Module Name: src Committed By: msaitoh Date: Tue May 18 05:29:16 UTC 2021
Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c ixgbe.c ixv.c Log Message: - Cleanup an rxbuf entry when bus_dmamap_load_mbuf() failed to prevent panic. - Print error number when error occurred. To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/sys/dev/pci/ixgbe/ix_txrx.c cvs rdiff -u -r1.282 -r1.283 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.159 -r1.160 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.74 src/sys/dev/pci/ixgbe/ix_txrx.c:1.75 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.74 Fri May 14 05:15:17 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Tue May 18 05:29:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.74 2021/05/14 05:15:17 msaitoh Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.75 2021/05/18 05:29:15 msaitoh Exp $ */ /****************************************************************************** @@ -64,7 +64,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.74 2021/05/14 05:15:17 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.75 2021/05/18 05:29:15 msaitoh Exp $"); #include "opt_inet.h" #include "opt_inet6.h" @@ -1556,8 +1556,16 @@ ixgbe_setup_receive_ring(struct rx_ring /* Get the memory mapping */ error = bus_dmamap_load_mbuf(rxr->ptag->dt_dmat, rxbuf->pmap, mp, BUS_DMA_NOWAIT); - if (error != 0) + if (error != 0) { + /* + * Clear this entry for later cleanup in + * ixgbe_discard() which is called via + * ixgbe_free_receive_ring(). + */ + m_freem(mp); + rxbuf->buf = NULL; goto fail; + } bus_dmamap_sync(rxr->ptag->dt_dmat, rxbuf->pmap, 0, adapter->rx_mbuf_sz, BUS_DMASYNC_PREREAD); /* Update the descriptor and the cached value */ Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.282 src/sys/dev/pci/ixgbe/ixgbe.c:1.283 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.282 Fri May 7 09:15:52 2021 +++ src/sys/dev/pci/ixgbe/ixgbe.c Tue May 18 05:29:16 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.282 2021/05/07 09:15:52 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.283 2021/05/18 05:29:16 msaitoh Exp $ */ /****************************************************************************** @@ -64,7 +64,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.282 2021/05/07 09:15:52 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.283 2021/05/18 05:29:16 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -3984,7 +3984,7 @@ ixgbe_init_locked(struct adapter *adapte u32 rxdctl, rxctrl; u32 ctrl_ext; bool unsupported_sfp = false; - int i, j, err; + int i, j, error; /* XXX check IFF_UP and IFF_RUNNING, power-saving state! */ @@ -4042,8 +4042,10 @@ ixgbe_init_locked(struct adapter *adapte adapter->rx_mbuf_sz = MJUMPAGESIZE; /* Prepare receive descriptors and buffers */ - if (ixgbe_setup_receive_structures(adapter)) { - device_printf(dev, "Could not setup receive structures\n"); + error = ixgbe_setup_receive_structures(adapter); + if (error) { + device_printf(dev, + "Could not setup receive structures (err = %d)\n", error); ixgbe_stop_locked(adapter); return; } @@ -4173,8 +4175,8 @@ ixgbe_init_locked(struct adapter *adapte * need to be kick-started */ if (hw->phy.type == ixgbe_phy_none) { - err = hw->phy.ops.identify(hw); - if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) + error = hw->phy.ops.identify(hw); + if (error == IXGBE_ERR_SFP_NOT_SUPPORTED) unsupported_sfp = true; } else if (hw->phy.type == ixgbe_phy_sfp_unsupported) unsupported_sfp = true; Index: src/sys/dev/pci/ixgbe/ixv.c diff -u src/sys/dev/pci/ixgbe/ixv.c:1.159 src/sys/dev/pci/ixgbe/ixv.c:1.160 --- src/sys/dev/pci/ixgbe/ixv.c:1.159 Fri Apr 30 06:55:32 2021 +++ src/sys/dev/pci/ixgbe/ixv.c Tue May 18 05:29:16 2021 @@ -1,4 +1,4 @@ -/*$NetBSD: ixv.c,v 1.159 2021/04/30 06:55:32 msaitoh Exp $*/ +/*$NetBSD: ixv.c,v 1.160 2021/05/18 05:29:16 msaitoh Exp $*/ /****************************************************************************** @@ -35,7 +35,7 @@ /*$FreeBSD: head/sys/dev/ixgbe/if_ixv.c 331224 2018-03-19 20:55:05Z erj $*/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ixv.c,v 1.159 2021/04/30 06:55:32 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixv.c,v 1.160 2021/05/18 05:29:16 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -756,8 +756,10 @@ ixv_init_locked(struct adapter *adapter) adapter->rx_mbuf_sz = MJUMPAGESIZE; /* Prepare receive descriptors and buffers */ - if (ixgbe_setup_receive_structures(adapter)) { - device_printf(dev, "Could not setup receive structures\n"); + error = ixgbe_setup_receive_structures(adapter); + if (error) { + device_printf(dev, + "Could not setup receive structures (err = %d)\n", error); ixv_stop_locked(adapter); return; }