Linux CXL
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Dan Williams <dan.j.williams@intel.com>, <linux-cxl@vger.kernel.org>
Cc: <stable@vger.kernel.org>, "Huang, Ying" <ying.huang@intel.com>,
	<alison.schofield@intel.com>
Subject: Re: [PATCH] cxl/port: Fix decoder initialization when nr_targets > interleave_ways
Date: Fri, 22 Dec 2023 08:57:20 -0700	[thread overview]
Message-ID: <938a3a03-a465-4d8f-9972-885ff73f262f@intel.com> (raw)
In-Reply-To: <170322553283.110939.32271609757456243.stgit@dwillia2-xfh.jf.intel.com>



On 12/21/23 23:12, Dan Williams wrote:
> From: Huang Ying <ying.huang@intel.com>
> 
> The decoder_populate_targets() helper walks all of the targets in a port
> and makes sure they can be looked up in @target_map. Where @target_map
> is a lookup table from target position to target id (corresponding to a
> cxl_dport instance). However @target_map is only responsible for
> conveying the active dport instances as conveyed by interleave_ways.
> 
> When nr_targets > interleave_ways it results in
> decoder_populate_targets() walking off the end of the valid entries in
> @target_map. Given target_map is initialized to 0 it results in the
> dport lookup failing if position 0 is not mapped to a dport with an id
> of 0:
> 
>   cxl_port port3: Failed to populate active decoder targets
>   cxl_port port3: Failed to add decoder
>   cxl_port port3: Failed to add decoder3.0
>   cxl_bus_probe: cxl_port port3: probe: -6
> 
> This bug also highlights that when the decoder's ->targets[] array is
> written in cxl_port_setup_targets() it is missing a hold of the
> targets_lock to synchronize against sysfs readers of the target list. A
> fix for that is saved for a later patch.
> 
> Fixes: a5c258021689 ("cxl/bus: Populate the target list at decoder create")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
> [djbw: rewrite the changelog, find the Fixes: tag]
> Co-developed-by: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  drivers/cxl/core/port.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index b7c93bb18f6e..57495cdc181f 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -1644,7 +1644,7 @@ static int decoder_populate_targets(struct cxl_switch_decoder *cxlsd,
>  		return -EINVAL;
>  
>  	write_seqlock(&cxlsd->target_lock);
> -	for (i = 0; i < cxlsd->nr_targets; i++) {
> +	for (i = 0; i < cxlsd->cxld.interleave_ways; i++) {
>  		struct cxl_dport *dport = find_dport(port, target_map[i]);
>  
>  		if (!dport) {
> 
> 

  reply	other threads:[~2023-12-22 15:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-22  6:12 [PATCH] cxl/port: Fix decoder initialization when nr_targets > interleave_ways Dan Williams
2023-12-22 15:57 ` Dave Jiang [this message]
2023-12-22 20:12 ` Alison Schofield
2023-12-22 21:10   ` Dan Williams
2023-12-22 22:01     ` 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=938a3a03-a465-4d8f-9972-885ff73f262f@intel.com \
    --to=dave.jiang@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=ying.huang@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