Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci/ixgbe Free jumbo mem structure correctly. Found ...



details:   https://anonhg.NetBSD.org/src/rev/5035c29a5ad4
branches:  trunk
changeset: 1006589:5035c29a5ad4
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Jan 20 07:19:04 2020 +0000

description:
Free jumbo mem structure correctly. Found by yamaguchi@ using with LOCKDEBUG.

diffstat:

 sys/dev/pci/ixgbe/ix_txrx.c      |   6 ++++-
 sys/dev/pci/ixgbe/ixgbe.h        |   3 +-
 sys/dev/pci/ixgbe/ixgbe_netbsd.c |  41 ++++++++++++++++++++++++++++++++-------
 3 files changed, 40 insertions(+), 10 deletions(-)

diffs (106 lines):

diff -r 4d2d15b26c8c -r 5035c29a5ad4 sys/dev/pci/ixgbe/ix_txrx.c
--- a/sys/dev/pci/ixgbe/ix_txrx.c       Mon Jan 20 06:55:35 2020 +0000
+++ b/sys/dev/pci/ixgbe/ix_txrx.c       Mon Jan 20 07:19:04 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.58 2019/12/16 02:50:54 msaitoh Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.59 2020/01/20 07:19:04 msaitoh Exp $ */
 
 /******************************************************************************
 
@@ -1681,6 +1681,10 @@
                                rxbuf->pmap = NULL;
                        }
                }
+
+               /* NetBSD specific. See ixgbe_netbsd.c */
+               ixgbe_jcl_destroy(adapter, rxr);
+
                if (rxr->rx_buffers != NULL) {
                        free(rxr->rx_buffers, M_DEVBUF);
                        rxr->rx_buffers = NULL;
diff -r 4d2d15b26c8c -r 5035c29a5ad4 sys/dev/pci/ixgbe/ixgbe.h
--- a/sys/dev/pci/ixgbe/ixgbe.h Mon Jan 20 06:55:35 2020 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.h Mon Jan 20 07:19:04 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.h,v 1.60 2019/12/16 02:50:54 msaitoh Exp $ */
+/* $NetBSD: ixgbe.h,v 1.61 2020/01/20 07:19:04 msaitoh Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -780,6 +780,7 @@
 /* For NetBSD */
 void ixgbe_jcl_reinit(struct adapter *, bus_dma_tag_t, struct rx_ring *,
     int, size_t);
+void ixgbe_jcl_destroy(struct adapter *,  struct rx_ring *);
 
 #include "ixgbe_bypass.h"
 #include "ixgbe_fdir.h"
diff -r 4d2d15b26c8c -r 5035c29a5ad4 sys/dev/pci/ixgbe/ixgbe_netbsd.c
--- a/sys/dev/pci/ixgbe/ixgbe_netbsd.c  Mon Jan 20 06:55:35 2020 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe_netbsd.c  Mon Jan 20 07:19:04 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_netbsd.c,v 1.10 2019/09/04 07:29:34 msaitoh Exp $ */
+/* $NetBSD: ixgbe_netbsd.c,v 1.11 2020/01/20 07:19:04 msaitoh Exp $ */
 /*
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -161,6 +161,22 @@
        return NULL;
 }
 
+static void
+ixgbe_jcl_freeall(struct adapter *adapter, struct rx_ring *rxr)
+{
+       ixgbe_extmem_head_t *eh = &rxr->jcl_head;
+       ixgbe_extmem_t *em;
+       bus_dma_tag_t dmat = rxr->ptag->dt_dmat;
+
+       while ((em = ixgbe_getext(eh, 0)) != NULL) {
+               KASSERT(em->em_vaddr != NULL);
+               bus_dmamem_unmap(dmat, em->em_vaddr, em->em_size);
+               bus_dmamem_free(dmat, &em->em_seg, 1);
+               memset(em, 0, sizeof(*em));
+               kmem_free(em, sizeof(*em));
+       }
+}
+
 void
 ixgbe_jcl_reinit(struct adapter *adapter, bus_dma_tag_t dmat,
     struct rx_ring *rxr, int nbuf, size_t size)
@@ -187,13 +203,7 @@
                return;
 
        /* Free all dmamem */
-       while ((em = ixgbe_getext(eh, 0)) != NULL) {
-               KASSERT(em->em_vaddr != NULL);
-               bus_dmamem_unmap(dmat, em->em_vaddr, em->em_size);
-               bus_dmamem_free(dmat, &em->em_seg, 1);
-               memset(em, 0, sizeof(*em));
-               kmem_free(em, sizeof(*em));
-       }
+       ixgbe_jcl_freeall(adapter, rxr);
 
        for (i = 0; i < nbuf; i++) {
                if ((em = ixgbe_newext(eh, dmat, size)) == NULL) {
@@ -210,6 +220,21 @@
        rxr->last_num_rx_desc = adapter->num_rx_desc;
 }
 
+void
+ixgbe_jcl_destroy(struct adapter *adapter, struct rx_ring *rxr)
+{
+       ixgbe_extmem_head_t *eh = &rxr->jcl_head;
+
+       /* Free all dmamem */
+       ixgbe_jcl_freeall(adapter, rxr);
+
+       if (eh->eh_initialized) {
+               mutex_destroy(&eh->eh_mtx);
+               eh->eh_initialized = false;
+       }
+}
+
+
 static void
 ixgbe_jcl_free(struct mbuf *m, void *buf, size_t size, void *arg)
 {



Home | Main Index | Thread Index | Old Index