cxgb4: Wait for device to get ready before reading any register
authorHariprasad Shenai <hariprasad@chelsio.com>
Thu, 9 Oct 2014 00:18:47 +0000 (05:48 +0530)
committerDavid S. Miller <davem@davemloft.net>
Thu, 9 Oct 2014 22:53:52 +0000 (18:53 -0400)
Call t4_wait_dev_ready() before attempting to read the PL_WHOAMI register
(to determine which function we have been attached to). This prevents us from
failing on that read if it comes right after a RESET.

Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c

index 9b2c669b6522234abedd23db142ad5493a008ade..410ed5805a9a8c46ff23cc0df05a20e3729b3c39 100644 (file)
@@ -968,7 +968,7 @@ void t4_intr_enable(struct adapter *adapter);
 void t4_intr_disable(struct adapter *adapter);
 int t4_slow_intr_handler(struct adapter *adapter);
 
-int t4_wait_dev_ready(struct adapter *adap);
+int t4_wait_dev_ready(void __iomem *regs);
 int t4_link_start(struct adapter *adap, unsigned int mbox, unsigned int port,
                  struct link_config *lc);
 int t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int port);
index 321f3d9385c9b0f6ec90c04c3fe91b63dc131c32..5b38e955af6ec39b804b333cbbfd9bdf3817db4f 100644 (file)
@@ -6137,7 +6137,7 @@ static pci_ers_result_t eeh_slot_reset(struct pci_dev *pdev)
        pci_save_state(pdev);
        pci_cleanup_aer_uncorrect_error_status(pdev);
 
-       if (t4_wait_dev_ready(adap) < 0)
+       if (t4_wait_dev_ready(adap->regs) < 0)
                return PCI_ERS_RESULT_DISCONNECT;
        if (t4_fw_hello(adap, adap->fn, adap->fn, MASTER_MUST, NULL) < 0)
                return PCI_ERS_RESULT_DISCONNECT;
@@ -6530,6 +6530,10 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
                goto out_disable_device;
        }
 
+       err = t4_wait_dev_ready(regs);
+       if (err < 0)
+               goto out_unmap_bar0;
+
        /* We control everything through one PF */
        func = SOURCEPF_GET(readl(regs + PL_WHOAMI));
        if (func != ent->driver_data) {
index 22d7581341a912a3fb1329fdf7445677aa27f2cd..1fff1495fe31561187e325dedc741a9367cf8c81 100644 (file)
@@ -3845,12 +3845,19 @@ static void init_link_config(struct link_config *lc, unsigned int caps)
        }
 }
 
-int t4_wait_dev_ready(struct adapter *adap)
+#define CIM_PF_NOACCESS 0xeeeeeeee
+
+int t4_wait_dev_ready(void __iomem *regs)
 {
-       if (t4_read_reg(adap, PL_WHOAMI) != 0xffffffff)
+       u32 whoami;
+
+       whoami = readl(regs + PL_WHOAMI);
+       if (whoami != 0xffffffff && whoami != CIM_PF_NOACCESS)
                return 0;
+
        msleep(500);
-       return t4_read_reg(adap, PL_WHOAMI) != 0xffffffff ? 0 : -EIO;
+       whoami = readl(regs + PL_WHOAMI);
+       return (whoami != 0xffffffff && whoami != CIM_PF_NOACCESS ? 0 : -EIO);
 }
 
 struct flash_desc {
@@ -3919,10 +3926,6 @@ int t4_prep_adapter(struct adapter *adapter)
        uint16_t device_id;
        u32 pl_rev;
 
-       ret = t4_wait_dev_ready(adapter);
-       if (ret < 0)
-               return ret;
-
        get_pci_mode(adapter, &adapter->params.pci);
        pl_rev = G_REV(t4_read_reg(adapter, PL_REV));