* [PATCH qemu 0/4] hw/cxl: Add support for scan media.
@ 2024-07-05 12:06 Jonathan Cameron
2024-07-05 12:06 ` [PATCH 1/4] hw/cxl: Add get scan media capabilities cmd support Jonathan Cameron
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Jonathan Cameron @ 2024-07-05 12:06 UTC (permalink / raw)
To: linux-cxl, mst, qemu-devel; +Cc: Davidlohr Bueso, Hyeonggon Yoo, Fan Ni
Now DCD is upstream, a number of sets that were dependent on it, that have
otherwise been in a good state for a long time, are (hopefully) ready to
upstream. I was also holding back series that were less critical for
kernel testing to make sure they didn't distract from the progress of
Dynamic Capacity.
This 1st series includes a couple of more general improvements that interact
closely with the scan media changes. This series applies directly on master
and can go in parallel to
[PATCH qemu v2 0/3] hw/cxl: Misc minor improvements
The Scan Media commands enable recovery from the situation where a poison
list has overflowed and the OS has no other way to find out which
memory is bad, or because the user wants force a recheck for uncorrectable
ECC errors. This functionality is emulated by keeping an additional list
of injected poison that is not exposed via the existing get poison list
command. This list is 'discovered' during processing of Scan Media as
if the hardware had detected these errors in real memory.
Davidlohr Bueso (2):
hw/cxl: Add get scan media capabilities cmd support
hw/cxl: Add get scan media results cmd support
Hyeonggon Yoo (2):
hw/cxl/mbox: replace sanitize_running() with cxl_dev_media_disabled()
hw/cxl/events: discard all event records during sanitation
include/hw/cxl/cxl_device.h | 15 +-
hw/cxl/cxl-events.c | 13 ++
hw/cxl/cxl-mailbox-utils.c | 326 ++++++++++++++++++++++++++++++++++--
hw/mem/cxl_type3.c | 26 ++-
4 files changed, 355 insertions(+), 25 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 12+ messages in thread* [PATCH 1/4] hw/cxl: Add get scan media capabilities cmd support 2024-07-05 12:06 [PATCH qemu 0/4] hw/cxl: Add support for scan media Jonathan Cameron @ 2024-07-05 12:06 ` Jonathan Cameron 2024-07-05 12:06 ` [PATCH 2/4] hw/cxl/mbox: replace sanitize_running() with cxl_dev_media_disabled() Jonathan Cameron ` (2 subsequent siblings) 3 siblings, 0 replies; 12+ messages in thread From: Jonathan Cameron @ 2024-07-05 12:06 UTC (permalink / raw) To: linux-cxl, mst, qemu-devel; +Cc: Davidlohr Bueso, Hyeonggon Yoo, Fan Ni From: Davidlohr Bueso <dave@stgolabs.net> Use simple heuristics to determine the cost of scanning any given chunk, assuming cost is equal across the whole device, without differentiating between volatile or persistent partitions. This is aligned to the fact that these constraints are not enforced in respective poison query commands. Signed-off-by: Davidlohr Bueso <dave@stgolabs.net> Link: https://lore.kernel.org/r/20230908073152.4386-3-dave@stgolabs.net Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> --- Tweaks: Update reference to 3.1 specification given 3.0 not easily available any more. --- include/hw/cxl/cxl_device.h | 9 ++ hw/cxl/cxl-mailbox-utils.c | 211 +++++++++++++++++++++++++++++++++++- hw/mem/cxl_type3.c | 22 ++-- 3 files changed, 233 insertions(+), 9 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 0a4fcb2800..b5beb7f90e 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -397,6 +397,11 @@ static inline void __toggle_media(CXLDeviceState *cxl_dstate, int val) #define cxl_dev_enable_media(cxlds) \ do { __toggle_media((cxlds), 0x1); } while (0) +static inline bool scan_media_running(CXLCCI *cci) +{ + return !!cci->bg.runtime && cci->bg.opcode == 0x4304; +} + static inline bool sanitize_running(CXLCCI *cci) { return !!cci->bg.runtime && cci->bg.opcode == 0x4400; @@ -491,6 +496,9 @@ struct CXLType3Dev { unsigned int poison_list_cnt; bool poison_list_overflowed; uint64_t poison_list_overflow_ts; + /* Poison Injection - backup */ + CXLPoisonList poison_list_bkp; + CXLPoisonList scan_media_results; struct dynamic_capacity { HostMemoryBackend *host_dc; @@ -558,6 +566,7 @@ CXLRetCode cxl_event_clear_records(CXLDeviceState *cxlds, void cxl_event_irq_assert(CXLType3Dev *ct3d); void cxl_set_poison_list_overflowed(CXLType3Dev *ct3d); +void cxl_clear_poison_list_overflowed(CXLType3Dev *ct3d); CXLDCRegion *cxl_find_dc_region(CXLType3Dev *ct3d, uint64_t dpa, uint64_t len); diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 74eeb6fde7..6a60f81794 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -83,6 +83,8 @@ enum { #define GET_POISON_LIST 0x0 #define INJECT_POISON 0x1 #define CLEAR_POISON 0x2 + #define GET_SCAN_MEDIA_CAPABILITIES 0x3 + #define SCAN_MEDIA 0x4 DCD_CONFIG = 0x48, #define GET_DC_CONFIG 0x0 #define GET_DYN_CAP_EXT_LIST 0x1 @@ -1117,6 +1119,10 @@ static CXLRetCode cmd_media_get_poison_list(const struct cxl_cmd *cmd, out->flags = (1 << 1); stq_le_p(&out->overflow_timestamp, ct3d->poison_list_overflow_ts); } + if (scan_media_running(cci)) { + out->flags |= (1 << 2); + } + stw_le_p(&out->count, record_count); *len_out = out_pl_len; return CXL_MBOX_SUCCESS; @@ -1146,6 +1152,16 @@ static CXLRetCode cmd_media_inject_poison(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } } + /* + * Freeze the list if there is an on-going scan media operation. + */ + if (scan_media_running(cci)) { + /* + * XXX: Spec is ambiguous - is this case considered + * a successful return despite not adding to the list? + */ + goto success; + } if (ct3d->poison_list_cnt == CXL_POISON_LIST_LIMIT) { return CXL_MBOX_INJECT_POISON_LIMIT; @@ -1161,6 +1177,7 @@ static CXLRetCode cmd_media_inject_poison(const struct cxl_cmd *cmd, */ QLIST_INSERT_HEAD(poison_list, p, node); ct3d->poison_list_cnt++; +success: *len_out = 0; return CXL_MBOX_SUCCESS; @@ -1200,6 +1217,17 @@ static CXLRetCode cmd_media_clear_poison(const struct cxl_cmd *cmd, } } + /* + * Freeze the list if there is an on-going scan media operation. + */ + if (scan_media_running(cci)) { + /* + * XXX: Spec is ambiguous - is this case considered + * a successful return despite not removing from the list? + */ + goto success; + } + QLIST_FOREACH(ent, poison_list, node) { /* * Test for contained in entry. Simpler than general case @@ -1210,7 +1238,7 @@ static CXLRetCode cmd_media_clear_poison(const struct cxl_cmd *cmd, } } if (!ent) { - return CXL_MBOX_SUCCESS; + goto success; } QLIST_REMOVE(ent, node); @@ -1247,11 +1275,180 @@ static CXLRetCode cmd_media_clear_poison(const struct cxl_cmd *cmd, } /* Any fragments have been added, free original entry */ g_free(ent); +success: *len_out = 0; return CXL_MBOX_SUCCESS; } +/* + * CXL r3.1 section 8.2.9.9.4.4: Get Scan Media Capabilities + */ +static CXLRetCode +cmd_media_get_scan_media_capabilities(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + struct get_scan_media_capabilities_pl { + uint64_t pa; + uint64_t length; + } QEMU_PACKED; + + struct get_scan_media_capabilities_out_pl { + uint32_t estimated_runtime_ms; + }; + + CXLType3Dev *ct3d = CXL_TYPE3(cci->d); + CXLDeviceState *cxl_dstate = &ct3d->cxl_dstate; + struct get_scan_media_capabilities_pl *in = (void *)payload_in; + struct get_scan_media_capabilities_out_pl *out = (void *)payload_out; + uint64_t query_start; + uint64_t query_length; + + query_start = ldq_le_p(&in->pa); + /* 64 byte alignment required */ + if (query_start & 0x3f) { + return CXL_MBOX_INVALID_INPUT; + } + query_length = ldq_le_p(&in->length) * CXL_CACHE_LINE_SIZE; + + if (query_start + query_length > cxl_dstate->static_mem_size) { + return CXL_MBOX_INVALID_PA; + } + + /* + * Just use 400 nanosecond access/read latency + 100 ns for + * the cost of updating the poison list. For small enough + * chunks return at least 1 ms. + */ + stl_le_p(&out->estimated_runtime_ms, + MAX(1, query_length * (0.0005L / 64))); + + *len_out = sizeof(*out); + return CXL_MBOX_SUCCESS; +} + +static void __do_scan_media(CXLType3Dev *ct3d) +{ + CXLPoison *ent; + unsigned int results_cnt = 0; + + QLIST_FOREACH(ent, &ct3d->scan_media_results, node) { + results_cnt++; + } + + /* only scan media may clear the overflow */ + if (ct3d->poison_list_overflowed && + ct3d->poison_list_cnt == results_cnt) { + cxl_clear_poison_list_overflowed(ct3d); + } +} + +/* + * CXL r3.1 section 8.2.9.9.4.5: Scan Media + */ +static CXLRetCode cmd_media_scan_media(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + struct scan_media_pl { + uint64_t pa; + uint64_t length; + uint8_t flags; + } QEMU_PACKED; + + struct scan_media_pl *in = (void *)payload_in; + CXLType3Dev *ct3d = CXL_TYPE3(cci->d); + CXLDeviceState *cxl_dstate = &ct3d->cxl_dstate; + uint64_t query_start; + uint64_t query_length; + CXLPoison *ent, *next; + + query_start = ldq_le_p(&in->pa); + /* 64 byte alignment required */ + if (query_start & 0x3f) { + return CXL_MBOX_INVALID_INPUT; + } + query_length = ldq_le_p(&in->length) * CXL_CACHE_LINE_SIZE; + + if (query_start + query_length > cxl_dstate->static_mem_size) { + return CXL_MBOX_INVALID_PA; + } + if (ct3d->dc.num_regions && query_start + query_length >= + cxl_dstate->static_mem_size + ct3d->dc.total_capacity) { + return CXL_MBOX_INVALID_PA; + } + + if (in->flags == 0) { /* TODO */ + qemu_log_mask(LOG_UNIMP, + "Scan Media Event Log is unsupported\n"); + } + + /* any previous results are discarded upon a new Scan Media */ + QLIST_FOREACH_SAFE(ent, &ct3d->scan_media_results, node, next) { + QLIST_REMOVE(ent, node); + g_free(ent); + } + + /* kill the poison list - it will be recreated */ + if (ct3d->poison_list_overflowed) { + QLIST_FOREACH_SAFE(ent, &ct3d->poison_list, node, next) { + QLIST_REMOVE(ent, node); + g_free(ent); + ct3d->poison_list_cnt--; + } + } + + /* + * Scan the backup list and move corresponding entries + * into the results list, updating the poison list + * when possible. + */ + QLIST_FOREACH_SAFE(ent, &ct3d->poison_list_bkp, node, next) { + CXLPoison *res; + + if (ent->start >= query_start + query_length || + ent->start + ent->length <= query_start) { + continue; + } + + /* + * If a Get Poison List cmd comes in while this + * scan is being done, it will see the new complete + * list, while setting the respective flag. + */ + if (ct3d->poison_list_cnt < CXL_POISON_LIST_LIMIT) { + CXLPoison *p = g_new0(CXLPoison, 1); + + p->start = ent->start; + p->length = ent->length; + p->type = ent->type; + QLIST_INSERT_HEAD(&ct3d->poison_list, p, node); + ct3d->poison_list_cnt++; + } + + res = g_new0(CXLPoison, 1); + res->start = ent->start; + res->length = ent->length; + res->type = ent->type; + QLIST_INSERT_HEAD(&ct3d->scan_media_results, res, node); + + QLIST_REMOVE(ent, node); + g_free(ent); + } + + cci->bg.runtime = MAX(1, query_length * (0.0005L / 64)); + *len_out = 0; + + return CXL_MBOX_BG_STARTED; +} + /* * CXL r3.1 section 8.2.9.9.9.1: Get Dynamic Capacity Configuration * (Opcode: 4800h) @@ -1864,6 +2061,11 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = { cmd_media_inject_poison, 8, 0 }, [MEDIA_AND_POISON][CLEAR_POISON] = { "MEDIA_AND_POISON_CLEAR_POISON", cmd_media_clear_poison, 72, 0 }, + [MEDIA_AND_POISON][GET_SCAN_MEDIA_CAPABILITIES] = { + "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 }, }; static const struct cxl_cmd cxl_cmd_set_dcd[256][256] = { @@ -1995,8 +2197,13 @@ static void bg_timercb(void *opaque) cxl_dev_enable_media(&ct3d->cxl_dstate); } break; - case 0x4304: /* TODO: scan media */ + case 0x4304: /* scan media */ + { + CXLType3Dev *ct3d = CXL_TYPE3(cci->d); + + __do_scan_media(ct3d); break; + } default: __builtin_unreachable(); break; diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 35ac59883a..62956a0403 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1304,6 +1304,12 @@ void cxl_set_poison_list_overflowed(CXLType3Dev *ct3d) cxl_device_get_timestamp(&ct3d->cxl_dstate); } +void cxl_clear_poison_list_overflowed(CXLType3Dev *ct3d) +{ + ct3d->poison_list_overflowed = false; + ct3d->poison_list_overflow_ts = 0; +} + void qmp_cxl_inject_poison(const char *path, uint64_t start, uint64_t length, Error **errp) { @@ -1340,19 +1346,21 @@ void qmp_cxl_inject_poison(const char *path, uint64_t start, uint64_t length, } } - if (ct3d->poison_list_cnt == CXL_POISON_LIST_LIMIT) { - cxl_set_poison_list_overflowed(ct3d); - return; - } - p = g_new0(CXLPoison, 1); p->length = length; p->start = start; /* Different from injected via the mbox */ p->type = CXL_POISON_TYPE_INTERNAL; - QLIST_INSERT_HEAD(&ct3d->poison_list, p, node); - ct3d->poison_list_cnt++; + if (ct3d->poison_list_cnt < CXL_POISON_LIST_LIMIT) { + QLIST_INSERT_HEAD(&ct3d->poison_list, p, node); + ct3d->poison_list_cnt++; + } else { + if (!ct3d->poison_list_overflowed) { + cxl_set_poison_list_overflowed(ct3d); + } + QLIST_INSERT_HEAD(&ct3d->poison_list_bkp, p, node); + } } /* For uncorrectable errors include support for multiple header recording */ -- 2.43.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/4] hw/cxl/mbox: replace sanitize_running() with cxl_dev_media_disabled() 2024-07-05 12:06 [PATCH qemu 0/4] hw/cxl: Add support for scan media Jonathan Cameron 2024-07-05 12:06 ` [PATCH 1/4] hw/cxl: Add get scan media capabilities cmd support Jonathan Cameron @ 2024-07-05 12:06 ` Jonathan Cameron 2024-07-05 12:06 ` [PATCH 3/4] hw/cxl/events: discard all event records during sanitation Jonathan Cameron 2024-07-05 12:06 ` [PATCH 4/4] hw/cxl: Add get scan media results cmd support Jonathan Cameron 3 siblings, 0 replies; 12+ messages in thread From: Jonathan Cameron @ 2024-07-05 12:06 UTC (permalink / raw) To: linux-cxl, mst, qemu-devel; +Cc: Davidlohr Bueso, Hyeonggon Yoo, Fan Ni From: Hyeonggon Yoo <42.hyeyoo@gmail.com> The spec states that reads/writes should have no effect and a part of commands should be ignored when the media is disabled, not when the sanitize command is running. Introduce cxl_dev_media_disabled() to check if the media is disabled and replace sanitize_running() with it. Make sure that the media has been correctly disabled during sanitation by adding an assert to __toggle_media(). Now, enabling when already enabled or vice versa results in an assert() failure. Suggested-by: Davidlohr Bueso <dave@stgolabs.net> Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Link: https://lore.kernel.org/r/20231222090051.3265307-4-42.hyeyoo@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> --- Fix added to ensure the state sanity check only applies on type3 devices --- include/hw/cxl/cxl_device.h | 10 +++++----- hw/cxl/cxl-mailbox-utils.c | 29 +++++++++++++++++------------ hw/mem/cxl_type3.c | 4 ++-- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index b5beb7f90e..42a622197e 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -397,14 +397,14 @@ static inline void __toggle_media(CXLDeviceState *cxl_dstate, int val) #define cxl_dev_enable_media(cxlds) \ do { __toggle_media((cxlds), 0x1); } while (0) -static inline bool scan_media_running(CXLCCI *cci) +static inline bool cxl_dev_media_disabled(CXLDeviceState *cxl_dstate) { - return !!cci->bg.runtime && cci->bg.opcode == 0x4304; + uint64_t dev_status_reg = cxl_dstate->mbox_reg_state64[R_CXL_MEM_DEV_STS]; + return FIELD_EX64(dev_status_reg, CXL_MEM_DEV_STS, MEDIA_STATUS) == 0x3; } - -static inline bool sanitize_running(CXLCCI *cci) +static inline bool scan_media_running(CXLCCI *cci) { - return !!cci->bg.runtime && cci->bg.opcode == 0x4400; + return !!cci->bg.runtime && cci->bg.opcode == 0x4304; } typedef struct CXLError { diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 6a60f81794..adeb71071c 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -2115,6 +2115,7 @@ int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, int ret; const struct cxl_cmd *cxl_cmd; opcode_handler h; + CXLDeviceState *cxl_dstate; *len_out = 0; cxl_cmd = &cci->cxl_cmd_set[set][cmd]; @@ -2135,18 +2136,22 @@ int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, return CXL_MBOX_BUSY; } - /* forbid any selected commands while overwriting */ - if (sanitize_running(cci)) { - if (h == cmd_events_get_records || - h == cmd_ccls_get_partition_info || - h == cmd_ccls_set_lsa || - h == cmd_ccls_get_lsa || - h == cmd_logs_get_log || - h == cmd_media_get_poison_list || - h == cmd_media_inject_poison || - h == cmd_media_clear_poison || - h == cmd_sanitize_overwrite) { - return CXL_MBOX_MEDIA_DISABLED; + /* forbid any selected commands while the media is disabled */ + if (object_dynamic_cast(OBJECT(cci->d), TYPE_CXL_TYPE3)) { + cxl_dstate = &CXL_TYPE3(cci->d)->cxl_dstate; + + if (cxl_dev_media_disabled(cxl_dstate)) { + if (h == cmd_events_get_records || + h == cmd_ccls_get_partition_info || + h == cmd_ccls_set_lsa || + h == cmd_ccls_get_lsa || + h == cmd_logs_get_log || + h == cmd_media_get_poison_list || + h == cmd_media_inject_poison || + h == cmd_media_clear_poison || + h == cmd_sanitize_overwrite) { + return CXL_MBOX_MEDIA_DISABLED; + } } } diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 62956a0403..925c88ac5d 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1127,7 +1127,7 @@ MemTxResult cxl_type3_read(PCIDevice *d, hwaddr host_addr, uint64_t *data, return MEMTX_ERROR; } - if (sanitize_running(&ct3d->cci)) { + if (cxl_dev_media_disabled(&ct3d->cxl_dstate)) { qemu_guest_getrandom_nofail(data, size); return MEMTX_OK; } @@ -1149,7 +1149,7 @@ MemTxResult cxl_type3_write(PCIDevice *d, hwaddr host_addr, uint64_t data, return MEMTX_ERROR; } - if (sanitize_running(&ct3d->cci)) { + if (cxl_dev_media_disabled(&ct3d->cxl_dstate)) { return MEMTX_OK; } -- 2.43.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/4] hw/cxl/events: discard all event records during sanitation 2024-07-05 12:06 [PATCH qemu 0/4] hw/cxl: Add support for scan media Jonathan Cameron 2024-07-05 12:06 ` [PATCH 1/4] hw/cxl: Add get scan media capabilities cmd support Jonathan Cameron 2024-07-05 12:06 ` [PATCH 2/4] hw/cxl/mbox: replace sanitize_running() with cxl_dev_media_disabled() Jonathan Cameron @ 2024-07-05 12:06 ` Jonathan Cameron 2024-07-05 12:06 ` [PATCH 4/4] hw/cxl: Add get scan media results cmd support Jonathan Cameron 3 siblings, 0 replies; 12+ messages in thread From: Jonathan Cameron @ 2024-07-05 12:06 UTC (permalink / raw) To: linux-cxl, mst, qemu-devel; +Cc: Davidlohr Bueso, Hyeonggon Yoo, Fan Ni From: Hyeonggon Yoo <42.hyeyoo@gmail.com> Per CXL r3.1 Section 8.2.9.9.5.1: Sanitize (Opcode 4400h), the sanitize command should delete all event logs. Introduce cxl_discard_all_event_logs() and call this in __do_sanitization(). Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Davidlohr Bueso <dave@stgolabs.net> Link: https://lore.kernel.org/r/20231222090051.3265307-5-42.hyeyoo@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> --- Tweaks: Made the reference in this description clearly refer to the 3.1 specification version. --- include/hw/cxl/cxl_device.h | 1 + hw/cxl/cxl-events.c | 13 +++++++++++++ hw/cxl/cxl-mailbox-utils.c | 1 + 3 files changed, 15 insertions(+) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 42a622197e..0509d961c3 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -562,6 +562,7 @@ CXLRetCode cxl_event_get_records(CXLDeviceState *cxlds, CXLGetEventPayload *pl, size_t *len); CXLRetCode cxl_event_clear_records(CXLDeviceState *cxlds, CXLClearEventPayload *pl); +void cxl_discard_all_event_records(CXLDeviceState *cxlds); void cxl_event_irq_assert(CXLType3Dev *ct3d); diff --git a/hw/cxl/cxl-events.c b/hw/cxl/cxl-events.c index d397718b1b..12dee2e467 100644 --- a/hw/cxl/cxl-events.c +++ b/hw/cxl/cxl-events.c @@ -139,6 +139,19 @@ bool cxl_event_insert(CXLDeviceState *cxlds, CXLEventLogType log_type, return cxl_event_count(log) == 1; } +void cxl_discard_all_event_records(CXLDeviceState *cxlds) +{ + CXLEventLogType log_type; + CXLEventLog *log; + + for (log_type = 0; log_type < CXL_EVENT_TYPE_MAX; log_type++) { + log = &cxlds->event_logs[log_type]; + while (!cxl_event_empty(log)) { + cxl_event_delete_head(cxlds, log_type, log); + } + } +} + CXLRetCode cxl_event_get_records(CXLDeviceState *cxlds, CXLGetEventPayload *pl, uint8_t log_type, int max_recs, size_t *len) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index adeb71071c..e3d3575b02 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -955,6 +955,7 @@ static void __do_sanitization(CXLType3Dev *ct3d) memset(lsa, 0, memory_region_size(mr)); } } + cxl_discard_all_event_records(&ct3d->cxl_dstate); } /* -- 2.43.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/4] hw/cxl: Add get scan media results cmd support 2024-07-05 12:06 [PATCH qemu 0/4] hw/cxl: Add support for scan media Jonathan Cameron ` (2 preceding siblings ...) 2024-07-05 12:06 ` [PATCH 3/4] hw/cxl/events: discard all event records during sanitation Jonathan Cameron @ 2024-07-05 12:06 ` Jonathan Cameron 3 siblings, 0 replies; 12+ messages in thread From: Jonathan Cameron @ 2024-07-05 12:06 UTC (permalink / raw) To: linux-cxl, mst, qemu-devel; +Cc: Davidlohr Bueso, Hyeonggon Yoo, Fan Ni From: Davidlohr Bueso <dave@stgolabs.net> Iterate over the list keeping the output payload size into account, returning the results from a previous scan media operation. The scan media operation does not fail prematurely due to device being out of storage, so this implementation does not deal with the retry/restart functionality. Signed-off-by: Davidlohr Bueso <dave@stgolabs.net> Link: https://lore.kernel.org/r/20230908073152.4386-5-dave@stgolabs.net Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> --- Tweak - update references to point to CXL r3.1 given lack of easy availability of r3.0. --- include/hw/cxl/cxl_device.h | 1 + hw/cxl/cxl-mailbox-utils.c | 85 +++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 0509d961c3..cc98553583 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -499,6 +499,7 @@ struct CXLType3Dev { /* Poison Injection - backup */ CXLPoisonList poison_list_bkp; CXLPoisonList scan_media_results; + bool scan_media_hasrun; struct dynamic_capacity { HostMemoryBackend *host_dc; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index e3d3575b02..e87089474a 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -85,6 +85,7 @@ enum { #define CLEAR_POISON 0x2 #define GET_SCAN_MEDIA_CAPABILITIES 0x3 #define SCAN_MEDIA 0x4 + #define GET_SCAN_MEDIA_RESULTS 0x5 DCD_CONFIG = 0x48, #define GET_DC_CONFIG 0x0 #define GET_DYN_CAP_EXT_LIST 0x1 @@ -1346,6 +1347,8 @@ static void __do_scan_media(CXLType3Dev *ct3d) ct3d->poison_list_cnt == results_cnt) { cxl_clear_poison_list_overflowed(ct3d); } + /* scan media has run since last conventional reset */ + ct3d->scan_media_hasrun = true; } /* @@ -1450,6 +1453,85 @@ static CXLRetCode cmd_media_scan_media(const struct cxl_cmd *cmd, return CXL_MBOX_BG_STARTED; } +/* + * CXL r3.1 section 8.2.9.9.4.6: Get Scan Media Results + */ +static CXLRetCode cmd_media_get_scan_media_results(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + struct get_scan_media_results_out_pl { + uint64_t dpa_restart; + uint64_t length; + uint8_t flags; + uint8_t rsvd1; + uint16_t count; + uint8_t rsvd2[0xc]; + struct { + uint64_t addr; + uint32_t length; + uint32_t resv; + } QEMU_PACKED records[]; + } QEMU_PACKED; + + struct get_scan_media_results_out_pl *out = (void *)payload_out; + CXLType3Dev *ct3d = CXL_TYPE3(cci->d); + CXLPoisonList *scan_media_results = &ct3d->scan_media_results; + CXLPoison *ent, *next; + uint16_t total_count = 0, record_count = 0, i = 0; + uint16_t out_pl_len; + + if (!ct3d->scan_media_hasrun) { + return CXL_MBOX_UNSUPPORTED; + } + + /* + * Calculate limits, all entries are within the same address range of the + * last scan media call. + */ + QLIST_FOREACH(ent, scan_media_results, node) { + size_t rec_size = record_count * sizeof(out->records[0]); + + if (sizeof(*out) + rec_size < CXL_MAILBOX_MAX_PAYLOAD_SIZE) { + record_count++; + } + total_count++; + } + + out_pl_len = sizeof(*out) + record_count * sizeof(out->records[0]); + assert(out_pl_len <= CXL_MAILBOX_MAX_PAYLOAD_SIZE); + + memset(out, 0, out_pl_len); + QLIST_FOREACH_SAFE(ent, scan_media_results, node, next) { + uint64_t start, stop; + + if (i == record_count) { + break; + } + + start = ROUND_DOWN(ent->start, 64ull); + stop = ROUND_DOWN(ent->start, 64ull) + ent->length; + stq_le_p(&out->records[i].addr, start | (ent->type & 0x7)); + stl_le_p(&out->records[i].length, (stop - start) / CXL_CACHE_LINE_SIZE); + i++; + + /* consume the returning entry */ + QLIST_REMOVE(ent, node); + g_free(ent); + } + + stw_le_p(&out->count, record_count); + if (total_count > record_count) { + out->flags = (1 << 0); /* More Media Error Records */ + } + + *len_out = out_pl_len; + return CXL_MBOX_SUCCESS; +} + /* * CXL r3.1 section 8.2.9.9.9.1: Get Dynamic Capacity Configuration * (Opcode: 4800h) @@ -2067,6 +2149,9 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = { 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 }, + [MEDIA_AND_POISON][GET_SCAN_MEDIA_RESULTS] = { + "MEDIA_AND_POISON_GET_SCAN_MEDIA_RESULTS", + cmd_media_get_scan_media_results, 0, 0 }, }; static const struct cxl_cmd cxl_cmd_set_dcd[256][256] = { -- 2.43.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH -qemu 0/4] hw/cxl: Support for scan media @ 2023-09-08 7:31 Davidlohr Bueso 2023-09-08 7:31 ` [PATCH 4/4] hw/cxl: Add get scan media results cmd support Davidlohr Bueso 0 siblings, 1 reply; 12+ messages in thread From: Davidlohr Bueso @ 2023-09-08 7:31 UTC (permalink / raw) To: Jonathan.Cameron Cc: fan.ni, dan.j.williams, alison.schofield, ayush.m55, a.manzanares, dave, linux-cxl Hello, Patch 1 is a fix I found which should be picked up regardless of the rest. As a side note, does it make sense to have a clear poison equivalent for the qmp interface? This is a (tardy) followup series to the rfc version[0]. With the exception of the get scan media caps, the whole thing has been mostly redone to 1) just use the qmp interface we have for poison injection and extend it to add to a backup list when the poison limit is reached; and 2) The valid address range chunks obtained by scan media are moved from the backup to a results list, which in turn is consumed by the get scan media results operation. As with the current state of things, DRAM Event Logs are not generated for every new poisoned dpa. Applies against https://gitlab.com/jic23/qemu/-/tree/cxl-2023-08-30 Testing - I hacked up kernel side equivalent to trigger the scan: 1. With an imaginary poison limit of 2 and 5 poisoned dpas. <get-poison-list> cxl_poison: memdev=mem1 host=0000:0d:00.0 serial=0 trace_type=List region= region_uuid=... hpa=0xffffffffffffffff dpa=0x800 dpa_length=0x40 source=Internal flags=Overflow overflow_time=1694153028389446574 cxl_poison: memdev=mem1 host=0000:0d:00.0 serial=0 trace_type=List region= region_uuid=... hpa=0xffffffffffffffff dpa=0x200 dpa_length=0x40 source=Internal flags=Overflow overflow_time=1694153028389446574 <scan-media> + <get-poison-list> cxl_poison: memdev=mem1 host=0000:0d:00.0 serial=0 trace_type=List region= region_uuid=... hpa=0xffffffffffffffff dpa=0x100 dpa_length=0x40 source=Internal flags=Overflow overflow_time=1694153028389446574 cxl_poison: memdev=mem1 host=0000:0d:00.0 serial=0 trace_type=List region= region_uuid=... hpa=0xffffffffffffffff dpa=0x80 dpa_length=0x40 source=Internal flags=Overflow overflow_time=1694153028389446574 2. With an imaginary poison limit of 2 and 3 poisoned dpas. <get-poison-list> cxl_poison: memdev=mem1 host=0000:0d:00.0 serial=0 trace_type=List region= region_uuid=... hpa=0xffffffffffffffff dpa=0x400 dpa_length=0x40 source=Internal flags=Overflow overflow_time=1694153398720616022 cxl_poison: memdev=mem1 host=0000:0d:00.0 serial=0 trace_type=List region= region_uuid=... hpa=0xffffffffffffffff dpa=0x80 dpa_length=0x40 source=Internal flags=Overflow overflow_time=1694153398720616022 <scan-media> + <get-poison-list> cxl_poison: memdev=mem1 host=0000:0d:00.0 serial=0 trace_type=List region= region_uuid=... hpa=0xffffffffffffffff dpa=0x100 dpa_length=0x40 source=Internal flags= overflow_time=0 Thanks! [0] https://lore.kernel.org/linux-cxl/20230426021418.10186-1-dave@stgolabs.net Davidlohr Bueso (4): cxl/type3: Fix crash in set_cacheline() hw/cxl: Add get scan media capabilities cmd support hw/cxl: Add scan media cmd support hw/cxl: Add get scan media results cmd support hw/cxl/cxl-mailbox-utils.c | 298 +++++++++++++++++++++++++++++++++++- hw/mem/cxl_type3.c | 24 ++- include/hw/cxl/cxl_device.h | 10 ++ 3 files changed, 317 insertions(+), 15 deletions(-) -- 2.42.0 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 4/4] hw/cxl: Add get scan media results cmd support 2023-09-08 7:31 [PATCH -qemu 0/4] hw/cxl: Support for scan media Davidlohr Bueso @ 2023-09-08 7:31 ` Davidlohr Bueso 2023-09-12 12:04 ` Jonathan Cameron 0 siblings, 1 reply; 12+ messages in thread From: Davidlohr Bueso @ 2023-09-08 7:31 UTC (permalink / raw) To: Jonathan.Cameron Cc: fan.ni, dan.j.williams, alison.schofield, ayush.m55, a.manzanares, dave, linux-cxl Iterate over the list keeping the output payload size into account, returning the results from a previous scan media operation. The scan media operation does not fail prematurely due to device being out of storage, so this implementation does not deal with the retry/restart functionality. Signed-off-by: Davidlohr Bueso <dave@stgolabs.net> --- hw/cxl/cxl-mailbox-utils.c | 84 +++++++++++++++++++++++++++++++++++++ include/hw/cxl/cxl_device.h | 1 + 2 files changed, 85 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 399ac03962db..109b9ecfabf1 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -82,6 +82,7 @@ enum { #define CLEAR_POISON 0x2 #define GET_SCAN_MEDIA_CAPABILITIES 0x3 #define SCAN_MEDIA 0x4 + #define GET_SCAN_MEDIA_RESULTS 0x5 DCD_CONFIG = 0x48, #define GET_DC_CONFIG 0x0 #define GET_DYN_CAP_EXT_LIST 0x1 @@ -1267,6 +1268,8 @@ static void __do_scan_media(CXLType3Dev *ct3d) ct3d->poison_list_cnt == results_cnt) { cxl_clear_poison_list_overflowed(ct3d); } + /* scan media has run since last conventional reset */ + ct3d->scan_media_hasrun = true; } /* @@ -1371,6 +1374,85 @@ static CXLRetCode cmd_media_scan_media(const struct cxl_cmd *cmd, return CXL_MBOX_BG_STARTED; } +/* + * CXL r3.0 section 8.2.9.8.4.6: Get Scan Media Results + */ +static CXLRetCode cmd_media_get_scan_media_results(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + struct get_scan_media_results_out_pl { + uint64_t dpa_restart; + uint64_t length; + uint8_t flags; + uint8_t rsvd1; + uint16_t count; + uint8_t rsvd2[0xc]; + struct { + uint64_t addr; + uint32_t length; + uint32_t resv; + } QEMU_PACKED records[]; + } QEMU_PACKED; + + struct get_scan_media_results_out_pl *out = (void *)payload_out; + CXLType3Dev *ct3d = CXL_TYPE3(cci->d); + CXLPoisonList *scan_media_results = &ct3d->scan_media_results; + CXLPoison *ent, *next; + uint16_t total_count = 0, record_count = 0, i = 0; + uint16_t out_pl_len; + + if (!ct3d->scan_media_hasrun) { + return CXL_MBOX_UNSUPPORTED; + } + + /* + * Calculate limits, all entries are within the same + * address range of the last scan media call. + */ + QLIST_FOREACH(ent, scan_media_results, node) { + size_t rec_size = record_count * sizeof(out->records[0]); + + if (sizeof(*out) + rec_size < CXL_MAILBOX_MAX_PAYLOAD_SIZE) { + record_count++; + } + total_count++; + } + + out_pl_len = sizeof(*out) + record_count * sizeof(out->records[0]); + assert(out_pl_len <= CXL_MAILBOX_MAX_PAYLOAD_SIZE); + + memset(out, 0, out_pl_len); + QLIST_FOREACH_SAFE(ent, scan_media_results, node, next) { + uint64_t start, stop; + + if (i == record_count) { + break; + } + + start = ROUND_DOWN(ent->start, 64ull); + stop = ROUND_DOWN(ent->start, 64ull) + ent->length; + stq_le_p(&out->records[i].addr, start | (ent->type & 0x7)); + stl_le_p(&out->records[i].length, (stop - start) / CXL_CACHE_LINE_SIZE); + i++; + + /* consume the returning entry */ + QLIST_REMOVE(ent, node); + g_free(ent); + } + + stw_le_p(&out->count, record_count); + if (total_count > record_count) { + out->flags = (1 << 0); /* More Media Error Records */ + } + + *len_out = out_pl_len; + return CXL_MBOX_SUCCESS; +} + /* * CXL r3.0 section 8.2.9.8.9.1: Dynamic Capacity Configuration */ @@ -1803,6 +1885,8 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = { 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 }, + [MEDIA_AND_POISON][GET_SCAN_MEDIA_RESULTS] = { "MEDIA_AND_POISON_GET_SCAN_MEDIA_RESULTS", + cmd_media_get_scan_media_results, 0, 0 }, }; static const struct cxl_cmd cxl_cmd_set_dcd[256][256] = { diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index eb5c5284fa9f..e9d130e5c988 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -484,6 +484,7 @@ struct CXLType3Dev { /* Poison Injection - backup */ CXLPoisonList poison_list_bkp; CXLPoisonList scan_media_results; + bool scan_media_hasrun; struct dynamic_capacity { HostMemoryBackend *host_dc; -- 2.42.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 4/4] hw/cxl: Add get scan media results cmd support 2023-09-08 7:31 ` [PATCH 4/4] hw/cxl: Add get scan media results cmd support Davidlohr Bueso @ 2023-09-12 12:04 ` Jonathan Cameron 2023-09-13 3:33 ` Davidlohr Bueso 0 siblings, 1 reply; 12+ messages in thread From: Jonathan Cameron @ 2023-09-12 12:04 UTC (permalink / raw) To: Davidlohr Bueso Cc: fan.ni, dan.j.williams, alison.schofield, ayush.m55, a.manzanares, linux-cxl On Fri, 8 Sep 2023 00:31:52 -0700 Davidlohr Bueso <dave@stgolabs.net> wrote: > Iterate over the list keeping the output payload size into account, > returning the results from a previous scan media operation. The > scan media operation does not fail prematurely due to device being > out of storage, so this implementation does not deal with the > retry/restart functionality. > > Signed-off-by: Davidlohr Bueso <dave@stgolabs.net> A few comments inline but nothing to stop me carrying this on my staging tree. (gitlab.com/jic23/qemu cxl-*latestdate* So I'll apply it there. Updates welcome or I'll act on comments when this gets to the top of our queue for upstreaming. Jonathan > --- > hw/cxl/cxl-mailbox-utils.c | 84 +++++++++++++++++++++++++++++++++++++ > include/hw/cxl/cxl_device.h | 1 + > 2 files changed, 85 insertions(+) > > diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c > index 399ac03962db..109b9ecfabf1 100644 > --- a/hw/cxl/cxl-mailbox-utils.c > +++ b/hw/cxl/cxl-mailbox-utils.c > @@ -82,6 +82,7 @@ enum { > #define CLEAR_POISON 0x2 > #define GET_SCAN_MEDIA_CAPABILITIES 0x3 > #define SCAN_MEDIA 0x4 > + #define GET_SCAN_MEDIA_RESULTS 0x5 > DCD_CONFIG = 0x48, > #define GET_DC_CONFIG 0x0 > #define GET_DYN_CAP_EXT_LIST 0x1 > @@ -1267,6 +1268,8 @@ static void __do_scan_media(CXLType3Dev *ct3d) > ct3d->poison_list_cnt == results_cnt) { > cxl_clear_poison_list_overflowed(ct3d); > } > + /* scan media has run since last conventional reset */ > + ct3d->scan_media_hasrun = true; > } > > /* > @@ -1371,6 +1374,85 @@ static CXLRetCode cmd_media_scan_media(const struct cxl_cmd *cmd, > return CXL_MBOX_BG_STARTED; > } > > +/* > + * CXL r3.0 section 8.2.9.8.4.6: Get Scan Media Results > + */ > +static CXLRetCode cmd_media_get_scan_media_results(const struct cxl_cmd *cmd, > + uint8_t *payload_in, > + size_t len_in, > + uint8_t *payload_out, > + size_t *len_out, > + CXLCCI *cci) > +{ > + struct get_scan_media_results_out_pl { > + uint64_t dpa_restart; > + uint64_t length; > + uint8_t flags; > + uint8_t rsvd1; > + uint16_t count; > + uint8_t rsvd2[0xc]; > + struct { > + uint64_t addr; > + uint32_t length; > + uint32_t resv; > + } QEMU_PACKED records[]; > + } QEMU_PACKED; > + > + struct get_scan_media_results_out_pl *out = (void *)payload_out; > + CXLType3Dev *ct3d = CXL_TYPE3(cci->d); > + CXLPoisonList *scan_media_results = &ct3d->scan_media_results; > + CXLPoison *ent, *next; > + uint16_t total_count = 0, record_count = 0, i = 0; > + uint16_t out_pl_len; > + > + if (!ct3d->scan_media_hasrun) { > + return CXL_MBOX_UNSUPPORTED; > + } > + > + /* > + * Calculate limits, all entries are within the same > + * address range of the last scan media call. > + */ > + QLIST_FOREACH(ent, scan_media_results, node) { > + size_t rec_size = record_count * sizeof(out->records[0]); > + > + if (sizeof(*out) + rec_size < CXL_MAILBOX_MAX_PAYLOAD_SIZE) { > + record_count++; > + } > + total_count++; > + } > + > + out_pl_len = sizeof(*out) + record_count * sizeof(out->records[0]); > + assert(out_pl_len <= CXL_MAILBOX_MAX_PAYLOAD_SIZE); Isn't aim of the if in the loop above to ensure this never happens? I'd hope that code is obvious enough we don't need the additional assert here. > + > + memset(out, 0, out_pl_len); > + QLIST_FOREACH_SAFE(ent, scan_media_results, node, next) { > + uint64_t start, stop; > + > + if (i == record_count) { > + break; > + } > + > + start = ROUND_DOWN(ent->start, 64ull); > + stop = ROUND_DOWN(ent->start, 64ull) + ent->length; I think we control the way these all turn up so they are multiples of 64. So this rounding shouldn't be needed (or am I missing something?) > + stq_le_p(&out->records[i].addr, start | (ent->type & 0x7)); define for that 0x7 > + stl_le_p(&out->records[i].length, (stop - start) / CXL_CACHE_LINE_SIZE); > + i++; > + > + /* consume the returning entry */ > + QLIST_REMOVE(ent, node); > + g_free(ent); > + } > + > + stw_le_p(&out->count, record_count); > + if (total_count > record_count) { > + out->flags = (1 << 0); /* More Media Error Records */ Define perhaps. > + } > + > + *len_out = out_pl_len; > + return CXL_MBOX_SUCCESS; > +} > + > /* > * CXL r3.0 section 8.2.9.8.9.1: Dynamic Capacity Configuration > */ > @@ -1803,6 +1885,8 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = { > 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 }, > + [MEDIA_AND_POISON][GET_SCAN_MEDIA_RESULTS] = { "MEDIA_AND_POISON_GET_SCAN_MEDIA_RESULTS", I'll wrap this line whilst applying. Shortly I'm going to send out a series hammering down all the line lengths in the CXL code. > + cmd_media_get_scan_media_results, 0, 0 }, > }; > > static const struct cxl_cmd cxl_cmd_set_dcd[256][256] = { > diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h > index eb5c5284fa9f..e9d130e5c988 100644 > --- a/include/hw/cxl/cxl_device.h > +++ b/include/hw/cxl/cxl_device.h > @@ -484,6 +484,7 @@ struct CXLType3Dev { > /* Poison Injection - backup */ > CXLPoisonList poison_list_bkp; > CXLPoisonList scan_media_results; > + bool scan_media_hasrun; > > struct dynamic_capacity { > HostMemoryBackend *host_dc; ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/4] hw/cxl: Add get scan media results cmd support 2023-09-12 12:04 ` Jonathan Cameron @ 2023-09-13 3:33 ` Davidlohr Bueso 2023-09-13 13:30 ` Jonathan Cameron 0 siblings, 1 reply; 12+ messages in thread From: Davidlohr Bueso @ 2023-09-13 3:33 UTC (permalink / raw) To: Jonathan Cameron Cc: fan.ni, dan.j.williams, alison.schofield, ayush.m55, a.manzanares, linux-cxl On Tue, 12 Sep 2023, Jonathan Cameron wrote: >On Fri, 8 Sep 2023 00:31:52 -0700 >Davidlohr Bueso <dave@stgolabs.net> wrote: > >> Iterate over the list keeping the output payload size into account, >> returning the results from a previous scan media operation. The >> scan media operation does not fail prematurely due to device being >> out of storage, so this implementation does not deal with the >> retry/restart functionality. >> >> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net> >A few comments inline but nothing to stop me carrying this on my >staging tree. (gitlab.com/jic23/qemu cxl-*latestdate* > >So I'll apply it there. Updates welcome or I'll act on comments when >this gets to the top of our queue for upstreaming. I'll send follow up patches for this series once your new latest branch is published. Thanks, Davidlohr ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/4] hw/cxl: Add get scan media results cmd support 2023-09-13 3:33 ` Davidlohr Bueso @ 2023-09-13 13:30 ` Jonathan Cameron 2023-09-16 0:11 ` Davidlohr Bueso 0 siblings, 1 reply; 12+ messages in thread From: Jonathan Cameron @ 2023-09-13 13:30 UTC (permalink / raw) To: Davidlohr Bueso Cc: fan.ni, dan.j.williams, alison.schofield, ayush.m55, a.manzanares, linux-cxl On Tue, 12 Sep 2023 20:33:52 -0700 Davidlohr Bueso <dave@stgolabs.net> wrote: > On Tue, 12 Sep 2023, Jonathan Cameron wrote: > > >On Fri, 8 Sep 2023 00:31:52 -0700 > >Davidlohr Bueso <dave@stgolabs.net> wrote: > > > >> Iterate over the list keeping the output payload size into account, > >> returning the results from a previous scan media operation. The > >> scan media operation does not fail prematurely due to device being > >> out of storage, so this implementation does not deal with the > >> retry/restart functionality. > >> > >> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net> > >A few comments inline but nothing to stop me carrying this on my > >staging tree. (gitlab.com/jic23/qemu cxl-*latestdate* > > > >So I'll apply it there. Updates welcome or I'll act on comments when > >this gets to the top of our queue for upstreaming. > > I'll send follow up patches for this series once your new latest > branch is published. > > Thanks, > Davidlohr https://gitlab.com/jic23/qemu/-/tree/cxl-2023-09-13 Fresh and tasty. Includes 3 series that I've posted with the hope of them merging soon and another one I'll post in a few mins to deal with over long lines... Jonathan ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/4] hw/cxl: Add get scan media results cmd support 2023-09-13 13:30 ` Jonathan Cameron @ 2023-09-16 0:11 ` Davidlohr Bueso 2023-09-18 11:11 ` Jonathan Cameron 0 siblings, 1 reply; 12+ messages in thread From: Davidlohr Bueso @ 2023-09-16 0:11 UTC (permalink / raw) To: Jonathan Cameron Cc: fan.ni, dan.j.williams, alison.schofield, ayush.m55, a.manzanares, linux-cxl On Wed, 13 Sep 2023, Jonathan Cameron wrote: >https://gitlab.com/jic23/qemu/-/tree/cxl-2023-09-13 > >Fresh and tasty. Includes 3 series that I've posted with the hope >of them merging soon and another one I'll post in a few mins to >deal with over long lines... fyi I'm getting the below: /usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: libcommon.fa.p/hw_cxl_vendor_skhynix_skhynix_niagara.c.o: in function `cxl_niagara_reset': /home/dave/git/qemu-jic/build/../hw/cxl/vendor/skhynix/skhynix_niagara.c:477: undefined reference to `ct3d_reset' /usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: libcommon.fa.p/hw_cxl_vendor_skhynix_skhynix_niagara.c.o: in function `cxl_niagara_exit': /home/dave/git/qemu-jic/build/../hw/cxl/vendor/skhynix/skhynix_niagara.c:466: undefined reference to `ct3_exit' /usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: libcommon.fa.p/hw_cxl_vendor_skhynix_skhynix_niagara.c.o: in function `cxl_niagara_realize': /home/dave/git/qemu-jic/build/../hw/cxl/vendor/skhynix/skhynix_niagara.c:428: undefined reference to `ct3_realize' /usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: libcommon.fa.p/hw_cxl_vendor_skhynix_skhynix_niagara.c.o: in function `cxl_niagara_reset': /home/dave/git/qemu-jic/build/../hw/cxl/vendor/skhynix/skhynix_niagara.c:478: undefined reference to `cxl_add_cci_commands' ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/4] hw/cxl: Add get scan media results cmd support 2023-09-16 0:11 ` Davidlohr Bueso @ 2023-09-18 11:11 ` Jonathan Cameron 2023-09-18 16:58 ` Gregory Price 0 siblings, 1 reply; 12+ messages in thread From: Jonathan Cameron @ 2023-09-18 11:11 UTC (permalink / raw) To: Davidlohr Bueso Cc: fan.ni, dan.j.williams, alison.schofield, ayush.m55, a.manzanares, linux-cxl, Gregory Price On Fri, 15 Sep 2023 17:11:27 -0700 Davidlohr Bueso <dave@stgolabs.net> wrote: > On Wed, 13 Sep 2023, Jonathan Cameron wrote: > > >https://gitlab.com/jic23/qemu/-/tree/cxl-2023-09-13 > > > >Fresh and tasty. Includes 3 series that I've posted with the hope > >of them merging soon and another one I'll post in a few mins to > >deal with over long lines... > > fyi I'm getting the below: > > /usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: libcommon.fa.p/hw_cxl_vendor_skhynix_skhynix_niagara.c.o: in function `cxl_niagara_reset': > /home/dave/git/qemu-jic/build/../hw/cxl/vendor/skhynix/skhynix_niagara.c:477: undefined reference to `ct3d_reset' > /usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: libcommon.fa.p/hw_cxl_vendor_skhynix_skhynix_niagara.c.o: in function `cxl_niagara_exit': > /home/dave/git/qemu-jic/build/../hw/cxl/vendor/skhynix/skhynix_niagara.c:466: undefined reference to `ct3_exit' > /usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: libcommon.fa.p/hw_cxl_vendor_skhynix_skhynix_niagara.c.o: in function `cxl_niagara_realize': > /home/dave/git/qemu-jic/build/../hw/cxl/vendor/skhynix/skhynix_niagara.c:428: undefined reference to `ct3_realize' > /usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: libcommon.fa.p/hw_cxl_vendor_skhynix_skhynix_niagara.c.o: in function `cxl_niagara_reset': > /home/dave/git/qemu-jic/build/../hw/cxl/vendor/skhynix/skhynix_niagara.c:478: undefined reference to `cxl_add_cci_commands' Thanks. I'd not noticed the niagara stuff doesn't have it's own kconfig with dependencies. Gregory, want to send a proper fix defining the various Kconfigs down to the actual build directory? I'd guess the lazy approach of making CXL_VENDOR depends on CXL_MEM_DEVICE should work in meantime. Jonathan ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/4] hw/cxl: Add get scan media results cmd support 2023-09-18 11:11 ` Jonathan Cameron @ 2023-09-18 16:58 ` Gregory Price 0 siblings, 0 replies; 12+ messages in thread From: Gregory Price @ 2023-09-18 16:58 UTC (permalink / raw) To: Jonathan Cameron Cc: Davidlohr Bueso, fan.ni, dan.j.williams, alison.schofield, ayush.m55, a.manzanares, linux-cxl, Gregory Price On Mon, Sep 18, 2023 at 12:11:28PM +0100, Jonathan Cameron wrote: > On Fri, 15 Sep 2023 17:11:27 -0700 > Davidlohr Bueso <dave@stgolabs.net> wrote: > > > On Wed, 13 Sep 2023, Jonathan Cameron wrote: > > > > >https://gitlab.com/jic23/qemu/-/tree/cxl-2023-09-13 > > > > > >Fresh and tasty. Includes 3 series that I've posted with the hope > > >of them merging soon and another one I'll post in a few mins to > > >deal with over long lines... > > > > fyi I'm getting the below: > > > > /usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: libcommon.fa.p/hw_cxl_vendor_skhynix_skhynix_niagara.c.o: in function `cxl_niagara_reset': > > /home/dave/git/qemu-jic/build/../hw/cxl/vendor/skhynix/skhynix_niagara.c:477: undefined reference to `ct3d_reset' > > /usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: libcommon.fa.p/hw_cxl_vendor_skhynix_skhynix_niagara.c.o: in function `cxl_niagara_exit': > > /home/dave/git/qemu-jic/build/../hw/cxl/vendor/skhynix/skhynix_niagara.c:466: undefined reference to `ct3_exit' > > /usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: libcommon.fa.p/hw_cxl_vendor_skhynix_skhynix_niagara.c.o: in function `cxl_niagara_realize': > > /home/dave/git/qemu-jic/build/../hw/cxl/vendor/skhynix/skhynix_niagara.c:428: undefined reference to `ct3_realize' > > /usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: libcommon.fa.p/hw_cxl_vendor_skhynix_skhynix_niagara.c.o: in function `cxl_niagara_reset': > > /home/dave/git/qemu-jic/build/../hw/cxl/vendor/skhynix/skhynix_niagara.c:478: undefined reference to `cxl_add_cci_commands' > > Thanks. I'd not noticed the niagara stuff doesn't have it's own kconfig with dependencies. > Gregory, want to send a proper fix defining the various Kconfigs down to the actual build directory? > > I'd guess the lazy approach of making CXL_VENDOR > depends on CXL_MEM_DEVICE > should work in meantime. > > Jonathan > woops! My bad. I will push up a patch later today with that + limiting niagara to linux-only (already fixed that up, just haven't pushed it). I don't think any other changes have been made to that line, so i'll just push an update to the Niagara patch itself and you can hot-swap them on the branch if you like. ~Gregory ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-07-05 12:08 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-07-05 12:06 [PATCH qemu 0/4] hw/cxl: Add support for scan media Jonathan Cameron 2024-07-05 12:06 ` [PATCH 1/4] hw/cxl: Add get scan media capabilities cmd support Jonathan Cameron 2024-07-05 12:06 ` [PATCH 2/4] hw/cxl/mbox: replace sanitize_running() with cxl_dev_media_disabled() Jonathan Cameron 2024-07-05 12:06 ` [PATCH 3/4] hw/cxl/events: discard all event records during sanitation Jonathan Cameron 2024-07-05 12:06 ` [PATCH 4/4] hw/cxl: Add get scan media results cmd support Jonathan Cameron -- strict thread matches above, loose matches on Subject: below -- 2023-09-08 7:31 [PATCH -qemu 0/4] hw/cxl: Support for scan media Davidlohr Bueso 2023-09-08 7:31 ` [PATCH 4/4] hw/cxl: Add get scan media results cmd support Davidlohr Bueso 2023-09-12 12:04 ` Jonathan Cameron 2023-09-13 3:33 ` Davidlohr Bueso 2023-09-13 13:30 ` Jonathan Cameron 2023-09-16 0:11 ` Davidlohr Bueso 2023-09-18 11:11 ` Jonathan Cameron 2023-09-18 16:58 ` Gregory Price
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox