Skip to content

Commit

Permalink
netxen: download firmware in pci probe
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dhananjay Phadke authored and Jeff Garzik committed Jun 18, 2008
1 parent dcd56fd commit 439b454
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 59 deletions.
24 changes: 20 additions & 4 deletions drivers/net/netxen/netxen_nic_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
}
}

Expand Down
65 changes: 10 additions & 55 deletions drivers/net/netxen/netxen_nic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)));

/*
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 439b454

Please sign in to comment.