hw/cxl: Minor CXL emulation fixes and cleanup
cover hw/cxl: Minor CXL emulation fixes and cleanup
A small set gathering patches that have been posted and reviewed on list over the last few months. Looking to get these upstream before making any significant changes to the CXL emulation for this cycle.
More wide spread cleanup will follow later this cycle (reference updates to available spec and line length improvements).
Dave Jiang (1):
hw/pci-bridge/cxl_upstream: Fix bandwidth entry base unit for SSLBIS
Fan Ni (1):
hw/cxl/cxl_device: Replace magic number in CXLError definition
Li Zhijian (2):
hw/cxl: Fix CFMW config memory leak
docs/cxl: Change to lowercase as others
docs/system/devices/cxl.rst | 8 ++++---- include/hw/cxl/cxl_device.h | 2 +- hw/cxl/cxl-host.c | 12 ++++++------ hw/pci-bridge/cxl_upstream.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/4 hw/cxl: Fix CFMW config memory leak
From: Li Zhijian <[email protected]>
Allocate targets and targets[n] resources when all sanity checks are passed to avoid memory leaks.
--- hw/cxl/cxl-host.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
hw/cxl/cxl-host.c +6 -6
@@ -39,12 +39,6 @@ static void cxl_fixed_memory_window_config(CXLState *cxl_state,return ; } - fw->targets =g_malloc0_n (fw->num_targets,sizeof (*fw->targets)); -for (i =0 , target = object->targets; target; i++, target = target->next) { -/* This link cannot be resolved yet, so stash the name for now */ - fw->targets[i] =g_strdup (target->value); - } -if (object->size % (256 * MiB)) {error_setg (errp,"Size of a CXL fixed memory window must be a multiple of 256MiB" );
@@ -64,6 +58,12 @@ static void cxl_fixed_memory_window_config(CXLState *cxl_state, fw->enc_int_gran =0 ; } + fw->targets =g_malloc0_n (fw->num_targets,sizeof (*fw->targets)); +for (i =0 , target = object->targets; target; i++, target = target->next) { +/* This link cannot be resolved yet, so stash the name for now */ + fw->targets[i] =g_strdup (target->value); + } + cxl_state->fixed_windows =g_list_append (cxl_state->fixed_windows,g_steal_pointer (&fw));
Signature · 1 line
2.39.2
Re: [PATCH 1/4] hw/cxl: Fix CFMW config memory leak
Quoted 9 lines · Jonathan Cameron
From: Li Zhijian <[email protected]>
Allocate targets and targets[n] resources when all sanity checks are passed to avoid memory leaks.
Suggested-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Li Zhijian <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>
Quoted 37 lines
--- hw/cxl/cxl-host.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)hw/cxl/cxl-host.c +6
-6@@ -39,12 +39,6 @@ static void cxl_fixed_memory_window_config(CXLState *cxl_state,return ; } - fw->targets =g_malloc0_n (fw->num_targets,sizeof (*fw->targets)); -for (i =0 , target = object->targets; target; i++, target = target->next) { -/* This link cannot be resolved yet, so stash the name for now */ - fw->targets[i] =g_strdup (target->value); - } -if (object->size % (256 * MiB)) {error_setg (errp,"Size of a CXL fixed memory window must be a multiple of 256MiB" );@@ -64,6 +58,12 @@ static void cxl_fixed_memory_window_config(CXLState *cxl_state, fw->enc_int_gran =0 ; } + fw->targets =g_malloc0_n (fw->num_targets,sizeof (*fw->targets)); +for (i =0 , target = object->targets; target; i++, target = target->next) { +/* This link cannot be resolved yet, so stash the name for now */ + fw->targets[i] =g_strdup (target->value); + } + cxl_state->fixed_windows =g_list_append (cxl_state->fixed_windows,g_steal_pointer (&fw));Signature · 1 line
2.39.2
Re: [PATCH 1/4] hw/cxl: Fix CFMW config memory leak
In reply to Jonathan Cameron04.09.2023 16:28, Jonathan Cameron via:
Quoted 5 lines
From: Li Zhijian <[email protected]>
Allocate targets and targets[n] resources when all sanity checks are passed to avoid memory leaks.
Quoted 7 lines
Suggested-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Li Zhijian <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>--- hw/cxl/cxl-host.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
This one has been Cc'd qemu-stable, adding the tag.
/mjt
PATCH 2/4 hw/pci-bridge/cxl_upstream: Fix bandwidth entry base unit for SSLBIS
In reply to Jonathan CameronFrom: Dave Jiang <[email protected]>
According to ACPI spec 6.5 5.2.28.4 System Locality Latency and Bandwidth Information Structure, if the "Entry Base Unit" is 1024 for BW and the matrix entry has the value of 100, the BW is 100 GB/s. So the entry_base_unit should be changed from 1000 to 1024 given the comment notes it's 16GB/s for .latency_bandwidth.
--- hw/pci-bridge/cxl_upstream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci-bridge/cxl_upstream.c +1 -1
@@ -262,7 +262,7 @@ static int build_cdat_table(CDATSubHeader ***cdat_table, void *priv) .length = sslbis_size, }, .data_type = HMATLB_DATA_TYPE_ACCESS_BANDWIDTH, - .entry_base_unit = 1000, + .entry_base_unit = 1024, }, };
Signature · 1 line
2.39.2
Re: [PATCH 2/4] hw/pci-bridge/cxl_upstream: Fix bandwidth entry base unit for SSLBIS
Quoted 8 lines · Jonathan Cameron
From: Dave Jiang <[email protected]>
According to ACPI spec 6.5 5.2.28.4 System Locality Latency and Bandwidth Information Structure, if the "Entry Base Unit" is 1024 for BW and the matrix entry has the value of 100, the BW is 100 GB/s. So the
entry_base_unitshould be changed from 1000 to 1024 given the comment notes it's 16GB/s for .latency_bandwidth.
Quoted 6 lines
Fixes 882877fc359d ("hw/pci-bridge/cxl-upstream: Add a CDAT table access DOE")Signed-off-by Dave Jiang <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>--- hw/pci-bridge/cxl_upstream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Re: [PATCH 2/4] hw/pci-bridge/cxl_upstream: Fix bandwidth entry base unit for SSLBIS
In reply to Jonathan CameronQuoted 11 lines · Jonathan Cameron
From: Dave Jiang <[email protected]>
According to ACPI spec 6.5 5.2.28.4 System Locality Latency and Bandwidth Information Structure, if the "Entry Base Unit" is 1024 for BW and the matrix entry has the value of 100, the BW is 100 GB/s. So the
entry_base_unitshould be changed from 1000 to 1024 given the comment notes it's 16GB/s for .latency_bandwidth.Fixes 882877fc359d ("hw/pci-bridge/cxl-upstream: Add a CDAT table access DOE")Signed-off-by Dave Jiang <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>
Quoted 20 lines
--- hw/pci-bridge/cxl_upstream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/pci-bridge/cxl_upstream.c +1
-1@@ -262,7 +262,7 @@ static int build_cdat_table(CDATSubHeader ***cdat_table, void *priv) .length = sslbis_size, }, .data_type = HMATLB_DATA_TYPE_ACCESS_BANDWIDTH, - .entry_base_unit = 1000, + .entry_base_unit = 1024, }, };Signature · 1 line
2.39.2
Re: [PATCH 2/4] hw/pci-bridge/cxl_upstream: Fix bandwidth entry base unit for SSLBIS
In reply to Jonathan Cameron04.09.2023 16:28, Jonathan Cameron:
Quoted 20 lines
From: Dave Jiang <[email protected]>
According to ACPI spec 6.5 5.2.28.4 System Locality Latency and Bandwidth Information Structure, if the "Entry Base Unit" is 1024 for BW and the matrix entry has the value of 100, the BW is 100 GB/s. So the
entry_base_unitshould be changed from 1000 to 1024 given the comment notes it's 16GB/s for .latency_bandwidth.Fixes 882877fc359d ("hw/pci-bridge/cxl-upstream: Add a CDAT table access DOE")Signed-off-by Dave Jiang <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>--- hw/pci-bridge/cxl_upstream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/pci-bridge/cxl_upstream.c +0
-0
hw/pci-bridge/cxl_upstream.c static int build_cdat_table(CDATSubHeader ***cdat_table, void *priv) · line 267
Quoted 7 lines
hw/pci-bridge/cxl_upstream.c +1
-1@@ -262,7 +262,7 @@ static int build_cdat_table(CDATSubHeader ***cdat_table, void *priv) .length = sslbis_size, }, .data_type = HMATLB_DATA_TYPE_ACCESS_BANDWIDTH, - .entry_base_unit = 1000, + .entry_base_unit = 1024, }, };
BTW, is this one stable-worthly? How it's been found, - due to some real issue or just by code review?
Thanks,
/mjt
Re: [PATCH 2/4] hw/pci-bridge/cxl_upstream: Fix bandwidth entry base unit for SSLBIS
Quoted 16 lines · Michael Tokarev
04.09.2023 16:28, Jonathan Cameron:
Quoted 15 lines
From: Dave Jiang <[email protected]>
According to ACPI spec 6.5 5.2.28.4 System Locality Latency and Bandwidth Information Structure, if the "Entry Base Unit" is 1024 for BW and the matrix entry has the value of 100, the BW is 100 GB/s. So the
entry_base_unitshould be changed from 1000 to 1024 given the comment notes it's 16GB/s for .latency_bandwidth.Fixes 882877fc359d ("hw/pci-bridge/cxl-upstream: Add a CDAT table access DOE")Signed-off-by Dave Jiang <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>---
hw/pci-bridge/cxl_upstream.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
hw/pci-bridge/cxl_upstream.c static int build_cdat_table(CDATSubHeader ***cdat_table, void *priv) · line 267
Quoted 12 lines
hw/pci-bridge/cxl_upstream.c +1
-1@@ -262,7 +262,7 @@ static int build_cdat_table(CDATSubHeader ***cdat_table, void *priv) .length = sslbis_size, }, .data_type = HMATLB_DATA_TYPE_ACCESS_BANDWIDTH, - .entry_base_unit = 1000, + .entry_base_unit = 1024, }, };BTW, is this one stable-worthly? How it's been found, - due to some real issue or just by code review?
Code review. I was doing CXL CDAT parsing. So I guess I'm the first user. It's small enough that it won't make much of a difference for the resulting computed data. Mostly just correctness fixing.
Quoted 6 lines
Thanks,
/mjt
PATCH 3/4 hw/cxl/cxl_device: Replace magic number in CXLError definition
In reply to Jonathan CameronFrom: Fan Ni <[email protected]>
Replace the magic number 32 with CXL_RAS_ERR_HEADER_NUM for better code readability and maintainability.
--- include/hw/cxl/cxl_device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/cxl/cxl_device.h +1 -1
@@ -300,7 +300,7 @@ REG64(CXL_MEM_DEV_STS, 0)typedef struct CXLError {QTAILQ_ENTRY (CXLError) node;int type;/* Error code as per FE definition */ -uint32_t header[32 ]; +uint32_t header[CXL_RAS_ERR_HEADER_NUM ]; }CXLError ; typedef QTAILQ_HEAD(, CXLError) CXLErrorList;
Signature · 1 line
2.39.2
Re: [PATCH 3/4] hw/cxl/cxl_device: Replace magic number in CXLError definition
Quoted 4 lines · Jonathan Cameron
From: Fan Ni <[email protected]>
Replace the magic number 32 with
CXL_RAS_ERR_HEADER_NUMfor better code readability and maintainability.
Thanks :)
Quoted 7 lines
Signed-off-by Fan Ni <[email protected]>Reviewed-by Davidlohr Bueso <[email protected]>Reviewed-by Dave Jiang <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>--- include/hw/cxl/cxl_device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH 4/4 docs/cxl: Change to lowercase as others
In reply to Jonathan CameronFrom: Li Zhijian <[email protected]>
Using the same style as elsewhere for topology / topo
--- docs/system/devices/cxl.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
docs/system/devices/cxl.rst +4 -4
@@ -157,7 +157,7 @@ responsible for allocating appropriate ranges from within the CFMWs and exposing those via normal memory configurations as would be done for system RAM. -Example system Topology. x marks the match in each decoder level:: +Example system topology. x marks the match in each decoder level:: |<------------------SYSTEM PHYSICAL ADDRESS MAP (1)----------------->| | __________ __________________________________ __________ |
@@ -187,8 +187,8 @@ Example system Topology. x marks the match in each decoder level:: ___________|___ __________|__ __|_________ ___|_________ (3)| Root Port 0 | | Root Port 1 | | Root Port 2| | Root Port 3 | | Appears in | | Appears in | | Appears in | | Appear in | - | PCI topology | | PCI Topology| | PCI Topo | | PCI Topo | - | As 0c:00.0 | | as 0c:01.0 | | as de:00.0 | | as de:01.0 | + | PCI topology | | PCI topology| | PCI topo | | PCI topo | + | as 0c:00.0 | | as 0c:01.0 | | as de:00.0 | | as de:01.0 | |_______________| |_____________| |____________| |_____________| | | | | | | | |
@@ -272,7 +272,7 @@ Example topology involving a switch:: | Root Port 0 | | Appears in | | PCI topology | - | As 0c:00.0 | + | as 0c:00.0 | |___________x___| | |
Signature · 1 line
2.39.2
Re: [PATCH 4/4] docs/cxl: Change to lowercase as others
Quoted 10 lines · Jonathan Cameron
From: Li Zhijian <[email protected]>
Using the same style as elsewhere for topology / topo
Signed-off-by Li Zhijian <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>--- docs/system/devices/cxl.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Re: [PATCH 4/4] docs/cxl: Change to lowercase as others
In reply to Jonathan CameronQuoted 8 lines · Jonathan Cameron
From: Li Zhijian <[email protected]>
Using the same style as elsewhere for topology / topo
Signed-off-by Li Zhijian <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>---
Quoted 39 lines
docs/system/devices/cxl.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)docs/system/devices/cxl.rst +4
-4@@ -157,7 +157,7 @@ responsible for allocating appropriate ranges from within the CFMWs and exposing those via normal memory configurations as would be done for system RAM. -Example system Topology. x marks the match in each decoder level:: +Example system topology. x marks the match in each decoder level:: |<------------------SYSTEM PHYSICAL ADDRESS MAP (1)----------------->| | __________ __________________________________ __________ |@@ -187,8 +187,8 @@ Example system Topology. x marks the match in each decoder level:: ___________|___ __________|__ __|_________ ___|_________ (3)| Root Port 0 | | Root Port 1 | | Root Port 2| | Root Port 3 | | Appears in | | Appears in | | Appears in | | Appear in | - | PCI topology | | PCI Topology| | PCI Topo | | PCI Topo | - | As 0c:00.0 | | as 0c:01.0 | | as de:00.0 | | as de:01.0 | + | PCI topology | | PCI topology| | PCI topo | | PCI topo | + | as 0c:00.0 | | as 0c:01.0 | | as de:00.0 | | as de:01.0 | |_______________| |_____________| |____________| |_____________| | | | | | | | |@@ -272,7 +272,7 @@ Example topology involving a switch:: | Root Port 0 | | Appears in | | PCI topology | - | As 0c:00.0 | + | as 0c:00.0 | |___________x___| | |Signature · 1 line
2.39.2
Cc'ing qemu-trivial@
Quoted 23 lines · Jonathan Cameron
A small set gathering patches that have been posted and reviewed on list over the last few months. Looking to get these upstream before making any significant changes to the CXL emulation for this cycle.
More wide spread cleanup will follow later this cycle (reference updates to available spec and line length improvements).
Dave Jiang (1):
hw/pci-bridge/cxl_upstream: Fix bandwidth entry base unit for SSLBISFan Ni (1):
hw/cxl/cxl_device: Replace magic number in CXLError definitionLi Zhijian (2):
hw/cxl: Fix CFMW config memory leak
docs/cxl: Change to lowercase as othersdocs/system/devices/cxl.rst | 8 ++++---- include/hw/cxl/cxl_device.h | 2 +- hw/cxl/cxl-host.c | 12 ++++++------ hw/pci-bridge/cxl_upstream.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-)
Michael Tokarev
AppliedQuoted 17 lines · Jonathan Cameron via
A small set gathering patches that have been posted and reviewed on list over the last few months. Looking to get these upstream before making any significant changes to the CXL emulation for this cycle.
More wide spread cleanup will follow later this cycle (reference updates to available spec and line length improvements).
Dave Jiang (1):
hw/pci-bridge/cxl_upstream: Fix bandwidth entry base unit for SSLBISFan Ni (1):
hw/cxl/cxl_device: Replace magic number in CXLError definitionLi Zhijian (2):
hw/cxl: Fix CFMW config memory leak
docs/cxl: Change to lowercase as others
Quoted 6 lines
docs/system/devices/cxl.rst | 8 ++++---- include/hw/cxl/cxl_device.h | 2 +- hw/cxl/cxl-host.c | 12 ++++++------ hw/pci-bridge/cxl_upstream.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-)
Applied to my trivial-patches tree. Thank you!
/mjt