From: Dan Williams <dan.j.williams@intel.com>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Dan Williams <dan.j.williams@intel.com>
Cc: <linux-cxl@vger.kernel.org>, Ira Weiny <ira.weiny@intel.com>,
"Alejandro Lucero" <alucerop@amd.com>,
Dave Jiang <dave.jiang@intel.com>
Subject: Re: [PATCH v3 5/6] cxl: Kill enum cxl_decoder_mode
Date: Tue, 4 Feb 2025 10:57:29 -0800 [thread overview]
Message-ID: <67a26319e928c_2d2c294da@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <20250204122338.0000284b@huawei.com>
Jonathan Cameron wrote:
> On Mon, 03 Feb 2025 20:24:29 -0800
> Dan Williams <dan.j.williams@intel.com> wrote:
>
> > Now that the operational mode of DPA capacity (ram vs pmem... etc) is
> > tracked in the partition, and no code paths have dependencies on the
> > mode implying the partition index, the ambiguous 'enum cxl_decoder_mode'
> > can be cleaned up, specifically this ambiguity on whether the operation
> > mode implied anything about the partition order.
> >
> > Endpoint decoders simply reference their assigned partition where the
> > operational mode can be retrieved as partition mode.
> >
> > With this in place PMEM can now be partition0 which happens today when
> > the RAM capacity size is zero. Dynamic RAM can appear above PMEM when
> > DCD arrives, etc. Code sequences that hard coded the "PMEM after RAM"
> > assumption can now just iterate partitions and consult the partition
> > mode after the fact.
> >
> > Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> > Reviewed-by: Alejandro Lucero <alucerop@amd.com>
> > Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> > Signed-off-by: Dan Williams <dan.j.williams@intel.com>
>
> One trivial equality check inline to tidy up otherwise nice.
>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
[..]
> > diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
> > index 78ecb88bad7e..d705dec1471e 100644
> > --- a/drivers/cxl/core/hdm.c
> > +++ b/drivers/cxl/core/hdm.c
> > @@ -359,7 +359,6 @@ static int __cxl_dpa_reserve(struct cxl_endpoint_decoder *cxled,
>
> > -int cxl_dpa_set_mode(struct cxl_endpoint_decoder *cxled,
> > - enum cxl_decoder_mode mode)
> > +int cxl_dpa_set_part(struct cxl_endpoint_decoder *cxled,
> > + enum cxl_partition_mode mode)
> > {
> > struct cxl_memdev *cxlmd = cxled_to_memdev(cxled);
> > struct cxl_dev_state *cxlds = cxlmd->cxlds;
> > struct device *dev = &cxled->cxld.dev;
> > -
> > - switch (mode) {
> > - case CXL_DECODER_RAM:
> > - case CXL_DECODER_PMEM:
> > - break;
> > - default:
> > - dev_dbg(dev, "unsupported mode: %d\n", mode);
> > - return -EINVAL;
> > - }
> > + int part;
> >
> > guard(rwsem_write)(&cxl_dpa_rwsem);
> > if (cxled->cxld.flags & CXL_DECODER_F_ENABLE)
> > return -EBUSY;
> >
> > - /*
> > - * Only allow modes that are supported by the current partition
> > - * configuration
> > - */
> > - if (mode == CXL_DECODER_PMEM && !cxl_pmem_size(cxlds)) {
> > - dev_dbg(dev, "no available pmem capacity\n");
> > - return -ENXIO;
> > + for (part = 0; part < cxlds->nr_partitions; part++)
> > + if (cxlds->part[part].mode == mode)
> > + break;
> > +
> > + if (part >= cxlds->nr_partitions) {
>
> How would it be greater?
It would never be greater in this context, this is just a personal
coding style preference for ">=" identifying the opposite set of numbers
from "<" rather than "==".
next prev parent reply other threads:[~2025-02-04 18:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-04 4:24 [PATCH v3 0/6] cxl: DPA partition metadata is a mess Dan Williams
2025-02-04 4:24 ` [PATCH v3 1/6] cxl: Remove the CXL_DECODER_MIXED mistake Dan Williams
2025-02-04 17:42 ` Fan Ni
2025-02-04 4:24 ` [PATCH v3 2/6] cxl: Introduce to_{ram,pmem}_{res,perf}() helpers Dan Williams
2025-02-04 11:30 ` Jonathan Cameron
2025-02-04 17:50 ` Fan Ni
2025-02-04 4:24 ` [PATCH v3 3/6] cxl: Introduce 'struct cxl_dpa_partition' and 'struct cxl_range_info' Dan Williams
2025-02-04 11:50 ` Jonathan Cameron
2025-02-04 18:50 ` Dan Williams
2025-02-04 4:24 ` [PATCH v3 4/6] cxl: Make cxl_dpa_alloc() DPA partition number agnostic Dan Williams
2025-02-04 12:13 ` Jonathan Cameron
2025-02-04 4:24 ` [PATCH v3 5/6] cxl: Kill enum cxl_decoder_mode Dan Williams
2025-02-04 12:23 ` Jonathan Cameron
2025-02-04 18:57 ` Dan Williams [this message]
2025-02-04 4:24 ` [PATCH v3 6/6] cxl: Cleanup partition size and perf helpers Dan Williams
2025-02-04 12:32 ` Jonathan Cameron
2025-02-04 20:52 ` Ira Weiny
2025-02-04 10:42 ` [PATCH v3 0/6] cxl: DPA partition metadata is a mess Alejandro Lucero Palau
2025-02-04 21:33 ` Dave Jiang
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=67a26319e928c_2d2c294da@dwillia2-xfh.jf.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=alucerop@amd.com \
--cc=dave.jiang@intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
/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