* [PATCH] cxl/pci: the ctrl register should be read when it is being used
@ 2024-05-29 9:33 Foryun Ma
2024-05-29 16:30 ` Alison Schofield
2024-05-29 16:31 ` Dave Jiang
0 siblings, 2 replies; 3+ messages in thread
From: Foryun Ma @ 2024-05-29 9:33 UTC (permalink / raw)
To: dave.jiang, dave; +Cc: linux-cxl, rrichter, foryun.ma, angus.chen
When the cap register and wait_for_valid checks fail, the ctrl register
read will be redundant.
Signed-off-by: Foryun Ma <foryun.ma@jaguarmicro.com>
---
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..627be83881e9 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;
@@ -363,6 +359,10 @@ int cxl_dvsec_rr_decode(struct device *dev, int d,
return rc;
}
+ rc = pci_read_config_word(pdev, d + CXL_DVSEC_CTRL_OFFSET, &ctrl);
+ if (rc)
+ return rc;
+
/*
* The current DVSEC values are moot if the memory capability is
* disabled, and they will remain moot after the HDM Decoder
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] cxl/pci: the ctrl register should be read when it is being used
2024-05-29 9:33 [PATCH] cxl/pci: the ctrl register should be read when it is being used Foryun Ma
@ 2024-05-29 16:30 ` Alison Schofield
2024-05-29 16:31 ` Dave Jiang
1 sibling, 0 replies; 3+ messages in thread
From: Alison Schofield @ 2024-05-29 16:30 UTC (permalink / raw)
To: Foryun Ma; +Cc: dave.jiang, dave, linux-cxl, rrichter, angus.chen
On Wed, May 29, 2024 at 05:33:54PM +0800, Foryun Ma wrote:
> When the cap register and wait_for_valid checks fail, the ctrl register
> read will be redundant.
>
Thanks for the patch. I suggest updating the commit message to match the
style of cxl/pci.c, something like:
cxl/pci: Only read the ctrl register it checking contents
A bit more below -
> Signed-off-by: Foryun Ma <foryun.ma@jaguarmicro.com>
> ---
> 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..627be83881e9 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;
> @@ -363,6 +359,10 @@ int cxl_dvsec_rr_decode(struct device *dev, int d,
> return rc;
> }
>
> + rc = pci_read_config_word(pdev, d + CXL_DVSEC_CTRL_OFFSET, &ctrl);
> + if (rc)
> + return rc;
> +
How about moving the read a few more lines down. Put it after the
comment so that it is directly before the check.
> /*
> * The current DVSEC values are moot if the memory capability is
> * disabled, and they will remain moot after the HDM Decoder
> --
> 2.34.1
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] cxl/pci: the ctrl register should be read when it is being used
2024-05-29 9:33 [PATCH] cxl/pci: the ctrl register should be read when it is being used Foryun Ma
2024-05-29 16:30 ` Alison Schofield
@ 2024-05-29 16:31 ` Dave Jiang
1 sibling, 0 replies; 3+ messages in thread
From: Dave Jiang @ 2024-05-29 16:31 UTC (permalink / raw)
To: Foryun Ma, dave
Cc: linux-cxl, rrichter, angus.chen, Dan Williams, Ira Weiny,
Alison Schofield
On 5/29/24 2:33 AM, Foryun Ma wrote:
> When the cap register and wait_for_valid checks fail, the ctrl register
> read will be redundant.
>
> Signed-off-by: Foryun Ma <foryun.ma@jaguarmicro.com>
Please consider slight change to the subject and commit log:
cxl/core/pci: Move reading of control register to immediately before usage
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.
Otherwise LGTM
> ---
> 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..627be83881e9 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;
> @@ -363,6 +359,10 @@ int cxl_dvsec_rr_decode(struct device *dev, int d,
> return rc;
> }
>
> + rc = pci_read_config_word(pdev, d + CXL_DVSEC_CTRL_OFFSET, &ctrl);
> + if (rc)
> + return rc;
> +
> /*
> * The current DVSEC values are moot if the memory capability is
> * disabled, and they will remain moot after the HDM Decoder
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-29 16:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-29 9:33 [PATCH] cxl/pci: the ctrl register should be read when it is being used Foryun Ma
2024-05-29 16:30 ` Alison Schofield
2024-05-29 16:31 ` Dave Jiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox