Skip to content

Commit 1cd8a25

Browse files
committed
cxl/hdm: Fix skip allocations vs multiple pmem allocations
Vishal notes that when attempting to define a second pmem region on a device the DPA allocation fails with a message of the form: decoder11.1: failed to reserve skipped space Recall that the skip setting is used when there is a pmem allocation in the presence of free ram DPA space. The first pmem allocation skips over the free ram and subsequent pmem allocations do not require a skip. The bug is that a skip is still attempted and the DPA reservation code flags the double skip allocation conflict. Fixes: cf88042 ("cxl/hdm: Add support for allocating DPA to an endpoint decoder") Reported-by: Vishal Verma <vishal.l.verma@intel.com> Tested-by: Vishal Verma <vishal.l.verma@intel.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Link: https://lore.kernel.org/r/165973754730.1558392.15466392461645857658.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 4d8e4ea commit 1cd8a25

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/cxl/core/hdm.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,16 @@ int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size)
445445
start = free_pmem_start;
446446
avail = cxlds->pmem_res.end - start + 1;
447447
skip_start = free_ram_start;
448-
skip_end = start - 1;
448+
449+
/*
450+
* If some pmem is already allocated, then that allocation
451+
* already handled the skip.
452+
*/
453+
if (cxlds->pmem_res.child &&
454+
skip_start == cxlds->pmem_res.child->start)
455+
skip_end = skip_start - 1;
456+
else
457+
skip_end = start - 1;
449458
skip = skip_end - skip_start + 1;
450459
} else {
451460
dev_dbg(dev, "mode not set\n");

0 commit comments

Comments
 (0)