diff options
author | Dhananjay Phadke <dhananjay@netxen.com> | 2009-08-13 03:03:01 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-08-13 19:33:04 -0400 |
commit | 232e7d68d50c9ac3a55d716e5ae215ecd1e043b9 (patch) | |
tree | 2367d09f6c2a6f9edc7f674f27dfb987968083fa /drivers | |
parent | e424fa9d6a0add1a9b812b07e3607daaa5b9e53d (diff) |
netxen: free napi resources during detach
o Defer napi resouce allocation to device attach.
o Free napi resources and delete napi during detach.
This ensures right behavior across firmware reset.
Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/netxen/netxen_nic_init.c | 7 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_main.c | 32 |
2 files changed, 24 insertions, 15 deletions
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index 7acf204e38c9..5d3343ef3d86 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c | |||
@@ -184,13 +184,6 @@ void netxen_free_sw_resources(struct netxen_adapter *adapter) | |||
184 | kfree(recv_ctx->rds_rings); | 184 | kfree(recv_ctx->rds_rings); |
185 | 185 | ||
186 | skip_rds: | 186 | skip_rds: |
187 | if (recv_ctx->sds_rings == NULL) | ||
188 | goto skip_sds; | ||
189 | |||
190 | for(ring = 0; ring < adapter->max_sds_rings; ring++) | ||
191 | recv_ctx->sds_rings[ring].consumer = 0; | ||
192 | |||
193 | skip_sds: | ||
194 | if (adapter->tx_ring == NULL) | 187 | if (adapter->tx_ring == NULL) |
195 | return; | 188 | return; |
196 | 189 | ||
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index d24e1cb93a26..28f270f5ac78 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -167,6 +167,8 @@ netxen_free_sds_rings(struct netxen_recv_context *recv_ctx) | |||
167 | { | 167 | { |
168 | if (recv_ctx->sds_rings != NULL) | 168 | if (recv_ctx->sds_rings != NULL) |
169 | kfree(recv_ctx->sds_rings); | 169 | kfree(recv_ctx->sds_rings); |
170 | |||
171 | recv_ctx->sds_rings = NULL; | ||
170 | } | 172 | } |
171 | 173 | ||
172 | static int | 174 | static int |
@@ -189,6 +191,21 @@ netxen_napi_add(struct netxen_adapter *adapter, struct net_device *netdev) | |||
189 | } | 191 | } |
190 | 192 | ||
191 | static void | 193 | static void |
194 | netxen_napi_del(struct netxen_adapter *adapter) | ||
195 | { | ||
196 | int ring; | ||
197 | struct nx_host_sds_ring *sds_ring; | ||
198 | struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; | ||
199 | |||
200 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { | ||
201 | sds_ring = &recv_ctx->sds_rings[ring]; | ||
202 | netif_napi_del(&sds_ring->napi); | ||
203 | } | ||
204 | |||
205 | netxen_free_sds_rings(&adapter->recv_ctx); | ||
206 | } | ||
207 | |||
208 | static void | ||
192 | netxen_napi_enable(struct netxen_adapter *adapter) | 209 | netxen_napi_enable(struct netxen_adapter *adapter) |
193 | { | 210 | { |
194 | int ring; | 211 | int ring; |
@@ -889,10 +906,12 @@ netxen_nic_attach(struct netxen_adapter *adapter) | |||
889 | struct nx_host_tx_ring *tx_ring; | 906 | struct nx_host_tx_ring *tx_ring; |
890 | 907 | ||
891 | err = netxen_init_firmware(adapter); | 908 | err = netxen_init_firmware(adapter); |
892 | if (err != 0) { | 909 | if (err) |
893 | printk(KERN_ERR "Failed to init firmware\n"); | 910 | return err; |
894 | return -EIO; | 911 | |
895 | } | 912 | err = netxen_napi_add(adapter, netdev); |
913 | if (err) | ||
914 | return err; | ||
896 | 915 | ||
897 | if (adapter->fw_major < 4) | 916 | if (adapter->fw_major < 4) |
898 | adapter->max_rds_rings = 3; | 917 | adapter->max_rds_rings = 3; |
@@ -956,6 +975,7 @@ netxen_nic_detach(struct netxen_adapter *adapter) | |||
956 | netxen_free_hw_resources(adapter); | 975 | netxen_free_hw_resources(adapter); |
957 | netxen_release_rx_buffers(adapter); | 976 | netxen_release_rx_buffers(adapter); |
958 | netxen_nic_free_irq(adapter); | 977 | netxen_nic_free_irq(adapter); |
978 | netxen_napi_del(adapter); | ||
959 | netxen_free_sw_resources(adapter); | 979 | netxen_free_sw_resources(adapter); |
960 | 980 | ||
961 | adapter->is_up = 0; | 981 | adapter->is_up = 0; |
@@ -1100,9 +1120,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1100 | 1120 | ||
1101 | netdev->irq = adapter->msix_entries[0].vector; | 1121 | netdev->irq = adapter->msix_entries[0].vector; |
1102 | 1122 | ||
1103 | if (netxen_napi_add(adapter, netdev)) | ||
1104 | goto err_out_disable_msi; | ||
1105 | |||
1106 | init_timer(&adapter->watchdog_timer); | 1123 | init_timer(&adapter->watchdog_timer); |
1107 | adapter->watchdog_timer.function = &netxen_watchdog; | 1124 | adapter->watchdog_timer.function = &netxen_watchdog; |
1108 | adapter->watchdog_timer.data = (unsigned long)adapter; | 1125 | adapter->watchdog_timer.data = (unsigned long)adapter; |
@@ -1183,7 +1200,6 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) | |||
1183 | netxen_free_adapter_offload(adapter); | 1200 | netxen_free_adapter_offload(adapter); |
1184 | 1201 | ||
1185 | netxen_teardown_intr(adapter); | 1202 | netxen_teardown_intr(adapter); |
1186 | netxen_free_sds_rings(&adapter->recv_ctx); | ||
1187 | 1203 | ||
1188 | netxen_cleanup_pci_map(adapter); | 1204 | netxen_cleanup_pci_map(adapter); |
1189 | 1205 | ||