Skip to contentSkip to conversation

octeontx2-af: Unlock contexts in the queue context cache in case of fault detection

PATCH Superseded Sai Krishna 2 participants 5 messages Feb 23, 2023 – Mar 2, 2023

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 octeontx2-af: Unlock contexts in the queue context cache in case of fault detection

From: Suman Ghosh <[email protected]>

NDC caches contexts of frequently used queue's (Rx and Tx queues) contexts. Due to a HW errata when NDC detects fault/poision while accessing contexts it could go into an illegal state where a cache line could get locked forever. To makesure all cache lines in NDC are available for optimum performance upon fault/lockerror/posion errors scan through all cache lines in NDC and clear the lock bit.

Fixes 4a3581cd5995 ("octeontx2-af: NPA AQ instruction enqueue support")

---
v2:
- Rebased to latest net tree after net-next merge as suggested by Paolo

 .../net/ethernet/marvell/octeontx2/af/rvu.h   |  8 +++
 .../marvell/octeontx2/af/rvu_debugfs.c        |  3 -
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   | 16 +++++-
 .../ethernet/marvell/octeontx2/af/rvu_npa.c   | 55 ++++++++++++++++++-
 .../ethernet/marvell/octeontx2/af/rvu_reg.h   |  3 +
 5 files changed, 80 insertions(+), 5 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +8 -0
index 389663a13d1d..6508f25b2b37 100644
@@ -884,6 +884,12 @@ int rvu_cpt_lf_teardown(struct rvu *rvu, u16 pcifunc, int blkaddr, int lf,
 int rvu_cpt_ctx_flush(struct rvu *rvu, u16 pcifunc);
 int rvu_cpt_init(struct rvu *rvu);
 
+/* NDC APIs */
+#define NDC_MAX_BANK(rvu, blk_addr) (rvu_read64(rvu, \
+					blk_addr, NDC_AF_CONST) & 0xFF)
+#define NDC_MAX_LINE_PER_BANK(rvu, blk_addr) ((rvu_read64(rvu, \
+					blk_addr, NDC_AF_CONST) & 0xFFFF0000) >> 16)
+
 /* CN10K RVU */
 int rvu_set_channels_base(struct rvu *rvu);
 void rvu_program_channels(struct rvu *rvu);
@@ -902,6 +908,8 @@ static inline void rvu_dbg_init(struct rvu *rvu) {}
 static inline void rvu_dbg_exit(struct rvu *rvu) {}
 #endif
 
+int rvu_ndc_fix_locked_cacheline(struct rvu *rvu, int blkaddr);
+
 /* RVU Switch */
 void rvu_switch_enable(struct rvu *rvu);
 void rvu_switch_disable(struct rvu *rvu);
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +0 -3
index fa280ebd3052..fad83d1f84b0 100644
@@ -198,9 +198,6 @@ enum cpt_eng_type {
 	CPT_IE_TYPE = 3,
 };
 
-#define NDC_MAX_BANK(rvu, blk_addr) (rvu_read64(rvu, \
-						blk_addr, NDC_AF_CONST) & 0xFF)
-
 #define rvu_dbg_NULL NULL
 #define rvu_dbg_open_NULL NULL
 
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +15 -1
index 26e639e57dae..4ad707e758b9 100644
@@ -790,6 +790,7 @@ static int nix_aq_enqueue_wait(struct rvu *rvu, struct rvu_block *block,
 	struct nix_aq_res_s *result;
 	int timeout = 1000;
 	u64 reg, head;
+	int ret;
 
 	result = (struct nix_aq_res_s *)aq->res->base;
 
@@ -813,9 +814,22 @@ static int nix_aq_enqueue_wait(struct rvu *rvu, struct rvu_block *block,
 			return -EBUSY;
 	}
 
-	if (result->compcode != NIX_AQ_COMP_GOOD)
+	if (result->compcode != NIX_AQ_COMP_GOOD) {
 		/* TODO: Replace this with some error code */
+		if (result->compcode == NIX_AQ_COMP_CTX_FAULT ||
+		    result->compcode == NIX_AQ_COMP_LOCKERR ||
+		    result->compcode == NIX_AQ_COMP_CTX_POISON) {
+			ret = rvu_ndc_fix_locked_cacheline(rvu, BLKADDR_NDC_NIX0_RX);
+			ret |= rvu_ndc_fix_locked_cacheline(rvu, BLKADDR_NDC_NIX0_TX);
+			ret |= rvu_ndc_fix_locked_cacheline(rvu, BLKADDR_NDC_NIX1_RX);
+			ret |= rvu_ndc_fix_locked_cacheline(rvu, BLKADDR_NDC_NIX1_TX);
+			if (ret)
+				dev_err(rvu->dev,
+					"%s: Not able to unlock cachelines\n", __func__);
+		}
+
 		return -EBUSY;
+	}
 
 	return 0;
 }
drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c +54 -1

66 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h +3 -0
index 1729b22580ce..bc6ca5ccc1ff 100644
@@ -694,6 +694,7 @@
 #define NDC_AF_INTR_ENA_W1S		(0x00068)
 #define NDC_AF_INTR_ENA_W1C		(0x00070)
 #define NDC_AF_ACTIVE_PC		(0x00078)
+#define NDC_AF_CAMS_RD_INTERVAL		(0x00080)
 #define NDC_AF_BP_TEST_ENABLE		(0x001F8)
 #define NDC_AF_BP_TEST(a)		(0x00200 | (a) << 3)
 #define NDC_AF_BLK_RST			(0x002F0)
@@ -709,6 +710,8 @@
 		(0x00F00 | (a) << 5 | (b) << 4)
 #define NDC_AF_BANKX_HIT_PC(a)		(0x01000 | (a) << 3)
 #define NDC_AF_BANKX_MISS_PC(a)		(0x01100 | (a) << 3)
+#define NDC_AF_BANKX_LINEX_METADATA(a, b) \
+		(0x10000 | (a) << 3 | (b) << 3)
 
 /* LBK */
 #define LBK_CONST			(0x10ull)
Signature · 1 line
2.25.1
#1 lore raw
Quoted 13 lines · Sai Krishna

From: Suman Ghosh <[email protected]>

NDC caches contexts of frequently used queue's (Rx and Tx queues) contexts. Due to a HW errata when NDC detects fault/poision while accessing contexts it could go into an illegal state where a cache line could get locked forever. To makesure all cache lines in NDC are available for optimum performance upon fault/lockerror/posion errors scan through all cache lines in NDC and clear the lock bit.

Fixes 4a3581cd5995 ("octeontx2-af: NPA AQ instruction enqueue support")

...

drivers/net/ethernet/marvell/octeontx2/af/rvu.h int rvu_cpt_lf_teardown(struct rvu *rvu, u16 pcifunc, int blkaddr, int lf, · line 891

Quoted 13 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +5 -0
index 389663a13d1d..6508f25b2b37 100644
@@ -884,6 +884,12 @@ int rvu_cpt_lf_teardown(struct rvu *rvu, u16 pcifunc, int blkaddr, int lf,
 int rvu_cpt_ctx_flush(struct rvu *rvu, u16 pcifunc);
 int rvu_cpt_init(struct rvu *rvu);
 
+/* NDC APIs */
+#define NDC_MAX_BANK(rvu, blk_addr) (rvu_read64(rvu, \
+					blk_addr, NDC_AF_CONST) & 0xFF)
+#define NDC_MAX_LINE_PER_BANK(rvu, blk_addr) ((rvu_read64(rvu, \
+					blk_addr, NDC_AF_CONST) & 0xFFFF0000) >> 16)

Perhaps not appropriate to include as part of a fix, as NDC_MAX_BANK is being moved from elsewhere, but I wonder if this might be more cleanly implemented using FIELD_GET().

...

Quoted 13 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h +1 -0
index 1729b22580ce..bc6ca5ccc1ff 100644
@@ -694,6 +694,7 @@
 #define NDC_AF_INTR_ENA_W1S		(0x00068)
 #define NDC_AF_INTR_ENA_W1C		(0x00070)
 #define NDC_AF_ACTIVE_PC		(0x00078)
+#define NDC_AF_CAMS_RD_INTERVAL		(0x00080)
 #define NDC_AF_BP_TEST_ENABLE		(0x001F8)
 #define NDC_AF_BP_TEST(a)		(0x00200 | (a) << 3)
 #define NDC_AF_BLK_RST			(0x002F0)

drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h line 714

Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h +2 -0
@@ -709,6 +710,8 @@
 		(0x00F00 | (a) << 5 | (b) << 4)
 #define NDC_AF_BANKX_HIT_PC(a)		(0x01000 | (a) << 3)
 #define NDC_AF_BANKX_MISS_PC(a)		(0x01100 | (a) << 3)
+#define NDC_AF_BANKX_LINEX_METADATA(a, b) \
+		(0x10000 | (a) << 3 | (b) << 3)

It looks a little odd that both a and b are shifted by 3 bits. If it's intended then perhaps it would be clearer to write this as:

#define NDC_AF_BANKX_LINEX_METADATA(a, b) \
		(0x10000 | ((a) | (b)) << 3)
Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h +0 -0
 /* LBK */
 #define LBK_CONST			(0x10ull)
Signature · 1 line
2.25.1
#2 lore raw

Hi Simon,

Quoted 47 lines

-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Thursday, February 23, 2023 6:47 PM
To: Sai Krishna Gajula <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sunil Kovvuri Goutham <[email protected]>; Suman Ghosh <[email protected]>
Subject: Re: [net PATCH v2] octeontx2-af: Unlock contexts in the queue context cache in case of fault detection

----------------------------------------------------------------------

Quoted 14 lines · Sai Krishna

From: Suman Ghosh <[email protected]>

NDC caches contexts of frequently used queue's (Rx and Tx queues) contexts. Due to a HW errata when NDC detects fault/poision while accessing contexts it could go into an illegal state where a cache line could get locked forever. To makesure all cache lines in NDC are available for optimum performance upon fault/lockerror/posion errors scan through all cache lines in NDC and clear the lock bit.

Fixes 4a3581cd5995 ("octeontx2-af: NPA AQ instruction enqueue

support")

...

Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +0 -0
index 389663a13d1d..6508f25b2b37 100644

drivers/net/ethernet/marvell/octeontx2/af/rvu.h int rvu_cpt_lf_teardown(struct rvu *rvu, u16 · line 891

Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +5 -0
@@ -884,6 +884,12 @@ int rvu_cpt_lf_teardown(struct rvu *rvu, u16
 pcifunc, int blkaddr, int lf,  int rvu_cpt_ctx_flush(struct rvu *rvu,
 u16 pcifunc);  int rvu_cpt_init(struct rvu *rvu);
 
+/* NDC APIs */
+#define NDC_MAX_BANK(rvu, blk_addr) (rvu_read64(rvu, \
+					blk_addr, NDC_AF_CONST) & 0xFF)
+#define NDC_MAX_LINE_PER_BANK(rvu, blk_addr) ((rvu_read64(rvu, \
+					blk_addr, NDC_AF_CONST) &

0xFFFF0000) >> 16)

Quoted 3 lines

Perhaps not appropriate to include as part of a fix, as NDC_MAX_BANK is being moved from elsewhere, but I wonder if this might be more cleanly implemented using FIELD_GET().

We will modify and send a separate patch for all the possible macros that can be replaced by FIELD_GET().

Quoted 26 lines

...

Quoted 14 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h +1 -0
index 1729b22580ce..bc6ca5ccc1ff 100644
@@ -694,6 +694,7 @@
 #define NDC_AF_INTR_ENA_W1S		(0x00068)
 #define NDC_AF_INTR_ENA_W1C		(0x00070)
 #define NDC_AF_ACTIVE_PC		(0x00078)
+#define NDC_AF_CAMS_RD_INTERVAL		(0x00080)
 #define NDC_AF_BP_TEST_ENABLE		(0x001F8)
 #define NDC_AF_BP_TEST(a)		(0x00200 | (a) << 3)
 #define NDC_AF_BLK_RST			(0x002F0)

drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h line 714

Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h +2 -0
@@ -709,6 +710,8 @@
 		(0x00F00 | (a) << 5 | (b) << 4)
 #define NDC_AF_BANKX_HIT_PC(a)		(0x01000 | (a) << 3)
 #define NDC_AF_BANKX_MISS_PC(a)		(0x01100 | (a) << 3)
+#define NDC_AF_BANKX_LINEX_METADATA(a, b) \
+		(0x10000 | (a) << 3 | (b) << 3)

It looks a little odd that both a and b are shifted by 3 bits. If it's intended then perhaps it would be clearer to write this as:

