]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
netxen: fix crashes during module unload
authordhananjay@netxen.com <dhananjay@netxen.com>
Tue, 28 Aug 2007 11:53:26 +0000 (17:23 +0530)
committerJeff Garzik <jeff@garzik.org>
Fri, 31 Aug 2007 10:52:57 +0000 (06:52 -0400)
This patch fixes two problems during driver unload. The pci_disable_device()
call is before firmware reload, causing reads and writes across PCI bus after
disabling device. Second problem is the register window was wrong during
firmware reload

Signed-off by: Dhananjay Phadke <dhananjay@netxen.com>

Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/netxen/netxen_nic_hdr.h
drivers/net/netxen/netxen_nic_hw.c
drivers/net/netxen/netxen_nic_main.c

index 3276866b17e2c17cc27446f42d42072b708c1687..d72f8f8fcb50b58f1ffce626dd6da44a6de31216 100644 (file)
@@ -649,9 +649,11 @@ enum {
 #define PCIX_INT_VECTOR                (0x10100)
 #define PCIX_INT_MASK          (0x10104)
 
-#define PCIX_MN_WINDOW         (0x10200)
+#define PCIX_MN_WINDOW_F0      (0x10200)
+#define PCIX_MN_WINDOW(_f)     (PCIX_MN_WINDOW_F0 + (0x20 * (_f)))
 #define PCIX_MS_WINDOW         (0x10204)
-#define PCIX_SN_WINDOW         (0x10208)
+#define PCIX_SN_WINDOW_F0      (0x10208)
+#define PCIX_SN_WINDOW(_f)     (PCIX_SN_WINDOW_F0 + (0x20 * (_f)))
 #define PCIX_CRB_WINDOW                (0x10210)
 #define PCIX_CRB_WINDOW_F0     (0x10210)
 #define PCIX_CRB_WINDOW_F1     (0x10230)
index aac15421bd1ed49dc7fbb68b84809ebd5d43ddd3..a7b8d7f23259ced85ce9a5925c68dd5e3235dea5 100644 (file)
@@ -904,11 +904,11 @@ netxen_nic_pci_set_window(struct netxen_adapter *adapter,
                        ddr_mn_window = window;
                        writel(window, PCI_OFFSET_SECOND_RANGE(adapter,
                                                               NETXEN_PCIX_PH_REG
-                                                              (PCIX_MN_WINDOW)));
+                                                              (PCIX_MN_WINDOW(adapter->ahw.pci_func))));
                        /* MUST make sure window is set before we forge on... */
                        readl(PCI_OFFSET_SECOND_RANGE(adapter,
                                                      NETXEN_PCIX_PH_REG
-                                                     (PCIX_MN_WINDOW)));
+                                                     (PCIX_MN_WINDOW(adapter->ahw.pci_func))));
                }
                addr -= (window * NETXEN_WINDOW_ONE);
                addr += NETXEN_PCI_DDR_NET;
@@ -929,11 +929,11 @@ netxen_nic_pci_set_window(struct netxen_adapter *adapter,
                        writel((window << 22),
                               PCI_OFFSET_SECOND_RANGE(adapter,
                                                       NETXEN_PCIX_PH_REG
-                                                      (PCIX_SN_WINDOW)));
+                                                      (PCIX_SN_WINDOW(adapter->ahw.pci_func))));
                        /* MUST make sure window is set before we forge on... */
                        readl(PCI_OFFSET_SECOND_RANGE(adapter,
                                                      NETXEN_PCIX_PH_REG
-                                                     (PCIX_SN_WINDOW)));
+                                                     (PCIX_SN_WINDOW(adapter->ahw.pci_func))));
                }
                addr -= (window * 0x400000);
                addr += NETXEN_PCI_QDR_NET;
index ab85fb709cc95d726a44eee5a0b715492a2625b5..3122d0101638a0d232ac6f983ed6c19632dfd05f 100644 (file)
@@ -746,9 +746,6 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
 
        netxen_nic_disable_int(adapter);
 
-       if (adapter->irq)
-               free_irq(adapter->irq, adapter);
-
        if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) {
                init_firmware_done++;
                netxen_free_hw_resources(adapter);
@@ -772,13 +769,8 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
                }
        }
 
-       if (adapter->flags & NETXEN_NIC_MSI_ENABLED)
-               pci_disable_msi(pdev);
-
        vfree(adapter->cmd_buf_arr);
 
-       pci_disable_device(pdev);
-
        if (adapter->portnum == 0) {
                if (init_firmware_done) {
                        i = 100;
@@ -829,12 +821,19 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
                }
        }
 
+       if (adapter->irq)
+               free_irq(adapter->irq, adapter);
+
+       if (adapter->flags & NETXEN_NIC_MSI_ENABLED)
+               pci_disable_msi(pdev);
+
        iounmap(adapter->ahw.db_base);
        iounmap(adapter->ahw.pci_base0);
        iounmap(adapter->ahw.pci_base1);
        iounmap(adapter->ahw.pci_base2);
 
        pci_release_regions(pdev);
+       pci_disable_device(pdev);
        pci_set_drvdata(pdev, NULL);
 
        free_netdev(netdev);