hw/cxl: Line length reduction and related
cover hw/cxl: Line length reduction and related
Michael observed that the CXL code regularly went above the 80 character recommendation and in many cases this was not necessary for readability.
This series is focused on tidying this up for the existing code so that we can maintain the preferred formatting going forwards.
Based on: [PATCH 0/4] hw/cxl: Minor CXL emulation fixes and cleanup
Based on: [PATCH v2 0/3] hw/cxl: Add dummy ACPI QTG DSM
Based-on: [PATCH V2] hw/pci-bridge/cxl-upstream: Add serial number extended capability support
Based on: Message ID: [email protected] Based on: Message ID: [email protected] Based on: Message ID: [email protected]
Jonathan Cameron (4):
hw/cxl: Use a switch to explicitly check size in caps_reg_read() hw/cxl: Use available size parameter to index into register arrays. hw/cxl: CXLDVSECPortExtensions renamed to CXLDVSECPortExt hw/cxl: Line length reductions
include/hw/cxl/cxl_component.h | 3 +- include/hw/cxl/cxl_device.h | 5 ++- include/hw/cxl/cxl_events.h | 3 +- include/hw/cxl/cxl_pci.h | 6 +-- hw/cxl/cxl-cdat.c | 3 +- hw/cxl/cxl-component-utils.c | 67 ++++++++++++++++++++-------------- hw/cxl/cxl-device-utils.c | 11 ++++-- hw/cxl/cxl-events.c | 9 +++-- hw/cxl/cxl-mailbox-utils.c | 21 +++++++---- hw/mem/cxl_type3.c | 31 ++++++++++------ hw/mem/cxl_type3_stubs.c | 5 ++- hw/pci-bridge/cxl_downstream.c | 2 +- hw/pci-bridge/cxl_root_port.c | 2 +- hw/pci-bridge/cxl_upstream.c | 2 +- 14 files changed, 103 insertions(+), 67 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/4 hw/cxl: Use a switch to explicitly check size in caps_reg_read()
Bring this read function inline with the others that do check for unexpected size values.
Also reduces line lengths to sub 80 chars.
--- hw/cxl/cxl-device-utils.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
hw/cxl/cxl-device-utils.c +7 -4
@@ -32,10 +32,13 @@ static uint64_t caps_reg_read(void *opaque, hwaddr offset, unsigned size) {CXLDeviceState *cxl_dstate = opaque; -if (size ==4 ) { -return cxl_dstate->caps_reg_state32[offset /sizeof (*cxl_dstate->caps_reg_state32)]; - }else { -return cxl_dstate->caps_reg_state64[offset /sizeof (*cxl_dstate->caps_reg_state64)]; +switch (size) { +case 4 : +return cxl_dstate->caps_reg_state32[offset / size]; +case 8 : +return cxl_dstate->caps_reg_state64[offset / size]; +default : +g_assert_not_reached (); } }
Signature · 1 line
2.39.2
Re: [PATCH 1/4] hw/cxl: Use a switch to explicitly check size in caps_reg_read()
Quoted 9 lines · Jonathan Cameron
Bring this read function inline with the others that do check for unexpected size values.
Also reduces line lengths to sub 80 chars.
Signed-off-by Jonathan Cameron <[email protected]>--- hw/cxl/cxl-device-utils.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
PATCH 2/4 hw/cxl: Use available size parameter to index into register arrays.
In reply to Jonathan Cameron viaIndexing has to be done into an array with the right size elements. As such, the size parameter always matches the array element size and can be used in place of the longer sizeof(*array)
--- hw/cxl/cxl-component-utils.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/cxl/cxl-component-utils.c +4 -4
@@ -76,7 +76,7 @@ static uint64_t cxl_cache_mem_read_reg(void *opaque, hwaddr offset,if (cregs->special_ops && cregs->special_ops->read) {return cregs->special_ops->read (cxl_cstate, offset, size); }else { -return cregs->cache_mem_registers[offset /sizeof (*cregs->cache_mem_registers)]; +return cregs->cache_mem_registers[offset / size]; } }
@@ -122,10 +122,10 @@ static void cxl_cache_mem_write_reg(void *opaque, hwaddr offset, uint64_t value, "CXL 8 byte cache mem registers not implemented\n");return ; } - mask = cregs->cache_mem_regs_write_mask[offset /sizeof (*cregs->cache_mem_regs_write_mask)]; + mask = cregs->cache_mem_regs_write_mask[offset / size]; value &= mask;/* RO bits should remain constant. Done by reading existing value */ - value |= ~mask & cregs->cache_mem_registers[offset /sizeof (*cregs->cache_mem_registers)]; + value |= ~mask & cregs->cache_mem_registers[offset / size];if (cregs->special_ops && cregs->special_ops->write) { cregs->special_ops->write (cxl_cstate, offset, value, size);return ;
@@ -135,7 +135,7 @@ static void cxl_cache_mem_write_reg(void *opaque, hwaddr offset, uint64_t value, offset <= A_CXL_HDM_DECODER3_TARGET_LIST_HI) { dumb_hdm_handler(cxl_cstate, offset, value); } else { - cregs->cache_mem_registers[offset /sizeof (*cregs->cache_mem_registers)] = value; + cregs->cache_mem_registers[offset / size] = value; } }
Signature · 1 line
2.39.2
Re: [PATCH 2/4] hw/cxl: Use available size parameter to index into register arrays.
Quoted 14 lines · Jonathan Cameron via
Indexing has to be done into an array with the right size elements. As such, the size parameter always matches the array element size and can be used in place of the longer
sizeof(*array)Signed-off-by Jonathan Cameron <[email protected]>--- hw/cxl/cxl-component-utils.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)hw/cxl/cxl-component-utils.c +0
-0
hw/cxl/cxl-component-utils.c static uint64_t cxl_cache_mem_read_reg(void *opaque, hwaddr offset, · line 79
Quoted 5 lines
hw/cxl/cxl-component-utils.c +1
-1@@ -76,7 +76,7 @@ static uint64_t cxl_cache_mem_read_reg(void *opaque, hwaddr offset,if (cregs->special_ops && cregs->special_ops->read) {return cregs->special_ops->read (cxl_cstate, offset, size); }else { -return cregs->cache_mem_registers[offset /sizeof (*cregs->cache_mem_registers)]; +return cregs->cache_mem_registers[offset / size];
This is a though one, and smells wrong.
Though because it is not at all obvious where this "size" value comes from, have to find usage(s) of this function (cache_mem_ops) and think twice about the other parameters in there. Also having in mind the previous comparison with 8. In this part of the code, size should always be =4, but it takes hard time to figure this out.
Wrong - no, because of the above - the only 2 possible values are 4 and 8, but it's difficult to see what's going on, and you're making it worse.
Original code was at least clear you're getting a single register from an array of registers, with new code it is not clear at all.
What I'd probably use here is to add comment that size can be either 4 or 8, and use a switch similar to what you've used in first patch in this series. And have a static_assert(sizeof(register) == 4) or something like that here in this second branch.
So it is something like:
static uint64_t cxl_cache_mem_read_reg(void *opaque, hwaddr offset,
unsigned size)
{
CXLComponentState *cxl_cstate = opaque;
ComponentRegisters *cregs = &cxl_cstate->crb;
switch (size) {
case 8:
qemu_log_mask(LOG_UNIMP,
"CXL 8 byte cache mem registers not implemented\n");
return 0;
case 4:
if (cregs->special_ops && cregs->special_ops->read) {
return cregs->special_ops->read(cxl_cstate, offset, 4);
} else {
return cregs->cache_mem_registers[offset /
sizeof(*cregs->cache_mem_registers)];
}
default:
/* this routine is called with size being either 4 or 8 only */
g_assert_not_reached();
}
}Note: I especially left the sizeof() here, instead of using a previously suggested static_assert() - because a register can be implemented using larger integers on the host, it does not need to be 4 bytes, - but only low 4 bytes can actually be used.
This does not shorten the line (it does by wrapping it up), but it keep code correct and more understandable. Adding size parameter there makes it much more cryptic.
Here and in other places.
This is just an example, not a suggestion.
/mjt
Re: [PATCH 2/4] hw/cxl: Use available size parameter to index into register arrays.
Quoted 29 lines · On Thu, 14 Sep 2023 15:54:54 +0300 Michael Tokarev <[email protected]> wrote:
Quoted 14 lines · Jonathan Cameron via
Indexing has to be done into an array with the right size elements. As such, the size parameter always matches the array element size and can be used in place of the longer
sizeof(*array)Signed-off-by Jonathan Cameron <[email protected]>--- hw/cxl/cxl-component-utils.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)hw/cxl/cxl-component-utils.c +0
-0hw/cxl/cxl-component-utils.c static uint64_t cxl_cache_mem_read_reg(void *opaque, hwaddr offset, · line 79
Quoted 5 lines
hw/cxl/cxl-component-utils.c +1
-1@@ -76,7 +76,7 @@ static uint64_t cxl_cache_mem_read_reg(void *opaque, hwaddr offset,if (cregs->special_ops && cregs->special_ops->read) {return cregs->special_ops->read (cxl_cstate, offset, size); }else { -return cregs->cache_mem_registers[offset /sizeof (*cregs->cache_mem_registers)]; +return cregs->cache_mem_registers[offset / size];This is a though one, and smells wrong.
Though because it is not at all obvious where this "size" value comes from, have to find usage(s) of this function (
cache_mem_ops) and think twice about the other parameters in there. Also having in mind the previous comparison with 8. In this part of the code, size should always be =4, but it takes hard time to figure this out.
Quoted 5 lines
Wrong - no, because of the above - the only 2 possible values are 4 and 8, but it's difficult to see what's going on, and you're making it worse.
Original code was at least clear you're getting a single register from an array of registers, with new code it is not clear at all.
Fair point.
Quoted 5 lines
What I'd probably use here is to add comment that size can be either 4 or 8, and use a switch similar to what you've used in first patch in this series. And have a
static_assert(sizeof(register) == 4)or something like that here in this second branch.
Good idea.
Quoted 29 lines
So it is something like:
static
uint64_tcxl_cache_mem_read_reg(void *opaque, hwaddr offset,
unsigned size){ CXLComponentState *cxl_cstate = opaque; ComponentRegisters *cregs = &cxl_cstate->crb; switch (size) { case 8: qemu_log_mask(LOG_UNIMP, "CXL 8 byte cache mem registers not implemented\n"); return 0; case 4: if (cregs->special_ops && cregs->special_ops->read) { return cregs->special_ops->read(cxl_cstate, offset, 4); } else { return cregs->cache_mem_registers[offset / sizeof(*cregs->cache_mem_registers)]; } default: /* this routine is called with size being either 4 or 8 only */ g_assert_not_reached(); } }
Quoted 4 lines
Note: I especially left the
sizeof()here, instead of using a previously suggestedstatic_assert()- because a register can be implemented using larger integers on the host, it does not need to be 4 bytes, - but only low 4 bytes can actually be used.
I don't follow. Here cache_mem_registers is an array of uint32_t so it is going to be 4 bytes on any host! Obviously that's not true for registers in general.
So I've added the assert as it is always valid and made it a / 4
Note I ended up with just using size in the first place because I was planning to add a local variable that was always the same size and that was silly.
Quoted 8 lines
This does not shorten the line (it does by wrapping it up), but it keep code correct and more understandable. Adding size parameter there makes it much more cryptic.
Here and in other places.
This is just an example, not a suggestion.
It makes sense. Sorry - thought I'd sent this last week!
Jonathan
Quoted 3 lines
/mjt
PATCH 3/4 hw/cxl: CXLDVSECPortExtensions renamed to CXLDVSECPortExt
In reply to Jonathan Cameron viaDone to reduce line lengths where this is used. Ext seems sufficiently obvious that it need not be spelt out fully.
--- include/hw/cxl/cxl_pci.h | 6 ++--- hw/cxl/cxl-component-utils.c | 49 ++++++++++++++++++++-------------- hw/pci-bridge/cxl_downstream.c | 2 +- hw/pci-bridge/cxl_root_port.c | 2 +- hw/pci-bridge/cxl_upstream.c | 2 +- 5 files changed, 35 insertions(+), 26 deletions(-)
include/hw/cxl/cxl_pci.h +3 -3
@@ -86,7 +86,7 @@ typedef struct CXLDVSECDevice {QEMU_BUILD_BUG_ON (sizeof (CXLDVSECDevice) !=0x38 );/* CXL 2.0 - 8.1.5 (ID 0003) */ -typedef struct CXLDVSECPortExtensions { +typedef struct CXLDVSECPortExt { DVSECHeader hdr; uint16_t status; uint16_t control;
@@ -100,8 +100,8 @@ typedef struct CXLDVSECPortExtensions {uint32_t alt_prefetch_limit_high;uint32_t rcrb_base;uint32_t rcrb_base_high; -} CXLDVSECPortExtensions; -QEMU_BUILD_BUG_ON (sizeof (CXLDVSECPortExtensions) !=0x28 ); +} CXLDVSECPortExt; +QEMU_BUILD_BUG_ON (sizeof (CXLDVSECPortExt) !=0x28 );#define PORT_CONTROL_OFFSET 0xc#define PORT_CONTROL_UNMASK_SBR 1
hw/cxl/cxl-component-utils.c +29 -20
55 lines not on this page · raw message
hw/pci-bridge/cxl_downstream.c +1 -1
@@ -98,7 +98,7 @@ static void build_dvsecs(CXLComponentState *cxl) {uint8_t *dvsec; - dvsec = (uint8_t *)&(CXLDVSECPortExtensions ){0 }; + dvsec = (uint8_t *)&(CXLDVSECPortExt ){0 }; cxl_component_create_dvsec(cxl, CXL2_DOWNSTREAM_PORT, EXTENSIONS_PORT_DVSEC_LENGTH, EXTENSIONS_PORT_DVSEC,
hw/pci-bridge/cxl_root_port.c +1 -1
@@ -107,7 +107,7 @@ static void build_dvsecs(CXLComponentState *cxl) {uint8_t *dvsec; - dvsec = (uint8_t *)&(CXLDVSECPortExtensions ){0 }; + dvsec = (uint8_t *)&(CXLDVSECPortExt ){0 }; cxl_component_create_dvsec(cxl, CXL2_ROOT_PORT, EXTENSIONS_PORT_DVSEC_LENGTH, EXTENSIONS_PORT_DVSEC,
hw/pci-bridge/cxl_upstream.c +1 -1
@@ -116,7 +116,7 @@ static void build_dvsecs(CXLComponentState *cxl) {uint8_t *dvsec; - dvsec = (uint8_t *)&(CXLDVSECPortExtensions ){ + dvsec = (uint8_t *)&(CXLDVSECPortExt ){ .status =0x1 ,/* Port Power Management Init Complete */ }; cxl_component_create_dvsec(cxl, CXL2_UPSTREAM_PORT,
Signature · 1 line
2.39.2
Re: [PATCH 3/4] hw/cxl: CXLDVSECPortExtensions renamed to CXLDVSECPortExt
Quoted 4 lines · Jonathan Cameron
Done to reduce line lengths where this is used. Ext seems sufficiently obvious that it need not be spelt out fully.
Quoted 8 lines
Signed-off-by Jonathan Cameron <[email protected]>--- include/hw/cxl/cxl_pci.h | 6 ++--- hw/cxl/cxl-component-utils.c | 49 ++++++++++++++++++++-------------- hw/pci-bridge/cxl_downstream.c | 2 +- hw/pci-bridge/cxl_root_port.c | 2 +- hw/pci-bridge/cxl_upstream.c | 2 +- 5 files changed, 35 insertions(+), 26 deletions(-)
PATCH 4/4 hw/cxl: Line length reductions
In reply to Jonathan Cameron viaMichael Tsirkin observed that there were some unnecessarily long lines in the CXL code in a recent review. This patch is intended to rectify that where it does not hurt readability.
--- include/hw/cxl/cxl_component.h | 3 ++- include/hw/cxl/cxl_device.h | 5 +++-- include/hw/cxl/cxl_events.h | 3 ++- hw/cxl/cxl-cdat.c | 3 ++- hw/cxl/cxl-component-utils.c | 10 ++++++---- hw/cxl/cxl-events.c | 9 ++++++--- hw/cxl/cxl-mailbox-utils.c | 21 ++++++++++++++------- hw/mem/cxl_type3.c | 31 +++++++++++++++++++------------ hw/mem/cxl_type3_stubs.c | 5 +++-- 9 files changed, 57 insertions(+), 33 deletions(-)
include/hw/cxl/cxl_component.h +2 -1
@@ -175,7 +175,8 @@ HDM_DECODER_INIT(3); (CXL_IDE_REGISTERS_OFFSET + CXL_IDE_REGISTERS_SIZE)#define CXL_SNOOP_REGISTERS_SIZE 0x8 -QEMU_BUILD_BUG_MSG ((CXL_SNOOP_REGISTERS_OFFSET +CXL_SNOOP_REGISTERS_SIZE ) >=0x1000 , +QEMU_BUILD_BUG_MSG ((CXL_SNOOP_REGISTERS_OFFSET + +CXL_SNOOP_REGISTERS_SIZE ) >=0x1000 ,"No space for registers" ); typedef struct component_registers {
include/hw/cxl/cxl_device.h +3 -2
@@ -192,7 +192,7 @@ void cxl_device_register_init_common(CXLDeviceState *dev);* Documented as a 128 bit register, but 64 bit accesses and the second * 64 bits are currently reserved. */ -REG64(CXL_DEV_CAP_ARRAY, 0) /* Documented as 128 bit register but 64 byte accesses */ +REG64(CXL_DEV_CAP_ARRAY, 0) FIELD(CXL_DEV_CAP_ARRAY, CAP_ID, 0, 16) FIELD(CXL_DEV_CAP_ARRAY, CAP_VERSION, 16, 8)FIELD (CXL_DEV_CAP_ARRAY ,CAP_COUNT ,32 ,16 )
@@ -361,7 +361,8 @@ struct CXLType3Class { uint64_t offset);void (*set_lsa)(CXLType3Dev *ct3d,const void *buf,uint64_t size,uint64_t offset); -bool (*set_cacheline)(CXLType3Dev *ct3d,uint64_t dpa_offset,uint8_t *data); +bool (*set_cacheline)(CXLType3Dev *ct3d,uint64_t dpa_offset, +uint8_t *data); }; MemTxResult cxl_type3_read(PCIDevice *d, hwaddr host_addr, uint64_t *data,
include/hw/cxl/cxl_events.h +2 -1
@@ -92,7 +92,8 @@ typedef enum CXLEventIntMode {CXL_INT_RES =0x03 , } CXLEventIntMode;#define CXL_EVENT_INT_MODE_MASK 0x3 -#define CXL_EVENT_INT_SETTING (vector) ((((uint8_t)vector & 0xf) << 4) | CXL_INT_MSI_MSIX) +#define CXL_EVENT_INT_SETTING (vector) \ + ((((uint8_t)vector & 0xf) << 4) | CXL_INT_MSI_MSIX) typedef struct CXLEventInterruptPolicy { uint8_t info_settings; uint8_t warn_settings;
hw/cxl/cxl-cdat.c +2 -1
@@ -60,7 +60,8 @@ static void ct3_build_cdat(CDATObject *cdat, Error **errp)return ; } - cdat->built_buf_len = cdat->build_cdat_table (&cdat->built_buf, cdat->private); + cdat->built_buf_len = cdat->build_cdat_table (&cdat->built_buf, + cdat->private);if (!cdat->built_buf_len) {/* Build later as not all data available yet */
hw/cxl/cxl-component-utils.c +6 -4
@@ -221,7 +221,8 @@ static void hdm_init_common(uint32_t *reg_state, uint32_t *write_msk,ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY ,TARGET_COUNT ,1 );ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY ,INTERLEAVE_256B ,1 );ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY ,INTERLEAVE_4K ,1 ); -ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY ,POISON_ON_ERR_CAP ,0 ); +ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_CAPABILITY , +POISON_ON_ERR_CAP ,0 );ARRAY_FIELD_DP32 (reg_state,CXL_HDM_DECODER_GLOBAL_CONTROL ,HDM_DECODER_ENABLE ,0 ); write_msk[R_CXL_HDM_DECODER_GLOBAL_CONTROL ] =0x3 ;
@@ -244,13 +245,14 @@ static void hdm_init_common(uint32_t *reg_state, uint32_t *write_msk, } } -void cxl_component_register_init_common (uint32_t *reg_state,uint32_t *write_msk, +void cxl_component_register_init_common (uint32_t *reg_state, +uint32_t *write_msk,enum reg_type type) {int caps =0 ;/* -* In CXL 2.0 the capabilities required for each CXL component are such that, +* In CXL2.0 the capabilities required for each CXL component are such that, * with the ordering chosen here, a single number can be used to define * which capabilities should be provided. */
@@ -429,7 +431,7 @@ void cxl_component_create_dvsec(CXLComponentState *cxl,default :/* Registers are RO for other component types */ break ; } -/* There are rw1cs bits in the status register but never set currently */ +/* There are rw1cs bits in the status register but never set */ break ; }
hw/cxl/cxl-events.c +6 -3
@@ -170,8 +170,10 @@ CXLRetCode cxl_event_get_records(CXLDeviceState *cxlds, CXLGetEventPayload *pl,if (log->overflow_err_count) { pl->flags |=CXL_GET_EVENT_FLAG_OVERFLOW ; pl->overflow_err_count =cpu_to_le16 (log->overflow_err_count); - pl->first_overflow_timestamp =cpu_to_le64 (log->first_overflow_timestamp); - pl->last_overflow_timestamp =cpu_to_le64 (log->last_overflow_timestamp); + pl->first_overflow_timestamp = +cpu_to_le64 (log->first_overflow_timestamp); + pl->last_overflow_timestamp = +cpu_to_le64 (log->last_overflow_timestamp); } pl->record_count =cpu_to_le16 (nr);
@@ -180,7 +182,8 @@ CXLRetCode cxl_event_get_records(CXLDeviceState *cxlds, CXLGetEventPayload *pl,return CXL_MBOX_SUCCESS ; } -CXLRetCode cxl_event_clear_records (CXLDeviceState *cxlds,CXLClearEventPayload *pl) +CXLRetCode cxl_event_clear_records (CXLDeviceState *cxlds, +CXLClearEventPayload *pl) {CXLEventLog *log;uint8_t log_type;
hw/cxl/cxl-mailbox-utils.c +14 -7
@@ -366,9 +366,12 @@ static CXLRetCode cmd_identify_memory_device(struct cxl_cmd *cmd,snprintf (id->fw_revision,0x10 ,"BWFW VERSION %02d" ,0 ); -stq_le_p (&id->total_capacity, cxl_dstate->mem_size /CXL_CAPACITY_MULTIPLIER ); -stq_le_p (&id->persistent_capacity, cxl_dstate->pmem_size /CXL_CAPACITY_MULTIPLIER ); -stq_le_p (&id->volatile_capacity, cxl_dstate->vmem_size /CXL_CAPACITY_MULTIPLIER ); +stq_le_p (&id->total_capacity, + cxl_dstate->mem_size /CXL_CAPACITY_MULTIPLIER ); +stq_le_p (&id->persistent_capacity, + cxl_dstate->pmem_size /CXL_CAPACITY_MULTIPLIER ); +stq_le_p (&id->volatile_capacity, + cxl_dstate->vmem_size /CXL_CAPACITY_MULTIPLIER );stl_le_p (&id->lsa_size, cvc->get_lsa_size (ct3d));/* 256 poison records */ st24_le_p (id->poison_list_max_mer,256 );
@@ -396,13 +399,15 @@ static CXLRetCode cmd_ccls_get_partition_info(struct cxl_cmd *cmd,return CXL_MBOX_INTERNAL_ERROR ; } -stq_le_p (&part_info->active_vmem, cxl_dstate->vmem_size /CXL_CAPACITY_MULTIPLIER ); +stq_le_p (&part_info->active_vmem, + cxl_dstate->vmem_size /CXL_CAPACITY_MULTIPLIER );/* * When both next_vmem and next_pmem are 0, there is no pending change to * partitioning. */ stq_le_p (&part_info->next_vmem,0 ); -stq_le_p (&part_info->active_pmem, cxl_dstate->pmem_size /CXL_CAPACITY_MULTIPLIER ); +stq_le_p (&part_info->active_pmem, + cxl_dstate->pmem_size /CXL_CAPACITY_MULTIPLIER );stq_le_p (&part_info->next_pmem,0 ); *len =sizeof (*part_info);
@@ -681,8 +686,10 @@ static struct cxl_cmd cxl_cmd_set[256][256] = { [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 }, - [LOGS][GET_SUPPORTED] = { "LOGS_GET_SUPPORTED", cmd_logs_get_supported, 0, 0 }, + [TIMESTAMP][SET] = { "TIMESTAMP_SET", cmd_timestamp_set, + 8, 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 }, [IDENTIFY][MEMORY_DEVICE] = { "IDENTIFY_MEMORY_DEVICE", cmd_identify_memory_device, 0, 0 },
hw/mem/cxl_type3.c +19 -12
@@ -197,10 +197,9 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat_table, void *priv) }if (nonvolatile_mr) { +uint64_t base = volatile_mr ?memory_region_size (volatile_mr) :0 ; rc =ct3_build_cdat_entries_for_mr (&(table[cur_ent]), dsmad_handle++, - nonvolatile_mr, true, - (volatile_mr ? -memory_region_size (volatile_mr) :0 )); + nonvolatile_mr, true, base);if (rc <0 ) { goto error_cleanup; }
@@ -503,7 +502,8 @@ static void ct3d_reg_write(void *opaque, hwaddr offset, uint64_t value,case A_CXL_RAS_UNC_ERR_STATUS : {uint32_t capctrl =ldl_le_p (cache_mem +R_CXL_RAS_ERR_CAP_CTRL ); -uint32_t fe =FIELD_EX32 (capctrl,CXL_RAS_ERR_CAP_CTRL ,FIRST_ERROR_POINTER ); +uint32_t fe =FIELD_EX32 (capctrl,CXL_RAS_ERR_CAP_CTRL , +FIRST_ERROR_POINTER );CXLError *cxl_err;uint32_t unc_err;
@@ -522,7 +522,8 @@ static void ct3d_reg_write(void *opaque, hwaddr offset, uint64_t value,* closest to behavior of hardware not capable of multiple * header recording. */ - QTAILQ_FOREACH_SAFE(cxl_err, &ct3d->error_list, node, cxl_next) { +QTAILQ_FOREACH_SAFE (cxl_err, &ct3d->error_list, node, + cxl_next) {if ((1 << cxl_err->type) & value) {QTAILQ_REMOVE (&ct3d->error_list, cxl_err, node);g_free (cxl_err);
@@ -1061,7 +1062,8 @@ void qmp_cxl_inject_poison(const char *path, uint64_t start, uint64_t length,if (((start >= p->start) && (start < p->start + p->length)) || ((start + length > p->start) && (start + length <= p->start + p->length))) { -error_setg (errp,"Overlap with existing poisoned region not supported" ); +error_setg (errp, +"Overlap with existing poisoned region not supported" );return ; } }
@@ -1074,7 +1076,8 @@ void qmp_cxl_inject_poison(const char *path, uint64_t start, uint64_t length, p =g_new0 (CXLPoison,1 ); p->length = length; p->start = start; - p->type =CXL_POISON_TYPE_INTERNAL ;/* Different from injected via the mbox */ +/* Different from injected via the mbox */ + p->type =CXL_POISON_TYPE_INTERNAL ;QLIST_INSERT_HEAD (&ct3d->poison_list, p, node); ct3d->poison_list_cnt++;
@@ -1211,7 +1214,8 @@ void qmp_cxl_inject_correctable_error(const char *path, CxlCorErrorType type,return ; }/* If the error is masked, nothting to do here */ -if (!((1 << cxl_err_type) & ~ldl_le_p (reg_state +R_CXL_RAS_COR_ERR_MASK ))) { +if (!((1 << cxl_err_type) & + ~ldl_le_p (reg_state +R_CXL_RAS_COR_ERR_MASK ))) {return ; }
@@ -1361,7 +1365,8 @@ void qmp_cxl_inject_dram_event(const char *path, CxlEventLog log, uint8_t flags, bool has_bank, uint8_t bank, bool has_row, uint32_t row, bool has_column, uint16_t column, - bool has_correction_mask, uint64List *correction_mask, + bool has_correction_mask, + uint64List *correction_mask, Error **errp) { Object *obj = object_resolve_path(path, NULL);
@@ -1462,7 +1467,7 @@ void qmp_cxl_inject_memory_module_event(const char *path, CxlEventLog log,int16_t temperature, uint32_t dirty_shutdown_count, uint32_t corrected_volatile_error_count, - uint32_t corrected_persistent_error_count, + uint32_t corrected_persist_error_count, Error **errp) { Object *obj = object_resolve_path(path, NULL);
@@ -1502,8 +1507,10 @@ void qmp_cxl_inject_memory_module_event(const char *path, CxlEventLog log, module.life_used = life_used;stw_le_p (&module.temperature, temperature);stl_le_p (&module.dirty_shutdown_count, dirty_shutdown_count); -stl_le_p (&module.corrected_volatile_error_count, corrected_volatile_error_count); -stl_le_p (&module.corrected_persistent_error_count, corrected_persistent_error_count); +stl_le_p (&module.corrected_volatile_error_count, + corrected_volatile_error_count); +stl_le_p (&module.corrected_persistent_error_count, + corrected_persist_error_count);if (cxl_event_insert (cxlds, enc_log, (CXLEventRecordRaw *)&module)) {cxl_event_irq_assert (ct3d);
hw/mem/cxl_type3_stubs.c +3 -2
@@ -23,7 +23,8 @@ void qmp_cxl_inject_dram_event(const char *path, CxlEventLog log, uint8_t flags, bool has_bank, uint8_t bank, bool has_row, uint32_t row, bool has_column, uint16_t column, - bool has_correction_mask, uint64List *correction_mask, + bool has_correction_mask, + uint64List *correction_mask, Error **errp) {} void qmp_cxl_inject_memory_module_event(const char *path, CxlEventLog log,
@@ -35,7 +36,7 @@ void qmp_cxl_inject_memory_module_event(const char *path, CxlEventLog log,int16_t temperature, uint32_t dirty_shutdown_count, uint32_t corrected_volatile_error_count, - uint32_t corrected_persistent_error_count, + uint32_t corrected_persist_error_count, Error **errp) {} void qmp_cxl_inject_poison(const char *path, uint64_t start, uint64_t length,
Signature · 1 line
2.39.2
Re: [PATCH 4/4] hw/cxl: Line length reductions
Quoted 4 lines · Jonathan Cameron via
Michael Tsirkin observed that there were some unnecessarily long lines in the CXL code in a recent review. This patch is intended to rectify that where it does not hurt readability.
This whole series can be picked up into trivial-patches tree (whcih is getting ready to be pushed to master).
/mjt
Re: [PATCH 4/4] hw/cxl: Line length reductions
Quoted 10 lines · On Thu, 14 Sep 2023 15:57:55 +0300 Michael Tokarev <[email protected]> wrote:
Quoted 4 lines · Jonathan Cameron via
Michael Tsirkin observed that there were some unnecessarily long lines in the CXL code in a recent review. This patch is intended to rectify that where it does not hurt readability.
Reviewed-by Michael Tokarev <[email protected]>This whole series can be picked up into trivial-patches tree (whcih is getting ready to be pushed to master).
I've reworked patch 2 as you made some good points about the changes making unclear code even more unclear.
Also, I have this on top of a series that touches the same bit of code. For me landing that is more important than this, hence the ordering of the series.
Hopefully Michael Tsirkin will pick up v2 along with the other series, or whcih can take this in the future once the dependency is in place.
Jonathan
Quoted 4 lines
/mjt
Re: [PATCH 4/4] hw/cxl: Line length reductions
Quoted 17 lines · On Fri, 15 Sep 2023 18:01:30 +0100 Jonathan Cameron via…
Quoted 10 lines · On Thu, 14 Sep 2023 15:57:55 +0300 Michael Tokarev <[email protected]> wrote:
Quoted 4 lines · Jonathan Cameron via
Michael Tsirkin observed that there were some unnecessarily long lines in the CXL code in a recent review. This patch is intended to rectify that where it does not hurt readability.
Reviewed-by Michael Tokarev <[email protected]>This whole series can be picked up into trivial-patches tree (whcih is getting ready to be pushed to master).
I've reworked patch 2 as you made some good points about the changes making unclear code even more unclear.
Quoted 7 lines
Also, I have this on top of a series that touches the same bit of code. For me landing that is more important than this, hence the ordering of the series.
Hopefully Michael Tsirkin will pick up v2 along with the other series, or whcih can take this in the future once the dependency is in place.
You that is. I briefly imagined there was someone using the tag whcih :)
Friday evening is my excuse...
Too much code review today it seems.
Jonathan
Quoted 11 lines
Jonathan
Quoted 4 lines
/mjt