EDAC: Scrub: introduce generic EDAC RAS control feature driver + CXL/ACPI-RAS2 drivers
Subsystems (7)
v17 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 features control attributes to userspace in sysfs. Some Examples:
- Scrub control
- Error Check Scrub (ECS) control
- ACPI RAS2 features
- Post Package Repair (PPR) control
- Memory Sparing Repair control etc.
High level design is illustrated in the following diagram.
_______________________________________________
| Userspace - Rasdaemon |
| ____________ |
| | RAS CXL | _______________ |
| | Err Handler|----->| | |
| |____________| | RAS Dynamic | |
| ____________ | Scrub, Memory | |
| | RAS Memory |----->| Repair Control| |
| | Err Handler| |_______________| |
| |____________| | |
|__________________________|____________________|
|
|
_______________________________|______________________________
| Kernel EDAC based SubSystem | for RAS Features Control |
| ______________________________|____________________________ |
|| EDAC Core Sysfs EDAC| Bus | |
|| __________________________|________ _ _____________ | |
|| |/sys/bus/edac/devices/<dev>/scrubX/ | | EDAC Device || |
|| |/sys/bus/edac/devices/<dev>/ecsX/ |<->| EDAC MC || |
|| |/sys/bus/edac/devices/<dev>/repairX | | EDAC Sysfs || |
|| |____________________________________| |_____________|| |
|| | EDAC Bus | |
|| Get | Get | |
|| __________ Features | Features __________ | |
|| | |Descs _________|______ Descs| | | |
|| |EDAC Scrub|<-----| EDAC Device | | EDAC Mem | | |
|| |__________| | Driver- RAS |---->| Repair | | |
|| __________ | Feature Control| |__________| | |
|| | |<-----|________________| | |
|| |EDAC ECS | Register RAS | Features | |
|| |__________| | | |
|| ______________________|_________ | |
||_________|_____________|________________|__________________| |
| _______|____ _____|_________ ____|_________ |
| | | | CXL Mem Driver| | Client Driver| |
| | ACPI RAS2 | | Sparing, PPR, | | Mem Repair | |
| | Driver | | Scrub, ECS | | Features | |
| |____________| |_______________| |______________| |
| | | | |
|________|______________|______________|_______________________|
| | |
_______|______________|______________|_______________________
| __|______________|_ ____________|____________ ____ |
| | | |
| | Platform HW and Firmware | |
| |__________________________________________________| |
|_____________________________________________________________| 1. EDAC RAS Features components - Create feature specific descriptors. for example, EDAC scrub, EDAC ECS, EDAC memory repair in the above diagram.
2. EDAC device driver for controlling RAS Features - Get feature's attr descriptors from 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 for scrub control in rasdaemon to issue scrubbing when excess number of memory errors are reported in a short span of time.
The added EDAC feature specific components (e.g. EDAC scrub, EDAC ECS, EDAC memory repair 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 whilst 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. The common sysfs scrub control interface abstracts the control of an arbitrary scrubbing functionality to a common set of functions.
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 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 added in rasdaemon for dynamic scrub control, based on frequency of memory errors reported to userspace, tested for CXL device based patrol scrubbing feature and ACPI RAS2 based scrubbing feature.
https://github.com/shijujose4/rasdaemon/tree/ras_feature_control
ToDO: For memory repair features, such as PPR, memory sparing, 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 some CXL event records.
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 . . . . .
................................................................
*(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 Memory Scrubbing features
=============================
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. During the execution of a PPR maintenance operation, a memory device, may or may not retain data and may or may not be able to process memory requests correctly. sPPR maintenance operation may be executed at runtime, if data is retained and memory requests are correctly processed. hPPR maintenance operation may be executed only at boot because data would not be retained.
Use cases of common PPR control feature
=======================================
1. The Soft PPR (sPPR) and Hard PPR (hPPR) share similar control interfaces, thus there is a requirement for a standard generic sysfs PPR controls exposed to userspace for the seamless control of the PPR features in the system by the admin/scripts/tools etc.
2. 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. Kernel reports the corresponding cxl general media or DRAM trace event to userspace. The userspace tool, for reg. rasdaemon initiate a PPR maintenance operation in response to a device request using the sysfs PPR control.
3. User space tools, for eg. rasdaemon, do request PPR on a memory region when uncorrected memory error or excess corrected memory errors reported on that memory.
4. Likely multiple instances of PPR present per memory device.
Memory Sparing
==============
Memory sparing is defined as a repair function that replaces a portion of memory with a portion of functional memory at that same DPA. User space tool, e.g. rasdaemon, may request the sparing operation for a given address for which the uncorrectable error is reported. In CXL, (CXL spec 3.1 section 8.2.9.7.1.4) subclasses for sparing operation vary in terms of the scope of the sparing being performed. The cacheline sparing subclass refers to a sparing action that can replace a full cacheline. Row sparing is provided as an alternative to PPR sparing functions and its scope is that of a single DDR row. Bank sparing allows an entire bank to be replaced. Rank sparing is defined as an operation in which an entire DDR rank is replaced.
Series adds,
1. EDAC device driver extended for controlling RAS features, EDAC scrub driver, EDAC ECS driver, EDAC memory repair driver supports memory scrub control, ECS control, memory repair(PPR, sparing) control respectively.
2. Several common patches from Dave's cxl/fwctl series.
3. Support for CXL feature mailbox commands, which is used by CXL device scrubbing and memory repair features.
4. CXL features driver supporting patrol scrub control (device and region based).
5. CXL features driver supporting ECS control feature.
6. 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 device 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 memory repair feature.
9. CXL features driver supporting PPR control feature.
10. CXL features driver supporting memory sparing control feature.
Note: There are other PPR, memory sparing drivers to come.
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 userspace. Left as future extension.
- For EDAC memory repair, control attribute for granularity(cache/row//bank/rank) is needed?
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 after all.
- "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 after all. As per LPC discussion, support for stop and attributes for addr range to be exposed to the userspace.
4. Borislav:
- How the scrub control exposed to userspace will be used?
POC added in rasdaemon with dynamic scrub control for CXL memory media errors and memory errors reported to 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.
Implementation
==============
1. Linux kernel
Version 14 of kernel implementations of RAS features control is available in,
https://github.com/shijujose4/linux.git
Branch: edac-enhancement-ras-features_v17
2. QEMU emulation
QEMU for CXL RAS features implementation is available in,
https://gitlab.com/shiju.jose/qemu.git
Branch: cxl-ras-features-2024-10-24
3. Userspace rasdaemon
The draft version of userspace sample code for dynamic scrub control, based on frequency of memory errors reported to userspace, is added in rasdaemon and enabled, tested for CXL device based patrol scrubbing feature and ACPI RAS2 based scrubbing feature. This required updation for the latest sysfs scrub interface.
https://github.com/shijujose4/rasdaemon/tree/ras_feature_control
ToDO: 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.
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. CXL spec r3.1 8.2.9.7.1.1 PPR Maintenance Operations 6. CXL spec r3.1 8.2.9.7.2.1 sPPR Feature Discovery and Configuration 7. CXL spec r3.1 8.2.9.7.2.2 hPPR Feature Discovery and Configuration
8. Background information about kernel support for memory scan, memory error detection and ACPI RASF.
https://lore.kernel.org/all/[email protected]/
9. Discussions on RASF:
https://lore.kernel.org/lkml/[email protected]/#r
Changes
=======
v16 -> v17:
1.
1.1 Took several patches for CXL feature commands from Dave's
fwctl/cxl series and add fixes pointed by Jonathan in those patches.
1.2. cxl/core/memfeature.c updated for interface changes in the
Get Supported Feature, Get Feature and Set Feature functions.
1.3. Used the UUID's for RAS features in CXL features code from
include/cxl/features.h
2. Changes based on feedbacks from Boris
- Added attributes in EDAC memory repair to return the range for DPA and other control attributes, and added callback functions for the DPA range in CXL PPR and memory sparing code, which is the only one supported in the CXL.
- Removed 'query' attribute for memory repair feature.
v15 -> v16:
1. Changes and Fixes for feedbacks from Boris
- Modified documentations and interface file for EDAC memory repair
to add more details and use cases.
- Merged documentations to corresponding patches instead of common patch for full documentation for better readability.
- Removed 'persist_mode_avail' attribute for memory repair feature.
2. Changes for feedback from Dave Jiang
- Dave suggested helper function for ECS initialization in cxl/core/memfeature.c, which added for all CXl RAS features, scrub, ECS, PPR and memory sparing features.
- Fixed endian conversion pointed by Dave in CXL memory sparing. Also I fixed similar in CXL scrub, ECS and PPR features.
3. Changes for feedback from Ni Fan.
- Fixed a memory leak in edac_dev_register() for memory repair feature and few suggestions by Ni Fan.
v14 -> v15:
1. Changes and Fixes for feedbacks from Boris
- Added documentations for edac features, scrub and memory_repair etc and placed in a separate patch.
- Deleted extra 2 attributes for EDAC ECS log_entry_type_per_* and
mode_counts_*.
- Rsolved issues reported in Documentation/ABI/testing/sysfs-edac-ecs.
- Deleted unused pr_ftmt() from few files.
- Fixed some formating issues EDAC ECS code and similar in other files. etc.
2. Change for feedback from Dave Jiang
- In CXL code for patrol scrub control, Dave suggested replace void *drv_data with a union of parameters in cxl_ps_get_attrs() and similar functions.
This is fixed by replacing void *drv_data with corresponding context structure(struct cxl_patrol_scrub_context) in CXL local functions as struct cxl_patrol_scrub_context difficult and can't be visible in generic EDAC control interface. Similar changes are made for CXL ECS, CXL PPR and CXL memory sparing local functions.
v13 -> v14:
1. Changes and Fixes for feedback from Boris
- Check grammar of patch description.
- Changed scrub control attributes for memory scrub range to "addr" and "size".
- Fixed unreached code in edac_dev_register().
- Removed enable_on_demand attribute from EDAC scrub control and modified RAS2 driver for the same.
- Updated ABI documentation for EDAC scrub control.
etc.
2. Changes for feedback from Greg/Rafael/Jonathan for ACPI RAS2
- Replaced platform device creation and binding with auxiliary device creation and binding with ACPI RAS2 memory auxiliary driver.
3. Changes and Fixes for feedback from Jonathan
- Fixed unreached code in edac_dev_register().
- Optimize callback functions in CXL ECS using macros.
- Add readback attributes for the EDAC memory repair feature and add support in the CXL driver for PPR and memory sparing.
- Add refactoring in the CXL driver for PPR and memory sparing for query/repair maintenance commands.
- Add cxl_dpa_to_region_locked() function.
- Some more cleanups in the ACPI RAS2 and RAS2 memory drivers. etc.
4. Changes and Fixes for feedback from Ni Fan
- Fixed compilation error - cxl_mem_ras_features_init refined, when CXL components build as module.
5. Optimize callback functions in CXL memory sparing using macros. etc.
v12 -> v13:
1. Changes and Fixes for feedback from Boris
- Function edac_dev_feat_init() merge with edac_dev_register()
- Add macros in EDAC feature specific code for repeated code.
- Correct spelling mistakes.
- Removed feature specific code from the patch "EDAC: Add support for EDAC device features control"
2. Changes for feedbacks from Dave Jiang
- Move fields num_features and entries to struct cxl_mailbox, in "cxl: Add Get Supported Features command for kernel usage"
- Use series from
https://lore.kernel.org/linux-cxl/[email protected]/
3. Changes and Fixes for feedback from Ni Fan
- In documentation scrub* to scrubX, ecs_fru* to ecs_fruX
- Corrected some grammar mistakes in the patch headers.
- Fixed an error print for min_scrub_cycle_hrs in the CXL patrol scrub code.
- Improved an error print in the CXL ECS code.
- bool -> tristate for config CXL_RAS_FEAT
4. Add support for CXL memory sparing feature.
5. Add common EDAC memory repair driver for controlling memory repair features, PPR, memory sparing etc.
v11 -> v12:
1. Changes and Fixes for feedback from Boris mainly for patch "EDAC: Add support for EDAC device features control" and other generic comments.
2. Took CXL patches from Dave Jiang for "Add Get Supported Features command for kernel usage" and other related patches. Merged helper functions from this series to the above patch. Modifications of CXL code in this series due to refactoring of CXL mailbox in Dave's patches.
3. Modified EDAC scrub control code to support multiple scrub instances per device.
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_available 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 available here.
https://lore.kernel.org/lkml/[email protected]/
Dave Jiang (5):
cxl: Refactor user ioctl command path from mds to mailbox
cxl: Add Get Supported Features command for kernel usage
cxl: Add Get Feature command support for user submission
cxl: Add Set Feature command support for user submission
cxl: Add UUIDs for the CXL RAS features
Shiju Jose (13):
EDAC: Add support for EDAC device features control
EDAC: Add scrub control feature
EDAC: Add ECS control feature
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 memory repair control feature
cxl/mbox: Add support for PERFORM_MAINTENANCE mailbox command cxl/memfeature: Add CXL memory device soft PPR control feature cxl/memfeature: Add CXL memory device memory sparing control feature
Documentation/ABI/testing/sysfs-edac-ecs | 63 + .../ABI/testing/sysfs-edac-memory-repair | 245 +++ Documentation/ABI/testing/sysfs-edac-scrub | 74 + Documentation/edac/features.rst | 102 + Documentation/edac/index.rst | 12 + Documentation/edac/memory_repair.rst | 249 +++ Documentation/edac/scrub.rst | 393 ++++ drivers/acpi/Kconfig | 11 + drivers/acpi/Makefile | 1 + drivers/acpi/ras2.c | 409 ++++ drivers/cxl/Kconfig | 18 + drivers/cxl/core/Makefile | 1 + drivers/cxl/core/core.h | 6 +- drivers/cxl/core/mbox.c | 421 ++++- drivers/cxl/core/memdev.c | 22 +- drivers/cxl/core/memfeature.c | 1653 +++++++++++++++++ drivers/cxl/core/region.c | 6 + drivers/cxl/cxlmem.h | 184 +- drivers/cxl/mem.c | 4 + drivers/cxl/pci.c | 4 + drivers/edac/Makefile | 1 + drivers/edac/ecs.c | 207 +++ drivers/edac/edac_device.c | 183 ++ drivers/edac/mem_repair.c | 492 +++++ drivers/edac/scrub.c | 209 +++ drivers/ras/Kconfig | 10 + drivers/ras/Makefile | 1 + drivers/ras/acpi_ras2.c | 385 ++++ include/acpi/ras2_acpi.h | 45 + include/cxl/features.h | 48 + include/cxl/mailbox.h | 45 +- include/linux/edac.h | 238 +++ include/uapi/linux/cxl_mem.h | 3 + 33 files changed, 5648 insertions(+), 97 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-edac-ecs create mode 100644 Documentation/ABI/testing/sysfs-edac-memory-repair create mode 100644 Documentation/ABI/testing/sysfs-edac-scrub create mode 100644 Documentation/edac/features.rst create mode 100644 Documentation/edac/index.rst create mode 100644 Documentation/edac/memory_repair.rst create mode 100644 Documentation/edac/scrub.rst create mode 100755 drivers/acpi/ras2.c create mode 100644 drivers/cxl/core/memfeature.c create mode 100755 drivers/edac/ecs.c create mode 100755 drivers/edac/mem_repair.c create mode 100755 drivers/edac/scrub.c create mode 100644 drivers/ras/acpi_ras2.c create mode 100644 include/acpi/ras2_acpi.h create mode 100644 include/cxl/features.h
Signature · 1 line
2.43.0
PATCH v17 1/18 EDAC: Add support for EDAC device features control
From: Shiju Jose <[email protected]>
Add generic EDAC device feature controls supporting the registration of RAS features available in the system. The driver exposes control attributes for these features to userspace in /sys/bus/edac/devices/<dev-name>/<ras-feature>/
--- Documentation/edac/features.rst | 94 ++++++++++++++++++++++++++++++ Documentation/edac/index.rst | 10 ++++ drivers/edac/edac_device.c | 100 ++++++++++++++++++++++++++++++++ include/linux/edac.h | 28 +++++++++ 4 files changed, 232 insertions(+) create mode 100644 Documentation/edac/features.rst create mode 100644 Documentation/edac/index.rst
Documentation/edac/features.rst new file +94 -0
@@ -0,0 +1,94 @@ +.. SPDX-License-Identifier: GPL-2.0 + +============================================ +Augmenting EDAC for controlling RAS features +============================================ + +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.13 + +Introduction +------------ +The expansion of EDAC for controlling RAS features and exposing features +control attributes to userspace via sysfs. Some Examples: + +* Scrub control + +* Error Check Scrub (ECS) control + +* ACPI RAS2 features + +* Post Package Repair (PPR) control + +* Memory Sparing Repair control etc. + +High level design is illustrated in the following diagram:: + + _______________________________________________ + | Userspace - Rasdaemon | + | _____________ | + | | RAS CXL mem | _______________ | + | |error handler|---->| | | + | |_____________| | RAS dynamic | | + | _____________ | scrub, memory | | + | | RAS memory |---->| repair control| | + | |error handler| |_______________| | + | |_____________| | | + |__________________________|____________________| + | + | + _______________________________|______________________________ + | Kernel EDAC extension for | controlling RAS Features | + | ______________________________|____________________________ | + || EDAC Core Sysfs EDAC| Bus | | + || __________________________|_________ _____________ | | + || |/sys/bus/edac/devices/<dev>/scrubX/ | | EDAC device || | + || |/sys/bus/edac/devices/<dev>/ecsX/ |<->| EDAC MC || | + || |/sys/bus/edac/devices/<dev>/repairX | | EDAC sysfs || | + || |____________________________________| |_____________|| | + || EDAC|Bus | | + || | | | + || __________ Get feature | Get feature | | + || | |desc _________|______ desc __________ | | + || |EDAC scrub|<-----| EDAC device | | | | | + || |__________| | driver- RAS |---->| EDAC mem | | | + || __________ | feature control| | repair | | | + || | |<-----|________________| |__________| | | + || |EDAC ECS | Register RAS|features | | + || |__________| | | | + || ______________________|_____________ | | + ||_________|_______________|__________________|______________| | + | _______|____ _______|_______ ____|__________ | + | | | | CXL mem driver| | Client driver | | + | | ACPI RAS2 | | scrub, ECS, | | memory repair | | + | | driver | | sparing, PPR | | features | | + | |____________| |_______________| |_______________| | + | | | | | + |________|_________________|____________________|______________| + | | | + ________|_________________|____________________|______________ + | ___|_________________|____________________|_______ | + | | | | + | | Platform HW and Firmware | | + | |__________________________________________________| | + |______________________________________________________________| + + +1. EDAC Features components - Create feature specific descriptors. +For example, EDAC scrub, EDAC ECS, EDAC memory repair in the above +diagram. + +2. EDAC device driver for controlling RAS Features - Get feature's attribute +descriptors from EDAC RAS feature component and registers device's RAS +features with EDAC bus and exposes the features control attributes via +the sysfs EDAC bus. For example, /sys/bus/edac/devices/<dev-name>/<feature>X/ + +3. RAS dynamic feature controller - Userspace sample modules in rasdaemon for +dynamic scrub/repair control to issue scrubbing/repair when excess number +of corrected memory errors are reported in a short span of time.
Documentation/edac/index.rst new file +10 -0
@@ -0,0 +1,10 @@ +.. SPDX-License-Identifier: GPL-2.0 + +============== +EDAC Subsystem +============== + +.. toctree:: + :maxdepth: 1 + + features
drivers/edac/edac_device.c +100 -0
103 lines not on this page · raw message
include/linux/edac.h +28 -0
@@ -661,4 +661,32 @@ static inline struct dimm_info *edac_get_dimm(struct mem_ctl_info *mci, return mci->dimms[index]; } + +#define EDAC_FEAT_NAME_LEN 128 + +/* RAS feature type */ +enum edac_dev_feat { +RAS_FEAT_MAX +}; + +/* EDAC device feature information structure */ +struct edac_dev_data { +u8 instance; +void *private; +}; + +struct edac_dev_feat_ctx { +struct device dev; +void *private; +}; + +struct edac_dev_feature { +enum edac_dev_feat ft_type; +u8 instance; +void *ctx; +}; + +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.43.0
PATCH v17 2/18 EDAC: Add scrub control feature
In reply to [email protected]From: Shiju Jose <[email protected]>
Add a generic EDAC scrub control to manage memory scrubbers in the system. Devices with a scrub feature register with the EDAC device driver, which retrieves the scrub descriptor from the EDAC scrub driver and exposes the sysfs scrub control attributes for a scrub instance to userspace at /sys/bus/edac/devices/<dev-name>/scrubX/.
The common sysfs scrub control interface abstracts the control of arbitrary scrubbing functionality into a common set of functions. The sysfs scrub attribute nodes are only present if the client driver has implemented the corresponding attribute callback function and passed the operations(ops) to the EDAC device driver during registration.
--- Documentation/ABI/testing/sysfs-edac-scrub | 74 +++++++ Documentation/edac/features.rst | 5 + Documentation/edac/index.rst | 1 + Documentation/edac/scrub.rst | 244 +++++++++++++++++++++ drivers/edac/Makefile | 1 + drivers/edac/edac_device.c | 41 +++- drivers/edac/scrub.c | 209 ++++++++++++++++++ include/linux/edac.h | 34 +++ 8 files changed, 605 insertions(+), 4 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-edac-scrub create mode 100644 Documentation/edac/scrub.rst create mode 100755 drivers/edac/scrub.c
Documentation/ABI/testing/sysfs-edac-scrub new file +74 -0
@@ -0,0 +1,74 @@ +What: /sys/bus/edac/devices/<dev-name>/scrubX +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + The sysfs EDAC bus devices /<dev-name>/scrubX subdirectory + belongs to an instance of memory scrub control feature, + where <dev-name> directory corresponds to a device/memory + region registered with the EDAC device driver for the + scrub control feature. + The sysfs scrub attr nodes are only present if the parent + driver has implemented the corresponding attr callback + function and provided the necessary operations to the EDAC + device driver during registration. + +What: /sys/bus/edac/devices/<dev-name>/scrubX/addr +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RW) The base address of the memory region to be scrubbed + for on-demand scrubbing. Setting address would start + scrubbing. The size must be set before that. + The readback addr value would be non-zero if the requested + on-demand scrubbing is in progress, zero otherwise. + +What: /sys/bus/edac/devices/<dev-name>/scrubX/size +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RW) The size of the memory region to be scrubbed + (on-demand scrubbing). + +What: /sys/bus/edac/devices/<dev-name>/scrubX/enable_background +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RW) Start/Stop background(patrol) scrubbing if supported. + +What: /sys/bus/edac/devices/<dev-name>/scrubX/enable_on_demand +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RW) Start/Stop on-demand scrubbing the memory region + if supported. + +What: /sys/bus/edac/devices/<dev-name>/scrubX/min_cycle_duration +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RO) Supported minimum scrub cycle duration in seconds + by the memory scrubber. + +What: /sys/bus/edac/devices/<dev-name>/scrubX/max_cycle_duration +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RO) Supported maximum scrub cycle duration in seconds + by the memory scrubber. + +What: /sys/bus/edac/devices/<dev-name>/scrubX/current_cycle_duration +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RW) The current scrub cycle duration in seconds and must be + within the supported range by the memory scrubber. + Scrub has an overhead when running and that may want to be + reduced by taking longer to do it.
Documentation/edac/features.rst +5 -0
@@ -92,3 +92,8 @@ the sysfs EDAC bus. For example, /sys/bus/edac/devices/<dev-name>/<feature>X/ 3. RAS dynamic feature controller - Userspace sample modules in rasdaemon for dynamic scrub/repair control to issue scrubbing/repair when excess number of corrected memory errors are reported in a short span of time. + +RAS features +------------ +1. Memory Scrub +Memory scrub features are documented in `Documentation/edac/scrub.rst`.
Documentation/edac/index.rst +1 -0
@@ -8,3 +8,4 @@ EDAC Subsystem :maxdepth: 1 features + scrub
Documentation/edac/scrub.rst new file +244 -0
244 lines not on this page · raw message
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 += scrub.o edac_core-$(CONFIG_EDAC_DEBUG) += debugfs.o
drivers/edac/edac_device.c +37 -4
84 lines not on this page · raw message
drivers/edac/scrub.c new file +209 -0
209 lines not on this page · raw message
include/linux/edac.h +34 -0
@@ -666,11 +666,43 @@ static inline struct dimm_info *edac_get_dimm(struct mem_ctl_info *mci,/* RAS feature type */ enum edac_dev_feat { +RAS_FEAT_SCRUB ,RAS_FEAT_MAX }; +/** +* struct edac_scrub_ops - scrub device operations (all elements optional) +* @read_addr: read base address of scrubbing range. +* @read_size: read offset of scrubbing range. +* @write_addr: set base address of the scrubbing range. +* @write_size: set offset of the scrubbing range. +* @get_enabled_bg: check if currently performing background scrub. +* @set_enabled_bg: start or stop a bg-scrub. +* @get_min_cycle: get minimum supported scrub cycle duration in seconds. +* @get_max_cycle: get maximum supported scrub cycle duration in seconds. +* @get_cycle_duration: get current scrub cycle duration in seconds. +* @set_cycle_duration: set current scrub cycle duration in seconds. +*/ +struct edac_scrub_ops { +int (*read_addr)(struct device *dev,void *drv_data,u64 *base); +int (*read_size)(struct device *dev,void *drv_data,u64 *size); +int (*write_addr)(struct device *dev,void *drv_data,u64 base); +int (*write_size)(struct device *dev,void *drv_data,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_min_cycle)(struct device *dev,void *drv_data,u32 *min); +int (*get_max_cycle)(struct device *dev,void *drv_data,u32 *max); +int (*get_cycle_duration)(struct device *dev,void *drv_data,u32 *cycle); +int (*set_cycle_duration)(struct device *dev,void *drv_data,u32 cycle); +}; + +int edac_scrub_get_desc (struct device *scrub_dev, +const struct attribute_group **attr_groups, +u8 instance); +/* EDAC device feature information structure */ struct edac_dev_data { +const struct edac_scrub_ops *scrub_ops;u8 instance;void *private; };
@@ -678,11 +710,13 @@ struct edac_dev_data {struct edac_dev_feat_ctx {struct device dev;void *private; +struct edac_dev_data *scrub; };struct edac_dev_feature {enum edac_dev_feat ft_type;u8 instance; +const struct edac_scrub_ops *scrub_ops;void *ctx; };
Signature · 1 line
2.43.0
PATCH v17 3/18 EDAC: Add ECS control feature
In reply to [email protected]From: Shiju Jose <[email protected]>
Add EDAC ECS (Error Check Scrub) control to manage a 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.
Memory devices support the ECS feature register with the EDAC device driver, which retrieves the ECS descriptor from the EDAC ECS driver. This driver exposes sysfs ECS control attributes to userspace via /sys/bus/edac/devices/<dev-name>/ecs_fruX/.
The common sysfs ECS control interface abstracts the control of an arbitrary ECS functionality to a common set of functions.
Support for the ECS feature is added separately because the control attributes of the DDR5 ECS feature differ from those of the scrub feature.
The sysfs ECS attribute nodes are only present if the client driver has implemented the corresponding attribute callback function and passed the necessary operations to the EDAC RAS feature driver during registration.
--- Documentation/ABI/testing/sysfs-edac-ecs | 63 +++++++ Documentation/edac/scrub.rst | 2 + drivers/edac/Makefile | 2 +- drivers/edac/ecs.c | 207 +++++++++++++++++++++++ drivers/edac/edac_device.c | 17 ++ include/linux/edac.h | 41 ++++- 6 files changed, 329 insertions(+), 3 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-edac-ecs create mode 100755 drivers/edac/ecs.c
Documentation/ABI/testing/sysfs-edac-ecs new file +63 -0
@@ -0,0 +1,63 @@ +What: /sys/bus/edac/devices/<dev-name>/ecs_fruX +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + The sysfs EDAC bus devices /<dev-name>/ecs_fruX subdirectory + pertains to the memory media ECS (Error Check Scrub) control + feature, where <dev-name> directory corresponds to a device + registered with the EDAC device driver for the ECS feature. + /ecs_fruX belongs to the media FRUs (Field Replaceable Unit) + under the memory device. + The sysfs ECS attr nodes are only present if the parent + driver has implemented the corresponding attr callback + function and provided the necessary operations to the EDAC + device driver during registration. + +What: /sys/bus/edac/devices/<dev-name>/ecs_fruX/log_entry_type +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RW) The log entry type of how the DDR5 ECS log is reported. + 0 - per DRAM. + 1 - per memory media FRU. + All other values are reserved. + +What: /sys/bus/edac/devices/<dev-name>/ecs_fruX/mode +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RW) The mode of how the DDR5 ECS counts the errors. + Error count is tracked based on two different modes + selected by DDR5 ECS Control Feature - Codeword mode and + Row Count mode. If the ECS is under Codeword mode, then + the error count increments each time a codeword with check + bit errors is detected. If the ECS is under Row Count mode, + then the error counter increments each time a row with + check bit errors is detected. + 0 - ECS counts rows in the memory media that have ECC errors. + 1 - ECS counts codewords with errors, specifically, it counts + the number of ECC-detected errors in the memory media. + All other values are reserved. + +What: /sys/bus/edac/devices/<dev-name>/ecs_fruX/reset +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (WO) ECS reset ECC counter. + 1 - reset ECC counter to the default value. + All other values are reserved. + +What: /sys/bus/edac/devices/<dev-name>/ecs_fruX/threshold +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RW) DDR5 ECS threshold count per gigabits of memory cells. + The ECS error count is subject to the ECS Threshold count + per Gbit, which masks error counts less than the Threshold. + Supported values are 256, 1024 and 4096. + All other values are reserved.
Documentation/edac/scrub.rst +2 -0
@@ -242,3 +242,5 @@ sysfs Sysfs files are documented in `Documentation/ABI/testing/sysfs-edac-scrub`. + +`Documentation/ABI/testing/sysfs-edac-ecs`.
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 += scrub.o +edac_core-y += scrub.o ecs.o edac_core-$(CONFIG_EDAC_DEBUG) += debugfs.o
drivers/edac/ecs.c new file +207 -0
207 lines not on this page · raw message
drivers/edac/edac_device.c +17 -0
@@ -625,6 +625,9 @@ int edac_dev_register(struct device *parent, char *name, attr_gcnt++; scrub_cnt++;break ; +case RAS_FEAT_ECS : + attr_gcnt += ras_features[feat].ecs_info.num_media_frus; +break ;default :return -EINVAL ; }
@@ -669,6 +672,20 @@ int edac_dev_register(struct device *parent, char *name, scrub_cnt++; attr_gcnt++;break ; +case RAS_FEAT_ECS : +if (!ras_features->ecs_ops) + goto data_mem_free; + + dev_data = &ctx->ecs; + dev_data->ecs_ops = ras_features->ecs_ops; + dev_data->private = ras_features->ctx; + ret =edac_ecs_get_desc (parent, &ras_attr_groups[attr_gcnt], + ras_features->ecs_info.num_media_frus); +if (ret) + goto data_mem_free; + + attr_gcnt += ras_features->ecs_info.num_media_frus; +break ;default : ret = -EINVAL ; goto data_mem_free;
include/linux/edac.h +39 -2
67 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v17 4/18 cxl: Refactor user ioctl command path from mds to mailbox
In reply to [email protected]From: Dave Jiang <[email protected]>
With 'struct cxl_mailbox' context introduced, the helper functions cxl_query_cmd() and cxl_send_cmd() can take a cxl_mailbox directly rather than a cxl_memdev parameter. Refactor to use cxl_mailbox directly.
--- drivers/cxl/core/core.h | 6 ++- drivers/cxl/core/mbox.c | 91 +++++++++++++++++++-------------------- drivers/cxl/core/memdev.c | 22 +++++++--- drivers/cxl/cxlmem.h | 40 ----------------- include/cxl/mailbox.h | 41 +++++++++++++++++- 5 files changed, 103 insertions(+), 97 deletions(-)
drivers/cxl/core/core.h +4 -2
@@ -4,6 +4,8 @@#ifndef __CXL_CORE_H__#define __CXL_CORE_H__ +#include <cxl/mailbox.h> +extern const struct device_type cxl_nvdimm_bridge_type;extern const struct device_type cxl_nvdimm_type;extern const struct device_type cxl_pmu_type;
@@ -65,9 +67,9 @@ static inline void cxl_region_exit(void)struct cxl_send_command ;struct cxl_mem_query_commands ; -int cxl_query_cmd (struct cxl_memdev *cxlmd, +int cxl_query_cmd (struct cxl_mailbox *cxl_mbox,struct cxl_mem_query_commands __user *q); -int cxl_send_cmd (struct cxl_memdev *cxlmd,struct cxl_send_command __user *s); +int cxl_send_cmd (struct cxl_mailbox *cxl_mailbox,struct cxl_send_command __user *s);void __iomem *devm_cxl_iomap_block (struct device *dev,resource_size_t addr,resource_size_t length);
drivers/cxl/core/mbox.c +44 -47
242 lines not on this page · raw message
drivers/cxl/core/memdev.c +15 -7
@@ -564,9 +564,11 @@ EXPORT_SYMBOL_NS_GPL(is_cxl_memdev, CXL);void set_exclusive_cxl_commands (struct cxl_memdev_state *mds,unsigned long *cmds) { +struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox; +down_write (&cxl_memdev_rwsem); -bitmap_or (mds->exclusive_cmds, mds->exclusive_cmds, cmds, -CXL_MEM_COMMAND_ID_MAX ); +bitmap_or (cxl_mbox->exclusive_cmds, cxl_mbox->exclusive_cmds, + cmds,CXL_MEM_COMMAND_ID_MAX );up_write (&cxl_memdev_rwsem); }EXPORT_SYMBOL_NS_GPL (set_exclusive_cxl_commands,CXL );
@@ -579,9 +581,11 @@ EXPORT_SYMBOL_NS_GPL(set_exclusive_cxl_commands, CXL);void clear_exclusive_cxl_commands (struct cxl_memdev_state *mds,unsigned long *cmds) { +struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox; +down_write (&cxl_memdev_rwsem); -bitmap_andnot (mds->exclusive_cmds, mds->exclusive_cmds, cmds, -CXL_MEM_COMMAND_ID_MAX ); +bitmap_andnot (cxl_mbox->exclusive_cmds, cxl_mbox->exclusive_cmds, + cmds,CXL_MEM_COMMAND_ID_MAX );up_write (&cxl_memdev_rwsem); }EXPORT_SYMBOL_NS_GPL (clear_exclusive_cxl_commands,CXL );
@@ -656,11 +660,14 @@ static struct cxl_memdev *cxl_memdev_alloc(struct cxl_dev_state *cxlds,static long __cxl_memdev_ioctl (struct cxl_memdev *cxlmd,unsigned int cmd,unsigned long arg) { +struct cxl_memdev_state *mds =to_cxl_memdev_state (cxlmd->cxlds); +struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox; +switch (cmd) {case CXL_MEM_QUERY_COMMANDS : -return cxl_query_cmd (cxlmd, (void __user *)arg); +return cxl_query_cmd (cxl_mbox, (void __user *)arg);case CXL_MEM_SEND_COMMAND : -return cxl_send_cmd (cxlmd, (void __user *)arg); +return cxl_send_cmd (cxl_mbox, (void __user *)arg);default :return -ENOTTY ; }
@@ -994,10 +1001,11 @@ static void cxl_remove_fw_upload(void *fwl)int devm_cxl_setup_fw_upload (struct device *host,struct cxl_memdev_state *mds) {struct cxl_dev_state *cxlds = &mds->cxlds; +struct cxl_mailbox *cxl_mbox = &cxlds->cxl_mbox;struct device *dev = &cxlds->cxlmd->dev;struct fw_upload *fwl; -if (!test_bit (CXL_MEM_COMMAND_ID_GET_FW_INFO , mds->enabled_cmds)) +if (!test_bit (CXL_MEM_COMMAND_ID_GET_FW_INFO , cxl_mbox->enabled_cmds))return 0 ; fwl = firmware_upload_register(THIS_MODULE, dev, dev_name(dev),
drivers/cxl/cxlmem.h +0 -40
@@ -106,42 +106,6 @@ static inline struct cxl_ep *cxl_ep_load(struct cxl_port *port,return xa_load (&port->endpoints, (unsigned long )&cxlmd->dev); } -/** -* struct cxl_mbox_cmd - A command to be submitted to hardware. -* @opcode: (input) The command set and command submitted to hardware. -* @payload_in: (input) Pointer to the input payload. -* @payload_out: (output) Pointer to the output payload. Must be allocated by -* the caller. -* @size_in: (input) Number of bytes to load from @payload_in. -* @size_out: (input) Max number of bytes loaded into @payload_out. -* (output) Number of bytes generated by the device. For fixed size -* outputs commands this is always expected to be deterministic. For -* variable sized output commands, it tells the exact number of bytes -* written. -* @min_out: (input) internal command output payload size validation -* @poll_count: (input) Number of timeouts to attempt. -* @poll_interval_ms: (input) Time between mailbox background command polling -* interval timeouts. -* @return_code: (output) Error code returned from hardware. -* -* This is the primary mechanism used to send commands to the hardware. -* All the fields except @payload_* correspond exactly to the fields described in -* Command Register section of the CXL 2.0 8.2.8.4.5. @payload_in and -* @payload_out are written to, and read from the Command Payload Registers -* defined in CXL 2.0 8.2.8.4.8. -*/ -struct cxl_mbox_cmd { -u16 opcode; -void *payload_in; -void *payload_out; -size_t size_in; -size_t size_out; -size_t min_out; -int poll_count; -int poll_interval_ms; -u16 return_code; -}; -/* * Per CXL 3.0 Section 8.2.8.4.5.1 */
@@ -461,8 +425,6 @@ static inline struct cxl_dev_state *mbox_to_cxlds(struct cxl_mailbox *cxl_mbox)* @lsa_size: Size of Label Storage Area * (CXL 2.0 8.2.9.5.1.1 Identify Memory Device) * @firmware_version: Firmware version for the memory device. -* @enabled_cmds: Hardware commands found enabled in CEL. -* @exclusive_cmds: Commands that are kernel-internal only * @total_bytes: sum of all possible capacities * @volatile_only_bytes: hard volatile capacity * @persistent_only_bytes: hard persistent capacity
@@ -485,8 +447,6 @@ struct cxl_memdev_state {struct cxl_dev_state cxlds;size_t lsa_size;char firmware_version[0x10 ]; -DECLARE_BITMAP (enabled_cmds,CXL_MEM_COMMAND_ID_MAX ); -DECLARE_BITMAP (exclusive_cmds,CXL_MEM_COMMAND_ID_MAX );u64 total_bytes;u64 volatile_only_bytes;u64 persistent_only_bytes;
include/cxl/mailbox.h +40 -1
58 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v17 5/18 cxl: Add Get Supported Features command for kernel usage
In reply to [email protected]From: Dave Jiang <[email protected]>
CXL spec r3.1 8.2.9.6.1 Get Supported Features (Opcode 0500h) The command retrieve the list of supported device-specific features (identified by UUID) and general information about each Feature.
The driver will retrieve the feature entries in order to make checks and provide information for the Get Feature and Set Feature command. One of the main piece of information retrieved are the effects a Set Feature command would have for a particular feature.
--- drivers/cxl/core/mbox.c | 179 +++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 44 +++++++++ drivers/cxl/pci.c | 4 + include/cxl/mailbox.h | 4 + include/uapi/linux/cxl_mem.h | 1 + 5 files changed, 232 insertions(+)
drivers/cxl/core/mbox.c +179 -0
@@ -67,6 +67,7 @@ static struct cxl_mem_command cxl_mem_commands[CXL_MEM_COMMAND_ID_MAX] = {CXL_CMD (SET_SHUTDOWN_STATE ,0x1 ,0 ,0 ),CXL_CMD (GET_SCAN_MEDIA_CAPS ,0x10 ,0x4 ,0 ),CXL_CMD (GET_TIMESTAMP ,0 ,0x8 ,0 ), + CXL_CMD(GET_SUPPORTED_FEATURES, 0x8, CXL_VARIABLE_PAYLOAD, 0), };/*
@@ -790,6 +791,184 @@ static const uuid_t log_uuid[] = { [VENDOR_DEBUG_UUID] = DEFINE_CXL_VENDOR_DEBUG_UUID, }; +static void cxl_free_features (void *features) +{ +kvfree (features); +} + +static int cxl_get_supported_features_count (struct cxl_dev_state *cxlds) +{ +struct cxl_mailbox *cxl_mbox = &cxlds->cxl_mbox; +struct cxl_mbox_get_sup_feats_out mbox_out; +struct cxl_mbox_get_sup_feats_in mbox_in; +struct cxl_mbox_cmd mbox_cmd; +int rc; + +memset (&mbox_in,0 ,sizeof (mbox_in)); + mbox_in.count =cpu_to_le32 (sizeof (mbox_out)); +memset (&mbox_out,0 ,sizeof (mbox_out)); + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_GET_SUPPORTED_FEATURES , + .size_in =sizeof (mbox_in), + .payload_in = &mbox_in, + .size_out =sizeof (mbox_out), + .payload_out = &mbox_out, + .min_out =sizeof (mbox_out), + }; + rc =cxl_internal_send_cmd (cxl_mbox, &mbox_cmd); +if (rc <0 ) +return rc; + + cxl_mbox->num_features =le16_to_cpu (mbox_out.supported_feats); + +return 0 ; +} + +int cxl_get_supported_features (struct cxl_dev_state *cxlds) +{ +int remain_feats, max_size, max_feats, start, rc; +struct cxl_mailbox *cxl_mbox = &cxlds->cxl_mbox; +int feat_size =sizeof (struct cxl_feat_entry ); +struct cxl_mbox_get_sup_feats_in mbox_in; +struct cxl_mbox_cmd mbox_cmd; +struct cxl_feat_entry *entry; +struct cxl_mem_command *cmd; +int hdr_size; + +/* Get supported features is optional, need to check */ + cmd =cxl_mem_find_command (CXL_MBOX_OP_GET_SUPPORTED_FEATURES ); +if (!cmd) +return -EOPNOTSUPP ; +if (!test_bit (cmd->info.id, cxl_mbox->enabled_cmds)) +return -EOPNOTSUPP ; + + rc =cxl_get_supported_features_count (cxlds); +if (rc) +return rc; + +if (!cxl_mbox->num_features) { +dev_dbg (cxl_mbox->host,"No CXL features enumerated.\n" ); +return 0 ; + } + + struct cxl_feat_entry *entries __free(kvfree) = +kvmalloc (cxl_mbox->num_features * feat_size,GFP_KERNEL ); + +if (!entries) +return -ENOMEM ; + + struct cxl_mbox_get_sup_feats_out *mbox_out __free(kvfree) = +kvmalloc (cxl_mbox->payload_size,GFP_KERNEL ); +if (!mbox_out) +return -ENOMEM ; + + hdr_size =sizeof (*mbox_out); + max_size = cxl_mbox->payload_size - hdr_size; +/* max feat entries that can fit in mailbox max payload size */ + max_feats = max_size / feat_size; + entry = &entries[0 ]; + + start =0 ; + remain_feats = cxl_mbox->num_features; +do { +int retrieved, alloc_size, copy_feats; +int num_entries; + +if (remain_feats > max_feats) { + alloc_size =sizeof (*mbox_out) + max_feats * feat_size; + remain_feats = remain_feats - max_feats; + copy_feats = max_feats; + }else { + alloc_size =sizeof (*mbox_out) + remain_feats * feat_size; + copy_feats = remain_feats; + remain_feats =0 ; + } + +memset (&mbox_in,0 ,sizeof (mbox_in)); + mbox_in.count =cpu_to_le32 (alloc_size); + mbox_in.start_idx =cpu_to_le16 (start); +memset (mbox_out,0 , alloc_size); + mbox_cmd = (struct cxl_mbox_cmd ) { + .opcode =CXL_MBOX_OP_GET_SUPPORTED_FEATURES , + .size_in =sizeof (mbox_in), + .payload_in = &mbox_in, + .size_out = alloc_size, + .payload_out = mbox_out, + .min_out = hdr_size, + }; + rc =cxl_internal_send_cmd (cxl_mbox, &mbox_cmd); +if (rc <0 ) +return rc; + +if (mbox_cmd.size_out <= hdr_size) { + rc = -ENXIO ; + goto err; + } + +/* +* Make sure retrieved out buffer is multiple of feature +* entries. +*/ + retrieved = mbox_cmd.size_out - hdr_size; +if (retrieved % feat_size) { + rc = -ENXIO ; + goto err; + } + + num_entries =le16_to_cpu (mbox_out->num_entries); +/* +* If the reported output entries * defined entry size != +* retrieved output bytes, then the output package is incorrect. +*/ +if (num_entries * feat_size != retrieved) { + rc = -ENXIO ; + goto err; + } + +memcpy (entry, mbox_out->ents, retrieved); + entry++; +/* +* If the number of output entries is less than expected, add the +* remaining entries to the next batch. +*/ + remain_feats += copy_feats - num_entries; + start += num_entries; + }while (remain_feats); + + cxl_mbox->entries =no_free_ptr (entries); + rc =devm_add_action_or_reset (cxl_mbox->host, cxl_free_features, + cxl_mbox->entries); +if (rc) +return rc; + +return 0 ; + +err: + cxl_mbox->num_features =0 ; +return rc; +} +EXPORT_SYMBOL_NS_GPL (cxl_get_supported_features,CXL ); + +int cxl_get_supported_feature_entry (struct cxl_dev_state *cxlds,const uuid_t *feat_uuid, +struct cxl_feat_entry *feat_entry_out) +{ +struct cxl_mailbox *cxl_mbox = &cxlds->cxl_mbox; +struct cxl_feat_entry *feat_entry; +int count; + +/* Check CXL dev supports the feature */ + feat_entry = &cxl_mbox->entries[0 ]; +for (count =0 ; count < cxl_mbox->num_features; count++, feat_entry++) { +if (uuid_equal (&feat_entry->uuid, feat_uuid)) { +memcpy (feat_entry_out, feat_entry,sizeof (*feat_entry_out)); +return 0 ; + } + } + +return -EOPNOTSUPP ; +} +EXPORT_SYMBOL_NS_GPL (cxl_get_supported_feature_entry,CXL ); +/** * cxl_enumerate_cmds() - Enumerate commands for a device. * @mds: The driver data for the operation
drivers/cxl/cxlmem.h +44 -0
60 lines not on this page · raw message
drivers/cxl/pci.c +4 -0
@@ -887,6 +887,10 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (rc)return rc; + rc =cxl_get_supported_features (cxlds); +if (rc) +dev_dbg (&pdev->dev,"No features enumerated.\n" ); + rc =cxl_set_timestamp (mds);if (rc)return rc;
include/cxl/mailbox.h +4 -0
@@ -50,6 +50,8 @@ struct cxl_mbox_cmd {* (CXL 3.1 8.2.8.4.3 Mailbox Capabilities Register) * @mbox_mutex: mutex protects device mailbox and firmware * @mbox_wait: rcuwait for mailbox +* @num_features: number of supported features entries +* @features: list of supported feature entries * @mbox_send: @dev specific transport for transmitting mailbox commands */ struct cxl_mailbox {
@@ -59,6 +61,8 @@ struct cxl_mailbox {size_t payload_size;struct mutex mbox_mutex;/* lock to protect mailbox context */ struct rcuwait mbox_wait; +int num_features; +struct cxl_feat_entry *entries;int (*mbox_send)(struct cxl_mailbox *cxl_mbox,struct cxl_mbox_cmd *cmd); };
include/uapi/linux/cxl_mem.h +1 -0
@@ -50,6 +50,7 @@___C (GET_LOG_CAPS ,"Get Log Capabilities" ), \___C (CLEAR_LOG ,"Clear Log" ), \___C (GET_SUP_LOG_SUBLIST ,"Get Supported Logs Sub-List" ), \ +___C (GET_SUPPORTED_FEATURES ,"Get Supported Features" ), \ ___C(MAX, "invalid / last command")#define ___C (a, b) CXL_MEM_COMMAND_ID_##a
Signature · 1 line
2.43.0
Re: [PATCH v17 05/18] cxl: Add Get Supported Features command for kernel usage
Quoted 15 lines · shiju.jose@ wrote:
From: Dave Jiang <[email protected]>
CXL spec r3.1 8.2.9.6.1 Get Supported Features (Opcode 0500h) The command retrieve the list of supported device-specific features (identified by UUID) and general information about each Feature.
The driver will retrieve the feature entries in order to make checks and provide information for the Get Feature and Set Feature command. One of the main piece of information retrieved are the effects a Set Feature command would have for a particular feature.
Reviewed-by Jonathan Cameron <[email protected]>Signed-off-by Dave Jiang <[email protected]>Co-developed-by Shiju Jose <[email protected]>Signed-off-by Shiju Jose <[email protected]>
Quoted 7 lines
--- drivers/cxl/core/mbox.c | 179 +++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 44 +++++++++ drivers/cxl/pci.c | 4 + include/cxl/mailbox.h | 4 + include/uapi/linux/cxl_mem.h | 1 + 5 files changed, 232 insertions(+)
Hi Shiju,
So I commented yesterday on this patch that is also duplicated in Dave's series have a merge order ordering plan to propose.
drivers/cxl/core/mbox.c static struct cxl_mem_command cxl_mem_commands[CXL_MEM_COMMAND_ID_MAX] = { · line 70
Quoted 9 lines
drivers/cxl/core/mbox.c +1
-0@@ -67,6 +67,7 @@ static struct cxl_mem_command cxl_mem_commands[CXL_MEM_COMMAND_ID_MAX] = {CXL_CMD (SET_SHUTDOWN_STATE ,0x1 ,0 ,0 ),CXL_CMD (GET_SCAN_MEDIA_CAPS ,0x10 ,0x4 ,0 ),CXL_CMD (GET_TIMESTAMP ,0 ,0x8 ,0 ), + CXL_CMD(GET_SUPPORTED_FEATURES, 0x8, CXL_VARIABLE_PAYLOAD, 0),
As I mention on the CXL FWCTL alias of this path, for kernel-internal only usage by definition that means a CXL command id does not need to be defined.
Setting that aside, the place where CXL EDAC and CXL FWCTL series can unify is on the definition of the cxl_{get,set}_features() helpers proposed in this series for kernel-internal submission of CXL FEATURES commands. I think Dave's series should ingest cxl_{get,set}_features(), go in first since it does not have cross-subsystem entanglements, and then you can build reuse that infrastructure to finalize the CXL scrub implementation.
The missing piece in my mind to make cxl_{get,set}_features() usable with the CXL FWCTL path is likely to make it be able to support copying in / out of __user buffers. To me that looks like updating cxl_internal_send_cmd() to use copy_{to,from}_sockptr() internally so that it is independent of the kernel vs user buffer concern from CXL EDAC vs CXL FWCTL callers.
RE: [PATCH v17 05/18] cxl: Add Get Supported Features command for kernel usage
Quoted 49 lines
-----Original Message-----
From: Dan Williams <[email protected]>
Sent: 06 December 2024 21:41
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]; tanxiaofei <[email protected]>; Zengtao (B) <[email protected]>; Roberto Sassu <[email protected]>; [email protected]; wanghuiqiang <[email protected]>; Linuxarm <[email protected]>; Shiju Jose <[email protected]>
Subject: Re: [PATCH v17 05/18] cxl: Add Get Supported Features command for kernel usageQuoted 15 lines · shiju.jose@ wrote:
From: Dave Jiang <[email protected]>
CXL spec r3.1 8.2.9.6.1 Get Supported Features (Opcode 0500h) The command retrieve the list of supported device-specific features (identified by UUID) and general information about each Feature.
The driver will retrieve the feature entries in order to make checks and provide information for the Get Feature and Set Feature command. One of the main piece of information retrieved are the effects a Set Feature command would have for a particular feature.
Reviewed-by Jonathan Cameron <[email protected]>Signed-off-by Dave Jiang <[email protected]>Co-developed-by Shiju Jose <[email protected]>Signed-off-by Shiju Jose <[email protected]>Quoted 7 lines
--- drivers/cxl/core/mbox.c | 179 +++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 44 +++++++++ drivers/cxl/pci.c | 4 + include/cxl/mailbox.h | 4 + include/uapi/linux/cxl_mem.h | 1 + 5 files changed, 232 insertions(+)
Quoted 4 lines
Hi Shiju,
So I commented yesterday on this patch that is also duplicated in Dave's series have a merge order ordering plan to propose.
Hi Dan,
Thanks for the suggestions.
I tested your suggestions for CXL features commands in the fwctl series, in the EDAC CXL features setup, as replied.
Quoted 7 lines
drivers/cxl/core/mbox.c static struct cxl_mem_command
Quoted 6 lines
drivers/cxl/core/mbox.c index renamed from drivers/cxl/core/mbox.c +0
-0
880ac1dba3cc..c5d4c7df2f99100644drivers/cxl/core/mbox.c +0
-0@@ -67,6 +67,7 @@ static struct cxl_mem_commandcxl_mem_commands[CXL_MEM_COMMAND_ID_MAX] = {
Quoted 8 lines
drivers/cxl/core/mbox.c static struct cxl_mem_command cxl_mem_commands[CXL_MEM_COMMAND_ID_MAX] = {
Quoted 4 lines
drivers/cxl/core/mbox.c +1
-0CXL_CMD (SET_SHUTDOWN_STATE ,0x1 ,0 ,0 ),CXL_CMD (GET_SCAN_MEDIA_CAPS ,0x10 ,0x4 ,0 ),CXL_CMD (GET_TIMESTAMP ,0 ,0x8 ,0 ), + CXL_CMD(GET_SUPPORTED_FEATURES, 0x8, CXL_VARIABLE_PAYLOAD,0),
As I mention on the CXL FWCTL alias of this path, for kernel-internal only usage by definition that means a CXL command id does not need to be defined.
I tried removing these definitions for get_supported_features, get_feature and set_feature from cxl_mem_command[] and build and worked fine for the EDAC CXL features.
For cxl_get_supported_features() to work , I removed following check.
===========================
int cxl_get_supported_features(struct cxl_dev_state *cxlds) {
int remain_feats, max_size, max_feats, start, rc;[...]
/* Get supported features is optional, need to check */ cmd = cxl_mem_find_command(CXL_MBOX_OP_GET_SUPPORTED_FEATURES); if (!cmd) return -EOPNOTSUPP; if (!test_bit(cmd->info.id, cxl_mbox->enabled_cmds)) return -EOPNOTSUPP;
[...]
}
==========================
Quoted 7 lines
Setting that aside, the place where CXL EDAC and CXL FWCTL series can unify is on the definition of the cxl_{get,set}_features() helpers proposed in this series for kernel-internal submission of CXL FEATURES commands. I think Dave's series should ingest cxl_{get,set}_features(), go in first since it does not have cross- subsystem entanglements, and then you can build reuse that infrastructure to finalize the CXL scrub implementation.
Agree. I will reuse merged features infrastructure for the EDAC CXL features.
Quoted 7 lines
The missing piece in my mind to make cxl_{get,set}_features() usable with the CXL FWCTL path is likely to make it be able to support copying in / out of
__userbuffers. To me that looks like updatingcxl_internal_send_cmd()to use copy_{to,from}_sockptr() internally so that it is independent of the kernel vs user buffer concern from CXL EDAC vs CXL FWCTL callers.
Ok.
Thanks,
Shiju
RE: [PATCH v17 05/18] cxl: Add Get Supported Features command for kernel usage
Quoted 77 lines
-----Original Message-----
From: Shiju Jose <[email protected]>
Sent: 09 December 2024 14:28
To: Dan Williams <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [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]; tanxiaofei <[email protected]>; Zengtao (B) <[email protected]>; Roberto Sassu <[email protected]>; [email protected]; wanghuiqiang <[email protected]>; Linuxarm <[email protected]>
Subject: RE: [PATCH v17 05/18] cxl: Add Get Supported Features command for kernel usageQuoted 7 lines
-----Original Message-----
From: Dan Williams <[email protected]>
Sent: 06 December 2024 21:41
To: Shiju Jose <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; linux- [email protected]
Cc: [email protected]; [email protected]; [email protected];Quoted 8 lines
[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];
Quoted 36 lines
[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]>; Shiju Jose <[email protected]>
Subject: Re: [PATCH v17 05/18] cxl: Add Get Supported Features command for kernel usageQuoted 15 lines · shiju.jose@ wrote:
From: Dave Jiang <[email protected]>
CXL spec r3.1 8.2.9.6.1 Get Supported Features (Opcode 0500h) The command retrieve the list of supported device-specific features (identified by UUID) and general information about each Feature.
The driver will retrieve the feature entries in order to make checks and provide information for the Get Feature and Set Feature command. One of the main piece of information retrieved are the effects a Set Feature command would have for a particular feature.
Reviewed-by Jonathan Cameron <[email protected]>Signed-off-by Dave Jiang <[email protected]>Co-developed-by Shiju Jose <[email protected]>Signed-off-by Shiju Jose <[email protected]>Quoted 7 lines
--- drivers/cxl/core/mbox.c | 179 +++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 44 +++++++++ drivers/cxl/pci.c | 4 + include/cxl/mailbox.h | 4 + include/uapi/linux/cxl_mem.h | 1 + 5 files changed, 232 insertions(+)Hi Shiju,
Quoted 8 lines
Quoted 2 lines
So I commented yesterday on this patch that is also duplicated in Dave's series have a merge order ordering plan to propose.
Hi Dan,
Thanks for the suggestions.
I tested your suggestions for CXL features commands in the fwctl series, in the EDAC CXL features setup, as replied.
Please find updated patches for your suggestions are shared here.
https://github.com/shijujose4/linux/tree/edac-enhancement-ras-features_for_v18
However next version (v18) of EDAC series will send after receiving feedbacks from Borislav on v17 EDAC patches.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/cxl/core/mbox.c index renamed from drivers/cxl/core/mbox.c +0
-0
[...]
Quoted 1 line
Thanks,
Shiju
PATCH v17 6/18 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 | 41 +++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 26 ++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)
drivers/cxl/core/mbox.c +41 -0
@@ -969,6 +969,47 @@ int cxl_get_supported_feature_entry(struct cxl_dev_state *cxlds, const uuid_t *f }EXPORT_SYMBOL_NS_GPL (cxl_get_supported_feature_entry,CXL ); +size_t cxl_get_feature (struct cxl_dev_state *cxlds,const uuid_t feat_uuid, +enum cxl_get_feat_selection selection, +void *feat_out,size_t feat_out_size) +{ +struct cxl_mailbox *cxl_mbox = &cxlds->cxl_mbox; +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, cxl_mbox->payload_size); + pi.uuid = feat_uuid; + pi.selection = selection; +do { + data_to_rd_size =min (feat_out_size - data_rcvd_size, + cxl_mbox->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 (cxl_mbox, &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 ); +/** * cxl_enumerate_cmds() - Enumerate commands for a device. * @mds: The driver data for the operation
drivers/cxl/cxlmem.h +26 -0
@@ -491,6 +491,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,
@@ -813,6 +814,28 @@ struct cxl_mbox_get_sup_feats_out { struct cxl_feat_entry ents[] __counted_by_le(num_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; +int cxl_internal_send_cmd (struct cxl_mailbox *cxl_mbox,struct cxl_mbox_cmd *cmd);int cxl_dev_state_identify (struct cxl_memdev_state *mds);
@@ -876,4 +899,7 @@ void cxl_dpa_debug(struct seq_file *file, struct cxl_dev_state *cxlds);int cxl_get_supported_features (struct cxl_dev_state *cxlds);int cxl_get_supported_feature_entry (struct cxl_dev_state *cxlds,const uuid_t *feat_uuid,struct cxl_feat_entry *feat_entry_out); +size_t cxl_get_feature (struct cxl_dev_state *cxlds,const uuid_t feat_uuid, +enum cxl_get_feat_selection selection, +void *feat_out,size_t feat_out_size);#endif /* __CXL_MEM_H__ */
Signature · 1 line
2.43.0
PATCH v17 7/18 cxl: Add Get Feature command support for user submission
In reply to [email protected]From: Dave Jiang <[email protected]>
Add enumeration of Get Feature mailbox command for the kernel to recognize the command being passed in from user space.
CXL spec r3.1 8.2.9.6.2 Get Feature (Opcode 0501h)
The feature requested is identified by specific UUID.
--- drivers/cxl/core/mbox.c | 1 + include/uapi/linux/cxl_mem.h | 1 + 2 files changed, 2 insertions(+)
drivers/cxl/core/mbox.c +1 -0
@@ -68,6 +68,7 @@ static struct cxl_mem_command cxl_mem_commands[CXL_MEM_COMMAND_ID_MAX] = {CXL_CMD (GET_SCAN_MEDIA_CAPS ,0x10 ,0x4 ,0 ),CXL_CMD (GET_TIMESTAMP ,0 ,0x8 ,0 ),CXL_CMD (GET_SUPPORTED_FEATURES ,0x8 ,CXL_VARIABLE_PAYLOAD ,0 ), + CXL_CMD(GET_FEATURE, 0x15, CXL_VARIABLE_PAYLOAD, 0), };/*
include/uapi/linux/cxl_mem.h +1 -0
@@ -51,6 +51,7 @@___C (CLEAR_LOG ,"Clear Log" ), \___C (GET_SUP_LOG_SUBLIST ,"Get Supported Logs Sub-List" ), \___C (GET_SUPPORTED_FEATURES ,"Get Supported Features" ), \ +___C (GET_FEATURE ,"Get Feature" ), \ ___C(MAX, "invalid / last command")#define ___C (a, b) CXL_MEM_COMMAND_ID_##a
Signature · 1 line
2.43.0
PATCH v17 8/18 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 support 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 | 73 +++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 34 +++++++++++++++++++ 2 files changed, 107 insertions(+)
drivers/cxl/core/mbox.c +73 -0
@@ -1011,6 +1011,79 @@ size_t cxl_get_feature(struct cxl_dev_state *cxlds, const uuid_t feat_uuid, }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_dev_state *cxlds, +const uuid_t feat_uuid,u8 feat_version, +void *feat_data,size_t feat_data_size, +u8 feat_flag) +{ +struct cxl_mailbox *cxl_mbox = &cxlds->cxl_mbox; +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 (cxl_mbox->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 > cxl_mbox->payload_size) +return -ENOMEM ; + +if ((hdr_size + feat_data_size) <= cxl_mbox->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 = cxl_mbox->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 (cxl_mbox, &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) <= (cxl_mbox->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 ); +/** * cxl_enumerate_cmds() - Enumerate commands for a device. * @mds: The driver data for the operation
drivers/cxl/cxlmem.h +34 -0
@@ -492,6 +492,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,
@@ -836,6 +837,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; +int cxl_internal_send_cmd (struct cxl_mailbox *cxl_mbox,struct cxl_mbox_cmd *cmd);int cxl_dev_state_identify (struct cxl_memdev_state *mds);
@@ -902,4 +932,8 @@ int cxl_get_supported_feature_entry(struct cxl_dev_state *cxlds, const uuid_t *fsize_t cxl_get_feature (struct cxl_dev_state *cxlds,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_dev_state *cxlds, +const uuid_t feat_uuid,u8 feat_version, +void *feat_data,size_t feat_data_size, +u8 feat_flag);#endif /* __CXL_MEM_H__ */
Signature · 1 line
2.43.0
PATCH v17 9/18 cxl: Add Set Feature command support for user submission
In reply to [email protected]From: Dave Jiang <[email protected]>
Add enumeration of Set Feature mailbox command for the kernel to recognize the command being passed in from user space.
CXL spec r3.1 8.2.9.6.3 Set Feature (Opcode 0502h)
The feature requested is identified by specific UUID.
--- drivers/cxl/core/mbox.c | 1 + include/uapi/linux/cxl_mem.h | 1 + 2 files changed, 2 insertions(+)
drivers/cxl/core/mbox.c +1 -0
@@ -69,6 +69,7 @@ static struct cxl_mem_command cxl_mem_commands[CXL_MEM_COMMAND_ID_MAX] = {CXL_CMD (GET_TIMESTAMP ,0 ,0x8 ,0 ),CXL_CMD (GET_SUPPORTED_FEATURES ,0x8 ,CXL_VARIABLE_PAYLOAD ,0 ),CXL_CMD (GET_FEATURE ,0x15 ,CXL_VARIABLE_PAYLOAD ,0 ), + CXL_CMD(SET_FEATURE, CXL_VARIABLE_PAYLOAD, 0, 0), };/*
include/uapi/linux/cxl_mem.h +1 -0
@@ -52,6 +52,7 @@___C (GET_SUP_LOG_SUBLIST ,"Get Supported Logs Sub-List" ), \___C (GET_SUPPORTED_FEATURES ,"Get Supported Features" ), \___C (GET_FEATURE ,"Get Feature" ), \ +___C (SET_FEATURE ,"Set Feature" ), \ ___C(MAX, "invalid / last command")#define ___C (a, b) CXL_MEM_COMMAND_ID_##a
Signature · 1 line
2.43.0
PATCH v17 10/18 cxl: Add UUIDs for the CXL RAS features
In reply to [email protected]From: Dave Jiang <[email protected]>
Add UUIDs for the CXL RAS features to a common file.
--- include/cxl/features.h | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 include/cxl/features.h
include/cxl/features.h new file +48 -0
@@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright(c) 2024 Intel Corporation. */ +#ifndef __CXL_FEATS_H_ +#define __CXL_FEATS_H_ + +#include <linux/uuid.h> + +/* +* Patrol scrub control CXL 3.1 Spec 8.2.9.9.11.1 Table 8-206 +*/ +#define CXL_FEAT_PATROL_SCRUB_UUID \ + UUID_INIT(0x96dad7d6, 0xfde8, 0x482b, 0xa7, 0x33, 0x75, 0x77, 0x4e, \ + 0x06, 0xdb, 0x8a) + +/* +* DDR5 ECS control CXL 3.1 Spec 8.2.9.9.11.2 Table 8-209 +*/ +#define CXL_FEAT_ECS_UUID \ + UUID_INIT(0xe5b13f22, 0x2328, 0x4a14, 0xb8, 0xba, 0xb9, 0x69, 0x1e, \ + 0x89, 0x33, 0x86) + +/* +* CXL maintenance operations CXL 3.1 Spec 8.2.9.7.2 Table 8-110 +*/ +#define CXL_FEAT_SPPR_UUID \ + UUID_INIT(0x892ba475, 0xfad8, 0x474e, 0x9d, 0x3e, 0x69, 0x2c, 0x91, \ + 0x75, 0x68, 0xbb) + +#define CXL_FEAT_HPPR_UUID \ + UUID_INIT(0x80ea4521, 0x786f, 0x4127, 0xaf, 0xb1, 0xec, 0x74, 0x59, \ + 0xfb, 0x0e, 0x24) + +#define CXL_FEAT_CACHELINE_SPARING_UUID \ + UUID_INIT(0x96C33386, 0x91dd, 0x44c7, 0x9e, 0xcb, 0xfd, 0xaf, 0x65, \ + 0x03, 0xba, 0xc4) + +#define CXL_FEAT_ROW_SPARING_UUID \ + UUID_INIT(0x450ebf67, 0xb135, 0x4f97, 0xa4, 0x98, 0xc2, 0xd5, 0x7f, \ + 0x27, 0x9b, 0xed) + +#define CXL_FEAT_BANK_SPARING_UUID \ + UUID_INIT(0x78b79636, 0x90ac, 0x4b64, 0xa4, 0xef, 0xfa, 0xac, 0x5d, \ + 0x18, 0xa8, 0x63) + +#define CXL_FEAT_RANK_SPARING_UUID \ + UUID_INIT(0x34dbaff5, 0x0552, 0x4281, 0x8f, 0x76, 0xda, 0x0b, 0x5e, \ + 0x7a, 0x76, 0xa7) +#endif
Signature · 1 line
2.43.0
PATCH v17 11/18 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 patrol scrub control on CXL memory devices. Register with the EDAC device driver, which retrieves the scrub attribute descriptors from EDAC scrub and exposes the sysfs scrub control attributes to userspace. For example, scrub control for the CXL memory device "cxl_mem0" is exposed in /sys/bus/edac/devices/cxl_mem0/scrubX/.
Additionally, add support for region-based CXL memory patrol scrub control. CXL memory regions 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/scrubX/.
--- Documentation/edac/scrub.rst | 71 ++++++ drivers/cxl/Kconfig | 18 ++ drivers/cxl/core/Makefile | 1 + drivers/cxl/core/memfeature.c | 404 ++++++++++++++++++++++++++++++++++ drivers/cxl/core/region.c | 6 + drivers/cxl/cxlmem.h | 23 ++ drivers/cxl/mem.c | 4 + 7 files changed, 527 insertions(+) create mode 100644 drivers/cxl/core/memfeature.c
Documentation/edac/scrub.rst +71 -0
@@ -244,3 +244,74 @@ Sysfs files are documented in `Documentation/ABI/testing/sysfs-edac-scrub`. `Documentation/ABI/testing/sysfs-edac-ecs`. + +Examples +-------- + +The usage takes the form shown in this example: + +1. CXL memory device patrol scrubber + +1.1 Device based scrubbing + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/scrub0/min_cycle_duration + +3600 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/scrub0/max_cycle_duration + +918000 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/scrub0/current_cycle_duration + +43200 + +root@localhost:~# echo 54000 > /sys/bus/edac/devices/cxl_mem0/scrub0/current_cycle_duration + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/scrub0/current_cycle_duration + +54000 + +root@localhost:~# echo 1 > /sys/bus/edac/devices/cxl_mem0/scrub0/enable_background + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/scrub0/enable_background + +1 + +root@localhost:~# echo 0 > /sys/bus/edac/devices/cxl_mem0/scrub0/enable_background + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/scrub0/enable_background + +0 + +1.2. Region based scrubbing + +root@localhost:~# cat /sys/bus/edac/devices/cxl_region0/scrub0/min_cycle_duration + +3600 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_region0/scrub0/max_cycle_duration + +918000 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_region0/scrub0/current_cycle_duration + +43200 + +root@localhost:~# echo 54000 > /sys/bus/edac/devices/cxl_region0/scrub0/current_cycle_duration + +root@localhost:~# cat /sys/bus/edac/devices/cxl_region0/scrub0/current_cycle_duration + +54000 + +root@localhost:~# echo 1 > /sys/bus/edac/devices/cxl_region0/scrub0/enable_background + +root@localhost:~# cat /sys/bus/edac/devices/cxl_region0/scrub0/enable_background + +1 + +root@localhost:~# echo 0 > /sys/bus/edac/devices/cxl_region0/scrub0/enable_background + +root@localhost:~# cat /sys/bus/edac/devices/cxl_region0/scrub0/enable_background + +0
drivers/cxl/Kconfig +18 -0
@@ -146,4 +146,22 @@ config CXL_REGION_INVALIDATION_TEST If unsure, or if this kernel is meant for production environments, say N. +config CXL_RAS_FEAT + tristate "CXL: Memory RAS features" + depends on CXL_PCI + depends on CXL_MEM + depends on EDAC + help + The CXL memory RAS feature control is optional and allows host to + control the RAS features configurations of CXL Type 3 devices. + + It registers with the EDAC device subsystem to expose control + attributes of CXL memory device's RAS features to the user. + It provides interface functions to support configuring the CXL + memory device's RAS features. + + Say 'y/m/n' to enable/disable control of the CXL.mem device's RAS features. + 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 +404 -0
404 lines not on this page · raw message
drivers/cxl/core/region.c +6 -0
@@ -3444,6 +3444,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 +23 -0
@@ -783,6 +783,22 @@ struct cxl_mbox_get_sup_feats_in {u8 reserved[2 ]; } __packed; +/* 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_feat_entry - CXL Spec r3.1 Table 8-97 * @uuid: Feature identifier
@@ -890,6 +906,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); +#if IS_ENABLED (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
@@ -116,6 +116,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.43.0
PATCH v17 12/18 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 the request falls within the limits specified in DDR5 mode registers), switch between codeword mode and row count mode, and reset the ECS counter.
Register with EDAC device driver, which retrieves the ECS attribute descriptors from the EDAC ECS and exposes the ECS control attributes to userspace via sysfs. For example, the ECS control for the memory media FRU0 in CXL mem0 device is located at /sys/bus/edac/devices/cxl_mem0/ecs_fru0/
--- drivers/cxl/core/memfeature.c | 371 +++++++++++++++++++++++++++++++++- 1 file changed, 368 insertions(+), 3 deletions(-)
drivers/cxl/core/memfeature.c +368 -3
@@ -18,7 +18,7 @@#include <cxl.h> #include <cxlmem.h> -#define CXL_DEV_NUM_RAS_FEATURES 1 +#define CXL_DEV_NUM_RAS_FEATURES 2#define CXL_DEV_HOUR_IN_SECS 3600#define CXL_DEV_NAME_LEN 128
@@ -308,6 +308,308 @@ static const struct edac_scrub_ops cxl_ps_scrub_ops = { .set_cycle_duration = cxl_patrol_scrub_write_scrub_cycle, }; +/* CXL DDR5 ECS control definitions */ +struct cxl_ecs_context { +u16 num_media_frus; +u16 get_feat_size; +u16 set_feat_size; +u8 get_version; +u8 set_version; +u16 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_COUNT_MODE_MASK BIT(3) +#define CXL_ECS_RESET_COUNTER_MASK BIT(4) +#define CXL_ECS_RESET_COUNTER 1 + +enum { +ECS_THRESHOLD_256 =256 , +ECS_THRESHOLD_1024 =1024 , +ECS_THRESHOLD_4096 =4096 , +}; + +enum { +ECS_THRESHOLD_IDX_256 =3 , +ECS_THRESHOLD_IDX_1024 =4 , +ECS_THRESHOLD_IDX_4096 =5 , +}; + +static const u16 ecs_supp_threshold[] = { + [ECS_THRESHOLD_IDX_256 ] =256 , + [ECS_THRESHOLD_IDX_1024 ] =1024 , + [ECS_THRESHOLD_IDX_4096 ] =4096 , +}; + +enum { +ECS_LOG_ENTRY_TYPE_DRAM =0x0 , +ECS_LOG_ENTRY_TYPE_MEM_MEDIA_FRU =0x1 , +}; + +enum cxl_ecs_count_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. +* @count_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_count_mode count_mode; +u8 reset_counter; +}; + +struct cxl_ecs_fru_rd_attrs { +u8 ecs_cap; +__le16 ecs_config; +u8 ecs_flags; +} __packed; + +struct cxl_ecs_rd_attrs { +u8 ecs_log_cap; +struct cxl_ecs_fru_rd_attrs fru_attrs[]; +} __packed; + +struct cxl_ecs_fru_wr_attrs { +__le16 ecs_config; +} __packed; + +struct cxl_ecs_wr_attrs { +u8 ecs_log_cap; +struct cxl_ecs_fru_wr_attrs fru_attrs[]; +} __packed; + +/* CXL DDR5 ECS control functions */ +static int cxl_mem_ecs_get_attrs (struct device *dev, +struct cxl_ecs_context *cxl_ecs_ctx, +int fru_id,struct cxl_ecs_params *params) +{ +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); +struct cxl_ecs_fru_rd_attrs *fru_rd_attrs; +size_t rd_data_size; +u8 threshold_index; +size_t data_size; +u16 ecs_config; + + 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->count_mode =0 ; + data_size =cxl_get_feature (&mds->cxlds,CXL_FEAT_ECS_UUID , +CXL_GET_FEAT_SEL_CURRENT_VALUE , + rd_attrs, rd_data_size); +if (!data_size) +return -EIO ; + + fru_rd_attrs = rd_attrs->fru_attrs; + params->log_entry_type =FIELD_GET (CXL_ECS_LOG_ENTRY_TYPE_MASK , + rd_attrs->ecs_log_cap); + ecs_config =le16_to_cpu (fru_rd_attrs[fru_id].ecs_config); + threshold_index =FIELD_GET (CXL_ECS_THRESHOLD_COUNT_MASK , + ecs_config); + params->threshold = ecs_supp_threshold[threshold_index]; + params->count_mode =FIELD_GET (CXL_ECS_COUNT_MODE_MASK , + ecs_config); +return 0 ; +} + +static int cxl_mem_ecs_set_attrs (struct device *dev, +struct cxl_ecs_context *cxl_ecs_ctx, +int fru_id,struct cxl_ecs_params *params, +u8 param_type) +{ +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); +struct cxl_ecs_fru_rd_attrs *fru_rd_attrs; +struct cxl_ecs_fru_wr_attrs *fru_wr_attrs; +size_t rd_data_size, wr_data_size; +u16 num_media_frus, count; +size_t data_size; +u16 ecs_config; +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->cxlds,CXL_FEAT_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. +*/ + fru_rd_attrs = rd_attrs->fru_attrs; + fru_wr_attrs = wr_attrs->fru_attrs; + wr_attrs->ecs_log_cap = rd_attrs->ecs_log_cap; +for (count =0 ; count < num_media_frus; count++) + fru_wr_attrs[count].ecs_config = fru_rd_attrs[count].ecs_config; + +/* Fill attribute to be set for the media FRU */ + ecs_config =le16_to_cpu (fru_rd_attrs[fru_id].ecs_config); +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->ecs_log_cap =FIELD_PREP (CXL_ECS_LOG_ENTRY_TYPE_MASK , + params->log_entry_type); +break ; +case CXL_ECS_PARAM_THRESHOLD : + ecs_config &= ~CXL_ECS_THRESHOLD_COUNT_MASK ; +switch (params->threshold) { +case ECS_THRESHOLD_256 : + ecs_config |=FIELD_PREP (CXL_ECS_THRESHOLD_COUNT_MASK , +ECS_THRESHOLD_IDX_256 ); +break ; +case ECS_THRESHOLD_1024 : + ecs_config |=FIELD_PREP (CXL_ECS_THRESHOLD_COUNT_MASK , +ECS_THRESHOLD_IDX_1024 ); +break ; +case ECS_THRESHOLD_4096 : + ecs_config |=FIELD_PREP (CXL_ECS_THRESHOLD_COUNT_MASK , +ECS_THRESHOLD_IDX_4096 ); +break ; +default : +dev_err (dev, +"Invalid CXL ECS scrub threshold count(%d) to set\n" , + params->threshold); +dev_err (dev, +"Supported scrub threshold counts: %u, %u, %u\n" , +ECS_THRESHOLD_256 ,ECS_THRESHOLD_1024 ,ECS_THRESHOLD_4096 ); +return -EINVAL ; + } +break ; +case CXL_ECS_PARAM_MODE : +if (params->count_mode !=ECS_MODE_COUNTS_ROWS && + params->count_mode !=ECS_MODE_COUNTS_CODEWORDS ) { +dev_err (dev, +"Invalid CXL ECS scrub mode(%d) to set\n" , + params->count_mode); +dev_err (dev, +"Supported ECS Modes: 0: ECS counts rows with errors," +" 1: ECS counts codewords with errors\n" ); +return -EINVAL ; + } + ecs_config &= ~CXL_ECS_COUNT_MODE_MASK ; + ecs_config |=FIELD_PREP (CXL_ECS_COUNT_MODE_MASK , params->count_mode); +break ; +case CXL_ECS_PARAM_RESET_COUNTER : +if (params->reset_counter !=CXL_ECS_RESET_COUNTER ) +return -EINVAL ; + + ecs_config &= ~CXL_ECS_RESET_COUNTER_MASK ; + 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 ; + } + fru_wr_attrs[fru_id].ecs_config =cpu_to_le16 (ecs_config); + + ret =cxl_set_feature (&mds->cxlds,CXL_FEAT_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 ; +} + +#define CXL_ECS_GET_ATTR (attrib) \ +static int cxl_ecs_get_##attrib(struct device *dev, void *drv_data, \ + int fru_id, u32 *val) \ +{ \ + struct cxl_ecs_context *ctx = drv_data; \ + struct cxl_ecs_params params; \ + int ret; \ + \ + ret = cxl_mem_ecs_get_attrs(dev, ctx, fru_id, ¶ms); \ + if (ret) \ + return ret; \ + \ + *val = params.attrib; \ + \ + return 0; \ +} + +CXL_ECS_GET_ATTR(log_entry_type) +CXL_ECS_GET_ATTR(count_mode) +CXL_ECS_GET_ATTR(threshold) + +#define CXL_ECS_SET_ATTR (attrib, param_type) \ +static int cxl_ecs_set_##attrib(struct device *dev, void *drv_data, \ + int fru_id, u32 val) \ +{ \ + struct cxl_ecs_context *ctx = drv_data; \ + struct cxl_ecs_params params = { \ + .attrib = val, \ + }; \ + \ + return cxl_mem_ecs_set_attrs(dev, ctx, fru_id, ¶ms, (param_type)); \ +} +CXL_ECS_SET_ATTR(log_entry_type, CXL_ECS_PARAM_LOG_ENTRY_TYPE) +CXL_ECS_SET_ATTR(count_mode, CXL_ECS_PARAM_MODE) +CXL_ECS_SET_ATTR(reset_counter, CXL_ECS_PARAM_RESET_COUNTER) +CXL_ECS_SET_ATTR(threshold, 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_mode = cxl_ecs_get_count_mode, + .set_mode = cxl_ecs_set_count_mode, + .reset = cxl_ecs_set_reset_counter, + .get_threshold = cxl_ecs_get_threshold, + .set_threshold = cxl_ecs_set_threshold, +}; +static int cxl_memdev_scrub_init (struct cxl_memdev *cxlmd,struct cxl_region *cxlr,struct edac_dev_feature *ras_feature,u8 scrub_inst) {
@@ -375,6 +677,54 @@ static int cxl_memdev_scrub_init(struct cxl_memdev *cxlmd, struct cxl_region *cxreturn -EOPNOTSUPP ; } +static int cxl_memdev_ecs_init (struct cxl_memdev *cxlmd, +struct edac_dev_feature *ras_feature) +{ +struct cxl_dev_state *cxlds = cxlmd->cxlds; +struct cxl_memdev_state *mds =to_cxl_memdev_state (cxlds); +struct cxl_ecs_context *cxl_ecs_ctx; +struct cxl_feat_entry feat_entry; +int num_media_frus; +int rc; + + rc =cxl_get_supported_feature_entry (&mds->cxlds, &CXL_FEAT_ECS_UUID , &feat_entry); +if (rc <0 ) + goto feat_unsupported; + +if (!(le32_to_cpu (feat_entry.flags) &CXL_FEAT_ENTRY_FLAG_CHANGABLE )) + goto feat_unsupported; + num_media_frus = (le16_to_cpu (feat_entry.get_feat_size) - +sizeof (struct cxl_ecs_rd_attrs )) / +sizeof (struct cxl_ecs_fru_rd_attrs ); +if (!num_media_frus) + goto feat_unsupported; + + cxl_ecs_ctx =devm_kzalloc (&cxlmd->dev,sizeof (*cxl_ecs_ctx), +GFP_KERNEL ); +if (!cxl_ecs_ctx) +return -ENOMEM ; + + *cxl_ecs_ctx = (struct cxl_ecs_context ) { + .get_feat_size =le16_to_cpu (feat_entry.get_feat_size), + .set_feat_size =le16_to_cpu (feat_entry.set_feat_size), + .get_version = feat_entry.get_feat_ver, + .set_version = feat_entry.set_feat_ver, + .effects =le16_to_cpu (feat_entry.effects), + .num_media_frus = num_media_frus, + .cxlmd = cxlmd, + }; + + ras_feature->ft_type =RAS_FEAT_ECS ; + ras_feature->ecs_ops = &cxl_ecs_ops; + ras_feature->ctx = cxl_ecs_ctx; + ras_feature->ecs_info.num_media_frus = num_media_frus; + +return 0 ; + +feat_unsupported: +return -EOPNOTSUPP ; +} +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 ];
@@ -385,19 +735,34 @@ int cxl_mem_ras_features_init(struct cxl_memdev *cxlmd, struct cxl_region *cxlr) rc =cxl_memdev_scrub_init (cxlmd, cxlr, &ras_features[num_ras_features], scrub_inst); +if (rc == -EOPNOTSUPP ) + goto feat_scrub_done;if (rc <0 )return rc; scrub_inst++; num_ras_features++; -if (cxlr) +feat_scrub_done: +if (cxlr) {snprintf (cxl_dev_name,sizeof (cxl_dev_name),"cxl_region%d" , cxlr->id); -else + goto feat_register; + }else {snprintf (cxl_dev_name,sizeof (cxl_dev_name),"%s_%s" ,"cxl" ,dev_name (&cxlmd->dev)); + } + + rc =cxl_memdev_ecs_init (cxlmd, &ras_features[num_ras_features]); +if (rc == -EOPNOTSUPP ) + goto feat_ecs_done; +if (rc <0 ) +return rc; + + num_ras_features++; +feat_ecs_done: +feat_register:return edac_dev_register (&cxlmd->dev, cxl_dev_name,NULL , num_ras_features, ras_features); }
Signature · 1 line
2.43.0
PATCH v17 13/18 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 auxiliary device for each memory feature 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 | 11 ++ drivers/acpi/Makefile | 1 + drivers/acpi/ras2.c | 409 +++++++++++++++++++++++++++++++++++++++ include/acpi/ras2_acpi.h | 45 +++++ 4 files changed, 466 insertions(+) create mode 100755 drivers/acpi/ras2.c create mode 100644 include/acpi/ras2_acpi.h
drivers/acpi/Kconfig +11 -0
@@ -284,6 +284,17 @@ 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 AUXILIARY_BUS + 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
@@ -100,6 +100,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 +409 -0
409 lines not on this page · raw message
include/acpi/ras2_acpi.h new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v17 14/18 ras: mem: Add memory ACPI RAS2 driver
In reply to [email protected]From: Shiju Jose <[email protected]>
Memory ACPI RAS2 auxiliary driver binds to the auxiliary device add by the ACPI RAS2 table parser.
Driver uses a PCC subspace for communicating with the ACPI compliant platform.
Device with ACPI RAS2 scrub feature registers with EDAC device driver, which retrieves the scrub descriptor from EDAC scrub and exposes the scrub control attributes for RAS2 scrub instance to userspace in /sys/bus/edac/devices/acpi_ras_mem0/scrubX/.
--- Documentation/edac/scrub.rst | 76 +++++++ drivers/ras/Kconfig | 10 + drivers/ras/Makefile | 1 + drivers/ras/acpi_ras2.c | 385 +++++++++++++++++++++++++++++++++++ 4 files changed, 472 insertions(+) create mode 100644 drivers/ras/acpi_ras2.c
Documentation/edac/scrub.rst +76 -0
@@ -315,3 +315,79 @@ root@localhost:~# echo 0 > /sys/bus/edac/devices/cxl_region0/scrub0/enable_backg root@localhost:~# cat /sys/bus/edac/devices/cxl_region0/scrub0/enable_background 0 + +2. RAS2 + +2.1 On demand scrubbing for a specific memory region. + +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras_mem0/scrub0/min_cycle_duration + +3600 + +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras_mem0/scrub0/max_cycle_duration + +86400 + +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras_mem0/scrub0/current_cycle_duration + +36000 + +# Readback 'addr', non-zero - demand scrub is in progress, zero - scrub is finished. + +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras_mem0/scrub0/addr + +0 + +root@localhost:~# echo 54000 > /sys/bus/edac/devices/acpi_ras_mem0/scrub0/current_cycle_duration + +root@localhost:~# echo 0x150000 > /sys/bus/edac/devices/acpi_ras_mem0/scrub0/size + +# Write 'addr' starts demand scrubbing, please make sure other attributes are set prior to that. + +root@localhost:~# echo 0x120000 > /sys/bus/edac/devices/acpi_ras_mem0/scrub0/addr + +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras_mem0/scrub0/current_cycle_duration + +54000 + +# Readback 'addr', non-zero - demand scrub is in progress, zero - scrub is finished. + +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras_mem0/scrub0/addr + +0x120000 + +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras_mem0/scrub0/addr + +0 + +2.2 Background scrubbing the entire memory + +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras_mem0/scrub0/min_cycle_duration + +3600 + +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras_mem0/scrub0/max_cycle_duration + +86400 + +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras_mem0/scrub0/current_cycle_duration + +36000 + +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras_mem0/scrub0/enable_background + +0 + +root@localhost:~# echo 10800 > /sys/bus/edac/devices/acpi_ras_mem0/scrub0/current_cycle_duration + +root@localhost:~# echo 1 > /sys/bus/edac/devices/acpi_ras_mem0/scrub0/enable_background + +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras_mem0/scrub0/enable_background + +1 + +root@localhost:~# cat /sys/bus/edac/devices/acpi_ras_mem0/scrub0/current_cycle_duration + +10800 + +root@localhost:~# echo 0 > /sys/bus/edac/devices/acpi_ras_mem0/scrub0/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 +385 -0
385 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v17 15/18 EDAC: Add memory repair control feature
In reply to [email protected]From: Shiju Jose <[email protected]>
Add a generic EDAC memory repair control driver to manage memory repairs in the system, such as CXL Post Package Repair (PPR) and CXL memory sparing features.
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, for a permanent row repair, and soft PPR, for a temporary row repair. Soft PPR is much faster than hard PPR, but the repair is lost with a power cycle.
Similarly a CXL memory device may support soft and hard memory sparing at cacheline, row, bank and rank granularities. Memory sparing is defined as a repair function that replaces a portion of memory with a portion of functional memory at that same granularity.
When a CXL device detects an error in a memory, it may report the host of the need for a repair maintenance operation by using an event record where the "maintenance needed" flag is set. The event records contains the device physical address(DPA) and other attributes of the memory to repair (such as channel, sub-channel, bank group, bank, rank, row, column etc). The kernel will report the corresponding CXL general media or DRAM trace event to userspace, and userspace tools (e.g. rasdaemon) will initiate a repair operation in response to the device request via the sysfs repair control.
Device with memory repair features registers with EDAC device driver, which retrieves memory repair descriptor from EDAC memory repair driver and exposes the sysfs repair control attributes to userspace in /sys/bus/edac/devices/<dev-name>/mem_repairX/.
The common memory repair control interface abstracts the control of arbitrary memory repair functionality into a standardized set of functions. The sysfs memory repair attribute nodes are only available if the client driver has implemented the corresponding attribute callback function and provided operations to the EDAC device driver during registration.
--- .../ABI/testing/sysfs-edac-memory-repair | 245 +++++++++ Documentation/edac/features.rst | 3 + Documentation/edac/index.rst | 1 + Documentation/edac/memory_repair.rst | 101 ++++ drivers/edac/Makefile | 2 +- drivers/edac/edac_device.c | 33 ++ drivers/edac/mem_repair.c | 492 ++++++++++++++++++ include/linux/edac.h | 139 +++++ 8 files changed, 1015 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-edac-memory-repair create mode 100644 Documentation/edac/memory_repair.rst create mode 100755 drivers/edac/mem_repair.c
Documentation/ABI/testing/sysfs-edac-memory-repair new file +245 -0
@@ -0,0 +1,245 @@ +What: /sys/bus/edac/devices/<dev-name>/mem_repairX +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + The sysfs EDAC bus devices /<dev-name>/mem_repairX subdirectory + pertains to the memory media repair features control, such as + PPR (Post Package Repair), memory sparing etc, where<dev-name> + directory corresponds to a device registered with the EDAC + device driver for the memory repair features. + + Post Package Repair is a maintenance operation requests the memory + device to perform a repair operation on its media, in detail is a + memory self-healing feature that fixes a failing memory location by + replacing it with a spare row in a DRAM device. For example, a + CXL memory device with DRAM components that support PPR features may + implement PPR maintenance operations. DRAM components may support + two types of PPR functions: hard PPR, for a permanent row repair, and + soft PPR, for a temporary row repair. soft PPR is much faster than + hard PPR, but the repair is lost with a power cycle. + + Memory sparing is a repair function that replaces a portion + of memory with a portion of functional memory at that same + sparing granularity. Memory sparing has cacheline/row/bank/rank + sparing granularities. For example, in memory-sparing mode, + one memory rank serves as a spare for other ranks on the same + channel in case they fail. The spare rank is held in reserve and + not used as active memory until a failure is indicated, with + reserved capacity subtracted from the total available memory + in the system.The DIMM installation order for memory sparing + varies based on the number of processors and memory modules + installed in the server. After an error threshold is surpassed + in a system protected by memory sparing, the content of a failing + rank of DIMMs is copied to the spare rank. The failing rank is + then taken offline and the spare rank placed online for use as + active memory in place of the failed rank. + + The sysfs attributes nodes for a repair feature are only + present if the parent driver has implemented the corresponding + attr callback function and provided the necessary operations + to the EDAC device driver during registration. + + 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 device physical address(DPA). The DPA and other control + attributes to use will be presented in related error records. + +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/repair_function +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RO) Memory repair function type. For eg. post package repair, + memory sparing etc. + EDAC_SOFT_PPR - Soft post package repair + EDAC_HARD_PPR - Hard post package repair + EDAC_CACHELINE_MEM_SPARING - Cacheline memory sparing + EDAC_ROW_MEM_SPARING - Row memory sparing + EDAC_BANK_MEM_SPARING - Bank memory sparing + EDAC_RANK_MEM_SPARING - Rank memory sparing + All other values are reserved. + +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/persist_mode +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RW) Read/Write the current persist repair mode set for a + repair function. Persist repair modes supported in the + device, based on the memory repair function is temporary + or permanent and is lost with a power cycle. + EDAC_MEM_REPAIR_SOFT - Soft repair function (temporary repair). + EDAC_MEM_REPAIR_HARD - Hard memory repair function (permanent repair). + All other values are reserved. + +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/dpa_support +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RO) True if memory device required device physical + address (DPA) of memory to repair. + False if memory device required host specific physical + address (HPA) of memory to 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 device physical address(DPA) to use will be + presented in related error records. + +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/repair_safe_when_in_use +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RO) True if memory media is accessible and data is retained + during the memory repair operation. + The data may not be retained and memory requests may not be + correctly processed during a repair operation. In such case + the repair operation should not executed at runtime. + +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/hpa +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RW) Host Physical Address (HPA) of the memory to repair. + See attribute 'dpa_support' for more details. + The HPA to use will be provided in related error records. + +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/dpa +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RW) Device Physical Address (DPA) of the memory to repair. + See attribute 'dpa_support' for more details. + The specific DPA to use will be provided in related error + records. + +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/nibble_mask +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RW) Read/Write Nibble mask of the memory to repair. + Nibble mask identifies one or more nibbles in error on the + memory bus that produced the error event. Nibble Mask bit 0 + shall be set if nibble 0 on the memory bus produced the + event, etc. For example, CXL PPR and sparing, a nibble mask + bit set to 1 indicates the request to perform repair + operation in the specific device. All nibble mask bits set + to 1 indicates the request to perform the operation in all + devices. For CXL memory to repiar, the specific value of + nibble mask to use will be provided in related error records. + For more details, See nibble mask field in CXL spec ver 3.1, + section 8.2.9.7.1.2 Table 8-103 soft PPR and section + 8.2.9.7.1.3 Table 8-104 hard PPR, section 8.2.9.7.1.4 + Table 8-105 memory sparing. + +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/bank_group +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/bank +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/rank +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/row +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/column +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/channel +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/sub_channel +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RW) The control attributes associated with memory address + that is to be repaired. The specific value of attributes to + use depends on the portion of memory to repair and may be + reported to host in related error records and may be + available to userspace in trace events, such as in CXL + memory devices. + + channel - The channel of the memory to repair. Channel is + defined as an interface that can be independently accessed + for a transaction. + rank - The rank of the memory to repair. Rank is defined as a + set of memory devices on a channel that together execute a + transaction. + bank_group - The bank group of the memory to repair. + bank - The bank number of the memory to repair. + row - The row number of the memory to repair. + column - The column number of the memory to repair. + sub_channel - The sub-channel of the memory to repair. + + The requirement to set these attributes varies based on the + repair function. The attributes in sysfs are not present + unless required for a repair function. + For example, CXL spec ver 3.1, Section 8.2.9.7.1.2 Table 8-103 + soft PPR and Section 8.2.9.7.1.3 Table 8-104 hard PPR operations, + these attributes are not required to set. + For example, CXL spec ver 3.1, Section 8.2.9.7.1.4 Table 8-105 + memory sparing, these attributes are required to set based on + memory sparing granularity as follows. + Channel: Channel associated with the DPA that is to be spared + and applies to all subclasses of sparing (cacheline, bank, + row and rank sparing). + Rank: Rank associated with the DPA that is to be spared and + applies to all subclasses of sparing. + Bank & Bank Group: Bank & bank group are associated with + the DPA that is to be spared and applies to cacheline sparing, + row sparing and bank sparing subclasses. + Row: Row associated with the DPA that is to be spared and + applies to cacheline sparing and row sparing subclasses. + Column: column associated with the DPA that is to be spared + and applies to cacheline sparing only. + Sub-channel: sub-channel associated with the DPA that is to + be spared and applies to cacheline sparing only. + +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/min_hpa +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/min_dpa +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/min_nibble_mask +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/min_bank_group +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/min_bank +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/min_rank +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/min_row +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/min_column +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/min_channel +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/min_sub_channel + +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/max_hpa +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/max_dpa +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/max_nibble_mask +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/max_bank_group +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/max_bank +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/max_rank +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/max_row +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/max_column +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/max_channel +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/max_sub_channel +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (RW) The supported range of control attributes (optional) + associated with a memory address that is to be repaired. + The memory device may give the supported range of + attributes to use and it will depend on the memory device + and the portion of memory to repair. + The userspace may receive the specific value of attributes + to use for a repair operation from the memory device via + related error records and trace events, such as in CXL + memory devices. + +What: /sys/bus/edac/devices/<dev-name>/mem_repairX/repair +Date: Jan 2025 +KernelVersion: 6.13 +Contact: [email protected] +Description: + (WO) Issue the memory repair operation for the specified + memory repair attributes. The operation may fail if resources + are insufficient based on the requirements of the memory + device and repair function. + EDAC_DO_MEM_REPAIR - issue repair operation. + All other values are reserved.
Documentation/edac/features.rst +3 -0
@@ -97,3 +97,6 @@ RAS features ------------ 1. Memory Scrub Memory scrub features are documented in `Documentation/edac/scrub.rst`. + +2. Memory Repair +Memory repair features are documented in `Documentation/edac/memory_repair.rst`.
Documentation/edac/index.rst +1 -0
@@ -8,4 +8,5 @@ EDAC Subsystem :maxdepth: 1 features + memory_repair scrub
Documentation/edac/memory_repair.rst new file +101 -0
101 lines not on this page · raw message
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 += scrub.o ecs.o +edac_core-y += scrub.o ecs.o mem_repair.o edac_core-$(CONFIG_EDAC_DEBUG) += debugfs.o
drivers/edac/edac_device.c +33 -0
@@ -575,6 +575,7 @@ 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->mem_repair);kfree (ctx->scrub);kfree (ctx->dev.groups);kfree (ctx);
@@ -611,6 +612,7 @@ int edac_dev_register(struct device *parent, char *name,const struct attribute_group **ras_attr_groups;struct edac_dev_data *dev_data;struct edac_dev_feat_ctx *ctx; +int mem_repair_cnt =0 ;int attr_gcnt =0 ;int scrub_cnt =0 ;int ret, feat;
@@ -628,6 +630,10 @@ int edac_dev_register(struct device *parent, char *name,case RAS_FEAT_ECS : attr_gcnt += ras_features[feat].ecs_info.num_media_frus;break ; +case RAS_FEAT_MEM_REPAIR : + attr_gcnt++; + mem_repair_cnt++; +break ;default :return -EINVAL ; }
@@ -651,8 +657,17 @@ int edac_dev_register(struct device *parent, char *name, } } +if (mem_repair_cnt) { + ctx->mem_repair =kcalloc (mem_repair_cnt,sizeof (*ctx->mem_repair),GFP_KERNEL ); +if (!ctx->mem_repair) { + ret = -ENOMEM ; + goto data_mem_free; + } + } + attr_gcnt =0 ; scrub_cnt =0 ; + mem_repair_cnt =0 ;for (feat =0 ; feat < num_features; feat++, ras_features++) {switch (ras_features->ft_type) {case RAS_FEAT_SCRUB :
@@ -686,6 +701,23 @@ int edac_dev_register(struct device *parent, char *name, attr_gcnt += ras_features->ecs_info.num_media_frus;break ; +case RAS_FEAT_MEM_REPAIR : +if (!ras_features->mem_repair_ops || + mem_repair_cnt != ras_features->instance) + goto data_mem_free; + + dev_data = &ctx->mem_repair[mem_repair_cnt]; + dev_data->instance = mem_repair_cnt; + dev_data->mem_repair_ops = ras_features->mem_repair_ops; + dev_data->private = ras_features->ctx; + ret =edac_mem_repair_get_desc (parent, &ras_attr_groups[attr_gcnt], + ras_features->instance); +if (ret) + goto data_mem_free; + + mem_repair_cnt++; + attr_gcnt++; +break ;default : ret = -EINVAL ; goto data_mem_free;
@@ -712,6 +744,7 @@ int edac_dev_register(struct device *parent, char *name,return devm_add_action_or_reset (parent, edac_dev_unreg, &ctx->dev); data_mem_free: +kfree (ctx->mem_repair);kfree (ctx->scrub); groups_free:kfree (ras_attr_groups);
drivers/edac/mem_repair.c new file +492 -0
492 lines not on this page · raw message
include/linux/edac.h +139 -0
168 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v17 16/18 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 | 35 +++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 17 +++++++++++++++++ 2 files changed, 52 insertions(+)
drivers/cxl/core/mbox.c +35 -0
@@ -1085,6 +1085,41 @@ int cxl_set_feature(struct cxl_dev_state *cxlds, }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_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox; +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; + + struct cxl_memdev_maintenance_pi *pi __free(kfree) = +kmalloc (cxl_mbox->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 > cxl_mbox->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, + }; + +return cxl_internal_send_cmd (cxl_mbox, &mbox_cmd); +} +EXPORT_SYMBOL_NS_GPL (cxl_do_maintenance,CXL ); +/** * cxl_enumerate_cmds() - Enumerate commands for a device. * @mds: The driver data for the operation
drivers/cxl/cxlmem.h +17 -0
@@ -493,6 +493,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,
@@ -882,6 +883,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; +int cxl_internal_send_cmd (struct cxl_mailbox *cxl_mbox,struct cxl_mbox_cmd *cmd);int cxl_dev_state_identify (struct cxl_memdev_state *mds);
@@ -959,4 +973,7 @@ int cxl_set_feature(struct cxl_dev_state *cxlds, 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);#endif /* __CXL_MEM_H__ */
Signature · 1 line
2.43.0
PATCH v17 17/18 cxl/memfeature: Add CXL memory device soft 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. Soft PPR 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.
Soft PPR 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 error 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.2 describes the hPPR feature discovery and configuration.
Add support for controlling CXL memory device sPPR feature. Register with EDAC driver, which gets the memory repair attr descriptors from the EDAC memory repair driver and exposes sysfs repair control attributes for PRR to the userspace. For example CXL PPR control for the CXL mem0 device is exposed in /sys/bus/edac/devices/cxl_mem0/mem_repairX/
Tested with QEMU patch for CXL PPR feature.
https://lore.kernel.org/all/[email protected]/
--- Documentation/edac/memory_repair.rst | 58 ++++ drivers/cxl/core/memfeature.c | 393 ++++++++++++++++++++++++++- 2 files changed, 450 insertions(+), 1 deletion(-)
Documentation/edac/memory_repair.rst +58 -0
@@ -99,3 +99,61 @@ sysfs Sysfs files are documented in `Documentation/ABI/testing/sysfs-edac-memory-repair`. + +Example +------- + +The usage takes the form shown in this example: + +1. CXL memory device Soft Post Package Repair (Soft PPR) + +# read capabilities + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair0/dpa_support + +1 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair0/nibble_mask + +0x0 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair0/persist_mode + +0 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair0/repair_function + +0 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair0/repair_safe_when_in_use + +1 + +# set and readback attributes + +root@localhost:~# echo 0x8a2d > /sys/bus/edac/devices/cxl_mem0/mem_repair0/nibble_mask + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair0/min_dpa + +0x0 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair0/max_dpa + +0xfffffff + +root@localhost:~# echo 0x300000 > /sys/bus/edac/devices/cxl_mem0/mem_repair0/dpa + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair0/dpa + +0x300000 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair0/nibble_mask + +0x8a2d + +# issue repair operations + +# reapir returns error if unsupported/resources are not available +# for the repair operation. + +root@localhost:~# echo 1 > /sys/bus/edac/devices/cxl_mem0/mem_repair0/repair
drivers/cxl/core/memfeature.c +392 -1
426 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v17 18/18 cxl/memfeature: Add CXL memory device memory sparing control feature
In reply to [email protected]From: Shiju Jose <[email protected]>
Memory sparing is defined as a repair function that replaces a portion of memory with a portion of functional memory at that same DPA. The subclasses for this operation vary in terms of the scope of the sparing being performed. The cacheline sparing subclass refers to a sparing action that can replace a full cacheline. Row sparing is provided as an alternative to PPR sparing functions and its scope is that of a single DDR row. Bank sparing allows an entire bank to be replaced. Rank sparing is defined as an operation in which an entire DDR rank is replaced.
Memory sparing maintenance operations may be supported by CXL devices that implement CXL.mem protocol. A sparing maintenance operation requests the CXL device to perform a repair operation on its media.
For example, a CXL device with DRAM components that support memory sparing features may implement sparing maintenance operations.
The host may issue a query command by setting query resources flag in the input payload (CXL spec 3.1 Table 8-105) to determine availability of sparing resources for a given address. In response to a query request, the device shall report the resource availability by producing the memory sparing event record (CXL spec 3.1 Table 8-48) in which the Channel, Rank, Nibble Mask, Bank Group, Bank, Row, Column, Sub-Channel fields are a copy of the values specified in the request.
During the execution of a sparing maintenance operation, a CXL memory device:
- may not retain data
- may not be able to process CXL.mem requests correctly. These CXL memory device capabilities are specified by restriction flags in the memory sparing feature readable attributes.
When a CXL device identifies error on a memory component, the device may inform the host about the need for a memory sparing maintenance operation by using an Event Record, where the maintenance needed flag may set. The event record specifies some of the DPA, Channel, Rank, Nibble Mask, Bank Group, Bank, Row, Column, Sub-Channel fields that should be repaired. 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.4 describes the device's memory sparing maintenance operation feature.
CXL spec 3.1 section 8.2.9.7.2.3 describes the memory sparing feature discovery and configuration.
Add support for controlling CXL memory device memory sparing feature. Register with EDAC driver, which gets the memory repair attr descriptors from the EDAC memory repair driver and exposes sysfs repair control attributes for memory sparing to the userspace. For example CXL memory sparing control for the CXL mem0 device is exposed in /sys/bus/edac/devices/cxl_mem0/mem_repairX/
Use case
========
1. CXL device identifies a failure in a memory component, report to userspace in a CXL generic or DRAM trace event with DPA and other attributes of memory to repair such as channel, rank, nibble mask, bank Group, bank, row, column, sub-channel.
2. Rasdaemon process the trace event and issue query request in sysfs to check resources available for memory sparing if either of the following conditions met.
- number of corrected error reported on a CXL.mem media exceeds error
threshold
- maintenance needed flag set in the event record.
3. CXL device shall report the resource availability by producing the memory sparing event record in which the channel, rank, nibble mask, bank Group, bank, row, column, sub-channel fields are a copy of the values specified in the request. The query resource command shall return error (invalid input) if the controller does not support reporting resource is available.
4. Rasdaemon process the memory sparing trace event and issue repair request for memory sparing.
Kernel CXL driver shall report memory sparing event record to the userspace with the resource availability in order rasdaemon to process the event record and issue a repair request in sysfs for the memory sparing operation in the CXL device.
Tested for memory sparing control feature with
"hw/cxl: Add memory sparing control feature"
Repository: "https://gitlab.com/shiju.jose/qemu.git"
Branch: cxl-ras-features-2024-10-24
--- Documentation/edac/memory_repair.rst | 90 +++++ drivers/cxl/core/memfeature.c | 497 ++++++++++++++++++++++++++- 2 files changed, 585 insertions(+), 2 deletions(-)
Documentation/edac/memory_repair.rst +90 -0
@@ -157,3 +157,93 @@ root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair0/nibble_mask # for the repair operation. root@localhost:~# echo 1 > /sys/bus/edac/devices/cxl_mem0/mem_repair0/repair + +1.2. CXL memory sparing + +# read capabilities + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair1/repair_function + +2 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair1/dpa_support + +1 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair1/persist_mode + +0 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair1/repair_safe_when_in_use + +1 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair1/min_dpa + +0x0 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair1/max_dpa + +0xfffffff + +#set and readback attributes + +root@localhost:~# echo 0x700000 > /sys/bus/edac/devices/cxl_mem0/mem_repair1/dpa + +root@localhost:~# echo 1 > /sys/bus/edac/devices/cxl_mem0/mem_repair1/bank_group + +root@localhost:~# echo 3 > /sys/bus/edac/devices/cxl_mem0/mem_repair1/bank + +root@localhost:~# echo 2 > /sys/bus/edac/devices/cxl_mem0/mem_repair1/channel + +root@localhost:~# echo 7 > /sys/bus/edac/devices/cxl_mem0/mem_repair1/rank + +root@localhost:~# echo 0x240a > /sys/bus/edac/devices/cxl_mem0/mem_repair1/row + +root@localhost:~# echo 5 > /sys/bus/edac/devices/cxl_mem0/mem_repair1/sub_channel + +root@localhost:~# echo 11 > /sys/bus/edac/devices/cxl_mem0/mem_repair1/column + +root@localhost:~# echo 0x85c2 > /sys/bus/edac/devices/cxl_mem0/mem_repair1/nibble_mask + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair1/bank_group + +1 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair1/bank + +3 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair1/channel + +2 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair1/rank + +7 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair1/row + +0x240a + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair1/sub_channel + +5 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair1/column + +11 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair1/nibble_mask + +0x85c2 + +root@localhost:~# cat /sys/bus/edac/devices/cxl_mem0/mem_repair1/dpa + +0x700000 + +# issue repair operation +# repair returns error if unsupported or resources are not available for the +# repair operation. + +root@localhost:~# echo 1 > /sys/bus/edac/devices/cxl_mem0/mem_repair1/repair
drivers/cxl/core/memfeature.c +495 -2
527 lines not on this page · raw message
Signature · 1 line
2.43.0
Borislav Petkov
maintainerQuoted 5 lines · On Fri, Nov 22, 2024 at 06:03:57PM +0000, [email protected] wrote:
drivers/edac/Makefile | 1 + drivers/edac/ecs.c | 207 +++ drivers/edac/edac_device.c | 183 ++ drivers/edac/mem_repair.c | 492 +++++ drivers/edac/scrub.c | 209 +++
Quoted 8 lines
drivers/ras/Kconfig | 10 + drivers/ras/Makefile | 1 + drivers/ras/acpi_ras2.c | 385 ++++ include/acpi/ras2_acpi.h | 45 + include/cxl/features.h | 48 + include/cxl/mailbox.h | 45 +- include/linux/edac.h | 238 +++ include/uapi/linux/cxl_mem.h | 3 +
So what's the plan here? Am I supposed to merge the EDAC/RAS bits through the RAS tree and then give folks an immutable branch or how do we want to proceed here?
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 15 lines · On Fri, 3 Jan 2025 12:41:45 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 5 lines · On Fri, Nov 22, 2024 at 06:03:57PM +0000, [email protected] wrote:
drivers/edac/Makefile | 1 + drivers/edac/ecs.c | 207 +++ drivers/edac/edac_device.c | 183 ++ drivers/edac/mem_repair.c | 492 +++++ drivers/edac/scrub.c | 209 +++Quoted 8 lines
drivers/ras/Kconfig | 10 + drivers/ras/Makefile | 1 + drivers/ras/acpi_ras2.c | 385 ++++ include/acpi/ras2_acpi.h | 45 + include/cxl/features.h | 48 + include/cxl/mailbox.h | 45 +- include/linux/edac.h | 238 +++ include/uapi/linux/cxl_mem.h | 3 +
Quoted 4 lines
So what's the plan here? Am I supposed to merge the EDAC/RAS bits through the RAS tree and then give folks an immutable branch or how do we want to proceed here?
Dave Jiang / Rafael, what would work best for the two of you?
To me Boris' suggestion makes sense, particularly as that avoids the complexity of CXL get/set features being in multiple series.
I think the split that would make sense is:
EDAC immutable branch for:
1: EDAC: Add support for EDAC device features control 2: Add scrub control feature
3: EDAC: Add ECS control feature
15: EDAC: Add memory repair control feature
ACPI merges EDAC immutable +
13: ACPI:RAS2: Add ACPI RAS2 driver
14: ras: mem: Add memory ACPI RAS2 driver
CXL merges EDAC immutable +
4: cxl: Refactor user ioctl command path from mds to mailbox 5: cxl: Add Get Supported Features command for kernel usage 6: cxl/mbox: Add GET_FEATURE mailbox command
7: cxl: Add Get Feature command support for user submission 8: cxl/mbox: Add SET_FEATURE mailbox command
9: cxl: Add Set Feature command support for user submission 10: cxl: Add UUIDs for the CXL RAS features
11: cxl/memfeature: Add CXL memory device patrol scrub control feature 12: cxl/memfeature: Add CXL memory device ECS control feature 16: cxl/mbox: Add support for PERFORM_MAINTENANCE mailbox command 17: cxl/memfeature: Add CXL memory device soft PPR control feature 18: cxl/memfeature: Add CXL memory device memory sparing control feature
That does mean that the actual drivers/edac/ specific drivers land
via the ACPI and CXL trees only, but without another layer of immutable branches we can't avoid that. Might cause merge conflicts in Kconfig/Makefiles but otherwise shouldn't be too bad.
There is going to be some noise in documentation as examples are added to the docs with the actual drivers (whereas generic docs are introduced with the infrastructure). I think that will work out though. Shiju, could you spin this ordering up and check it all works (incorporating Dave's updates to the GET / SET feature)?
Thanks,
Jonathan
Dave Jiang
maintainerQuoted 40 lines · Jonathan Cameron
Quoted 15 lines · On Fri, 3 Jan 2025 12:41:45 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 5 lines · On Fri, Nov 22, 2024 at 06:03:57PM +0000, [email protected] wrote:
drivers/edac/Makefile | 1 + drivers/edac/ecs.c | 207 +++ drivers/edac/edac_device.c | 183 ++ drivers/edac/mem_repair.c | 492 +++++ drivers/edac/scrub.c | 209 +++Quoted 8 lines
drivers/ras/Kconfig | 10 + drivers/ras/Makefile | 1 + drivers/ras/acpi_ras2.c | 385 ++++ include/acpi/ras2_acpi.h | 45 + include/cxl/features.h | 48 + include/cxl/mailbox.h | 45 +- include/linux/edac.h | 238 +++ include/uapi/linux/cxl_mem.h | 3 +Quoted 4 lines
So what's the plan here? Am I supposed to merge the EDAC/RAS bits through the RAS tree and then give folks an immutable branch or how do we want to proceed here?
Dave Jiang / Rafael, what would work best for the two of you?
To me Boris' suggestion makes sense, particularly as that avoids the complexity of CXL get/set features being in multiple series.
I think the split that would make sense is:
EDAC immutable branch for:
1: EDAC: Add support for EDAC device features control 2: Add scrub control feature
3: EDAC: Add ECS control feature
15: EDAC: Add memory repair control featureACPI merges EDAC immutable +
13: ACPI:RAS2: Add ACPI RAS2 driver
14: ras: mem: Add memory ACPI RAS2 driver
Quoted 13 lines
CXL merges EDAC immutable +
4: cxl: Refactor user ioctl command path from mds to mailbox 5: cxl: Add Get Supported Features command for kernel usage 6: cxl/mbox: AddGET_FEATUREmailbox command
7: cxl: Add Get Feature command support for user submission 8: cxl/mbox: AddSET_FEATUREmailbox command
9: cxl: Add Set Feature command support for user submission 10: cxl: Add UUIDs for the CXL RAS features
11: cxl/memfeature: Add CXL memory device patrol scrub control feature 12: cxl/memfeature: Add CXL memory device ECS control feature 16: cxl/mbox: Add support forPERFORM_MAINTENANCEmailbox command 17: cxl/memfeature: Add CXL memory device soft PPR control feature 18: cxl/memfeature: Add CXL memory device memory sparing control feature
That works for me.
DJ
Quoted 14 lines
That does mean that the actual
drivers/edac/specific drivers land
via the ACPI and CXL trees only, but without another layer of immutable branches we can't avoid that. Might cause merge conflicts in Kconfig/Makefiles but otherwise shouldn't be too bad.There is going to be some noise in documentation as examples are added to the docs with the actual drivers (whereas generic docs are introduced with the infrastructure). I think that will work out though. Shiju, could you spin this ordering up and check it all works (incorporating Dave's updates to the GET / SET feature)?
Quoted 1 line
Thanks,
Jonathan
Quoted 84 lines
-----Original Message-----
From: Dave Jiang <[email protected]>
Sent: 03 January 2025 15:50
To: Jonathan Cameron <[email protected]>; Borislav Petkov <[email protected]>
Cc: Shiju Jose <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; tanxiaofei <[email protected]>; Zengtao (B) <[email protected]>; Roberto Sassu <[email protected]>; [email protected]; wanghuiqiang <[email protected]>; Linuxarm <[email protected]>
Subject: Re: [PATCH v17 00/18] EDAC: Scrub: introduce generic EDAC RAS control feature driver + CXL/ACPI-RAS2 driversQuoted 40 lines · Jonathan Cameron
Quoted 15 lines · On Fri, 3 Jan 2025 12:41:45 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 5 lines · On Fri, Nov 22, 2024 at 06:03:57PM +0000, [email protected] wrote:
drivers/edac/Makefile | 1 + drivers/edac/ecs.c | 207 +++ drivers/edac/edac_device.c | 183 ++ drivers/edac/mem_repair.c | 492 +++++ drivers/edac/scrub.c | 209 +++Quoted 8 lines
drivers/ras/Kconfig | 10 + drivers/ras/Makefile | 1 + drivers/ras/acpi_ras2.c | 385 ++++ include/acpi/ras2_acpi.h | 45 + include/cxl/features.h | 48 + include/cxl/mailbox.h | 45 +- include/linux/edac.h | 238 +++ include/uapi/linux/cxl_mem.h | 3 +Quoted 4 lines
So what's the plan here? Am I supposed to merge the EDAC/RAS bits through the RAS tree and then give folks an immutable branch or how do we want to proceed here?
Dave Jiang / Rafael, what would work best for the two of you?
To me Boris' suggestion makes sense, particularly as that avoids the complexity of CXL get/set features being in multiple series.
I think the split that would make sense is:
EDAC immutable branch for:
1: EDAC: Add support for EDAC device features control 2: Add scrub control feature
3: EDAC: Add ECS control feature
15: EDAC: Add memory repair control featureACPI merges EDAC immutable +
13: ACPI:RAS2: Add ACPI RAS2 driver
14: ras: mem: Add memory ACPI RAS2 driverQuoted 15 lines
CXL merges EDAC immutable +
4: cxl: Refactor user ioctl command path from mds to mailbox 5: cxl: Add Get Supported Features command for kernel usage 6: cxl/mbox: AddGET_FEATUREmailbox command
7: cxl: Add Get Feature command support for user submission 8: cxl/mbox: AddSET_FEATUREmailbox command
9: cxl: Add Set Feature command support for user submission 10: cxl: Add UUIDs for the CXL RAS features
11: cxl/memfeature: Add CXL memory device patrol scrub control
feature
12: cxl/memfeature: Add CXL memory device ECS control feature 16: cxl/mbox: Add support forPERFORM_MAINTENANCEmailbox command 17: cxl/memfeature: Add CXL memory device soft PPR control feature 18: cxl/memfeature: Add CXL memory device memory sparing control
feature
Quoted 15 lines
That works for me.
DJ
Quoted 11 lines
That does mean that the actual
drivers/edac/specific drivers land via the ACPI and CXL trees only, but without another layer of immutable branches we can't avoid that. Might cause merge conflicts in Kconfig/Makefiles but otherwise shouldn't be too bad.There is going to be some noise in documentation as examples are added to the docs with the actual drivers (whereas generic docs are introduced with the infrastructure). I think that will work out though. Shiju, could you spin this ordering up and check it all works (incorporating Dave's updates to the GET / SET feature)?
Rebased, reordered and tested fine. Waiting for some information before sharing the updated patches.
Thanks,
Shiju
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
Thanks,
Jonathan
Quoted 25 lines
-----Original Message-----
From: Shiju Jose <[email protected]>
Sent: 03 January 2025 18:33
To: Dave Jiang <[email protected]>; Jonathan Cameron <[email protected]>; Borislav Petkov <[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]; [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 v17 00/18] EDAC: Scrub: introduce generic EDAC RAS control feature driver + CXL/ACPI-RAS2 drivers
[...]
Quoted 69 lines
Quoted 69 lines · Jonathan Cameron
Quoted 40 lines
Quoted 15 lines · On Fri, 3 Jan 2025 12:41:45 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 5 lines · On Fri, Nov 22, 2024 at 06:03:57PM +0000, [email protected] wrote:
drivers/edac/Makefile | 1 + drivers/edac/ecs.c | 207 +++ drivers/edac/edac_device.c | 183 ++ drivers/edac/mem_repair.c | 492 +++++ drivers/edac/scrub.c | 209 +++Quoted 8 lines
drivers/ras/Kconfig | 10 + drivers/ras/Makefile | 1 + drivers/ras/acpi_ras2.c | 385 ++++ include/acpi/ras2_acpi.h | 45 + include/cxl/features.h | 48 + include/cxl/mailbox.h | 45 +- include/linux/edac.h | 238 +++ include/uapi/linux/cxl_mem.h | 3 +Quoted 4 lines
So what's the plan here? Am I supposed to merge the EDAC/RAS bits through the RAS tree and then give folks an immutable branch or how do we want to proceed here?
Dave Jiang / Rafael, what would work best for the two of you?
To me Boris' suggestion makes sense, particularly as that avoids the complexity of CXL get/set features being in multiple series.
I think the split that would make sense is:
EDAC immutable branch for:
1: EDAC: Add support for EDAC device features control 2: Add scrub control feature
3: EDAC: Add ECS control feature
15: EDAC: Add memory repair control featureACPI merges EDAC immutable +
13: ACPI:RAS2: Add ACPI RAS2 driver
14: ras: mem: Add memory ACPI RAS2 driverQuoted 15 lines
CXL merges EDAC immutable +
4: cxl: Refactor user ioctl command path from mds to mailbox 5: cxl: Add Get Supported Features command for kernel usage 6: cxl/mbox: AddGET_FEATUREmailbox command
7: cxl: Add Get Feature command support for user submission 8: cxl/mbox: AddSET_FEATUREmailbox command
9: cxl: Add Set Feature command support for user submission 10: cxl: Add UUIDs for the CXL RAS features
11: cxl/memfeature: Add CXL memory device patrol scrub control
feature
12: cxl/memfeature: Add CXL memory device ECS control feature 16: cxl/mbox: Add support forPERFORM_MAINTENANCEmailbox command 17: cxl/memfeature: Add CXL memory device soft PPR control feature 18: cxl/memfeature: Add CXL memory device memory sparing control
featureThat works for me.
DJ
Quoted 6 lines
That does mean that the actual
drivers/edac/specific drivers land via the ACPI and CXL trees only, but without another layer of immutable branches we can't avoid that. Might cause merge conflicts in Kconfig/Makefiles but otherwise shouldn't be too bad.
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
There is going to be some noise in documentation as examples are added to the docs with the actual drivers (whereas generic docs are introduced with the infrastructure). I think that will work out though. Shiju, could you spin this ordering up and check it all works (incorporating Dave's updates to the GET / SET feature)?
Rebased, reordered and tested fine. Waiting for some information before sharing the updated patches.
Please find updated and reordered patches in
https://github.com/shijujose4/linux/tree/edac-enhancement-ras-features_v18
Please note that EDAC patches are the same as in v17 other than updated, the kernel version to 6.14 in the documentation.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Thanks,
Jonathan
Thanks,
Shiju
Borislav Petkov
maintainerQuoted 4 lines · Shiju Jose
Please find updated and reordered patches in
https://github.com/shijujose4/linux/tree/edac-enhancement-ras-features_v18
Please note that EDAC patches are the same as in v17 other than updated, the kernel version to 6.14 in the documentation.
If you want patches applied, you send them as mails to the mailing list. Not some branch on github. Unless I should take the v17 stuff...
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette