@@ -502,6 +502,7 @@ static int create_region(struct cxl_ctx *ctx, int *count,
unsigned long flags = UTIL_JSON_TARGETS;
struct json_object *jregion;
struct cxl_region *region;
+ bool default_size = true;
int i, rc, granularity;
u64 size, max_extent;
const char *devname;
@@ -513,6 +514,7 @@ static int create_region(struct cxl_ctx *ctx, int *count,
if (p->size) {
size = p->size;
+ default_size = false;
} else if (p->ep_min_size) {
size = p->ep_min_size * p->ways;
} else {
@@ -525,13 +527,16 @@ static int create_region(struct cxl_ctx *ctx, int *count,
cxl_decoder_get_devname(p->root_decoder));
return -EINVAL;
}
- if (size > max_extent) {
+ if (!default_size && size > max_extent) {
log_err(&rl,
"%s: region size %#lx exceeds max available space\n",
cxl_decoder_get_devname(p->root_decoder), size);
return -ENOSPC;
}
+ if (size > max_extent)
+ size = ALIGN_DOWN(max_extent, SZ_256M * p->ways);
+
if (p->mode == CXL_DECODER_MODE_PMEM) {
region = cxl_decoder_create_pmem_region(p->root_decoder);
if (!region) {
When a size is not specified, limit the size to either the available DPA capacity, or the max available extent in the root decoder, whichever is smaller. Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- cxl/region.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)