Module Name: src Committed By: knakahara Date: Tue Apr 17 05:23:58 UTC 2018
Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h Log Message: Fix panic when "sysctl -w hw.ixg0.txrx_workqueue=[01]" while there is traffic. The operation is not supported, however causing panic is problem. To generate a diff of this commit: cvs rdiff -u -r1.146 -r1.147 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.41 -r1.42 src/sys/dev/pci/ixgbe/ixgbe.h 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/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.146 src/sys/dev/pci/ixgbe/ixgbe.c:1.147 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.146 Thu Apr 12 08:03:55 2018 +++ src/sys/dev/pci/ixgbe/ixgbe.c Tue Apr 17 05:23:58 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.146 2018/04/12 08:03:55 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.147 2018/04/17 05:23:58 knakahara Exp $ */ /****************************************************************************** @@ -2487,7 +2487,7 @@ static inline void ixgbe_sched_handle_que(struct adapter *adapter, struct ix_queue *que) { - if (adapter->txrx_use_workqueue) { + if(que->txrx_use_workqueue) { /* * adapter->que_wq is bound to each CPU instead of * each NIC queue to reduce workqueue kthread. As we @@ -2531,6 +2531,12 @@ ixgbe_msix_que(void *arg) ixgbe_disable_queue(adapter, que->msix); ++que->irqs.ev_count; + /* + * Don't change "que->txrx_use_workqueue" from this point to avoid + * flip-flopping softint/workqueue mode in one deferred processing. + */ + que->txrx_use_workqueue = adapter->txrx_use_workqueue; + #ifdef __NetBSD__ /* Don't run ixgbe_rxeof in interrupt context */ more = true; @@ -3174,6 +3180,16 @@ ixgbe_add_device_sysctls(struct adapter CTL_EOL) != 0) aprint_error_dev(dev, "could not create sysctl\n"); + /* + * If each "que->txrx_use_workqueue" is changed in sysctl handler, + * it causesflip-flopping softint/workqueue mode in one deferred + * processing. Therefore, preempt_disable()/preempt_enable() are + * required in ixgbe_sched_handle_que() to avoid + * KASSERT(ixgbe_sched_handle_que()) in softint_schedule(). + * I think changing "que->txrx_use_workqueue" in interrupt handler + * is lighter than doing preempt_disable()/preempt_enable() in every + * ixgbe_sched_handle_que(). + */ adapter->txrx_use_workqueue = ixgbe_txrx_workqueue; if (sysctl_createv(log, 0, &rnode, &cnode, CTLFLAG_READWRITE, CTLTYPE_BOOL, "txrx_workqueue", SYSCTL_DESCR("Use workqueue for packet processing"), @@ -4798,6 +4814,11 @@ ixgbe_legacy_irq(void *arg) } if ((ifp->if_flags & IFF_RUNNING) != 0) { + /* + * The same as ixgbe_msix_que() about "que->txrx_use_workqueue". + */ + que->txrx_use_workqueue = adapter->txrx_use_workqueue; + #ifdef __NetBSD__ /* Don't run ixgbe_rxeof in interrupt context */ more = true; Index: src/sys/dev/pci/ixgbe/ixgbe.h diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.41 src/sys/dev/pci/ixgbe/ixgbe.h:1.42 --- src/sys/dev/pci/ixgbe/ixgbe.h:1.41 Wed Apr 4 08:13:07 2018 +++ src/sys/dev/pci/ixgbe/ixgbe.h Tue Apr 17 05:23:58 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.h,v 1.41 2018/04/04 08:13:07 msaitoh Exp $ */ +/* $NetBSD: ixgbe.h,v 1.42 2018/04/17 05:23:58 knakahara Exp $ */ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause @@ -346,6 +346,7 @@ struct ix_queue { * > 0 : this queue is disabled * the value is ixgbe_disable_queue() called count */ + bool txrx_use_workqueue; }; /*