Re: [PATCH 14/26] cxl/region: Read existing extents on region creation

From: Ira Weiny
Date: Wed Apr 10 2024 - 01:46:58 EST


fan wrote:
> On Sun, Mar 24, 2024 at 04:18:17PM -0700, ira.weiny@xxxxxxxxx wrote:
> > From: Navneet Singh <navneet.singh@xxxxxxxxx>
> >

[snip]

> > diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
> > index 58b31fa47b93..9e33a0976828 100644
> > --- a/drivers/cxl/core/mbox.c
> > +++ b/drivers/cxl/core/mbox.c
> > @@ -870,6 +870,53 @@ int cxl_enumerate_cmds(struct cxl_memdev_state *mds)
> > }
> > EXPORT_SYMBOL_NS_GPL(cxl_enumerate_cmds, CXL);
> >
> > +static int cxl_validate_extent(struct cxl_memdev_state *mds,
> > + struct cxl_dc_extent *dc_extent)
> > +{
> > + struct device *dev = mds->cxlds.dev;
> > + uint64_t start, len;
> > +
> > + start = le64_to_cpu(dc_extent->start_dpa);
> > + len = le64_to_cpu(dc_extent->length);
> > +
> > + /* Extents must not cross region boundary's */
> > + for (int i = 0; i < mds->nr_dc_region; i++) {
> > + struct cxl_dc_region_info *dcr = &mds->dc_region[i];
> > +
> > + if (dcr->base <= start &&
> > + (start + len) <= (dcr->base + dcr->decode_len)) {
>
> Why not use range_contains here as below?

Because when I initially wrote this I (or perhaps Navneet, I can't remember) we
were not using ranges. This version I tried to convert to ranges and I missed
this one.

Good catch!

Ira