Linux CXL
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: alison.schofield@intel.com, 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>
Cc: linux-cxl@vger.kernel.org, Neha Agrawal <neha.agrawal@intel.com>
Subject: Re: [PATCH] cxl/region: Allow out of order assembly of autodiscovered regions
Date: Thu, 22 Feb 2024 11:11:04 -0700	[thread overview]
Message-ID: <3088022b-c9e3-4ff3-985a-c3c2834c59df@intel.com> (raw)
In-Reply-To: <20240126045446.1750854-1-alison.schofield@intel.com>



On 1/25/24 9:54 PM, alison.schofield@intel.com wrote:
> From: Alison Schofield <alison.schofield@intel.com>
> 
> Autodiscovered regions can fail to assemble if they are not discovered
> in HPA decode order. The user will see failure messages like:
> 
> [] cxl region0: endpoint5: HPA order violation region1
> [] cxl region0: endpoint5: failed to allocate region reference
> 
> The check that is causing the failure helps the CXL driver enforce
> a CXL spec mandate that decoders be committed in HPA order. The
> check is needless for autodiscovered regions since their decoders
> are already programmed. Trying to enforce order in the assembly of
> these regions is useless because they are assembled once all their
> member endpoints arrive, and there is no guarantee on the order in
> which endpoints are discovered during probe.
> 
> Keep the existing check, but for autodiscovered regions, allow the
> out of order assembly after a sanity check that the lowered numbered
> decoder has the lower HPA starting address.
> 
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> Tested-by: Neha Agrawal <neha.agrawal@intel.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>

s/autodiscovered/auto-discovered/?

> ---
> 
> Changes since RFC:
> - Declare auto_order_ok() as static (lkp)
> - Add Tested-by tag (Neha)
> Link to RFC: https://lore.kernel.org/linux-cxl/20240113050421.1622533-1-alison.schofield@intel.com/
> 
> 
>  drivers/cxl/core/region.c | 34 +++++++++++++++++++++++++++++++++-
>  1 file changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 0f05692bfec3..f6a49fd01ae9 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -753,6 +753,37 @@ static struct cxl_decoder *cxl_region_find_decoder(struct cxl_port *port,
>  	return to_cxl_decoder(dev);
>  }
>  
> +static bool auto_order_ok(struct cxl_port *port, struct cxl_region *cxlr_a,
> +			  struct cxl_region *cxlr_b)
> +{
> +	struct cxl_region_ref *cxl_rr;
> +	struct cxl_decoder *cxld_a, *cxld_b;
> +
> +	/*
> +	 * Allow the out of order assembly of auto-discovered regions as
> +	 * long as correct decoder programming order can be verified.
> +	 *
> +	 * Per CXL Spec 3.1 8.2.4.20.12 Committing Decoder Programming,
> +	 * software must commit decoders in HPA order. Therefore it is
> +	 * sufficient to sanity check that the lowered number decoder
> +	 * has the lower HPA starting address.
> +	 */
> +	if (!test_bit(CXL_REGION_F_AUTO, &cxlr_a->flags))
> +		return false;
> +
> +	cxld_a = cxl_region_find_decoder(port, cxlr_a);
> +	cxl_rr = cxl_rr_load(port, cxlr_b);
> +	cxld_b = cxl_rr->decoder;
> +
> +	if (cxld_b->id > cxld_a->id) {
> +		dev_dbg(&cxlr_a->dev,
> +			"allow out of order region ref alloc\n");
> +		return true;
> +	}
> +
> +	return false;
> +}
> +
>  static struct cxl_region_ref *alloc_region_ref(struct cxl_port *port,
>  					       struct cxl_region *cxlr)
>  {
> @@ -767,7 +798,8 @@ static struct cxl_region_ref *alloc_region_ref(struct cxl_port *port,
>  		if (!ip->res)
>  			continue;
>  
> -		if (ip->res->start > p->res->start) {
> +		if (ip->res->start > p->res->start &&
> +		    (!auto_order_ok(port, cxlr, iter->region))) {
>  			dev_dbg(&cxlr->dev,
>  				"%s: HPA order violation %s:%pr vs %pr\n",
>  				dev_name(&port->dev),
> 
> base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d

      reply	other threads:[~2024-02-22 18:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-26  4:54 [PATCH] cxl/region: Allow out of order assembly of autodiscovered regions alison.schofield
2024-02-22 18:11 ` Dave Jiang [this message]

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=3088022b-c9e3-4ff3-985a-c3c2834c59df@intel.com \
    --to=dave.jiang@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=neha.agrawal@intel.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