Quoted 2 lines
#define NDC_AF_BANKX_LINEX_METADATA(a, b) \
		(0x10000 | ((a) | (b)) << 3)

will send v3 patch.

Thanks,
Sai

Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h +0 -1
 /* LBK */
 #define LBK_CONST			(0x10ull)
--

2.25.1

#3 lore raw
Quoted 49 lines · Sai Krishna Gajula

Hi Simon,

Quoted 47 lines

-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Thursday, February 23, 2023 6:47 PM
To: Sai Krishna Gajula <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sunil Kovvuri Goutham <[email protected]>; Suman Ghosh <[email protected]>
Subject: Re: [net PATCH v2] octeontx2-af: Unlock contexts in the queue context cache in case of fault detection

----------------------------------------------------------------------

Quoted 14 lines · Sai Krishna

From: Suman Ghosh <[email protected]>

NDC caches contexts of frequently used queue's (Rx and Tx queues) contexts. Due to a HW errata when NDC detects fault/poision while accessing contexts it could go into an illegal state where a cache line could get locked forever. To makesure all cache lines in NDC are available for optimum performance upon fault/lockerror/posion errors scan through all cache lines in NDC and clear the lock bit.

Fixes 4a3581cd5995 ("octeontx2-af: NPA AQ instruction enqueue

support")

...

Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +0 -0
index 389663a13d1d..6508f25b2b37 100644

drivers/net/ethernet/marvell/octeontx2/af/rvu.h int rvu_cpt_lf_teardown(struct rvu *rvu, u16 · line 891

Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +5 -0
@@ -884,6 +884,12 @@ int rvu_cpt_lf_teardown(struct rvu *rvu, u16
 pcifunc, int blkaddr, int lf,  int rvu_cpt_ctx_flush(struct rvu *rvu,
 u16 pcifunc);  int rvu_cpt_init(struct rvu *rvu);
 
+/* NDC APIs */
+#define NDC_MAX_BANK(rvu, blk_addr) (rvu_read64(rvu, \
+					blk_addr, NDC_AF_CONST) & 0xFF)
+#define NDC_MAX_LINE_PER_BANK(rvu, blk_addr) ((rvu_read64(rvu, \
+					blk_addr, NDC_AF_CONST) &

0xFFFF0000) >> 16)

Quoted 5 lines
Quoted 3 lines

Perhaps not appropriate to include as part of a fix, as NDC_MAX_BANK is being moved from elsewhere, but I wonder if this might be more cleanly implemented using FIELD_GET().

We will modify and send a separate patch for all the possible macros that can be replaced by FIELD_GET().

Thanks, much appreciated.

Quoted 25 lines
Quoted 25 lines

...

Quoted 14 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h +1 -0
index 1729b22580ce..bc6ca5ccc1ff 100644
@@ -694,6 +694,7 @@
 #define NDC_AF_INTR_ENA_W1S		(0x00068)
 #define NDC_AF_INTR_ENA_W1C		(0x00070)
 #define NDC_AF_ACTIVE_PC		(0x00078)
+#define NDC_AF_CAMS_RD_INTERVAL		(0x00080)
 #define NDC_AF_BP_TEST_ENABLE		(0x001F8)
 #define NDC_AF_BP_TEST(a)		(0x00200 | (a) << 3)
 #define NDC_AF_BLK_RST			(0x002F0)

drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h line 714

Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h +2 -0
@@ -709,6 +710,8 @@
 		(0x00F00 | (a) << 5 | (b) << 4)
 #define NDC_AF_BANKX_HIT_PC(a)		(0x01000 | (a) << 3)
 #define NDC_AF_BANKX_MISS_PC(a)		(0x01100 | (a) << 3)
+#define NDC_AF_BANKX_LINEX_METADATA(a, b) \
+		(0x10000 | (a) << 3 | (b) << 3)

It looks a little odd that both a and b are shifted by 3 bits. If it's intended then perhaps it would be clearer to write this as:

Quoted 4 lines
Quoted 2 lines
#define NDC_AF_BANKX_LINEX_METADATA(a, b) \
		(0x10000 | ((a) | (b)) << 3)

will send v3 patch.

Likewise, thanks.

#4 lore raw

Hi Simon,

Quoted 98 lines

