netxen: download firmware in pci probe
authorDhananjay Phadke <dhananjay@netxen.com>
Mon, 16 Jun 2008 05:59:46 +0000 (22:59 -0700)
committerJeff Garzik <jgarzik@redhat.com>
Wed, 18 Jun 2008 03:07:01 +0000 (23:07 -0400)
Downloading firmware in pci probe allows recovery in case of
firmware failure by reloading the driver.

Also reduced delays in firmware load.

Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
drivers/net/netxen/netxen_nic_init.c
drivers/net/netxen/netxen_nic_main.c

index f6aeccfa28318ba5207599b934b7b2a3a5b0194e..70d1b22ced220c601276f47a4e6e92b50a95f7a0 100644 (file)
@@ -840,10 +840,10 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
                                netxen_nic_pci_change_crbwindow(adapter, 1);
                        }
                        if (init_delay == 1) {
-                               msleep(2000);
+                               msleep(1000);
                                init_delay = 0;
                        }
-                       msleep(20);
+                       msleep(1);
                }
                kfree(buf);
 
@@ -918,12 +918,28 @@ int netxen_initialize_adapter_offload(struct netxen_adapter *adapter)
 
 void netxen_free_adapter_offload(struct netxen_adapter *adapter)
 {
+       int i;
+
        if (adapter->dummy_dma.addr) {
-               pci_free_consistent(adapter->ahw.pdev,
+               i = 100;
+               do {
+                       if (dma_watchdog_shutdown_request(adapter) == 1)
+                               break;
+                       msleep(50);
+                       if (dma_watchdog_shutdown_poll_result(adapter) == 1)
+                               break;
+               } while (--i);
+
+               if (i) {
+                       pci_free_consistent(adapter->ahw.pdev,
                                    NETXEN_HOST_DUMMY_DMA_SIZE,
                                    adapter->dummy_dma.addr,
                                    adapter->dummy_dma.phys_addr);
-               adapter->dummy_dma.addr = NULL;
+                       adapter->dummy_dma.addr = NULL;
+               } else {
+                       printk(KERN_ERR "%s: dma_watchdog_shutdown failed\n",
+                                       adapter->netdev->name);
+               }
        }
 }
 
index 755f4abe2f5500e0f5cf202d26838cee806d829d..6797ed069f1f43ed659147da5d925bda1036e9e8 100644 (file)
@@ -543,14 +543,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                break;
        }
 
-#ifdef CONFIG_IA64
-       if(adapter->portnum == 0) {
-               netxen_pinit_from_rom(adapter, 0);
-               udelay(500);
-               netxen_load_firmware(adapter);
-       }
-#endif
-
        init_timer(&adapter->watchdog_timer);
        adapter->ahw.xg_linkup = 0;
        adapter->watchdog_timer.function = &netxen_watchdog;
@@ -622,11 +614,18 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                                err = -ENODEV;
                                goto err_out_free_dev;
                    }
+               } else {
+                       writel(0, NETXEN_CRB_NORMALIZE(adapter,
+                                               CRB_CMDPEG_STATE));
+                       netxen_pinit_from_rom(adapter, 0);
+                       msleep(1);
+                       netxen_load_firmware(adapter);
+                       netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
                }
 
                /* clear the register for future unloads/loads */
                writel(0, NETXEN_CRB_NORMALIZE(adapter, NETXEN_CAM_RAM(0x1fc)));
-               printk(KERN_DEBUG "State: 0x%0x\n",
+               dev_info(&pdev->dev, "cmdpeg state: 0x%0x\n",
                        readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)));
 
                /*
@@ -757,52 +756,8 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
 
        vfree(adapter->cmd_buf_arr);
 
-       if (adapter->portnum == 0) {
-               if (init_firmware_done) {
-                       i = 100;
-                       do {
-                               if (dma_watchdog_shutdown_request(adapter) == 1)
-                                       break;
-                               msleep(100);
-                               if (dma_watchdog_shutdown_poll_result(adapter) == 1)
-                                       break;
-                       } while (--i);
-
-                       if (i == 0)
-                               printk(KERN_ERR "%s: dma_watchdog_shutdown failed\n",
-                                               netdev->name);
-
-                       /* clear the register for future unloads/loads */
-                       writel(0, NETXEN_CRB_NORMALIZE(adapter, NETXEN_CAM_RAM(0x1fc)));
-                       /* leave the hw in the same state as reboot */
-                       writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
-                       netxen_pinit_from_rom(adapter, 0);
-                       msleep(1);
-                       netxen_load_firmware(adapter);
-                       netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
-               }
-
-               /* clear the register for future unloads/loads */
-               writel(0, NETXEN_CRB_NORMALIZE(adapter, NETXEN_CAM_RAM(0x1fc)));
-               printk(KERN_DEBUG "State: 0x%0x\n",
-                       readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)));
-
-               i = 100;
-               do {
-                       if (dma_watchdog_shutdown_request(adapter) == 1)
-                               break;
-                       msleep(100);
-                       if (dma_watchdog_shutdown_poll_result(adapter) == 1)
-                               break;
-               } while (--i);
-
-               if (i) {
-                       netxen_free_adapter_offload(adapter);
-               } else {
-                       printk(KERN_ERR "%s: dma_watchdog_shutdown failed\n",
-                                       netdev->name);
-               }
-       }
+       if (adapter->portnum == 0)
+               netxen_free_adapter_offload(adapter);
 
        if (adapter->irq)
                free_irq(adapter->irq, adapter);