[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 11/12] hw/cxl/cxl-mailbox-utils: Add superset extent release m
From: |
nifan . cxl |
Subject: |
[PATCH v6 11/12] hw/cxl/cxl-mailbox-utils: Add superset extent release mailbox support |
Date: |
Mon, 25 Mar 2024 12:02:29 -0700 |
From: Fan Ni <fan.ni@samsung.com>
With the change, we extend the extent release mailbox command processing
to allow more flexible release. As long as the DPA range of the extent to
release is covered by accepted extent(s) in the device, the release can be
performed.
Signed-off-by: Fan Ni <fan.ni@samsung.com>
---
hw/cxl/cxl-mailbox-utils.c | 41 ++++++++++++++++++++++----------------
1 file changed, 24 insertions(+), 17 deletions(-)
diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
index a0d2239176..3b7949c364 100644
--- a/hw/cxl/cxl-mailbox-utils.c
+++ b/hw/cxl/cxl-mailbox-utils.c
@@ -1674,6 +1674,12 @@ static CXLRetCode
cxl_dc_extent_release_dry_run(CXLType3Dev *ct3d,
dpa = in->updated_entries[i].start_dpa;
len = in->updated_entries[i].len;
+ /* Check if the DPA range is not fully backed with valid extents */
+ if (!ct3_test_region_block_backed(ct3d, dpa, len)) {
+ ret = CXL_MBOX_INVALID_PA;
+ goto free_and_exit;
+ }
+ /* After this point, extent overflow is the only error can happen */
while (len > 0) {
QTAILQ_FOREACH(ent, &tmp_list, node) {
range_init_nofail(&range, ent->start_dpa, ent->len);
@@ -1713,25 +1719,27 @@ static CXLRetCode
cxl_dc_extent_release_dry_run(CXLType3Dev *ct3d,
goto free_and_exit;
}
} else {
- /*
- * TODO: we reject the attempt to remove an extent
- * that overlaps with multiple extents in the device
- * for now, we will allow it once superset release
- * support is added.
- */
- ret = CXL_MBOX_INVALID_PA;
- goto free_and_exit;
+ len1 = dpa - ent_start_dpa;
+ len2 = 0;
+ len_done = ent_len - len1 - len2;
+
+ cxl_remove_extent_from_extent_list(&tmp_list, ent);
+ cnt_delta--;
+ if (len1) {
+ cxl_insert_extent_to_extent_list(&tmp_list,
+ ent_start_dpa,
+ len1, NULL, 0);
+ cnt_delta++;
+ }
}
len -= len_done;
- /* len == 0 here until superset release is added */
+ if (len) {
+ dpa = ent_start_dpa + ent_len;
+ }
break;
}
}
- if (len) {
- ret = CXL_MBOX_INVALID_PA;
- goto free_and_exit;
- }
}
}
free_and_exit:
@@ -1819,10 +1827,9 @@ static CXLRetCode cmd_dcd_release_dyn_cap(const struct
cxl_cmd *cmd,
}
len -= len_done;
- /*
- * len will always be 0 until superset release is add.
- * TODO: superset release will be added.
- */
+ if (len > 0) {
+ dpa = ent_start_dpa + ent_len;
+ }
break;
}
}
--
2.43.0
- [PATCH v6 01/12] hw/cxl/cxl-mailbox-utils: Add dc_event_log_size field to output payload of identify memory device command, (continued)
- [PATCH v6 01/12] hw/cxl/cxl-mailbox-utils: Add dc_event_log_size field to output payload of identify memory device command, nifan . cxl, 2024/03/25
- [PATCH v6 02/12] hw/cxl/cxl-mailbox-utils: Add dynamic capacity region representative and mailbox command support, nifan . cxl, 2024/03/25
- [PATCH v6 03/12] include/hw/cxl/cxl_device: Rename mem_size as static_mem_size for type3 memory devices, nifan . cxl, 2024/03/25
- [PATCH v6 04/12] hw/mem/cxl_type3: Add support to create DC regions to type3 memory devices, nifan . cxl, 2024/03/25
- [PATCH v6 05/12] hw/mem/cxl-type3: Refactor ct3_build_cdat_entries_for_mr to take mr size instead of mr as argument, nifan . cxl, 2024/03/25
- [PATCH v6 06/12] hw/mem/cxl_type3: Add host backend and address space handling for DC regions, nifan . cxl, 2024/03/25
- [PATCH v6 07/12] hw/mem/cxl_type3: Add DC extent list representative and get DC extent list mailbox support, nifan . cxl, 2024/03/25
- [PATCH v6 08/12] hw/cxl/cxl-mailbox-utils: Add mailbox commands to support add/release dynamic capacity response, nifan . cxl, 2024/03/25
- [PATCH v6 09/12] hw/cxl/events: Add qmp interfaces to add/release dynamic capacity extents, nifan . cxl, 2024/03/25
- [PATCH v6 10/12] hw/mem/cxl_type3: Add dpa range validation for accesses to DC regions, nifan . cxl, 2024/03/25
- [PATCH v6 11/12] hw/cxl/cxl-mailbox-utils: Add superset extent release mailbox support,
nifan . cxl <=
- [PATCH v6 12/12] hw/mem/cxl_type3: Allow to release extent superset in QMP interface, nifan . cxl, 2024/03/25