Skip to contentSkip to conversation

liquidio: fix rare pci_driver.probe failure of VF driver

PATCH Applied Felix Manlunas 3 participants 3 messages May 25, 2017 – May 26, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 liquidio: fix rare pci_driver.probe failure of VF driver

From: Prasad Kanneganti <[email protected]>

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.

---
 drivers/net/ethernet/cavium/liquidio/octeon_mailbox.c |  5 ++++-
 drivers/net/ethernet/cavium/liquidio/octeon_mailbox.h | 12 ++++++------
 2 files changed, 10 insertions(+), 7 deletions(-)
drivers/net/ethernet/cavium/liquidio/octeon_mailbox.c +4 -1
index 5cca73b..57af7df 100644
@@ -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;
 		}
 	}
 
drivers/net/ethernet/cavium/liquidio/octeon_mailbox.h +6 -6
index c9376fe..1def22a 100644
@@ -20,16 +20,16 @@
 
 /* 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 {
#1 lore raw

Looks good to me.

Derek

Quoted 84 lines

-----Original Message-----
From: Manlunas, Felix
Sent: Thursday, May 25, 2017 10:42 AM
To: [email protected]
Cc: [email protected]; Vatsavayi, Raghu <[email protected]>; Chickles, Derek <[email protected]>; Burla, Satananda <[email protected]>; Kanneganti, Prasad <[email protected]>
Subject: [PATCH net-next] liquidio: fix rare pci_driver.probe failure of VF driver

From: Prasad Kanneganti <[email protected]>

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.

---
 drivers/net/ethernet/cavium/liquidio/octeon_mailbox.c |  5 ++++-
drivers/net/ethernet/cavium/liquidio/octeon_mailbox.h | 12 ++++++------
 2 files changed, 10 insertions(+), 7 deletions(-)
drivers/net/ethernet/cavium/liquidio/octeon_mailbox.c +4 -1
index 5cca73b..57af7df 100644
@@ -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;
 		}
 	}
 
drivers/net/ethernet/cavium/liquidio/octeon_mailbox.h +6 -6
index c9376fe..1def22a 100644
@@ -20,16 +20,16 @@
 
 /* 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 {
maintainer Applied
#2 lore raw
In reply to Felix Manlunas

From: Felix Manlunas <[email protected]>
Date: Thu, 25 May 2017 10:42:14 -0700

Quoted 9 lines

From: Prasad Kanneganti <[email protected]>

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.

Quoted 5 lines

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.

Applied.