Linux CXL
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: Li Ming <ming.li@zohomail.com>
Cc: linux-cxl@vger.kernel.org, Davidlohr Bueso <dave@stgolabs.net>,
	Jonathan Cameron <jonathan.cameron@huawei.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Dan Williams <dan.j.williams@intel.com>
Subject: Re: [PATCH] cxl/region: Quiet some dev_warn()s in extended linear cache setup
Date: Tue, 4 Mar 2025 16:40:04 -0800	[thread overview]
Message-ID: <Z8edZPIWsjSLiEac@aschofie-mobl2.lan> (raw)
In-Reply-To: <12e0d842-0ff3-4c8a-9bc2-b5c1436521e1@zohomail.com>

On Tue, Mar 04, 2025 at 01:14:47PM +0800, Li Ming wrote:
> On 3/4/2025 12:33 PM, alison.schofield@intel.com wrote:
> > From: Alison Schofield <alison.schofield@intel.com>
> >
> > Extended Linear Cache (ELC) setup code emits a dev_warn(), "Extended
> > linear cache calculation failed." for issues found while setting up
> > the ELC.
> >
> > For platforms without CONFIG_ACPI_HMAT, every auto region setup will
> > emit the warning because the default !ACPI_HMAT return value is
> > EOPNOTSUPP. Suppress it by skipping the warn for EOPNOTSUPP. Change
> > the EOPNOTSUPP in the actual ELC failure path to ENXIO.
> >
> > In a much less likely path, the dev_warn() is emitted if the size of
> > the region resource is NULL. Move that size check out of the ELC setup
> > code since NULL resource size is unrelated to the ELC setup and should
> > cause an immediate failure to construct the auto region.
> >
> > For good measure, add the rc value to the dev_warn(). It will either
> > be the -ENOENT returned by HMAT if the mem target is not found, or
> > the -ENXIO from the region driver calculation.
> >
> > Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> > ---
> >  drivers/cxl/core/region.c | 16 ++++++++--------
> >  1 file changed, 8 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> > index 8537b6a9ca18..2d2d2f221902 100644
> > --- a/drivers/cxl/core/region.c
> > +++ b/drivers/cxl/core/region.c
> > @@ -3235,13 +3235,10 @@ static int cxl_extended_linear_cache_resize(struct cxl_region *cxlr,
> >  	struct cxl_root_decoder *cxlrd = to_cxl_root_decoder(cxlr->dev.parent);
> >  	struct cxl_region_params *p = &cxlr->params;
> >  	int nid = phys_to_target_node(res->start);
> > -	resource_size_t size, cache_size, start;
> > +	resource_size_t size = resource_size(res);
> > +	resource_size_t cache_size, start;
> >  	int rc;
> >  
> > -	size = resource_size(res);
> > -	if (!size)
> > -		return -EINVAL;
> > -
> >  	rc = cxl_acpi_get_extended_linear_cache_size(res, nid, &cache_size);
> >  	if (rc)
> >  		return rc;
> > @@ -3253,7 +3250,7 @@ static int cxl_extended_linear_cache_resize(struct cxl_region *cxlr,
> >  		dev_warn(&cxlr->dev,
> >  			 "Extended Linear Cache size %pa != CXL size %pa. No Support!",
> >  			 &cache_size, &size);
> > -		return -EOPNOTSUPP;
> > +		return -ENXIO;
> >  	}
> >  
> >  	/*
> > @@ -3304,15 +3301,18 @@ static int __construct_region(struct cxl_region *cxlr,
> >  	*res = DEFINE_RES_MEM_NAMED(hpa->start, range_len(hpa),
> >  				    dev_name(&cxlr->dev));
> >  
> > +	if (!resource_size(res))
> > +		return -EINVAL;
> > +
> 
> Hi Alison,
> 
> 
> There is a 'res = kmalloc(sizeof(*res), GFP_KERNEL);' in __construct_region() before this return, I think that you should release 'res' before returning -EINVAL.

Thanks for the review. I zoomed out a bit and can't find how
we can get here without a valid hpa_range which makes me
want to remove the check altogher. Then again it's harmless,
and not in any performance path.

Checking with DaveJ ?


> 
> Other looks good to me.
> 
> Reviewed-by: Li Ming <ming.li@zohomail.com>
> 
> 
> Ming
> 
> [snip]
> 
> 

  reply	other threads:[~2025-03-05  0:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-04  4:33 [PATCH] cxl/region: Quiet some dev_warn()s in extended linear cache setup alison.schofield
2025-03-04  5:14 ` Li Ming
2025-03-05  0:40   ` Alison Schofield [this message]
2025-03-05  4:41     ` Li Ming
2025-03-06 21:09       ` Alison Schofield

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=Z8edZPIWsjSLiEac@aschofie-mobl2.lan \
    --to=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=ming.li@zohomail.com \
    --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