CXL Poison List Retrieval & Tracing
[email protected]
maintainerPATCH v5 3/5 cxl/memdev: Add trigger_poison_list sysfs attribute
In reply to [email protected]From: Alison Schofield <[email protected]>
When a boolean 'true' is written to this attribute the memdev driver retrieves the poison list from the device. The list consists of addresses that are poisoned, or would result in poison if accessed, and the source of the poison. This attribute is only visible for devices supporting the capability. The retrieved errors are logged as kernel trace events with the label 'cxl_poison'.
--- Documentation/ABI/testing/sysfs-bus-cxl | 14 ++++++++ drivers/cxl/core/memdev.c | 45 +++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 2 +- 3 files changed, 60 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-bus-cxl +14 -0
@@ -388,3 +388,17 @@ Description: 1), and checks that the hardware accepts the commit request. Reading this value indicates whether the region is committed or not. + + +What: /sys/bus/cxl/devices/memX/trigger_poison_list +Date: November, 2022 +KernelVersion: v6.2 +Contact: [email protected] +Description: + (WO) When a boolean 'true' is written to this attribute the + memdev driver retrieves the poison list from the device. The + list consists of addresses that are poisoned, or would result + in poison if accessed, and the source of the poison. This + attribute is only visible for devices supporting the + capability. The retrieved errors are logged as kernel + trace events with the label 'cxl_poison'.
drivers/cxl/core/memdev.c +45 -0
63 lines not on this page · raw message
drivers/cxl/cxlmem.h +1 -1
@@ -139,7 +139,7 @@ struct cxl_mbox_cmd {C (FWROLLBACK , -ENXIO ,"rolled back to the previous active FW" ), \C (FWRESET , -ENXIO ,"FW failed to activate, needs cold reset" ), \C (HANDLE , -ENXIO ,"one or more Event Record Handles were invalid" ), \ -C (PADDR , -ENXIO ,"physical address specified is invalid" ), \ +C (PADDR , -EFAULT ,"physical address specified is invalid" ), \C (POISONLMT , -ENXIO ,"poison injection limit has been reached" ), \C (MEDIAFAILURE , -ENXIO ,"permanent issue with the media" ), \ C(ABORT, -ENXIO, "background cmd was aborted by device"), \
Signature · 1 line
2.37.3
[email protected]
maintainerPATCH v5 2/5 cxl/trace: Add TRACE support for CXL media-error records
In reply to [email protected]From: Alison Schofield <[email protected]>
CXL devices may support the retrieval of a device poison list. Add a new trace event that the CXL subsystem may use to log the media-error records returned in the poison list.
Log each media-error record as a trace event of type 'cxl_poison'.
When the poison list is requested by region, include the region name and uuid in the trace event.
--- drivers/cxl/core/mbox.c | 6 ++- drivers/cxl/core/trace.h | 83 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-)
drivers/cxl/core/mbox.c +5 -1
@@ -10,6 +10,7 @@#include <cxl.h> #include "core.h" +#include "trace.h" static bool cxl_raw_allow_all;
@@ -898,7 +899,10 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,if (rc)break ; -/* TODO TRACE the media error records */ +for (int i =0 ; i <le16_to_cpu (po->count); i++) +trace_cxl_poison (cxlmd,to_pci_dev (cxlds->dev), + cxlr, &po->record[i], po->flags, + po->overflow_t);/* Protect against an uncleared _FLAG_MORE */ nr_records = nr_records +le16_to_cpu (po->count);
drivers/cxl/core/trace.h +83 -0
95 lines not on this page · raw message
Signature · 1 line
2.37.3
[email protected]
maintainerPATCH v5 1/5 cxl/mbox: Add GET_POISON_LIST mailbox command
In reply to [email protected]From: Alison Schofield <[email protected]>
CXL devices maintain a list of locations that are poisoned or result in poison if the addresses are accessed by the host.
Per the spec (CXL 3.0 8.2.9.8.4.1), the device returns this Poison list as a set of Media Error Records that include the source of the error, the starting device physical address and length. The length is the number of adjacent DPAs in the record and is in units of 64 bytes.
Retrieve the poison list.
--- drivers/cxl/core/mbox.c | 74 +++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 67 +++++++++++++++++++++++++++++++++++++ drivers/cxl/pci.c | 4 +++ 3 files changed, 145 insertions(+)
drivers/cxl/core/mbox.c +74 -0
@@ -4,7 +4,9 @@#include <linux/security.h> #include <linux/debugfs.h> #include <linux/mutex.h> +#include <asm/unaligned.h> #include <cxlmem.h> +#include <cxlpci.h> #include <cxl.h> #include "core.h"
@@ -770,6 +772,7 @@ int cxl_dev_state_identify(struct cxl_dev_state *cxlds)/* See CXL 2.0 Table 175 Identify Memory Device Output Payload */ struct cxl_mbox_identify id;struct cxl_mbox_cmd mbox_cmd; +u32 val;int rc; mbox_cmd = (struct cxl_mbox_cmd ) {
@@ -793,6 +796,11 @@ int cxl_dev_state_identify(struct cxl_dev_state *cxlds) cxlds->lsa_size =le32_to_cpu (id.lsa_size);memcpy (cxlds->firmware_version, id.fw_revision,sizeof (id.fw_revision)); +if (test_bit (CXL_MEM_COMMAND_ID_GET_POISON , cxlds->enabled_cmds)) { + val =get_unaligned_le24 (id.poison_list_max_mer); + cxlds->poison.max_mer =min_t (u32, val,CXL_POISON_LIST_MAX ); + } +return 0 ; }EXPORT_SYMBOL_NS_GPL (cxl_dev_state_identify,CXL );
@@ -857,6 +865,72 @@ int cxl_mem_create_range_info(struct cxl_dev_state *cxlds) }EXPORT_SYMBOL_NS_GPL (cxl_mem_create_range_info,CXL ); +int cxl_mem_get_poison (struct cxl_memdev *cxlmd,u64 offset,u64 len, +struct cxl_region *cxlr) +{ +struct cxl_dev_state *cxlds = cxlmd->cxlds; +struct cxl_poison_state *cxlps = &cxlds->poison; +struct cxl_mbox_poison_payload_out *po; +struct cxl_mbox_poison_payload_in pi; +struct cxl_mbox_cmd mbox_cmd; +int nr_records =0 ; +int rc; + + rc =mutex_lock_interruptible (&cxlps->getpoison_lock); +if (rc) +return rc; + + po = cxlps->getpoison_po; + pi.offset =cpu_to_le64 (offset); + pi.length =cpu_to_le64 (len /CXL_POISON_LEN_MULT ); + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_GET_POISON , + .size_in =sizeof (pi), + .payload_in = &pi, + .size_out = cxlds->payload_size, + .payload_out = po, + .min_out =struct_size (po, record,0 ), + }; + +do { + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +break ; + +/* TODO TRACE the media error records */ + +/* Protect against an uncleared _FLAG_MORE */ + nr_records = nr_records +le16_to_cpu (po->count); +if (nr_records >= cxlps->max_mer) { +dev_dbg (&cxlmd->dev,"Max Error Records reached: %d\n" , + nr_records); +break ; + } + }while (po->flags &CXL_POISON_FLAG_MORE ); + +mutex_unlock (&cxlps->getpoison_lock); +return rc; +} +EXPORT_SYMBOL_NS_GPL (cxl_mem_get_poison,CXL ); + +int cxl_poison_state_init (struct cxl_dev_state *cxlds) +{ +struct cxl_poison_state *cxlps = &cxlds->poison; + +if (!test_bit (CXL_MEM_COMMAND_ID_GET_POISON , cxlds->enabled_cmds)) +return 0 ; + + cxlps->getpoison_po =devm_kzalloc (cxlds->dev, cxlds->payload_size, +GFP_KERNEL ); +if (!cxlps->getpoison_po) +return -ENOMEM ; + +mutex_init (&cxlps->getpoison_lock); +return 0 ; +} +EXPORT_SYMBOL_NS_GPL (cxl_poison_state_init,CXL ); +struct cxl_dev_state *cxl_dev_state_create (struct device *dev) {struct cxl_dev_state *cxlds;
drivers/cxl/cxlmem.h +67 -0
97 lines not on this page · raw message
drivers/cxl/pci.c +4 -0
@@ -482,6 +482,10 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (rc)return rc; + rc =cxl_poison_state_init (cxlds); +if (rc) +return rc; + rc =cxl_dev_state_identify (cxlds);if (rc)return rc;
Signature · 1 line
2.37.3
[email protected]
maintainerPATCH v5 5/5 tools/testing/cxl: Mock support for Get Poison List
In reply to [email protected]From: Alison Schofield <[email protected]>
Make mock memdevs support the Get Poison List mailbox command. Return a fake poison error record when the get poison list command is issued.
This supports testing the kernel tracing and cxl list capabilities for media errors.
--- tools/testing/cxl/test/mem.c | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
tools/testing/cxl/test/mem.c +42 -0
@@ -7,6 +7,7 @@#include <linux/delay.h> #include <linux/sizes.h> #include <linux/bits.h> +#include <asm/unaligned.h> #include <cxlmem.h> #define LSA_SIZE SZ_128K
@@ -38,6 +39,10 @@ static struct cxl_cel_entry mock_cel[] = { .opcode = cpu_to_le16(CXL_MBOX_OP_GET_HEALTH_INFO), .effect = cpu_to_le16(0), }, + { + .opcode = cpu_to_le16(CXL_MBOX_OP_GET_POISON), + .effect = cpu_to_le16(0), + }, };/* See CXL 2.0 Table 181 Get Health Info Output Payload */
@@ -141,6 +146,8 @@ static int mock_id(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)cpu_to_le64 (DEV_SIZE /CXL_CAPACITY_MULTIPLIER ), }; +put_unaligned_le24 (CXL_POISON_LIST_MAX , id.poison_list_max_mer); +if (cmd->size_out <sizeof (id))return -EINVAL ;
@@ -558,6 +565,34 @@ static int mock_health_info(struct cxl_dev_state *cxlds,return 0 ; } +static int mock_get_poison (struct cxl_dev_state *cxlds, +struct cxl_mbox_cmd *cmd) +{ +struct cxl_mbox_poison_payload_in *pi = cmd->payload_in; + +/* Mock one poison record at pi.offset for 64 bytes */ +struct { +struct cxl_mbox_poison_payload_out po; +struct cxl_poison_record record; + } mock_plist = { + .po = { + .count =cpu_to_le16 (1 ), + }, + .record = { + .length =cpu_to_le32 (1 ), + .address =cpu_to_le64 (pi->offset + +CXL_POISON_SOURCE_INJECTED ), + }, + }; + +if (cmd->size_out <sizeof (mock_plist)) +return -EINVAL ; + +memcpy (cmd->payload_out, &mock_plist,sizeof (mock_plist)); + cmd->size_out =sizeof (mock_plist); +return 0 ; +} +static int cxl_mock_mbox_send (struct cxl_dev_state *cxlds,struct cxl_mbox_cmd *cmd) {struct device *dev = cxlds->dev;
@@ -606,6 +641,9 @@ static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *case CXL_MBOX_OP_PASSPHRASE_SECURE_ERASE : rc =mock_passphrase_secure_erase (cxlds, cmd);break ; +case CXL_MBOX_OP_GET_POISON : + rc =mock_get_poison (cxlds, cmd); +break ;default :break ; }
@@ -664,6 +702,10 @@ static int cxl_mock_mem_probe(struct platform_device *pdev)if (rc)return rc; + rc =cxl_poison_state_init (cxlds); +if (rc) +return rc; + rc =cxl_dev_state_identify (cxlds);if (rc)return rc;
Signature · 1 line
2.37.3
[email protected]
maintainerPATCH v5 4/5 cxl/region: Add trigger_poison_list sysfs attribute
In reply to [email protected]From: Alison Schofield <[email protected]>
When a boolean 'true' is written to this attribute the region driver retrieves the poison list for the capacity each device contributes to this region. The list consists of addresses that are poisoned, or would result in poison if accessed, and the source of the poison. The retrieved errors are logged as kernel trace events with the label 'cxl_poison'.
Devices not supporting the poison list capability are ignored.
--- Documentation/ABI/testing/sysfs-bus-cxl | 14 +++++++++++ drivers/cxl/core/region.c | 33 +++++++++++++++++++++++++ 2 files changed, 47 insertions(+)
Documentation/ABI/testing/sysfs-bus-cxl +14 -0
@@ -402,3 +402,17 @@ Description: attribute is only visible for devices supporting the capability. The retrieved errors are logged as kernel trace events with the label 'cxl_poison'. + + +What: /sys/bus/cxl/devices/regionZ/trigger_poison_list +Date: November, 2022 +KernelVersion: v6.2 +Contact: [email protected] +Description: + (WO) When a boolean 'true' is written to this attribute the + region driver retrieves the poison list for the capacity + each device contributes to this region. The list consists + of addresses that are poisoned, or would result in poison + if accessed, and the source of the poison. The retrieved + errors are logged as kernel trace events with the label + 'cxl_poison'.
drivers/cxl/core/region.c +33 -0
@@ -72,6 +72,38 @@ static int is_dup(struct device *match, void *data)return 0 ; } +static ssize_t trigger_poison_list_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t len) +{ +struct cxl_region *cxlr =to_cxl_region (dev); +struct cxl_region_params *p = &cxlr->params; +struct cxl_endpoint_decoder *cxled; +struct cxl_memdev *cxlmd; +u64 offset, length; +int rc, i; +bool tmp; + +if (kstrtobool (buf, &tmp)) +return -EINVAL ; + +for (i =0 ; i < p->nr_targets; i++) { + cxled = p->targets[i]; + cxlmd =cxled_to_memdev (cxled); +if (!test_bit (CXL_MEM_COMMAND_ID_GET_POISON , + cxlmd->cxlds->enabled_cmds)) +continue ; + + offset =cxl_dpa_resource_start (cxled); + length =cxl_dpa_size (cxled); + rc =cxl_mem_get_poison (cxlmd, offset, length, cxlr); +if (rc) +return rc; + } +return len; +} +static DEVICE_ATTR_WO (trigger_poison_list); +static ssize_t uuid_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t len) {
@@ -570,6 +602,7 @@ static struct attribute *cxl_region_attrs[] = { &dev_attr_interleave_granularity.attr, &dev_attr_resource.attr, &dev_attr_size.attr, + &dev_attr_trigger_poison_list.attr, NULL, };
Signature · 1 line
2.37.3
[email protected]
maintainerv5 cover CXL Poison List Retrieval & Tracing
From: Alison Schofield <[email protected]>
**RESENDING this cover letter previously mis-threaded.
Changes in v5:
- Rebase on cxl/next
- Use struct_size() to calc mbox cmd payload .min_out
- s/INTERNAL/INJECTED mocked poison record source
- Added Jonathan Reviewed-by tag on Patch 3
Link to v4:
https://lore.kernel.org/linux-cxl/[email protected]/
Add support for retrieving device poison lists and store the returned error records as kernel trace events.
The handling of the poison list is guided by the CXL 3.0 Specification Section 8.2.9.8.4.1. [1]
Example, triggered by memdev:
$ echo 1 > /sys/bus/cxl/devices/mem3/trigger_poison_list cxl_poison: memdev=mem3 pcidev=cxl_mem.3 region= region_uuid=00000000-0000-0000-0000-000000000000 dpa=0x0 length=0x40 source=Internal flags= overflow_time=0
Example, triggered by region:
$ echo 1 > /sys/bus/cxl/devices/region5/trigger_poison_list cxl_poison: memdev=mem0 pcidev=cxl_mem.0 region=region5 region_uuid=bfcb7a29-890e-4a41-8236-fe22221fc75c dpa=0x0 length=0x40 source=Internal flags= overflow_time=0 cxl_poison: memdev=mem1 pcidev=cxl_mem.1 region=region5 region_uuid=bfcb7a29-890e-4a41-8236-fe22221fc75c dpa=0x0 length=0x40 source=Internal flags= overflow_time=0
[1]: https://www.computeexpresslink.org/download-the-specification
Alison Schofield (5):
cxl/mbox: Add GET_POISON_LIST mailbox command cxl/trace: Add TRACE support for CXL media-error records cxl/memdev: Add trigger_poison_list sysfs attribute cxl/region: Add trigger_poison_list sysfs attribute tools/testing/cxl: Mock support for Get Poison List
Documentation/ABI/testing/sysfs-bus-cxl | 28 +++++++++ drivers/cxl/core/mbox.c | 78 +++++++++++++++++++++++ drivers/cxl/core/memdev.c | 45 ++++++++++++++ drivers/cxl/core/region.c | 33 ++++++++++ drivers/cxl/core/trace.h | 83 +++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 69 +++++++++++++++++++- drivers/cxl/pci.c | 4 ++ tools/testing/cxl/test/mem.c | 42 +++++++++++++ 8 files changed, 381 insertions(+), 1 deletion(-)
base-commit: 589c3357370a596ef7c99c00baca8ac799fce531
Signature · 1 line
2.37.3
Quoted 16 lines · alison.schofield@ wrote:
From: Alison Schofield <[email protected]>
Subject: [PATCH v5 0/5] CXL Poison List Retrieval & Tracing
Changes in v5:
- Rebase on cxl/next
- Usestruct_size()to calc mbox cmd payload .min_out
- s/INTERNAL/INJECTED mocked poison record source
- Added Jonathan Reviewed-by tag on Patch 3Link to v4:
https://lore.kernel.org/linux-cxl/[email protected]/Add support for retrieving device poison lists and store the returned error records as kernel trace events.
Quoted 6 lines
The handling of the poison list is guided by the CXL 3.0 Specification Section 8.2.9.8.4.1. [1]
Example, triggered by memdev:
$ echo 1 > /sys/bus/cxl/devices/mem3/trigger_poison_list cxl_poison: memdev=mem3 pcidev=cxl_mem.3 region= region_uuid=00000000-0000-0000-0000-000000000000 dpa=0x0 length=0x40 source=Internal flags= overflow_time=0
I think the pcidev= field wants to be called something like "host" or "parent", because there is no strict requirement that a 'struct cxl_memdev' is related to a 'struct pci_dev'. In fact in that example "cxl_mem.3" is a 'struct platform_device'. Now that I think about it, I think all CXL device events should be emitting the PCIe serial number for the memdev.
I will look in the implementation, but do region= and region_uuid= get populated when mem3 is a member of the region?
Quoted 30 lines
Example, triggered by region:
$ echo 1 > /sys/bus/cxl/devices/region5/trigger_poison_list cxl_poison: memdev=mem0 pcidev=cxl_mem.0 region=region5 region_uuid=bfcb7a29-890e-4a41-8236-fe22221fc75c dpa=0x0 length=0x40 source=Internal flags= overflow_time=0 cxl_poison: memdev=mem1 pcidev=cxl_mem.1 region=region5 region_uuid=bfcb7a29-890e-4a41-8236-fe22221fc75c dpa=0x0 length=0x40 source=Internal flags= overflow_time=0[1]: https://www.computeexpresslink.org/download-the-specification
Alison Schofield (5):
cxl/mbox: AddGET_POISON_LISTmailbox command cxl/trace: Add TRACE support for CXL media-error records cxl/memdev: Addtrigger_poison_listsysfs attribute cxl/region: Addtrigger_poison_listsysfs attributetools/testing/cxl: Mock support for Get Poison ListDocumentation/ABI/testing/sysfs-bus-cxl | 28 +++++++++ drivers/cxl/core/mbox.c | 78 +++++++++++++++++++++++ drivers/cxl/core/memdev.c | 45 ++++++++++++++ drivers/cxl/core/region.c | 33 ++++++++++ drivers/cxl/core/trace.h | 83 +++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 69 +++++++++++++++++++- drivers/cxl/pci.c | 4 ++ tools/testing/cxl/test/mem.c | 42 +++++++++++++ 8 files changed, 381 insertions(+), 1 deletion(-)base-commit:
589c3357370a596ef7c99c00baca8ac799fce531Signature · 1 line
2.37.3
RE: [PATCH v5 1/5] cxl/mbox: Add GET_POISON_LIST mailbox command
In reply to [email protected]Quoted 43 lines · alison.schofield@ wrote:
From: Alison Schofield <[email protected]>
CXL devices maintain a list of locations that are poisoned or result in poison if the addresses are accessed by the host.
Per the spec (CXL 3.0 8.2.9.8.4.1), the device returns this Poison list as a set of Media Error Records that include the source of the error, the starting device physical address and length. The length is the number of adjacent DPAs in the record and is in units of 64 bytes.
Retrieve the poison list.
Reviewed-by Jonathan Cameron <[email protected]>Signed-off-by Alison Schofield <[email protected]>--- drivers/cxl/core/mbox.c | 74 +++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 67 +++++++++++++++++++++++++++++++++++++ drivers/cxl/pci.c | 4 +++ 3 files changed, 145 insertions(+)drivers/cxl/core/mbox.c +3
-0@@ -4,7 +4,9 @@#include <linux/security.h> #include <linux/debugfs.h> #include <linux/mutex.h> +#include <asm/unaligned.h> #include <cxlmem.h> +#include <cxlpci.h> #include <cxl.h> #include "core.h" @@ -770,6 +772,7 @@ int cxl_dev_state_identify(struct cxl_dev_state *cxlds)/* See CXL 2.0 Table 175 Identify Memory Device Output Payload */ struct cxl_mbox_identify id;struct cxl_mbox_cmd mbox_cmd; +u32 val;int rc; mbox_cmd = (struct cxl_mbox_cmd ) {
drivers/cxl/core/mbox.c int cxl_dev_state_identify(struct cxl_dev_state *cxlds) · line 801
Quoted 6 lines
drivers/cxl/core/mbox.c +3
-0@@ -793,6 +796,11 @@ int cxl_dev_state_identify(struct cxl_dev_state *cxlds) cxlds->lsa_size =le32_to_cpu (id.lsa_size);memcpy (cxlds->firmware_version, id.fw_revision,sizeof (id.fw_revision)); +if (test_bit (CXL_MEM_COMMAND_ID_GET_POISON , cxlds->enabled_cmds)) { + val =get_unaligned_le24 (id.poison_list_max_mer); + cxlds->poison.max_mer =min_t (u32, val,CXL_POISON_LIST_MAX );
There are not many abbreviations in the subsystem, most names are spelled out. So, s/cxlds->poison.max_mer/cxlds->poison.max_errors/, or something like that?
Quoted 6 lines
drivers/cxl/core/mbox.c +2
-0+ } +return 0 ; }EXPORT_SYMBOL_NS_GPL (cxl_dev_state_identify,CXL );
drivers/cxl/core/mbox.c int cxl_mem_create_range_info(struct cxl_dev_state *cxlds) · line 872
Quoted 8 lines
drivers/cxl/core/mbox.c +5
-0@@ -857,6 +865,72 @@ int cxl_mem_create_range_info(struct cxl_dev_state *cxlds) }EXPORT_SYMBOL_NS_GPL (cxl_mem_create_range_info,CXL ); +int cxl_mem_get_poison (struct cxl_memdev *cxlmd,u64 offset,u64 len, +struct cxl_region *cxlr) +{ +struct cxl_dev_state *cxlds = cxlmd->cxlds; +struct cxl_poison_state *cxlps = &cxlds->poison;
I think similar to the cxl_nvd / cxl_nvb concern that Dave raised, @cxlds is too close to @cxlps. Just type out cxlds->poison.lock. No need to call it getpoison_lock when it is already in 'struct cxl_poison_state'.
Quoted 76 lines
drivers/cxl/core/mbox.c +61
-0+struct cxl_mbox_poison_payload_out *po; +struct cxl_mbox_poison_payload_in pi; +struct cxl_mbox_cmd mbox_cmd; +int nr_records =0 ; +int rc; + + rc =mutex_lock_interruptible (&cxlps->getpoison_lock); +if (rc) +return rc; + + po = cxlps->getpoison_po; + pi.offset =cpu_to_le64 (offset); + pi.length =cpu_to_le64 (len /CXL_POISON_LEN_MULT ); + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_GET_POISON , + .size_in =sizeof (pi), + .payload_in = &pi, + .size_out = cxlds->payload_size, + .payload_out = po, + .min_out =struct_size (po, record,0 ), + }; + +do { + rc =cxl_internal_send_cmd (cxlds, &mbox_cmd); +if (rc) +break ; + +/* TODO TRACE the media error records */ + +/* Protect against an uncleared _FLAG_MORE */ + nr_records = nr_records +le16_to_cpu (po->count); +if (nr_records >= cxlps->max_mer) { +dev_dbg (&cxlmd->dev,"Max Error Records reached: %d\n" , + nr_records); +break ; + } + }while (po->flags &CXL_POISON_FLAG_MORE ); + +mutex_unlock (&cxlps->getpoison_lock); +return rc; +} +EXPORT_SYMBOL_NS_GPL (cxl_mem_get_poison,CXL ); + +int cxl_poison_state_init (struct cxl_dev_state *cxlds) +{ +struct cxl_poison_state *cxlps = &cxlds->poison; + +if (!test_bit (CXL_MEM_COMMAND_ID_GET_POISON , cxlds->enabled_cmds)) +return 0 ; + + cxlps->getpoison_po =devm_kzalloc (cxlds->dev, cxlds->payload_size, +GFP_KERNEL ); +if (!cxlps->getpoison_po) +return -ENOMEM ; + +mutex_init (&cxlps->getpoison_lock); +return 0 ; +} +EXPORT_SYMBOL_NS_GPL (cxl_poison_state_init,CXL ); +struct cxl_dev_state *cxl_dev_state_create (struct device *dev) {struct cxl_dev_state *cxlds;drivers/cxl/cxlmem.h +4
-0@@ -193,6 +193,24 @@ struct cxl_endpoint_dvsec_info {struct range dvsec_range[2 ]; }; +/** +* struct cxl_poison_state - Poison list retrieval +* +* @max_mer: Maximum media error records held in device cache
drivers/cxl/cxlmem.h struct cxl_endpoint_dvsec_info { · line 209
Quoted 10 lines
drivers/cxl/cxlmem.h +10
-0+* @getpoison_po: The poison list payload returned by device +* @getpoison_lock: Protect reads of the poison list +* +* Reads of the poison list are synchronized to ensure that a reader +* does not get an incomplete list because their request overlapped +* (was interrupted or preceded by) another read request of the same +* DPA range. CXL Spec 3.0 Section 8.2.9.8.4.1 +*/ +struct cxl_poison_state { +u32 max_mer;
Suggested rename to 'max_errors' mentioned earlier.
drivers/cxl/cxlmem.h struct cxl_endpoint_dvsec_info { · line 210
Quoted 1 line
drivers/cxl/cxlmem.h +1
-0+void *getpoison_po;
No need for this to be named getpoison as its already prefixed by "cxlds->poison". This can also be a specific typed data-structure pointer, right?
drivers/cxl/cxlmem.h struct cxl_endpoint_dvsec_info { · line 211
Quoted 1 line
drivers/cxl/cxlmem.h +1
-0+struct mutex getpoison_lock;/* Protect reads of poison list */
Suggested rename 'lock' mentioned earlier.
Quoted 100 lines
drivers/cxl/cxlmem.h +51
-0+}; +/** * struct cxl_dev_state - The driver device state * @@ -211,6 +229,7 @@ struct cxl_endpoint_dvsec_info {* (CXL 2.0 8.2.9.5.1.1 Identify Memory Device) * @mbox_mutex: Mutex to synchronize mailbox access. * @firmware_version: Firmware version for the memory device. +* @poison: Poison list retrieval * @enabled_cmds: Hardware commands found enabled in CEL. * @exclusive_cmds: Commands that are kernel-internal only * @dpa_res: Overall DPA resource tree for the device @@ -245,6 +264,7 @@ struct cxl_dev_state {size_t lsa_size;struct mutex mbox_mutex;/* Protects device mailbox and firmware */ char firmware_version[0x10 ]; +struct cxl_poison_state poison;DECLARE_BITMAP (enabled_cmds,CXL_MEM_COMMAND_ID_MAX );DECLARE_BITMAP (exclusive_cmds,CXL_MEM_COMMAND_ID_MAX );@@ -372,6 +392,50 @@ struct cxl_mbox_set_partition_info {#define CXL_SET_PARTITION_IMMEDIATE_FLAG BIT(0) +/* Get Poison List CXL 3.0 Spec 8.2.9.8.4.1 */ +struct cxl_mbox_poison_payload_in { +__le64 offset; +__le64 length; +} __packed; + +struct cxl_mbox_poison_payload_out { +u8 flags; +u8 rsvd1; +__le64 overflow_t; +__le16 count; +u8 rsvd2[20 ]; +struct cxl_poison_record { +__le64 address; +__le32 length; +__le32 rsvd; + } __packed record[]; +} __packed; + +/* +* Get Poison List address field encodes the starting +* address of poison, and the source of the poison. +*/ +#define CXL_POISON_START_MASK GENMASK_ULL(63, 6) +#define CXL_POISON_SOURCE_MASK GENMASK(2, 0) + +/* Get Poison List record length is in units of 64 bytes */ +#define CXL_POISON_LEN_MULT 64 + +/* Kernel defined maximum for a list of poison errors */ +#define CXL_POISON_LIST_MAX 1024 + +/* Get Poison List: Payload out flags */ +#define CXL_POISON_FLAG_MORE BIT(0) +#define CXL_POISON_FLAG_OVERFLOW BIT(1) +#define CXL_POISON_FLAG_SCANNING BIT(2) + +/* Get Poison List: Poison Source */ +#define CXL_POISON_SOURCE_UNKNOWN 0 +#define CXL_POISON_SOURCE_EXTERNAL 1 +#define CXL_POISON_SOURCE_INTERNAL 2 +#define CXL_POISON_SOURCE_INJECTED 3 +#define CXL_POISON_SOURCE_VENDOR 7 +/** * struct cxl_mem_command - Driver representation of a memory device command * @info: Command information as it exists for the UAPI @@ -441,6 +505,9 @@ int cxl_mem_create_range_info(struct cxl_dev_state *cxlds);struct cxl_dev_state *cxl_dev_state_create (struct device *dev);void set_exclusive_cxl_commands (struct cxl_dev_state *cxlds,unsigned long *cmds);void clear_exclusive_cxl_commands (struct cxl_dev_state *cxlds,unsigned long *cmds); +int cxl_poison_state_init (struct cxl_dev_state *cxlds); +int cxl_mem_get_poison (struct cxl_memdev *cxlmd,u64 offset,u64 len, +struct cxl_region *cxlr);#ifdef CONFIG_CXL_SUSPEND void cxl_mem_active_inc (void );void cxl_mem_active_dec (void );drivers/cxl/pci.c +4
-0@@ -482,6 +482,10 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (rc)return rc; + rc =cxl_poison_state_init (cxlds); +if (rc) +return rc; + rc =cxl_dev_state_identify (cxlds);if (rc)return rc;Signature · 1 line
2.37.3
Alison Schofield
maintainerRe:
In reply to Dan WilliamsQuoted 24 lines · Dan Williams
Quoted 16 lines · alison.schofield@ wrote:
From: Alison Schofield <[email protected]>
Subject: [PATCH v5 0/5] CXL Poison List Retrieval & Tracing
Changes in v5:
- Rebase on cxl/next
- Usestruct_size()to calc mbox cmd payload .min_out
- s/INTERNAL/INJECTED mocked poison record source
- Added Jonathan Reviewed-by tag on Patch 3Link to v4:
https://lore.kernel.org/linux-cxl/[email protected]/Add support for retrieving device poison lists and store the returned error records as kernel trace events.
Quoted 6 lines
The handling of the poison list is guided by the CXL 3.0 Specification Section 8.2.9.8.4.1. [1]
Example, triggered by memdev:
$ echo 1 > /sys/bus/cxl/devices/mem3/trigger_poison_list cxl_poison: memdev=mem3 pcidev=cxl_mem.3 region= region_uuid=00000000-0000-0000-0000-000000000000 dpa=0x0 length=0x40 source=Internal flags= overflow_time=0
Quoted 6 lines
I think the pcidev= field wants to be called something like "host" or "parent", because there is no strict requirement that a 'struct
cxl_memdev' is related to a 'structpci_dev'. In fact in that example "cxl_mem.3" is a 'structplatform_device'. Now that I think about it, I think all CXL device events should be emitting the PCIe serial number for the memdev.
]
Will do, 'host' and add PCIe serial no.
Quoted 3 lines
I will look in the implementation, but do region= and region_uuid= get populated when mem3 is a member of the region?
Not always.
In the case above, where the trigger was by memdev, no. Region= and region_uuid= (and in the follow-on patch, hpa=) only get populated if the poison was triggered by region, like the case below.
It could be looked up for the by memdev cases. Is that wanted?
Thanks for the reviews Dan!
Quoted 33 lines
Quoted 31 lines
Example, triggered by region:
$ echo 1 > /sys/bus/cxl/devices/region5/trigger_poison_list cxl_poison: memdev=mem0 pcidev=cxl_mem.0 region=region5 region_uuid=bfcb7a29-890e-4a41-8236-fe22221fc75c dpa=0x0 length=0x40 source=Internal flags= overflow_time=0 cxl_poison: memdev=mem1 pcidev=cxl_mem.1 region=region5 region_uuid=bfcb7a29-890e-4a41-8236-fe22221fc75c dpa=0x0 length=0x40 source=Internal flags= overflow_time=0[1]: https://www.computeexpresslink.org/download-the-specification
Alison Schofield (5):
cxl/mbox: AddGET_POISON_LISTmailbox command cxl/trace: Add TRACE support for CXL media-error records cxl/memdev: Addtrigger_poison_listsysfs attribute cxl/region: Addtrigger_poison_listsysfs attributetools/testing/cxl: Mock support for Get Poison ListDocumentation/ABI/testing/sysfs-bus-cxl | 28 +++++++++ drivers/cxl/core/mbox.c | 78 +++++++++++++++++++++++ drivers/cxl/core/memdev.c | 45 ++++++++++++++ drivers/cxl/core/region.c | 33 ++++++++++ drivers/cxl/core/trace.h | 83 +++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 69 +++++++++++++++++++- drivers/cxl/pci.c | 4 ++ tools/testing/cxl/test/mem.c | 42 +++++++++++++ 8 files changed, 381 insertions(+), 1 deletion(-)base-commit:
589c3357370a596ef7c99c00baca8ac799fce531Signature · 1 line
2.37.3
Re:
Quoted 39 lines · Alison Schofield
Quoted 24 lines · Dan Williams
Quoted 16 lines · alison.schofield@ wrote:
From: Alison Schofield <[email protected]>
Subject: [PATCH v5 0/5] CXL Poison List Retrieval & Tracing
Changes in v5:
- Rebase on cxl/next
- Usestruct_size()to calc mbox cmd payload .min_out
- s/INTERNAL/INJECTED mocked poison record source
- Added Jonathan Reviewed-by tag on Patch 3Link to v4:
https://lore.kernel.org/linux-cxl/[email protected]/Add support for retrieving device poison lists and store the returned error records as kernel trace events.
Quoted 6 lines
The handling of the poison list is guided by the CXL 3.0 Specification Section 8.2.9.8.4.1. [1]
Example, triggered by memdev:
$ echo 1 > /sys/bus/cxl/devices/mem3/trigger_poison_list cxl_poison: memdev=mem3 pcidev=cxl_mem.3 region= region_uuid=00000000-0000-0000-0000-000000000000 dpa=0x0 length=0x40 source=Internal flags= overflow_time=0Quoted 6 lines
I think the pcidev= field wants to be called something like "host" or "parent", because there is no strict requirement that a 'struct
cxl_memdev' is related to a 'structpci_dev'. In fact in that example "cxl_mem.3" is a 'structplatform_device'. Now that I think about it, I think all CXL device events should be emitting the PCIe serial number for the memdev.]
Will do, 'host' and add PCIe serial no.
Quoted 3 lines
I will look in the implementation, but do region= and region_uuid= get populated when mem3 is a member of the region?
Quoted 6 lines
Not always.
In the case above, where the trigger was by memdev, no. Region= and region_uuid= (and in the follow-on patch, hpa=) only get populated if the poison was triggered by region, like the case below.It could be looked up for the by memdev cases. Is that wanted?
Just trying to understand the semantics. However, I do think it makes sense for a memdev trigger to lookup information on all impacted regions across all of the device's DPA and the region trigger makes sense to lookup all memdevs, but bounded by the DPA that contributes to that region. I just want to avoid someone having to trigger the region to get extra information that was readily available from a memdev listing.
Quoted 35 lines
Thanks for the reviews Dan!
Quoted 33 lines
Quoted 31 lines
Example, triggered by region:
$ echo 1 > /sys/bus/cxl/devices/region5/trigger_poison_list cxl_poison: memdev=mem0 pcidev=cxl_mem.0 region=region5 region_uuid=bfcb7a29-890e-4a41-8236-fe22221fc75c dpa=0x0 length=0x40 source=Internal flags= overflow_time=0 cxl_poison: memdev=mem1 pcidev=cxl_mem.1 region=region5 region_uuid=bfcb7a29-890e-4a41-8236-fe22221fc75c dpa=0x0 length=0x40 source=Internal flags= overflow_time=0[1]: https://www.computeexpresslink.org/download-the-specification
Alison Schofield (5):
cxl/mbox: AddGET_POISON_LISTmailbox command cxl/trace: Add TRACE support for CXL media-error records cxl/memdev: Addtrigger_poison_listsysfs attribute cxl/region: Addtrigger_poison_listsysfs attributetools/testing/cxl: Mock support for Get Poison ListDocumentation/ABI/testing/sysfs-bus-cxl | 28 +++++++++ drivers/cxl/core/mbox.c | 78 +++++++++++++++++++++++ drivers/cxl/core/memdev.c | 45 ++++++++++++++ drivers/cxl/core/region.c | 33 ++++++++++ drivers/cxl/core/trace.h | 83 +++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 69 +++++++++++++++++++- drivers/cxl/pci.c | 4 ++ tools/testing/cxl/test/mem.c | 42 +++++++++++++ 8 files changed, 381 insertions(+), 1 deletion(-)base-commit:
589c3357370a596ef7c99c00baca8ac799fce531Signature · 1 line
2.37.3
RE: [PATCH v5 3/5] cxl/memdev: Add trigger_poison_list sysfs attribute
In reply to [email protected]Quoted 49 lines · alison.schofield@ wrote:
From: Alison Schofield <[email protected]>
When a boolean 'true' is written to this attribute the memdev driver retrieves the poison list from the device. The list consists of addresses that are poisoned, or would result in poison if accessed, and the source of the poison. This attribute is only visible for devices supporting the capability. The retrieved errors are logged as kernel trace events with the label '
cxl_poison'.Reviewed-by Jonathan Cameron <[email protected]>Signed-off-by Alison Schofield <[email protected]>--- Documentation/ABI/testing/sysfs-bus-cxl | 14 ++++++++ drivers/cxl/core/memdev.c | 45 +++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 2 +- 3 files changed, 60 insertions(+), 1 deletion(-)Documentation/ABI/testing/sysfs-bus-cxl +14
-0@@ -388,3 +388,17 @@ Description: 1), and checks that the hardware accepts the commit request. Reading this value indicates whether the region is committed or not. + + +What: /sys/bus/cxl/devices/memX/trigger_poison_list +Date: November, 2022 +KernelVersion: v6.2 +Contact: [email protected] +Description: + (WO) When a boolean 'true' is written to this attribute the + memdev driver retrieves the poison list from the device. The + list consists of addresses that are poisoned, or would result + in poison if accessed, and the source of the poison. This + attribute is only visible for devices supporting the + capability. The retrieved errors are logged as kernel + trace events with the label 'cxl_poison'.drivers/cxl/core/memdev.c +2
-0@@ -106,12 +106,49 @@ static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr, }static DEVICE_ATTR_RO (numa_node); +static ssize_t trigger_poison_list_store(struct device *dev, + struct device_attribute *attr,
drivers/cxl/core/memdev.c static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr, · line 120
Quoted 10 lines
drivers/cxl/core/memdev.c +10
-0+ const char *buf, size_t len) +{ +struct cxl_memdev *cxlmd =to_cxl_memdev (dev); +struct cxl_dev_state *cxlds = cxlmd->cxlds; +u64 offset, length; +bool tmp; +int rc; + +if (kstrtobool (buf, &tmp)) +return -EINVAL ;
Wait, where's the check for "if (tmp)"? Otherwise I can do "echo N > trigger_poison_list" and it will still run. Should probably s/tmp/trigger/.
drivers/cxl/core/memdev.c static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr, · line 126
Quoted 6 lines
drivers/cxl/core/memdev.c +6
-0+ +/* CXL 3.0 Spec 8.2.9.8.4.1 Separate pmem and ram poison requests */ +if (resource_size (&cxlds->pmem_res)) { + offset = cxlds->pmem_res.start; + length =resource_size (&cxlds->pmem_res); + rc =cxl_mem_get_poison (cxlmd, offset, length,NULL );
Ah now I see why the region information is not provided in the memdev triggers. I think while the scan needs to be done on partition boundary basis, like you have here, I think the region lookup needs to happen on a per-record basis.
However, that's a significant architectural change, so I am going to think out loud about the implications.
A site operator wants to know "is FRU (field-replaceable-unit) X bad, and if so what's the damage?". In that report I expect they want to know if poison impacts media that is allocated to a region (an imminent danger) or is in free space (a problem for a later date). If the memdev trigger does all the region lookup per record it provides that information. Further if the memdev trigger reliably provides region information it allows the region trigger ABI to be deleted. The region trigger can be replaced in userspace with logic that does:
set tracepoint filter to look for region_id == $region for endpoint decoder in $region
trigger associated memdev
...so I do think the arch change is worth it, but I am willing to hear counter arguments.
Alison Schofield
maintainerRe:
In reply to Dan WilliamsQuoted 45 lines · Dan Williams
Quoted 44 lines · Alison Schofield
Quoted 24 lines · Dan Williams
Quoted 16 lines · alison.schofield@ wrote:
From: Alison Schofield <[email protected]>
Subject: [PATCH v5 0/5] CXL Poison List Retrieval & Tracing
Changes in v5:
- Rebase on cxl/next
- Usestruct_size()to calc mbox cmd payload .min_out
- s/INTERNAL/INJECTED mocked poison record source
- Added Jonathan Reviewed-by tag on Patch 3Link to v4:
https://lore.kernel.org/linux-cxl/[email protected]/Add support for retrieving device poison lists and store the returned error records as kernel trace events.
Quoted 6 lines
The handling of the poison list is guided by the CXL 3.0 Specification Section 8.2.9.8.4.1. [1]
Example, triggered by memdev:
$ echo 1 > /sys/bus/cxl/devices/mem3/trigger_poison_list cxl_poison: memdev=mem3 pcidev=cxl_mem.3 region= region_uuid=00000000-0000-0000-0000-000000000000 dpa=0x0 length=0x40 source=Internal flags= overflow_time=0Quoted 6 lines
I think the pcidev= field wants to be called something like "host" or "parent", because there is no strict requirement that a 'struct
cxl_memdev' is related to a 'structpci_dev'. In fact in that example "cxl_mem.3" is a 'structplatform_device'. Now that I think about it, I think all CXL device events should be emitting the PCIe serial number for the memdev.]
Will do, 'host' and add PCIe serial no.
Quoted 3 lines
I will look in the implementation, but do region= and region_uuid= get populated when mem3 is a member of the region?
Not always.
In the case above, where the trigger was by memdev, no. Region= and region_uuid= (and in the follow-on patch, hpa=) only get populated if the poison was triggered by region, like the case below.
Quoted 9 lines
Quoted 1 line
It could be looked up for the by memdev cases. Is that wanted?
Just trying to understand the semantics. However, I do think it makes sense for a memdev trigger to lookup information on all impacted regions across all of the device's DPA and the region trigger makes sense to lookup all memdevs, but bounded by the DPA that contributes to that region. I just want to avoid someone having to trigger the region to get extra information that was readily available from a memdev listing.
Dan -
Confirming my take-away from this email, and our chat:
Remove the by-region trigger_poison_list option entirely. User space needs to trigger by-memdev the memdevs participating in the region and filter those events by region.
Add the region info (region name, uuid) to the TRACE_EVENTs when the poisoned DPA is part of any region.
Alison
Quoted 37 lines
Quoted 35 lines
Thanks for the reviews Dan!
Quoted 33 lines
Quoted 31 lines
Example, triggered by region:
$ echo 1 > /sys/bus/cxl/devices/region5/trigger_poison_list cxl_poison: memdev=mem0 pcidev=cxl_mem.0 region=region5 region_uuid=bfcb7a29-890e-4a41-8236-fe22221fc75c dpa=0x0 length=0x40 source=Internal flags= overflow_time=0 cxl_poison: memdev=mem1 pcidev=cxl_mem.1 region=region5 region_uuid=bfcb7a29-890e-4a41-8236-fe22221fc75c dpa=0x0 length=0x40 source=Internal flags= overflow_time=0[1]: https://www.computeexpresslink.org/download-the-specification
Alison Schofield (5):
cxl/mbox: AddGET_POISON_LISTmailbox command cxl/trace: Add TRACE support for CXL media-error records cxl/memdev: Addtrigger_poison_listsysfs attribute cxl/region: Addtrigger_poison_listsysfs attributetools/testing/cxl: Mock support for Get Poison ListDocumentation/ABI/testing/sysfs-bus-cxl | 28 +++++++++ drivers/cxl/core/mbox.c | 78 +++++++++++++++++++++++ drivers/cxl/core/memdev.c | 45 ++++++++++++++ drivers/cxl/core/region.c | 33 ++++++++++ drivers/cxl/core/trace.h | 83 +++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 69 +++++++++++++++++++- drivers/cxl/pci.c | 4 ++ tools/testing/cxl/test/mem.c | 42 +++++++++++++ 8 files changed, 381 insertions(+), 1 deletion(-)base-commit:
589c3357370a596ef7c99c00baca8ac799fce531Signature · 1 line
2.37.3
Alison Schofield
maintainerRe: [PATCH v5 3/5] cxl/memdev: Add trigger_poison_list sysfs attribute
In reply to Dan WilliamsQuoted 48 lines · Dan Williams
Quoted 47 lines · alison.schofield@ wrote:
From: Alison Schofield <[email protected]>
When a boolean 'true' is written to this attribute the memdev driver retrieves the poison list from the device. The list consists of addresses that are poisoned, or would result in poison if accessed, and the source of the poison. This attribute is only visible for devices supporting the capability. The retrieved errors are logged as kernel trace events with the label '
cxl_poison'.Reviewed-by Jonathan Cameron <[email protected]>Signed-off-by Alison Schofield <[email protected]>--- Documentation/ABI/testing/sysfs-bus-cxl | 14 ++++++++ drivers/cxl/core/memdev.c | 45 +++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 2 +- 3 files changed, 60 insertions(+), 1 deletion(-)Documentation/ABI/testing/sysfs-bus-cxl +14
-0@@ -388,3 +388,17 @@ Description: 1), and checks that the hardware accepts the commit request. Reading this value indicates whether the region is committed or not. + + +What: /sys/bus/cxl/devices/memX/trigger_poison_list +Date: November, 2022 +KernelVersion: v6.2 +Contact: [email protected] +Description: + (WO) When a boolean 'true' is written to this attribute the + memdev driver retrieves the poison list from the device. The + list consists of addresses that are poisoned, or would result + in poison if accessed, and the source of the poison. This + attribute is only visible for devices supporting the + capability. The retrieved errors are logged as kernel + trace events with the label 'cxl_poison'.drivers/cxl/core/memdev.c +0
-0@@ -106,12 +106,49 @@ static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr, }static DEVICE_ATTR_RO (numa_node);
Quoted 16 lines
drivers/cxl/core/memdev.c static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr, · line 120
Quoted 12 lines
drivers/cxl/core/memdev.c +12
-0+static ssize_t trigger_poison_list_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t len) +{ +struct cxl_memdev *cxlmd =to_cxl_memdev (dev); +struct cxl_dev_state *cxlds = cxlmd->cxlds; +u64 offset, length; +bool tmp; +int rc; + +if (kstrtobool (buf, &tmp)) +return -EINVAL ;Wait, where's the check for "if (tmp)"? Otherwise I can do "echo N >
trigger_poison_list" and it will still run. Should probably s/tmp/trigger/.
Got it.
(I guess I was too loose w the trigger, thinking you write anything to it, I'm triggering.)
Quoted 13 lines
drivers/cxl/core/memdev.c static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr, · line 126
Quoted 7 lines
drivers/cxl/core/memdev.c +6
-0+ +/* CXL 3.0 Spec 8.2.9.8.4.1 Separate pmem and ram poison requests */ +if (resource_size (&cxlds->pmem_res)) { + offset = cxlds->pmem_res.start; + length =resource_size (&cxlds->pmem_res); + rc =cxl_mem_get_poison (cxlmd, offset, length,NULL );Ah now I see why the region information is not provided in the memdev triggers. I think while the scan needs to be done on partition boundary basis, like you have here, I think the region lookup needs to happen on a per-record basis.
Quoted 2 lines
However, that's a significant architectural change, so I am going to think out loud about the implications.
I'm thinking that adding region info to the trace event isn't starting here. That will be looked up when we log the event. Basically assuming assuming find regions memdev participates in, and look for which one maps this DPA.
Quoted 10 lines
A site operator wants to know "is FRU (field-replaceable-unit) X bad, and if so what's the damage?". In that report I expect they want to know if poison impacts media that is allocated to a region (an imminent danger) or is in free space (a problem for a later date). If the memdev trigger does all the region lookup per record it provides that information. Further if the memdev trigger reliably provides region information it allows the region trigger ABI to be deleted. The region trigger can be replaced in userspace with logic that does:
Quoted 6 lines
set tracepoint filter to look for
region_id== $region for endpoint decoder in $region
trigger associated memdev...so I do think the arch change is worth it, but I am willing to hear counter arguments.
My only counter argument was that we could let them have it both ways, but, simplifying and reducing code in kernel is good!
Re:
In reply to Alison SchofieldQuoted 58 lines · Alison Schofield
Quoted 45 lines · Dan Williams
Quoted 44 lines · Alison Schofield
Quoted 24 lines · Dan Williams
Quoted 16 lines · alison.schofield@ wrote:
From: Alison Schofield <[email protected]>
Subject: [PATCH v5 0/5] CXL Poison List Retrieval & Tracing
Changes in v5:
- Rebase on cxl/next
- Usestruct_size()to calc mbox cmd payload .min_out
- s/INTERNAL/INJECTED mocked poison record source
- Added Jonathan Reviewed-by tag on Patch 3Link to v4:
https://lore.kernel.org/linux-cxl/[email protected]/Add support for retrieving device poison lists and store the returned error records as kernel trace events.
Quoted 6 lines
The handling of the poison list is guided by the CXL 3.0 Specification Section 8.2.9.8.4.1. [1]
Example, triggered by memdev:
$ echo 1 > /sys/bus/cxl/devices/mem3/trigger_poison_list cxl_poison: memdev=mem3 pcidev=cxl_mem.3 region= region_uuid=00000000-0000-0000-0000-000000000000 dpa=0x0 length=0x40 source=Internal flags= overflow_time=0Quoted 6 lines
I think the pcidev= field wants to be called something like "host" or "parent", because there is no strict requirement that a 'struct
cxl_memdev' is related to a 'structpci_dev'. In fact in that example "cxl_mem.3" is a 'structplatform_device'. Now that I think about it, I think all CXL device events should be emitting the PCIe serial number for the memdev.]
Will do, 'host' and add PCIe serial no.
Quoted 3 lines
I will look in the implementation, but do region= and region_uuid= get populated when mem3 is a member of the region?
Not always.
In the case above, where the trigger was by memdev, no. Region= and region_uuid= (and in the follow-on patch, hpa=) only get populated if the poison was triggered by region, like the case below.Quoted 9 lines
Quoted 1 line
It could be looked up for the by memdev cases. Is that wanted?
Just trying to understand the semantics. However, I do think it makes sense for a memdev trigger to lookup information on all impacted regions across all of the device's DPA and the region trigger makes sense to lookup all memdevs, but bounded by the DPA that contributes to that region. I just want to avoid someone having to trigger the region to get extra information that was readily available from a memdev listing.
Dan -
Quoted 8 lines
Confirming my take-away from this email, and our chat:
Remove the by-region
trigger_poison_listoption entirely. User space needs to trigger by-memdev the memdevs participating in the region and filter those events by region.Add the region info (region name, uuid) to the
TRACE_EVENTswhen the poisoned DPA is part of any region.
That's what I was thinking, yes. So the internals of cxl_mem_get_poison() will take the cxl_region_rwsem for read and compare the device's endpoint decoder settings against the media error records to do the region (and later HPA) lookup.
RE: [PATCH v5 5/5] tools/testing/cxl: Mock support for Get Poison List
In reply to [email protected]Quoted 51 lines · alison.schofield@ wrote:
From: Alison Schofield <[email protected]>
Make mock memdevs support the Get Poison List mailbox command. Return a fake poison error record when the get poison list command is issued.
This supports testing the kernel tracing and cxl list capabilities for media errors.
Reviewed-by Jonathan Cameron <[email protected]>Signed-off-by Alison Schofield <[email protected]>--- tools/testing/cxl/test/mem.c | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)tools/testing/cxl/test/mem.c +7
-0@@ -7,6 +7,7 @@#include <linux/delay.h> #include <linux/sizes.h> #include <linux/bits.h> +#include <asm/unaligned.h> #include <cxlmem.h> #define LSA_SIZE SZ_128K@@ -38,6 +39,10 @@ static struct cxl_cel_entry mock_cel[] = { .opcode = cpu_to_le16(CXL_MBOX_OP_GET_HEALTH_INFO), .effect = cpu_to_le16(0), }, + { + .opcode = cpu_to_le16(CXL_MBOX_OP_GET_POISON), + .effect = cpu_to_le16(0), + }, };/* See CXL 2.0 Table 181 Get Health Info Output Payload */ @@ -141,6 +146,8 @@ static int mock_id(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)cpu_to_le64 (DEV_SIZE /CXL_CAPACITY_MULTIPLIER ), }; +put_unaligned_le24 (CXL_POISON_LIST_MAX , id.poison_list_max_mer); +if (cmd->size_out <sizeof (id))return -EINVAL ;@@ -558,6 +565,34 @@ static int mock_health_info(struct cxl_dev_state *cxlds,return 0 ; }
tools/testing/cxl/test/mem.c static int mock_health_info(struct cxl_dev_state *cxlds, · line 577
Quoted 10 lines
tools/testing/cxl/test/mem.c +10
-0+static int mock_get_poison (struct cxl_dev_state *cxlds, +struct cxl_mbox_cmd *cmd) +{ +struct cxl_mbox_poison_payload_in *pi = cmd->payload_in; + +/* Mock one poison record at pi.offset for 64 bytes */ +struct { +struct cxl_mbox_poison_payload_out po; +struct cxl_poison_record record; + } mock_plist = {
...I think this needs to be __packed as well otherwise the compiler could inject alignment padding between these 2 packed structures.
tools/testing/cxl/test/mem.c static int mock_health_info(struct cxl_dev_state *cxlds, · line 583
Quoted 6 lines
tools/testing/cxl/test/mem.c +6
-0+ .po = { + .count = cpu_to_le16(1), + }, + .record = { + .length = cpu_to_le32(1), + .address = cpu_to_le64(pi->offset +
sparse says there is a missing le64_to_cpu(pi->offset) here
Re: [PATCH v5 3/5] cxl/memdev: Add trigger_poison_list sysfs attribute
In reply to Alison SchofieldQuoted 82 lines · Alison Schofield
Quoted 48 lines · Dan Williams
Quoted 47 lines · alison.schofield@ wrote:
From: Alison Schofield <[email protected]>
When a boolean 'true' is written to this attribute the memdev driver retrieves the poison list from the device. The list consists of addresses that are poisoned, or would result in poison if accessed, and the source of the poison. This attribute is only visible for devices supporting the capability. The retrieved errors are logged as kernel trace events with the label '
cxl_poison'.Reviewed-by Jonathan Cameron <[email protected]>Signed-off-by Alison Schofield <[email protected]>--- Documentation/ABI/testing/sysfs-bus-cxl | 14 ++++++++ drivers/cxl/core/memdev.c | 45 +++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 2 +- 3 files changed, 60 insertions(+), 1 deletion(-)Documentation/ABI/testing/sysfs-bus-cxl +14
-0@@ -388,3 +388,17 @@ Description: 1), and checks that the hardware accepts the commit request. Reading this value indicates whether the region is committed or not. + + +What: /sys/bus/cxl/devices/memX/trigger_poison_list +Date: November, 2022 +KernelVersion: v6.2 +Contact: [email protected] +Description: + (WO) When a boolean 'true' is written to this attribute the + memdev driver retrieves the poison list from the device. The + list consists of addresses that are poisoned, or would result + in poison if accessed, and the source of the poison. This + attribute is only visible for devices supporting the + capability. The retrieved errors are logged as kernel + trace events with the label 'cxl_poison'.drivers/cxl/core/memdev.c +0
-0@@ -106,12 +106,49 @@ static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr, }static DEVICE_ATTR_RO (numa_node);Quoted 16 lines
drivers/cxl/core/memdev.c static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr, · line 120
Quoted 12 lines
drivers/cxl/core/memdev.c +12
-0+static ssize_t trigger_poison_list_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t len) +{ +struct cxl_memdev *cxlmd =to_cxl_memdev (dev); +struct cxl_dev_state *cxlds = cxlmd->cxlds; +u64 offset, length; +bool tmp; +int rc; + +if (kstrtobool (buf, &tmp)) +return -EINVAL ;Wait, where's the check for "if (tmp)"? Otherwise I can do "echo N >
trigger_poison_list" and it will still run. Should probably s/tmp/trigger/.Got it.
(I guess I was too loose w the trigger, thinking you write anything to it, I'm triggering.)Quoted 13 lines
drivers/cxl/core/memdev.c static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr, · line 126
Quoted 7 lines
drivers/cxl/core/memdev.c +6
-0+ +/* CXL 3.0 Spec 8.2.9.8.4.1 Separate pmem and ram poison requests */ +if (resource_size (&cxlds->pmem_res)) { + offset = cxlds->pmem_res.start; + length =resource_size (&cxlds->pmem_res); + rc =cxl_mem_get_poison (cxlmd, offset, length,NULL );Ah now I see why the region information is not provided in the memdev triggers. I think while the scan needs to be done on partition boundary basis, like you have here, I think the region lookup needs to happen on a per-record basis.
Quoted 7 lines
Quoted 2 lines
However, that's a significant architectural change, so I am going to think out loud about the implications.
I'm thinking that adding region info to the trace event isn't starting here. That will be looked up when we log the event. Basically assuming assuming find regions memdev participates in, and look for which one maps this DPA.
Yup, we're on the same page. Just compare the dpa of the error record to the dpa ranges of the enabled decoders on the memdev then it is a straightforward cxld->region de-reference from there.
Quoted 15 lines
Quoted 15 lines
A site operator wants to know "is FRU (field-replaceable-unit) X bad, and if so what's the damage?". In that report I expect they want to know if poison impacts media that is allocated to a region (an imminent danger) or is in free space (a problem for a later date). If the memdev trigger does all the region lookup per record it provides that information. Further if the memdev trigger reliably provides region information it allows the region trigger ABI to be deleted. The region trigger can be replaced in userspace with logic that does:
set tracepoint filter to look for
region_id== $region for endpoint decoder in $region
trigger associated memdev
Quoted 5 lines
Quoted 2 lines
...so I do think the arch change is worth it, but I am willing to hear counter arguments.
My only counter argument was that we could let them have it both ways, but, simplifying and reducing code in kernel is good!
Yeah, in this case I think the memdev interface is -><- that close to being a general purpose poison lister with all the relevant info in the record. The only thing missing after the info is populated is the filter logic, but event filtering is a first class feature of the trace events subsystem.