-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Friday, February 24, 2023 2:37 PM
To: Sai Krishna Gajula <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sunil Kovvuri Goutham <[email protected]>; Suman Ghosh <[email protected]>
Subject: Re: [net PATCH v2] octeontx2-af: Unlock contexts in the queue context cache in case of fault detection

----------------------------------------------------------------------

Quoted 43 lines · Sai Krishna Gajula

Hi Simon,

Quoted 41 lines

-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Thursday, February 23, 2023 6:47 PM
To: Sai Krishna Gajula <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sunil Kovvuri Goutham <[email protected]>; Suman Ghosh <[email protected]>
Subject: Re: [net PATCH v2] octeontx2-af: Unlock contexts in the queue context cache in case of fault detection

--------------------------------------------------------------------

Quoted 14 lines · Sai Krishna

From: Suman Ghosh <[email protected]>

NDC caches contexts of frequently used queue's (Rx and Tx queues) contexts. Due to a HW errata when NDC detects fault/poision while accessing contexts it could go into an illegal state where a cache line could get locked forever. To makesure all cache lines in NDC are available for optimum performance upon fault/lockerror/posion errors scan through all cache lines in NDC and clear the lock bit.

Fixes 4a3581cd5995 ("octeontx2-af: NPA AQ instruction enqueue

support")

...

Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +0 -0
index 389663a13d1d..6508f25b2b37 100644
@@ -884,6 +884,12 @@ int rvu_cpt_lf_teardown(struct rvu *rvu, u16

pcifunc, int blkaddr, int lf, int rvu_cpt_ctx_flush(struct rvu *rvu,
u16 pcifunc); int rvu_cpt_init(struct rvu *rvu);

Quoted 3 lines
Quoted 3 lines

drivers/net/ethernet/marvell/octeontx2/af/rvu.h int rvu_cpt_lf_teardown(struct rvu *rvu, u16 pcifunc, int blkaddr, int lf, · line 889

Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +3 -0
+/* NDC APIs */
+#define NDC_MAX_BANK(rvu, blk_addr) (rvu_read64(rvu, \
+					blk_addr, NDC_AF_CONST) & 0xFF)

#define

Quoted 9 lines
Quoted 7 lines

drivers/net/ethernet/marvell/octeontx2/af/rvu.h

Quoted 2 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +2 -0
+NDC_MAX_LINE_PER_BANK(rvu, blk_addr) ((rvu_read64(rvu, \
+					blk_addr, NDC_AF_CONST) &

0xFFFF0000) >> 16)

Perhaps not appropriate to include as part of a fix, as NDC_MAX_BANK is being moved from elsewhere, but I wonder if this might be more cleanly implemented using FIELD_GET().

We will modify and send a separate patch for all the possible macros that

can be replaced by FIELD_GET().

Thanks, much appreciated.

Quoted 25 lines
Quoted 25 lines

...

Quoted 14 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h +1 -0
index 1729b22580ce..bc6ca5ccc1ff 100644
@@ -694,6 +694,7 @@
 #define NDC_AF_INTR_ENA_W1S		(0x00068)
 #define NDC_AF_INTR_ENA_W1C		(0x00070)
 #define NDC_AF_ACTIVE_PC		(0x00078)
+#define NDC_AF_CAMS_RD_INTERVAL		(0x00080)
 #define NDC_AF_BP_TEST_ENABLE		(0x001F8)
 #define NDC_AF_BP_TEST(a)		(0x00200 | (a) << 3)
 #define NDC_AF_BLK_RST			(0x002F0)

drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h line 714

Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h +2 -0
@@ -709,6 +710,8 @@
 		(0x00F00 | (a) << 5 | (b) << 4)
 #define NDC_AF_BANKX_HIT_PC(a)		(0x01000 | (a) << 3)
 #define NDC_AF_BANKX_MISS_PC(a)		(0x01100 | (a) << 3)
+#define NDC_AF_BANKX_LINEX_METADATA(a, b) \
+		(0x10000 | (a) << 3 | (b) << 3)

It looks a little odd that both a and b are shifted by 3 bits. If it's intended then perhaps it would be clearer to write this as:

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
#define NDC_AF_BANKX_LINEX_METADATA(a, b) \
		(0x10000 | ((a) | (b)) << 3)

will send v3 patch.

Likewise, thanks.

We found a bug related to the macro NDC_AF_BANKX_LINEX_METADATA which we will fix and send in v3 patch.

Thanks,
Sai