rt2x00: Properly clean up beacon skbs.
[safe/jmp/linux-2.6] / drivers / net / sfc / efx.c
index 3494f4c..74265d8 100644 (file)
@@ -199,11 +199,12 @@ static inline int efx_process_channel(struct efx_channel *channel, int rx_quota)
  */
 static inline void efx_channel_processed(struct efx_channel *channel)
 {
-       /* Write to EVQ_RPTR_REG.  If a new event arrived in a race
-        * with finishing processing, a new interrupt will be raised.
-        */
+       /* The interrupt handler for this channel may set work_pending
+        * as soon as we acknowledge the events we've seen.  Make sure
+        * it's cleared before then. */
        channel->work_pending = 0;
-       smp_wmb(); /* Ensure channel updated before any new interrupt. */
+       smp_wmb();
+
        falcon_eventq_read_ack(channel);
 }
 
@@ -427,9 +428,12 @@ static void efx_start_channel(struct efx_channel *channel)
                netif_napi_add(channel->napi_dev, &channel->napi_str,
                               efx_poll, napi_weight);
 
+       /* The interrupt handler for this channel may set work_pending
+        * as soon as we enable it.  Make sure it's cleared before
+        * then.  Similarly, make sure it sees the enabled flag set. */
        channel->work_pending = 0;
        channel->enabled = 1;
-       smp_wmb(); /* ensure channel updated before first interrupt */
+       smp_wmb();
 
        napi_enable(&channel->napi_str);
 
@@ -691,7 +695,7 @@ static void efx_stop_port(struct efx_nic *efx)
        mutex_unlock(&efx->mac_lock);
 
        /* Serialise against efx_set_multicast_list() */
-       if (NET_DEV_REGISTERED(efx)) {
+       if (efx_dev_registered(efx)) {
                netif_tx_lock_bh(efx->net_dev);
                netif_tx_unlock_bh(efx->net_dev);
        }
@@ -778,15 +782,16 @@ static int efx_init_io(struct efx_nic *efx)
        efx->membase = ioremap_nocache(efx->membase_phys,
                                       efx->type->mem_map_size);
        if (!efx->membase) {
-               EFX_ERR(efx, "could not map memory BAR %d at %lx+%x\n",
-                       efx->type->mem_bar, efx->membase_phys,
+               EFX_ERR(efx, "could not map memory BAR %d at %llx+%x\n",
+                       efx->type->mem_bar,
+                       (unsigned long long)efx->membase_phys,
                        efx->type->mem_map_size);
                rc = -ENOMEM;
                goto fail4;
        }
-       EFX_LOG(efx, "memory BAR %u at %lx+%x (virtual %p)\n",
-               efx->type->mem_bar, efx->membase_phys, efx->type->mem_map_size,
-               efx->membase);
+       EFX_LOG(efx, "memory BAR %u at %llx+%x (virtual %p)\n",
+               efx->type->mem_bar, (unsigned long long)efx->membase_phys,
+               efx->type->mem_map_size, efx->membase);
 
        return 0;
 
@@ -1030,7 +1035,7 @@ static void efx_start_all(struct efx_nic *efx)
                return;
        if ((efx->state != STATE_RUNNING) && (efx->state != STATE_INIT))
                return;
-       if (NET_DEV_REGISTERED(efx) && !netif_running(efx->net_dev))
+       if (efx_dev_registered(efx) && !netif_running(efx->net_dev))
                return;
 
        /* Mark the port as enabled so port reconfigurations can start, then
@@ -1060,9 +1065,8 @@ static void efx_flush_all(struct efx_nic *efx)
        cancel_delayed_work_sync(&efx->monitor_work);
 
        /* Ensure that all RX slow refills are complete. */
-       efx_for_each_rx_queue(rx_queue, efx) {
+       efx_for_each_rx_queue(rx_queue, efx)
                cancel_delayed_work_sync(&rx_queue->work);
-       }
 
        /* Stop scheduled port reconfigurations */
        cancel_work_sync(&efx->reconfigure_work);
@@ -1088,9 +1092,10 @@ static void efx_stop_all(struct efx_nic *efx)
        falcon_disable_interrupts(efx);
        if (efx->legacy_irq)
                synchronize_irq(efx->legacy_irq);
-       efx_for_each_channel_with_interrupt(channel, efx)
+       efx_for_each_channel_with_interrupt(channel, efx) {
                if (channel->irq)
                        synchronize_irq(channel->irq);
+       }
 
        /* Stop all NAPI processing and synchronous rx refills */
        efx_for_each_channel(channel, efx)
@@ -1112,7 +1117,7 @@ static void efx_stop_all(struct efx_nic *efx)
        /* Stop the kernel transmit interface late, so the watchdog
         * timer isn't ticking over the flush */
        efx_stop_queue(efx);
-       if (NET_DEV_REGISTERED(efx)) {
+       if (efx_dev_registered(efx)) {
                netif_tx_lock_bh(efx->net_dev);
                netif_tx_unlock_bh(efx->net_dev);
        }
@@ -1331,13 +1336,17 @@ static int efx_net_stop(struct net_device *net_dev)
        return 0;
 }
 
-/* Context: process, dev_base_lock held, non-blocking. */
+/* Context: process, dev_base_lock or RTNL held, non-blocking. */
 static struct net_device_stats *efx_net_stats(struct net_device *net_dev)
 {
        struct efx_nic *efx = net_dev->priv;
        struct efx_mac_stats *mac_stats = &efx->mac_stats;
        struct net_device_stats *stats = &net_dev->stats;
 
+       /* Update stats if possible, but do not wait if another thread
+        * is updating them (or resetting the NIC); slightly stale
+        * stats are acceptable.
+        */
        if (!spin_trylock(&efx->stats_lock))
                return stats;
        if (efx->state == STATE_RUNNING) {
@@ -1481,7 +1490,7 @@ static void efx_set_multicast_list(struct net_device *net_dev)
 static int efx_netdev_event(struct notifier_block *this,
                            unsigned long event, void *ptr)
 {
-       struct net_device *net_dev = (struct net_device *)ptr;
+       struct net_device *net_dev = ptr;
 
        if (net_dev->open == efx_net_open && event == NETDEV_CHANGENAME) {
                struct efx_nic *efx = net_dev->priv;
@@ -1550,7 +1559,7 @@ static void efx_unregister_netdev(struct efx_nic *efx)
        efx_for_each_tx_queue(tx_queue, efx)
                efx_release_tx_buffers(tx_queue);
 
-       if (NET_DEV_REGISTERED(efx)) {
+       if (efx_dev_registered(efx)) {
                strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name));
                unregister_netdev(efx->net_dev);
        }
@@ -1806,6 +1815,7 @@ static struct efx_board efx_dummy_board_info = {
        .init    = efx_nic_dummy_op_int,
        .init_leds = efx_port_dummy_op_int,
        .set_fault_led = efx_port_dummy_op_blink,
+       .fini   = efx_port_dummy_op_void,
 };
 
 /**************************************************************************
@@ -1932,6 +1942,7 @@ static void efx_pci_remove_main(struct efx_nic *efx)
        efx_fini_port(efx);
 
        /* Shutdown the board, then the NIC and board state */
+       efx->board_info.fini(efx);
        falcon_fini_interrupt(efx);
 
        efx_fini_napi(efx);