From: Ira Weiny <ira.weiny@intel.com>
To: "Verma, Vishal L" <vishal.l.verma@intel.com>,
"linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>,
"Weiny, Ira" <ira.weiny@intel.com>
Cc: "Williams, Dan J" <dan.j.williams@intel.com>,
"gregory.price@memverge.com" <gregory.price@memverge.com>,
"Jonathan.Cameron@huawei.com" <Jonathan.Cameron@huawei.com>,
"dave@stgolabs.net" <dave@stgolabs.net>,
"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>
Subject: Re: [PATCH ndctl 3/7] cxl: add core plumbing for creation of ram regions
Date: Wed, 8 Feb 2023 14:07:40 -0800 [thread overview]
Message-ID: <63e41d2c5512b_11f3dc2946d@iweiny-mobl.notmuch> (raw)
In-Reply-To: <544c4a34207fe45195472451730881991f541ec4.camel@intel.com>
Verma, Vishal L wrote:
> On Tue, 2023-02-07 at 19:55 -0800, Ira Weiny wrote:
> > Vishal Verma wrote:
> <..>
> > >
> > > diff --git a/cxl/region.c b/cxl/region.c
> > > index 38aa142..0945a14 100644
> > > --- a/cxl/region.c
> > > +++ b/cxl/region.c
> > > @@ -380,7 +380,22 @@ static void collect_minsize(struct cxl_ctx *ctx, struct parsed_params *p)
> > > struct json_object *jobj =
> > > json_object_array_get_idx(p->memdevs, i);
> > > struct cxl_memdev *memdev = json_object_get_userdata(jobj);
> > > - u64 size = cxl_memdev_get_pmem_size(memdev);
> > > + u64 size;
> > > +
> > > + switch(p->mode) {
> > > + case CXL_DECODER_MODE_RAM:
> > > + size = cxl_memdev_get_ram_size(memdev);
> > > + break;
> > > + case CXL_DECODER_MODE_PMEM:
> > > + size = cxl_memdev_get_pmem_size(memdev);
> > > + break;
> > > + default:
> > > + /*
> > > + * This will 'poison' ep_min_size with a 0, and
> > > + * subsequently cause the region creation to fail.
> > > + */
> > > + size = 0;
> >
> > Why not change collect_minsize() to return int and propagate the error up
> > through create_region_validate_config()?
> >
> > It seems more confusing to hide a special value in size like this.
> >
> Hm, true, though the default case should never get hit. In fact I was
> planning to leave it out entirely until gcc warned that I can't skip
> cases if switching for an enum. I think the comment is maybe misleading
> in that it makes one think that this is some special handling. It would
> probably be clearer to make size = 0 in the initial declaration, and
> make the default case a no-op (maybe with a comment that we would never
> get here). Does that sound better?
> >
To me the question is whether size == 0 is an error or just a valid size
which something at the higher level determines is an error. To me the
default case here is that mode is incorrectly set to get a valid size.
Your comment implied that as well.
Having size == 0 is ok generally as this is a 'min size'. So I will not
argue the point too much.
Ira
next prev parent reply other threads:[~2023-02-08 22:07 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-07 19:16 [PATCH ndctl 0/7] cxl: add support for listing and creating volatile regions Vishal Verma
2023-02-07 19:16 ` [PATCH ndctl 1/7] cxl/region: skip region_actions for region creation Vishal Verma
2023-02-07 22:07 ` Fan Ni
2023-02-08 0:19 ` Verma, Vishal L
2023-02-08 3:45 ` Ira Weiny
2023-02-08 5:41 ` Dan Williams
2023-02-07 19:16 ` [PATCH ndctl 2/7] cxl: add a type attribute to region listings Vishal Verma
2023-02-08 3:46 ` Ira Weiny
2023-02-08 5:47 ` Dan Williams
2023-02-08 6:10 ` Verma, Vishal L
2023-02-10 0:47 ` Fan Ni
2023-02-07 19:16 ` [PATCH ndctl 3/7] cxl: add core plumbing for creation of ram regions Vishal Verma
2023-02-08 3:55 ` Ira Weiny
2023-02-08 6:23 ` Verma, Vishal L
2023-02-08 22:07 ` Ira Weiny [this message]
2023-02-08 5:49 ` Dan Williams
2023-02-10 1:04 ` Fan Ni
2023-02-10 1:10 ` Verma, Vishal L
2023-02-10 1:15 ` Fan Ni
2023-02-07 19:16 ` [PATCH ndctl 4/7] cxl/region: accept user-supplied UUIDs for pmem regions Vishal Verma
2023-02-08 3:56 ` Ira Weiny
2023-02-08 5:51 ` Dan Williams
2023-02-07 19:16 ` [PATCH ndctl 5/7] cxl/region: determine region type based on root decoder capability Vishal Verma
2023-02-08 4:07 ` Ira Weiny
2023-02-08 6:34 ` Verma, Vishal L
2023-02-08 22:09 ` Ira Weiny
2023-02-08 5:55 ` Dan Williams
2023-02-08 6:36 ` Verma, Vishal L
2023-02-07 19:16 ` [PATCH ndctl 6/7] cxl/list: Include regions in the verbose listing Vishal Verma
2023-02-08 4:08 ` Ira Weiny
2023-02-07 19:16 ` [PATCH ndctl 7/7] cxl/list: Enumerate device-dax properties for regions Vishal Verma
2023-02-08 4:15 ` Ira Weiny
2023-02-08 6:00 ` Dan Williams
2023-02-08 6:48 ` Verma, Vishal L
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=63e41d2c5512b_11f3dc2946d@iweiny-mobl.notmuch \
--to=ira.weiny@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=dan.j.williams@intel.com \
--cc=dave@stgolabs.net \
--cc=gregory.price@memverge.com \
--cc=linux-cxl@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox