liquidio: fix rare pci_driver.probe failure of VF driver
authorPrasad Kanneganti <prasad.kanneganti@cavium.com>
Thu, 25 May 2017 17:42:14 +0000 (10:42 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 26 May 2017 18:41:47 +0000 (14:41 -0400)
There's a rare pci_driver.probe failure of the VF driver that's caused by
PF/VF handshake going out of sync.  The culprit is octeon_mbox_write() who
ignores an ack timeout condition; it just keeps unconditionally writing all
elements of mbox_cmd->data[] even when the other side is not ready for
them.  Fix it by making each write of mbox_cmd->data[i] conditional to
having previously received an ack.

Also fix the octeon_mbox_state enum such that each state gets a unique
value.  Also add ULL suffix to numeric literals in macro definitions.

Signed-off-by: Prasad Kanneganti <prasad.kanneganti@cavium.com>
Signed-off-by: Felix Manlunas <felix.manlunas@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/cavium/liquidio/octeon_mailbox.c
drivers/net/ethernet/cavium/liquidio/octeon_mailbox.h

index 5cca73b8880b0dc1a95de176b31b0278bc0d2fb2..57af7df74ced48591744ba0261e5ee586ad48e79 100644 (file)
@@ -178,7 +178,10 @@ int octeon_mbox_write(struct octeon_device *oct,
                                        break;
                                }
                        }
-                       writeq(mbox_cmd->data[i], mbox->mbox_write_reg);
+                       if (ret == OCTEON_MBOX_STATUS_SUCCESS)
+                               writeq(mbox_cmd->data[i], mbox->mbox_write_reg);
+                       else
+                               break;
                }
        }
 
index c9376fe075bc0afaf74ffc6279c376c7271e8825..1def22afeff1049edc8e5eb0923ad904cc57fcbd 100644 (file)
 
 /* Macros for Mail Box Communication */
 
-#define OCTEON_MBOX_DATA_MAX   32
+#define OCTEON_MBOX_DATA_MAX           32
 
 #define OCTEON_VF_ACTIVE               0x1
 #define OCTEON_VF_FLR_REQUEST          0x2
 #define OCTEON_PF_CHANGED_VF_MACADDR   0x4
 
 /*Macro for Read acknowldgement*/
-#define OCTEON_PFVFACK                 0xffffffffffffffff
-#define OCTEON_PFVFSIG                 0x1122334455667788
-#define OCTEON_PFVFERR                 0xDEADDEADDEADDEAD
+#define OCTEON_PFVFACK                 0xffffffffffffffffULL
+#define OCTEON_PFVFSIG                 0x1122334455667788ULL
+#define OCTEON_PFVFERR                 0xDEADDEADDEADDEADULL
 
 #define LIO_MBOX_WRITE_WAIT_CNT         1000
 #define LIO_MBOX_WRITE_WAIT_TIME        msecs_to_jiffies(1)
@@ -74,8 +74,8 @@ enum octeon_mbox_state {
        OCTEON_MBOX_STATE_REQUEST_RECEIVED = 4,
        OCTEON_MBOX_STATE_RESPONSE_PENDING = 8,
        OCTEON_MBOX_STATE_RESPONSE_RECEIVING = 16,
-       OCTEON_MBOX_STATE_RESPONSE_RECEIVED = 16,
-       OCTEON_MBOX_STATE_ERROR = 32
+       OCTEON_MBOX_STATE_RESPONSE_RECEIVED = 32,
+       OCTEON_MBOX_STATE_ERROR = 64
 };
 
 struct octeon_mbox {