mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: Li Ming <ming.li@zohomail.com>
Cc: Dave Jiang <dave.jiang@intel.com>, <linux-cxl@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Davidlohr Bueso <dave@stgolabs.net>,
	"Jonathan Cameron" <jonathan.cameron@huawei.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/hdm: Add support for 32 switch decoders
Date: Thu, 19 Mar 2026 19:03:52 -0700	[thread overview]
Message-ID: <abyrCJGqMTsyPnMN@aschofie-mobl2.lan> (raw)
In-Reply-To: <291ac46e-67cb-4732-8626-e0c434ede12f@zohomail.com>

On Thu, Mar 19, 2026 at 07:11:34PM +0800, Li Ming wrote:
> 
> 在 2026/3/18 23:40, Dave Jiang 写道:
> > 
> > On 3/18/26 6:00 AM, Li Ming wrote:
> > > Per CXL r4.0 section 8.2.4.20.1. CXL host bridge and switch ports can
> > > support 32 HDM decoders. Current implementation misses some decoders on
> > > CXL host bridge and switch in the case that the value of Decoder Count
> > > field in CXL HDM decoder Capability Register is greater than or equal to
> > > 9.
> > > 
> > > Update calculation implementation to ensure the decoder count calculation
> > > is correct for CXL host bridge/switch ports.
> > > 
> > > Signed-off-by: Li Ming <ming.li@zohomail.com>
> > > ---
> > >   drivers/cxl/cxl.h | 7 ++++++-
> > >   1 file changed, 6 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
> > > index 9b947286eb9b..466b8eeefed7 100644
> > > --- a/drivers/cxl/cxl.h
> > > +++ b/drivers/cxl/cxl.h
> > > @@ -77,7 +77,12 @@ static inline int cxl_hdm_decoder_count(u32 cap_hdr)
> > >   {
> > >   	int val = FIELD_GET(CXL_HDM_DECODER_COUNT_MASK, cap_hdr);
> > > -	return val ? val * 2 : 1;
> > > +	if (!val)
> > > +		return 1;
> > > +	else if (val <= 8)
> > > +		return val * 2;
> > > +	else
> > > +		return 4 * (val - 4);
> > That looks a bit messy. How about:
> > 
> > switch (val) {
> > case 0:
> > 	return 1;
> > case 1..8:
> > 	return val * 2;
> > case 9..12:
> > 	return val 4 * (val - 4);
> > default:
> > 	return -ENXIO;
> > }
> > 
> > DJ
> 
> Sure, will do that in v2.

Hi Ming,

You may have already spied this while implementing. Before this change
this function could only return 1 or val*2, so never negative. Adding
-ENXIO changes that and could wrap to huge value in the decoder for
loops. Change decoder_count field to int to clean that up.

Or, you could do something like this:
	WARN_ONCE(1, "reserved HDM decoder count field: %d\n", val);
        return 0;

I like the ENXIO and type cleanup or maybe you have something else?

--Alison

> 
> 
> Ming
> 

  reply	other threads:[~2026-03-20  2:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-18 13:00 Li Ming
2026-03-18 15:40 ` Dave Jiang
2026-03-19 11:11   ` Li Ming
2026-03-20  2:03     ` Alison Schofield [this message]
2026-03-20 12:56       ` Li Ming

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=abyrCJGqMTsyPnMN@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=linux-kernel@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

all inboxes | Powered by JetHome®