]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
liquidio: change manner of detecting whether or not NIC firmware is loaded
authorFelix Manlunas <felix.manlunas@cavium.com>
Tue, 22 Aug 2017 19:46:37 +0000 (12:46 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 24 Aug 2017 03:29:24 +0000 (20:29 -0700)
In the NIC firmware, the 1-bit flag indicating "firmware is loaded" moved
from SLI_SCRATCH_1 to SLI_SCRATCH_2 (these are Octeon general-purpose
scratch registers).  Make the PF driver conform to this change.

Remove code that sets the "firmware is loaded" flag because it's now the
firmware's job to do that.

In the code that detects whether or not the firmware is loaded, don't just
rely on checking the "firmware is loaded" flag because that may cause a
rare false negative.  Add code that deduces whether or not the firmware is
loaded; that will never give a false negative.

Also bump up driver version to match newer NIC firmware.

Signed-off-by: Felix Manlunas <felix.manlunas@cavium.com>
Signed-off-by: Derek Chickles <derek.chickles@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c
drivers/net/ethernet/cavium/liquidio/lio_main.c
drivers/net/ethernet/cavium/liquidio/liquidio_common.h

index fbc0d4e008f3a31b5645f1c8de7ccc006aed40f8..f6c0bad78cd412f9e850eeb9dacc385ad1b7ecf5 100644 (file)
@@ -1442,8 +1442,19 @@ int cn23xx_fw_loaded(struct octeon_device *oct)
 {
        u64 val;
 
-       val = octeon_read_csr64(oct, CN23XX_SLI_SCRATCH1);
-       return (val >> 1) & 1ULL;
+       /* If there's more than one active PF on this NIC, then that
+        * implies that the NIC firmware is loaded and running.  This check
+        * prevents a rare false negative that might occur if we only relied
+        * on checking the SCR2_BIT_FW_LOADED flag.  The false negative would
+        * happen if the PF driver sees SCR2_BIT_FW_LOADED as cleared even
+        * though the firmware was already loaded but still booting and has yet
+        * to set SCR2_BIT_FW_LOADED.
+        */
+       if (atomic_read(oct->adapter_refcount) > 1)
+               return 1;
+
+       val = octeon_read_csr64(oct, CN23XX_SLI_SCRATCH2);
+       return (val >> SCR2_BIT_FW_LOADED) & 1ULL;
 }
 
 void cn23xx_tell_vf_its_macaddr_changed(struct octeon_device *oct, int vfidx,
index c2360fe8cef2bacc250569f112207869da5a2372..e7f54948173f7e6764b57ba5b99636ba206ba323 100644 (file)
@@ -4125,12 +4125,6 @@ static int octeon_device_init(struct octeon_device *octeon_dev)
                        dev_err(&octeon_dev->pci_dev->dev, "Could not load firmware to board\n");
                        return 1;
                }
-               /* set bit 1 of SLI_SCRATCH_1 to indicate that firmware is
-                * loaded
-                */
-               if (OCTEON_CN23XX_PF(octeon_dev))
-                       octeon_write_csr64(octeon_dev, CN23XX_SLI_SCRATCH1,
-                                          2ULL);
        }
 
        handshake[octeon_dev->octeon_id].init_ok = 1;
index d0076c191cee11e9578f39f34672f7ec0dac4ed5..3788c8cd082a30dfe8005496e279d245b415841e 100644 (file)
@@ -28,7 +28,7 @@
 #define LIQUIDIO_PACKAGE ""
 #define LIQUIDIO_BASE_MAJOR_VERSION 1
 #define LIQUIDIO_BASE_MINOR_VERSION 6
-#define LIQUIDIO_BASE_MICRO_VERSION 0
+#define LIQUIDIO_BASE_MICRO_VERSION 1
 #define LIQUIDIO_BASE_VERSION   __stringify(LIQUIDIO_BASE_MAJOR_VERSION) "." \
                                __stringify(LIQUIDIO_BASE_MINOR_VERSION)
 #define LIQUIDIO_MICRO_VERSION  "." __stringify(LIQUIDIO_BASE_MICRO_VERSION)
@@ -106,6 +106,7 @@ enum octeon_tag_type {
 #define MAX_IOQ_INTERRUPTS_PER_PF   (64 * 2)
 #define MAX_IOQ_INTERRUPTS_PER_VF   (8 * 2)
 
+#define SCR2_BIT_FW_LOADED         63
 
 static inline u32 incr_index(u32 index, u32 count, u32 max)
 {