[PATCH 3/3] cxl: update fixed window mappings on decoder programming

Li Chen posted 3 patches 2 weeks, 6 days ago
Maintainers: Jonathan Cameron <jonathan.cameron@huawei.com>, Fan Ni <fan.ni@samsung.com>
[PATCH 3/3] cxl: update fixed window mappings on decoder programming
Posted by Li Chen 2 weeks, 6 days ago
Invoke cxl_fmws_update_mappings() when HDM decoder registers are updated
on host components and Type-3 devices, so fixed memory windows can
switch between the MMIO dispatcher and the RAM alias overlay as the guest
commits/uncommits decoder state.

Signed-off-by: Li Chen <me@linux.beauty>
---
 hw/cxl/cxl-component-utils.c | 2 ++
 hw/mem/cxl_type3.c           | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/hw/cxl/cxl-component-utils.c b/hw/cxl/cxl-component-utils.c
index 07aabe331c..8a36a62db0 100644
--- a/hw/cxl/cxl-component-utils.c
+++ b/hw/cxl/cxl-component-utils.c
@@ -12,6 +12,7 @@
 #include "qapi/error.h"
 #include "hw/pci/pci.h"
 #include "hw/cxl/cxl.h"
+#include "hw/cxl/cxl_host.h"
 
 /* CXL r3.1 Section 8.2.4.20.1 CXL HDM Decoder Capability Register */
 int cxl_decoder_count_enc(int count)
@@ -209,6 +210,7 @@ static void cxl_cache_mem_write_reg(void *opaque, hwaddr offset, uint64_t value,
         if (offset >= A_CXL_HDM_DECODER_CAPABILITY &&
             offset <= A_CXL_HDM_DECODER3_TARGET_LIST_HI) {
             dumb_hdm_handler(cxl_cstate, offset, value);
+            cxl_fmws_update_mappings();
         } else if (offset == A_CXL_BI_RT_CTRL ||
                    offset == A_CXL_BI_DECODER_CTRL) {
             bi_handler(cxl_cstate, offset, value);
diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c
index bf79db6082..8ad36e6f53 100644
--- a/hw/mem/cxl_type3.c
+++ b/hw/mem/cxl_type3.c
@@ -29,6 +29,7 @@
 #include "system/hostmem.h"
 #include "system/numa.h"
 #include "hw/cxl/cxl.h"
+#include "hw/cxl/cxl_host.h"
 #include "hw/pci/msix.h"
 
 /* type3 device private */
@@ -628,6 +629,11 @@ static void ct3d_reg_write(void *opaque, hwaddr offset, uint64_t value,
     } else if (should_uncommit) {
         hdm_decoder_uncommit(ct3d, which_hdm);
     }
+
+    if (offset >= A_CXL_HDM_DECODER_CAPABILITY &&
+        offset <= A_CXL_HDM_DECODER3_TARGET_LIST_HI) {
+        cxl_fmws_update_mappings();
+    }
 }
 
 /*
@@ -1377,6 +1383,7 @@ static void ct3d_reset(DeviceState *dev)
     cxl_component_register_init_common(reg_state, write_msk,
                                        CXL2_TYPE3_DEVICE, ct3d->hdmdb);
     cxl_device_register_init_t3(ct3d, CXL_T3_MSIX_MBOX);
+    cxl_fmws_update_mappings();
 
     /*
      * Bring up an endpoint to target with MCTP over VDM.
-- 
2.52.0