Re: [PATCH v3 06/18] cxl/region: Rename function to cxl_find_decoder_early()

From: Robert Richter
Date: Wed Mar 05 2025 - 07:48:56 EST


On 14.02.25 15:58:08, Jonathan Cameron wrote:
> On Tue, 11 Feb 2025 10:53:36 +0100
> Robert Richter <rrichter@xxxxxxx> wrote:
>
> > Current function cxl_region_find_decoder() is used to find a port's
> > decoder during region setup. The decoder is later used to attach the
> > port to a region.
> >
> > Rename function to cxl_find_decoder_early() to emphasize its use only
> > during region setup in the early setup stage. Once a port is attached
> > to a region, the region reference can be used to lookup a region's
> > port and decoder configuration (see struct cxl_region_ref).
>
> Early doesn't seem that well defined to me. Can we indicate what the state
> is more explicitly?

'early' is used here as common term in the kernel to run pre-init
code. Here that means, an endpoint is not yet attached to a region
(cxl_region_attach()).

>
> Or does it actually matter? Whilst there is a better way to get
> it later, does this function then return the wrong answer?

There region references are setup and should be used then.

>
> Or if we have both cases of 'finding' it, can we just make this
> code do both?

No, there is no user.

I will update description and comment in the code to better explain
the 'early' state.

-Robert

>
> Jonathan
>
> >
> > Signed-off-by: Robert Richter <rrichter@xxxxxxx>
> > Reviewed-by: Gregory Price <gourry@xxxxxxxxxx>
> > Tested-by: Gregory Price <gourry@xxxxxxxxxx>
> > ---
> > drivers/cxl/core/region.c | 17 ++++++++++++-----
> > 1 file changed, 12 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> > index 54afdb0fa61c..13e3ba984a53 100644
> > --- a/drivers/cxl/core/region.c
> > +++ b/drivers/cxl/core/region.c
> > @@ -850,10 +850,17 @@ static int match_auto_decoder(struct device *dev, const void *data)
> > return 0;
> > }
> >
> > +/*
> > + * Use cxl_find_decoder_early() only during region setup in the early
> > + * setup stage. Once a port is attached to a region, the region
> > + * reference can be used to lookup a region's port and decoder
> > + * configuration (see struct cxl_region_ref).
> > +*/
> > +
> > static struct cxl_decoder *
> > -cxl_region_find_decoder(struct cxl_port *port,
> > - struct cxl_endpoint_decoder *cxled,
> > - struct cxl_region *cxlr)
> > +cxl_find_decoder_early(struct cxl_port *port,
> > + struct cxl_endpoint_decoder *cxled,
> > + struct cxl_region *cxlr)
> > {
> > struct device *dev;
> >
> > @@ -917,7 +924,7 @@ alloc_region_ref(struct cxl_port *port, struct cxl_region *cxlr,
> > if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) {
> > struct cxl_decoder *cxld;
> >
> > - cxld = cxl_region_find_decoder(port, cxled, cxlr);
> > + cxld = cxl_find_decoder_early(port, cxled, cxlr);
> > if (auto_order_ok(port, iter->region, cxld))
> > continue;
> > }
> > @@ -1005,7 +1012,7 @@ static int cxl_rr_alloc_decoder(struct cxl_port *port, struct cxl_region *cxlr,
> > {
> > struct cxl_decoder *cxld;
> >
> > - cxld = cxl_region_find_decoder(port, cxled, cxlr);
> > + cxld = cxl_find_decoder_early(port, cxled, cxlr);
> > if (!cxld) {
> > dev_dbg(&cxlr->dev, "%s: no decoder available\n",
> > dev_name(&port->dev));
>