On Sun, Nov 06, 2022 at 03:48:01PM -0800, Dan Williams wrote:
> Allow for:
> 
>    cxl create-region -d decoderX.Y
> 
> ...to assume (-m -w $(count of memdevs beneath decoderX.Y))

I'm not understanding what the change is here. Poked around a bit
and still didn't get it. Help!

Leaving out the -m leads to this:
$ cxl create-region -d decoder3.3 mem0 mem1
cxl region: parse_create_options: must specify option for target object types 
(-m)
cxl region: cmd_create_region: created 0 regions

Leaving out the the -m and the memdevs fails because the memdev order is
not correct. 
$ cxl create-region -d decoder3.3
cxl region: create_region: region5: failed to set target0 to mem1
cxl region: cmd_create_region: created 0 regions

This still works, where I give the -m and the correct order of memdevs.
cxl create-region -m -d decoder3.3 mem0 mem1

> 
> Signed-off-by: Dan Williams <[email protected]>
> ---
>  cxl/region.c |   16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/cxl/region.c b/cxl/region.c
> index aa0735194fa1..c0cf4ab350da 100644
> --- a/cxl/region.c
> +++ b/cxl/region.c
> @@ -227,10 +227,13 @@ static int parse_create_options(struct cxl_ctx *ctx, 
> int count,
>       }
>  
>       /*
> -      * For all practical purposes, -m is the default target type, but
> -      * hold off on actively making that decision until a second target
> -      * option is available.
> +      * For all practical purposes, -m is the default target type, but hold
> +      * off on actively making that decision until a second target option is
> +      * available. Unless there are no arguments then just assume memdevs.
>        */
> +     if (!count)
> +             param.memdevs = true;
> +
>       if (!param.memdevs) {
>               log_err(&rl,
>                       "must specify option for target object types (-m)\n");
> @@ -272,11 +275,8 @@ static int parse_create_options(struct cxl_ctx *ctx, int 
> count,
>               p->ways = count;
>               if (!validate_ways(p, count))
>                       return -EINVAL;
> -     } else {
> -             log_err(&rl,
> -                     "couldn't determine interleave ways from options or 
> arguments\n");
> -             return -EINVAL;
> -     }
> +     } else
> +             p->ways = p->num_memdevs;
>  
>       if (param.granularity < INT_MAX) {
>               if (param.granularity <= 0) {
> 

Reply via email to