EDAC: Scrub: introduce generic EDAC RAS control feature driver + CXL/ACPI-RAS2 drivers
Subsystems (7)
v11 cover EDAC: Scrub: introduce generic EDAC RAS control feature driver + CXL/ACPI-RAS2 drivers
From: Shiju Jose <[email protected]>
Previously known as "ras: scrub: introduce subsystem + CXL/ACPI-RAS2 drivers".
Augmenting EDAC for controlling RAS features
============================================
The proposed expansion of EDAC for controlling RAS features and exposing feature's control attributes to the userspace in sysfs. Some Examples:
- Scrub control
- Error Check Scrub (ECS) control
- ACPI RAS2 features
- ACPI Address Range Scrubbing (ARS)
- Post Package Repair (PPR) etc.
High level design is illustrated in the following diagram.
_______________________________________________
| Userspace - Rasdaemon |
| ____________ |
| | RAS CXL | _____________ |
| | Err Handler|----->| | |
| |____________| | RAS Dynamic | |
| ____________ | Scrub | |
| | RAS Memory |----->| Controller | |
| | Err Handler| |_____________| |
| |____________| | |
|__________________________|____________________|
|
|
_______________________________|______________________________
| Kernel EDAC based SubSystem | for RAS Features Control |
| ______________________________|____________________________ |
|| EDAC Core Sysfs EDAC| Bus | |
|| __________________________|_______ _____________ | |
|| |/sys/bus/edac/devices/<dev>/scrub/| | EDAC Device | | |
|| |/sys/bus/edac/devices/<dev>/ecs*/ |<->| EDAC MC | | |
|| |/sys/bus/edac/devices/<dev>/ars/ | | EDAC Sysfs | | |
|| |/sys/bus/edac/devices/<dev>/ppr/ | | EDAC Module | | |
|| |__________________________________| |_____________| | |
|| | EDAC Bus | |
|| Get | | |
|| __________ Feature's | __________ | |
|| | |Descs _________|______ | | | |
|| |EDAC Scrub|<-----| EDAC RAS |---->| EDAC ARS | | |
|| |__________| |Control Feature | |__________| | |
|| __________ | Driver | __________ | |
|| | |<-----|________________|---->| | | |
|| |EDAC ECS | Register RAS | Features | EDAC PPR | | |
|| |__________| | |__________| | |
|| ______________________|___________________ | |
||_________|_____________|_____________|____________|________| |
| _______|____ _____|______ ____|______ ___|_____ |
| | | | CXL Mem | | | | | |
| | ACPI RAS2 | | Driver PPR,| | ACPI ARS | | PPR | |
| | Driver | | Scrub,ECS | | Driver | | Driver | |
| |____________| |____________| |___________| |_________| |
| | | | | |
|________|______________|______________|___________|___________|
| | | |
_______|______________|______________|___________|___________
| __|______________|_ ____________|___________|_____ |
| | | |
| | Platform HW and Firmware | |
| |__________________________________________________| |
|_____________________________________________________________| 1. EDAC Features components - Create feature specific descriptors.
2. EDAC RAS Feature driver - Get feature's attr descriptors from the EDAC RAS feature component and registers device's RAS features with EDAC bus and expose the feature's sysfs attributes under the sysfs EDAC bus.
3. RAS dynamic scrub controller - Userspace sample module added in the rasdaemon to start scrubbing when excess number of related errors are reported in a short span of time.
The added EDAC feature specific components (e.g. EDAC scrub, EDAC ECS, EDAC PPR etc) do callbacks to the parent driver (e.g. CXL driver, ACPI RAS driver etc) for the controls rather than just letting the caller deal with it because of the following reasons.
1. Enforces a common API across multiple implementations can do that via review, but that's not generally gone well in the long run for subsystems that have done it (several have later moved to callback and feature list based approaches).
2. Gives a path for 'intercepting' in the EDAC feature driver. An example for this is that we could intercept PPR repair calls and sanity check that the memory in question is offline before passing back to the underlying code. Sure we could rely on doing that via some additional calls from the parent driver, but the ABI will get messier.
3. (Speculative) we may get in kernel users of some features in the long run.
More details of the common RAS features are described in the following sections.
Memory Scrubbing
================
Increasing DRAM size and cost has made memory subsystem reliability an important concern. These modules are used where potentially corrupted data could cause expensive or fatal issues. Memory errors are one of the top hardware failures that cause server and workload crashes.
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.
The memory DIMMs could be scrubbed at a configurable rate to detect uncorrected memory errors and attempts to recover from detected memory errors providing the following benefits.
- Proactively scrubbing memory DIMMs reduces the chance of a correctable error becoming uncorrectable.
- Once detected, uncorrected errors caught in unallocated memory pages are isolated and prevented from being allocated to an application or the OS.
- The probability of software/hardware products encountering memory errors is reduced.
Some details of background can be found in Reference [5].
There are 2 types of memory scrubbing,
1. Background (patrol) scrubbing of the RAM whilest the RAM is otherwise idle.
2. On-demand scrubbing for a specific address range/region of memory.
There are several types of interfaces to HW memory scrubbers identified such as ACPI NVDIMM ARS(Address Range Scrub), CXL memory device patrol scrub, CXL DDR5 ECS, ACPI RAS2 memory scrubbing.
The scrub control varies between different memory scrubbers. To allow for standard userspace tooling there is a need to present these controls with a standard ABI.
Introduce generic memory EDAC scrub control which allows user to control underlying scrubbers in the system via generic sysfs scrub control interface.
Use case of common scrub control feature
========================================
1. There are several types of interfaces to HW memory scrubbers identified such as ACPI NVDIMM ARS(Address Range Scrub), CXL memory device patrol scrub, CXL DDR5 ECS, ACPI RAS2 memory scrubbing features and software based memory scrubber(discussed in the community Reference [5]). Also some scrubbers support controlling (background) patrol scrubbing (ACPI RAS2, CXL) and/or on-demand scrubbing(ACPI RAS2, ACPI ARS). However the scrub controls varies between memory scrubbers. Thus there is a requirement for a standard generic sysfs scrub controls exposed to the userspace for the seamless control of the HW/SW scrubbers in the system by admin/scripts/tools etc.
2. Scrub controls in user space allow the user to disable the scrubbing in case disabling of the background patrol scrubbing or changing the scrub rate are needed for other purposes such as performance-aware operations which requires the background operations to be turned off or reduced.
3. Allows to perform on-demand scrubbing for specific address range if supported by the scrubber.
4. User space tools controls scrub the memory DIMMs regularly at a configurable scrub rate using the sysfs scrub controls discussed help,
- to detect uncorrectable memory errors early before user accessing memory, which helps to recover the detected memory errors.
- reduces the chance of a correctable error becoming uncorrectable.
5. Policy control for hotplugged memory. There is not necessarily a system wide bios or similar in the loop to control the scrub settings on a CXL device that wasn't there at boot. What that setting should be is a policy decision as we are trading of reliability vs performance - hence it should be in control of userspace. As such, 'an' interface is needed. Seems more sensible to try and unify it with other similar interfaces than spin yet another one.
The draft version of userspace code for dynamic scrub control, based on frequency of memory errors reported to the userspace, is added in rasdaemon and enabled, tested for CXL device based patrol scrubbing feature and ACPI RAS2 based scrubbing feature.
https://github.com/shijujose4/rasdaemon/tree/scrub_control_6_june_2024
For PPR, rasdaemon collates records and decides to replace a row if there are lots of corrected errors, or a single uncorrected error or error record received with maintenance request flag set as in CXL DRAM error record.
Comparison of scrubbing features
================================
................................................................
. . ACPI . CXL patrol. CXL ECS . ARS . . Name . RAS2 . scrub . . . ................................................................ . . . . . . . On-demand . Supported . No . No . Supported . . Scrubbing . . . . . . . . . . . ................................................................ . . . . . . . Background . Supported . Supported . Supported . No . . scrubbing . . . . . . . . . . . ................................................................ . . . . . . . Mode of . Scrub ctrl. per device. per memory. Unknown . . scrubbing . per NUMA . . media . . . . domain. . . . . ................................................................ . . . . . . . Query scrub . Supported . Supported . Supported . Supported . . capabilities . . . . . . . . . . . ................................................................ . . . . . . . Setting . Supported . No . No . Supported . . address range. . . . . . . . . . . ................................................................ . . . . . . . Setting . Supported . Supported . No . No . . scrub rate . . . . . . . . . . . ................................................................ . . . . . . . Unit for . Not . in hours . No . No . . scrub rate . Defined . . . . . . . . . . ................................................................ . . Supported . . . . . Scrub . on-demand . No . No . Supported . . status/ . scrubbing . . . . . Completion . only . . . . ................................................................ . UC error . .CXL general.CXL general. ACPI UCE . . reporting . Exception .media/DRAM .media/DRAM . notify and. . . .event/media.event/media. query . . . .scan? .scan? . ARS status. ................................................................ . . . . . . . Clear UC . No . No . No . Supported . . error . . . . . . . . . . . ................................................................ . . . . . . . Translate . No . No . No . Supported . . *(1)SPA to . . . . . . *(2)DPA . . . . . ................................................................ . . . . . . . Error inject . No . Can inject. No . Supported . . . . poison for. . . . . . CXL . . .
................................................................
*(1) - SPA - System Physical Address. See section 9.19.7.8
Function Index 5 - Translate SPA of ACPI spec r6.5.
*(2) - DPA - Device Physical Address. See section 9.19.7.8
Function Index 5 - Translate SPA of ACPI spec r6.5.
CXL Scrubbing features
======================
Add support for control CXL patrol scrubber and ACPI RAS2 HW based memory patrol scrubber and register with the EDAC scrub to expose the scrub controls to the userspace tool.
CXL spec r3.1 section 8.2.9.9.11.1 describes the memory 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 scrubber's input configurations.
The patrol scrub control allows the requester to specify the number of hours in 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.
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 DDR5 device contains number of memory media FRUs per device. The DDR5 ECS feature and thus the ECS control driver supports configuring the ECS parameters per FRU.
ACPI RAS2 Hardware-based Memory Scrubbing
=========================================
ACPI spec 6.5 section 5.2.21 ACPI RAS2 describes ACPI RAS2 table provides interfaces for platform RAS features and supports independent RAS controls and capabilities for a given RAS feature for multiple instances of the same component in a given system.
Memory RAS features apply to RAS capabilities, controls and operations that are specific to memory. RAS2 PCC sub-spaces for memory-specific RAS features have a Feature Type of 0x00 (Memory).
The platform can use the hardware-based memory scrubbing feature to expose controls and capabilities associated with hardware-based memory scrub engines. The RAS2 memory scrubbing feature supports following as per spec,
- Independent memory scrubbing controls for each NUMA domain, identified using its proximity domain.
Note: However AmpereComputing has single entry repeated as they have
centralized controls.
- Provision for background (patrol) scrubbing of the entire memory system, as well as on-demand scrubbing for a specific region of memory.
ACPI Address Range Scrubbing(ARS)
================================
ARS allows the platform to communicate memory errors to system software. This capability allows system software to prevent accesses to addresses with uncorrectable errors in memory. ARS functions manage all NVDIMMs present in the system. Only one scrub can be in progress system wide at any given time.
Following functions are supported as per the specification.
1. Query ARS Capabilities for a given address range, indicates platform supports the ACPI NVDIMM Root Device Unconsumed Error Notification.
2. Start ARS triggers an Address Range Scrub for the given memory range. Address scrubbing can be done for volatile memory, persistent memory, or both.
3. Query ARS Status command allows software to get the status of ARS, including the progress of ARS and ARS error record.
4. Clear Uncorrectable Error.
5. Translate SPA
6. ARS Error Inject etc.
Note: Support for ARS is not added in this series because to reduce the line of code for review and could be added after initial code is merged. We'd like feedback on whether this is of interest to ARS community?
Post Package Repair(PPR)
========================
PPR (Post Package Repair) maintenance operation requests the memory device to perform a repair operation on its media if supported. A memory device may support two types of PPR: Hard PPR (hPPR), for a permanent row repair, and Soft PPR (sPPR), for a temporary row repair. sPPR is much faster than hPPR, but the repair is lost with a power cycle.
Series adds,
1. Generic EDAC RAS feature driver, EDAC scrub driver, EDAC ECS driver supports memory scrub control, ECS control and PPR control, other RAS features in the system.
2. Support for CXL feature mailbox commands, which is used by CXL device scrubbing and PPR features.
3. CXL scrub driver supporting patrol scrub control (device and region based).
4. CXL ECS driver supporting ECS control feature.
5. ACPI RAS2 driver adds OS interface for RAS2 communication through PCC mailbox and extracts ACPI RAS2 feature table (RAS2) and create platform device for the RAS memory features, which binds to the memory ACPI RAS2 driver.
7. Memory ACPI RAS2 driver gets the PCC subspace for communicating with the ACPI compliant platform supports ACPI RAS2. Add callback functions and registers with EDAC scrub to support user to control the HW patrol scrubbers exposed to the kernel via the ACPI RAS2 table.
8. Support for CXL maintenance mailbox command, which is used by CXL device PPR feature.
9. CXL PPR driver supporting PPR control feature.
10. Note: There are other PPR drivers to come.
The QEMU series to support the CXL specific scrub features is available here,
https://lore.kernel.org/linux-cxl/[email protected]/T/#mae1e799306d2841eb7e1b637b82046114b926d56
QEMU patch supports the CXL PPR feature is
available here,
https://lore.kernel.org/all/[email protected]/
Open Questions based on feedbacks from the community:
1. Leo: Standardize unit for scrub rate, for example ACPI RAS2 does not define unit for the scrub rate. RAS2 clarification needed.
2. Jonathan: Any need for discoverability of capability to scan different regions, such as global PA space to the userspace. Left as future extension.
3. Jiaqi:
- STOP_PATROL_SCRUBBER from RAS2 must be blocked and, must not be exposed to OS/userspace. Stopping patrol scrubber is unacceptable for platform where OEM has enabled patrol scrubber, because the patrol scrubber is a key part of logging and is repurposed for other RAS actions.
If the OEM does not want to expose this control, they should lock it down so the interface is not exposed to the OS. These features are optional afterall.
- "Requested Address Range"/"Actual Address Range" (region to scrub) is a similarly bad thing to expose in RAS2.
If the OEM does not want to expose this, they should lock it down so the interface is not exposed to the OS. These features are optional afterall.
4. Borislav:
- How the scrub control exposed to the userspace will be used?
POC added in rasdaemon with dynamic scrub control for CXL memory media errors and memory errors reported to the userspace.
https://github.com/shijujose4/rasdaemon/tree/scrub_control_6_june_2024
- Is the scrub interface is sufficient for the use cases?
- Who is going to use scrub controls tools/admin/scripts?
1) Rasdaemon for dynamic control
2) Udev script for more static 'defaults' on hotplug etc.
5. PPR
- For PPR, rasdaemon collates records and decides to replace a row if there are lots of corrected errors, or a single uncorrected error or error record received with maintenance request flag set as in CXL DRAM error record.
- sPPR more or less startup only (so faking hPPR) or actually useful in a running system (if not the safe version that keeps everything running whilst replacement is ongoing)
- Is future proofing for multiple PPR units useful given we've mashed together hPPR and sPPR for CXL.
References:
1. ACPI spec r6.5 section 5.2.21 ACPI RAS2.
2. ACPI spec r6.5 section 9.19.7.2 ARS.
3. CXL spec r3.1 8.2.9.9.11.1 Device patrol scrub control feature
4. CXL spec r3.1 8.2.9.9.11.2 DDR5 ECS feature
5. Background information about kernel support for memory scan, memory error detection and ACPI RASF.
https://lore.kernel.org/all/[email protected]/
6. Discussions on RASF:
https://lore.kernel.org/lkml/[email protected]/#r
Changes
=======
v10 -> v11:
1. Feedback from Borislav:
- Add generic EDAC code for control device features to /drivers/edac/edac_device.c.
- Add common structure in edac for device feature's data.
2. Some more optimizations in generic EDAC code for control device features.
3. Changes for feedback from Fan for ACPI RAS2 memory driver.
4. Add support for control memory PPR (Post Package Repair) features in EDAC.
5. Add support for maintenance command in the CXL mailbox code, which is needed for support PPR features in CXL driver.
6. Add support for control memory PPR (Post Package Repair) features and do perform PPR maintenance operation in CXL driver.
7. Rename drivers/cxl/core/memscrub.c to drivers/cxl/core/memfeature.c
v9 -> v10:
1. Feedback from Mauro Carvalho Chehab:
- Changes suggested in EDAC RAS feature driver.
use uppercase for enums, if else to switch-case, documentation for static scrub and ecs init functions etc.
- Changes suggested in EDAC scrub.
unit of scrub cycle hour to seconds.
attribute node cycle_in_hours_avaiable to min_cycle_duration and max_cycle_duration.
attribute node cycle_in_hours to current_cycle_duration. Use base 0 for kstrtou64() and kstrtol() functions. etc.
- Changes suggested in EDAC ECS.
uppercase for enums
add ABI documentation. etc
2. Feedback from Fan:
- Changes suggested in EDAC RAS feature driver. use uppercase for enums, change if...else to switch-case. some optimization in edac_ras_dev_register() function add missing goto free_ctx
- Changes suggested in the code for feature commands.
- CXL driver scrub and ECS code
use uppercase for enums, fix typo, use enum type for mode fix lonf lines etc.
v8 -> v9:
1. Feedback from Borislav:
- Add scrub control driver to the EDAC on feedback from Borislav.
- Changed DEVICE_ATTR_..() static.
- Changed the write permissions for scrub control sysfs files as root-only.
2. Feedback from Fan:
- Optimized cxl_get_feature() function by using min() and removed feat_out_min_size.
- Removed unreached return from cxl_set_feature() function.
- Changed the term "rate" to "cycle_in_hours" in all the scrub control code.
- Allow cxl_mem_probe() continue if cxl_mem_patrol_scrub_init() fail, with just a debug warning.
3. Feedback from Jonathan:
- Removed patch __free() based cleanup function for acpi_put_table. and added fix in the acpi ras2 driver.
4. Feedback from Dan Williams:
- Allow cxl_mem_probe() continue if cxl_mem_patrol_scrub_init() fail, with just a debug warning.
- Add support for CXL region based scrub control.
5. Feedback from Daniel Ferguson on RAS2 drivers:
In the ACPI RAS2 driver,
- Incorporated the changes given for clearing error reported.
- Incorporated the changes given for check the Set RAS Capability status and return an appropriate error.
In the RAS2 memory driver,
- Added more checks for start/stop bg and on-demand scrubbing so that addr range in cache do not get cleared and restrict permitted operations during scrubbing.
History for v1 to v8 is avaiable here.
https://lore.kernel.org/lkml/[email protected]/
Jonathan Cameron (1):
platform: Add __free() based cleanup function for platform_device_put
Shiju Jose (13):
EDAC: Add support for EDAC device feature's control
EDAC: Add EDAC scrub control driver
EDAC: Add EDAC ECS control driver
cxl/mbox: Add GET_SUPPORTED_FEATURES mailbox command cxl/mbox: Add GET_FEATURE mailbox command
cxl/mbox: Add SET_FEATURE mailbox command cxl/memfeature: Add CXL memory device patrol scrub control feature cxl/memfeature: Add CXL memory device ECS control feature ACPI:RAS2: Add ACPI RAS2 driver
ras: mem: Add memory ACPI RAS2 driver
EDAC: Add EDAC PPR control driver
cxl/mbox: Add support for PERFORM_MAINTENANCE mailbox command cxl/memfeature: Add CXL memory device PPR control feature
Documentation/ABI/testing/sysfs-edac-ecs | 78 ++ Documentation/ABI/testing/sysfs-edac-ppr | 69 ++ Documentation/ABI/testing/sysfs-edac-scrub | 69 ++ Documentation/edac/edac-scrub.rst | 115 +++ drivers/acpi/Kconfig | 10 + drivers/acpi/Makefile | 1 + drivers/acpi/ras2.c | 391 +++++++ drivers/cxl/Kconfig | 18 + drivers/cxl/core/Makefile | 1 + drivers/cxl/core/mbox.c | 219 ++++ drivers/cxl/core/memfeature.c | 1090 ++++++++++++++++++++ drivers/cxl/core/region.c | 6 + drivers/cxl/cxlmem.h | 148 +++ drivers/cxl/mem.c | 4 + drivers/edac/Makefile | 1 + drivers/edac/edac_device.c | 189 ++++ drivers/edac/edac_ecs.c | 376 +++++++ drivers/edac/edac_ppr.c | 255 +++++ drivers/edac/edac_scrub.c | 315 ++++++ drivers/ras/Kconfig | 10 + drivers/ras/Makefile | 1 + drivers/ras/acpi_ras2.c | 411 ++++++++ include/acpi/ras2_acpi.h | 59 ++ include/linux/edac.h | 151 +++ include/linux/platform_device.h | 1 + 25 files changed, 3988 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-edac-ecs create mode 100644 Documentation/ABI/testing/sysfs-edac-ppr create mode 100644 Documentation/ABI/testing/sysfs-edac-scrub create mode 100644 Documentation/edac/edac-scrub.rst create mode 100755 drivers/acpi/ras2.c create mode 100644 drivers/cxl/core/memfeature.c create mode 100755 drivers/edac/edac_ecs.c create mode 100755 drivers/edac/edac_ppr.c create mode 100755 drivers/edac/edac_scrub.c create mode 100644 drivers/ras/acpi_ras2.c create mode 100644 include/acpi/ras2_acpi.h
Signature · 1 line
2.34.1
PATCH v11 1/14 EDAC: Add support for EDAC device feature's control
From: Shiju Jose <[email protected]>
Add generic EDAC device feature's control supports registering RAS features supported in the system. Driver exposes feature's control attributes to the userspace in /sys/bus/edac/devices/<dev-name>/<ras-feature>/
--- drivers/edac/edac_device.c | 178 +++++++++++++++++++++++++++++++++++++ include/linux/edac.h | 60 +++++++++++++ 2 files changed, 238 insertions(+)
drivers/edac/edac_device.c +178 -0
@@ -570,3 +570,181 @@ void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, block ? block->name : "N/A", count, msg); }EXPORT_SYMBOL_GPL (edac_device_handle_ue_count); + +/* EDAC device feature */ +static void edac_dev_release (struct device *dev) +{ +struct edac_dev_feat_ctx *ctx = + container_of(dev, struct edac_dev_feat_ctx, dev); + +kfree (ctx->dev.groups); +kfree (ctx); +} + +const struct device_type edac_dev_type = { + .name ="edac_dev" , + .release = edac_dev_release, +}; + +static void edac_dev_unreg (void *data) +{ +device_unregister (data); +} + +/** +* edac_dev_feature_init - Init a ras feature +* @parent: client device. +* @dev_data: pointer to struct edac_dev_data. +* @feat: pointer to struct edac_dev_feature. +* @attr_groups: pointer to attribute group's container. +* +* Returns number of scrub feature's attribute groups on success, +* error otherwise. +*/ +static int edac_dev_feat_init (struct device *parent, +struct edac_dev_data *dev_data, +const struct edac_dev_feature *ras_feat, +const struct attribute_group **attr_groups) +{ +int num; + +switch (ras_feat->feat) { +case RAS_FEAT_SCRUB : + dev_data->scrub_ops = ras_feat->scrub_ops; + dev_data->private = ras_feat->scrub_ctx; +return 1 ; +case RAS_FEAT_ECS : + num = ras_feat->ecs_info.num_media_frus; + dev_data->ecs_ops = ras_feat->ecs_ops; + dev_data->private = ras_feat->ecs_ctx; +return num; +case RAS_FEAT_PPR : + dev_data->ppr_ops = ras_feat->ppr_ops; + dev_data->private = ras_feat->ppr_ctx; +return 1 ; +default : +return -EINVAL ; + } +} + +/** +* edac_dev_register - register device for ras features with edac +* @parent: client device. +* @name: client device's name. +* @private: parent driver's data to store in the context if any. +* @num_features: number of ras features to register. +* @ras_features: list of ras features to register. +* +* Returns 0 on success, error otherwise. +* The new edac_dev_feat_ctx would be freed automatically. +*/ +int edac_dev_register (struct device *parent,char *name, +void *private,int num_features, +const struct edac_dev_feature *ras_features) +{ +const struct attribute_group **ras_attr_groups; +struct edac_dev_data *dev_data; +struct edac_dev_feat_ctx *ctx; +int ppr_cnt =0 , ppr_inst =0 ; +int attr_gcnt =0 ; +int ret, feat; + +if (!parent || !name || !num_features || !ras_features) +return -EINVAL ; + +/* Double parse so we can make space for attributes */ +for (feat =0 ; feat < num_features; feat++) { +switch (ras_features[feat].feat) { +case RAS_FEAT_SCRUB : +case RAS_FEAT_PPR : + attr_gcnt++; + ppr_cnt++; +break ; +case RAS_FEAT_ECS : + attr_gcnt += ras_features[feat].ecs_info.num_media_frus; +break ; +default : +return -EINVAL ; + } + } + + ctx =kzalloc (sizeof (*ctx),GFP_KERNEL ); +if (!ctx) +return -ENOMEM ; + + ctx->dev.parent = parent; + ctx->private = private; + + ras_attr_groups =kcalloc (attr_gcnt +1 ,sizeof (*ras_attr_groups),GFP_KERNEL ); +if (!ras_attr_groups) { + ret = -ENOMEM ; + goto ctx_free; + } + +if (ppr_cnt) { + ctx->ppr =kcalloc (ppr_cnt,sizeof (*(ctx->ppr)),GFP_KERNEL ); +if (!ctx->ppr) { + ret = -ENOMEM ; + goto groups_free; + } + } + + attr_gcnt =0 ; +for (feat =0 ; feat < num_features; feat++, ras_features++) { +switch (ras_features->feat) { +case RAS_FEAT_SCRUB : +if (!ras_features->scrub_ops) +continue ; + dev_data = &ctx->scrub; +break ; +case RAS_FEAT_ECS : +if (!ras_features->ecs_ops) +continue ; + dev_data = &ctx->ecs; +break ; +case RAS_FEAT_PPR : +if (!ras_features->ppr_ops) +continue ; + dev_data = &ctx->ppr[ppr_inst]; + dev_data->instance = ppr_inst; + ppr_inst++; +break ; +default : + ret = -EINVAL ; + goto data_mem_free; + } + ret =edac_dev_feat_init (parent, dev_data, ras_features, + &ras_attr_groups[attr_gcnt]); +if (ret <0 ) + goto data_mem_free; + + attr_gcnt += ret; + } + ras_attr_groups[attr_gcnt] =NULL ; + ctx->dev.bus =edac_get_sysfs_subsys (); + ctx->dev.type = &edac_dev_type; + ctx->dev.groups = ras_attr_groups; +dev_set_drvdata (&ctx->dev, ctx); + ret =dev_set_name (&ctx->dev, name); +if (ret) + goto data_mem_free; + + ret =device_register (&ctx->dev); +if (ret) { +put_device (&ctx->dev); + goto data_mem_free; +return ret; + } + +return devm_add_action_or_reset (parent, edac_dev_unreg, &ctx->dev); + +data_mem_free: +if (ppr_cnt) +kfree (ctx->ppr); +groups_free: +kfree (ras_attr_groups); +ctx_free: +kfree (ctx); +return ret; +} +EXPORT_SYMBOL_GPL (edac_dev_register);
include/linux/edac.h +60 -0
64 lines not on this page · raw message
Signature · 1 line
2.34.1
kernel test robot
build botRe: [PATCH v11 01/14] EDAC: Add support for EDAC device feature's control
kernel test robot noticed the following build warnings:
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on ras/edac-for-next]
[also build test WARNING on rafael-pm/linux-next rafael-pm/bleeding-edge cxl/next linus/master cxl/pending v6.11-rc3 next-20240816] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/shiju-jose-huawei-com/EDAC-Add-support-for-EDAC-device-feature-s-control/20240817-004442 base: https://git.kernel.org/pub/scm/linux/kernel/git/ras/ras.git edac-for-next patch link: https://lore.kernel.org/r/20240816164238.1902-2-shiju.jose%40huawei.com patch subject: [PATCH v11 01/14] EDAC: Add support for EDAC device feature's control config: i386-buildonly-randconfig-003-20240818 (https://download.01.org/0day-ci/archive/20240818/[email protected]/config) compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240818/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/edac/edac_device.c:608: warning: Function parameter or struct member 'ras_feat' not described in 'edac_dev_feat_init' >> drivers/edac/edac_device.c:608: warning: expecting prototype for edac_dev_feature_init(). Prototype was for edac_dev_feat_init() instead
vim +608 drivers/edac/edac_device.c
593
594 /**
595 * edac_dev_feature_init - Init a ras feature
596 * @parent: client device.
597 * @dev_data: pointer to struct edac_dev_data.
598 * @feat: pointer to struct edac_dev_feature.
599 * @attr_groups: pointer to attribute group's container.
600 *
601 * Returns number of scrub feature's attribute groups on success,
602 * error otherwise.
603 */
604 static int edac_dev_feat_init(struct device *parent,
605 struct edac_dev_data *dev_data,
606 const struct edac_dev_feature *ras_feat,
607 const struct attribute_group **attr_groups)
> 608 { 609 int num;
610
611 switch (ras_feat->feat) {
612 case RAS_FEAT_SCRUB:
613 dev_data->scrub_ops = ras_feat->scrub_ops;
614 dev_data->private = ras_feat->scrub_ctx;
615 return 1;
616 case RAS_FEAT_ECS:
617 num = ras_feat->ecs_info.num_media_frus;
618 dev_data->ecs_ops = ras_feat->ecs_ops;
619 dev_data->private = ras_feat->ecs_ctx;
620 return num;
621 case RAS_FEAT_PPR:
622 dev_data->ppr_ops = ras_feat->ppr_ops;
623 dev_data->private = ras_feat->ppr_ctx;
624 return 1;
625 default:
626 return -EINVAL;
627 }
628 }
629
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v11 01/14] EDAC: Add support for EDAC device feature's control
In reply to [email protected]kernel test robot noticed the following build warnings:
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on ras/edac-for-next]
[also build test WARNING on rafael-pm/linux-next rafael-pm/bleeding-edge cxl/next linus/master cxl/pending v6.11-rc3 next-20240816] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/shiju-jose-huawei-com/EDAC-Add-support-for-EDAC-device-feature-s-control/20240817-004442 base: https://git.kernel.org/pub/scm/linux/kernel/git/ras/ras.git edac-for-next patch link: https://lore.kernel.org/r/20240816164238.1902-2-shiju.jose%40huawei.com patch subject: [PATCH v11 01/14] EDAC: Add support for EDAC device feature's control config: i386-randconfig-062-20240818 (https://download.01.org/0day-ci/archive/20240819/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240819/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> drivers/edac/edac_device.c:584:26: sparse: sparse: symbol 'edac_dev_type' was not declared. Should it be static?
drivers/edac/edac_device.c: note: in included file (through include/linux/smp.h, include/linux/lockdep.h, include/linux/spinlock.h, ...):
include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true
vim +/edac_dev_type +584 drivers/edac/edac_device.c
583
> 584 const struct device_type edac_dev_type = { 585 .name = "edac_dev",
586 .release = edac_dev_release,
587 };
588
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Borislav Petkov
maintainerRe: [PATCH v11 01/14] EDAC: Add support for EDAC device feature's control
In reply to [email protected]Quoted 3 lines · On Fri, Aug 16, 2024 at 05:42:24PM +0100, [email protected] wrote:
From: Shiju Jose <[email protected]>
Add generic EDAC device feature's control supports registering
"features"
Check your whole set.
Quoted 2 lines
RAS features supported in the system. Driver exposes feature's control attributes to the userspace in
s/the //
Quoted 15 lines
/sys/bus/edac/devices/<dev-name>/<ras-feature>/
Co-developed-by Jonathan Cameron <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>Signed-off-by Shiju Jose <[email protected]>--- drivers/edac/edac_device.c | 178 +++++++++++++++++++++++++++++++++++++ include/linux/edac.h | 60 +++++++++++++ 2 files changed, 238 insertions(+)drivers/edac/edac_device.c +0
-0
drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, · line 578
Quoted 9 lines
drivers/edac/edac_device.c +6
-0@@ -570,3 +570,181 @@ void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, block ? block->name : "N/A", count, msg); }EXPORT_SYMBOL_GPL (edac_device_handle_ue_count); + +/* EDAC device feature */ +static void edac_dev_release (struct device *dev) +{ +struct edac_dev_feat_ctx *ctx = + container_of(dev, struct edac_dev_feat_ctx, dev);
Ew, no, don't do such silly linebreaks pls.
Quoted 6 lines
drivers/edac/edac_device.c +6
-0+kfree (ctx->dev.groups); +kfree (ctx); +} + +const struct device_type edac_dev_type = { + .name ="edac_dev" ,
drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, · line 595
Quoted 10 lines
drivers/edac/edac_device.c +10
-0+ .release = edac_dev_release, +}; + +static void edac_dev_unreg (void *data) +{ +device_unregister (data); +} + +/** +* edac_dev_feature_init - Init a ras feature
s/ras/RAS/g
Check your whole set.
drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, · line 597
Quoted 2 lines
drivers/edac/edac_device.c +2
-0+* @parent: client device. +* @dev_data: pointer to struct edac_dev_data.
I can see it is a pointer. What it is used for?
Quoted 24 lines
drivers/edac/edac_device.c +24
-0+* @feat: pointer to struct edac_dev_feature. +* @attr_groups: pointer to attribute group's container. +* +* Returns number of scrub feature's attribute groups on success, +* error otherwise. +*/ +static int edac_dev_feat_init (struct device *parent, +struct edac_dev_data *dev_data, +const struct edac_dev_feature *ras_feat, +const struct attribute_group **attr_groups) +{ +int num; + +switch (ras_feat->feat) { +case RAS_FEAT_SCRUB : + dev_data->scrub_ops = ras_feat->scrub_ops; + dev_data->private = ras_feat->scrub_ctx; +return 1 ; +case RAS_FEAT_ECS : + num = ras_feat->ecs_info.num_media_frus; + dev_data->ecs_ops = ras_feat->ecs_ops; + dev_data->private = ras_feat->ecs_ctx; +return num; +case RAS_FEAT_PPR :
drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, · line 631
Quoted 10 lines
drivers/edac/edac_device.c +10
-0+ dev_data->ppr_ops = ras_feat->ppr_ops; + dev_data->private = ras_feat->ppr_ctx; +return 1 ; +default : +return -EINVAL ; + } +} + +/** +* edac_dev_register - register device for ras features with edac
s/edac/EDAC/g
Check your whole set.
Quoted 14 lines
drivers/edac/edac_device.c +14
-0+* @parent: client device. +* @name: client device's name. +* @private: parent driver's data to store in the context if any. +* @num_features: number of ras features to register. +* @ras_features: list of ras features to register. +* +* Returns 0 on success, error otherwise. +* The new edac_dev_feat_ctx would be freed automatically. +*/ +int edac_dev_register (struct device *parent,char *name, +void *private,int num_features, +const struct edac_dev_feature *ras_features) +{ +const struct attribute_group **ras_attr_groups;
drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, · line 655
Quoted 10 lines
drivers/edac/edac_device.c +10
-0+struct edac_dev_data *dev_data; +struct edac_dev_feat_ctx *ctx; +int ppr_cnt =0 , ppr_inst =0 ; +int attr_gcnt =0 ; +int ret, feat; + +if (!parent || !name || !num_features || !ras_features) +return -EINVAL ; + +/* Double parse so we can make space for attributes */
Who's "we"?
Please use passive voice in your comments: no "we" or "I", etc.
Personal pronouns are ambiguous in text, especially with so many parties/companies/etc developing the kernel so let's avoid them please.
drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, · line 658
Quoted 3 lines
drivers/edac/edac_device.c +3
-0+for (feat =0 ; feat < num_features; feat++) { +switch (ras_features[feat].feat) { +case RAS_FEAT_SCRUB :
Does this need "fallthrough;" or somesuch?
Quoted 54 lines
drivers/edac/edac_device.c +54
-0+case RAS_FEAT_PPR : + attr_gcnt++; + ppr_cnt++; +break ; +case RAS_FEAT_ECS : + attr_gcnt += ras_features[feat].ecs_info.num_media_frus; +break ; +default : +return -EINVAL ; + } + } + + ctx =kzalloc (sizeof (*ctx),GFP_KERNEL ); +if (!ctx) +return -ENOMEM ; + + ctx->dev.parent = parent; + ctx->private = private; + + ras_attr_groups =kcalloc (attr_gcnt +1 ,sizeof (*ras_attr_groups),GFP_KERNEL ); +if (!ras_attr_groups) { + ret = -ENOMEM ; + goto ctx_free; + } + +if (ppr_cnt) { + ctx->ppr =kcalloc (ppr_cnt,sizeof (*(ctx->ppr)),GFP_KERNEL ); +if (!ctx->ppr) { + ret = -ENOMEM ; + goto groups_free; + } + } + + attr_gcnt =0 ; +for (feat =0 ; feat < num_features; feat++, ras_features++) { +switch (ras_features->feat) { +case RAS_FEAT_SCRUB : +if (!ras_features->scrub_ops) +continue ; + dev_data = &ctx->scrub; +break ; +case RAS_FEAT_ECS : +if (!ras_features->ecs_ops) +continue ; + dev_data = &ctx->ecs; +break ; +case RAS_FEAT_PPR : +if (!ras_features->ppr_ops) +continue ; + dev_data = &ctx->ppr[ppr_inst]; + dev_data->instance = ppr_inst; + ppr_inst++; +break ; +default :
drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, · line 722
Quoted 10 lines
drivers/edac/edac_device.c +10
-0+ ret = -EINVAL ; + goto data_mem_free; + } + ret =edac_dev_feat_init (parent, dev_data, ras_features, + &ras_attr_groups[attr_gcnt]); +if (ret <0 ) + goto data_mem_free; + + attr_gcnt += ret; + }
Newline.
drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, · line 727
Quoted 5 lines
drivers/edac/edac_device.c +5
-0+ ras_attr_groups[attr_gcnt] =NULL ; + ctx->dev.bus =edac_get_sysfs_subsys (); + ctx->dev.type = &edac_dev_type; + ctx->dev.groups = ras_attr_groups; +dev_set_drvdata (&ctx->dev, ctx);
Ditto.
Quoted 30 lines
drivers/edac/edac_device.c +23
-0+ ret =dev_set_name (&ctx->dev, name); +if (ret) + goto data_mem_free; + + ret =device_register (&ctx->dev); +if (ret) { +put_device (&ctx->dev); + goto data_mem_free; +return ret; + } + +return devm_add_action_or_reset (parent, edac_dev_unreg, &ctx->dev); + +data_mem_free: +if (ppr_cnt) +kfree (ctx->ppr); +groups_free: +kfree (ras_attr_groups); +ctx_free: +kfree (ctx); +return ret; +} +EXPORT_SYMBOL_GPL (edac_dev_register);include/linux/edac.h +0
-0@@ -661,4 +661,64 @@ static inline struct dimm_info *edac_get_dimm(struct mem_ctl_info *mci,return mci->dimms[index];
include/linux/edac.h static inline struct dimm_info *edac_get_dimm(struct mem_ctl_info *mci, · line 672
Quoted 10 lines
include/linux/edac.h +9
-0} + +/* EDAC device features */ + +#define EDAC_FEAT_NAME_LEN 128 + +enum edac_dev_feat { +RAS_FEAT_SCRUB , +RAS_FEAT_ECS , +RAS_FEAT_PPR ,
What are those? Comments ontop explaining pls.
Quoted 22 lines
include/linux/edac.h +22
-0+ RAS_FEAT_MAX +}; + +struct edac_ecs_ex_info { +u16 num_media_frus; +}; + +/* +* EDAC device feature information structure +*/ +struct edac_dev_data { +union { +const struct edac_scrub_ops *scrub_ops; +const struct edac_ecs_ops *ecs_ops; +const struct edac_ppr_ops *ppr_ops; + }; +u8 instance; +void *private; +}; + +struct device ; +
include/linux/edac.h static inline struct dimm_info *edac_get_dimm(struct mem_ctl_info *mci, · line 704
Quoted 10 lines
include/linux/edac.h +10
-0+struct edac_dev_feat_ctx { +struct device dev; +void *private; +struct edac_dev_data scrub; +struct edac_dev_data ecs; +struct edac_dev_data *ppr; +}; + +struct edac_dev_feature { +enum edac_dev_feat feat;
ft_type;
include/linux/edac.h static inline struct dimm_info *edac_get_dimm(struct mem_ctl_info *mci, · line 715
Quoted 11 lines
include/linux/edac.h +11
-0+u8 instance; +union { +const struct edac_scrub_ops *scrub_ops; +const struct edac_ecs_ops *ecs_ops; +const struct edac_ppr_ops *ppr_ops; + }; +union { +void *scrub_ctx; +void *ecs_ctx; +void *ppr_ctx; + };
Or drop the silly union and simply do
void *ctx;
include/linux/edac.h static inline struct dimm_info *edac_get_dimm(struct mem_ctl_info *mci, · line 718
Quoted 3 lines
include/linux/edac.h +3
-0+union { +struct edac_ecs_ex_info ecs_info; + };
Union with a single member?!
Quoted 9 lines
include/linux/edac.h +5
-0+}; + +int edac_dev_register (struct device *parent,char *dev_name, +void *parent_pvt_data,int num_features, +const struct edac_dev_feature *ras_features);#endif /* _LINUX_EDAC_H_ */ Signature · 1 line
2.34.1
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRE: [PATCH v11 01/14] EDAC: Add support for EDAC device feature's control
Thank you for the feedbacks.
Apologies for the delay in replying.
Quoted 25 lines
-----Original Message-----
From: Borislav Petkov <[email protected]>
Sent: 03 September 2024 17:35
To: Shiju Jose <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [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]; tanxiaofei <[email protected]>; Zengtao (B) <[email protected]>; Roberto Sassu <[email protected]>; [email protected]; wanghuiqiang <[email protected]>; Linuxarm <[email protected]>
Subject: Re: [PATCH v11 01/14] EDAC: Add support for EDAC device feature's control
Quoted 8 lines
Quoted 3 lines · On Fri, Aug 16, 2024 at 05:42:24PM +0100, [email protected] wrote:
From: Shiju Jose <[email protected]>
Add generic EDAC device feature's control supports registering
"features"
Check your whole set.
Sure. Modified.
Quoted 5 lines
Quoted 3 lines
RAS features supported in the system. Driver exposes feature's control attributes to the userspace in
s/the //
Changed.
Quoted 18 lines
Quoted 8 lines
/sys/bus/edac/devices/<dev-name>/<ras-feature>/
Co-developed-by Jonathan Cameron <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>Signed-off-by Shiju Jose <[email protected]>--- drivers/edac/edac_device.c | 178+++++++++++++++++++++++++++++++++++++
drivers/edac/edac_device.c void edac_device_handle_ue_count(struct
Quoted 8 lines
include/linux/edac.h | 60 +++++++++++++ 2 files changed, 238 insertions(+)drivers/edac/edac_device.c +0
-0@@ -570,3 +570,181 @@ void edac_device_handle_ue_count(struct
edac_device_ctl_info*edac_dev,
Quoted 9 lines
drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, · line 578
Quoted 7 lines
drivers/edac/edac_device.c +5
-0block ? block->name : "N/A", count, msg); }EXPORT_SYMBOL_GPL (edac_device_handle_ue_count); + +/* EDAC device feature */ +static void edac_dev_release (struct device *dev) { +struct edac_dev_feat_ctx *ctx = + container_of(dev, struct edac_dev_feat_ctx, dev);Ew, no, don't do such silly linebreaks pls.
Changed.
Quoted 19 lines
Quoted 6 lines
drivers/edac/edac_device.c +5
-0+kfree (ctx->dev.groups); +kfree (ctx); +} + +const struct device_type edac_dev_type = {drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, · line 595
Quoted 10 lines
drivers/edac/edac_device.c +10
-0+ .name = "edac_dev", + .release = edac_dev_release, +}; + +static void edac_dev_unreg (void *data) { +device_unregister (data); +} + +/** +* edac_dev_feature_init - Init a ras feature s/ras/RAS/g
Quoted 1 line
Check your whole set.
Sure. Modified.
Quoted 5 lines
drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, · line 597
Quoted 3 lines
drivers/edac/edac_device.c +2
-0+* @parent: client device. +* @dev_data: pointer to struct edac_dev_data. I can see it is a pointer. What it is used for?
Updated.
Quoted 37 lines
Quoted 24 lines
drivers/edac/edac_device.c +23
-0+* @feat: pointer to struct edac_dev_feature. +* @attr_groups: pointer to attribute group's container. +* +* Returns number of scrub feature's attribute groups on success, +* error otherwise. +*/ +static int edac_dev_feat_init (struct device *parent, +struct edac_dev_data *dev_data, +const struct edac_dev_feature *ras_feat, +const struct attribute_group **attr_groups) { +int num; + +switch (ras_feat->feat) { +case RAS_FEAT_SCRUB : + dev_data->scrub_ops = ras_feat->scrub_ops; + dev_data->private = ras_feat->scrub_ctx; +return 1 ; +case RAS_FEAT_ECS : + num = ras_feat->ecs_info.num_media_frus; + dev_data->ecs_ops = ras_feat->ecs_ops; + dev_data->private = ras_feat->ecs_ctx; +return num; +case RAS_FEAT_PPR :drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, · line 631
Quoted 10 lines
drivers/edac/edac_device.c +10
-0+ dev_data->ppr_ops = ras_feat->ppr_ops; + dev_data->private = ras_feat->ppr_ctx; +return 1 ; +default : +return -EINVAL ; + } +} + +/** +* edac_dev_register - register device for ras features with edac s/edac/EDAC/g
Quoted 1 line
Check your whole set.
Modified.
Quoted 27 lines
Quoted 14 lines
drivers/edac/edac_device.c +13
-0+* @parent: client device. +* @name: client device's name. +* @private: parent driver's data to store in the context if any. +* @num_features: number of ras features to register. +* @ras_features: list of ras features to register. +* +* Returns 0 on success, error otherwise. +* The new edac_dev_feat_ctx would be freed automatically. +*/ +int edac_dev_register (struct device *parent,char *name, +void *private,int num_features, +const struct edac_dev_feature *ras_features) { +const struct attribute_group **ras_attr_groups;drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, · line 655
Quoted 10 lines
drivers/edac/edac_device.c +10
-0+struct edac_dev_data *dev_data; +struct edac_dev_feat_ctx *ctx; +int ppr_cnt =0 , ppr_inst =0 ; +int attr_gcnt =0 ; +int ret, feat; + +if (!parent || !name || !num_features || !ras_features) +return -EINVAL ; + +/* Double parse so we can make space for attributes */ Who's "we"?
Quoted 1 line
Please use passive voice in your comments: no "we" or "I", etc.
Fixed.
Quoted 9 lines
Personal pronouns are ambiguous in text, especially with so many parties/companies/etc developing the kernel so let's avoid them please.
drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, · line 658
Quoted 3 lines
drivers/edac/edac_device.c +3
-0+for (feat =0 ; feat < num_features; feat++) { +switch (ras_features[feat].feat) { +case RAS_FEAT_SCRUB :Does this need "fallthrough;" or somesuch?
It is a bug, fixed.
Quoted 61 lines
drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev,
Quoted 7 lines
drivers/edac/edac_device.c +6
-0+case RAS_FEAT_PPR : + attr_gcnt++; + ppr_cnt++; +break ; +case RAS_FEAT_ECS : + attr_gcnt +=ras_features[feat].ecs_info.num_media_frus;
Quoted 4 lines
drivers/edac/edac_device.c +4
-0+break ; +default : +return -EINVAL ; + }drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev,
Quoted 10 lines
drivers/edac/edac_device.c +10
-0+ } + + ctx =kzalloc (sizeof (*ctx),GFP_KERNEL ); +if (!ctx) +return -ENOMEM ; + + ctx->dev.parent = parent; + ctx->private = private; + + ras_attr_groups = kcalloc(attr_gcnt + 1, sizeof(*ras_attr_groups),
GFP_KERNEL);Quoted 38 lines
drivers/edac/edac_device.c +38
-0+if (!ras_attr_groups) { + ret = -ENOMEM ; + goto ctx_free; + } + +if (ppr_cnt) { + ctx->ppr =kcalloc (ppr_cnt,sizeof (*(ctx->ppr)),GFP_KERNEL ); +if (!ctx->ppr) { + ret = -ENOMEM ; + goto groups_free; + } + } + + attr_gcnt =0 ; +for (feat =0 ; feat < num_features; feat++, ras_features++) { +switch (ras_features->feat) { +case RAS_FEAT_SCRUB : +if (!ras_features->scrub_ops) +continue ; + dev_data = &ctx->scrub; +break ; +case RAS_FEAT_ECS : +if (!ras_features->ecs_ops) +continue ; + dev_data = &ctx->ecs; +break ; +case RAS_FEAT_PPR : +if (!ras_features->ppr_ops) +continue ; + dev_data = &ctx->ppr[ppr_inst]; + dev_data->instance = ppr_inst; + ppr_inst++; +break ; +default : + ret = -EINVAL ; + goto data_mem_free; + } + ret = edac_dev_feat_init(parent, dev_data, ras_features,
Quoted 8 lines
drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, · line 722
Quoted 6 lines
drivers/edac/edac_device.c +6
-0+ &ras_attr_groups[attr_gcnt]); +if (ret <0 ) + goto data_mem_free; + + attr_gcnt += ret; + }Newline.
Added newline.
Quoted 8 lines
drivers/edac/edac_device.c void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev, · line 727
Quoted 6 lines
drivers/edac/edac_device.c +5
-0+ ras_attr_groups[attr_gcnt] =NULL ; + ctx->dev.bus =edac_get_sysfs_subsys (); + ctx->dev.type = &edac_dev_type; + ctx->dev.groups = ras_attr_groups; +dev_set_drvdata (&ctx->dev, ctx);Ditto.
Added newline.
Quoted 31 lines
Quoted 31 lines
drivers/edac/edac_device.c +23
-0+ ret =dev_set_name (&ctx->dev, name); +if (ret) + goto data_mem_free; + + ret =device_register (&ctx->dev); +if (ret) { +put_device (&ctx->dev); + goto data_mem_free; +return ret; + } + +return devm_add_action_or_reset (parent, edac_dev_unreg, &ctx->dev); + +data_mem_free: +if (ppr_cnt) +kfree (ctx->ppr); +groups_free: +kfree (ras_attr_groups); +ctx_free: +kfree (ctx); +return ret; +} +EXPORT_SYMBOL_GPL (edac_dev_register);include/linux/edac.h index renamed from include/linux/edac.h +0
-0
b4ee8961e623..cc96f55ac714100644include/linux/edac.h +0
-0@@ -661,4 +661,64 @@ static inline struct dimm_info *edac_get_dimm(struct mem_ctl_info *mci,
Quoted 13 lines
include/linux/edac.h static inline struct dimm_info *edac_get_dimm(struct mem_ctl_info *mci, · line 672
Quoted 11 lines
include/linux/edac.h +9
-0return mci->dimms[index]; } + +/* EDAC device features */ + +#define EDAC_FEAT_NAME_LEN 128 + +enum edac_dev_feat { +RAS_FEAT_SCRUB , +RAS_FEAT_ECS , +RAS_FEAT_PPR ,What are those? Comments ontop explaining pls.
Added comments.
Quoted 26 lines
Quoted 26 lines
include/linux/edac.h +25
-0+RAS_FEAT_MAX +}; + +struct edac_ecs_ex_info { +u16 num_media_frus; +}; + +/* +* EDAC device feature information structure */ struct edac_dev_data +{ +union { +const struct edac_scrub_ops *scrub_ops; +const struct edac_ecs_ops *ecs_ops; +const struct edac_ppr_ops *ppr_ops; + }; +u8 instance; +void *private; +}; + +struct device ; + +struct edac_dev_feat_ctx { +struct device dev; +void *private; +struct edac_dev_data scrub;
Quoted 8 lines
include/linux/edac.h static inline struct dimm_info *edac_get_dimm(struct mem_ctl_info *mci, · line 704
Quoted 6 lines
include/linux/edac.h +6
-0+struct edac_dev_data ecs; +struct edac_dev_data *ppr; +}; + +struct edac_dev_feature { +enum edac_dev_feat feat;ft_type;
Sure. Changed.
Quoted 15 lines
include/linux/edac.h static inline struct dimm_info *edac_get_dimm(struct mem_ctl_info *mci, · line 715
Quoted 12 lines
include/linux/edac.h +11
-0+u8 instance; +union { +const struct edac_scrub_ops *scrub_ops; +const struct edac_ecs_ops *ecs_ops; +const struct edac_ppr_ops *ppr_ops; + }; +union { +void *scrub_ctx; +void *ecs_ctx; +void *ppr_ctx; + };Or drop the silly union and simply do
Quoted 1 line
void *ctx;
Modified.
Quoted 6 lines
include/linux/edac.h static inline struct dimm_info *edac_get_dimm(struct mem_ctl_info *mci, · line 718
Quoted 4 lines
include/linux/edac.h +3
-0+union { +struct edac_ecs_ex_info ecs_info; + };Union with a single member?!
Removed Union.
Quoted 15 lines
Quoted 10 lines
include/linux/edac.h +5
-1+}; + +int edac_dev_register (struct device *parent,char *dev_name, +void *parent_pvt_data,int num_features, +const struct edac_dev_feature *ras_features);#endif /* _LINUX_EDAC_H_ */ --2.34.1
--
Regards/Gruss,
Boris.
Thanks,
Shiju
PATCH v11 2/14 EDAC: Add EDAC scrub control driver
In reply to [email protected]From: Shiju Jose <[email protected]>
Add generic EDAC scrub control driver supports configuring the memory scrubbers in the system. The device with scrub feature, get the scrub descriptor from the EDAC scrub and registers with the EDAC RAS feature driver, which adds the sysfs scrub control interface. The scrub control attributes are available to the userspace in /sys/bus/edac/devices/<dev-name>/scrub/.
Generic EDAC scrub driver and the common sysfs scrub interface promotes unambiguous access from the userspace irrespective of the underlying scrub devices.
The sysfs scrub attribute nodes would be present only if the client driver has implemented the corresponding attribute callback function and pass in ops to the EDAC RAS feature driver during registration.
Question: Does EDAC scrub control driver need supporting multiple scrub instances per device like EDAC ECS and EDAC PPR?
--- Documentation/ABI/testing/sysfs-edac-scrub | 69 +++++ drivers/edac/Makefile | 1 + drivers/edac/edac_device.c | 1 + drivers/edac/edac_scrub.c | 315 +++++++++++++++++++++ include/linux/edac.h | 28 ++ 5 files changed, 414 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-edac-scrub create mode 100755 drivers/edac/edac_scrub.c
Documentation/ABI/testing/sysfs-edac-scrub new file +69 -0
@@ -0,0 +1,69 @@ +What: /sys/bus/edac/devices/<dev-name>/scrub +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + The sysfs edac bus devices /<dev-name>/scrub subdirectory + belongs to the memory scrub control feature, where <dev-name> + directory corresponds to a device/memory region registered + with the edac scrub driver and thus registered with the + generic edac ras driver too. + The sysfs scrub attr nodes would be present only if the + client driver has implemented the corresponding attr + callback function and pass in ops to the EDAC RAS feature + driver during registration. + +What: /sys/bus/edac/devices/<dev-name>/scrub/addr_range_base +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (RW) The base of the address range of the memory region + to be scrubbed (on-demand scrubbing). + +What: /sys/bus/edac/devices/<dev-name>/scrub/addr_range_size +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (RW) The size of the address range of the memory region + to be scrubbed (on-demand scrubbing). + +What: /sys/bus/edac/devices/<dev-name>/scrub/enable_background +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (RW) Start/Stop background(patrol) scrubbing if supported. + +What: /sys/bus/edac/devices/<dev-name>/scrub/enable_on_demand +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (RW) Start/Stop on-demand scrubbing the memory region + if supported. + +What: /sys/bus/edac/devices/<dev-name>/scrub/min_cycle_duration +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (RO) Supported minimum scrub cycle duration in seconds + by the memory scrubber. + +What: /sys/bus/edac/devices/<dev-name>/scrub/max_cycle_duration +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (RO) Supported maximum scrub cycle duration in seconds + by the memory scrubber. + +What: /sys/bus/edac/devices/<dev-name>/scrub/current_cycle_duration +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (RW) The current scrub cycle duration in seconds and must be + within the supported range by the memory scrubber.
drivers/edac/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_EDAC) := edac_core.o edac_core-y := edac_mc.o edac_device.o edac_mc_sysfs.o edac_core-y += edac_module.o edac_device_sysfs.o wq.o +edac_core-y += edac_scrub.o edac_core-$(CONFIG_EDAC_DEBUG) += debugfs.o
drivers/edac/edac_device.c +1 -0
@@ -612,6 +612,7 @@ static int edac_dev_feat_init(struct device *parent,case RAS_FEAT_SCRUB : dev_data->scrub_ops = ras_feat->scrub_ops; dev_data->private = ras_feat->scrub_ctx; + attr_groups[0 ] =edac_scrub_get_desc ();return 1 ;case RAS_FEAT_ECS : num = ras_feat->ecs_info.num_media_frus;
drivers/edac/edac_scrub.c new file +315 -0
315 lines not on this page · raw message
include/linux/edac.h +28 -0
@@ -673,6 +673,34 @@ enum edac_dev_feat {RAS_FEAT_MAX }; +/** +* struct scrub_ops - scrub device operations (all elements optional) +* @read_range: read base and offset of scrubbing range. +* @write_range: set the base and offset of the scrubbing range. +* @get_enabled_bg: check if currently performing background scrub. +* @set_enabled_bg: start or stop a bg-scrub. +* @get_enabled_od: check if currently performing on-demand scrub. +* @set_enabled_od: start or stop an on-demand scrub. +* @min_cycle_read: minimum supported scrub cycle duration in seconds. +* @max_cycle_read: maximum supported scrub cycle duration in seconds. +* @cycle_duration_read: get the scrub cycle duration in seconds. +* @cycle_duration_write: set the scrub cycle duration in seconds. +*/ +struct edac_scrub_ops { +int (*read_range)(struct device *dev,void *drv_data,u64 *base,u64 *size); +int (*write_range)(struct device *dev,void *drv_data,u64 base,u64 size); +int (*get_enabled_bg)(struct device *dev,void *drv_data,bool *enable); +int (*set_enabled_bg)(struct device *dev,void *drv_data,bool enable); +int (*get_enabled_od)(struct device *dev,void *drv_data,bool *enable); +int (*set_enabled_od)(struct device *dev,void *drv_data,bool enable); +int (*min_cycle_read)(struct device *dev,void *drv_data,u32 *min); +int (*max_cycle_read)(struct device *dev,void *drv_data,u32 *max); +int (*cycle_duration_read)(struct device *dev,void *drv_data,u32 *cycle); +int (*cycle_duration_write)(struct device *dev,void *drv_data,u32 cycle); +}; + +const struct attribute_group *edac_scrub_get_desc (void ); +struct edac_ecs_ex_info {u16 num_media_frus; };
Signature · 1 line
2.34.1
PATCH v11 3/14 EDAC: Add EDAC ECS control driver
In reply to [email protected]From: Shiju Jose <[email protected]>
Add EDAC ECS (Error Check Scrub) control driver supports configuring the memory device's ECS 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 DDR5 device contains number of memory media FRUs per device. The DDR5 ECS feature and thus the ECS control driver supports configuring the ECS parameters per FRU.
The memory devices support ECS feature register with the EDAC ECS driver and thus with the generic EDAC RAS feature driver, which adds the sysfs ECS control interface. The ECS control attributes are exposed to the userspace in /sys/bus/edac/devices/<dev-name>/ecs_fruX/.
Generic EDAC ECS driver and the common sysfs ECS interface promotes unambiguous control from the userspace irrespective of the underlying devices, support ECS feature.
The support for ECS feature is added separately because the DDR5 ECS feature's control attributes are dissimilar from those of the scrub feature.
The sysfs ECS attr nodes would be present only if the client driver has implemented the corresponding attr callback function and pass in ops to the EDAC RAS feature driver during registration.
--- Documentation/ABI/testing/sysfs-edac-ecs | 78 +++++ drivers/edac/Makefile | 2 +- drivers/edac/edac_device.c | 4 + drivers/edac/edac_ecs.c | 376 +++++++++++++++++++++++ include/linux/edac.h | 34 ++ 5 files changed, 493 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-edac-ecs create mode 100755 drivers/edac/edac_ecs.c
Documentation/ABI/testing/sysfs-edac-ecs new file +78 -0
@@ -0,0 +1,78 @@ +What: /sys/bus/edac/devices/<dev-name>/ecs_fru* +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + The sysfs edac bus devices /<dev-name>/ecs_fru* subdirectory + belongs to the memory media ECS (Error Check Scrub) control + feature, where <dev-name> directory corresponds to a device + registered with the EDAC ECS driver and thus registered with + the generic edac ras driver too. + /ecs_fru* belongs to the media FRUs (Field replaceable unit) + under the memory device. + The sysfs ECS attr nodes would be present only if the client + driver has implemented the corresponding attr callback + function and pass in ops to the EDAC RAS feature driver + during registration. + +What: /sys/bus/edac/devices/<dev-name>/ecs_fru*/log_entry_type +Date: Oct 2024 +KernelVersion: 6.12 +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/bus/edac/devices/<dev-name>/ecs_fru*/log_entry_type_per_dram +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (RO) True if current log entry type is per DRAM. + +What: /sys/bus/edac/devices/<dev-name>/ecs_fru*/log_entry_type_per_memory_media +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (RO) True if current log entry type is per memory media FRU. + +What: /sys/bus/edac/devices/<dev-name>/ecs_fru*/mode +Date: Oct 2024 +KernelVersion: 6.12 +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/bus/edac/devices/<dev-name>/ecs_fru*/mode_counts_rows +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (RO) True if current mode is ECS counts rows with errors. + +What: /sys/bus/edac/devices/<dev-name>/ecs_fru*/mode_counts_codewords +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (RO) True if current mode is ECS counts codewords with errors. + +What: /sys/bus/edac/devices/<dev-name>/ecs_fru*/reset +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (WO) ECS reset ECC counter. + 0 - normal, ECC counter running actively. + 1 - reset ECC counter to the default value. + +What: /sys/bus/edac/devices/<dev-name>/ecs_fru*/threshold +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (RW) ECS threshold count per GB of memory cells.
drivers/edac/Makefile +1 -1
@@ -10,7 +10,7 @@ obj-$(CONFIG_EDAC) := edac_core.o edac_core-y := edac_mc.o edac_device.o edac_mc_sysfs.o edac_core-y += edac_module.o edac_device_sysfs.o wq.o -edac_core-y += edac_scrub.o +edac_core-y += edac_scrub.o edac_ecs.o edac_core-$(CONFIG_EDAC_DEBUG) += debugfs.o
drivers/edac/edac_device.c +4 -0
@@ -606,6 +606,7 @@ static int edac_dev_feat_init(struct device *parent,const struct edac_dev_feature *ras_feat, const struct attribute_group **attr_groups) { + int ret;int num;switch (ras_feat->feat) {
@@ -618,6 +619,9 @@ static int edac_dev_feat_init(struct device *parent, num = ras_feat->ecs_info.num_media_frus; dev_data->ecs_ops = ras_feat->ecs_ops; dev_data->private = ras_feat->ecs_ctx; + ret =edac_ecs_get_desc (parent, attr_groups, num); +if (ret) +return ret;return num;case RAS_FEAT_PPR : dev_data->ppr_ops = ras_feat->ppr_ops;
drivers/edac/edac_ecs.c new file +376 -0
376 lines not on this page · raw message
include/linux/edac.h +34 -0
@@ -701,10 +701,44 @@ struct edac_scrub_ops {const struct attribute_group *edac_scrub_get_desc (void ); +/** +* struct ecs_ops - ECS device operations (all elements optional) +* @get_log_entry_type: read the log entry type value. +* @set_log_entry_type: set the log entry type value. +* @get_log_entry_type_per_dram: read the log entry type per dram value. +* @get_log_entry_type_memory_media: read the log entry type per memory media value. +* @get_mode: read the mode value. +* @set_mode: set the mode value. +* @get_mode_counts_rows: read the mode counts rows value. +* @get_mode_counts_codewords: read the mode counts codewords value. +* @reset: reset the ECS counter. +* @get_threshold: read the threshold value. +* @set_threshold: set the threshold value. +*/ +struct edac_ecs_ops { +int (*get_log_entry_type)(struct device *dev,void *drv_data,int fru_id,u32 *val); +int (*set_log_entry_type)(struct device *dev,void *drv_data,int fru_id,u32 val); +int (*get_log_entry_type_per_dram)(struct device *dev,void *drv_data, +int fru_id,u32 *val); +int (*get_log_entry_type_per_memory_media)(struct device *dev,void *drv_data, +int fru_id,u32 *val); +int (*get_mode)(struct device *dev,void *drv_data,int fru_id,u32 *val); +int (*set_mode)(struct device *dev,void *drv_data,int fru_id,u32 val); +int (*get_mode_counts_rows)(struct device *dev,void *drv_data,int fru_id,u32 *val); +int (*get_mode_counts_codewords)(struct device *dev,void *drv_data,int fru_id,u32 *val); +int (*reset)(struct device *dev,void *drv_data,int fru_id,u32 val); +int (*get_threshold)(struct device *dev,void *drv_data,int fru_id,u32 *threshold); +int (*set_threshold)(struct device *dev,void *drv_data,int fru_id,u32 threshold); +}; +struct edac_ecs_ex_info {u16 num_media_frus; }; +int edac_ecs_get_desc (struct device *ecs_dev, +const struct attribute_group **attr_groups, +u16 num_media_frus); +/* * EDAC device feature information structure */
Signature · 1 line
2.34.1
PATCH v11 4/14 cxl/mbox: Add GET_SUPPORTED_FEATURES mailbox command
In reply to [email protected]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 support features with changeable attributes.
CXL spec 3.1 section 8.2.9.6.1 describes Get Supported features command. 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 | 68 +++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 63 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+)
drivers/cxl/core/mbox.c +68 -0
@@ -1324,6 +1324,74 @@ 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_get_supported_feature_entry (struct cxl_memdev_state *mds,const uuid_t *feat_uuid, +struct cxl_mbox_supp_feat_entry *feat_entry_out) +{ +struct cxl_mbox_supp_feat_entry *feat_entry; +int feat_index, feats_out_size; +int nentries, count; +int ret; + + feat_index =0 ; + feats_out_size =sizeof (struct cxl_mbox_get_supp_feats_out ) + +sizeof (struct cxl_mbox_supp_feat_entry ); + struct cxl_mbox_get_supp_feats_out *feats_out __free(kfree) = +kmalloc (feats_out_size,GFP_KERNEL ); +if (!feats_out) +return -ENOMEM ; + +while (true) { +memset (feats_out,0 , feats_out_size); + ret =cxl_get_supported_features (mds, feats_out_size, + feat_index, feats_out); +if (ret) +return ret; + + nentries = feats_out->nr_entries; +if (!nentries) +return -EOPNOTSUPP ; + +/* Check CXL memdev supports the feature */ + feat_entry = feats_out->feat_entries; +for (count =0 ; count < nentries; count++, feat_entry++) { +if (uuid_equal (&feat_entry->uuid, feat_uuid)) { +memcpy (feat_entry_out, feat_entry, +sizeof (*feat_entry_out)); +return 0 ; + } + } + feat_index += nentries; + } +} +EXPORT_SYMBOL_NS_GPL (cxl_get_supported_feature_entry,CXL ); +int cxl_mem_get_poison (struct cxl_memdev *cxlmd,u64 offset,u64 len,struct cxl_region *cxlr) {
drivers/cxl/cxlmem.h +63 -0
81 lines not on this page · raw message
Signature · 1 line
2.34.1
kernel test robot
build botRe: [PATCH v11 04/14] cxl/mbox: Add GET_SUPPORTED_FEATURES mailbox command
kernel test robot noticed the following build warnings:
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on ras/edac-for-next]
[also build test WARNING on rafael-pm/linux-next rafael-pm/bleeding-edge cxl/next linus/master v6.11-rc3 next-20240816] [cannot apply to cxl/pending]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/shiju-jose-huawei-com/EDAC-Add-support-for-EDAC-device-feature-s-control/20240817-004442 base: https://git.kernel.org/pub/scm/linux/kernel/git/ras/ras.git edac-for-next patch link: https://lore.kernel.org/r/20240816164238.1902-5-shiju.jose%40huawei.com patch subject: [PATCH v11 04/14] cxl/mbox: Add GET_SUPPORTED_FEATURES mailbox command config: alpha-randconfig-r131-20240818 (https://download.01.org/0day-ci/archive/20240819/[email protected]/config) compiler: alpha-linux-gcc (GCC) 13.3.0 reproduce: (https://download.01.org/0day-ci/archive/20240819/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> drivers/cxl/core/mbox.c:1377:26: sparse: sparse: incorrect type in assignment (different base types) @@ expected int nentries @@ got restricted __le16 [usertype] nr_entries @@
drivers/cxl/core/mbox.c:1377:26: sparse: expected int nentries
drivers/cxl/core/mbox.c:1377:26: sparse: got restricted __le16 [usertype] nr_entries
vim +1377 drivers/cxl/core/mbox.c
1353
1354 int cxl_get_supported_feature_entry(struct cxl_memdev_state *mds, const uuid_t *feat_uuid,
1355 struct cxl_mbox_supp_feat_entry *feat_entry_out)
1356 {
1357 struct cxl_mbox_supp_feat_entry *feat_entry;
1358 int feat_index, feats_out_size;
1359 int nentries, count;
1360 int ret;
1361
1362 feat_index = 0;
1363 feats_out_size = sizeof(struct cxl_mbox_get_supp_feats_out) +
1364 sizeof(struct cxl_mbox_supp_feat_entry);
1365 struct cxl_mbox_get_supp_feats_out *feats_out __free(kfree) =
1366 kmalloc(feats_out_size, GFP_KERNEL);
1367 if (!feats_out)
1368 return -ENOMEM;
1369
1370 while (true) {
1371 memset(feats_out, 0, feats_out_size);
1372 ret = cxl_get_supported_features(mds, feats_out_size,
1373 feat_index, feats_out);
1374 if (ret)
1375 return ret;
1376
> 1377 nentries = feats_out->nr_entries;
1378 if (!nentries)
1379 return -EOPNOTSUPP;
1380
1381 /* Check CXL memdev supports the feature */
1382 feat_entry = feats_out->feat_entries;
1383 for (count = 0; count < nentries; count++, feat_entry++) {
1384 if (uuid_equal(&feat_entry->uuid, feat_uuid)) {
1385 memcpy(feat_entry_out, feat_entry,
1386 sizeof(*feat_entry_out));
1387 return 0;
1388 }
1389 }
1390 feat_index += nentries;
1391 }
1392 }
1393 EXPORT_SYMBOL_NS_GPL(cxl_get_supported_feature_entry, CXL);
1394
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Dave Jiang
maintainerRe: [PATCH v11 04/14] cxl/mbox: Add GET_SUPPORTED_FEATURES mailbox command
In reply to [email protected]Quoted 45 lines · On 8/16/24 9:42 AM, [email protected] wrote:
From: Shiju Jose <[email protected]>
Add support for
GET_SUPPORTED_FEATURESmailbox command.CXL spec 3.1 section 8.2.9.6 describes optional device specific features. CXL devices support features with changeable attributes.
CXL spec 3.1 section 8.2.9.6.1 describes Get Supported features command. 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.
Signed-off-by Shiju Jose <[email protected]>--- drivers/cxl/core/mbox.c | 68 +++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 63 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+)drivers/cxl/core/mbox.c +19
-0@@ -1324,6 +1324,74 @@ 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), + };
drivers/cxl/core/mbox.c int cxl_set_timestamp(struct cxl_memdev_state *mds) · line 1355
Quoted 10 lines
drivers/cxl/core/mbox.c +10
-0+ 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_get_supported_feature_entry (struct cxl_memdev_state *mds,const uuid_t *feat_uuid, +struct cxl_mbox_supp_feat_entry *feat_entry_out)
Hi Shiju,
thoughts on storing all the supported features meta info from GET_SUPPORTED_FEATURES command in the cxl core driver during device enumeration and the CXL EDAC code can just query the core instead of reading from the device? Just looking forward to supporting other read/set features operations in the future and avoiding going through this entire read and find routine for each feature.
DJ
Quoted 130 lines
drivers/cxl/core/mbox.c +39
-0+{ +struct cxl_mbox_supp_feat_entry *feat_entry; +int feat_index, feats_out_size; +int nentries, count; +int ret; + + feat_index =0 ; + feats_out_size =sizeof (struct cxl_mbox_get_supp_feats_out ) + +sizeof (struct cxl_mbox_supp_feat_entry ); + struct cxl_mbox_get_supp_feats_out *feats_out __free(kfree) = +kmalloc (feats_out_size,GFP_KERNEL ); +if (!feats_out) +return -ENOMEM ; + +while (true) { +memset (feats_out,0 , feats_out_size); + ret =cxl_get_supported_features (mds, feats_out_size, + feat_index, feats_out); +if (ret) +return ret; + + nentries = feats_out->nr_entries; +if (!nentries) +return -EOPNOTSUPP ; + +/* Check CXL memdev supports the feature */ + feat_entry = feats_out->feat_entries; +for (count =0 ; count < nentries; count++, feat_entry++) { +if (uuid_equal (&feat_entry->uuid, feat_uuid)) { +memcpy (feat_entry_out, feat_entry, +sizeof (*feat_entry_out)); +return 0 ; + } + } + feat_index += nentries; + } +} +EXPORT_SYMBOL_NS_GPL (cxl_get_supported_feature_entry,CXL ); +int cxl_mem_get_poison (struct cxl_memdev *cxlmd,u64 offset,u64 len,struct cxl_region *cxlr) {drivers/cxl/cxlmem.h +63
-0@@ -531,6 +531,7 @@ enum cxl_opcode {CXL_MBOX_OP_GET_LOG_CAPS =0x0402 ,CXL_MBOX_OP_CLEAR_LOG =0x0403 ,CXL_MBOX_OP_GET_SUP_LOG_SUBLIST =0x0405 , +CXL_MBOX_OP_GET_SUPPORTED_FEATURES =0x0500 ,CXL_MBOX_OP_IDENTIFY =0x4000 ,CXL_MBOX_OP_GET_PARTITION_INFO =0x4100 , CXL_MBOX_OP_SET_PARTITION_INFO = 0x4101,@@ -700,6 +701,63 @@ struct cxl_mbox_set_timestamp_in { } __packed; +/* +* Get Supported Features CXL 3.1 Spec 8.2.9.6.1 +*/ + +/* +* Get Supported Features input payload +* CXL rev 3.1 section 8.2.9.6.1 Table 8-95 +*/ +struct cxl_mbox_get_supp_feats_in { +__le32 count; +__le16 start_index; +u8 rsvd[2 ]; +} __packed; + +/* +* Get Supported Features Supported Feature Entry +* CXL rev 3.1 section 8.2.9.6.1 Table 8-97 +*/ +/* Supported Feature Entry : Payload out attribute flags */ +#define CXL_FEAT_ENTRY_FLAG_CHANGABLE BIT(0) +#define CXL_FEAT_ENTRY_FLAG_DEEPEST_RESET_PERSISTENCE_MASK GENMASK(3, 1) +#define CXL_FEAT_ENTRY_FLAG_PERSIST_ACROSS_FIRMWARE_UPDATE BIT(4) +#define CXL_FEAT_ENTRY_FLAG_SUPPORT_DEFAULT_SELECTION BIT(5) +#define CXL_FEAT_ENTRY_FLAG_SUPPORT_SAVED_SELECTION BIT(6) + +enum cxl_feat_attr_value_persistence { +CXL_FEAT_ATTR_VALUE_PERSISTENCE_NONE , +CXL_FEAT_ATTR_VALUE_PERSISTENCE_CXL_RESET , +CXL_FEAT_ATTR_VALUE_PERSISTENCE_HOT_RESET , +CXL_FEAT_ATTR_VALUE_PERSISTENCE_WARM_RESET , +CXL_FEAT_ATTR_VALUE_PERSISTENCE_COLD_RESET , +CXL_FEAT_ATTR_VALUE_PERSISTENCE_MAX +}; + +struct cxl_mbox_supp_feat_entry { +uuid_t uuid; +__le16 index; +__le16 get_size; +__le16 set_size; +__le32 attr_flags; +u8 get_version; +u8 set_version; +__le16 set_effects; +u8 rsvd[18 ]; +} __packed; + +/* +* Get Supported Features output payload +* CXL rev 3.1 section 8.2.9.6.1 Table 8-96 +*/ +struct cxl_mbox_get_supp_feats_out { +__le16 nr_entries; +__le16 nr_supported; +u8 rsvd[4 ]; +struct cxl_mbox_supp_feat_entry feat_entries[]; +} __packed; +/* Get Poison List CXL 3.0 Spec 8.2.9.8.4.1 */ struct cxl_mbox_poison_in {__le64 offset;@@ -831,6 +889,11 @@ void cxl_event_trace_record(const struct cxl_memdev *cxlmd,enum cxl_event_type event_type, const uuid_t *uuid, union cxl_event *evt);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); +int cxl_get_supported_feature_entry (struct cxl_memdev_state *mds,const uuid_t *feat_uuid, +struct cxl_mbox_supp_feat_entry *feat_entry_out);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);
RE: [PATCH v11 04/14] cxl/mbox: Add GET_SUPPORTED_FEATURES mailbox command
Hi Dave,
Quoted 85 lines
-----Original Message-----
From: Dave Jiang <[email protected]>
Sent: 20 August 2024 23:46
To: Shiju Jose <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; linux- [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [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]; tanxiaofei <[email protected]>; Zengtao (B) <[email protected]>; Roberto Sassu <[email protected]>; [email protected]; wanghuiqiang <[email protected]>; Linuxarm <[email protected]>
Subject: Re: [PATCH v11 04/14] cxl/mbox: AddGET_SUPPORTED_FEATURESmailbox commandQuoted 7 lines · On 8/16/24 9:42 AM, [email protected] wrote:
From: Shiju Jose <[email protected]>
Add support for
GET_SUPPORTED_FEATURESmailbox command.CXL spec 3.1 section 8.2.9.6 describes optional device specific features. CXL devices support features with changeable attributes.
Quoted 8 lines
CXL spec 3.1 section 8.2.9.6.1 describes Get Supported features command. 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.
Signed-off-by Shiju Jose <[email protected]>--- drivers/cxl/core/mbox.c | 68+++++++++++++++++++++++++++++++++++++++++
Quoted 27 lines
drivers/cxl/cxlmem.h | 63 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+)drivers/cxl/core/mbox.c index renamed from drivers/cxl/core/mbox.c +0
-0
2626f3fff201..760fa3e1075f100644drivers/cxl/core/mbox.c +17
-0@@ -1324,6 +1324,74 @@ 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),drivers/cxl/core/mbox.c int cxl_set_timestamp(struct cxl_memdev_state · line 1352
Quoted 10 lines
drivers/cxl/core/mbox.c +10
-0+ }; + 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_get_supported_feature_entry(struct cxl_memdev_state *mds, const
uuid_t*feat_uuid,drivers/cxl/core/mbox.c int cxl_set_timestamp(struct cxl_memdev_state · line 1353
Quoted 1 line
drivers/cxl/core/mbox.c +1
-0+struct cxl_mbox_supp_feat_entry
*feat_entry_out)
Quoted 7 lines
Hi Shiju,
thoughts on storing all the supported features meta info fromGET_SUPPORTED_FEATUREScommand in the cxl core driver during device enumeration and the CXL EDAC code can just query the core instead of reading from the device? Just looking forward to supporting other read/set features operations in the future and avoiding going through this entire read and find routine for each feature.
Thanks for the suggestion.
I saw you have implementation for storing all the supported features meta info from GET_SUPPORTED_FEATURES command here.
https://patchwork.kernel.org/project/cxl/patch/[email protected]/
I am fine basing on it if this patch is ready to go?
Quoted 2 lines
DJ
Thanks,
Shiju
Quoted 132 lines
Quoted 67 lines
drivers/cxl/core/mbox.c +39
-0+{ +struct cxl_mbox_supp_feat_entry *feat_entry; +int feat_index, feats_out_size; +int nentries, count; +int ret; + + feat_index =0 ; + feats_out_size =sizeof (struct cxl_mbox_get_supp_feats_out ) + +sizeof (struct cxl_mbox_supp_feat_entry ); + struct cxl_mbox_get_supp_feats_out *feats_out __free(kfree) = +kmalloc (feats_out_size,GFP_KERNEL ); +if (!feats_out) +return -ENOMEM ; + +while (true) { +memset (feats_out,0 , feats_out_size); + ret =cxl_get_supported_features (mds, feats_out_size, + feat_index, feats_out); +if (ret) +return ret; + + nentries = feats_out->nr_entries; +if (!nentries) +return -EOPNOTSUPP ; + +/* Check CXL memdev supports the feature */ + feat_entry = feats_out->feat_entries; +for (count =0 ; count < nentries; count++, feat_entry++) { +if (uuid_equal (&feat_entry->uuid, feat_uuid)) { +memcpy (feat_entry_out, feat_entry, +sizeof (*feat_entry_out)); +return 0 ; + } + } + feat_index += nentries; + } +} +EXPORT_SYMBOL_NS_GPL (cxl_get_supported_feature_entry,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
af8169ccdbc0..9939c771f642100644drivers/cxl/cxlmem.h +9
-0@@ -531,6 +531,7 @@ enum cxl_opcode {CXL_MBOX_OP_GET_LOG_CAPS =0x0402 ,CXL_MBOX_OP_CLEAR_LOG =0x0403 ,CXL_MBOX_OP_GET_SUP_LOG_SUBLIST =0x0405 , +CXL_MBOX_OP_GET_SUPPORTED_FEATURES =0x0500 ,CXL_MBOX_OP_IDENTIFY =0x4000 ,CXL_MBOX_OP_GET_PARTITION_INFO =0x4100 , CXL_MBOX_OP_SET_PARTITION_INFO = 0x4101,@@ -700,6 +701,63 @@ struct cxl_mbox_set_timestamp_in { } __packed; +/* +* Get Supported Features CXL 3.1 Spec 8.2.9.6.1 */ + +/* +* Get Supported Features input payload +* CXL rev 3.1 section 8.2.9.6.1 Table 8-95 */ struct +cxl_mbox_get_supp_feats_in { +__le32 count;drivers/cxl/cxlmem.h struct cxl_mbox_set_timestamp_in { · line 721
Quoted 10 lines
drivers/cxl/cxlmem.h +10
-0+__le16 start_index; +u8 rsvd[2 ]; +} __packed; + +/* +* Get Supported Features Supported Feature Entry +* CXL rev 3.1 section 8.2.9.6.1 Table 8-97 */ +/* Supported Feature Entry : Payload out attribute flags */ +#define CXL_FEAT_ENTRY_FLAG_CHANGABLE BIT(0) +#define CXL_FEAT_ENTRY_FLAG_DEEPEST_RESET_PERSISTENCE_MASK GENMASK(3, 1)drivers/cxl/cxlmem.h struct cxl_mbox_set_timestamp_in { · line 722
Quoted 1 line
drivers/cxl/cxlmem.h +1
-0+#define CXL_FEAT_ENTRY_FLAG_PERSIST_ACROSS_FIRMWARE_UPDATE BIT(4)drivers/cxl/cxlmem.h void cxl_event_trace_record(const struct
Quoted 37 lines
drivers/cxl/cxlmem.h +33
-0+#define CXL_FEAT_ENTRY_FLAG_SUPPORT_DEFAULT_SELECTION BIT(5) +#define CXL_FEAT_ENTRY_FLAG_SUPPORT_SAVED_SELECTION BIT(6) + +enum cxl_feat_attr_value_persistence { +CXL_FEAT_ATTR_VALUE_PERSISTENCE_NONE , +CXL_FEAT_ATTR_VALUE_PERSISTENCE_CXL_RESET , +CXL_FEAT_ATTR_VALUE_PERSISTENCE_HOT_RESET , +CXL_FEAT_ATTR_VALUE_PERSISTENCE_WARM_RESET , +CXL_FEAT_ATTR_VALUE_PERSISTENCE_COLD_RESET , +CXL_FEAT_ATTR_VALUE_PERSISTENCE_MAX +}; + +struct cxl_mbox_supp_feat_entry { +uuid_t uuid; +__le16 index; +__le16 get_size; +__le16 set_size; +__le32 attr_flags; +u8 get_version; +u8 set_version; +__le16 set_effects; +u8 rsvd[18 ]; +} __packed; + +/* +* Get Supported Features output payload +* CXL rev 3.1 section 8.2.9.6.1 Table 8-96 */ struct +cxl_mbox_get_supp_feats_out { +__le16 nr_entries; +__le16 nr_supported; +u8 rsvd[4 ]; +struct cxl_mbox_supp_feat_entry feat_entries[]; } __packed; +/* Get Poison List CXL 3.0 Spec 8.2.9.8.4.1 */ struct cxl_mbox_poison_in {__le64 offset;@@ -831,6 +889,11 @@ void cxl_event_trace_record(const struct
cxl_memdev*cxlmd,drivers/cxl/cxlmem.h void cxl_event_trace_record(const struct cxl_memdev *cxlmd, · line 894
Quoted 6 lines
drivers/cxl/cxlmem.h +3
-0enum cxl_event_type event_type, const uuid_t *uuid, union cxl_event *evt); intcxl_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);int
drivers/cxl/cxlmem.h void cxl_event_trace_record(const struct · line 895
Quoted 1 line
drivers/cxl/cxlmem.h +1
-0+cxl_get_supported_feature_entry(struct cxl_memdev_state *mds, const
uuid_t*feat_uuid,drivers/cxl/cxlmem.h void cxl_event_trace_record(const struct · line 896
Quoted 1 line
drivers/cxl/cxlmem.h +1
-0+struct cxl_mbox_supp_feat_entry
*feat_entry_out);Quoted 3 lines
drivers/cxl/cxlmem.h +0
-0int 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);
Dave Jiang
maintainerRe: [PATCH v11 04/14] cxl/mbox: Add GET_SUPPORTED_FEATURES mailbox command
Quoted 94 lines · Shiju Jose
Hi Dave,
Quoted 85 lines
-----Original Message-----
From: Dave Jiang <[email protected]>
Sent: 20 August 2024 23:46
To: Shiju Jose <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; linux- [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [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]; tanxiaofei <[email protected]>; Zengtao (B) <[email protected]>; Roberto Sassu <[email protected]>; [email protected]; wanghuiqiang <[email protected]>; Linuxarm <[email protected]>
Subject: Re: [PATCH v11 04/14] cxl/mbox: AddGET_SUPPORTED_FEATURESmailbox commandQuoted 7 lines · On 8/16/24 9:42 AM, [email protected] wrote:
From: Shiju Jose <[email protected]>
Add support for
GET_SUPPORTED_FEATURESmailbox command.CXL spec 3.1 section 8.2.9.6 describes optional device specific features. CXL devices support features with changeable attributes.
Quoted 8 lines
CXL spec 3.1 section 8.2.9.6.1 describes Get Supported features command. 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.
Signed-off-by Shiju Jose <[email protected]>--- drivers/cxl/core/mbox.c | 68+++++++++++++++++++++++++++++++++++++++++
Quoted 27 lines
drivers/cxl/cxlmem.h | 63 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+)drivers/cxl/core/mbox.c index renamed from drivers/cxl/core/mbox.c +0
-0
2626f3fff201..760fa3e1075f100644drivers/cxl/core/mbox.c +17
-0@@ -1324,6 +1324,74 @@ 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),drivers/cxl/core/mbox.c int cxl_set_timestamp(struct cxl_memdev_state · line 1352
Quoted 10 lines
drivers/cxl/core/mbox.c +10
-0+ }; + 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_get_supported_feature_entry(struct cxl_memdev_state *mds, const
uuid_t*feat_uuid,drivers/cxl/core/mbox.c int cxl_set_timestamp(struct cxl_memdev_state · line 1353
Quoted 1 line
drivers/cxl/core/mbox.c +1
-0+struct cxl_mbox_supp_feat_entry
*feat_entry_out)Quoted 7 lines
Hi Shiju,
thoughts on storing all the supported features meta info fromGET_SUPPORTED_FEATUREScommand in the cxl core driver during device enumeration and the CXL EDAC code can just query the core instead of reading from the device? Just looking forward to supporting other read/set features operations in the future and avoiding going through this entire read and find routine for each feature.
Quoted 4 lines
Thanks for the suggestion.
I saw you have implementation for storing all the supported features meta info fromGET_SUPPORTED_FEATUREScommand here.
https://patchwork.kernel.org/project/cxl/patch/[email protected]/
I am fine basing on it if this patch is ready to go?
If you are fine with it then please feel free to incorporate the changes with your code and we'll go through the reviews. Thanks!
Quoted 138 lines
Quoted 2 lines
DJ
Thanks,
ShijuQuoted 132 lines
Quoted 67 lines
drivers/cxl/core/mbox.c +39
-0+{ +struct cxl_mbox_supp_feat_entry *feat_entry; +int feat_index, feats_out_size; +int nentries, count; +int ret; + + feat_index =0 ; + feats_out_size =sizeof (struct cxl_mbox_get_supp_feats_out ) + +sizeof (struct cxl_mbox_supp_feat_entry ); + struct cxl_mbox_get_supp_feats_out *feats_out __free(kfree) = +kmalloc (feats_out_size,GFP_KERNEL ); +if (!feats_out) +return -ENOMEM ; + +while (true) { +memset (feats_out,0 , feats_out_size); + ret =cxl_get_supported_features (mds, feats_out_size, + feat_index, feats_out); +if (ret) +return ret; + + nentries = feats_out->nr_entries; +if (!nentries) +return -EOPNOTSUPP ; + +/* Check CXL memdev supports the feature */ + feat_entry = feats_out->feat_entries; +for (count =0 ; count < nentries; count++, feat_entry++) { +if (uuid_equal (&feat_entry->uuid, feat_uuid)) { +memcpy (feat_entry_out, feat_entry, +sizeof (*feat_entry_out)); +return 0 ; + } + } + feat_index += nentries; + } +} +EXPORT_SYMBOL_NS_GPL (cxl_get_supported_feature_entry,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
af8169ccdbc0..9939c771f642100644drivers/cxl/cxlmem.h +9
-0@@ -531,6 +531,7 @@ enum cxl_opcode {CXL_MBOX_OP_GET_LOG_CAPS =0x0402 ,CXL_MBOX_OP_CLEAR_LOG =0x0403 ,CXL_MBOX_OP_GET_SUP_LOG_SUBLIST =0x0405 , +CXL_MBOX_OP_GET_SUPPORTED_FEATURES =0x0500 ,CXL_MBOX_OP_IDENTIFY =0x4000 ,CXL_MBOX_OP_GET_PARTITION_INFO =0x4100 , CXL_MBOX_OP_SET_PARTITION_INFO = 0x4101,@@ -700,6 +701,63 @@ struct cxl_mbox_set_timestamp_in { } __packed; +/* +* Get Supported Features CXL 3.1 Spec 8.2.9.6.1 */ + +/* +* Get Supported Features input payload +* CXL rev 3.1 section 8.2.9.6.1 Table 8-95 */ struct +cxl_mbox_get_supp_feats_in { +__le32 count;drivers/cxl/cxlmem.h struct cxl_mbox_set_timestamp_in { · line 721
Quoted 10 lines
drivers/cxl/cxlmem.h +10
-0+__le16 start_index; +u8 rsvd[2 ]; +} __packed; + +/* +* Get Supported Features Supported Feature Entry +* CXL rev 3.1 section 8.2.9.6.1 Table 8-97 */ +/* Supported Feature Entry : Payload out attribute flags */ +#define CXL_FEAT_ENTRY_FLAG_CHANGABLE BIT(0) +#define CXL_FEAT_ENTRY_FLAG_DEEPEST_RESET_PERSISTENCE_MASK GENMASK(3, 1)drivers/cxl/cxlmem.h struct cxl_mbox_set_timestamp_in { · line 722
Quoted 1 line
drivers/cxl/cxlmem.h +1
-0+#define CXL_FEAT_ENTRY_FLAG_PERSIST_ACROSS_FIRMWARE_UPDATE BIT(4)drivers/cxl/cxlmem.h void cxl_event_trace_record(const struct
Quoted 37 lines
drivers/cxl/cxlmem.h +33
-0+#define CXL_FEAT_ENTRY_FLAG_SUPPORT_DEFAULT_SELECTION BIT(5) +#define CXL_FEAT_ENTRY_FLAG_SUPPORT_SAVED_SELECTION BIT(6) + +enum cxl_feat_attr_value_persistence { +CXL_FEAT_ATTR_VALUE_PERSISTENCE_NONE , +CXL_FEAT_ATTR_VALUE_PERSISTENCE_CXL_RESET , +CXL_FEAT_ATTR_VALUE_PERSISTENCE_HOT_RESET , +CXL_FEAT_ATTR_VALUE_PERSISTENCE_WARM_RESET , +CXL_FEAT_ATTR_VALUE_PERSISTENCE_COLD_RESET , +CXL_FEAT_ATTR_VALUE_PERSISTENCE_MAX +}; + +struct cxl_mbox_supp_feat_entry { +uuid_t uuid; +__le16 index; +__le16 get_size; +__le16 set_size; +__le32 attr_flags; +u8 get_version; +u8 set_version; +__le16 set_effects; +u8 rsvd[18 ]; +} __packed; + +/* +* Get Supported Features output payload +* CXL rev 3.1 section 8.2.9.6.1 Table 8-96 */ struct +cxl_mbox_get_supp_feats_out { +__le16 nr_entries; +__le16 nr_supported; +u8 rsvd[4 ]; +struct cxl_mbox_supp_feat_entry feat_entries[]; } __packed; +/* Get Poison List CXL 3.0 Spec 8.2.9.8.4.1 */ struct cxl_mbox_poison_in {__le64 offset;@@ -831,6 +889,11 @@ void cxl_event_trace_record(const struct
cxl_memdev*cxlmd,drivers/cxl/cxlmem.h void cxl_event_trace_record(const struct cxl_memdev *cxlmd, · line 894
Quoted 6 lines
drivers/cxl/cxlmem.h +3
-0enum cxl_event_type event_type, const uuid_t *uuid, union cxl_event *evt); intcxl_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);int
drivers/cxl/cxlmem.h void cxl_event_trace_record(const struct · line 895
Quoted 1 line
drivers/cxl/cxlmem.h +1
-0+cxl_get_supported_feature_entry(struct cxl_memdev_state *mds, const
uuid_t*feat_uuid,drivers/cxl/cxlmem.h void cxl_event_trace_record(const struct · line 896
Quoted 1 line
drivers/cxl/cxlmem.h +1
-0+struct cxl_mbox_supp_feat_entry
*feat_entry_out);Quoted 3 lines
drivers/cxl/cxlmem.h +0
-0int 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);
PATCH v11 5/14 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. CXL spec 3.1 section 8.2.9.6.2 describes Get Feature command.
--- drivers/cxl/core/mbox.c | 40 ++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 27 +++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)
drivers/cxl/core/mbox.c +40 -0
@@ -1392,6 +1392,46 @@ int cxl_get_supported_feature_entry(struct cxl_memdev_state *mds, const uuid_t * }EXPORT_SYMBOL_NS_GPL (cxl_get_supported_feature_entry,CXL ); +size_t cxl_get_feature (struct cxl_memdev_state *mds, +const uuid_t feat_uuid, +enum cxl_get_feat_selection selection, +void *feat_out,size_t feat_out_size) +{ +size_t data_to_rd_size, size_out; +struct cxl_mbox_get_feat_in pi; +struct cxl_mbox_cmd mbox_cmd; +size_t data_rcvd_size =0 ; +int rc; + +if (!feat_out || !feat_out_size) +return 0 ; + + size_out =min (feat_out_size, mds->payload_size); + pi.uuid = feat_uuid; + pi.selection = selection; +do { + data_to_rd_size =min (feat_out_size - data_rcvd_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 = size_out, + .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) +return 0 ; + data_rcvd_size += mbox_cmd.size_out; + }while (data_rcvd_size < feat_out_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 +27 -0
@@ -532,6 +532,7 @@ enum cxl_opcode {CXL_MBOX_OP_CLEAR_LOG =0x0403 ,CXL_MBOX_OP_GET_SUP_LOG_SUBLIST =0x0405 ,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,
@@ -758,6 +759,28 @@ 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;
@@ -894,6 +917,10 @@ int cxl_get_supported_features(struct cxl_memdev_state *mds, struct cxl_mbox_get_supp_feats_out *feats_out);int cxl_get_supported_feature_entry (struct cxl_memdev_state *mds,const uuid_t *feat_uuid,struct cxl_mbox_supp_feat_entry *feat_entry_out); +size_t cxl_get_feature (struct cxl_memdev_state *mds, +const uuid_t feat_uuid, +enum cxl_get_feat_selection selection, +void *feat_out,size_t feat_out_size);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
PATCH v11 6/14 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.
CXL spec 3.1 section 8.2.9.6.3 describes Set Feature command.
--- drivers/cxl/core/mbox.c | 72 +++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 34 +++++++++++++++++++ 2 files changed, 106 insertions(+)
drivers/cxl/core/mbox.c +72 -0
@@ -1432,6 +1432,78 @@ size_t cxl_get_feature(struct cxl_memdev_state *mds, }EXPORT_SYMBOL_NS_GPL (cxl_get_feature,CXL ); +/* +* FEAT_DATA_MIN_PAYLOAD_SIZE - min extra number of bytes should be +* available in the mailbox for storing the actual feature data so that +* the feature data transfer would work as expected. +*/ +#define FEAT_DATA_MIN_PAYLOAD_SIZE 10 +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 ; + feat_flag |=CXL_SET_FEAT_FLAG_DATA_SAVED_ACROSS_RESET ; + hdr_size =sizeof (pi->hdr); +/* +* Check minimum mbox payload size is available for +* the feature data transfer. +*/ +if (hdr_size +FEAT_DATA_MIN_PAYLOAD_SIZE > 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); +} +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 +34 -0
@@ -533,6 +533,7 @@ enum cxl_opcode {CXL_MBOX_OP_GET_SUP_LOG_SUBLIST =0x0405 ,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,
@@ -781,6 +782,35 @@ 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;
@@ -921,6 +951,10 @@ size_t cxl_get_feature(struct cxl_memdev_state *mds,const uuid_t feat_uuid, enum cxl_get_feat_selection selection, void *feat_out, size_t feat_out_size); +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
PATCH v11 7/14 cxl/memfeature: Add CXL memory 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.
Allow specifying the number of hours within which the patrol scrub must be completed, subject to minimum and maximum limits reported by the device. Also allow disabling scrub allowing trade-off error rates against performance.
Add support for CXL memory device based patrol scrub control. Register with EDAC RAS control feature driver, which gets the scrub attr descriptors from the EDAC scrub and expose sysfs scrub control attributes to the userspace.
For example CXL device based scrub control for the CXL mem0 device is exposed in /sys/bus/edac/devices/cxl_mem0/scrub/
Also add support for region based CXL memory patrol scrub control. CXL memory region may be interleaved across one or more CXL memory devices. For example region based scrub control for CXL region1 is exposed in /sys/bus/edac/devices/cxl_region1/scrub/
Open Questions:
Q1: CXL 3.1 spec defined patrol scrub control feature at CXL memory devices with supporting set scrub cycle and enable/disable scrub. but not based on HPA range. Thus presently scrub control for a region is implemented based on all associated CXL memory devices.
What is the exact use case for the CXL region based scrub control? How the HPA range, which Dan asked for region based scrubbing is used? Does spec change is required for patrol scrub control feature with support for setting the HPA range?
Q2: Both CXL device based and CXL region based scrub control would be enabled at the same time in a system?
--- Documentation/edac/edac-scrub.rst | 74 ++++++ drivers/cxl/Kconfig | 18 ++ drivers/cxl/core/Makefile | 1 + drivers/cxl/core/memfeature.c | 374 ++++++++++++++++++++++++++++++ drivers/cxl/core/region.c | 6 + drivers/cxl/cxlmem.h | 7 + drivers/cxl/mem.c | 4 + 7 files changed, 484 insertions(+) create mode 100644 Documentation/edac/edac-scrub.rst create mode 100644 drivers/cxl/core/memfeature.c
Documentation/edac/edac-scrub.rst new file +74 -0
@@ -0,0 +1,74 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=================== +EDAC Scrub control +=================== + +Copyright (c) 2024 HiSilicon Limited. + +:Author: Shiju Jose <[email protected]> +:License: The GNU Free Documentation License, Version 1.2 + (dual licensed under the GPL v2) +:Original Reviewers: + +- Written for: 6.12 +- Updated for: + +Introduction +------------ +The edac scrub driver provides interfaces for controlling the +memory scrubbers in the system. The scrub device drivers in the +system register with the edac scrub. The driver exposes the +scrub controls to the user in the sysfs. + +The File System +--------------- + +The control attributes of the registered scrubbers could be +accessed in the /sys/bus/edac/devices/<dev-name>/scrub/ + +sysfs +----- + +Sysfs files are documented in +`Documentation/ABI/testing/sysfs-edac-scrub-control`. + +Example +------- + +The usage takes the form shown in this example:: + +1. CXL memory device patrol scrubber +1.1 device based +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/scrub/min_cycle_duration +3600 +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/scrub/max_cycle_duration +918000 +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/scrub/current_cycle_duration +43200 +root@localhost:~# echo 54000 > /sys/bus/edac/devices/cxl_mem0/scrub/current_cycle_duration +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/scrub/current_cycle_duration +54000 +root@localhost:~# echo 1 > /sys/bus/edac/devices/cxl_mem0/scrub/enable_background +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/scrub/enable_background +1 +root@localhost:~# echo 0 > /sys/bus/edac/devices/cxl_mem0/scrub/enable_background +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/scrub/enable_background +0 + +1.2. region based +root@localhost:~# cat /sys/bus/edac/devices/cxl_region0/scrub/min_cycle_duration +3600 +root@localhost:~# cat /sys/bus/edac/devices/cxl_region0/scrub/max_cycle_duration +918000 +root@localhost:~# cat /sys/bus/edac/devices/cxl_region0/scrub/current_cycle_duration +43200 +root@localhost:~# echo 54000 > /sys/bus/edac/devices/cxl_region0/scrub/current_cycle_duration +root@localhost:~# cat /sys/bus/edac/devices/cxl_region0/scrub/current_cycle_duration +54000 +root@localhost:~# echo 1 > /sys/bus/edac/devices/cxl_region0/scrub/enable_background +root@localhost:~# cat /sys/bus/edac/devices/cxl_region0/scrub/enable_background +1 +root@localhost:~# echo 0 > /sys/bus/edac/devices/cxl_region0/scrub/enable_background +root@localhost:~# cat /sys/bus/edac/devices/cxl_region0/scrub/enable_background +0
drivers/cxl/Kconfig +18 -0
@@ -145,4 +145,22 @@ config CXL_REGION_INVALIDATION_TEST If unsure, or if this kernel is meant for production environments, say N. +config CXL_RAS_FEAT + bool "CXL: Memory RAS features" + depends on CXL_PCI + depends on CXL_MEM + depends on EDAC + help + The CXL memory RAS feature control is optional allows host to control + the RAS feature's configurations of CXL Type 3 devices. + + Registers with the EDAC device subsystem to expose control attributes + of CXL memory device's RAS features to the user. + Provides interface functions to support configuring the CXL memory + device's RAS features. + + Say 'y/n' to enable/disable CXL.mem device'ss RAS feature's control. + See section 8.2.9.9.11 of CXL 3.1 specification for the detailed + information of CXL memory device 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_RAS_FEAT) += memfeature.o
drivers/cxl/core/memfeature.c new file +374 -0
374 lines not on this page · raw message
drivers/cxl/core/region.c +6 -0
@@ -3397,6 +3397,12 @@ static int cxl_region_probe(struct device *dev) p->res->start, p->res->end, cxlr, is_system_ram) > 0)return 0 ; + + rc =cxl_mem_ras_features_init (NULL , cxlr); +if (rc) +dev_warn (&cxlr->dev,"CXL ras features init for region_id=%d failed\n" , + cxlr->id); +return devm_cxl_add_dax_region (cxlr);default : dev_dbg(&cxlr->dev, "unsupported region mode: %d\n",
drivers/cxl/cxlmem.h +7 -0
@@ -962,6 +962,13 @@ 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); +#ifdef CONFIG_CXL_RAS_FEAT +int cxl_mem_ras_features_init (struct cxl_memdev *cxlmd,struct cxl_region *cxlr); +#else +static inline int cxl_mem_ras_features_init (struct cxl_memdev *cxlmd,struct cxl_region *cxlr) +{return 0 ; } +#endif +#ifdef CONFIG_CXL_SUSPEND void cxl_mem_active_inc (void );void cxl_mem_active_dec (void );
drivers/cxl/mem.c +4 -0
@@ -117,6 +117,10 @@ static int cxl_mem_probe(struct device *dev)if (!cxlds->media_ready)return -EBUSY ; + rc =cxl_mem_ras_features_init (cxlmd,NULL ); +if (rc) +dev_warn (&cxlmd->dev,"CXL ras features init failed\n" ); +/* * Someone is trying to reattach this device after it lost its port * connection (an endpoint port previously registered by this memdev was
Signature · 1 line
2.34.1
kernel test robot
build botRe: [PATCH v11 07/14] cxl/memfeature: Add CXL memory device patrol scrub control feature
kernel test robot noticed the following build warnings:
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on ras/edac-for-next]
[also build test WARNING on rafael-pm/linux-next rafael-pm/bleeding-edge cxl/next linus/master v6.11-rc3 next-20240816] [cannot apply to cxl/pending]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/shiju-jose-huawei-com/EDAC-Add-support-for-EDAC-device-feature-s-control/20240817-004442 base: https://git.kernel.org/pub/scm/linux/kernel/git/ras/ras.git edac-for-next patch link: https://lore.kernel.org/r/20240816164238.1902-8-shiju.jose%40huawei.com patch subject: [PATCH v11 07/14] cxl/memfeature: Add CXL memory device patrol scrub control feature reproduce: (https://download.01.org/0day-ci/archive/20240817/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
Warning: Documentation/devicetree/bindings/power/wakeup-source.txt references a file that doesn't exist: Documentation/devicetree/bindings/input/qcom,pm8xxx-keypad.txt
Warning: Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml references a file that doesn't exist: Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
>> Warning: Documentation/edac/edac-scrub.rst references a file that doesn't exist: Documentation/ABI/testing/sysfs-edac-scrub-control
Warning: Documentation/hwmon/g762.rst references a file that doesn't exist: Documentation/devicetree/bindings/hwmon/g762.txt
Warning: MAINTAINERS references a file that doesn't exist: Documentation/devicetree/bindings/reserved-memory/qcom
Warning: MAINTAINERS references a file that doesn't exist: Documentation/devicetree/bindings/display/exynos/
Warning: MAINTAINERS references a file that doesn't exist: Documentation/devicetree/bindings/misc/fsl,qoriq-mc.txt Using alabaster theme
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v11 8/14 cxl/memfeature: Add CXL memory 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 ECS (Error Check Scrub) 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 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.
Register with EDAC RAS control feature driver, which gets the ECS attr descriptors from the EDAC ECS and expose sysfs ECS control attributes to the userspace.
For example ECS control for the memory media FRU 0 in CXL mem0 device is in /sys/bus/edac/devices/cxl_mem0/ecs_fru0/
--- drivers/cxl/core/memfeature.c | 441 +++++++++++++++++++++++++++++++++- 1 file changed, 440 insertions(+), 1 deletion(-)
drivers/cxl/core/memfeature.c +440 -1
@@ -19,7 +19,7 @@#include <cxl.h> #include <linux/edac.h> -#define CXL_DEV_NUM_RAS_FEATURES 1 +#define CXL_DEV_NUM_RAS_FEATURES 2#define CXL_DEV_HOUR_IN_SECS 3600#define CXL_SCRUB_NAME_LEN 128
@@ -307,6 +307,407 @@ static const struct edac_scrub_ops cxl_ps_scrub_ops = { .cycle_duration_write = cxl_patrol_scrub_write_scrub_cycle, }; +/* CXL DDR5 ECS control definitions */ +static const uuid_t cxl_ecs_uuid = +UUID_INIT (0xe5b13f22 ,0x2328 ,0x4a14 ,0xb8 ,0xba ,0xb9 ,0x69 ,0x1e , \ +0x89 ,0x33 ,0x86 ); + +struct cxl_ecs_context { +u16 num_media_frus; +u16 get_feat_size; +u16 set_feat_size; +u8 get_version; +u8 set_version; +u16 set_effects; +struct cxl_memdev *cxlmd; +}; + +enum { +CXL_ECS_PARAM_LOG_ENTRY_TYPE , +CXL_ECS_PARAM_THRESHOLD , +CXL_ECS_PARAM_MODE , +CXL_ECS_PARAM_RESET_COUNTER , +}; + +#define CXL_ECS_LOG_ENTRY_TYPE_MASK GENMASK(1, 0) +#define CXL_ECS_REALTIME_REPORT_CAP_MASK BIT(0) +#define CXL_ECS_THRESHOLD_COUNT_MASK GENMASK(2, 0) +#define CXL_ECS_MODE_MASK BIT(3) +#define CXL_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 cxl_ecs_mode { +ECS_MODE_COUNTS_ROWS =0 , +ECS_MODE_COUNTS_CODEWORDS =1 , +}; + +/** +* struct cxl_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_ecs_params { +u8 log_entry_type; +u16 threshold; +enum cxl_ecs_mode mode; +bool reset_counter; +}; + +struct cxl_ecs_rd_attrs { +u8 ecs_log_cap; +u8 ecs_cap; +__le16 ecs_config; +u8 ecs_flags; +} __packed; + +struct cxl_ecs_wr_attrs { +u8 ecs_log_cap; +__le16 ecs_config; +} __packed; + +/* CXL DDR5 ECS control functions */ +static int cxl_mem_ecs_get_attrs (struct device *dev,void *drv_data,int fru_id, +struct cxl_ecs_params *params) +{ +struct cxl_ecs_context *cxl_ecs_ctx = drv_data; +struct cxl_memdev *cxlmd = cxl_ecs_ctx->cxlmd; +struct cxl_dev_state *cxlds = cxlmd->cxlds; +struct cxl_memdev_state *mds =to_cxl_memdev_state (cxlds); +size_t rd_data_size; +u8 threshold_index; +size_t data_size; + + rd_data_size = cxl_ecs_ctx->get_feat_size; + + struct cxl_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, +CXL_GET_FEAT_SEL_CURRENT_VALUE , + rd_attrs, rd_data_size); +if (!data_size) +return -EIO ; + + params->log_entry_type =FIELD_GET (CXL_ECS_LOG_ENTRY_TYPE_MASK , + rd_attrs[fru_id].ecs_log_cap); + threshold_index =FIELD_GET (CXL_ECS_THRESHOLD_COUNT_MASK , + rd_attrs[fru_id].ecs_config); + params->threshold = ecs_supp_threshold[threshold_index]; + params->mode =FIELD_GET (CXL_ECS_MODE_MASK , + rd_attrs[fru_id].ecs_config); +return 0 ; +} + +static int cxl_mem_ecs_set_attrs (struct device *dev,void *drv_data,int fru_id, +struct cxl_ecs_params *params,u8 param_type) +{ +struct cxl_ecs_context *cxl_ecs_ctx = drv_data; +struct cxl_memdev *cxlmd = cxl_ecs_ctx->cxlmd; +struct cxl_dev_state *cxlds = cxlmd->cxlds; +struct cxl_memdev_state *mds =to_cxl_memdev_state (cxlds); +size_t rd_data_size, wr_data_size; +u16 num_media_frus, count; +size_t data_size; +int ret; + + num_media_frus = cxl_ecs_ctx->num_media_frus; + rd_data_size = cxl_ecs_ctx->get_feat_size; + wr_data_size = cxl_ecs_ctx->set_feat_size; + struct cxl_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, +CXL_GET_FEAT_SEL_CURRENT_VALUE , + rd_attrs, rd_data_size); +if (!data_size) +return -EIO ; + struct cxl_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 < num_media_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_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_ECS_LOG_ENTRY_TYPE_MASK , + params->log_entry_type); +break ; +case CXL_ECS_PARAM_THRESHOLD : + wr_attrs[fru_id].ecs_config &= ~CXL_ECS_THRESHOLD_COUNT_MASK ; +switch (params->threshold) { +case 256 : + wr_attrs[fru_id].ecs_config |=FIELD_PREP (CXL_ECS_THRESHOLD_COUNT_MASK , +ECS_THRESHOLD_256 ); +break ; +case 1024 : + wr_attrs[fru_id].ecs_config |=FIELD_PREP (CXL_ECS_THRESHOLD_COUNT_MASK , +ECS_THRESHOLD_1024 ); +break ; +case 4096 : + wr_attrs[fru_id].ecs_config |=FIELD_PREP (CXL_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_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_ECS_MODE_MASK ; + wr_attrs[fru_id].ecs_config |=FIELD_PREP (CXL_ECS_MODE_MASK , + params->mode); +break ; +case CXL_ECS_PARAM_RESET_COUNTER : + wr_attrs[fru_id].ecs_config &= ~CXL_ECS_RESET_COUNTER_MASK ; + wr_attrs[fru_id].ecs_config |=FIELD_PREP (CXL_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_ecs_ctx->set_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 ; +} + +static int cxl_ecs_get_log_entry_type (struct device *dev,void *drv_data, +int fru_id,u32 *val) +{ +struct cxl_ecs_params params; +int ret; + + ret =cxl_mem_ecs_get_attrs (dev, drv_data, fru_id, ¶ms); +if (ret) +return ret; + + *val = params.log_entry_type; + +return 0 ; +} + +static int cxl_ecs_set_log_entry_type (struct device *dev,void *drv_data, +int fru_id,u32 val) +{ +struct cxl_ecs_params params = { + .log_entry_type = val, + }; + +return cxl_mem_ecs_set_attrs (dev, drv_data, fru_id, + ¶ms,CXL_ECS_PARAM_LOG_ENTRY_TYPE ); +} + +static int cxl_ecs_get_log_entry_type_per_dram (struct device *dev,void *drv_data, +int fru_id,u32 *val) +{ +struct cxl_ecs_params params; +int ret; + + ret =cxl_mem_ecs_get_attrs (dev, drv_data, fru_id, ¶ms); +if (ret) +return ret; + +if (params.log_entry_type ==ECS_LOG_ENTRY_TYPE_DRAM ) + *val =1 ; +else + *val =0 ; + +return 0 ; +} + +static int cxl_ecs_get_log_entry_type_per_memory_media (struct device *dev, +void *drv_data, +int fru_id,u32 *val) +{ +struct cxl_ecs_params params; +int ret; + + ret =cxl_mem_ecs_get_attrs (dev, drv_data, fru_id, ¶ms); +if (ret) +return ret; + +if (params.log_entry_type ==ECS_LOG_ENTRY_TYPE_MEM_MEDIA_FRU ) + *val =1 ; +else + *val =0 ; + +return 0 ; +} + +static int cxl_ecs_get_mode (struct device *dev,void *drv_data, +int fru_id,u32 *val) +{ +struct cxl_ecs_params params; +int ret; + + ret =cxl_mem_ecs_get_attrs (dev, drv_data, fru_id, ¶ms); +if (ret) +return ret; + + *val = params.mode; + +return 0 ; +} + +static int cxl_ecs_set_mode (struct device *dev,void *drv_data, +int fru_id,u32 val) +{ +struct cxl_ecs_params params = { + .mode = val, + }; + +return cxl_mem_ecs_set_attrs (dev, drv_data, fru_id, + ¶ms,CXL_ECS_PARAM_MODE ); +} + +static int cxl_ecs_get_mode_counts_rows (struct device *dev,void *drv_data, +int fru_id,u32 *val) +{ +struct cxl_ecs_params params; +int ret; + + ret =cxl_mem_ecs_get_attrs (dev, drv_data, fru_id, ¶ms); +if (ret) +return ret; + +if (params.mode ==ECS_MODE_COUNTS_ROWS ) + *val =1 ; +else + *val =0 ; + +return 0 ; +} + +static int cxl_ecs_get_mode_counts_codewords (struct device *dev,void *drv_data, +int fru_id,u32 *val) +{ +struct cxl_ecs_params params; +int ret; + + ret =cxl_mem_ecs_get_attrs (dev, drv_data, fru_id, ¶ms); +if (ret) +return ret; + +if (params.mode ==ECS_MODE_COUNTS_CODEWORDS ) + *val =1 ; +else + *val =0 ; + +return 0 ; +} + +static int cxl_ecs_reset (struct device *dev,void *drv_data,int fru_id,u32 val) +{ +struct cxl_ecs_params params = { + .reset_counter = val, + }; + +return cxl_mem_ecs_set_attrs (dev, drv_data, fru_id, + ¶ms,CXL_ECS_PARAM_RESET_COUNTER ); +} + +static int cxl_ecs_get_threshold (struct device *dev,void *drv_data, +int fru_id,u32 *val) +{ +struct cxl_ecs_params params; +int ret; + + ret =cxl_mem_ecs_get_attrs (dev, drv_data, fru_id, ¶ms); +if (ret) +return ret; + + *val = params.threshold; + +return 0 ; +} + +static int cxl_ecs_set_threshold (struct device *dev,void *drv_data, +int fru_id,u32 val) +{ +struct cxl_ecs_params params = { + .threshold = val, + }; + +return cxl_mem_ecs_set_attrs (dev, drv_data, fru_id, + ¶ms,CXL_ECS_PARAM_THRESHOLD ); +} + +static const struct edac_ecs_ops cxl_ecs_ops = { + .get_log_entry_type = cxl_ecs_get_log_entry_type, + .set_log_entry_type = cxl_ecs_set_log_entry_type, + .get_log_entry_type_per_dram = cxl_ecs_get_log_entry_type_per_dram, + .get_log_entry_type_per_memory_media = + cxl_ecs_get_log_entry_type_per_memory_media, + .get_mode = cxl_ecs_get_mode, + .set_mode = cxl_ecs_set_mode, + .get_mode_counts_codewords = cxl_ecs_get_mode_counts_codewords, + .get_mode_counts_rows = cxl_ecs_get_mode_counts_rows, + .reset = cxl_ecs_reset, + .get_threshold = cxl_ecs_get_threshold, + .set_threshold = cxl_ecs_set_threshold, +}; +int cxl_mem_ras_features_init (struct cxl_memdev *cxlmd,struct cxl_region *cxlr) {struct edac_dev_feature ras_features[CXL_DEV_NUM_RAS_FEATURES ];
@@ -315,7 +716,9 @@ int cxl_mem_ras_features_init(struct cxl_memdev *cxlmd, struct cxl_region *cxlr)struct cxl_patrol_scrub_context *cxl_ps_ctx;struct cxl_mbox_supp_feat_entry feat_entry;char cxl_dev_name[CXL_SCRUB_NAME_LEN ]; +struct cxl_ecs_context *cxl_ecs_ctx;int rc, i, num_ras_features =0 ; +int num_media_frus;if (cxlr) {struct cxl_region_params *p = &cxlr->params;
@@ -368,6 +771,42 @@ int cxl_mem_ras_features_init(struct cxl_memdev *cxlmd, struct cxl_region *cxlr) ras_features[num_ras_features].scrub_ctx = cxl_ps_ctx; num_ras_features++; +if (!cxlr) { + rc =cxl_get_supported_feature_entry (mds, &cxl_ecs_uuid, + &feat_entry); +if (rc <0 ) + goto feat_register; + +if (!(feat_entry.attr_flags &CXL_FEAT_ENTRY_FLAG_CHANGABLE )) + goto feat_register; + num_media_frus = feat_entry.get_size / +sizeof (struct cxl_ecs_rd_attrs ); +if (!num_media_frus) + goto feat_register; + + cxl_ecs_ctx =devm_kzalloc (&cxlmd->dev,sizeof (*cxl_ecs_ctx), +GFP_KERNEL ); +if (!cxl_ecs_ctx) + goto feat_register; + *cxl_ecs_ctx = (struct cxl_ecs_context ) { + .get_feat_size = feat_entry.get_size, + .set_feat_size = feat_entry.set_size, + .get_version = feat_entry.get_version, + .set_version = feat_entry.set_version, + .set_effects = feat_entry.set_effects, + .num_media_frus = num_media_frus, + .cxlmd = cxlmd, + }; + + ras_features[num_ras_features].feat =RAS_FEAT_ECS ; + ras_features[num_ras_features].ecs_ops = &cxl_ecs_ops; + ras_features[num_ras_features].ecs_ctx = cxl_ecs_ctx; + ras_features[num_ras_features].ecs_info.num_media_frus = + num_media_frus; + num_ras_features++; + } + +feat_register:return edac_dev_register (&cxlmd->dev, cxl_dev_name,NULL , num_ras_features, ras_features); }
Signature · 1 line
2.34.1
PATCH v11 9/14 platform: Add __free() based cleanup function for platform_device_put
In reply to [email protected]From: Jonathan Cameron <[email protected]>
Add __free() based cleanup function for platform_device_put().
--- include/linux/platform_device.h | 1 + 1 file changed, 1 insertion(+)
include/linux/platform_device.h +1 -0
@@ -232,6 +232,7 @@ extern int platform_device_add_data(struct platform_device *pdev,extern int platform_device_add (struct platform_device *pdev);extern void platform_device_del (struct platform_device *pdev);extern void platform_device_put (struct platform_device *pdev); +DEFINE_FREE(platform_device_put, struct platform_device *, if (_T) platform_device_put(_T))struct platform_driver {int (*probe)(struct platform_device *);
Signature · 1 line
2.34.1
PATCH v11 10/14 ACPI:RAS2: Add ACPI RAS2 driver
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.
Driver contains RAS2 Init, which extracts the RAS2 table and driver adds platform device for each memory features which binds to the RAS2 memory driver.
Driver uses PCC mailbox to communicate with the ACPI HW and the driver adds OSPM interfaces to send RAS2 commands.
--- drivers/acpi/Kconfig | 10 + drivers/acpi/Makefile | 1 + drivers/acpi/ras2.c | 391 +++++++++++++++++++++++++++++++++++++++ include/acpi/ras2_acpi.h | 59 ++++++ 4 files changed, 461 insertions(+) create mode 100755 drivers/acpi/ras2.c create mode 100644 include/acpi/ras2_acpi.h
drivers/acpi/Kconfig +10 -0
@@ -284,6 +284,16 @@ config ACPI_CPPC_LIB If your platform does not support CPPC in firmware, leave this option disabled. +config ACPI_RAS2 + bool "ACPI RAS2 driver" + select MAILBOX + select PCC + help + The driver adds support for ACPI RAS2 feature table(extracts RAS2 + table from OS system table) and OSPM interfaces to send RAS2 + commands via PCC mailbox subspace. Driver adds platform device for + the RAS2 memory features which binds to the RAS2 memory driver. + config ACPI_PROCESSOR tristate "Processor" depends on X86 || ARM64 || LOONGARCH || RISCV
drivers/acpi/Makefile +1 -0
@@ -99,6 +99,7 @@ obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.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.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.c new file +391 -0
391 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
PATCH v11 11/14 ras: mem: Add memory ACPI RAS2 driver
In reply to [email protected]From: Shiju Jose <[email protected]>
Memory ACPI RAS2 driver binds to the platform device add by the ACPI RAS2 table parser.
Driver uses a PCC subspace for communicating with the ACPI compliant platform to provide control of memory scrub parameters to the userspace via the edac scrub.
Get the scrub attr descriptors from the EDAC scrub and register with EDAC RAS feature driver to expose sysfs scrub control attributes to the userspace. For example scrub control for the RAS2 memory device is exposed in /sys/bus/edac/devices/acpi_ras2_mem0/scrub/
--- Documentation/edac/edac-scrub.rst | 41 +++ drivers/ras/Kconfig | 10 + drivers/ras/Makefile | 1 + drivers/ras/acpi_ras2.c | 411 ++++++++++++++++++++++++++++++ 4 files changed, 463 insertions(+) create mode 100644 drivers/ras/acpi_ras2.c
Documentation/edac/edac-scrub.rst +41 -0
@@ -72,3 +72,44 @@ root@localhost:~# cat /sys/bus/edac/devices/cxl_region0/scrub/enable_background root@localhost:~# echo 0 > /sys/bus/edac/devices/cxl_region0/scrub/enable_background root@localhost:~# cat /sys/bus/edac/devices/cxl_region0/scrub/enable_background 0 + +2. RAS2 +2.1 On demand scrubbing for a specific memory region. +root@localhost:~# echo 0x120000 > /sys/bus/edac/devices/acpi_ras2_mem0/scrub/addr_range_base +root@localhost:~# echo 0x150000 > /sys/bus/edac/devices/acpi_ras2_mem0/scrub/addr_range_size +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras2_mem0/scrub/min_cycle_duration +3600 +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras2_mem0/scrub/max_cycle_duration +86400 +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras2_mem0/scrub/current_cycle_duration +36000 +root@localhost:~# echo 54000 > /sys/bus/edac/devices/acpi_ras2_mem0/scrub/current_cycle_duration +root@localhost:~# echo 1 > /sys/bus/edac/devices/acpi_ras2_mem0/scrub/enable_on_demand +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras2_mem0/scrub/enable_on_demand +1 +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras2_mem0/scrub/current_cycle_duration +54000 +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras2_mem0/scrub/addr_range_base +0x120000 +root@localhost:~# cat //sys/bus/edac/devices/acpi_ras2_mem0/scrub/addr_range_size +0x150000 +root@localhost:~# echo 0 > /sys/bus/edac/devices/acpi_ras2_mem0/scrub/enable_on_demand +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras2_mem0/scrub/enable_on_demand +0 + +2.2 Background scrubbing the entire memory +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras2_mem0/scrub/min_cycle_duration +3600 +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras2_mem0/scrub/max_cycle_duration +86400 +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras2_mem0/scrub/current_cycle_duration +36000 +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras2_mem0/enable_background +0 +root@localhost:~# echo 10800 > /sys/bus/edac/devices/acpi_ras2_mem0/scrub/current_cycle_duration +root@localhost:~# echo 1 > /sys/bus/edac/devices/acpi_ras2_mem0/enable_background +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras2_mem0/enable_background +1 +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras2_mem0/scrub/current_cycle_duration +10800 +root@localhost:~# echo 0 > /sys/bus/edac/devices/acpi_ras2_mem0/enable_background
drivers/ras/Kconfig +10 -0
@@ -46,4 +46,14 @@ config RAS_FMPM Memory will be retired during boot time and run time depending on platform-specific policies. +config MEM_ACPI_RAS2 + tristate "Memory ACPI RAS2 driver" + depends on ACPI_RAS2 + depends on EDAC + help + The driver binds to the platform device added by the ACPI RAS2 + table parser. Use a PCC channel subspace for communicating with + the ACPI compliant platform to provide control of memory scrub + parameters to the user via the edac scrub. + endif
drivers/ras/Makefile +1 -0
@@ -2,6 +2,7 @@ obj-$(CONFIG_RAS) += ras.o obj-$(CONFIG_DEBUG_FS) += debugfs.o obj-$(CONFIG_RAS_CEC) += cec.o +obj-$(CONFIG_MEM_ACPI_RAS2) += acpi_ras2.o obj-$(CONFIG_RAS_FMPM) += amd/fmpm.o obj-y += amd/atl/
drivers/ras/acpi_ras2.c new file +411 -0
411 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v11 12/14 EDAC: Add EDAC PPR control driver
In reply to [email protected]From: Shiju Jose <[email protected]>
Add generic EDAC PPR(Post Package Repair) control driver supports configuring the memory PPR feature in the system. Supports both sPPR(soft PPR) and hPPR(hard PPR). The device with PPR feature, get the PPR descriptor from the EDAC PPR and registers with the EDAC, which adds the sysfs PPR control attributes. The PPR control attributes are available to the userspace in /sys/bus/edac/devices/<dev-name>/pprX/
Generic EDAC PPR driver and the common sysfs PPR interface promotes unambiguous access from the userspace irrespective of the underlying memory devices with PPR feature supported.
The sysfs PPR attribute nodes would be present only if the client driver has implemented the corresponding attribute callback functions and pass in ops to the EDAC during registration.
Note: There are other PPR drivers to come apart from the CXL PPR in this series.
--- Documentation/ABI/testing/sysfs-edac-ppr | 69 ++++++ drivers/edac/Makefile | 2 +- drivers/edac/edac_device.c | 6 + drivers/edac/edac_ppr.c | 255 +++++++++++++++++++++++ include/linux/edac.h | 29 +++ 5 files changed, 360 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-edac-ppr create mode 100755 drivers/edac/edac_ppr.c
Documentation/ABI/testing/sysfs-edac-ppr new file +69 -0
@@ -0,0 +1,69 @@ +What: /sys/bus/edac/devices/<dev-name>/ppr* +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + The sysfs edac bus devices /<dev-name>/ppr* subdirectory + belongs to the memory media PPR (Post Package Repair) control + feature, where <dev-name> directory corresponds to a device + registered with the EDAC PPR driver and thus registered with + the generic edac device driver. + /ppr* belongs to either sPPR (Soft PPR) or hPPR (Hard PPR) + feature for the memory device. + The sysfs PPR attr nodes would be only present if PPR is + supported. + +What: /sys/bus/edac/devices/<dev-name>/ppr*/persist_mode_avail +Date: Oct 2024 +KernelVersion: 6.12For e.g. HBM, DDR. +Contact: [email protected] +Description: + (RO) persist PPR modes supported in the device. + For e.g. Hard PPR(hPPR) for a permanent row repair, + Soft PPR(sPPR) for a temporary row repair. + +What: /sys/bus/edac/devices/<dev-name>/ppr*/persist_mode +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (RW) Current persist PPR mode. + +What: /sys/bus/edac/devices/<dev-name>/ppr*/dpa_support +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (RO) True if supports DPA for PPR maintenance operation. + +What: /sys/bus/edac/devices/<dev-name>/ppr*/ppr_safe_when_in_use +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (RO) True if memory media is accessible and data is retained + during the PPR operation. + +What: /sys/bus/edac/devices/<dev-name>/ppr*/repair_hpa +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (WO) Start the PPR operation for the HPA (host physical + address) set. Return failure if resources are not available + to perform repair. + +What: /sys/bus/edac/devices/<dev-name>/ppr*/repair_dpa +Date: Oct 2024 +KernelVersion: 6.12 +Contact: [email protected] +Description: + (WO) Starts the PPR operation for the DPA(device physical + address) set. Return failure if resources are not available + to perform repair. + In some states of system configuration (e.g. before address decoders + have been configured), memory devices (e.g. CXL) may not have an + active mapping in the main host address physical address map. + As such, the memory to repair must be identified by a device + specific physical addressing scheme using a DPA. The DPA to use + will be presented in related error records.
drivers/edac/Makefile +1 -1
@@ -10,7 +10,7 @@ obj-$(CONFIG_EDAC) := edac_core.o edac_core-y := edac_mc.o edac_device.o edac_mc_sysfs.o edac_core-y += edac_module.o edac_device_sysfs.o wq.o -edac_core-y += edac_scrub.o edac_ecs.o +edac_core-y += edac_scrub.o edac_ecs.o edac_ppr.o edac_core-$(CONFIG_EDAC_DEBUG) += debugfs.o
drivers/edac/edac_device.c +6 -0
@@ -626,6 +626,12 @@ static int edac_dev_feat_init(struct device *parent,case RAS_FEAT_PPR : dev_data->ppr_ops = ras_feat->ppr_ops; dev_data->private = ras_feat->ppr_ctx; + + ret =edac_ppr_get_desc (parent, attr_groups, + ras_feat->instance); +if (ret) +return ret; +return 1 ;default :return -EINVAL ;
drivers/edac/edac_ppr.c new file +255 -0
255 lines not on this page · raw message
include/linux/edac.h +29 -0
@@ -739,6 +739,35 @@ int edac_ecs_get_desc(struct device *ecs_dev,const struct attribute_group **attr_groups, u16 num_media_frus); +enum edac_ppr_type { +EDAC_TYPE_SPPR ,/* soft PPR */ +EDAC_TYPE_HPPR ,/* hard PPR */ +}; + +/** +* struct edac_ppr_ops - PPR(Post Package Repair) device operations +* (all elements optional) +* @get_persist_mode_avail: get the persist modes supported in the device. +* @get_persist_mode: get the persist mode of the PPR instance. +* @set_persist_mode: set the persist mode for the PPR instance. +* @get_dpa_support: get dpa support flag. +* @get_ppr_safe_when_in_use: get whether memory media is accessible and +* data is retained during PPR operation. +* @do_ppr: start PPR operation for the HPA/DPA set. +*/ +struct edac_ppr_ops { +int (*get_persist_mode_avail)(struct device *dev,void *drv_data,char *buf); +int (*get_persist_mode)(struct device *dev,void *drv_data,u32 *mode); +int (*set_persist_mode)(struct device *dev,void *drv_data,u32 mode); +int (*get_dpa_support)(struct device *dev,void *drv_data,u32 *val); +int (*get_ppr_safe_when_in_use)(struct device *dev,void *drv_data,u32 *val); +int (*do_ppr)(struct device *dev,void *drv_data,bool hpa,u64 pa); +}; + +int edac_ppr_get_desc (struct device *ppr_dev, +const struct attribute_group **attr_groups, +u8 instance); +/* * EDAC device feature information structure */
Signature · 1 line
2.34.1
PATCH v11 13/14 cxl/mbox: Add support for PERFORM_MAINTENANCE mailbox command
In reply to [email protected]From: Shiju Jose <[email protected]>
Add support for PERFORM_MAINTENANCE mailbox command.
CXL spec 3.1 section 8.2.9.7.1 describes the Perform Maintenance command. This command requests the device to execute the maintenance operation specified by the maintenance operation class and the maintenance operation subclass.
--- drivers/cxl/core/mbox.c | 39 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 17 +++++++++++++++++ 2 files changed, 56 insertions(+)
drivers/cxl/core/mbox.c +39 -0
@@ -1504,6 +1504,45 @@ int cxl_set_feature(struct cxl_memdev_state *mds, }EXPORT_SYMBOL_NS_GPL (cxl_set_feature,CXL ); +int cxl_do_maintenance (struct cxl_memdev_state *mds, +u8 class,u8 subclass, +void *data_in,size_t data_in_size) +{ +struct cxl_memdev_maintenance_pi { +struct cxl_mbox_do_maintenance_hdr hdr; +u8 data[]; + } __packed; +struct cxl_mbox_cmd mbox_cmd; +size_t hdr_size; +int rc =0 ; + + struct cxl_memdev_maintenance_pi *pi __free(kfree) = +kmalloc (mds->payload_size,GFP_KERNEL ); + pi->hdr.op_class = class; + pi->hdr.op_subclass = subclass; + hdr_size =sizeof (pi->hdr); +/* +* Check minimum mbox payload size is available for +* the maintenance data transfer. +*/ +if (hdr_size + data_in_size > mds->payload_size) +return -ENOMEM ; + +memcpy (pi->data, data_in, data_in_size); + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_DO_MAINTENANCE , + .size_in = hdr_size + data_in_size, + .payload_in = pi, + }; + + rc =cxl_internal_send_cmd (mds, &mbox_cmd); +if (rc <0 ) +return rc; + +return 0 ; +} +EXPORT_SYMBOL_NS_GPL (cxl_do_maintenance,CXL ); +int cxl_mem_get_poison (struct cxl_memdev *cxlmd,u64 offset,u64 len,struct cxl_region *cxlr) {
drivers/cxl/cxlmem.h +17 -0
@@ -534,6 +534,7 @@ enum cxl_opcode {CXL_MBOX_OP_GET_SUPPORTED_FEATURES =0x0500 ,CXL_MBOX_OP_GET_FEATURE =0x0501 ,CXL_MBOX_OP_SET_FEATURE =0x0502 , +CXL_MBOX_OP_DO_MAINTENANCE =0x0600 ,CXL_MBOX_OP_IDENTIFY =0x4000 ,CXL_MBOX_OP_GET_PARTITION_INFO =0x4100 , CXL_MBOX_OP_SET_PARTITION_INFO = 0x4101,
@@ -811,6 +812,19 @@ struct cxl_mbox_set_feat_hdr {u8 rsvd[9 ]; } __packed; +/* +* Perform Maintenance CXL 3.1 Spec 8.2.9.7.1 +*/ + +/* +* Perform Maintenance input payload +* CXL rev 3.1 section 8.2.9.7.1 Table 8-102 +*/ +struct cxl_mbox_do_maintenance_hdr { +u8 op_class; +u8 op_subclass; +} __packed; +/* Get Poison List CXL 3.0 Spec 8.2.9.8.4.1 */ struct cxl_mbox_poison_in {__le64 offset;
@@ -955,6 +969,9 @@ 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_do_maintenance (struct cxl_memdev_state *mds, +u8 class,u8 subclass, +void *data_in,size_t data_in_size);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
PATCH v11 14/14 cxl/memfeature: Add CXL memory device PPR control feature
In reply to [email protected]From: Shiju Jose <[email protected]>
Post Package Repair (PPR) maintenance operations may be supported by CXL devices that implement CXL.mem protocol. A PPR maintenance operation requests the CXL device to perform a repair operation on its media. For example, a CXL device with DRAM components that support PPR features may implement PPR Maintenance operations. DRAM components may support two types of PPR: Hard PPR (hPPR), for a permanent row repair, and Soft PPR (sPPR), for a temporary row repair. sPPR is much faster than hPPR, but the repair is lost with a power cycle.
During the execution of a PPR Maintenance operation, a CXL memory device:
- May or may not retain data
- May or may not be able to process CXL.mem requests correctly, including the ones that target the DPA involved in the repair.
These CXL Memory Device capabilities are specified by Restriction Flags in the sPPR Feature and hPPR Feature.
sPPR maintenance operation may be executed at runtime, if data is retained and CXL.mem requests are correctly processed. For CXL devices with DRAM components, hPPR maintenance operation may be executed only at boot because data would not be retained.
When a CXL device identifies a failure on a memory component, the device may inform the host about the need for a PPR maintenance operation by using an Event Record, where the Maintenance Needed flag is set. The Event Record specifies the DPA that should be repaired. A CXL device may not keep track of the requests that have already been sent and the information on which DPA should be repaired may be lost upon power cycle.
The userspace tool requests for maintenance operation if the number of corrected error reported on a CXL.mem media exceeds error threshold.
CXL spec 3.1 section 8.2.9.7.1.2 describes the device's sPPR (soft PPR) maintenance operation and section 8.2.9.7.1.3 describes the device's hPPR (hard PPR) maintenance operation feature.
CXL spec 3.1 section 8.2.9.7.2.1 describes the sPPR feature discovery and configuration.
CXL spec 3.1 section 8.2.9.7.2.12 describes the hPPR feature discovery and configuration.
Add support for CXL memory device PPR control.
Register with EDAC driver, which gets the PPR attr descriptors from the EDAC PPR and expose sysfs PPR control attributes to the userspace. For example CXL PPR control for the CXL mem0 device is exposed in /sys/bus/edac/devices/cxl_mem0/pprX/
Tested with QEMU patch for CXL PPR feature.
https://lore.kernel.org/all/[email protected]/
--- drivers/cxl/core/memfeature.c | 279 +++++++++++++++++++++++++++++++++- 1 file changed, 278 insertions(+), 1 deletion(-)
drivers/cxl/core/memfeature.c +278 -1
@@ -18,8 +18,9 @@#include <linux/limits.h> #include <cxl.h> #include <linux/edac.h> +#include "core.h" -#define CXL_DEV_NUM_RAS_FEATURES 2 +#define CXL_DEV_NUM_RAS_FEATURES 3#define CXL_DEV_HOUR_IN_SECS 3600#define CXL_SCRUB_NAME_LEN 128
@@ -708,6 +709,249 @@ static const struct edac_ecs_ops cxl_ecs_ops = { .set_threshold = cxl_ecs_set_threshold, }; +/* CXL memory soft PPR & hard PPR control definitions */ +static const uuid_t cxl_sppr_uuid = +UUID_INIT (0x892ba475 ,0xfad8 ,0x474e ,0x9d ,0x3e ,0x69 ,0x2c ,0x91 , \ +0x75 ,0x68 ,0xbb ); + +static const uuid_t cxl_hppr_uuid = +UUID_INIT (0x80ea4521 ,0x786f ,0x4127 ,0xaf ,0xb1 ,0xec ,0x74 ,0x59 , \ +0xfb ,0x0e ,0x24 ); + +struct cxl_ppr_context { +uuid_t ppr_uuid; +u8 instance; +u16 get_feat_size; +u16 set_feat_size; +u8 get_version; +u8 set_version; +u16 set_effects; +struct cxl_memdev *cxlmd; +enum edac_ppr_type ppr_type; +u64 dpa; +u32 nibble_mask; +}; + +/** +* struct cxl_memdev_ppr_params - CXL memory PPR parameter data structure. +* @op_class[OUT]: PPR operation class. +* @op_subclass[OUT]: PPR operation subclass. +* @dpa_support[OUT]: device physical address for PPR support. +* @media_accessible[OUT]: memory media is accessible or not during PPR operation. +* @data_retained[OUT]: data is retained or not during PPR operation. +* @dpa:[IN]: device physical address. +*/ +struct cxl_memdev_ppr_params { +u8 op_class; +u8 op_subclass; +bool dpa_support; +bool media_accessible; +bool data_retained; +u64 dpa; +}; + +enum cxl_ppr_param { +CXL_PPR_PARAM_DO_PPR , +}; + +#define CXL_MEMDEV_PPR_QUERY_RESOURCE_FLAG BIT(0) + +#define CXL_MEMDEV_PPR_DEVICE_INITIATED_MASK BIT(0) +#define CXL_MEMDEV_PPR_FLAG_DPA_SUPPORT_MASK BIT(0) +#define CXL_MEMDEV_PPR_FLAG_NIBBLE_SUPPORT_MASK BIT(1) +#define CXL_MEMDEV_PPR_FLAG_MEM_SPARING_EV_REC_SUPPORT_MASK BIT(2) + +#define CXL_MEMDEV_PPR_RESTRICTION_FLAG_MEDIA_ACCESSIBLE_MASK BIT(0) +#define CXL_MEMDEV_PPR_RESTRICTION_FLAG_DATA_RETAINED_MASK BIT(2) + +#define CXL_MEMDEV_PPR_SPARING_EV_REC_EN_MASK BIT(0) + +struct cxl_memdev_ppr_rd_attrs { +u8 max_op_latency; +__le16 op_cap; +__le16 op_mode; +u8 op_class; +u8 op_subclass; +u8 rsvd[9 ]; +u8 ppr_flags; +__le16 restriction_flags; +u8 ppr_op_mode; +} __packed; + +struct cxl_memdev_ppr_wr_attrs { +__le16 op_mode; +u8 ppr_op_mode; +} __packed; + +struct cxl_memdev_ppr_maintenance_attrs { +u8 flags; +__le64 dpa; +u8 nibble_mask[3 ]; +} __packed; + +static int cxl_mem_ppr_get_attrs (struct device *dev,void *drv_data, +struct cxl_memdev_ppr_params *params) +{ +struct cxl_ppr_context *cxl_ppr_ctx = drv_data; +struct cxl_memdev *cxlmd = cxl_ppr_ctx->cxlmd; +struct cxl_dev_state *cxlds = cxlmd->cxlds; +struct cxl_memdev_state *mds =to_cxl_memdev_state (cxlds); +size_t rd_data_size =sizeof (struct cxl_memdev_ppr_rd_attrs ); +size_t data_size; + struct cxl_memdev_ppr_rd_attrs *rd_attrs __free(kfree) = +kmalloc (rd_data_size,GFP_KERNEL ); +if (!rd_attrs) +return -ENOMEM ; + + data_size =cxl_get_feature (mds, cxl_ppr_ctx->ppr_uuid, +CXL_GET_FEAT_SEL_CURRENT_VALUE , + rd_attrs, rd_data_size); +if (!data_size) +return -EIO ; + + params->op_class = rd_attrs->op_class; + params->op_subclass = rd_attrs->op_subclass; + params->dpa_support =FIELD_GET (CXL_MEMDEV_PPR_FLAG_DPA_SUPPORT_MASK , + rd_attrs->ppr_flags); + params->media_accessible =FIELD_GET (CXL_MEMDEV_PPR_RESTRICTION_FLAG_MEDIA_ACCESSIBLE_MASK , + rd_attrs->restriction_flags) ^1 ; + params->data_retained =FIELD_GET (CXL_MEMDEV_PPR_RESTRICTION_FLAG_DATA_RETAINED_MASK , + rd_attrs->restriction_flags) ^1 ; + +return 0 ; +} + +static int cxl_mem_ppr_set_attrs (struct device *dev,void *drv_data, +struct cxl_memdev_ppr_params *params, +enum cxl_ppr_param param_type) +{ +struct cxl_memdev_ppr_maintenance_attrs maintenance_attrs; +struct cxl_ppr_context *cxl_ppr_ctx = drv_data; +struct cxl_memdev *cxlmd = cxl_ppr_ctx->cxlmd; +struct cxl_dev_state *cxlds = cxlmd->cxlds; +struct cxl_memdev_state *mds =to_cxl_memdev_state (cxlds); +struct cxl_memdev_ppr_params rd_params; +struct cxl_region *cxlr; +int ret; + + ret =cxl_mem_ppr_get_attrs (dev, drv_data, &rd_params); +if (ret) { +dev_err (dev,"Get cxlmemdev PPR params failed ret=%d\n" , + ret); +return ret; + } + +switch (param_type) { +case CXL_PPR_PARAM_DO_PPR : + ret =down_read_interruptible (&cxl_region_rwsem); +if (ret) +return ret; +if (!rd_params.media_accessible || !rd_params.data_retained) { +/* Check if DPA is mapped */ + ret =down_read_interruptible (&cxl_dpa_rwsem); +if (ret) { +up_read (&cxl_region_rwsem); +return ret; + } + + cxlr =cxl_dpa_to_region (cxlmd, cxl_ppr_ctx->dpa); +up_read (&cxl_dpa_rwsem); +if (cxlr) { +dev_err (dev,"CXL can't do PPR as DPA is mapped\n" ); +up_read (&cxl_region_rwsem); +return -EBUSY ; + } + } + maintenance_attrs.flags =CXL_MEMDEV_PPR_QUERY_RESOURCE_FLAG ; + maintenance_attrs.dpa = params->dpa; +/* May need to get the nibble mask from the CXL dram error record via +* trace dram event. Presently all nibble masks bits set to 1. +*/ + maintenance_attrs.nibble_mask[0 ] =0xFF ; + maintenance_attrs.nibble_mask[1 ] =0xFF ; + maintenance_attrs.nibble_mask[2 ] =0xFF ; + ret =cxl_do_maintenance (mds, rd_params.op_class, rd_params.op_subclass, + &maintenance_attrs,sizeof (maintenance_attrs)); +if (ret) { +dev_err (dev,"CXL do PPR maintenance failed ret=%d\n" , ret); +up_read (&cxl_region_rwsem); +return ret; + } +up_read (&cxl_region_rwsem); +return 0 ; +default : +return -EINVAL ; + } +} + +static int cxl_ppr_get_persist_mode_avail (struct device *dev,void *drv_data, +char *buf) +{ +return sysfs_emit (buf,"Soft PPR Hard PPR\n" ); +} + +static int cxl_ppr_get_persist_mode (struct device *dev,void *drv_data, +u32 *persist_mode) +{ +struct cxl_ppr_context *cxl_ppr_ctx = drv_data; + + *persist_mode = cxl_ppr_ctx->ppr_type; + +return 0 ; +} + +static int cxl_ppr_get_dpa_support (struct device *dev,void *drv_data, +u32 *dpa_support) +{ +struct cxl_memdev_ppr_params params; +int ret; + + ret =cxl_mem_ppr_get_attrs (dev, drv_data, ¶ms); +if (ret) +return ret; + + *dpa_support = params.dpa_support; + +return 0 ; +} + +static int cxl_get_ppr_safe_when_in_use (struct device *dev,void *drv_data, +u32 *safe) +{ +struct cxl_memdev_ppr_params params; +int ret; + + ret =cxl_mem_ppr_get_attrs (dev, drv_data, ¶ms); +if (ret) +return ret; + + *safe = params.media_accessible & params.data_retained; + +return 0 ; +} + +static int cxl_do_ppr (struct device *dev,void *drv_data,bool hpa,u64 pa) +{ +struct cxl_memdev_ppr_params params = { + .dpa = pa, + }; + +/* CXL mem perform PPR, need support for HPA? */ +if (hpa) +return -EOPNOTSUPP ; + +return cxl_mem_ppr_set_attrs (dev, drv_data, ¶ms, +CXL_PPR_PARAM_DO_PPR ); +} + +static const struct edac_ppr_ops cxl_sppr_ops = { + .get_persist_mode_avail = cxl_ppr_get_persist_mode_avail, + .get_persist_mode = cxl_ppr_get_persist_mode, + .get_dpa_support = cxl_ppr_get_dpa_support, + .get_ppr_safe_when_in_use = cxl_get_ppr_safe_when_in_use, + .do_ppr = cxl_do_ppr, +}; +int cxl_mem_ras_features_init (struct cxl_memdev *cxlmd,struct cxl_region *cxlr) {struct edac_dev_feature ras_features[CXL_DEV_NUM_RAS_FEATURES ];
@@ -717,8 +961,10 @@ int cxl_mem_ras_features_init(struct cxl_memdev *cxlmd, struct cxl_region *cxlr)struct cxl_mbox_supp_feat_entry feat_entry;char cxl_dev_name[CXL_SCRUB_NAME_LEN ];struct cxl_ecs_context *cxl_ecs_ctx; +struct cxl_ppr_context *cxl_sppr_ctx;int rc, i, num_ras_features =0 ;int num_media_frus; +u8 ppr_inst =0 ;if (cxlr) {struct cxl_region_params *p = &cxlr->params;
@@ -804,6 +1050,37 @@ int cxl_mem_ras_features_init(struct cxl_memdev *cxlmd, struct cxl_region *cxlr) ras_features[num_ras_features].ecs_info.num_media_frus = num_media_frus; num_ras_features++; + +/* CXL sPPR */ + rc =cxl_get_supported_feature_entry (mds, &cxl_sppr_uuid, + &feat_entry); +if (rc <0 ) + goto feat_register; + +if (!(feat_entry.attr_flags &CXL_FEAT_ENTRY_FLAG_CHANGABLE )) + goto feat_register; + + cxl_sppr_ctx =devm_kzalloc (&cxlmd->dev,sizeof (*cxl_sppr_ctx), +GFP_KERNEL ); +if (!cxl_sppr_ctx) + goto feat_register; + *cxl_sppr_ctx = (struct cxl_ppr_context ) { + .ppr_uuid = cxl_sppr_uuid, + .get_feat_size = feat_entry.get_size, + .set_feat_size = feat_entry.set_size, + .get_version = feat_entry.get_version, + .set_version = feat_entry.set_version, + .set_effects = feat_entry.set_effects, + .cxlmd = cxlmd, + .ppr_type =EDAC_TYPE_SPPR , + .instance = ppr_inst++, + }; + + ras_features[num_ras_features].feat =RAS_FEAT_PPR ; + ras_features[num_ras_features].instance = cxl_sppr_ctx->instance; + ras_features[num_ras_features].ppr_ops = &cxl_sppr_ops; + ras_features[num_ras_features].ppr_ctx = cxl_sppr_ctx; + num_ras_features++; } feat_register:
Signature · 1 line
2.34.1
kernel test robot
build botRe: [PATCH v11 14/14] cxl/memfeature: Add CXL memory device PPR control feature
kernel test robot noticed the following build warnings:
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on ras/edac-for-next]
[also build test WARNING on rafael-pm/linux-next rafael-pm/bleeding-edge cxl/next linus/master v6.11-rc3 next-20240816] [cannot apply to cxl/pending]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/shiju-jose-huawei-com/EDAC-Add-support-for-EDAC-device-feature-s-control/20240817-004442 base: https://git.kernel.org/pub/scm/linux/kernel/git/ras/ras.git edac-for-next patch link: https://lore.kernel.org/r/20240816164238.1902-15-shiju.jose%40huawei.com patch subject: [PATCH v11 14/14] cxl/memfeature: Add CXL memory device PPR control feature config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20240818/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240818/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/cxl/core/memfeature.c:717:21: warning: 'cxl_hppr_uuid' defined but not used [-Wunused-const-variable=]
717 | static const uuid_t cxl_hppr_uuid =
| ^~~~~~~~~~~~~
vim +/cxl_hppr_uuid +717 drivers/cxl/core/memfeature.c
711
712 /* CXL memory soft PPR & hard PPR control definitions */
713 static const uuid_t cxl_sppr_uuid =
714 UUID_INIT(0x892ba475, 0xfad8, 0x474e, 0x9d, 0x3e, 0x69, 0x2c, 0x91, \
715 0x75, 0x68, 0xbb);
716
> 717 static const uuid_t cxl_hppr_uuid =
718 UUID_INIT(0x80ea4521, 0x786f, 0x4127, 0xaf, 0xb1, 0xec, 0x74, 0x59, \
719 0xfb, 0x0e, 0x24);
720
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki