Linux CXL
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Guixin Liu <kanie@linux.alibaba.com>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Jonathan Cameron <jic23@kernel.org>,
	Alison Schofield <alison.schofield@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Dan Williams <djbw@kernel.org>, Ira Weiny <iweiny@kernel.org>,
	Li Ming <ming.li@zohomail.com>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH 2/3] cxl/pci: Program the Port GPF timeouts before caching the DVSEC
Date: Mon, 28 Sep 2026 16:46:27 -0700	[thread overview]
Message-ID: <a0146647-8bd1-4ca2-9548-d04174d4e430@intel.com> (raw)
In-Reply-To: <20260922100026.3742401-3-kanie@linux.alibaba.com>



On 9/22/26 3:00 AM, Guixin Liu wrote:
> cxl_gpf_port_setup() caches the Port GPF DVSEC offset in the dport
> before programming the phase timeouts, and ignores the return value
> of both update_gpf_port_dvsec() calls: the function always reports
> success.
> 
> A failing config write is therefore not only silent, it is also
> permanent: the timeouts stay at the hardware defaults instead of the
> maximum flush window the kernel is asking for, and the cached offset
> keeps any later endpoint attach from retrying the update.
> 
> Propagate the errors and cache the offset only after both phases are
> programmed, so the next endpoint attach retries the setup.
> 
> Fixes: 6af941db6a60 ("cxl/pci: Update Port GPF timeout only when the first EP attaching")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>

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

> ---
>  drivers/cxl/core/pci.c | 30 +++++++++++++++++++++---------
>  1 file changed, 21 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c
> index e31aad7a525a..1f470ab0df3b 100644
> --- a/drivers/cxl/core/pci.c
> +++ b/drivers/cxl/core/pci.c
> @@ -840,7 +840,7 @@ static int update_gpf_port_dvsec(struct pci_dev *pdev, int dvsec, int phase)
>  
>  	rc = pci_read_config_word(pdev, dvsec + offset, &ctrl);
>  	if (rc)
> -		return rc;
> +		return pcibios_err_to_errno(rc);
>  
>  	if (FIELD_GET(base, ctrl) == GPF_TIMEOUT_BASE_MAX &&
>  	    FIELD_GET(scale, ctrl) == GPF_TIMEOUT_SCALE_MAX)
> @@ -850,11 +850,17 @@ static int update_gpf_port_dvsec(struct pci_dev *pdev, int dvsec, int phase)
>  	ctrl |= FIELD_PREP(scale, GPF_TIMEOUT_SCALE_MAX);
>  
>  	rc = pci_write_config_word(pdev, dvsec + offset, ctrl);
> -	if (!rc)
> -		pci_dbg(pdev, "Port GPF phase %d timeout: %d0 secs\n",
> -			phase, GPF_TIMEOUT_BASE_MAX);
> +	if (rc) {
> +		rc = pcibios_err_to_errno(rc);
> +		pci_warn(pdev, "Port GPF phase %d timeout write failed: %d\n",
> +			 phase, rc);
> +		return rc;
> +	}
>  
> -	return rc;
> +	pci_dbg(pdev, "Port GPF phase %d timeout: %d0 secs\n",
> +		phase, GPF_TIMEOUT_BASE_MAX);
> +
> +	return 0;
>  }
>  
>  int cxl_gpf_port_setup(struct cxl_dport *dport)
> @@ -864,16 +870,22 @@ int cxl_gpf_port_setup(struct cxl_dport *dport)
>  
>  	if (!dport->gpf_dvsec) {
>  		struct pci_dev *pdev;
> -		int dvsec;
> +		int dvsec, rc;
>  
>  		dvsec = cxl_gpf_get_dvsec(dport->dport_dev);
>  		if (!dvsec)
>  			return -EINVAL;
>  
> -		dport->gpf_dvsec = dvsec;
>  		pdev = to_pci_dev(dport->dport_dev);
> -		update_gpf_port_dvsec(pdev, dport->gpf_dvsec, 1);
> -		update_gpf_port_dvsec(pdev, dport->gpf_dvsec, 2);
> +		rc = update_gpf_port_dvsec(pdev, dvsec, 1);
> +		if (rc)
> +			return rc;
> +
> +		rc = update_gpf_port_dvsec(pdev, dvsec, 2);
> +		if (rc)
> +			return rc;
> +
> +		dport->gpf_dvsec = dvsec;
>  	}
>  
>  	return 0;


  parent reply	other threads:[~2026-09-28 23:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 10:00 [PATCH 0/3] cxl/pci: Fix the GPF DVSEC setup path Guixin Liu
2026-09-22 10:00 ` [PATCH 1/3] cxl/pci: Use the Device GPF DVSEC for restricted endpoints Guixin Liu
2026-09-25 23:36   ` Jonathan Cameron
2026-09-28 23:45   ` Dave Jiang
2026-09-22 10:00 ` [PATCH 2/3] cxl/pci: Program the Port GPF timeouts before caching the DVSEC Guixin Liu
2026-09-25 23:43   ` Jonathan Cameron
2026-09-28 23:46   ` Dave Jiang [this message]
2026-09-22 10:00 ` [PATCH 3/3] cxl/pci: Update only the Port GPF timeout fields Guixin Liu
2026-09-25 23:44   ` Jonathan Cameron
2026-10-08  3:15     ` Guixin Liu

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=a0146647-8bd1-4ca2-9548-d04174d4e430@intel.com \
    --to=dave.jiang@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=dave@stgolabs.net \
    --cc=djbw@kernel.org \
    --cc=iweiny@kernel.org \
    --cc=jic23@kernel.org \
    --cc=kanie@linux.alibaba.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