hw/cxl/cxl-mailbox-utils: Add feature commands, device patrol scrub control and DDR5 ECS control feature
v6 cover hw/cxl/cxl-mailbox-utils: Add feature commands, device patrol scrub control and DDR5 ECS control feature
I believe this is ready to merge (I was holding it until DCD was in place and that is upstream now)
Changes since v5:
- Include Gregory's patch to bring forward the renames. Not strictly needed here, but a sensible change and it makes reordring my CXL staging tree a lot simpler.
Based-on: [PATCH qemu 0/4] hw/cxl: Add support for scan media
Message-id: [email protected]
Add support for the feature commands, device patrol scrub control and DDR5 ECS control features.
CXL spec 3.1 section 8.2.9.6 describes optional device specific features. CXL spec 3.1 section 8.2.9.9.11.1 describes the device patrol scrub control feature.
CXL spec 3.1 section 8.2.9.9.11.2 describes the DDR5 Error Check Scrub (ECS) control feature.
This series is one of the test vehicles for the support of RAS feature control in Linux and having it upstream would be useful to support that work. There are also a lot more 'features' using the feature infrastructure that are dependent on the first 2 patches.
Gregory Price (1):
cxl/mailbox: move mailbox effect definitions to a header
Shiju Jose (3):
hw/cxl/cxl-mailbox-utils: Add support for feature commands (8.2.9.6) hw/cxl/cxl-mailbox-utils: Add device patrol scrub control feature hw/cxl/cxl-mailbox-utils: Add device DDR5 ECS control feature
include/hw/cxl/cxl_device.h | 58 +++++ include/hw/cxl/cxl_mailbox.h | 18 ++ hw/cxl/cxl-mailbox-utils.c | 432 +++++++++++++++++++++++++++++++++-- hw/mem/cxl_type3.c | 23 ++ 4 files changed, 512 insertions(+), 19 deletions(-) create mode 100644 include/hw/cxl/cxl_mailbox.h
Signature · 1 line
2.43.0
PATCH v6 1/4 cxl/mailbox: move mailbox effect definitions to a header
From: Gregory Price <[email protected]>
Preparation for allowing devices to define their own CCI commands
--- include/hw/cxl/cxl_mailbox.h | 18 ++++++++++++++++++ hw/cxl/cxl-mailbox-utils.c | 34 +++++++++++++++------------------- 2 files changed, 33 insertions(+), 19 deletions(-)
include/hw/cxl/cxl_mailbox.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* QEMU CXL Mailbox +* +* This work is licensed under the terms of the GNU GPL, version 2. See the +* COPYING file in the top-level directory. +*/ + +#ifndef CXL_MAILBOX_H +#define CXL_MAILBOX_H + +#define CXL_MBOX_IMMEDIATE_CONFIG_CHANGE (1 << 1) +#define CXL_MBOX_IMMEDIATE_DATA_CHANGE (1 << 2) +#define CXL_MBOX_IMMEDIATE_POLICY_CHANGE (1 << 3) +#define CXL_MBOX_IMMEDIATE_LOG_CHANGE (1 << 4) +#define CXL_MBOX_SECURITY_STATE_CHANGE (1 << 5) +#define CXL_MBOX_BACKGROUND_OPERATION (1 << 6) + +#endif
hw/cxl/cxl-mailbox-utils.c +15 -19
@@ -12,6 +12,7 @@#include "hw/pci/msix.h" #include "hw/cxl/cxl.h" #include "hw/cxl/cxl_events.h" +#include "hw/cxl/cxl_mailbox.h" #include "hw/pci/pci.h" #include "hw/pci-bridge/cxl_upstream_port.h" #include "qemu/cutils.h"
@@ -2102,28 +2103,21 @@ static CXLRetCode cmd_dcd_release_dyn_cap(const struct cxl_cmd *cmd,return CXL_MBOX_SUCCESS ; } -#define IMMEDIATE_CONFIG_CHANGE (1 << 1) -#define IMMEDIATE_DATA_CHANGE (1 << 2) -#define IMMEDIATE_POLICY_CHANGE (1 << 3) -#define IMMEDIATE_LOG_CHANGE (1 << 4) -#define SECURITY_STATE_CHANGE (1 << 5) -#define BACKGROUND_OPERATION (1 << 6) -static const struct cxl_cmd cxl_cmd_set[256 ][256 ] = { [EVENTS ][GET_RECORDS ] = {"EVENTS_GET_RECORDS" , cmd_events_get_records,1 ,0 }, [EVENTS ][CLEAR_RECORDS ] = {"EVENTS_CLEAR_RECORDS" , - cmd_events_clear_records, ~0 ,IMMEDIATE_LOG_CHANGE }, + cmd_events_clear_records, ~0 ,CXL_MBOX_IMMEDIATE_LOG_CHANGE }, [EVENTS ][GET_INTERRUPT_POLICY ] = {"EVENTS_GET_INTERRUPT_POLICY" , cmd_events_get_interrupt_policy,0 ,0 }, [EVENTS ][SET_INTERRUPT_POLICY ] = {"EVENTS_SET_INTERRUPT_POLICY" , cmd_events_set_interrupt_policy, - ~0 ,IMMEDIATE_CONFIG_CHANGE }, + ~0 ,CXL_MBOX_IMMEDIATE_CONFIG_CHANGE }, [FIRMWARE_UPDATE ][GET_INFO ] = {"FIRMWARE_UPDATE_GET_INFO" , cmd_firmware_update_get_info,0 ,0 }, [TIMESTAMP ][GET ] = {"TIMESTAMP_GET" , cmd_timestamp_get,0 ,0 }, [TIMESTAMP ][SET ] = {"TIMESTAMP_SET" , cmd_timestamp_set, -8 ,IMMEDIATE_POLICY_CHANGE }, +8 ,CXL_MBOX_IMMEDIATE_POLICY_CHANGE }, [LOGS ][GET_SUPPORTED ] = {"LOGS_GET_SUPPORTED" , cmd_logs_get_supported,0 ,0 }, [LOGS ][GET_LOG ] = {"LOGS_GET_LOG" , cmd_logs_get_log,0x18 ,0 },
@@ -2133,9 +2127,11 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = { cmd_ccls_get_partition_info, 0, 0 }, [CCLS][GET_LSA] = { "CCLS_GET_LSA", cmd_ccls_get_lsa, 8, 0 }, [CCLS][SET_LSA] = { "CCLS_SET_LSA", cmd_ccls_set_lsa, - ~0, IMMEDIATE_CONFIG_CHANGE | IMMEDIATE_DATA_CHANGE }, + ~0, CXL_MBOX_IMMEDIATE_CONFIG_CHANGE | CXL_MBOX_IMMEDIATE_DATA_CHANGE }, [SANITIZE][OVERWRITE] = { "SANITIZE_OVERWRITE", cmd_sanitize_overwrite, 0, - IMMEDIATE_DATA_CHANGE | SECURITY_STATE_CHANGE | BACKGROUND_OPERATION }, + (CXL_MBOX_IMMEDIATE_DATA_CHANGE | +CXL_MBOX_SECURITY_STATE_CHANGE | + CXL_MBOX_BACKGROUND_OPERATION)}, [PERSISTENT_MEM][GET_SECURITY_STATE] = { "GET_SECURITY_STATE", cmd_get_security_state, 0, 0 }, [MEDIA_AND_POISON][GET_POISON_LIST] = { "MEDIA_AND_POISON_GET_POISON_LIST",
@@ -2148,7 +2144,7 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = {"MEDIA_AND_POISON_GET_SCAN_MEDIA_CAPABILITIES" , cmd_media_get_scan_media_capabilities, 16, 0 }, [MEDIA_AND_POISON][SCAN_MEDIA] = { "MEDIA_AND_POISON_SCAN_MEDIA", - cmd_media_scan_media, 17, BACKGROUND_OPERATION }, + cmd_media_scan_media, 17, CXL_MBOX_BACKGROUND_OPERATION }, [MEDIA_AND_POISON][GET_SCAN_MEDIA_RESULTS] = {"MEDIA_AND_POISON_GET_SCAN_MEDIA_RESULTS" , cmd_media_get_scan_media_results, 0, 0 },
@@ -2162,10 +2158,10 @@ static const struct cxl_cmd cxl_cmd_set_dcd[256][256] = { 8, 0 }, [DCD_CONFIG][ADD_DYN_CAP_RSP] = {"DCD_ADD_DYNAMIC_CAPACITY_RESPONSE" , cmd_dcd_add_dyn_cap_rsp, - ~0, IMMEDIATE_DATA_CHANGE }, + ~0, CXL_MBOX_IMMEDIATE_DATA_CHANGE }, [DCD_CONFIG][RELEASE_DYN_CAP] = {"DCD_RELEASE_DYNAMIC_CAPACITY" , cmd_dcd_release_dyn_cap, - ~0, IMMEDIATE_DATA_CHANGE }, + ~0, CXL_MBOX_IMMEDIATE_DATA_CHANGE }, }; static const struct cxl_cmd cxl_cmd_set_sw[256][256] = {
@@ -2173,8 +2169,8 @@ static const struct cxl_cmd cxl_cmd_set_sw[256][256] = { [INFOSTAT][BACKGROUND_OPERATION_STATUS] = { "BACKGROUND_OPERATION_STATUS", cmd_infostat_bg_op_sts, 0, 0 }, [TIMESTAMP][GET] = { "TIMESTAMP_GET", cmd_timestamp_get, 0, 0 }, - [TIMESTAMP][SET] = { "TIMESTAMP_SET", cmd_timestamp_set, 0, - IMMEDIATE_POLICY_CHANGE }, + [TIMESTAMP][SET] = { "TIMESTAMP_SET", cmd_timestamp_set, 8, + CXL_MBOX_IMMEDIATE_POLICY_CHANGE }, [LOGS][GET_SUPPORTED] = { "LOGS_GET_SUPPORTED", cmd_logs_get_supported, 0, 0 }, [LOGS][GET_LOG] = { "LOGS_GET_LOG", cmd_logs_get_log, 0x18, 0 },
@@ -2217,7 +2213,7 @@ int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, }/* Only one bg command at a time */ -if ((cxl_cmd->effect &BACKGROUND_OPERATION ) && +if ((cxl_cmd->effect &CXL_MBOX_BACKGROUND_OPERATION ) && cci->bg.runtime >0 ) {return CXL_MBOX_BUSY ; }
@@ -2242,7 +2238,7 @@ int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, } ret = (*h)(cxl_cmd, pl_in, len_in, pl_out, len_out, cci); -if ((cxl_cmd->effect &BACKGROUND_OPERATION ) && +if ((cxl_cmd->effect &CXL_MBOX_BACKGROUND_OPERATION ) && ret ==CXL_MBOX_BG_STARTED ) { *bg_started = true; }else {
Signature · 1 line
2.43.0
PATCH v6 2/4 hw/cxl/cxl-mailbox-utils: Add support for feature commands (8.2.9.6)
In reply to Jonathan CameronFrom: Shiju Jose <[email protected]>
CXL spec 3.1 section 8.2.9.6 describes optional device specific features. CXL devices supports features with changeable attributes.
Get Supported Features retrieves the list of supported device specific features. The settings of a feature can be retrieved using Get Feature and optionally modified using Set Feature.
--- include/hw/cxl/cxl_device.h | 10 ++ hw/cxl/cxl-mailbox-utils.c | 258 ++++++++++++++++++++++++++++++++++++ 2 files changed, 268 insertions(+)
include/hw/cxl/cxl_device.h +10 -0
@@ -464,6 +464,14 @@ typedef struct CXLDCRegion {unsigned long *blk_bitmap; } CXLDCRegion; +typedef struct CXLSetFeatureInfo { +QemuUUID uuid; +uint8_t data_transfer_flag; +bool data_saved_across_reset; +uint16_t data_offset; +size_t data_size; +}CXLSetFeatureInfo ; +struct CXLType3Dev {/* Private */ PCIDevice parent_obj;
@@ -501,6 +509,8 @@ struct CXLType3Dev {CXLPoisonList scan_media_results;bool scan_media_hasrun; +CXLSetFeatureInfo set_feat_info; +struct dynamic_capacity {HostMemoryBackend *host_dc;AddressSpace host_dc_as;
hw/cxl/cxl-mailbox-utils.c +258 -0
276 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v6 3/4 hw/cxl/cxl-mailbox-utils: Add device patrol scrub control feature
In reply to Jonathan CameronFrom: Shiju Jose <[email protected]>
CXL spec 3.1 section 8.2.9.9.11.1 describes the device patrol scrub control feature. The device patrol scrub proactively locates and makes corrections to errors in regular cycle. The patrol scrub control allows the request to configure patrol scrub input configurations.
The patrol scrub control allows the requester to specify the number of hours for which the patrol scrub cycles must be completed, provided that the requested number is not less than the minimum number of hours for the patrol scrub cycle that the device is capable of. In addition, the patrol scrub controls allow the host to disable and enable the feature in case disabling of the feature is needed for other purposes such as performance-aware operations which require the background operations to be turned off.
--- include/hw/cxl/cxl_device.h | 24 +++++++++++ hw/cxl/cxl-mailbox-utils.c | 79 ++++++++++++++++++++++++++++++++++--- hw/mem/cxl_type3.c | 9 +++++ 3 files changed, 107 insertions(+), 5 deletions(-)
include/hw/cxl/cxl_device.h +24 -0
@@ -427,6 +427,26 @@ typedef struct CXLPoison { typedef QLIST_HEAD(, CXLPoison) CXLPoisonList;#define CXL_POISON_LIST_LIMIT 256 +/* CXL memory device patrol scrub control attributes */ +typedef struct CXLMemPatrolScrubReadAttrs { +uint8_t scrub_cycle_cap; +uint16_t scrub_cycle; +uint8_t scrub_flags; +} QEMU_PACKED CXLMemPatrolScrubReadAttrs; + +typedef struct CXLMemPatrolScrubWriteAttrs { +uint8_t scrub_cycle_hr; +uint8_t scrub_flags; +} QEMU_PACKED CXLMemPatrolScrubWriteAttrs; + +#define CXL_MEMDEV_PS_GET_FEATURE_VERSION 0x01 +#define CXL_MEMDEV_PS_SET_FEATURE_VERSION 0x01 +#define CXL_MEMDEV_PS_SCRUB_CYCLE_CHANGE_CAP_DEFAULT BIT(0) +#define CXL_MEMDEV_PS_SCRUB_REALTIME_REPORT_CAP_DEFAULT BIT(1) +#define CXL_MEMDEV_PS_CUR_SCRUB_CYCLE_DEFAULT 12 +#define CXL_MEMDEV_PS_MIN_SCRUB_CYCLE_DEFAULT 1 +#define CXL_MEMDEV_PS_ENABLE_DEFAULT 0 +#define DCD_MAX_NUM_REGION 8 typedef struct CXLDCExtentRaw {
@@ -511,6 +531,10 @@ struct CXLType3Dev {CXLSetFeatureInfo set_feat_info; +/* Patrol scrub control attributes */ +CXLMemPatrolScrubReadAttrs patrol_scrub_attrs; +CXLMemPatrolScrubWriteAttrs patrol_scrub_wr_attrs; +struct dynamic_capacity {HostMemoryBackend *host_dc;AddressSpace host_dc_as;
hw/cxl/cxl-mailbox-utils.c +74 -5
127 lines not on this page · raw message
hw/mem/cxl_type3.c +9 -0
@@ -893,6 +893,15 @@ static void ct3_realize(PCIDevice *pci_dev, Error **errp) }cxl_event_init (&ct3d->cxl_dstate,2 ); +/* Set default value for patrol scrub attributes */ + ct3d->patrol_scrub_attrs.scrub_cycle_cap = +CXL_MEMDEV_PS_SCRUB_CYCLE_CHANGE_CAP_DEFAULT | +CXL_MEMDEV_PS_SCRUB_REALTIME_REPORT_CAP_DEFAULT ; + ct3d->patrol_scrub_attrs.scrub_cycle = +CXL_MEMDEV_PS_CUR_SCRUB_CYCLE_DEFAULT | + (CXL_MEMDEV_PS_MIN_SCRUB_CYCLE_DEFAULT <<8 ); + ct3d->patrol_scrub_attrs.scrub_flags =CXL_MEMDEV_PS_ENABLE_DEFAULT ; +return ; err_release_cdat:
Signature · 1 line
2.43.0
PATCH v6 4/4 hw/cxl/cxl-mailbox-utils: Add device DDR5 ECS control feature
In reply to Jonathan CameronFrom: Shiju Jose <[email protected]>
CXL spec 3.1 section 8.2.9.9.11.2 describes the DDR5 Error Check Scrub (ECS) control feature.
The Error Check Scrub (ECS) is a feature defined in JEDEC DDR5 SDRAM Specification (JESD79-5) and allows the DRAM to internally read, correct single-bit errors, and write back corrected data bits to the DRAM array while providing transparency to error counts. The ECS control feature allows the request to configure ECS input configurations during system boot or at run-time.
The ECS control allows the requester to change the log entry type, the ECS threshold count provided that the request is within the definition specified in DDR5 mode registers, change mode between codeword mode and row count mode, and reset the ECS counter.
--- include/hw/cxl/cxl_device.h | 24 +++++++++++++ hw/cxl/cxl-mailbox-utils.c | 71 +++++++++++++++++++++++++++++++++++++ hw/mem/cxl_type3.c | 14 ++++++++ 3 files changed, 109 insertions(+)
include/hw/cxl/cxl_device.h +24 -0
@@ -447,6 +447,27 @@ typedef struct CXLMemPatrolScrubWriteAttrs {#define CXL_MEMDEV_PS_MIN_SCRUB_CYCLE_DEFAULT 1#define CXL_MEMDEV_PS_ENABLE_DEFAULT 0 +/* CXL memory device DDR5 ECS control attributes */ +typedef struct CXLMemECSReadAttrs { +uint8_t ecs_log_cap; +uint8_t ecs_cap; +uint16_t ecs_config; +uint8_t ecs_flags; +} QEMU_PACKED CXLMemECSReadAttrs; + +typedef struct CXLMemECSWriteAttrs { +uint8_t ecs_log_cap; +uint16_t ecs_config; +} QEMU_PACKED CXLMemECSWriteAttrs; + +#define CXL_ECS_GET_FEATURE_VERSION 0x01 +#define CXL_ECS_SET_FEATURE_VERSION 0x01 +#define CXL_ECS_LOG_ENTRY_TYPE_DEFAULT 0x01 +#define CXL_ECS_REALTIME_REPORT_CAP_DEFAULT 1 +#define CXL_ECS_THRESHOLD_COUNT_DEFAULT 3/* 3: 256, 4: 1024, 5: 4096 */ +#define CXL_ECS_MODE_DEFAULT 0 +#define CXL_ECS_NUM_MEDIA_FRUS 3/* Default */ +#define DCD_MAX_NUM_REGION 8 typedef struct CXLDCExtentRaw {
@@ -534,6 +555,9 @@ struct CXLType3Dev {/* Patrol scrub control attributes */ CXLMemPatrolScrubReadAttrs patrol_scrub_attrs;CXLMemPatrolScrubWriteAttrs patrol_scrub_wr_attrs; +/* ECS control attributes */ +CXLMemECSReadAttrs ecs_attrs[CXL_ECS_NUM_MEDIA_FRUS ]; +CXLMemECSWriteAttrs ecs_wr_attrs[CXL_ECS_NUM_MEDIA_FRUS ];struct dynamic_capacity {HostMemoryBackend *host_dc;
hw/cxl/cxl-mailbox-utils.c +71 -0
117 lines not on this page · raw message
hw/mem/cxl_type3.c +14 -0
@@ -829,6 +829,7 @@ static void ct3_realize(PCIDevice *pci_dev, Error **errp)uint8_t *pci_conf = pci_dev->config;unsigned short msix_num =6 ;int i, rc; +uint16_t count;QTAILQ_INIT (&ct3d->error_list);
@@ -901,6 +902,19 @@ static void ct3_realize(PCIDevice *pci_dev, Error **errp)CXL_MEMDEV_PS_CUR_SCRUB_CYCLE_DEFAULT | (CXL_MEMDEV_PS_MIN_SCRUB_CYCLE_DEFAULT <<8 ); ct3d->patrol_scrub_attrs.scrub_flags =CXL_MEMDEV_PS_ENABLE_DEFAULT ; + +/* Set default value for DDR5 ECS read attributes */ +for (count =0 ; count <CXL_ECS_NUM_MEDIA_FRUS ; count++) { + ct3d->ecs_attrs[count].ecs_log_cap = +CXL_ECS_LOG_ENTRY_TYPE_DEFAULT ; + ct3d->ecs_attrs[count].ecs_cap = +CXL_ECS_REALTIME_REPORT_CAP_DEFAULT ; + ct3d->ecs_attrs[count].ecs_config = +CXL_ECS_THRESHOLD_COUNT_DEFAULT | + (CXL_ECS_MODE_DEFAULT <<3 ); +/* Reserved */ + ct3d->ecs_attrs[count].ecs_flags =0 ; + }return ;
Signature · 1 line
2.43.0
Re: [PATCH v6 4/4] hw/cxl/cxl-mailbox-utils: Add device DDR5 ECS control feature
Quoted 4 lines · On Fri, 5 Jul 2024 13:30:38 +0100 Jonathan Cameron…
From: Shiju Jose <[email protected]>
CXL spec 3.1 section 8.2.9.9.11.2 describes the DDR5 Error Check Scrub (ECS) control feature.
Hi Michael / all,
Silly stray white space issue inline that checkpatch will catch.
Quoted 13 lines
hw/mem/cxl_type3.c +1
-0@@ -829,6 +829,7 @@ static void ct3_realize(PCIDevice *pci_dev, Error **errp)uint8_t *pci_conf = pci_dev->config;unsigned short msix_num =6 ;int i, rc; +uint16_t count;QTAILQ_INIT (&ct3d->error_list);
hw/mem/cxl_type3.c static void ct3_realize(PCIDevice *pci_dev, Error **errp) · line 905
Quoted 4 lines
hw/mem/cxl_type3.c +1
-0@@ -901,6 +902,19 @@ static void ct3_realize(PCIDevice *pci_dev, Error **errp)CXL_MEMDEV_PS_CUR_SCRUB_CYCLE_DEFAULT | (CXL_MEMDEV_PS_MIN_SCRUB_CYCLE_DEFAULT <<8 ); ct3d->patrol_scrub_attrs.scrub_flags =CXL_MEMDEV_PS_ENABLE_DEFAULT ; +
Sorry - stray whitespace here. I'll not send a new version for just this though.
Quoted 15 lines
hw/mem/cxl_type3.c +12
-0+/* Set default value for DDR5 ECS read attributes */ +for (count =0 ; count <CXL_ECS_NUM_MEDIA_FRUS ; count++) { + ct3d->ecs_attrs[count].ecs_log_cap = +CXL_ECS_LOG_ENTRY_TYPE_DEFAULT ; + ct3d->ecs_attrs[count].ecs_cap = +CXL_ECS_REALTIME_REPORT_CAP_DEFAULT ; + ct3d->ecs_attrs[count].ecs_config = +CXL_ECS_THRESHOLD_COUNT_DEFAULT | + (CXL_ECS_MODE_DEFAULT <<3 ); +/* Reserved */ + ct3d->ecs_attrs[count].ecs_flags =0 ; + }return ;