@@ -75,7 +75,8 @@ include::bus-option.txt[]
-t::
--type=::
- Specify the region type - 'pmem' or 'ram'. Defaults to 'pmem'.
+ Specify the region type - 'pmem' or 'ram'. Default to root decoder
+ capability, and if that is ambiguous, default to 'pmem'.
-U::
--uuid=::
@@ -444,6 +444,22 @@ static int validate_decoder(struct cxl_decoder *decoder,
return 0;
}
+static void set_type_from_decoder(struct cxl_ctx *ctx, struct parsed_params *p)
+{
+ /* if param.type was explicitly specified, nothing to do here */
+ if (param.type)
+ return;
+
+ /*
+ * default to pmem if both types are set, otherwise the single
+ * capability dominates.
+ */
+ if (cxl_decoder_is_volatile_capable(p->root_decoder))
+ p->mode = CXL_DECODER_MODE_RAM;
+ if (cxl_decoder_is_pmem_capable(p->root_decoder))
+ p->mode = CXL_DECODER_MODE_PMEM;
+}
+
static int create_region_validate_config(struct cxl_ctx *ctx,
struct parsed_params *p)
{
@@ -477,6 +493,8 @@ found:
return -ENXIO;
}
+ set_type_from_decoder(ctx, p);
+
rc = validate_decoder(p->root_decoder, p);
if (rc)
return rc;