Linux CXL
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Foryun Ma <foryun.ma@jaguarmicro.com>
Cc: <alison.schofield@intel.com>, <dan.j.williams@intel.com>,
	<angus.chen@jaguarmicro.com>, <dave.jiang@intel.com>,
	<dave@stgolabs.net>, <linux-cxl@vger.kernel.org>,
	<rrichter@amd.com>
Subject: Re: [PATCH v3] cxl/core/pci: Move reading of control register to immediately before usage
Date: Wed, 5 Jun 2024 13:15:34 +0100	[thread overview]
Message-ID: <20240605131534.0000182d@Huawei.com> (raw)
In-Reply-To: <20240604032151.655-1-foryun.ma@jaguarmicro.com>

On Tue,  4 Jun 2024 11:21:51 +0800
Foryun Ma <foryun.ma@jaguarmicro.com> wrote:

> Relocate the reading of the DVSEC control register to immediately
> before usage and avoid unnecessary PCI config access from the read
> if DVSEC capability check, hdm_count check, or device validity check
> results in failure.
I would focus more on the code readability / clarity improvement
Alison highlighted.
Something like:

"Move the read of the DVSEC control register to immediately before is
used to slightly improve readability. Also avoids reading this register
if an error condition is hit before it is needed."

With that as the focus I'm fine with this one as a small improvement.
Dave is handling the tree though, so ultimately his decision on this
one like any other patch.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> 
> Signed-off-by: Foryun Ma <foryun.ma@jaguarmicro.com>
> 
> ---
> V2->V3: move the check to after the comment
> V1->V2: change the subject and commit log, suggested by dave.jiang
> 	and add change log, suggested by Alison Schofield
> ---
>  drivers/cxl/core/pci.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c
> index 8567dd11eaac..a663e7566c48 100644
> --- a/drivers/cxl/core/pci.c
> +++ b/drivers/cxl/core/pci.c
> @@ -338,10 +338,6 @@ int cxl_dvsec_rr_decode(struct device *dev, int d,
>  	if (rc)
>  		return rc;
>  
> -	rc = pci_read_config_word(pdev, d + CXL_DVSEC_CTRL_OFFSET, &ctrl);
> -	if (rc)
> -		return rc;
> -
>  	if (!(cap & CXL_DVSEC_MEM_CAPABLE)) {
>  		dev_dbg(dev, "Not MEM Capable\n");
>  		return -ENXIO;
> @@ -368,6 +364,10 @@ int cxl_dvsec_rr_decode(struct device *dev, int d,
>  	 * disabled, and they will remain moot after the HDM Decoder
>  	 * capability is enabled.
>  	 */
> +	rc = pci_read_config_word(pdev, d + CXL_DVSEC_CTRL_OFFSET, &ctrl);
> +	if (rc)
> +		return rc;
> +
>  	info->mem_enabled = FIELD_GET(CXL_DVSEC_MEM_ENABLE, ctrl);
>  	if (!info->mem_enabled)
>  		return 0;


  reply	other threads:[~2024-06-05 12:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04  3:21 [PATCH v3] cxl/core/pci: Move reading of control register to immediately before usage Foryun Ma
2024-06-05 12:15 ` Jonathan Cameron [this message]
2024-06-05 15:35 ` 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=20240605131534.0000182d@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=alison.schofield@intel.com \
    --cc=angus.chen@jaguarmicro.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=foryun.ma@jaguarmicro.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=rrichter@amd.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