Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sfc: Make reset_workqueue driver-global rather than per-NIC

Each reset is serialised by the rtnl_lock anyway, so there's no win
per-NIC.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Steve Hodgson and committed by
David S. Miller
1ab00629 65f667fb

+20 -27
+20 -25
drivers/net/sfc/efx.c
··· 39 39 */ 40 40 static struct workqueue_struct *refill_workqueue; 41 41 42 + /* Reset workqueue. If any NIC has a hardware failure then a reset will be 43 + * queued onto this work queue. This is not a per-nic work queue, because 44 + * efx_reset_work() acquires the rtnl lock, so resets are naturally serialised. 45 + */ 46 + static struct workqueue_struct *reset_workqueue; 47 + 42 48 /************************************************************************** 43 49 * 44 50 * Configurable values ··· 1703 1697 1704 1698 efx->reset_pending = method; 1705 1699 1706 - queue_work(efx->reset_workqueue, &efx->reset_work); 1700 + queue_work(reset_workqueue, &efx->reset_work); 1707 1701 } 1708 1702 1709 1703 /************************************************************************** ··· 1769 1763 struct efx_channel *channel; 1770 1764 struct efx_tx_queue *tx_queue; 1771 1765 struct efx_rx_queue *rx_queue; 1772 - int i, rc; 1766 + int i; 1773 1767 1774 1768 /* Initialise common structures */ 1775 1769 memset(efx, 0, sizeof(*efx)); ··· 1838 1832 interrupt_mode); 1839 1833 1840 1834 efx->workqueue = create_singlethread_workqueue("sfc_work"); 1841 - if (!efx->workqueue) { 1842 - rc = -ENOMEM; 1843 - goto fail1; 1844 - } 1845 - 1846 - efx->reset_workqueue = create_singlethread_workqueue("sfc_reset"); 1847 - if (!efx->reset_workqueue) { 1848 - rc = -ENOMEM; 1849 - goto fail2; 1850 - } 1835 + if (!efx->workqueue) 1836 + return -ENOMEM; 1851 1837 1852 1838 return 0; 1853 - 1854 - fail2: 1855 - destroy_workqueue(efx->workqueue); 1856 - efx->workqueue = NULL; 1857 - 1858 - fail1: 1859 - return rc; 1860 1839 } 1861 1840 1862 1841 static void efx_fini_struct(struct efx_nic *efx) 1863 1842 { 1864 - if (efx->reset_workqueue) { 1865 - destroy_workqueue(efx->reset_workqueue); 1866 - efx->reset_workqueue = NULL; 1867 - } 1868 1843 if (efx->workqueue) { 1869 1844 destroy_workqueue(efx->workqueue); 1870 1845 efx->workqueue = NULL; ··· 1910 1923 * scheduled from this point because efx_stop_all() has been 1911 1924 * called, we are no longer registered with driverlink, and 1912 1925 * the net_device's have been removed. */ 1913 - flush_workqueue(efx->reset_workqueue); 1926 + cancel_work_sync(&efx->reset_work); 1914 1927 1915 1928 efx_pci_remove_main(efx); 1916 1929 ··· 2032 2045 * scheduled since efx_stop_all() has been called, and we 2033 2046 * have not and never have been registered with either 2034 2047 * the rtnetlink or driverlink layers. */ 2035 - flush_workqueue(efx->reset_workqueue); 2048 + cancel_work_sync(&efx->reset_work); 2036 2049 2037 2050 /* Retry if a recoverably reset event has been scheduled */ 2038 2051 if ((efx->reset_pending != RESET_TYPE_INVISIBLE) && ··· 2108 2121 rc = -ENOMEM; 2109 2122 goto err_refill; 2110 2123 } 2124 + reset_workqueue = create_singlethread_workqueue("sfc_reset"); 2125 + if (!reset_workqueue) { 2126 + rc = -ENOMEM; 2127 + goto err_reset; 2128 + } 2111 2129 2112 2130 rc = pci_register_driver(&efx_pci_driver); 2113 2131 if (rc < 0) ··· 2121 2129 return 0; 2122 2130 2123 2131 err_pci: 2132 + destroy_workqueue(reset_workqueue); 2133 + err_reset: 2124 2134 destroy_workqueue(refill_workqueue); 2125 2135 err_refill: 2126 2136 unregister_netdevice_notifier(&efx_netdev_notifier); ··· 2135 2141 printk(KERN_INFO "Solarflare NET driver unloading\n"); 2136 2142 2137 2143 pci_unregister_driver(&efx_pci_driver); 2144 + destroy_workqueue(reset_workqueue); 2138 2145 destroy_workqueue(refill_workqueue); 2139 2146 unregister_netdevice_notifier(&efx_netdev_notifier); 2140 2147
-2
drivers/net/sfc/net_driver.h
··· 635 635 * @legacy_irq: IRQ number 636 636 * @workqueue: Workqueue for port reconfigures and the HW monitor. 637 637 * Work items do not hold and must not acquire RTNL. 638 - * @reset_workqueue: Workqueue for resets. Work item will acquire RTNL. 639 638 * @reset_work: Scheduled reset workitem 640 639 * @monitor_work: Hardware monitor workitem 641 640 * @membase_phys: Memory BAR value as physical address ··· 710 711 const struct efx_nic_type *type; 711 712 int legacy_irq; 712 713 struct workqueue_struct *workqueue; 713 - struct workqueue_struct *reset_workqueue; 714 714 struct work_struct reset_work; 715 715 struct delayed_work monitor_work; 716 716 resource_size_t membase_phys;