Return EBUSY on inject poison limit reached
[email protected]
maintainercover Return EBUSY on inject poison limit reached
From: Alison Schofield <[email protected]>
Validation users are asking for the ability to recognize when their injection testing has hit the limit of the device.
Change the drivers error code for this failure to EBUSY and do the same in the cxl-test mock of inject poison.
Alison Schofield (2):
cxl/memdev: Replace ENXIO with EBUSY for inject poison limit reached cxl/test: Replace ENXIO with EBUSY for inject poison limit reached
Documentation/ABI/testing/debugfs-cxl | 7 ++++--- drivers/cxl/cxlmem.h | 2 +- tools/testing/cxl/test/mem.c | 13 ++++++------- 3 files changed, 11 insertions(+), 11 deletions(-)
base-commit: 22a40d14b572deb80c0648557f4bd502d7e83826
Signature · 1 line
2.37.3
[email protected]
maintainerPATCH 1/2 cxl/memdev: Replace ENXIO with EBUSY for inject poison limit reached
From: Alison Schofield <[email protected]>
The CXL driver provides a debugfs interface offering users the ability to inject and clear poison to a memdev. Once a user has injected up to the devices limit further injection requests fail with ENXIO until a clear poison is issued.
Users may not have device specs in hand or may want to intentionally hit the limit and then clear. Replace the usual ENXIO return status with EBUSY so users can recognize this failure.
--- Documentation/ABI/testing/debugfs-cxl | 7 ++++--- drivers/cxl/cxlmem.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)
Documentation/ABI/testing/debugfs-cxl +4 -3
@@ -14,9 +14,10 @@ Description: event to its internal Informational Event log, updates the Event Status register, and if configured, interrupts the host. It is not an error to inject poison into an address that - already has poison present and no error is returned. The - inject_poison attribute is only visible for devices supporting - the capability. + already has poison present and no error is returned. If the + device returns 'Inject Poison Limit Reached' an -EBUSY error + is returned to the user. The inject_poison attribute is only + visible for devices supporting the capability. What: /sys/kernel/debug/memX/clear_poison
drivers/cxl/cxlmem.h +1 -1
@@ -161,7 +161,7 @@ struct cxl_mbox_cmd {C (FWRESET , -ENXIO ,"FW failed to activate, needs cold reset" ), \C (HANDLE , -ENXIO ,"one or more Event Record Handles were invalid" ), \C (PADDR , -EFAULT ,"physical address specified is invalid" ), \ -C (POISONLMT , -ENXIO ,"poison injection limit has been reached" ), \ +C (POISONLMT , -EBUSY ,"poison injection limit has been reached" ), \C (MEDIAFAILURE , -ENXIO ,"permanent issue with the media" ), \C (ABORT , -ENXIO ,"background cmd was aborted by device" ), \ C(SECURITY, -ENXIO, "not valid in the current security state"), \
Signature · 1 line
2.37.3
[email protected]
maintainerPATCH 2/2 cxl/test: Replace ENXIO with EBUSY for inject poison limit reached
In reply to [email protected]From: Alison Schofield <[email protected]>
The CXL driver was recently updated to return EBUSY rather than ENXIO when the device reports that an injection request exceeds the device's limit. That change to EBUSY allows debug users to differentiate between limit reached and inject failures for any other reason.
Do the same here in cxl-test.
Reminder: the cxl-test per device injection limit is a configurable
attribute: /sys/bus/platform/drivers/cxl_mock_mem/poison_inject_max
--- tools/testing/cxl/test/mem.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
tools/testing/cxl/test/mem.c +6 -7
@@ -1131,27 +1131,28 @@ static bool mock_poison_dev_max_injected(struct cxl_dev_state *cxlds)return (count >= poison_inject_dev_max); } -static bool mock_poison_add (struct cxl_dev_state *cxlds,u64 dpa) +static int mock_poison_add (struct cxl_dev_state *cxlds,u64 dpa) { +/* Return EBUSY to match the CXL driver handling */ if (mock_poison_dev_max_injected (cxlds)) {dev_dbg (cxlds->dev,"Device poison injection limit has been reached: %d\n" ,MOCK_INJECT_DEV_MAX ); -return false; +return -EBUSY ; }for (int i =0 ; i <MOCK_INJECT_TEST_MAX ; i++) {if (!mock_poison_list[i].cxlds) { mock_poison_list[i].cxlds = cxlds; mock_poison_list[i].dpa = dpa; -return true; +return 0 ; } }dev_dbg (cxlds->dev,"Mock test poison injection limit has been reached: %d\n" ,MOCK_INJECT_TEST_MAX ); -return false; +return -ENXIO ; }static bool mock_poison_found (struct cxl_dev_state *cxlds,u64 dpa)
@@ -1175,10 +1176,8 @@ static int mock_inject_poison(struct cxl_dev_state *cxlds,dev_dbg (cxlds->dev,"DPA: 0x%llx already poisoned\n" , dpa);return 0 ; } -if (!mock_poison_add (cxlds, dpa)) -return -ENXIO ; -return 0 ; +return mock_poison_add (cxlds, dpa); }static bool mock_poison_del (struct cxl_dev_state *cxlds,u64 dpa)
Signature · 1 line
2.37.3
Quoted 9 lines · alison.schofield@ wrote:
From: Alison Schofield <[email protected]>
Validation users are asking for the ability to recognize when their injection testing has hit the limit of the device.
Change the drivers error code for this failure to EBUSY and do the same in the cxl-test mock of inject poison.
Quoted 8 lines
Alison Schofield (2):
cxl/memdev: Replace ENXIO with EBUSY for inject poison limit reached cxl/test: Replace ENXIO with EBUSY for inject poison limit reachedDocumentation/ABI/testing/debugfs-cxl | 7 ++++--- drivers/cxl/cxlmem.h | 2 +- tools/testing/cxl/test/mem.c | 13 ++++++------- 3 files changed, 11 insertions(+), 11 deletions(-)
Looks good to me:
RE: [PATCH 2/2] cxl/test: Replace ENXIO with EBUSY for inject poison limit reached
In reply to [email protected]Quoted 37 lines
-----Original Message-----
From: [email protected] <[email protected]>
Sent: Thursday, July 4, 2024 8:38 AM
To: Davidlohr Bueso <[email protected]>; Jonathan Cameron <[email protected]>; Dave Jiang <[email protected]>; Alison Schofield <[email protected]>; Vishal Verma <[email protected]>; Ira Weiny <[email protected]>; Dan Williams <[email protected]>
Cc: [email protected]
Subject: [PATCH 2/2] cxl/test: Replace ENXIO with EBUSY for inject poison limit reachedFrom: Alison Schofield <[email protected]>
The CXL driver was recently updated to return EBUSY rather than ENXIO when the device reports that an injection request exceeds the device's limit. That change to EBUSY allows debug users to differentiate between limit reached and inject failures for any other reason.
Do the same here in cxl-test.
Reminder: the cxl-test per device injection limit is a configurable
attribute:/sys/bus/platform/drivers/cxl_mock_mem/poison_inject_maxSigned-off-by Alison Schofield <[email protected]>--- tools/testing/cxl/test/mem.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)tools/testing/cxl/test/mem.c +0
-0@@ -1131,27 +1131,28 @@ static bool mock_poison_dev_max_injected(struct cxl_dev_state *cxlds)return (count >= poison_inject_dev_max);
tools/testing/cxl/test/mem.c static bool mock_poison_dev_max_injected(struct · line 1141
Quoted 10 lines
tools/testing/cxl/test/mem.c +2
-1} -static bool mock_poison_add (struct cxl_dev_state *cxlds,u64 dpa) +static int mock_poison_add (struct cxl_dev_state *cxlds,u64 dpa) { +/* Return EBUSY to match the CXL driver handling */ if (mock_poison_dev_max_injected (cxlds)) {dev_dbg (cxlds->dev,"Device poison injection limit has been reached: %d\n" ,MOCK_INJECT_DEV_MAX );
There is a tiny issue here, we'd better replace MOCK_INJECT_DEV_MAX with poison_inject_dev_max, as this value can be configured through /sys/bus/platform/drivers/cxl_mock_mem/poison_inject_max
like:
# echo 128 > /sys/bus/platform/drivers/cxl_mock_mem/poison_inject_max
after injecting 129 poisons, the “Device or resource busy” occurred, but the debug message still output:
[ 7664.280587] cxl_mock_mem cxl_mem.0: Device poison injection limit has been reached: 8 [ 7664.280591] cxl_mock_mem cxl_mem.0: opcode: 0x4301 sz_in: 8 sz_out: 0 rc: -16
Quoted 37 lines
tools/testing/cxl/test/mem.c +3
-3-return false; +return -EBUSY ; }for (int i =0 ; i <MOCK_INJECT_TEST_MAX ; i++) {if (!mock_poison_list[i].cxlds) { mock_poison_list[i].cxlds = cxlds; mock_poison_list[i].dpa = dpa; -return true; +return 0 ; } }dev_dbg (cxlds->dev,"Mock test poison injection limit has been reached: %d\n" ,MOCK_INJECT_TEST_MAX ); -return false; +return -ENXIO ; }static bool
mock_poison_found(struct cxl_dev_state *cxlds, u64 dpa)tools/testing/cxl/test/mem.c +1
-3@@ -1175,10 +1176,8 @@ static int mock_inject_poison(struct cxl_dev_state *cxlds,dev_dbg (cxlds->dev,"DPA: 0x%llx already poisoned\n" , dpa);return 0 ; } -if (!mock_poison_add (cxlds, dpa)) -return -ENXIO ; -return 0 ; +return mock_poison_add (cxlds, dpa); }static bool
mock_poison_del(struct cxl_dev_state *cxlds, u64 dpa)
--
2.37.3
RE: [PATCH 1/2] cxl/memdev: Replace ENXIO with EBUSY for inject poison limit reached
In reply to [email protected]Quoted 71 lines
-----Original Message-----
From: [email protected] <[email protected]>
Sent: Thursday, July 4, 2024 8:38 AM
To: Davidlohr Bueso <[email protected]>; Jonathan Cameron <[email protected]>; Dave Jiang <[email protected]>; Alison Schofield <[email protected]>; Vishal Verma <[email protected]>; Ira Weiny <[email protected]>; Dan Williams <[email protected]>
Cc: [email protected]
Subject: [PATCH 1/2] cxl/memdev: Replace ENXIO with EBUSY for inject poison limit reachedFrom: Alison Schofield <[email protected]>
The CXL driver provides a debugfs interface offering users the ability to inject and clear poison to a memdev. Once a user has injected up to the devices limit further injection requests fail with ENXIO until a clear poison is issued.
Users may not have device specs in hand or may want to intentionally hit the limit and then clear. Replace the usual ENXIO return status with EBUSY so users can recognize this failure.
Signed-off-by Alison Schofield <[email protected]>--- Documentation/ABI/testing/debugfs-cxl | 7 ++++--- drivers/cxl/cxlmem.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)Documentation/ABI/testing/debugfs-cxl +4
-3@@ -14,9 +14,10 @@ Description: event to its internal Informational Event log, updates the Event Status register, and if configured, interrupts the host. It is not an error to inject poison into an address that - already has poison present and no error is returned. The - inject_poison attribute is only visible for devices supporting - the capability. + already has poison present and no error is returned. If the + device returns 'Inject Poison Limit Reached' an -EBUSY error + is returned to the user. The inject_poison attribute is only + visible for devices supporting the capability. What: /sys/kernel/debug/memX/clear_poisondrivers/cxl/cxlmem.h +0
-1@@ -161,7 +161,7 @@ struct cxl_mbox_cmd {C (FWRESET , -ENXIO ,"FW failed to activate, needs cold reset" ), \C (HANDLE , -ENXIO ,"one or more Event Record Handles were invalid" ), \ C(PADDR, -EFAULT, "physical address specified is invalid"), \ - C(POISONLMT, -ENXIO, "poison injection limit has been reached"),\
drivers/cxl/cxlmem.h +1
-0+ C(POISONLMT, -EBUSY, "poison injection limit has been reached"),\
C(MEDIAFAILURE, -ENXIO, "permanent issue with the media"),\
C(ABORT, -ENXIO, "background cmd was aborted by device"),
\
C(SECURITY, -ENXIO, "not valid in the current security state"), \
--
2.37.3
Quoted 9 lines · On Wed, 03 Jul 2024, [email protected] wrote:
From: Alison Schofield <[email protected]>
Validation users are asking for the ability to recognize when their injection testing has hit the limit of the device.
Change the drivers error code for this failure to EBUSY and do the same in the cxl-test mock of inject poison.
Quoted 8 lines
Alison Schofield (2):
cxl/memdev: Replace ENXIO with EBUSY for inject poison limit reached cxl/test: Replace ENXIO with EBUSY for inject poison limit reachedDocumentation/ABI/testing/debugfs-cxl | 7 ++++--- drivers/cxl/cxlmem.h | 2 +- tools/testing/cxl/test/mem.c | 13 ++++++------- 3 files changed, 11 insertions(+), 11 deletions(-)
Alison Schofield
maintainerRe: [PATCH 2/2] cxl/test: Replace ENXIO with EBUSY for inject poison limit reached
In reply to Xingtao Yao (Fujitsu)Quoted 2 lines · Xingtao Yao (Fujitsu)
Quoted 2 lines
-----Original Message-----
From: [email protected] <[email protected]>
snip
Quoted 16 lines
tools/testing/cxl/test/mem.c static bool mock_poison_dev_max_injected(struct cxl_dev_state *cxlds) · line 1140
Quoted 9 lines
tools/testing/cxl/test/mem.c +2
-1-static bool mock_poison_add (struct cxl_dev_state *cxlds,u64 dpa) +static int mock_poison_add (struct cxl_dev_state *cxlds,u64 dpa) { +/* Return EBUSY to match the CXL driver handling */ if (mock_poison_dev_max_injected (cxlds)) {dev_dbg (cxlds->dev,"Device poison injection limit has been reached: %d\n" ,MOCK_INJECT_DEV_MAX );There is a tiny issue here, we'd better replace
MOCK_INJECT_DEV_MAXwithpoison_inject_dev_max, as this value can be configured through/sys/bus/platform/drivers/cxl_mock_mem/poison_inject_maxlike:
# echo 128 > /sys/bus/platform/drivers/cxl_mock_mem/poison_inject_max
Quoted 8 lines
after injecting 129 poisons, the “Device or resource busy” occurred, but the debug message still output:
[ 7664.280587] cxl_mock_mem cxl_mem.0: Device poison injection limit has been reached: 8 [ 7664.280591] cxl_mock_mem cxl_mem.0: opcode: 0x4301 sz_in: 8 sz_out: 0 rc: -16Tested-by Xingtao Yao <[email protected]>
Thanks for testing and thanks for finding this issue.
I've folded this fixup into v2 of this patch. Since it's cxl-test, and it's a dev_dbg() message, and it's directly adjacent to what this patch touches, I expect that will be OK. (as opposed to a seperate fixup)
--Alison