Skip to content

Commit a0328b3

Browse files
Foryun Madavejiang
authored andcommitted
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. Signed-off-by: Foryun Ma <foryun.ma@jaguarmicro.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Alison Schofield <alison.schofield@intel.com> Link: https://patch.msgid.link/20240604032151.655-1-foryun.ma@jaguarmicro.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent 5647847 commit a0328b3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/cxl/core/pci.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,6 @@ int cxl_dvsec_rr_decode(struct device *dev, int d,
338338
if (rc)
339339
return rc;
340340

341-
rc = pci_read_config_word(pdev, d + CXL_DVSEC_CTRL_OFFSET, &ctrl);
342-
if (rc)
343-
return rc;
344-
345341
if (!(cap & CXL_DVSEC_MEM_CAPABLE)) {
346342
dev_dbg(dev, "Not MEM Capable\n");
347343
return -ENXIO;
@@ -368,6 +364,10 @@ int cxl_dvsec_rr_decode(struct device *dev, int d,
368364
* disabled, and they will remain moot after the HDM Decoder
369365
* capability is enabled.
370366
*/
367+
rc = pci_read_config_word(pdev, d + CXL_DVSEC_CTRL_OFFSET, &ctrl);
368+
if (rc)
369+
return rc;
370+
371371
info->mem_enabled = FIELD_GET(CXL_DVSEC_MEM_ENABLE, ctrl);
372372
if (!info->mem_enabled)
373373
return 0;

0 commit comments

Comments
 (0)