aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen/netxen_nic_init.c
diff options
context:
space:
mode:
authorDhananjay Phadke <dhananjay@netxen.com>2007-07-02 00:07:57 -0400
committerJeff Garzik <jeff@garzik.org>2007-07-02 08:24:52 -0400
commit96acb6eb8effe7c2549909e2ee49f4130f2c167d (patch)
tree5f6049fe53d9305f7edb45e4ed94aed59f66aef7 /drivers/net/netxen/netxen_nic_init.c
parentd14e37e12087e98b63907518dff83a90297605d6 (diff)
RESEND [PATCH 3/3] NetXen: Graceful teardown of interface and hardware upon module unload
Resending patch 3/3 only. These changes allow driver close routine to be called during module unload, to clean-up buffers and other software resources, flush queues etc. Also, hardware is reset to pristine state. Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com> Signed-off-by: Milan Bag <mbag@netxen.com> Signed-off-by: Wen Xiong <wenxiong@us.ibm.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/netxen/netxen_nic_init.c')
-rw-r--r--drivers/net/netxen/netxen_nic_init.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 15f6dc5a1cf7..1811bcb8c380 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -407,10 +407,7 @@ static inline int do_rom_fast_write(struct netxen_adapter *adapter, int addr,
407static inline int 407static inline int
408do_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp) 408do_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp)
409{ 409{
410 if (jiffies > (last_schedule_time + (8 * HZ))) { 410 cond_resched();
411 last_schedule_time = jiffies;
412 schedule();
413 }
414 411
415 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr); 412 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr);
416 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3); 413 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
@@ -856,10 +853,10 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
856 netxen_nic_pci_change_crbwindow(adapter, 1); 853 netxen_nic_pci_change_crbwindow(adapter, 1);
857 } 854 }
858 if (init_delay == 1) { 855 if (init_delay == 1) {
859 ssleep(1); 856 msleep(2000);
860 init_delay = 0; 857 init_delay = 0;
861 } 858 }
862 msleep(1); 859 msleep(20);
863 } 860 }
864 kfree(buf); 861 kfree(buf);
865 862
@@ -935,10 +932,6 @@ int netxen_initialize_adapter_offload(struct netxen_adapter *adapter)
935void netxen_free_adapter_offload(struct netxen_adapter *adapter) 932void netxen_free_adapter_offload(struct netxen_adapter *adapter)
936{ 933{
937 if (adapter->dummy_dma.addr) { 934 if (adapter->dummy_dma.addr) {
938 writel(0, NETXEN_CRB_NORMALIZE(adapter,
939 CRB_HOST_DUMMY_BUF_ADDR_HI));
940 writel(0, NETXEN_CRB_NORMALIZE(adapter,
941 CRB_HOST_DUMMY_BUF_ADDR_LO));
942 pci_free_consistent(adapter->ahw.pdev, 935 pci_free_consistent(adapter->ahw.pdev,
943 NETXEN_HOST_DUMMY_DMA_SIZE, 936 NETXEN_HOST_DUMMY_DMA_SIZE,
944 adapter->dummy_dma.addr, 937 adapter->dummy_dma.addr,
@@ -947,25 +940,32 @@ void netxen_free_adapter_offload(struct netxen_adapter *adapter)
947 } 940 }
948} 941}
949 942
950void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val) 943int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
951{ 944{
952 u32 val = 0; 945 u32 val = 0;
953 int loops = 0; 946 int retries = 30;
954 947
955 if (!pegtune_val) { 948 if (!pegtune_val) {
956 val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); 949 do {
957 while (val != PHAN_INITIALIZE_COMPLETE && 950 val = readl(NETXEN_CRB_NORMALIZE
958 val != PHAN_INITIALIZE_ACK && loops < 200000) {
959 udelay(100);
960 schedule();
961 val =
962 readl(NETXEN_CRB_NORMALIZE
963 (adapter, CRB_CMDPEG_STATE)); 951 (adapter, CRB_CMDPEG_STATE));
964 loops++; 952 pegtune_val = readl(NETXEN_CRB_NORMALIZE
953 (adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE));
954
955 if (val == PHAN_INITIALIZE_COMPLETE ||
956 val == PHAN_INITIALIZE_ACK)
957 return 0;
958
959 msleep(1000);
960 } while (--retries);
961 if (!retries) {
962 printk(KERN_WARNING "netxen_phantom_init: init failed, "
963 "pegtune_val=%x\n", pegtune_val);
964 return -1;
965 } 965 }
966 if (val != PHAN_INITIALIZE_COMPLETE)
967 printk("WARNING: Initial boot wait loop failed...\n");
968 } 966 }
967
968 return 0;
969} 969}
970 970
971int netxen_nic_rx_has_work(struct netxen_adapter *adapter) 971int netxen_nic_rx_has_work(struct netxen_adapter *adapter)
@@ -1122,6 +1122,7 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1122 adapter->stats.csummed++; 1122 adapter->stats.csummed++;
1123 skb->ip_summed = CHECKSUM_UNNECESSARY; 1123 skb->ip_summed = CHECKSUM_UNNECESSARY;
1124 } 1124 }
1125 skb->dev = netdev;
1125 if (desc_ctx == RCV_DESC_LRO_CTXID) { 1126 if (desc_ctx == RCV_DESC_LRO_CTXID) {
1126 /* True length was only available on the last pkt */ 1127 /* True length was only available on the last pkt */
1127 skb_put(skb, buffer->lro_length); 1128 skb_put(skb, buffer->lro_length);
@@ -1226,6 +1227,7 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
1226 NETXEN_CRB_NORMALIZE(adapter, 1227 NETXEN_CRB_NORMALIZE(adapter,
1227 recv_crb_registers[adapter->portnum]. 1228 recv_crb_registers[adapter->portnum].
1228 crb_rcv_status_consumer)); 1229 crb_rcv_status_consumer));
1230 wmb();
1229 } 1231 }
1230 1232
1231 return count; 1233 return count;
@@ -1278,11 +1280,13 @@ int netxen_process_cmd_ring(unsigned long data)
1278 if (skb && (cmpxchg(&buffer->skb, skb, 0) == skb)) { 1280 if (skb && (cmpxchg(&buffer->skb, skb, 0) == skb)) {
1279 pci_unmap_single(pdev, frag->dma, frag->length, 1281 pci_unmap_single(pdev, frag->dma, frag->length,
1280 PCI_DMA_TODEVICE); 1282 PCI_DMA_TODEVICE);
1283 frag->dma = 0ULL;
1281 for (i = 1; i < buffer->frag_count; i++) { 1284 for (i = 1; i < buffer->frag_count; i++) {
1282 DPRINTK(INFO, "getting fragment no %d\n", i); 1285 DPRINTK(INFO, "getting fragment no %d\n", i);
1283 frag++; /* Get the next frag */ 1286 frag++; /* Get the next frag */
1284 pci_unmap_page(pdev, frag->dma, frag->length, 1287 pci_unmap_page(pdev, frag->dma, frag->length,
1285 PCI_DMA_TODEVICE); 1288 PCI_DMA_TODEVICE);
1289 frag->dma = 0ULL;
1286 } 1290 }
1287 1291
1288 adapter->stats.skbfreed++; 1292 adapter->stats.skbfreed++;
@@ -1448,6 +1452,7 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1448 writel(msg, 1452 writel(msg,
1449 DB_NORMALIZE(adapter, 1453 DB_NORMALIZE(adapter,
1450 NETXEN_RCV_PRODUCER_OFFSET)); 1454 NETXEN_RCV_PRODUCER_OFFSET));
1455 wmb();
1451 } 1456 }
1452 } 1457 }
1453} 1458}