qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC] cxl-host: Fix committed check for passthrough decoder


From: Fan Ni
Subject: [RFC] cxl-host: Fix committed check for passthrough decoder
Date: Fri, 13 Jan 2023 00:27:55 +0000

For passthrough decoder (a decoder hosted by a cxl component with only
one downstream port), its cache_mem_registers field COMMITTED
(see spec 2.0 8.2.5.12 - CXL HDM Decoder Capability Structure) will not
be set by the current Linux CXL driver. Without the fix, for a cxl
topology setup with a single HB and single root port, the memdev read/write
requests cannot be passed to the device successfully as the function
cxl_hdm_find_target will fail the decoder COMMITTED check and return
directly, which causes read/write not being directed to cxl type3 device.

Before the fix, a segfault is observed when trying using cxl memory for
htop command through 'numactl --membind' after converting cxl memory
into normal RAM.

Detailed steps to reproduce the issue with the cxl setup where there is
only one HB and a memdev is directly attached to the only root port of
the HB are listed as below,
1. cxl create-region region0
2. ndctl create-namespace -m dax -r region0
3. daxctl reconfigure-device --mode=system-ram --no-online dax0.0
4. daxctl online-memory dax0.0
5. numactl --membind=1 htop

Signed-off-by: Fan Ni <fan.ni@samsung.com>
---
 hw/cxl/cxl-host.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c
index 1adf61231a..5ca0d6fd8f 100644
--- a/hw/cxl/cxl-host.c
+++ b/hw/cxl/cxl-host.c
@@ -107,8 +107,11 @@ static bool cxl_hdm_find_target(uint32_t *cache_mem, 
hwaddr addr,
     uint32_t target_idx;
 
     ctrl = cache_mem[R_CXL_HDM_DECODER0_CTRL];
-    if (!FIELD_EX32(ctrl, CXL_HDM_DECODER0_CTRL, COMMITTED)) {
-        return false;
+
+    /* skip the check for passthrough decoder */
+       if (FIELD_EX32(ctrl, CXL_HDM_DECODER0_CTRL, COMMIT)
+               && !FIELD_EX32(ctrl, CXL_HDM_DECODER0_CTRL, COMMITTED)) {
+               return false;
     }
 
     ig_enc = FIELD_EX32(ctrl, CXL_HDM_DECODER0_CTRL, IG);
-- 
2.25.1



reply via email to

[Prev in Thread] Current Thread [Next in Thread]