Linux CXL
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: <linux-cxl@vger.kernel.org>
Subject: Re: [PATCH 2/3] cxl/region: Clarify when a cxld->commit() callback is mandatory
Date: Fri, 13 Jan 2023 11:24:18 +0000	[thread overview]
Message-ID: <20230113112418.0000060b@Huawei.com> (raw)
In-Reply-To: <167124081824.1626103.1555704405392757219.stgit@dwillia2-xfh.jf.intel.com>

On Fri, 16 Dec 2022 17:33:38 -0800
Dan Williams <dan.j.williams@intel.com> wrote:

> Both cxl_switch_decoders() and cxl_endpoint_decoders() are considered by
> cxl_region_decode_commit(). Flag cases where cxl_switch_decoders with
> multiple targets, or cxl_endpoint_decoders do not have a commit callback
> set. The switch case is unlikely to happen since switches are only
> enumerated by the CXL core, but the endpoint case may support decoders
> defined by drivers outside of drivers/cxl, like accerator drivers.
> 
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

Seems reasonable though (just for consistency with earlier discussions)
I don't like assumption that nr->targets is the right thing to decide on.
It's fine to have decoders in single target case and if we do
they should be committed / not registered as pass through decoders etc.

Hmm. I've never tested the single downstream CXL switch port case.
Similar to HB in that case HDM decoders are optional. I've no idea
what we do about that corner currently.  One to add to my tests ;)


Anyhow, this is fine
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>




> ---
>  drivers/cxl/core/region.c |   19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index c11a6ab5e48d..60828d01972a 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -156,6 +156,22 @@ static int cxl_region_decode_reset(struct cxl_region *cxlr, int count)
>  	return 0;
>  }
>  
> +static int commit_decoder(struct cxl_decoder *cxld)
> +{
> +	struct cxl_switch_decoder *cxlsd = NULL;
> +
> +	if (cxld->commit)
> +		return cxld->commit(cxld);
> +
> +	if (is_switch_decoder(&cxld->dev))
> +		cxlsd = to_cxl_switch_decoder(&cxld->dev);
> +
> +	if (dev_WARN_ONCE(&cxld->dev, !cxlsd || cxlsd->nr_targets > 1,
> +			  "->commit() is required\n"))
> +		return -ENXIO;
> +	return 0;
> +}
> +
>  static int cxl_region_decode_commit(struct cxl_region *cxlr)
>  {
>  	struct cxl_region_params *p = &cxlr->params;
> @@ -174,8 +190,7 @@ static int cxl_region_decode_commit(struct cxl_region *cxlr)
>  		     iter = to_cxl_port(iter->dev.parent)) {
>  			cxl_rr = cxl_rr_load(iter, cxlr);
>  			cxld = cxl_rr->decoder;
> -			if (cxld->commit)
> -				rc = cxld->commit(cxld);
> +			rc = commit_decoder(cxld);
>  			if (rc)
>  				break;
>  		}
> 


  reply	other threads:[~2023-01-13 11:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-17  1:33 [PATCH 0/3] cxl: Misc fixups that missed v6.2 Dan Williams
2022-12-17  1:33 ` [PATCH 1/3] cxl/mem: Quiet port walking warning Dan Williams
2023-01-03 10:49   ` Robert Richter
2023-01-03 21:07     ` Dan Williams
2023-01-04  9:36       ` Robert Richter
2023-01-13 11:04         ` Jonathan Cameron
2023-01-25 21:09           ` Dan Williams
2023-01-25 22:11           ` [PATCH v2 1/3] cxl/mem: Quiet port walking warnings Dan Williams
2023-01-26 10:02             ` Jonathan Cameron
2023-01-26 11:47             ` Robert Richter
2022-12-17  1:33 ` [PATCH 2/3] cxl/region: Clarify when a cxld->commit() callback is mandatory Dan Williams
2023-01-13 11:24   ` Jonathan Cameron [this message]
2023-01-25 22:44     ` Dan Williams
2022-12-17  1:33 ` [PATCH 3/3] cxl/port: Link the 'parent_dport' in portX/ and endpointX/ sysfs Dan Williams
2023-01-13 11:39   ` Jonathan Cameron
2023-01-25 22:46     ` Dan Williams
2023-01-25 23:32       ` Dan Williams

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=20230113112418.0000060b@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=dan.j.williams@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