projects/linux·commit 1cd8a253

cxl/hdm: Fix skip allocations vs multiple pmem allocations

1cd8a253 · Dan Williams <[email protected]> · 2022-08-05 15:12:27 -07:00

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: cf880423b6a0 ("cxl/hdm: Add support for allocating DPA to an endpoint decoder")
Reported-by: Vishal Verma <[email protected]>
Tested-by: Vishal Verma <[email protected]>
Reviewed-by: Ira Weiny <[email protected]>
Link: https://lore.kernel.org/r/165973754730.1558392.15466392461645857658.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Dan Williams <[email protected]>
Commit
1cd8a2537eb07751d405ab7e2223f20338a90506
Parents
4d8e4ea5

Changes

1 files changed · +10 −1

FileStatusAddDelContent
drivers/cxl/core/hdm.cmodified+10−1View file

drivers/cxl/core/hdm.c

View file
diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
index e096f74..d1d2cae 100644
--- a/drivers/cxl/core/hdm.c
+++ b/drivers/cxl/core/hdm.c
@@ -445,7 +445,16 @@ int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size)
start = free_pmem_start;
avail = cxlds->pmem_res.end - start + 1;
skip_start = free_ram_start;
- skip_end = start - 1;
+
+ /*
+ * If some pmem is already allocated, then that allocation
+ * already handled the skip.
+ */
+ if (cxlds->pmem_res.child &&
+ skip_start == cxlds->pmem_res.child->start)
+ skip_end = skip_start - 1;
+ else
+ skip_end = start - 1;
skip = skip_end - skip_start + 1;
} else {
dev_dbg(dev, "mode not set\n");