memory: scrub: introduce subsystem + CXL/ACPI-RAS2 drivers
Subsystems (6)
v7 cover memory: scrub: introduce subsystem + CXL/ACPI-RAS2 drivers
From: Shiju Jose <[email protected]>
'Previously known as: cxl: Add support for CXL feature commands,
CXL device patrol scrub control and DDR5 ECS control features'
https://lore.kernel.org/lkml/[email protected]/
Introduce generic memory scrub subsystem which allows user to control underlying memory scrubbers in the system via the sysfs scrub control interface.
Memory scrub is a feature where an ECC engine reads data from each memory media location, corrects with an ECC if necessary and writes the corrected data back to the same memory media location. More details can be found in Reference [1].
CXL patrol scrub and DDR5 ECS and ACPI RAS2 HW based memory patrol scrub features are added as use cases for the scrub subsystem to expose the scrub controls to the user.
CXL device patrol scrub and DDR5 ECS features needs support for the CXL feature mail box commands. CXL device scrub driver registers with the memory scrub subsystem to expose the scrub controls for CXL device patrol and ECS scrubs to the user.
RAS2 HW based memory patrol scrub needs RAS2 PCC interfaces and ACPI RAS2 driver for communication b/w kernel and firmware. ACPI RAS2 Driver adds platform device, for each memory feature, which binds to the RAS2 memory driver.
Memory RAS2 driver registers with the memory scrub subsystem to expose the RAS2 scrub controls to the user.
Series adds,
1. scrub subsystem driver supports configuring memory scrubs in the system.
2. support for CXL feature mailbox commands.
3. CXL device scrub driver supporting patrol scrub control and ECS control features.
4. register CXL device patrol scrub and ECS with scrub subsystem.
5. common library for RAS2 PCC interfaces.
6. ACPI RAS2 driver for ACPI RAS2 feature table (RAS2).
7. memory RAS2 driver and registers with scrub subsystem.
The QEMU series to support the CXL specific scrub features is available here,
https://lore.kernel.org/qemu-devel/[email protected]/
References:
1. Discussions on kernel support of memory error detection and patrol scrubber can be found here.
https://lore.kernel.org/all/[email protected]/
2. Discussions on RASF:
https://lore.kernel.org/lkml/[email protected]/#r
https://patchwork.kernel.org/project/linux-arm-kernel/patch/CS1PR84MB0038718F49DBC0FF03919E1184390@CS1PR84MB0038.NAMPRD84.PROD.OUTLOOK.COM/
Changes
v6 -> v7:
1. Main changes for comments from Jonathan.
1.1. CXL
- Changes for deal with small mail box and supporting multipart feature data transfers.
- Provide more specific parameters to mbox supported/get/set features interface functions.
- kvmalloc -> kmalloc in CXL scrub mem allocation for feature commands.
- Changed the way using __free(kfree)
- Removed readback and verify for setting CXL scrub patrol and ECS parameters. Could be added later if needed.
- In is_visible() callback functions for scrub control sysfs attrs changed to writeback the default attribute mode value instead of setting per attrs.
- Add documentation for sysfs interfaces for CXL ECS scrub control.
1.2. RAS2
- In rasf common code, rename rasf to ras2 because RASF seems obselete.
- Replace pr_* with dev_* log function calls from ACPI RAS2 and memory RAS2 drivers.
- In rasf common code, rename rasf to ras2.
- Removed including unnecessary .h file from memory RAS2 driver.
- In is_visible() callback functions for scrub control sysfs attrs changed to writeback the default attribute mode value instead of setting per attribute.
2. Changes for comments from Fan.
- Add debug message if cxl patrol scrub and ecs init function calls fail.
3. Updated cover letter for feedback from Dan Williams.
v5 -> v6:
1. Changes for comments from Davidlohr, Thanks.
- Update CXL feature code based on spec 3.1.
- attrb -> attr
- Use enums with default counting.
2. Rebased to the latest kernel.
v4 -> v5:
1. Following are the main changes made based on the feedback from Dan Williams on v4. 1.1. In the scrub subsystem the common scrub control attributes are statically defined instead of dynamically created.
1.2. Add scrub subsystem support externally defined attribute group.
Add CXL ECS driver define ECS specific attribute group and pass to
the scrub subsystem.
1.3. Move cxl_mem_ecs_init() to cxl/core/region.c so that the CXL region_id
is used in the registration with the scrub subsystem.
1.4. Add previously posted RASF common and RAS2 patches to this scrub series.
2. Add support for the 'enable_background_scrub' attribute
for RAS2, on request from Bill Schwartz([email protected]).
v3 -> v4:
1. Fixes for the warnings/errors reported by kernel test robot.
2. Add support for reading the 'enable' attribute of CXL patrol scrub.
Changes
v2 -> v3:
1. Changes for comments from Davidlohr, Thanks.
- Updated cxl scrub kconfig
- removed usage of the flag is_support_feature from the function cxl_mem_get_supported_feature_entry().
- corrected spelling error.
- removed unnecessary debug message.
- removed export feature commands to the userspace.
2. Possible fix for the warnings/errors reported by kernel test robot.
3. Add documentation for the common scrub configure atrributes.
v1 -> v2:
1. Changes for comments from Dave Jiang, Thanks.
- Split patches.
- reversed xmas tree declarations.
- declared flags as enums.
- removed few unnecessary variable initializations.
- replaced PTR_ERR_OR_ZERO() with IS_ERR() and PTR_ERR().
- add auto clean declarations.
- replaced while loop with for loop.
- Removed allocation from cxl_get_supported_features() and cxl_get_feature() and make change to take allocated memory pointer from the caller.
- replaced if/else with switch case.
- replaced sprintf() with sysfs_emit() in 2 places.
- replaced goto label with return in few functions.
2. removed unused code for supported attributes from ecs.
3. Included following common patch for scrub configure driver to this series.
"memory: scrub: Add scrub driver supports configuring memory scrubbers
in the system"
A Somasundaram (1):
ACPI:RAS2: Add common library for RAS2 PCC interfaces
Shiju Jose (11):
cxl/mbox: Add GET_SUPPORTED_FEATURES mailbox command cxl/mbox: Add GET_FEATURE mailbox command
cxl/mbox: Add SET_FEATURE mailbox command
cxl/memscrub: Add CXL device patrol scrub control feature cxl/memscrub: Add CXL device ECS control feature
memory: scrub: Add scrub subsystem driver supports configuring memory
scrubs in the system
cxl/memscrub: Register CXL device patrol scrub with scrub subsystem
driver
cxl/memscrub: Register CXL device ECS with scrub subsystem driver
ACPICA: ACPI 6.5: Add support for RAS2 table
ACPI:RAS2: Add driver for ACPI RAS2 feature table (RAS2)
memory: RAS2: Add memory RAS2 driver
.../ABI/testing/sysfs-class-cxl-ecs-configure | 79 ++ .../ABI/testing/sysfs-class-scrub-configure | 91 ++ drivers/acpi/Kconfig | 14 + drivers/acpi/Makefile | 1 + drivers/acpi/ras2_acpi.c | 97 ++ drivers/acpi/ras2_acpi_common.c | 272 +++++ drivers/cxl/Kconfig | 21 + drivers/cxl/core/Makefile | 1 + drivers/cxl/core/mbox.c | 143 +++ drivers/cxl/core/memscrub.c | 954 ++++++++++++++++++ drivers/cxl/core/region.c | 3 + drivers/cxl/cxlmem.h | 124 +++ drivers/cxl/pci.c | 4 + drivers/memory/Kconfig | 15 + drivers/memory/Makefile | 3 + drivers/memory/ras2.c | 364 +++++++ drivers/memory/ras2_common.c | 282 ++++++ drivers/memory/scrub/Kconfig | 11 + drivers/memory/scrub/Makefile | 6 + drivers/memory/scrub/memory-scrub.c | 369 +++++++ include/acpi/actbl2.h | 137 +++ include/acpi/ras2_acpi.h | 59 ++ include/memory/memory-scrub.h | 79 ++ include/memory/ras2.h | 88 ++ 24 files changed, 3217 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-cxl-ecs-configure create mode 100644 Documentation/ABI/testing/sysfs-class-scrub-configure create mode 100755 drivers/acpi/ras2_acpi.c create mode 100755 drivers/acpi/ras2_acpi_common.c create mode 100644 drivers/cxl/core/memscrub.c create mode 100644 drivers/memory/ras2.c create mode 100644 drivers/memory/ras2_common.c create mode 100644 drivers/memory/scrub/Kconfig create mode 100644 drivers/memory/scrub/Makefile create mode 100755 drivers/memory/scrub/memory-scrub.c create mode 100644 include/acpi/ras2_acpi.h create mode 100755 include/memory/memory-scrub.h create mode 100755 include/memory/ras2.h
Signature · 1 line
2.34.1
RFC PATCH v7 1/12 cxl/mbox: Add GET_SUPPORTED_FEATURES mailbox command
From: Shiju Jose <[email protected]>
Add support for GET_SUPPORTED_FEATURES mailbox command.
CXL spec 3.1 section 8.2.9.6 describes optional device specific features. CXL devices supports features with changeable attributes.
Get Supported Features retrieves the list of supported device specific features. The settings of a feature can be retrieved using Get Feature and optionally modified using Set Feature.
--- drivers/cxl/core/mbox.c | 27 +++++++++++++++++++ drivers/cxl/cxlmem.h | 58 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+)
drivers/cxl/core/mbox.c +27 -0
@@ -1290,6 +1290,33 @@ int cxl_set_timestamp(struct cxl_memdev_state *mds) }EXPORT_SYMBOL_NS_GPL (cxl_set_timestamp,CXL ); +int cxl_get_supported_features (struct cxl_memdev_state *mds, +u32 count,u16 start_index, +struct cxl_mbox_get_supp_feats_out *feats_out) +{ +struct cxl_mbox_get_supp_feats_in pi; +struct cxl_mbox_cmd mbox_cmd; +int rc; + + pi.count =cpu_to_le32 (count); + pi.start_index =cpu_to_le16 (start_index); + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_GET_SUPPORTED_FEATURES , + .size_in =sizeof (pi), + .payload_in = &pi, + .size_out = count, + .payload_out = feats_out, + .min_out =sizeof (*feats_out), + }; + rc =cxl_internal_send_cmd (mds, &mbox_cmd); +if (rc <0 ) +return rc; + +return 0 ; +} +EXPORT_SYMBOL_NS_GPL (cxl_get_supported_features,CXL ); +int cxl_mem_get_poison (struct cxl_memdev *cxlmd,u64 offset,u64 len,struct cxl_region *cxlr) {
drivers/cxl/cxlmem.h +58 -0
76 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH v7 2/12 cxl/mbox: Add GET_FEATURE mailbox command
In reply to [email protected]From: Shiju Jose <[email protected]>
Add support for GET_FEATURE mailbox command.
CXL spec 3.1 section 8.2.9.6 describes optional device specific features. The settings of a feature can be retrieved using Get Feature command.
--- drivers/cxl/core/mbox.c | 49 +++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 25 +++++++++++++++++++++ 2 files changed, 74 insertions(+)
drivers/cxl/core/mbox.c +49 -0
@@ -1317,6 +1317,55 @@ int cxl_get_supported_features(struct cxl_memdev_state *mds, }EXPORT_SYMBOL_NS_GPL (cxl_get_supported_features,CXL ); +size_t cxl_get_feature (struct cxl_memdev_state *mds, +const uuid_t feat_uuid,void *feat_out, +size_t feat_out_size, +size_t feat_out_min_size, +enum cxl_get_feat_selection selection) +{ +struct cxl_dev_state *cxlds = &mds->cxlds; +struct cxl_mbox_get_feat_in pi; +struct cxl_mbox_cmd mbox_cmd; +size_t data_rcvd_size =0 ; +size_t data_to_rd_size; +int rc; + +if (feat_out_size < feat_out_min_size) { +dev_err (cxlds->dev, +"%s: feature out buffer size(%lu) is not big enough\n" , + __func__, feat_out_size); +return 0 ; + } + + pi.uuid = feat_uuid; + pi.selection = selection; +do { +if ((feat_out_min_size - data_rcvd_size) <= mds->payload_size) + data_to_rd_size = feat_out_min_size - data_rcvd_size; +else + data_to_rd_size = mds->payload_size; + + pi.offset =cpu_to_le16 (data_rcvd_size); + pi.count =cpu_to_le16 (data_to_rd_size); + + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_GET_FEATURE , + .size_in =sizeof (pi), + .payload_in = &pi, + .size_out = data_to_rd_size, + .payload_out = feat_out + data_rcvd_size, + .min_out = data_to_rd_size, + }; + rc =cxl_internal_send_cmd (mds, &mbox_cmd); +if (rc <0 || mbox_cmd.size_out ==0 ) +return 0 ; + data_rcvd_size += mbox_cmd.size_out; + }while (data_rcvd_size < feat_out_min_size); + +return data_rcvd_size; +} +EXPORT_SYMBOL_NS_GPL (cxl_get_feature,CXL ); +int cxl_mem_get_poison (struct cxl_memdev *cxlmd,u64 offset,u64 len,struct cxl_region *cxlr) {
drivers/cxl/cxlmem.h +25 -0
@@ -530,6 +530,7 @@ enum cxl_opcode {CXL_MBOX_OP_GET_SUPPORTED_LOGS =0x0400 ,CXL_MBOX_OP_GET_LOG =0x0401 ,CXL_MBOX_OP_GET_SUPPORTED_FEATURES =0x0500 , +CXL_MBOX_OP_GET_FEATURE =0x0501 ,CXL_MBOX_OP_IDENTIFY =0x4000 ,CXL_MBOX_OP_GET_PARTITION_INFO =0x4100 , CXL_MBOX_OP_SET_PARTITION_INFO = 0x4101,
@@ -753,6 +754,25 @@ struct cxl_mbox_get_supp_feats_out {struct cxl_mbox_supp_feat_entry feat_entries[]; } __packed; +/* Get Feature CXL 3.1 Spec 8.2.9.6.2 */ +/* +* Get Feature input payload +* CXL rev 3.1 section 8.2.9.6.2 Table 8-99 +*/ +enum cxl_get_feat_selection { +CXL_GET_FEAT_SEL_CURRENT_VALUE , +CXL_GET_FEAT_SEL_DEFAULT_VALUE , +CXL_GET_FEAT_SEL_SAVED_VALUE , +CXL_GET_FEAT_SEL_MAX +}; + +struct cxl_mbox_get_feat_in { +uuid_t uuid; +__le16 offset; +__le16 count; +u8 selection; +} __packed; +/* Get Poison List CXL 3.0 Spec 8.2.9.8.4.1 */ struct cxl_mbox_poison_in {__le64 offset;
@@ -887,6 +907,11 @@ int cxl_set_timestamp(struct cxl_memdev_state *mds);int cxl_get_supported_features (struct cxl_memdev_state *mds,u32 count,u16 start_index,struct cxl_mbox_get_supp_feats_out *feats_out); +size_t cxl_get_feature (struct cxl_memdev_state *mds, +const uuid_t feat_uuid,void *feat_out, +size_t feat_out_size, +size_t feat_out_min_size, +enum cxl_get_feat_selection selection);int cxl_poison_state_init (struct cxl_memdev_state *mds);int cxl_mem_get_poison (struct cxl_memdev *cxlmd,u64 offset,u64 len,struct cxl_region *cxlr);
Signature · 1 line
2.34.1
RFC PATCH v7 3/12 cxl/mbox: Add SET_FEATURE mailbox command
In reply to [email protected]From: Shiju Jose <[email protected]>
Add support for SET_FEATURE mailbox command.
CXL spec 3.1 section 8.2.9.6 describes optional device specific features. CXL devices supports features with changeable attributes.
The settings of a feature can be optionally modified using Set Feature command.
--- drivers/cxl/core/mbox.c | 67 +++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 30 ++++++++++++++++++ 2 files changed, 97 insertions(+)
drivers/cxl/core/mbox.c +67 -0
@@ -1366,6 +1366,73 @@ size_t cxl_get_feature(struct cxl_memdev_state *mds, }EXPORT_SYMBOL_NS_GPL (cxl_get_feature,CXL ); +int cxl_set_feature (struct cxl_memdev_state *mds, +const uuid_t feat_uuid,u8 feat_version, +void *feat_data,size_t feat_data_size, +u8 feat_flag) +{ +struct cxl_memdev_set_feat_pi { +struct cxl_mbox_set_feat_hdr hdr; +u8 feat_data[]; + } __packed; +size_t data_in_size, data_sent_size =0 ; +struct cxl_mbox_cmd mbox_cmd; +size_t hdr_size; +int rc =0 ; + + struct cxl_memdev_set_feat_pi *pi __free(kfree) = +kmalloc (mds->payload_size,GFP_KERNEL ); + pi->hdr.uuid = feat_uuid; + pi->hdr.version = feat_version; + feat_flag &= ~CXL_SET_FEAT_FLAG_DATA_TRANSFER_MASK ; + hdr_size =sizeof (pi->hdr); +/* +* Check minimum mbox payload size is available for +* the feature data transfer. +*/ +if (hdr_size +10 > mds->payload_size) +return -ENOMEM ; + +if ((hdr_size + feat_data_size) <= mds->payload_size) { + pi->hdr.flags =cpu_to_le32 (feat_flag | +CXL_SET_FEAT_FLAG_FULL_DATA_TRANSFER ); + data_in_size = feat_data_size; + }else { + pi->hdr.flags =cpu_to_le32 (feat_flag | +CXL_SET_FEAT_FLAG_INITIATE_DATA_TRANSFER ); + data_in_size = mds->payload_size - hdr_size; + } + +do { + pi->hdr.offset =cpu_to_le16 (data_sent_size); +memcpy (pi->feat_data, feat_data + data_sent_size, data_in_size); + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_SET_FEATURE , + .size_in = hdr_size + data_in_size, + .payload_in = pi, + }; + rc =cxl_internal_send_cmd (mds, &mbox_cmd); +if (rc <0 ) +return rc; + + data_sent_size += data_in_size; +if (data_sent_size >= feat_data_size) +return 0 ; + +if ((feat_data_size - data_sent_size) <= (mds->payload_size - hdr_size)) { + data_in_size = feat_data_size - data_sent_size; + pi->hdr.flags =cpu_to_le32 (feat_flag | +CXL_SET_FEAT_FLAG_FINISH_DATA_TRANSFER ); + }else { + pi->hdr.flags =cpu_to_le32 (feat_flag | +CXL_SET_FEAT_FLAG_CONTINUE_DATA_TRANSFER ); + } + }while (true); + +return rc; +} +EXPORT_SYMBOL_NS_GPL (cxl_set_feature,CXL ); +int cxl_mem_get_poison (struct cxl_memdev *cxlmd,u64 offset,u64 len,struct cxl_region *cxlr) {
drivers/cxl/cxlmem.h +30 -0
@@ -531,6 +531,7 @@ enum cxl_opcode {CXL_MBOX_OP_GET_LOG =0x0401 ,CXL_MBOX_OP_GET_SUPPORTED_FEATURES =0x0500 ,CXL_MBOX_OP_GET_FEATURE =0x0501 , +CXL_MBOX_OP_SET_FEATURE =0x0502 ,CXL_MBOX_OP_IDENTIFY =0x4000 ,CXL_MBOX_OP_GET_PARTITION_INFO =0x4100 , CXL_MBOX_OP_SET_PARTITION_INFO = 0x4101,
@@ -773,6 +774,31 @@ struct cxl_mbox_get_feat_in {u8 selection; } __packed; +/* Set Feature CXL 3.1 Spec 8.2.9.6.3 */ +/* +* Set Feature input payload +* CXL rev 3.1 section 8.2.9.6.3 Table 8-101 +*/ +/* Set Feature : Payload in flags */ +#define CXL_SET_FEAT_FLAG_DATA_TRANSFER_MASK GENMASK(2, 0) +enum cxl_set_feat_flag_data_transfer { +CXL_SET_FEAT_FLAG_FULL_DATA_TRANSFER , +CXL_SET_FEAT_FLAG_INITIATE_DATA_TRANSFER , +CXL_SET_FEAT_FLAG_CONTINUE_DATA_TRANSFER , +CXL_SET_FEAT_FLAG_FINISH_DATA_TRANSFER , +CXL_SET_FEAT_FLAG_ABORT_DATA_TRANSFER , +CXL_SET_FEAT_FLAG_DATA_TRANSFER_MAX +}; +#define CXL_SET_FEAT_FLAG_DATA_SAVED_ACROSS_RESET BIT(3) + +struct cxl_mbox_set_feat_hdr { +uuid_t uuid; +__le32 flags; +__le16 offset; +u8 version; +u8 rsvd[9 ]; +} __packed; +/* Get Poison List CXL 3.0 Spec 8.2.9.8.4.1 */ struct cxl_mbox_poison_in {__le64 offset;
@@ -912,6 +938,10 @@ size_t cxl_get_feature(struct cxl_memdev_state *mds,size_t feat_out_size, size_t feat_out_min_size, enum cxl_get_feat_selection selection); +int cxl_set_feature (struct cxl_memdev_state *mds, +const uuid_t feat_uuid,u8 feat_version, +void *feat_data,size_t feat_data_size, +u8 feat_flag);int cxl_poison_state_init (struct cxl_memdev_state *mds);int cxl_mem_get_poison (struct cxl_memdev *cxlmd,u64 offset,u64 len,struct cxl_region *cxlr);
Signature · 1 line
2.34.1
Re: [RFC PATCH v7 03/12] cxl/mbox: Add SET_FEATURE mailbox command
Quoted 38 lines · On Fri, Feb 23, 2024 at 10:37:14PM +0800, [email protected] wrote:
From: Shiju Jose <[email protected]>
Add support for
SET_FEATUREmailbox command.CXL spec 3.1 section 8.2.9.6 describes optional device specific features. CXL devices supports features with changeable attributes.
The settings of a feature can be optionally modified using Set Feature command.Signed-off-by Shiju Jose <[email protected]>--- drivers/cxl/core/mbox.c | 67 +++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 30 ++++++++++++++++++ 2 files changed, 97 insertions(+)drivers/cxl/core/mbox.c +15
-0@@ -1366,6 +1366,73 @@ size_t cxl_get_feature(struct cxl_memdev_state *mds, }EXPORT_SYMBOL_NS_GPL (cxl_get_feature,CXL ); +int cxl_set_feature (struct cxl_memdev_state *mds, +const uuid_t feat_uuid,u8 feat_version, +void *feat_data,size_t feat_data_size, +u8 feat_flag) +{ +struct cxl_memdev_set_feat_pi { +struct cxl_mbox_set_feat_hdr hdr; +u8 feat_data[]; + } __packed; +size_t data_in_size, data_sent_size =0 ; +struct cxl_mbox_cmd mbox_cmd; +size_t hdr_size; +int rc =0 ; + + struct cxl_memdev_set_feat_pi *pi __free(kfree) =
drivers/cxl/core/mbox.c size_t cxl_get_feature(struct cxl_memdev_state *mds, · line 1393
Quoted 10 lines
drivers/cxl/core/mbox.c +10
-0+kmalloc (mds->payload_size,GFP_KERNEL ); + pi->hdr.uuid = feat_uuid; + pi->hdr.version = feat_version; + feat_flag &= ~CXL_SET_FEAT_FLAG_DATA_TRANSFER_MASK ; + hdr_size =sizeof (pi->hdr); +/* +* Check minimum mbox payload size is available for +* the feature data transfer. +*/ +if (hdr_size +10 > mds->payload_size)
Where does this magic number come from?
Fan
Quoted 103 lines
drivers/cxl/core/mbox.c +42
-0+return -ENOMEM ; + +if ((hdr_size + feat_data_size) <= mds->payload_size) { + pi->hdr.flags =cpu_to_le32 (feat_flag | +CXL_SET_FEAT_FLAG_FULL_DATA_TRANSFER ); + data_in_size = feat_data_size; + }else { + pi->hdr.flags =cpu_to_le32 (feat_flag | +CXL_SET_FEAT_FLAG_INITIATE_DATA_TRANSFER ); + data_in_size = mds->payload_size - hdr_size; + } + +do { + pi->hdr.offset =cpu_to_le16 (data_sent_size); +memcpy (pi->feat_data, feat_data + data_sent_size, data_in_size); + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_SET_FEATURE , + .size_in = hdr_size + data_in_size, + .payload_in = pi, + }; + rc =cxl_internal_send_cmd (mds, &mbox_cmd); +if (rc <0 ) +return rc; + + data_sent_size += data_in_size; +if (data_sent_size >= feat_data_size) +return 0 ; + +if ((feat_data_size - data_sent_size) <= (mds->payload_size - hdr_size)) { + data_in_size = feat_data_size - data_sent_size; + pi->hdr.flags =cpu_to_le32 (feat_flag | +CXL_SET_FEAT_FLAG_FINISH_DATA_TRANSFER ); + }else { + pi->hdr.flags =cpu_to_le32 (feat_flag | +CXL_SET_FEAT_FLAG_CONTINUE_DATA_TRANSFER ); + } + }while (true); + +return rc; +} +EXPORT_SYMBOL_NS_GPL (cxl_set_feature,CXL ); +int cxl_mem_get_poison (struct cxl_memdev *cxlmd,u64 offset,u64 len,struct cxl_region *cxlr) {drivers/cxl/cxlmem.h +30
-0@@ -531,6 +531,7 @@ enum cxl_opcode {CXL_MBOX_OP_GET_LOG =0x0401 ,CXL_MBOX_OP_GET_SUPPORTED_FEATURES =0x0500 ,CXL_MBOX_OP_GET_FEATURE =0x0501 , +CXL_MBOX_OP_SET_FEATURE =0x0502 ,CXL_MBOX_OP_IDENTIFY =0x4000 ,CXL_MBOX_OP_GET_PARTITION_INFO =0x4100 , CXL_MBOX_OP_SET_PARTITION_INFO = 0x4101,@@ -773,6 +774,31 @@ struct cxl_mbox_get_feat_in {u8 selection; } __packed; +/* Set Feature CXL 3.1 Spec 8.2.9.6.3 */ +/* +* Set Feature input payload +* CXL rev 3.1 section 8.2.9.6.3 Table 8-101 +*/ +/* Set Feature : Payload in flags */ +#define CXL_SET_FEAT_FLAG_DATA_TRANSFER_MASK GENMASK(2, 0) +enum cxl_set_feat_flag_data_transfer { +CXL_SET_FEAT_FLAG_FULL_DATA_TRANSFER , +CXL_SET_FEAT_FLAG_INITIATE_DATA_TRANSFER , +CXL_SET_FEAT_FLAG_CONTINUE_DATA_TRANSFER , +CXL_SET_FEAT_FLAG_FINISH_DATA_TRANSFER , +CXL_SET_FEAT_FLAG_ABORT_DATA_TRANSFER , +CXL_SET_FEAT_FLAG_DATA_TRANSFER_MAX +}; +#define CXL_SET_FEAT_FLAG_DATA_SAVED_ACROSS_RESET BIT(3) + +struct cxl_mbox_set_feat_hdr { +uuid_t uuid; +__le32 flags; +__le16 offset; +u8 version; +u8 rsvd[9 ]; +} __packed; +/* Get Poison List CXL 3.0 Spec 8.2.9.8.4.1 */ struct cxl_mbox_poison_in {__le64 offset;@@ -912,6 +938,10 @@ size_t cxl_get_feature(struct cxl_memdev_state *mds,size_t feat_out_size, size_t feat_out_min_size, enum cxl_get_feat_selection selection); +int cxl_set_feature (struct cxl_memdev_state *mds, +const uuid_t feat_uuid,u8 feat_version, +void *feat_data,size_t feat_data_size, +u8 feat_flag);int cxl_poison_state_init (struct cxl_memdev_state *mds);int cxl_mem_get_poison (struct cxl_memdev *cxlmd,u64 offset,u64 len,struct cxl_region *cxlr);Signature · 1 line
2.34.1
RE: [RFC PATCH v7 03/12] cxl/mbox: Add SET_FEATURE mailbox command
Hi Fan,
Quoted 64 lines
-----Original Message-----
From: fan <[email protected]>
Sent: 11 March 2024 21:20
To: Shiju Jose <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; Jonathan Cameron <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; tanxiaofei <[email protected]>; Zengtao (B) <[email protected]>; [email protected]; wanghuiqiang <[email protected]>; Linuxarm <[email protected]>
Subject: Re: [RFC PATCH v7 03/12] cxl/mbox: AddSET_FEATUREmailbox commandQuoted 4 lines · On Fri, Feb 23, 2024 at 10:37:14PM +0800, [email protected] wrote:
From: Shiju Jose <[email protected]>
Add support for
SET_FEATUREmailbox command.Quoted 8 lines
CXL spec 3.1 section 8.2.9.6 describes optional device specific features. CXL devices supports features with changeable attributes.
The settings of a feature can be optionally modified using Set Feature command.Signed-off-by Shiju Jose <[email protected]>--- drivers/cxl/core/mbox.c | 67+++++++++++++++++++++++++++++++++++++++++
Quoted 16 lines
drivers/cxl/cxlmem.h | 30 ++++++++++++++++++ 2 files changed, 97 insertions(+)drivers/cxl/core/mbox.c index renamed from drivers/cxl/core/mbox.c +0
-0
c078e62ea194..d1660bd20bdb100644drivers/cxl/core/mbox.c +6
-0@@ -1366,6 +1366,73 @@ size_t cxl_get_feature(struct cxl_memdev_state *mds, } EXPORT_SYMBOL_NS_GPL(cxl_get_feature, CXL); +int cxl_set_feature (struct cxl_memdev_state *mds, +const uuid_t feat_uuid,u8 feat_version, +void *feat_data,size_t feat_data_size, +u8 feat_flag) +{ + struct cxl_memdev_set_feat_pi {drivers/cxl/core/mbox.c size_t cxl_get_feature(struct cxl_memdev_state · line 1383
Quoted 10 lines
drivers/cxl/core/mbox.c +10
-0+struct cxl_mbox_set_feat_hdr hdr; +u8 feat_data[]; + } __packed; +size_t data_in_size, data_sent_size =0 ; +struct cxl_mbox_cmd mbox_cmd; +size_t hdr_size; +int rc =0 ; + + struct cxl_memdev_set_feat_pi *pi __free(kfree) = + kmalloc(mds->payload_size,
GFP_KERNEL);
Quoted 11 lines
drivers/cxl/core/mbox.c size_t cxl_get_feature(struct cxl_memdev_state *mds, · line 1393
Quoted 9 lines
drivers/cxl/core/mbox.c +9
-0+ pi->hdr.uuid = feat_uuid; + pi->hdr.version = feat_version; + feat_flag &= ~CXL_SET_FEAT_FLAG_DATA_TRANSFER_MASK ; + hdr_size =sizeof (pi->hdr); +/* +* Check minimum mbox payload size is available for +* the feature data transfer. +*/ +if (hdr_size +10 > mds->payload_size)Where does this magic number come from?
This represents minimum extra number of bytes to be available in the mail box for storing the actual feature data to work with multipart feature data transfers. This will be set as a definition in the next version and however not sure the best value to be set.
Quoted 99 lines
Fan
drivers/cxl/core/mbox.c size_t cxl_get_feature(struct cxl_memdev_state *mds, · line 1405
Quoted 5 lines
drivers/cxl/core/mbox.c +5
-0+return -ENOMEM ; + +if ((hdr_size + feat_data_size) <= mds->payload_size) { + pi->hdr.flags = cpu_to_le32(feat_flag | +
CXL_SET_FEAT_FLAG_FULL_DATA_TRANSFER);drivers/cxl/core/mbox.c size_t cxl_get_feature(struct cxl_memdev_state *mds, · line 1405
Quoted 4 lines
drivers/cxl/core/mbox.c +4
-0+ data_in_size = feat_data_size; + }else { + pi->hdr.flags = cpu_to_le32(feat_flag | +
CXL_SET_FEAT_FLAG_INITIATE_DATA_TRANSFER);drivers/cxl/core/mbox.c size_t cxl_get_feature(struct cxl_memdev_state *mds,
Quoted 6 lines
drivers/cxl/core/mbox.c +6
-0+ data_in_size = mds->payload_size - hdr_size; + } + + do { + pi->hdr.offset = cpu_to_le16(data_sent_size); + memcpy(pi->feat_data, feat_data + data_sent_size,
data_in_size);Quoted 4 lines
drivers/cxl/core/mbox.c +4
-0+ mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_SET_FEATURE , + .size_in = hdr_size + data_in_size, + .payload_in = pi,drivers/cxl/core/mbox.c size_t cxl_get_feature(struct cxl_memdev_state *mds,
Quoted 10 lines
drivers/cxl/core/mbox.c +10
-0+ }; + rc =cxl_internal_send_cmd (mds, &mbox_cmd); +if (rc <0 ) +return rc; + + data_sent_size += data_in_size; +if (data_sent_size >= feat_data_size) +return 0 ; + + if ((feat_data_size - data_sent_size) <= (mds->payload_size -
hdr_size)) {drivers/cxl/core/mbox.c size_t cxl_get_feature(struct cxl_memdev_state *mds, · line 1431
Quoted 3 lines
drivers/cxl/core/mbox.c +3
-0+ data_in_size = feat_data_size - data_sent_size; + pi->hdr.flags = cpu_to_le32(feat_flag | +
CXL_SET_FEAT_FLAG_FINISH_DATA_TRANSFER);drivers/cxl/core/mbox.c size_t cxl_get_feature(struct cxl_memdev_state *mds, · line 1405
Quoted 3 lines
drivers/cxl/core/mbox.c +3
-0+ }else { + pi->hdr.flags = cpu_to_le32(feat_flag | +
CXL_SET_FEAT_FLAG_CONTINUE_DATA_TRANSFER);drivers/cxl/cxlmem.h size_t cxl_get_feature(struct cxl_memdev_state
Quoted 54 lines
drivers/cxl/core/mbox.c +7
-0+ } + }while (true); + +return rc; +} +EXPORT_SYMBOL_NS_GPL (cxl_set_feature,CXL ); +int cxl_mem_get_poison (struct cxl_memdev *cxlmd,u64 offset,u64 len,struct cxl_region *cxlr) {drivers/cxl/cxlmem.h index renamed from drivers/cxl/cxlmem.h +0
-0
bcfefff062a6..a8d4104afa53100644drivers/cxl/cxlmem.h +25
-0@@ -531,6 +531,7 @@ enum cxl_opcode {CXL_MBOX_OP_GET_LOG =0x0401 ,CXL_MBOX_OP_GET_SUPPORTED_FEATURES =0x0500 ,CXL_MBOX_OP_GET_FEATURE =0x0501 , +CXL_MBOX_OP_SET_FEATURE =0x0502 ,CXL_MBOX_OP_IDENTIFY =0x4000 ,CXL_MBOX_OP_GET_PARTITION_INFO =0x4100 , CXL_MBOX_OP_SET_PARTITION_INFO = 0x4101,@@ -773,6 +774,31 @@ struct cxl_mbox_get_feat_in {u8 selection; } __packed; +/* Set Feature CXL 3.1 Spec 8.2.9.6.3 */ +/* +* Set Feature input payload +* CXL rev 3.1 section 8.2.9.6.3 Table 8-101 */ +/* Set Feature : Payload in flags */ +#define CXL_SET_FEAT_FLAG_DATA_TRANSFER_MASK GENMASK(2, 0) +enum cxl_set_feat_flag_data_transfer { +CXL_SET_FEAT_FLAG_FULL_DATA_TRANSFER , +CXL_SET_FEAT_FLAG_INITIATE_DATA_TRANSFER , +CXL_SET_FEAT_FLAG_CONTINUE_DATA_TRANSFER , +CXL_SET_FEAT_FLAG_FINISH_DATA_TRANSFER , +CXL_SET_FEAT_FLAG_ABORT_DATA_TRANSFER , +CXL_SET_FEAT_FLAG_DATA_TRANSFER_MAX +}; +#define CXL_SET_FEAT_FLAG_DATA_SAVED_ACROSS_RESET BIT(3) + +struct cxl_mbox_set_feat_hdr { +uuid_t uuid; +__le32 flags; +__le16 offset; +u8 version; +u8 rsvd[9 ]; +} __packed; +/* Get Poison List CXL 3.0 Spec 8.2.9.8.4.1 */ struct cxl_mbox_poison_in {__le64 offset;@@ -912,6 +938,10 @@ size_t cxl_get_feature(struct cxl_memdev_state*mds,
Quoted 13 lines
Quoted 11 lines
drivers/cxl/cxlmem.h +4
-1size_t feat_out_size, size_t feat_out_min_size, enum cxl_get_feat_selection selection); +int cxl_set_feature (struct cxl_memdev_state *mds, +const uuid_t feat_uuid,u8 feat_version, +void *feat_data,size_t feat_data_size, +u8 feat_flag);int cxl_poison_state_init (struct cxl_memdev_state *mds);int cxl_mem_get_poison (struct cxl_memdev *cxlmd,u64 offset,u64 len,struct cxl_region *cxlr); --Quoted 2 lines
2.34.1
Thanks,
Shiju
RFC PATCH v7 4/12 cxl/memscrub: Add CXL device patrol scrub control feature
In reply to [email protected]From: Shiju Jose <[email protected]>
CXL spec 3.1 section 8.2.9.9.11.1 describes the device patrol scrub control feature. The device patrol scrub proactively locates and makes corrections to errors in regular cycle. The patrol scrub control allows the request to configure patrol scrub input configurations.
The patrol scrub control allows the requester to specify the number of hours for which the patrol scrub cycles must be completed, provided that the requested number is not less than the minimum number of hours for the patrol scrub cycle that the device is capable of. In addition, the patrol scrub controls allow the host to disable and enable the feature in case disabling of the feature is needed for other purposes such as performance-aware operations which require the background operations to be turned off.
--- drivers/cxl/Kconfig | 15 +++ drivers/cxl/core/Makefile | 1 + drivers/cxl/core/memscrub.c | 248 ++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 8 ++ drivers/cxl/pci.c | 4 + 5 files changed, 276 insertions(+) create mode 100644 drivers/cxl/core/memscrub.c
drivers/cxl/Kconfig +15 -0
@@ -157,4 +157,19 @@ config CXL_PMU monitoring units and provide standard perf based interfaces. If unsure say 'm'. + +config CXL_SCRUB + bool "CXL: Memory scrub feature" + depends on CXL_PCI + depends on CXL_MEM + help + The CXL memory scrub control is an optional feature allows host to + control the scrub configurations of CXL Type 3 devices, which + support patrol scrub and/or DDR5 ECS(Error Check Scrub). + + Say 'y/n' to enable/disable the CXL memory scrub driver that will + attach to CXL.mem devices for memory scrub control feature. See + sections 8.2.9.9.11.1 and 8.2.9.9.11.2 in the CXL 3.1 specification + for a detailed description of CXL memory scrub control features. + endif
drivers/cxl/core/Makefile +1 -0
@@ -16,3 +16,4 @@ cxl_core-y += pmu.o cxl_core-y += cdat.o cxl_core-$(CONFIG_TRACING) += trace.o cxl_core-$(CONFIG_CXL_REGION) += region.o +cxl_core-$(CONFIG_CXL_SCRUB) += memscrub.o
drivers/cxl/core/memscrub.c new file +248 -0
248 lines not on this page · raw message
drivers/cxl/cxlmem.h +8 -0
@@ -949,6 +949,14 @@ int cxl_trigger_poison_list(struct cxl_memdev *cxlmd);int cxl_inject_poison (struct cxl_memdev *cxlmd,u64 dpa);int cxl_clear_poison (struct cxl_memdev *cxlmd,u64 dpa); +/* cxl memory scrub functions */ +#ifdef CONFIG_CXL_SCRUB +int cxl_mem_patrol_scrub_init (struct cxl_memdev *cxlmd); +#else +static inline int cxl_mem_patrol_scrub_init (struct cxl_memdev *cxlmd) +{return -EOPNOTSUPP ; } +#endif +#ifdef CONFIG_CXL_SUSPEND void cxl_mem_active_inc (void );void cxl_mem_active_dec (void );
drivers/cxl/pci.c +4 -0
@@ -886,6 +886,10 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (rc)return rc; + rc =cxl_mem_patrol_scrub_init (cxlmd); +if (rc) +dev_dbg (&pdev->dev,"CXL patrol scrub init failed\n" ); + rc =devm_cxl_sanitize_setup_notifier (&pdev->dev, cxlmd);if (rc)return rc;
Signature · 1 line
2.34.1
RFC PATCH v7 5/12 cxl/memscrub: Add CXL device ECS control feature
In reply to [email protected]From: Shiju Jose <[email protected]>
CXL spec 3.1 section 8.2.9.9.11.2 describes the DDR5 Error Check Scrub (ECS) control feature.
The Error Check Scrub (ECS) is a feature defined in JEDEC DDR5 SDRAM Specification (JESD79-5) and allows the DRAM to internally read, correct single-bit errors, and write back corrected data bits to the DRAM array while providing transparency to error counts. The ECS control feature allows the request to configure ECS input configurations during system boot or at run-time.
The ECS control allows the requester to change the log entry type, the ECS threshold count provided that the request is within the definition specified in DDR5 mode registers, change mode between codeword mode and row count mode, and reset the ECS counter.
Open Question:
Is cxl_mem_ecs_init() invoked in the right function in cxl/core/region.c?
--- drivers/cxl/core/memscrub.c | 272 +++++++++++++++++++++++++++++++++++- drivers/cxl/core/region.c | 3 + drivers/cxl/cxlmem.h | 3 + 3 files changed, 276 insertions(+), 2 deletions(-)
drivers/cxl/core/memscrub.c +270 -2
@@ -4,8 +4,8 @@* * Copyright (c) 2024 HiSilicon Limited. * -* - Provides functions to configure patrol scrub feature of the -* CXL memory devices. +* - Provides functions to configure patrol scrub and DDR5 ECS features +* of the CXL memory devices. */ #define pr_fmt (fmt) "CXL_MEM_SCRUB: " fmt
@@ -246,3 +246,271 @@ int cxl_mem_patrol_scrub_init(struct cxl_memdev *cxlmd)return 0 ; }EXPORT_SYMBOL_NS_GPL (cxl_mem_patrol_scrub_init,CXL ); + +/* CXL DDR5 ECS control definitions */ +#define CXL_MEMDEV_ECS_GET_FEAT_VERSION 0x01 +#define CXL_MEMDEV_ECS_SET_FEAT_VERSION 0x01 + +static const uuid_t cxl_ecs_uuid = +UUID_INIT (0xe5b13f22 ,0x2328 ,0x4a14 ,0xb8 ,0xba ,0xb9 ,0x69 ,0x1e , \ +0x89 ,0x33 ,0x86 ); + +struct cxl_ecs_context { +struct device *dev; +u16 nregions; +int region_id; +u16 get_feat_size; +u16 set_feat_size; +}; + +/** +* struct cxl_memdev_ecs_params - CXL memory DDR5 ECS parameter data structure. +* @log_entry_type: ECS log entry type, per DRAM or per memory media FRU. +* @threshold: ECS threshold count per GB of memory cells. +* @mode: codeword/row count mode +* 0 : ECS counts rows with errors +* 1 : ECS counts codeword with errors +* @reset_counter: [IN] reset ECC counter to default value. +*/ +struct cxl_memdev_ecs_params { +u8 log_entry_type; +u16 threshold; +u8 mode; +bool reset_counter; +}; + +enum { +CXL_MEMDEV_ECS_PARAM_LOG_ENTRY_TYPE , +CXL_MEMDEV_ECS_PARAM_THRESHOLD , +CXL_MEMDEV_ECS_PARAM_MODE , +CXL_MEMDEV_ECS_PARAM_RESET_COUNTER , +}; + +#define CXL_MEMDEV_ECS_LOG_ENTRY_TYPE_MASK GENMASK(1, 0) +#define CXL_MEMDEV_ECS_REALTIME_REPORT_CAP_MASK BIT(0) +#define CXL_MEMDEV_ECS_THRESHOLD_COUNT_MASK GENMASK(2, 0) +#define CXL_MEMDEV_ECS_MODE_MASK BIT(3) +#define CXL_MEMDEV_ECS_RESET_COUNTER_MASK BIT(4) + +static const u16 ecs_supp_threshold[] = {0 ,0 ,0 ,256 ,1024 ,4096 }; + +enum { +ECS_LOG_ENTRY_TYPE_DRAM =0x0 , +ECS_LOG_ENTRY_TYPE_MEM_MEDIA_FRU =0x1 , +}; + +enum { +ECS_THRESHOLD_256 =3 , +ECS_THRESHOLD_1024 =4 , +ECS_THRESHOLD_4096 =5 , +}; + +enum { +ECS_MODE_COUNTS_ROWS =0 , +ECS_MODE_COUNTS_CODEWORDS =1 , +}; + +struct cxl_memdev_ecs_rd_attrs { +u8 ecs_log_cap; +u8 ecs_cap; +__le16 ecs_config; +u8 ecs_flags; +} __packed; + +struct cxl_memdev_ecs_wr_attrs { +u8 ecs_log_cap; +__le16 ecs_config; +} __packed; + +/* CXL DDR5 ECS control functions */ +static int __maybe_unused +cxl_mem_ecs_get_attrs (struct device *scrub_dev,int fru_id, +struct cxl_memdev_ecs_params *params) +{ +struct cxl_memdev *cxlmd =to_cxl_memdev (scrub_dev->parent); +struct cxl_dev_state *cxlds = cxlmd->cxlds; +struct cxl_memdev_state *mds =to_cxl_memdev_state (cxlds); +struct cxl_ecs_context *cxl_ecs_ctx; +size_t rd_data_size; +u8 threshold_index; +size_t data_size; + +if (!mds) +return -EFAULT ; + cxl_ecs_ctx =dev_get_drvdata (scrub_dev); + rd_data_size = cxl_ecs_ctx->get_feat_size; + + struct cxl_memdev_ecs_rd_attrs *rd_attrs __free(kfree) = +kmalloc (rd_data_size,GFP_KERNEL ); +if (!rd_attrs) +return -ENOMEM ; + + params->log_entry_type =0 ; + params->threshold =0 ; + params->mode =0 ; + data_size =cxl_get_feature (mds, cxl_ecs_uuid, rd_attrs, + rd_data_size, rd_data_size, +CXL_GET_FEAT_SEL_CURRENT_VALUE ); +if (!data_size) +return -EIO ; + + params->log_entry_type =FIELD_GET (CXL_MEMDEV_ECS_LOG_ENTRY_TYPE_MASK , + rd_attrs[fru_id].ecs_log_cap); + threshold_index =FIELD_GET (CXL_MEMDEV_ECS_THRESHOLD_COUNT_MASK , + rd_attrs[fru_id].ecs_config); + params->threshold = ecs_supp_threshold[threshold_index]; + params->mode =FIELD_GET (CXL_MEMDEV_ECS_MODE_MASK , + rd_attrs[fru_id].ecs_config); + +return 0 ; +} + +static int __maybe_unused +cxl_mem_ecs_set_attrs (struct device *scrub_dev,int fru_id, +struct cxl_memdev_ecs_params *params,u8 param_type) +{ +struct cxl_memdev *cxlmd =to_cxl_memdev (scrub_dev->parent); +struct cxl_dev_state *cxlds = cxlmd->cxlds; +struct cxl_memdev_state *mds =to_cxl_memdev_state (cxlds); +struct cxl_ecs_context *cxl_ecs_ctx; +struct device *dev = scrub_dev->parent; +size_t rd_data_size, wr_data_size; +u16 nmedia_frus, count; +size_t data_size; +int ret; + +if (!mds) +return -EFAULT ; + + cxl_ecs_ctx =dev_get_drvdata (scrub_dev); + nmedia_frus = cxl_ecs_ctx->nregions; + rd_data_size = cxl_ecs_ctx->get_feat_size; + wr_data_size = cxl_ecs_ctx->set_feat_size; + struct cxl_memdev_ecs_rd_attrs *rd_attrs __free(kfree) = +kmalloc (rd_data_size,GFP_KERNEL ); +if (!rd_attrs) +return -ENOMEM ; + + data_size =cxl_get_feature (mds, cxl_ecs_uuid, rd_attrs, + rd_data_size, rd_data_size, +CXL_GET_FEAT_SEL_CURRENT_VALUE ); +if (!data_size) +return -EIO ; + struct cxl_memdev_ecs_wr_attrs *wr_attrs __free(kfree) = +kmalloc (wr_data_size,GFP_KERNEL ); +if (!wr_attrs) +return -ENOMEM ; + +/* Fill writable attributes from the current attributes read for all the media FRUs */ +for (count =0 ; count < nmedia_frus; count++) { + wr_attrs[count].ecs_log_cap = rd_attrs[count].ecs_log_cap; + wr_attrs[count].ecs_config = rd_attrs[count].ecs_config; + } + +/* Fill attribute to be set for the media FRU */ +switch (param_type) { +case CXL_MEMDEV_ECS_PARAM_LOG_ENTRY_TYPE : +if (params->log_entry_type !=ECS_LOG_ENTRY_TYPE_DRAM && + params->log_entry_type !=ECS_LOG_ENTRY_TYPE_MEM_MEDIA_FRU ) { +dev_err (dev, +"Invalid CXL ECS scrub log entry type(%d) to set\n" , + params->log_entry_type); +dev_err (dev, +"Log Entry Type 0: per DRAM 1: per Memory Media FRU\n" ); +return -EINVAL ; + } + wr_attrs[fru_id].ecs_log_cap =FIELD_PREP (CXL_MEMDEV_ECS_LOG_ENTRY_TYPE_MASK , + params->log_entry_type); +break ; +case CXL_MEMDEV_ECS_PARAM_THRESHOLD : + wr_attrs[fru_id].ecs_config &= ~CXL_MEMDEV_ECS_THRESHOLD_COUNT_MASK ; +switch (params->threshold) { +case 256 : + wr_attrs[fru_id].ecs_config |=FIELD_PREP ( +CXL_MEMDEV_ECS_THRESHOLD_COUNT_MASK , +ECS_THRESHOLD_256 ); +break ; +case 1024 : + wr_attrs[fru_id].ecs_config |=FIELD_PREP ( +CXL_MEMDEV_ECS_THRESHOLD_COUNT_MASK , +ECS_THRESHOLD_1024 ); +break ; +case 4096 : + wr_attrs[fru_id].ecs_config |=FIELD_PREP ( +CXL_MEMDEV_ECS_THRESHOLD_COUNT_MASK , +ECS_THRESHOLD_4096 ); +break ; +default : +dev_err (dev, +"Invalid CXL ECS scrub threshold count(%d) to set\n" , + params->threshold); +dev_err (dev, +"Supported scrub threshold count: 256,1024,4096\n" ); +return -EINVAL ; + } +break ; +case CXL_MEMDEV_ECS_PARAM_MODE : +if (params->mode !=ECS_MODE_COUNTS_ROWS && + params->mode !=ECS_MODE_COUNTS_CODEWORDS ) { +dev_err (dev, +"Invalid CXL ECS scrub mode(%d) to set\n" , + params->mode); +dev_err (dev, +"Mode 0: ECS counts rows with errors" +" 1: ECS counts codewords with errors\n" ); +return -EINVAL ; + } + wr_attrs[fru_id].ecs_config &= ~CXL_MEMDEV_ECS_MODE_MASK ; + wr_attrs[fru_id].ecs_config |=FIELD_PREP (CXL_MEMDEV_ECS_MODE_MASK , + params->mode); +break ; +case CXL_MEMDEV_ECS_PARAM_RESET_COUNTER : + wr_attrs[fru_id].ecs_config &= ~CXL_MEMDEV_ECS_RESET_COUNTER_MASK ; + wr_attrs[fru_id].ecs_config |=FIELD_PREP (CXL_MEMDEV_ECS_RESET_COUNTER_MASK , + params->reset_counter); +break ; +default : +dev_err (dev,"Invalid CXL ECS parameter to set\n" ); +return -EINVAL ; + } + ret =cxl_set_feature (mds, cxl_ecs_uuid,CXL_MEMDEV_ECS_SET_FEAT_VERSION , + wr_attrs, wr_data_size, +CXL_SET_FEAT_FLAG_DATA_SAVED_ACROSS_RESET ); +if (ret) { +dev_err (dev,"CXL ECS set feature failed ret=%d\n" , ret); +return ret; + } + +return 0 ; +} + +int cxl_mem_ecs_init (struct cxl_memdev *cxlmd,int region_id) +{ +struct cxl_mbox_supp_feat_entry feat_entry; +struct cxl_ecs_context *cxl_ecs_ctx; +int nr_media_frus; +int ret; + + ret =cxl_mem_get_supported_feature_entry (cxlmd, &cxl_ecs_uuid, &feat_entry); +if (ret <0 ) +return ret; + +if (!(feat_entry.attr_flags &CXL_FEAT_ENTRY_FLAG_CHANGABLE )) +return -EOPNOTSUPP ; + nr_media_frus = feat_entry.get_size/ +sizeof (struct cxl_memdev_ecs_rd_attrs ); +if (!nr_media_frus) +return -ENODEV ; + + cxl_ecs_ctx =devm_kzalloc (&cxlmd->dev,sizeof (*cxl_ecs_ctx),GFP_KERNEL ); +if (!cxl_ecs_ctx) +return -ENOMEM ; + + cxl_ecs_ctx->nregions = nr_media_frus; + cxl_ecs_ctx->get_feat_size = feat_entry.get_size; + cxl_ecs_ctx->set_feat_size = feat_entry.set_size; + cxl_ecs_ctx->region_id = region_id; + +return 0 ; +} +EXPORT_SYMBOL_NS_GPL (cxl_mem_ecs_init,CXL );
drivers/cxl/core/region.c +3 -0
@@ -2913,6 +2913,9 @@ int cxl_add_to_region(struct cxl_port *root, struct cxl_endpoint_decoder *cxled)dev_err (&cxlr->dev,"failed to enable, range: %pr\n" , p->res); } + rc =cxl_mem_ecs_init (cxlmd,atomic_read (&cxlrd->region_id)); +if (rc) +dev_dbg (&cxlr->dev,"CXL memory ECS init failed\n" );put_device (region_dev); out:
drivers/cxl/cxlmem.h +3 -0
@@ -952,9 +952,12 @@ int cxl_clear_poison(struct cxl_memdev *cxlmd, u64 dpa);/* cxl memory scrub functions */ #ifdef CONFIG_CXL_SCRUB int cxl_mem_patrol_scrub_init (struct cxl_memdev *cxlmd); +int cxl_mem_ecs_init (struct cxl_memdev *cxlmd,int region_id);#else static inline int cxl_mem_patrol_scrub_init (struct cxl_memdev *cxlmd) {return -EOPNOTSUPP ; } +static inline int cxl_mem_ecs_init (struct cxl_memdev *cxlmd,int region_id) +{return -EOPNOTSUPP ; }#endif #ifdef CONFIG_CXL_SUSPEND
Signature · 1 line
2.34.1
RFC PATCH v7 6/12 memory: scrub: Add scrub subsystem driver supports configuring memory scrubs in the system
In reply to [email protected]From: Shiju Jose <[email protected]>
Add scrub driver supports configuring the memory scrubs in the system. The scrub driver provides the interface for registering the scrub devices and supports configuring memory scrubs in the system.
Driver exposes the sysfs scrub control attributes to the user in /sys/class/scrub/scrubX/regionN/
ToDo: The unit of the scrub rate may vary depends on the scrub
devices, feedback is to either standardise it or provide an interface for it to the userspace.
--- .../ABI/testing/sysfs-class-scrub-configure | 91 +++++ drivers/memory/Kconfig | 1 + drivers/memory/Makefile | 1 + drivers/memory/scrub/Kconfig | 11 + drivers/memory/scrub/Makefile | 6 + drivers/memory/scrub/memory-scrub.c | 369 ++++++++++++++++++ include/memory/memory-scrub.h | 79 ++++ 7 files changed, 558 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-scrub-configure create mode 100644 drivers/memory/scrub/Kconfig create mode 100644 drivers/memory/scrub/Makefile create mode 100755 drivers/memory/scrub/memory-scrub.c create mode 100755 include/memory/memory-scrub.h
Documentation/ABI/testing/sysfs-class-scrub-configure new file +91 -0
@@ -0,0 +1,91 @@ +What: /sys/class/scrub/ +Date: January 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + The scrub/ class subdirectory belongs to the + scrubber subsystem. + +What: /sys/class/scrub/scrubX/ +Date: January 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + The /sys/class/scrub/scrub{0,1,2,3,...} directories + correspond to each scrub device. + +What: /sys/class/scrub/scrubX/name +Date: January 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + (RO) name of the memory scrub device + +What: /sys/class/scrub/scrubX/regionN/ +Date: January 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + The /sys/class/scrub/scrubX/region{0,1,2,3,...} + directories correspond to each scrub region under a scrub device. + Scrub region is a physical address range for which scrub may be + separately controlled. Regions may overlap in which case the + scrubbing rate of the overlapped memory will be at least that + expected due to each overlapping region. + +What: /sys/class/scrub/scrubX/regionN/addr_base +Date: January 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + (RW) The base of the address range of the memory region + to be scrubbed. + On reading, returns the base of the memory region for + the actual address range(The platform calculates + the nearest patrol scrub boundary address from where + it can start scrub). + +What: /sys/class/scrub/scrubX/regionN/addr_size +Date: January 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + (RW) The size of the address range to be scrubbed. + On reading, returns the size of the memory region for + the actual address range. + +What: /sys/class/scrub/scrubX/regionN/enable +Date: January 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + (WO) Enable/Disable scrub the memory region. + 1 - enable the memory scrub. + 0 - disable the memory scrub. + +What: /sys/class/scrub/scrubX/regionN/enable_background_scrub +Date: January 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + (WO) Enable/Disable background scrubbing if supported. + 1 - enable background scrubbing. + 0 - disable background scrubbing. + +What: /sys/class/scrub/scrubX/regionN/rate_available +Date: January 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + (RO) Supported range for the scrub rate) + by the scrubber for a memory region. + The unit of the scrub rate vary depends on the scrub. + +What: /sys/class/scrub/scrubX/regionN/rate +Date: January 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + (RW) The scrub rate in the memory region specified + and it must be with in the supported range by the scrub. + The unit of the scrub rate vary depends on the scrub.
drivers/memory/Kconfig +1 -0
@@ -227,5 +227,6 @@ config STM32_FMC2_EBI source "drivers/memory/samsung/Kconfig" source "drivers/memory/tegra/Kconfig" +source "drivers/memory/scrub/Kconfig" endif
drivers/memory/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_STM32_FMC2_EBI) += stm32-fmc2-ebi.o obj-$(CONFIG_SAMSUNG_MC) += samsung/ obj-$(CONFIG_TEGRA_MC) += tegra/ +obj-$(CONFIG_SCRUB) += scrub/ obj-$(CONFIG_TI_EMIF_SRAM) += ti-emif-sram.o obj-$(CONFIG_FPGA_DFL_EMIF) += dfl-emif.o
drivers/memory/scrub/Kconfig new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Memory scrub driver configurations +# + +config SCRUB + bool "Memory scrub driver" + help + This option selects the memory scrub subsystem, supports + configuring the parameters of underlying scrubbers in the + system for the DRAM memories.
drivers/memory/scrub/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for memory scrub drivers +# + +obj-$(CONFIG_SCRUB) += memory-scrub.o
drivers/memory/scrub/memory-scrub.c new file +369 -0
369 lines not on this page · raw message
include/memory/memory-scrub.h new file +79 -0
79 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH v7 7/12 cxl/memscrub: Register CXL device patrol scrub with scrub subsystem driver
In reply to [email protected]From: Shiju Jose <[email protected]>
Register with the scrub subsystem driver to expose the sysfs attributes to the user for configuring the CXL device memory patrol scrub. Add the callback functions to support configuring the CXL memory device patrol scrub.
--- drivers/cxl/Kconfig | 6 ++ drivers/cxl/core/memscrub.c | 199 +++++++++++++++++++++++++++++++++++- 2 files changed, 202 insertions(+), 3 deletions(-)
drivers/cxl/Kconfig +6 -0
@@ -162,11 +162,17 @@ config CXL_SCRUB bool "CXL: Memory scrub feature" depends on CXL_PCI depends on CXL_MEM + depends on SCRUB help The CXL memory scrub control is an optional feature allows host to control the scrub configurations of CXL Type 3 devices, which support patrol scrub and/or DDR5 ECS(Error Check Scrub). + Register with the scrub configure driver to expose sysfs attributes + to the user for configuring the CXL device memory patrol and DDR5 ECS + scrubs. Provides the interface functions to support configuring the + CXL memory device patrol and ECS scrubs. + Say 'y/n' to enable/disable the CXL memory scrub driver that will attach to CXL.mem devices for memory scrub control feature. See sections 8.2.9.9.11.1 and 8.2.9.9.11.2 in the CXL 3.1 specification
drivers/cxl/core/memscrub.c +196 -3
236 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH v7 8/12 cxl/memscrub: Register CXL device ECS with scrub subsystem driver
In reply to [email protected]From: Shiju Jose <[email protected]>
Register with the scrub subsystem driver to expose the sysfs attributes to the user for configuring the CXL memory device's ECS feature. Add the static CXL ECS specific attributes to support configuring the CXL memory device ECS feature.
--- .../ABI/testing/sysfs-class-cxl-ecs-configure | 79 ++++++ drivers/cxl/core/memscrub.c | 251 +++++++++++++++++- 2 files changed, 327 insertions(+), 3 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-class-cxl-ecs-configure
Documentation/ABI/testing/sysfs-class-cxl-ecs-configure new file +79 -0
@@ -0,0 +1,79 @@ +See `Documentation/ABI/testing/sysfs-class-scrub-configure` for the +documentation of common scrub configure directory layout (/sys/class/scrub/), +including the attributes used for configuring the CXL patrol scrub. +Following are the attributes defined for configuring the CXL ECS. + +What: /sys/class/scrub/scrubX/regionN/ecs_log_entry_type +Date: February 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + (RW) The log entry type of how the DDR5 ECS log is + reported. + 00b - per DRAM. + 01b - per memory media FRU. + +What: /sys/class/scrub/scrubX/regionN/ecs_log_entry_type_per_dram +Date: February 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + (RO) Returns true if current log entry type of DDR5 ECS + region is per DRAM. + +What: /sys/class/scrub/scrubX/regionN/ecs_log_entry_type_per_memory_media +Date: February 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + (RO) Returns true if current log entry type of DDR5 ECS + region is per memory media FRU. + +What: /sys/class/scrub/scrubX/regionN/mode +Date: February 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + (RW) The mode of how the DDR5 ECS counts the errors. + 0 - ECS counts rows with errors. + 1 - ECS counts codewords with errors. + +What: /sys/class/scrub/scrubX/regionN/mode_counts_rows +Date: February 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + (RO) Returns true if current mode of DDR5 ECS region + is counts rows with errors. + +What: /sys/class/scrub/scrubX/regionN/mode_counts_codewords +Date: February 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + (RO) Returns true if current mode of DDR5 ECS region + is counts codewords with errors. + +What: /sys/class/scrub/scrubX/regionN/reset_counter +Date: February 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + (WO) DDR5 ECS reset ECC counter. + 0 - normal, ECC counter running actively. + 1 - reset ECC counter to the default value. + +What: /sys/class/scrub/scrubX/regionN/threshold +Date: February 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + (RW) DDR5 ECS threshold count per GB of memory cells. + +What: /sys/class/scrub/scrubX/regionN/threshold_available +Date: February 2024 +KernelVersion: 6.8 +Contact: [email protected] +Description: + (RO) Supported list of DDR5 ECS threshold count per GB of + memory cells.
drivers/cxl/core/memscrub.c +248 -3
271 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH v7 9/12 ACPICA: ACPI 6.5: Add support for RAS2 table
In reply to [email protected]From: Shiju Jose <[email protected]>
Add support for ACPI RAS2 feature table(RAS2) defined in the ACPI 6.5 Specification & upwards revision, section 5.2.21.
The RAS2 table provides interfaces for platform RAS features. RAS2 offers the same services as RASF, but is more scalable than the latter. RAS2 supports independent RAS controls and capabilities for a given RAS feature for multiple instances of the same component in a given system. The platform can support either RAS2 or RASF but not both.
--- include/acpi/actbl2.h | 137 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+)
include/acpi/actbl2.h +137 -0
@@ -47,6 +47,7 @@#define ACPI_SIG_PPTT "PPTT"/* Processor Properties Topology Table */ #define ACPI_SIG_PRMT "PRMT"/* Platform Runtime Mechanism Table */ #define ACPI_SIG_RASF "RASF"/* RAS Feature table */ +#define ACPI_SIG_RAS2 "RAS2"/* RAS2 Feature table */ #define ACPI_SIG_RGRT "RGRT"/* Regulatory Graphics Resource Table */ #define ACPI_SIG_RHCT "RHCT"/* RISC-V Hart Capabilities Table */ #define ACPI_SIG_SBST "SBST"/* Smart Battery Specification Table */
@@ -2751,6 +2752,142 @@ enum acpi_rasf_status {#define ACPI_RASF_ERROR (1<<2)#define ACPI_RASF_STATUS (0x1F<<3) +/******************************************************************************* +* +* RAS2 - RAS2 Feature Table (ACPI 6.5) +* Version 2 +* +* +******************************************************************************/ + +struct acpi_table_ras2 { +struct acpi_table_header header;/* Common ACPI table header */ +u16 reserved; +u16 num_pcc_descs; +}; + +/* +* RAS2 Platform Communication Channel Descriptor +*/ + +struct acpi_ras2_pcc_desc { +u8 channel_id; +u16 reserved; +u8 feature_type; +u32 instance; +}; + +/* +* RAS2 Platform Communication Channel Shared Memory Region +*/ + +struct acpi_ras2_shared_memory { +u32 signature; +u16 command; +u16 status; +u16 version; +u8 features[16 ]; +u8 set_capabilities[16 ]; +u16 num_parameter_blocks; +u32 set_capabilities_status; +}; + +/* RAS2 Parameter Block Structure Header */ + +struct acpi_ras2_parameter_block { +u16 type; +u16 version; +u16 length; +}; + +/* +* RAS2 Parameter Block Structure for PATROL_SCRUB +*/ + +struct acpi_ras2_patrol_scrub_parameter { +struct acpi_ras2_parameter_block header; +u16 patrol_scrub_command; +u64 requested_address_range[2 ]; +u64 actual_address_range[2 ]; +u32 flags; +u32 scrub_params_out; +u32 scrub_params_in; +}; + +/* Masks for Flags field above */ + +#define ACPI_RAS2_SCRUBBER_RUNNING 1 + +/* +* RAS2 Parameter Block Structure for LA2PA_TRANSLATION +*/ + +struct acpi_ras2_la2pa_translation_parameter { +struct acpi_ras2_parameter_block header; +u16 addr_translation_command; +u64 sub_instance_id; +u64 logical_address; +u64 physical_address; +u32 status; +}; + +/* Channel Commands */ + +enum acpi_ras2_commands { +ACPI_RAS2_EXECUTE_RAS2_COMMAND =1 +}; + +/* Platform RAS2 Features */ + +enum acpi_ras2_features { +ACPI_RAS2_PATROL_SCRUB_SUPPORTED =0 , +ACPI_RAS2_LA2PA_TRANSLATION =1 +}; + +/* RAS2 Patrol Scrub Commands */ + +enum acpi_ras2_patrol_scrub_commands { +ACPI_RAS2_GET_PATROL_PARAMETERS =1 , +ACPI_RAS2_START_PATROL_SCRUBBER =2 , +ACPI_RAS2_STOP_PATROL_SCRUBBER =3 +}; + +/* RAS2 LA2PA Translation Commands */ + +enum acpi_ras2_la2pa_translation_commands { +ACPI_RAS2_GET_LA2PA_TRANSLATION =1 +}; + +/* RAS2 LA2PA Translation Status values */ + +enum acpi_ras2_la2pa_translation_status { +ACPI_RAS2_LA2PA_TRANSLATION_SUCCESS =0 , +ACPI_RAS2_LA2PA_TRANSLATION_FAIL =1 +}; + +/* Channel Command flags */ + +#define ACPI_RAS2_GENERATE_SCI (1<<15) + +/* Status values */ + +enum acpi_ras2_status { +ACPI_RAS2_SUCCESS =0 , +ACPI_RAS2_NOT_VALID =1 , +ACPI_RAS2_NOT_SUPPORTED =2 , +ACPI_RAS2_BUSY =3 , +ACPI_RAS2_FAILED =4 , +ACPI_RAS2_ABORTED =5 , +ACPI_RAS2_INVALID_DATA =6 +}; + +/* Status flags */ + +#define ACPI_RAS2_COMMAND_COMPLETE (1) +#define ACPI_RAS2_SCI_DOORBELL (1<<1) +#define ACPI_RAS2_ERROR (1<<2) +#define ACPI_RAS2_STATUS (0x1F<<3) +/******************************************************************************* * * RGRT - Regulatory Graphics Resource Table
Signature · 1 line
2.34.1
RFC PATCH v7 10/12 ACPI:RAS2: Add common library for RAS2 PCC interfaces
In reply to [email protected]From: A Somasundaram <[email protected]>
The code contains PCC interfaces for RAS2 table, functions to send RAS2 commands as per ACPI 6.5 & upwards revision.
References for this implementation,
ACPI specification 6.5 section 5.2.21 for RAS2 table and chapter 14 for PCC (Platform Communication Channel).
Driver uses PCC interfaces to communicate to the ACPI HW. This code implements PCC interfaces and the functions to send the RAS2 commands to be used by OSPM.
--- drivers/acpi/Kconfig | 14 ++ drivers/acpi/Makefile | 1 + drivers/acpi/ras2_acpi_common.c | 272 ++++++++++++++++++++++++++++++++ include/acpi/ras2_acpi.h | 59 +++++++ 4 files changed, 346 insertions(+) create mode 100755 drivers/acpi/ras2_acpi_common.c create mode 100644 include/acpi/ras2_acpi.h
drivers/acpi/Kconfig +14 -0
@@ -284,6 +284,20 @@ config ACPI_CPPC_LIB If your platform does not support CPPC in firmware, leave this option disabled. +config ACPI_RAS2 + bool "ACPI RAS2 driver" + depends on ACPI_PROCESSOR + select MAILBOX + select PCC + help + The driver adds support for PCC (platform communication + channel) interfaces to communicate with the ACPI complaint + hardware platform supports RAS2(RAS2 Feature table). + The driver adds support for RAS2(extraction of RAS2 + tables from OS system table), PCC interfaces and OSPM interfaces + to send RAS2 commands. Driver adds platform device which + binds to the RAS2 memory driver. + config ACPI_PROCESSOR tristate "Processor" depends on X86 || ARM64 || LOONGARCH
drivers/acpi/Makefile +1 -0
@@ -105,6 +105,7 @@ obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o obj-$(CONFIG_ACPI_BGRT) += bgrt.o obj-$(CONFIG_ACPI_CPPC_LIB) += cppc_acpi.o obj-$(CONFIG_ACPI_SPCR_TABLE) += spcr.o +obj-$(CONFIG_ACPI_RAS2) += ras2_acpi_common.o obj-$(CONFIG_ACPI_DEBUGGER_USER) += acpi_dbg.o obj-$(CONFIG_ACPI_PPTT) += pptt.o obj-$(CONFIG_ACPI_PFRUT) += pfr_update.o pfr_telemetry.o
drivers/acpi/ras2_acpi_common.c new file +272 -0
272 lines not on this page · raw message
include/acpi/ras2_acpi.h new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [RFC PATCH v7 10/12] ACPI:RAS2: Add common library for RAS2 PCC interfaces
Quoted 91 lines · On Fri, Feb 23, 2024 at 10:37:21PM +0800, [email protected] wrote:
From: A Somasundaram <[email protected]>
The code contains PCC interfaces for RAS2 table, functions to send RAS2 commands as per ACPI 6.5 & upwards revision.
References for this implementation,
ACPI specification 6.5 section 5.2.21 for RAS2 table and chapter 14 for PCC (Platform Communication Channel).Driver uses PCC interfaces to communicate to the ACPI HW. This code implements PCC interfaces and the functions to send the RAS2 commands to be used by OSPM.
Signed-off-by A Somasundaram <[email protected]>Co-developed-by Shiju Jose <[email protected]>Signed-off-by Shiju Jose <[email protected]>--- drivers/acpi/Kconfig | 14 ++ drivers/acpi/Makefile | 1 + drivers/acpi/ras2_acpi_common.c | 272 ++++++++++++++++++++++++++++++++ include/acpi/ras2_acpi.h | 59 +++++++ 4 files changed, 346 insertions(+) create mode 100755 drivers/acpi/ras2_acpi_common.c create mode 100644 include/acpi/ras2_acpi.hdrivers/acpi/Kconfig +14
-0@@ -284,6 +284,20 @@ config ACPI_CPPC_LIB If your platform does not support CPPC in firmware, leave this option disabled. +config ACPI_RAS2 + bool "ACPI RAS2 driver" + depends on ACPI_PROCESSOR + select MAILBOX + select PCC + help + The driver adds support for PCC (platform communication + channel) interfaces to communicate with the ACPI complaint + hardware platform supports RAS2(RAS2 Feature table). + The driver adds support for RAS2(extraction of RAS2 + tables from OS system table), PCC interfaces and OSPM interfaces + to send RAS2 commands. Driver adds platform device which + binds to the RAS2 memory driver. + config ACPI_PROCESSOR tristate "Processor" depends on X86 || ARM64 || LOONGARCHdrivers/acpi/Makefile +1
-0@@ -105,6 +105,7 @@ obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o obj-$(CONFIG_ACPI_BGRT) += bgrt.o obj-$(CONFIG_ACPI_CPPC_LIB) += cppc_acpi.o obj-$(CONFIG_ACPI_SPCR_TABLE) += spcr.o +obj-$(CONFIG_ACPI_RAS2) += ras2_acpi_common.o obj-$(CONFIG_ACPI_DEBUGGER_USER) += acpi_dbg.o obj-$(CONFIG_ACPI_PPTT) += pptt.o obj-$(CONFIG_ACPI_PFRUT) += pfr_update.o pfr_telemetry.odrivers/acpi/ras2_acpi_common.c new file +23
-0@@ -0,0 +1,272 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* ACPI RAS2 table processing common functions +* +* (C) Copyright 2014, 2015 Hewlett-Packard Enterprises. +* +* Copyright (c) 2024 HiSilicon Limited. +* +* Support for +* RAS2 - ACPI 6.5 Specification, section 5.2.21 +* PCC(Platform Communications Channel) - ACPI 6.5 Specification, +* chapter 14. +* +* Code contains common functions for RAS2. +* PCC(Platform communication channel) interfaces for the RAS2 +* and the functions for sending RAS2 commands to the ACPI HW. +*/ + +#include <linux/export.h> +#include <linux/delay.h> +#include <linux/ktime.h> +#include <linux/platform_device.h> +#include <acpi/ras2_acpi.h>
drivers/acpi/ras2_acpi_common.c line 33
Quoted 10 lines
drivers/acpi/ras2_acpi_common.c new file +10
-0+#include <acpi/acpixf.h> + +static int ras2_check_pcc_chan (struct ras2_context *ras2_ctx) +{ +struct acpi_ras2_shared_memory __iomem *generic_comm_base = ras2_ctx->pcc_comm_addr; +ktime_t next_deadline =ktime_add (ktime_get (), ras2_ctx->deadline); + +while (!ktime_after (ktime_get (), next_deadline)) { +/* +* As per ACPI spec, the PCC space wil be initialized by
s/wil/will/
Fan
Quoted 307 lines
drivers/acpi/ras2_acpi_common.c new file +239
-0+* platform and should have set the command completion bit when +* PCC can be used by OSPM +*/ +if (readw_relaxed (&generic_comm_base->status) &RAS2_PCC_CMD_COMPLETE ) +return 0 ; +/* +* Reducing the bus traffic in case this loop takes longer than +* a few retries. +*/ +udelay (10 ); + } + +return -EIO ; +} + +/** +* ras2_send_pcc_cmd() - Send RAS2 command via PCC channel +* @ras2_ctx: pointer to the ras2 context structure +* @cmd: command to send +* +* Returns: 0 on success, an error otherwise +*/ +int ras2_send_pcc_cmd (struct ras2_context *ras2_ctx,u16 cmd) +{ +int ret; +struct acpi_ras2_shared_memory *generic_comm_base = + (struct acpi_ras2_shared_memory *)ras2_ctx->pcc_comm_addr; +static ktime_t last_cmd_cmpl_time, last_mpar_reset; +struct mbox_chan *pcc_channel; +static int mpar_count; +unsigned int time_delta; + +if (cmd ==RAS2_PCC_CMD_EXEC ) { + ret =ras2_check_pcc_chan (ras2_ctx); +if (ret) +return ret; + } + pcc_channel = ras2_ctx->pcc_chan->mchan; + +/* +* Handle the Minimum Request Turnaround Time(MRTT) +* "The minimum amount of time that OSPM must wait after the completion +* of a command before issuing the next command, in microseconds" +*/ +if (ras2_ctx->pcc_mrtt) { + time_delta =ktime_us_delta (ktime_get (), last_cmd_cmpl_time); +if (ras2_ctx->pcc_mrtt > time_delta) +udelay (ras2_ctx->pcc_mrtt - time_delta); + } + +/* +* Handle the non-zero Maximum Periodic Access Rate(MPAR) +* "The maximum number of periodic requests that the subspace channel can +* support, reported in commands per minute. 0 indicates no limitation." +* +* This parameter should be ideally zero or large enough so that it can +* handle maximum number of requests that all the cores in the system can +* collectively generate. If it is not, we will follow the spec and just +* not send the request to the platform after hitting the MPAR limit in +* any 60s window +*/ +if (ras2_ctx->pcc_mpar) { +if (mpar_count ==0 ) { + time_delta =ktime_ms_delta (ktime_get (), last_mpar_reset); +if (time_delta <60 *MSEC_PER_SEC ) { +dev_dbg (ras2_ctx->dev, +"PCC cmd not sent due to MPAR limit" ); +return -EIO ; + } + last_mpar_reset =ktime_get (); + mpar_count = ras2_ctx->pcc_mpar; + } + mpar_count--; + } + +/* Write to the shared comm region. */ +writew_relaxed (cmd, &generic_comm_base->command); + +/* Flip CMD COMPLETE bit */ +writew_relaxed (0 , &generic_comm_base->status); + +/* Ring doorbell */ + ret =mbox_send_message (pcc_channel, &cmd); +if (ret <0 ) { +dev_err (ras2_ctx->dev, +"Err sending PCC mbox message. cmd:%d, ret:%d\n" , + cmd, ret); +return ret; + } + +/* +* For READs we need to ensure the cmd completed to ensure +* the ensuing read()s can proceed. For WRITEs we dont care +* because the actual write()s are done before coming here +* and the next READ or WRITE will check if the channel +* is busy/free at the entry of this call. +* +* If Minimum Request Turnaround Time is non-zero, we need +* to record the completion time of both READ and WRITE +* command for proper handling of MRTT, so we need to check +* for pcc_mrtt in addition to CMD_READ +*/ +if (cmd ==RAS2_PCC_CMD_EXEC || ras2_ctx->pcc_mrtt) { + ret =ras2_check_pcc_chan (ras2_ctx); +if (ras2_ctx->pcc_mrtt) + last_cmd_cmpl_time =ktime_get (); + } + +if (pcc_channel->mbox->txdone_irq) +mbox_chan_txdone (pcc_channel, ret); +else +mbox_client_txdone (pcc_channel, ret); + +return ret; +} +EXPORT_SYMBOL_GPL (ras2_send_pcc_cmd); + +/** +* ras2_register_pcc_channel() - Register PCC channel +* @ras2_ctx: pointer to the ras2 context structure +* +* Returns: 0 on success, an error otherwise +*/ +int ras2_register_pcc_channel (struct ras2_context *ras2_ctx) +{ +u64 usecs_lat; +unsigned int len; +struct pcc_mbox_chan *pcc_chan; +struct mbox_client *ras2_mbox_cl; +struct acpi_pcct_hw_reduced *ras2_ss; + + ras2_mbox_cl = &ras2_ctx->mbox_client; +if (!ras2_mbox_cl || ras2_ctx->pcc_subspace_idx <0 ) +return -EINVAL ; + + pcc_chan =pcc_mbox_request_channel (ras2_mbox_cl, + ras2_ctx->pcc_subspace_idx); + +if (IS_ERR (pcc_chan)) { +dev_err (ras2_ctx->dev, +"Failed to find PCC channel for subspace %d\n" , + ras2_ctx->pcc_subspace_idx); +return -ENODEV ; + } + ras2_ctx->pcc_chan = pcc_chan; +/* +* The PCC mailbox controller driver should +* have parsed the PCCT (global table of all +* PCC channels) and stored pointers to the +* subspace communication region in con_priv. +*/ + ras2_ss = pcc_chan->mchan->con_priv; + +if (!ras2_ss) { +dev_err (ras2_ctx->dev,"No PCC subspace found for RAS2\n" ); +pcc_mbox_free_channel (ras2_ctx->pcc_chan); +return -ENODEV ; + } + +/* +* This is the shared communication region +* for the OS and Platform to communicate over. +*/ + ras2_ctx->comm_base_addr = ras2_ss->base_address; + len = ras2_ss->length; +dev_dbg (ras2_ctx->dev,"PCC subspace for RAS2=0x%llx len=%d\n" , + ras2_ctx->comm_base_addr, len); + +/* +* ras2_ss->latency is just a Nominal value. In reality +* the remote processor could be much slower to reply. +* So add an arbitrary amount of wait on top of Nominal. +*/ + usecs_lat =RAS2_NUM_RETRIES * ras2_ss->latency; + ras2_ctx->deadline =ns_to_ktime (usecs_lat *NSEC_PER_USEC ); + ras2_ctx->pcc_mrtt = ras2_ss->min_turnaround_time; + ras2_ctx->pcc_mpar = ras2_ss->max_access_rate; + ras2_ctx->pcc_comm_addr =acpi_os_ioremap (ras2_ctx->comm_base_addr, + len); +dev_dbg (ras2_ctx->dev,"pcc_comm_addr=%p\n" , + ras2_ctx->pcc_comm_addr); + +/* Set flag so that we dont come here for each CPU. */ + ras2_ctx->pcc_channel_acquired = true; + +return 0 ; +} +EXPORT_SYMBOL_GPL (ras2_register_pcc_channel); + +/** +* ras2_unregister_pcc_channel() - Unregister PCC channel +* @ras2_ctx: pointer to the ras2 context structure +* +* Returns: 0 on success, an error otherwise +*/ +int ras2_unregister_pcc_channel (struct ras2_context *ras2_ctx) +{ +if (!ras2_ctx->pcc_chan) +return -EINVAL ; + +pcc_mbox_free_channel (ras2_ctx->pcc_chan); + +return 0 ; +} +EXPORT_SYMBOL_GPL (ras2_unregister_pcc_channel); + +/** +* ras2_add_platform_device() - Add a platform device for RAS2 +* @name: name of the device we're adding +* @data: platform specific data for this platform device +* @size: size of platform specific data +* +* Returns: pointer to platform device on success, an error otherwise +*/ +struct platform_device *ras2_add_platform_device (char *name,const void *data, +size_t size) +{ +int ret; +struct platform_device *pdev; + + pdev =platform_device_alloc (name,PLATFORM_DEVID_AUTO ); +if (!pdev) +return NULL ; + + ret =platform_device_add_data (pdev, data, size); +if (ret) + goto dev_put; + + ret =platform_device_add (pdev); +if (ret) + goto dev_put; + +return pdev; + +dev_put: +platform_device_put (pdev); + +return ERR_PTR (ret); +}include/acpi/ras2_acpi.h new file +59
-0@@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* RAS2 ACPI driver header file +* +* (C) Copyright 2014, 2015 Hewlett-Packard Enterprises +* +* Copyright (c) 2024 HiSilicon Limited +*/ + +#ifndef _RAS2_ACPI_H +#define _RAS2_ACPI_H + +#include <linux/acpi.h> +#include <linux/mailbox_client.h> +#include <linux/mailbox_controller.h> +#include <linux/types.h> +#include <acpi/pcc.h> + +#define RAS2_PCC_CMD_COMPLETE 1 + +/* RAS2 specific PCC commands */ +#define RAS2_PCC_CMD_EXEC 0x01 + +#define RAS2_FAILURE 0 +#define RAS2_SUCCESS 1 + +/* +* Arbitrary Retries for PCC commands because the +* remote processor could be much slower to reply. +*/ +#define RAS2_NUM_RETRIES 600 + +/* +* Data structures for PCC communication and RAS2 table +*/ +struct ras2_context { +struct device *dev; +int id; +struct mbox_client mbox_client; +struct pcc_mbox_chan *pcc_chan; +void __iomem *pcc_comm_addr; +u64 comm_base_addr; +int pcc_subspace_idx; +bool pcc_channel_acquired; +ktime_t deadline; +unsigned int pcc_mpar; +unsigned int pcc_mrtt; +/* Lock to provide mutually exclusive access to PCC channel */ +spinlock_t spinlock; +struct device *scrub_dev; +const struct ras2_hw_scrub_ops *ops; +}; + +struct platform_device *ras2_add_platform_device (char *name,const void *data, +size_t size); +int ras2_send_pcc_cmd (struct ras2_context *ras2_ctx,u16 cmd); +int ras2_register_pcc_channel (struct ras2_context *ras2_ctx); +int ras2_unregister_pcc_channel (struct ras2_context *ras2_ctx); +#endif /* _RAS2_ACPI_H */ Signature · 1 line
2.34.1
Re: [RFC PATCH v7 10/12] ACPI:RAS2: Add common library for RAS2 PCC interfaces
In reply to [email protected]drivers/acpi/ras2_acpi_common.c line 38
Quoted 13 lines
drivers/acpi/ras2_acpi_common.c new file +13
-0+static int ras2_check_pcc_chan (struct ras2_context *ras2_ctx) +{ +struct acpi_ras2_shared_memory __iomem *generic_comm_base = ras2_ctx->pcc_comm_addr; +ktime_t next_deadline =ktime_add (ktime_get (), ras2_ctx->deadline); + +while (!ktime_after (ktime_get (), next_deadline)) { +/* +* As per ACPI spec, the PCC space wil be initialized by +* platform and should have set the command completion bit when +* PCC can be used by OSPM +*/ +if (readw_relaxed (&generic_comm_base->status) &RAS2_PCC_CMD_COMPLETE ) +return 0 ;
We should consider adding error checking here. In a modification of this driver in our enabling efforts, we are checking bit 2 in the status register for errors. For example, in our FW, we will set bit 2 if you try to disable an already disabled scrub.
Quoted 9 lines
drivers/acpi/ras2_acpi_common.c new file +9
-0+/* +* Reducing the bus traffic in case this loop takes longer than +* a few retries. +*/ +udelay (10 ); + } + +return -EIO ; +}
RFC PATCH v7 11/12 ACPI:RAS2: Add driver for ACPI RAS2 feature table (RAS2)
In reply to [email protected]From: Shiju Jose <[email protected]>
Add support for ACPI RAS2 feature table (RAS2) defined in the ACPI 6.5 Specification, section 5.2.21.
This driver contains RAS2 Init, which extracts the RAS2 table. Driver adds platform device, for each memory feature, which binds to the RAS2 memory driver.
--- drivers/acpi/Makefile | 2 +- drivers/acpi/ras2_acpi.c | 97 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100755 drivers/acpi/ras2_acpi.c
drivers/acpi/Makefile +1 -1
@@ -105,7 +105,7 @@ obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o obj-$(CONFIG_ACPI_BGRT) += bgrt.o obj-$(CONFIG_ACPI_CPPC_LIB) += cppc_acpi.o obj-$(CONFIG_ACPI_SPCR_TABLE) += spcr.o -obj-$(CONFIG_ACPI_RAS2) += ras2_acpi_common.o +obj-$(CONFIG_ACPI_RAS2) += ras2_acpi_common.o ras2_acpi.o obj-$(CONFIG_ACPI_DEBUGGER_USER) += acpi_dbg.o obj-$(CONFIG_ACPI_PPTT) += pptt.o obj-$(CONFIG_ACPI_PFRUT) += pfr_update.o pfr_telemetry.o
drivers/acpi/ras2_acpi.c new file +97 -0
97 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [RFC PATCH v7 11/12] ACPI:RAS2: Add driver for ACPI RAS2 feature table (RAS2)
Quoted 41 lines
drivers/acpi/ras2_acpi.c new file +41
-0+static int __init ras2_acpi_init (void ) +{ +u8 count; +acpi_status status; +acpi_size ras2_size; +int pcc_subspace_idx; +struct platform_device *pdev; +struct acpi_table_ras2 *pRas2Table; +struct acpi_ras2_pcc_desc *pcc_desc_list; +struct platform_device **pdev_list =NULL ; +struct acpi_table_header *pAcpiTable =NULL ; + + status =acpi_get_table ("RAS2" ,0 , &pAcpiTable); +if (ACPI_FAILURE (status) || !pAcpiTable) { +pr_err ("ACPI RAS2 driver failed to initialize, get table failed\n" ); +return RAS2_FAILURE ; + } + + ras2_size = pAcpiTable->length; +if (ras2_size <sizeof (struct acpi_table_ras2 )) { +pr_err ("ACPI RAS2 table present but broken (too short #1)\n" ); + goto free_ras2_table; + } + + pRas2Table = (struct acpi_table_ras2 *)pAcpiTable; + +if (pRas2Table->num_pcc_descs <=0 ) { +pr_err ("ACPI RAS2 table does not contain PCC descriptors\n" ); + goto free_ras2_table; + } + + pdev_list =kzalloc ((pRas2Table->num_pcc_descs *sizeof (struct platform_device *)), +GFP_KERNEL ); +if (!pdev_list) + goto free_ras2_table; + + pcc_desc_list = (struct acpi_ras2_pcc_desc *) + ((void *)pRas2Table +sizeof (struct acpi_table_ras2 )); + count =0 ; +while (count < pRas2Table->num_pcc_descs) { +if (pcc_desc_list->feature_type ==RAS2_FEATURE_TYPE_MEMORY ) {
drivers/acpi/ras2_acpi.c line 78
Quoted 10 lines
drivers/acpi/ras2_acpi.c new file +10
-0+ pcc_subspace_idx = pcc_desc_list->channel_id; +/* Add the platform device and bind ras2 memory driver */ + pdev =ras2_add_platform_device ("ras2" , &pcc_subspace_idx, +sizeof (pcc_subspace_idx)); +if (!pdev) + goto free_ras2_pdev; + pdev_list[count] = pdev; + } + count++; + pcc_desc_list = pcc_desc_list +sizeof (struct acpi_ras2_pcc_desc );
This line needs to be:pcc_desc_list = pcc_desc_list + 1
because pcc_desc_list is a type larger than a byte. This bug will crash the module when num_pcc_descs is greater than 1
Quoted 18 lines
drivers/acpi/ras2_acpi.c new file +18
-0+ } + +acpi_put_table (pAcpiTable); +return RAS2_SUCCESS ; + +free_ras2_pdev: + count =0 ; +while (count < pRas2Table->num_pcc_descs) { +if (pcc_desc_list->feature_type == +RAS2_FEATURE_TYPE_MEMORY ) +platform_device_put (pdev_list[count++]); + } +kfree (pdev_list); + +free_ras2_table: +acpi_put_table (pAcpiTable); +return RAS2_FAILURE ; +}
RFC PATCH v7 12/12 memory: RAS2: Add memory RAS2 driver
In reply to [email protected]From: Shiju Jose <[email protected]>
Memory RAS2 driver binds to the platform device add by the ACPI RAS2 driver.
Driver registers the PCC channel for communicating with the ACPI compliant platform that contains RAS2 command support in the hardware.
Add interface functions to support configuring the parameters of HW patrol scrubs in the system, which exposed to the kernel via the RAS2 and PCC, using the RAS2 commands.
Add support for RAS2 platform devices to register with scrub subsystem driver. This enables user to configure the parameters of HW patrol scrubs, which exposed to the kernel via the RAS2 table, through the scrub sysfs attributes.
Open Question:
Sysfs scrub control attribute "enable_background_scrub" is added for RAS2, based on the feedback from Bill Schwartz <[email protected] on v4 to enable/disable the background_scrubbing in the platform as defined in the “Configure Scrub Parameters [INPUT]“ field in RAS2 Table 5.87: Parameter Block Structure for PATROL_SCRUB.
Is it a right approach to support "enable_background_scrub" in the sysfs scrub control?
--- drivers/memory/Kconfig | 14 ++ drivers/memory/Makefile | 2 + drivers/memory/ras2.c | 364 +++++++++++++++++++++++++++++++++++ drivers/memory/ras2_common.c | 282 +++++++++++++++++++++++++++ include/memory/ras2.h | 88 +++++++++ 5 files changed, 750 insertions(+) create mode 100644 drivers/memory/ras2.c create mode 100644 drivers/memory/ras2_common.c create mode 100755 include/memory/ras2.h
drivers/memory/Kconfig +14 -0
@@ -225,6 +225,20 @@ config STM32_FMC2_EBI devices (like SRAM, ethernet adapters, FPGAs, LCD displays, ...) on SOCs containing the FMC2 External Bus Interface. +config MEM_RAS2 + bool "Memory RAS2 driver" + depends on ACPI_RAS2 + depends on SCRUB + help + The driver bound to the platform device added by the ACPI RAS2 + driver. Driver registers the PCC channel for communicating with + the ACPI compliant platform that contains RAS2 command support + in the hardware. + Registers with the scrub configure driver to provide sysfs interfaces + for configuring the hw patrol scrubber in the system, which exposed + via the ACPI RAS2 table and PCC. Provides the interface functions + support configuring the HW patrol scrubbers in the system. + source "drivers/memory/samsung/Kconfig" source "drivers/memory/tegra/Kconfig" source "drivers/memory/scrub/Kconfig"
drivers/memory/Makefile +2 -0
@@ -7,6 +7,8 @@ obj-$(CONFIG_DDR) += jedec_ddr_data.o ifeq ($(CONFIG_DDR),y) obj-$(CONFIG_OF) += of_memory.o endif +obj-$(CONFIG_MEM_RAS2) += ras2_common.o ras2.o + obj-$(CONFIG_ARM_PL172_MPMC) += pl172.o obj-$(CONFIG_ATMEL_EBI) += atmel-ebi.o obj-$(CONFIG_BRCMSTB_DPFE) += brcmstb_dpfe.o
drivers/memory/ras2.c new file +364 -0
364 lines not on this page · raw message
drivers/memory/ras2_common.c new file +282 -0
282 lines not on this page · raw message
include/memory/ras2.h new file +88 -0
88 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [RFC PATCH v7 12/12] memory: RAS2: Add memory RAS2 driver
Quoted 26 lines · On 2/23/2024 9:37 AM, [email protected] wrote:
From: Shiju Jose <[email protected]>
Memory RAS2 driver binds to the platform device add by the ACPI RAS2 driver.
Driver registers the PCC channel for communicating with the ACPI compliant platform that contains RAS2 command support in the hardware.Add interface functions to support configuring the parameters of HW patrol scrubs in the system, which exposed to the kernel via the RAS2 and PCC, using the RAS2 commands.
Add support for RAS2 platform devices to register with scrub subsystem driver. This enables user to configure the parameters of HW patrol scrubs, which exposed to the kernel via the RAS2 table, through the scrub sysfs attributes.
Open Question:
Sysfs scrub control attribute "enable_background_scrub" is added for RAS2, based on the feedback from Bill Schwartz <[email protected] on v4 to enable/disable thebackground_scrubbingin the platform as defined in the “Configure Scrub Parameters [INPUT]“ field in RAS2 Table 5.87: Parameter Block Structure forPATROL_SCRUB.
Is it a right approach to support "enable_background_scrub" in the sysfs scrub control?Signed-off-by Shiju Jose <[email protected]>
Quoted 11 lines
--- drivers/memory/Kconfig | 14 ++ drivers/memory/Makefile | 2 + drivers/memory/ras2.c | 364 +++++++++++++++++++++++++++++++++++ drivers/memory/ras2_common.c | 282 +++++++++++++++++++++++++++ include/memory/ras2.h | 88 +++++++++ 5 files changed, 750 insertions(+) create mode 100644 drivers/memory/ras2.c create mode 100644 drivers/memory/ras2_common.c create mode 100755 include/memory/ras2.h
Sorry if this was already covered, but why not put the common scrub and ras2 changes under /drivers/ras/?
Thanks,
Yazen
Re: [RFC PATCH v7 12/12] memory: RAS2: Add memory RAS2 driver
Quoted 39 lines · On Thu, 28 Mar 2024 11:23:38 -0400 Yazen Ghannam <[email protected]> wrote:
Quoted 26 lines · On 2/23/2024 9:37 AM, [email protected] wrote:
From: Shiju Jose <[email protected]>
Memory RAS2 driver binds to the platform device add by the ACPI RAS2 driver.
Driver registers the PCC channel for communicating with the ACPI compliant platform that contains RAS2 command support in the hardware.Add interface functions to support configuring the parameters of HW patrol scrubs in the system, which exposed to the kernel via the RAS2 and PCC, using the RAS2 commands.
Add support for RAS2 platform devices to register with scrub subsystem driver. This enables user to configure the parameters of HW patrol scrubs, which exposed to the kernel via the RAS2 table, through the scrub sysfs attributes.
Open Question:
Sysfs scrub control attribute "enable_background_scrub" is added for RAS2, based on the feedback from Bill Schwartz <[email protected] on v4 to enable/disable thebackground_scrubbingin the platform as defined in the “Configure Scrub Parameters [INPUT]“ field in RAS2 Table 5.87: Parameter Block Structure forPATROL_SCRUB.
Is it a right approach to support "enable_background_scrub" in the sysfs scrub control?Signed-off-by Shiju Jose <[email protected]>Quoted 11 lines
--- drivers/memory/Kconfig | 14 ++ drivers/memory/Makefile | 2 + drivers/memory/ras2.c | 364 +++++++++++++++++++++++++++++++++++ drivers/memory/ras2_common.c | 282 +++++++++++++++++++++++++++ include/memory/ras2.h | 88 +++++++++ 5 files changed, 750 insertions(+) create mode 100644 drivers/memory/ras2.c create mode 100644 drivers/memory/ras2_common.c create mode 100755 include/memory/ras2.h
Quoted 2 lines
Sorry if this was already covered, but why not put the common scrub and ras2 changes under /drivers/ras/?
Hi Yazen
Location / naming etc is definitely an open question.
Given the OCP RAS API has repeatedly come up in discussions (and that has a much wider scope), a RAS focused location may well make sense + some renaming to avoid being memory scrub specific.
Jonathan
Quoted 3 lines
Thanks,
Yazen
Re: [RFC PATCH v7 12/12] memory: RAS2: Add memory RAS2 driver
In reply to [email protected]Quoted 15 lines
drivers/memory/ras2.c new file +15
-0+/* +* The below functions are exposed to OSPM, to query, configure and +* initiate memory patrol scrub. +*/ +static int ras2_is_patrol_scrub_support (struct ras2_context *ras2_ctx) +{ +int ret; +struct acpi_ras2_shared_memory __iomem *generic_comm_base; + +if (!ras2_ctx || !ras2_ctx->pcc_comm_addr) +return -EFAULT ; + + generic_comm_base = ras2_ctx->pcc_comm_addr; +guard (spinlock_irqsave)(&ras2_ctx->spinlock); + generic_comm_base->set_capabilities[0 ] =0 ;
drivers/memory/ras2.c line 79
Quoted 10 lines
drivers/memory/ras2.c new file +10
-0+ +/* send command for reading RAS2 capabilities */ + ret =ras2_send_pcc_cmd (ras2_ctx,RAS2_PCC_CMD_EXEC ); +if (ret) { +dev_err (ras2_ctx->dev, +"%s: ras2_send_pcc_cmd failed\n" , __func__); +return ret; + } + +return generic_comm_base->features[0 ] &RAS2_SUPPORT_HW_PARTOL_SCRUB ;
Since firmware populates the feature bitmask on initialization, it would seem that we do not need to send a PCC CMD EXEC to read RAS2 capabilities.
Quoted 15 lines
drivers/memory/ras2.c new file +15
-0+} + +static int ras2_get_patrol_scrub_params (struct ras2_context *ras2_ctx, +struct ras2_scrub_params *params) +{ +int ret =0 ; +u8 min_supp_scrub_rate, max_supp_scrub_rate; +struct acpi_ras2_shared_memory __iomem *generic_comm_base; +struct acpi_ras2_patrol_scrub_parameter __iomem *patrol_scrub_params; + +if (!ras2_ctx || !ras2_ctx->pcc_comm_addr) +return -EFAULT ; + + generic_comm_base = ras2_ctx->pcc_comm_addr; + patrol_scrub_params = ras2_ctx->pcc_comm_addr +sizeof (*generic_comm_base);
drivers/memory/ras2.c line 104
Quoted 10 lines
drivers/memory/ras2.c new file +10
-0+ +guard (spinlock_irqsave)(&ras2_ctx->spinlock); + generic_comm_base->set_capabilities[0 ] =RAS2_SUPPORT_HW_PARTOL_SCRUB ; +/* send command for reading RAS2 capabilities */ + ret =ras2_send_pcc_cmd (ras2_ctx,RAS2_PCC_CMD_EXEC ); +if (ret) { +dev_err (ras2_ctx->dev, +"%s: ras2_send_pcc_cmd failed\n" , __func__); +return ret; + }
Similarly, since firmware populates the feature bitmask on initialization, it would seem that we do not need to send a PCC CMD EXEC to read RAS2 capabilities.
Quoted 11 lines
drivers/memory/ras2.c new file +11
-0+ +if (!(generic_comm_base->features[0 ] &RAS2_SUPPORT_HW_PARTOL_SCRUB ) || + !(generic_comm_base->num_parameter_blocks)) { +dev_err (ras2_ctx->dev, +"%s: Platform does not support HW Patrol Scrubber\n" , __func__); +return -EOPNOTSUPP ; + } + +if (!patrol_scrub_params->requested_address_range[1 ]) { + dev_err(ras2_ctx->dev, + "%s: Invalid requested address range, \
drivers/memory/ras2.c line 125
Quoted 10 lines
drivers/memory/ras2.c new file +10
-0+ requested_address_range[0]=0x%llx \ + requested_address_range[1]=0x%llx\n", + __func__, + patrol_scrub_params->requested_address_range[0 ], + patrol_scrub_params->requested_address_range[1]); +return -EOPNOTSUPP ; + } + + generic_comm_base->set_capabilities[0 ] =RAS2_SUPPORT_HW_PARTOL_SCRUB ; + patrol_scrub_params->header.type =RAS2_TYPE_PATROL_SCRUB ;
header.type should already be populated by firmware. Is assigning it here necessary?
Quoted 40 lines
drivers/memory/ras2.c new file +40
-0+ patrol_scrub_params->patrol_scrub_command =RAS2_GET_PATROL_PARAMETERS ; + +/* send command for reading the HW patrol scrub parameters */ + ret =ras2_send_pcc_cmd (ras2_ctx,RAS2_PCC_CMD_EXEC ); +if (ret) { +dev_err (ras2_ctx->dev, +"%s: failed to read HW patrol scrub parameters\n" , + __func__); +return ret; + } + +/* copy output scrub parameters */ + params->addr_base = patrol_scrub_params->actual_address_range[0 ]; + params->addr_size = patrol_scrub_params->actual_address_range[1 ]; + params->flags = patrol_scrub_params->flags; + params->rate =FIELD_GET (RAS2_PATROL_SCRUB_RATE_OUT_MASK , + patrol_scrub_params->scrub_params_out); + min_supp_scrub_rate =FIELD_GET (RAS2_PATROL_SCRUB_MIN_RATE_OUT_MASK , + patrol_scrub_params->scrub_params_out); + max_supp_scrub_rate =FIELD_GET (RAS2_PATROL_SCRUB_MAX_RATE_OUT_MASK , + patrol_scrub_params->scrub_params_out); +snprintf (params->rate_avail,RAS2_MAX_RATE_RANGE_LENGTH , +"%d-%d" , min_supp_scrub_rate, max_supp_scrub_rate); + +return 0 ; +} + +static int ras2_enable_patrol_scrub (struct ras2_context *ras2_ctx,bool enable) +{ +int ret =0 ; +struct ras2_scrub_params params; +struct acpi_ras2_shared_memory __iomem *generic_comm_base; +u8 scrub_rate_to_set, min_supp_scrub_rate, max_supp_scrub_rate; +struct acpi_ras2_patrol_scrub_parameter __iomem *patrol_scrub_params; + +if (!ras2_ctx || !ras2_ctx->pcc_comm_addr) +return -EFAULT ; + + generic_comm_base = ras2_ctx->pcc_comm_addr; + patrol_scrub_params = ras2_ctx->pcc_comm_addr +sizeof (*generic_comm_base);
drivers/memory/ras2.c line 175
Quoted 10 lines
drivers/memory/ras2.c new file +10
-0+ +if (enable) { + ret =ras2_get_patrol_scrub_params (ras2_ctx, ¶ms); +if (ret) +return ret; + } + +guard (spinlock_irqsave)(&ras2_ctx->spinlock); + generic_comm_base->set_capabilities[0 ] =RAS2_SUPPORT_HW_PARTOL_SCRUB ; + patrol_scrub_params->header.type =RAS2_TYPE_PATROL_SCRUB ;
header.type should already be populated by firmware. Is assigning it here necessary?
Quoted 40 lines
drivers/memory/ras2.c new file +40
-0+ +if (enable) { + patrol_scrub_params->patrol_scrub_command =RAS2_START_PATROL_SCRUBBER ; + patrol_scrub_params->requested_address_range[0 ] = params.addr_base; + patrol_scrub_params->requested_address_range[1 ] = params.addr_size; + + scrub_rate_to_set =FIELD_GET (RAS2_PATROL_SCRUB_RATE_IN_MASK , + patrol_scrub_params->scrub_params_in); + min_supp_scrub_rate =FIELD_GET (RAS2_PATROL_SCRUB_MIN_RATE_OUT_MASK , + patrol_scrub_params->scrub_params_out); + max_supp_scrub_rate =FIELD_GET (RAS2_PATROL_SCRUB_MAX_RATE_OUT_MASK , + patrol_scrub_params->scrub_params_out); +if (scrub_rate_to_set < min_supp_scrub_rate || + scrub_rate_to_set > max_supp_scrub_rate) { +dev_warn (ras2_ctx->dev, +"patrol scrub rate to set is out of the supported range\n" ); +dev_warn (ras2_ctx->dev, +"min_supp_scrub_rate=%d max_supp_scrub_rate=%d\n" , + min_supp_scrub_rate, max_supp_scrub_rate); +return -EINVAL ; + } + }else { + patrol_scrub_params->patrol_scrub_command =RAS2_STOP_PATROL_SCRUBBER ; + } + +/* send command for enable/disable HW patrol scrub */ + ret =ras2_send_pcc_cmd (ras2_ctx,RAS2_PCC_CMD_EXEC ); +if (ret) { +pr_err ("%s: failed to enable/disable the HW patrol scrub\n" , __func__); +return ret; + } + +return 0 ; +} + +static int ras2_enable_background_scrub (struct ras2_context *ras2_ctx,bool enable) +{ +int ret; +struct acpi_ras2_shared_memory __iomem *generic_comm_base; +struct acpi_ras2_patrol_scrub_parameter __iomem *patrol_scrub_params;
drivers/memory/ras2.c line 225
Quoted 10 lines
drivers/memory/ras2.c new file +10
-0+ +if (!ras2_ctx || !ras2_ctx->pcc_comm_addr) +return -EFAULT ; + + generic_comm_base = ras2_ctx->pcc_comm_addr; + patrol_scrub_params = ras2_ctx->pcc_comm_addr +sizeof (*generic_comm_base); + +guard (spinlock_irqsave)(&ras2_ctx->spinlock); + generic_comm_base->set_capabilities[0 ] =RAS2_SUPPORT_HW_PARTOL_SCRUB ; + patrol_scrub_params->header.type =RAS2_TYPE_PATROL_SCRUB ;
header.type should already be populated by firmware. Is assigning it here necessary?
Quoted 86 lines
drivers/memory/ras2.c new file +86
-0+ patrol_scrub_params->patrol_scrub_command =RAS2_START_PATROL_SCRUBBER ; + + patrol_scrub_params->scrub_params_in &= ~RAS2_PATROL_SCRUB_EN_BACKGROUND ; + patrol_scrub_params->scrub_params_in |=FIELD_PREP (RAS2_PATROL_SCRUB_EN_BACKGROUND , + enable); + +/* send command for enable/disable HW patrol scrub */ + ret =ras2_send_pcc_cmd (ras2_ctx,RAS2_PCC_CMD_EXEC ); +if (ret) { +dev_err (ras2_ctx->dev, +"%s: failed to enable/disable background patrol scrubbing\n" , + __func__); +return ret; + } + +return 0 ; +} +static int ras2_set_patrol_scrub_params (struct ras2_context *ras2_ctx, +struct ras2_scrub_params *params,u8 param_type) +{ +struct acpi_ras2_shared_memory __iomem *generic_comm_base; +struct acpi_ras2_patrol_scrub_parameter __iomem *patrol_scrub_params; + +if (!ras2_ctx || !ras2_ctx->pcc_comm_addr) +return -EFAULT ; + + generic_comm_base = ras2_ctx->pcc_comm_addr; + patrol_scrub_params = ras2_ctx->pcc_comm_addr +sizeof (*generic_comm_base); + +guard (spinlock_irqsave)(&ras2_ctx->spinlock); + patrol_scrub_params->header.type =RAS2_TYPE_PATROL_SCRUB ; +if (param_type ==RAS2_MEM_SCRUB_PARAM_ADDR_BASE && params->addr_base) { + patrol_scrub_params->requested_address_range[0 ] = params->addr_base; + }else if (param_type ==RAS2_MEM_SCRUB_PARAM_ADDR_SIZE && params->addr_size) { + patrol_scrub_params->requested_address_range[1 ] = params->addr_size; + }else if (param_type ==RAS2_MEM_SCRUB_PARAM_RATE ) { + patrol_scrub_params->scrub_params_in &= ~RAS2_PATROL_SCRUB_RATE_IN_MASK ; + patrol_scrub_params->scrub_params_in |=FIELD_PREP (RAS2_PATROL_SCRUB_RATE_IN_MASK , + params->rate); + }else { +dev_err (ras2_ctx->dev,"Invalid patrol scrub parameter to set\n" ); +return -EINVAL ; + } + +return 0 ; +} + +static const struct ras2_hw_scrub_ops ras2_hw_ops = { + .enable_scrub = ras2_enable_patrol_scrub, + .enable_background_scrub = ras2_enable_background_scrub, + .get_scrub_params = ras2_get_patrol_scrub_params, + .set_scrub_params = ras2_set_patrol_scrub_params, +}; + +static const struct scrub_ops ras2_scrub_ops = { + .is_visible = ras2_hw_scrub_is_visible, + .read = ras2_hw_scrub_read, + .write = ras2_hw_scrub_write, + .read_string = ras2_hw_scrub_read_strings, +}; + +static DEFINE_IDA (ras2_ida); + +static void devm_ras2_release (void *ctx) +{ +struct ras2_context *ras2_ctx = ctx; + +ida_free (&ras2_ida, ras2_ctx->id); +ras2_unregister_pcc_channel (ras2_ctx); +} + +static int ras2_probe (struct platform_device *pdev) +{ +int ret, id; +struct mbox_client *cl; +struct device *hw_scrub_dev; +struct ras2_context *ras2_ctx; +char scrub_name[RAS2_MAX_NAME_LENGTH ]; + + ras2_ctx =devm_kzalloc (&pdev->dev,sizeof (*ras2_ctx),GFP_KERNEL ); +if (!ras2_ctx) +return -ENOMEM ; + + ras2_ctx->dev = &pdev->dev; + ras2_ctx->ops = &ras2_hw_ops; +spin_lock_init (&ras2_ctx->spinlock);
drivers/memory/ras2.c line 321
Quoted 10 lines
drivers/memory/ras2.c new file +10
-0+platform_set_drvdata (pdev, ras2_ctx); + + cl = &ras2_ctx->mbox_client; +/* Request mailbox channel */ + cl->dev = &pdev->dev; + cl->tx_done = ras2_tx_done; + cl->knows_txdone = true; + ras2_ctx->pcc_subspace_idx = *((int *)pdev->dev.platform_data); +dev_dbg (&pdev->dev,"pcc-subspace-id=%d\n" , ras2_ctx->pcc_subspace_idx); + ret =ras2_register_pcc_channel (ras2_ctx);
In our enabling activities, we have found a challenge here. Our hardware has a single PCC channel corresponding to a single platform-wide scrub interface. This driver, following the ACPI spec, will create a new scrub node for each NUMA node. However, for us, this means that each scrub device will try to map the same PCC channel, and this causes an error.
Quoted 24 lines
drivers/memory/ras2.c new file +24
-0+if (ret <0 ) +return ret; + + ret =devm_add_action_or_reset (&pdev->dev, devm_ras2_release, ras2_ctx); +if (ret <0 ) +return ret; + +if (ras2_is_patrol_scrub_support (ras2_ctx)) { + id =ida_alloc (&ras2_ida,GFP_KERNEL ); +if (id <0 ) +return id; + ras2_ctx->id = id; +snprintf (scrub_name,sizeof (scrub_name),"%s%d" ,RAS2_SCRUB , id); +dev_set_name (&pdev->dev,RAS2_ID_FORMAT , id); + hw_scrub_dev =devm_scrub_device_register (&pdev->dev, scrub_name, + ras2_ctx, &ras2_scrub_ops, +0 ,NULL ); +if (PTR_ERR_OR_ZERO (hw_scrub_dev)) +return PTR_ERR_OR_ZERO (hw_scrub_dev); + } + ras2_ctx->scrub_dev = hw_scrub_dev; + +return 0 ; +}
RE: [RFC PATCH v7 12/12] memory: RAS2: Add memory RAS2 driver
Hi Daniel,
Quoted 23 lines
-----Original Message-----
From: Daniel Ferguson <[email protected]>
Sent: 28 March 2024 23:42
To: Shiju Jose <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; Jonathan Cameron <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; tanxiaofei <[email protected]>; Zengtao (B) <[email protected]>; [email protected]; wanghuiqiang <[email protected]>; Linuxarm <[email protected]>; [email protected]
Subject: Re: [RFC PATCH v7 12/12] memory: RAS2: Add memory RAS2 driverQuoted 1 line
+/*
...
Quoted 24 lines
Quoted 24 lines
drivers/memory/ras2.c new file +24
-0+ +static int ras2_probe (struct platform_device *pdev) { +int ret, id; +struct mbox_client *cl; +struct device *hw_scrub_dev; +struct ras2_context *ras2_ctx; +char scrub_name[RAS2_MAX_NAME_LENGTH ]; + + ras2_ctx =devm_kzalloc (&pdev->dev,sizeof (*ras2_ctx),GFP_KERNEL ); +if (!ras2_ctx) +return -ENOMEM ; + + ras2_ctx->dev = &pdev->dev; + ras2_ctx->ops = &ras2_hw_ops; +spin_lock_init (&ras2_ctx->spinlock); +platform_set_drvdata (pdev, ras2_ctx); + + cl = &ras2_ctx->mbox_client; +/* Request mailbox channel */ + cl->dev = &pdev->dev; + cl->tx_done = ras2_tx_done; + cl->knows_txdone = true; + ras2_ctx->pcc_subspace_idx = *((int *)pdev->dev.platform_data); + dev_dbg(&pdev->dev, "pcc-subspace-id=%d\n", ras2_ctx-
Quoted 8 lines
drivers/memory/ras2.c line 321
Quoted 2 lines
pcc_subspace_idx);drivers/memory/ras2.c new file +1
-0+ ret =ras2_register_pcc_channel (ras2_ctx);In our enabling activities, we have found a challenge here.
Our hardware has a single PCC channel corresponding to a single platform-wide scrub interface. This driver, following the ACPI spec, will create a new scrub node for each NUMA node. However, for us, this means that each scrub device will try to map the same PCC channel, and this causes an error.
Is failing to probe cleanly is enough for your platform? i.e. put any error messages as dev_dbg() or whichever one causes this problem.
Quoted 20 lines
drivers/memory/ras2.c
Quoted 4 lines
drivers/memory/ras2.c new file +4
-0+if (ret <0 ) +return ret; + + ret = devm_add_action_or_reset(&pdev->dev, devm_ras2_release,
ras2_ctx);drivers/memory/ras2.c
Quoted 9 lines
drivers/memory/ras2.c new file +9
-0+if (ret <0 ) +return ret; + +if (ras2_is_patrol_scrub_support (ras2_ctx)) { + id =ida_alloc (&ras2_ida,GFP_KERNEL ); +if (id <0 ) +return id; + ras2_ctx->id = id; + snprintf(scrub_name, sizeof(scrub_name), "%s%d",
RAS2_SCRUB, id);Review
Quoted 2 lines
(quoted diff) +2
-0+ dev_set_name(&pdev->dev, RAS2_ID_FORMAT, id); + hw_scrub_dev = devm_scrub_device_register(&pdev->dev,
scrub_name,Review
Quoted 1 line
(quoted diff) +1
-0+ ras2_ctx,
&ras2_scrub_ops,
Quoted 9 lines
drivers/memory/ras2.c line 345
Quoted 8 lines
drivers/memory/ras2.c new file +8
-0+ 0, NULL); +if (PTR_ERR_OR_ZERO (hw_scrub_dev)) +return PTR_ERR_OR_ZERO (hw_scrub_dev); + } + ras2_ctx->scrub_dev = hw_scrub_dev; + +return 0 ; +}
Thanks,
Shiju
Borislav Petkov
maintainerQuoted 3 lines · On Fri, Feb 23, 2024 at 10:37:11PM +0800, [email protected] wrote:
CXL patrol scrub and DDR5 ECS and ACPI RAS2 HW based memory patrol scrub features are added as use cases for the scrub subsystem to expose the scrub controls to the user.
WTH is a RAS2 driver and where is the RAS1 driver?
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 7 lines · On Fri, 23 Feb 2024 16:42:51 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 3 lines · On Fri, Feb 23, 2024 at 10:37:11PM +0800, [email protected] wrote:
CXL patrol scrub and DDR5 ECS and ACPI RAS2 HW based memory patrol scrub features are added as use cases for the scrub subsystem to expose the scrub controls to the user.
WTH is a RAS2 driver and where is the RAS1 driver?
Odd ACPI naming. RASF (which is very limited) was replaced by RAS2.
Both are ACPI tables that describe the Platform Communication Channels (mailbox) + provide a definition of the protocol that is sent over it in order to control memory scrub. RAS2 has some other uses this driver isn't touching on.
So in short, it's an ACPI spec defined interface for controlling Memory Scrub engines.
https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#acpi-ras2-feature-table-ras2
Jonathan
Borislav Petkov
maintainerQuoted 2 lines · Jonathan Cameron
So in short, it's an ACPI spec defined interface for controlling Memory Scrub engines.
Ok, let's call it acpi_ras2 then so that it is clear. We shouldn't be perpetuating the ACPI poor naming in the kernel. This way at least it is namespaced and says exactly where it is coming from.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette[AMD Official Use Only - General]
BTW, what is the encoding (units) of the 8-bit "scrub rate"? (the ACPI spec does not seem to define that detail)
Thanks,
Leo.
-----Original Message-----
From: Jonathan Cameron <[email protected]>
Sent: Friday, February 23, 2024 11:26 AM
To: Borislav Petkov <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sridharan, Vilas <[email protected]>; Duran, Leo <[email protected]>; Ghannam, Yazen <[email protected]>; [email protected]; [email protected]; [email protected]; Grimm, Jon <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [RFC PATCH v7 00/12] memory: scrub: introduce subsystem + CXL/ACPI-RAS2 drivers
Quoted 7 lines · On Fri, 23 Feb 2024 16:42:51 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 3 lines · On Fri, Feb 23, 2024 at 10:37:11PM +0800, [email protected] wrote:
CXL patrol scrub and DDR5 ECS and ACPI RAS2 HW based memory patrol scrub features are added as use cases for the scrub subsystem to expose the scrub controls to the user.
WTH is a RAS2 driver and where is the RAS1 driver?
Odd ACPI naming. RASF (which is very limited) was replaced by RAS2.
Both are ACPI tables that describe the Platform Communication Channels
(mailbox) + provide a definition of the protocol that is sent over it in order to control memory scrub. RAS2 has some other uses this driver isn't touching on.
So in short, it's an ACPI spec defined interface for controlling Memory Scrub engines.
https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#acpi-ras2-feature-table-ras2
Jonathan
Quoted 6 lines
RAS2 HW based memory patrol scrub needs RAS2 PCC interfaces and ACPI RAS2 driver for communication b/w kernel and firmware. ACPI RAS2 Driver adds platform device, for each memory feature, which binds to the RAS2 memory driver.
Memory RAS2 driver registers with the memory scrub subsystem to expose the RAS2 scrub controls to the user.
Hi Shiju,
Thanks for this work. This has been very useful for us, as we've been using it to test a RAS2 implementation here at Ampere Computing.
In general, the pieces implementing RAS2 are useful and functional. We did, however, encounter a few places where we had to make some bug fixes. I'll reply to specific patches with changes I can recommend. Also, there are a few implementation choices that I will have questions about.
Here is an outline containing the generalized comments I plan on making within/near relevant patches:
1) Found a bug in ras2.c in how the pcc_desc_list pointer is incremented.
2) Executing a RAS2 command seems unnecessary for feature detection. specifically, in the functions ras2_is_patrol_scrub_support() and ras2_get_patrol_scrub_params()
3) Consider adding more error detection/reporting in ras2_check_pcc_chan()
4) Concerns with multiple scrub devices attempting to map the same PCC channel.
-Daniel
Hi Daniel,
Thanks for the feedbacks.
Quoted 34 lines
-----Original Message-----
From: Daniel Ferguson <[email protected]>
Sent: 28 March 2024 23:40
To: Shiju Jose <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; Jonathan Cameron <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; tanxiaofei <[email protected]>; Zengtao (B) <[email protected]>; [email protected]; wanghuiqiang <[email protected]>; Linuxarm <[email protected]>; [email protected]
Subject: Re: [RFC PATCH v7 00/12] memory: scrub: introduce subsystem + CXL/ACPI-RAS2 driversQuoted 6 lines
RAS2 HW based memory patrol scrub needs RAS2 PCC interfaces and ACPI RAS2 driver for communication b/w kernel and firmware.
ACPI RAS2 Driver adds platform device, for each memory feature, which binds to the RAS2 memory driver.
Memory RAS2 driver registers with the memory scrub subsystem to expose the RAS2 scrub controls to the user.Hi Shiju,
Thanks for this work. This has been very useful for us, as we've been using it to test a RAS2 implementation here at Ampere Computing.
Quoted 8 lines
In general, the pieces implementing RAS2 are useful and functional. We did, however, encounter a few places where we had to make some bug fixes. I'll reply to specific patches with changes I can recommend. Also, there are a few implementation choices that I will have questions about.
Here is an outline containing the generalized comments I plan on making within/near relevant patches:
1) Found a bug inras2.cin how thepcc_desc_listpointer is incremented.
This bug was fixed in the local v8 code.
Quoted 3 lines
2) Executing a RAS2 command seems unnecessary for feature detection. specifically, in the functions
ras2_is_patrol_scrub_support()andras2_get_patrol_scrub_params()
I will check and modify in the next version.
Quoted 1 line
3) Consider adding more error detection/reporting in
ras2_check_pcc_chan()
Sure.
Quoted 2 lines
4) Concerns with multiple scrub devices attempting to map the same PCC channel.
I will reply in the patch.
Quoted 3 lines
-Daniel
Thanks,
Shiju