提交 1ab00629 编写于 作者: S Steve Hodgson 提交者: David S. Miller

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: NBen Hutchings <bhutchings@solarflare.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 65f667fb
...@@ -39,6 +39,12 @@ ...@@ -39,6 +39,12 @@
*/ */
static struct workqueue_struct *refill_workqueue; static struct workqueue_struct *refill_workqueue;
/* Reset workqueue. If any NIC has a hardware failure then a reset will be
* queued onto this work queue. This is not a per-nic work queue, because
* efx_reset_work() acquires the rtnl lock, so resets are naturally serialised.
*/
static struct workqueue_struct *reset_workqueue;
/************************************************************************** /**************************************************************************
* *
* Configurable values * Configurable values
...@@ -1697,7 +1703,7 @@ void efx_schedule_reset(struct efx_nic *efx, enum reset_type type) ...@@ -1697,7 +1703,7 @@ void efx_schedule_reset(struct efx_nic *efx, enum reset_type type)
efx->reset_pending = method; efx->reset_pending = method;
queue_work(efx->reset_workqueue, &efx->reset_work); queue_work(reset_workqueue, &efx->reset_work);
} }
/************************************************************************** /**************************************************************************
...@@ -1763,7 +1769,7 @@ static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type, ...@@ -1763,7 +1769,7 @@ static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type,
struct efx_channel *channel; struct efx_channel *channel;
struct efx_tx_queue *tx_queue; struct efx_tx_queue *tx_queue;
struct efx_rx_queue *rx_queue; struct efx_rx_queue *rx_queue;
int i, rc; int i;
/* Initialise common structures */ /* Initialise common structures */
memset(efx, 0, sizeof(*efx)); memset(efx, 0, sizeof(*efx));
...@@ -1832,33 +1838,14 @@ static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type, ...@@ -1832,33 +1838,14 @@ static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type,
interrupt_mode); interrupt_mode);
efx->workqueue = create_singlethread_workqueue("sfc_work"); efx->workqueue = create_singlethread_workqueue("sfc_work");
if (!efx->workqueue) { if (!efx->workqueue)
rc = -ENOMEM; return -ENOMEM;
goto fail1;
}
efx->reset_workqueue = create_singlethread_workqueue("sfc_reset");
if (!efx->reset_workqueue) {
rc = -ENOMEM;
goto fail2;
}
return 0; return 0;
fail2:
destroy_workqueue(efx->workqueue);
efx->workqueue = NULL;
fail1:
return rc;
} }
static void efx_fini_struct(struct efx_nic *efx) static void efx_fini_struct(struct efx_nic *efx)
{ {
if (efx->reset_workqueue) {
destroy_workqueue(efx->reset_workqueue);
efx->reset_workqueue = NULL;
}
if (efx->workqueue) { if (efx->workqueue) {
destroy_workqueue(efx->workqueue); destroy_workqueue(efx->workqueue);
efx->workqueue = NULL; efx->workqueue = NULL;
...@@ -1923,7 +1910,7 @@ static void efx_pci_remove(struct pci_dev *pci_dev) ...@@ -1923,7 +1910,7 @@ static void efx_pci_remove(struct pci_dev *pci_dev)
* scheduled from this point because efx_stop_all() has been * scheduled from this point because efx_stop_all() has been
* called, we are no longer registered with driverlink, and * called, we are no longer registered with driverlink, and
* the net_device's have been removed. */ * the net_device's have been removed. */
flush_workqueue(efx->reset_workqueue); cancel_work_sync(&efx->reset_work);
efx_pci_remove_main(efx); efx_pci_remove_main(efx);
...@@ -2045,7 +2032,7 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev, ...@@ -2045,7 +2032,7 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev,
* scheduled since efx_stop_all() has been called, and we * scheduled since efx_stop_all() has been called, and we
* have not and never have been registered with either * have not and never have been registered with either
* the rtnetlink or driverlink layers. */ * the rtnetlink or driverlink layers. */
flush_workqueue(efx->reset_workqueue); cancel_work_sync(&efx->reset_work);
/* Retry if a recoverably reset event has been scheduled */ /* Retry if a recoverably reset event has been scheduled */
if ((efx->reset_pending != RESET_TYPE_INVISIBLE) && if ((efx->reset_pending != RESET_TYPE_INVISIBLE) &&
...@@ -2121,6 +2108,11 @@ static int __init efx_init_module(void) ...@@ -2121,6 +2108,11 @@ static int __init efx_init_module(void)
rc = -ENOMEM; rc = -ENOMEM;
goto err_refill; goto err_refill;
} }
reset_workqueue = create_singlethread_workqueue("sfc_reset");
if (!reset_workqueue) {
rc = -ENOMEM;
goto err_reset;
}
rc = pci_register_driver(&efx_pci_driver); rc = pci_register_driver(&efx_pci_driver);
if (rc < 0) if (rc < 0)
...@@ -2129,6 +2121,8 @@ static int __init efx_init_module(void) ...@@ -2129,6 +2121,8 @@ static int __init efx_init_module(void)
return 0; return 0;
err_pci: err_pci:
destroy_workqueue(reset_workqueue);
err_reset:
destroy_workqueue(refill_workqueue); destroy_workqueue(refill_workqueue);
err_refill: err_refill:
unregister_netdevice_notifier(&efx_netdev_notifier); unregister_netdevice_notifier(&efx_netdev_notifier);
...@@ -2141,6 +2135,7 @@ static void __exit efx_exit_module(void) ...@@ -2141,6 +2135,7 @@ static void __exit efx_exit_module(void)
printk(KERN_INFO "Solarflare NET driver unloading\n"); printk(KERN_INFO "Solarflare NET driver unloading\n");
pci_unregister_driver(&efx_pci_driver); pci_unregister_driver(&efx_pci_driver);
destroy_workqueue(reset_workqueue);
destroy_workqueue(refill_workqueue); destroy_workqueue(refill_workqueue);
unregister_netdevice_notifier(&efx_netdev_notifier); unregister_netdevice_notifier(&efx_netdev_notifier);
......
...@@ -635,7 +635,6 @@ union efx_multicast_hash { ...@@ -635,7 +635,6 @@ union efx_multicast_hash {
* @legacy_irq: IRQ number * @legacy_irq: IRQ number
* @workqueue: Workqueue for port reconfigures and the HW monitor. * @workqueue: Workqueue for port reconfigures and the HW monitor.
* Work items do not hold and must not acquire RTNL. * Work items do not hold and must not acquire RTNL.
* @reset_workqueue: Workqueue for resets. Work item will acquire RTNL.
* @reset_work: Scheduled reset workitem * @reset_work: Scheduled reset workitem
* @monitor_work: Hardware monitor workitem * @monitor_work: Hardware monitor workitem
* @membase_phys: Memory BAR value as physical address * @membase_phys: Memory BAR value as physical address
...@@ -711,7 +710,6 @@ struct efx_nic { ...@@ -711,7 +710,6 @@ struct efx_nic {
const struct efx_nic_type *type; const struct efx_nic_type *type;
int legacy_irq; int legacy_irq;
struct workqueue_struct *workqueue; struct workqueue_struct *workqueue;
struct workqueue_struct *reset_workqueue;
struct work_struct reset_work; struct work_struct reset_work;
struct delayed_work monitor_work; struct delayed_work monitor_work;
resource_size_t membase_phys; resource_size_t membase_phys;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册