Skip to content

Commit 87d2de0

Browse files
MingLi-4davejiang
authored andcommitted
cxl/core: Fix caching dport GPF DVSEC issue
Per Table 8-2 in CXL r3.2 section 8.1.1 and CXL r3.2 section 8.1.6, only CXL Downstream switch ports and CXL root ports have GPF DVSEC for CXL Port(DVSEC ID 04h). CXL subsystem has a gpf_dvsec in struct cxl_port which is used to cache the offset of a GPF DVSEC in PCIe configuration space. It will be updated during the first EP attaching to the cxl_port, so the gpf_dvsec can only cache the GPF DVSEC offset of the dport which the first EP is under. Will not have chance to update it during other EPs attaching. That means CXL subsystem will use the same GPF DVSEC offset for all dports under the port, it will be a problem if the GPF DVSEC offset cached in cxl_port is not the right offset for a dport. Moving gpf_dvsec from struct cxl_port to struct cxl_dport, make every cxl dport has their own GPF DVSEC offset caching, and each cxl dport uses its own GPF DVSEC offset for GPF DVSEC accessing. Fixes: a52b6a2 ("cxl/pci: Support Global Persistent Flush (GPF)") Signed-off-by: Li Ming <ming.li@zohomail.com> Reviewed-by: Davidlohr Bueso <dave@stgolabs.net> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Tested-by: Davidlohr Bueso <dave@stgolabs.net> Link: https://patch.msgid.link/20250323093110.233040-2-ming.li@zohomail.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent 0af2f6b commit 87d2de0

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

drivers/cxl/core/core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ int cxl_port_get_switch_dport_bandwidth(struct cxl_port *port,
119119

120120
int cxl_ras_init(void);
121121
void cxl_ras_exit(void);
122-
int cxl_gpf_port_setup(struct device *dport_dev, struct cxl_port *port);
122+
int cxl_gpf_port_setup(struct cxl_dport *dport);
123123
int cxl_acpi_get_extended_linear_cache_size(struct resource *backing_res,
124124
int nid, resource_size_t *size);
125125

drivers/cxl/core/pci.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,26 +1128,26 @@ static int update_gpf_port_dvsec(struct pci_dev *pdev, int dvsec, int phase)
11281128
return rc;
11291129
}
11301130

1131-
int cxl_gpf_port_setup(struct device *dport_dev, struct cxl_port *port)
1131+
int cxl_gpf_port_setup(struct cxl_dport *dport)
11321132
{
11331133
struct pci_dev *pdev;
11341134

1135-
if (!port)
1135+
if (!dport)
11361136
return -EINVAL;
11371137

1138-
if (!port->gpf_dvsec) {
1138+
if (!dport->gpf_dvsec) {
11391139
int dvsec;
11401140

1141-
dvsec = cxl_gpf_get_dvsec(dport_dev, true);
1141+
dvsec = cxl_gpf_get_dvsec(dport->dport_dev, true);
11421142
if (!dvsec)
11431143
return -EINVAL;
11441144

1145-
port->gpf_dvsec = dvsec;
1145+
dport->gpf_dvsec = dvsec;
11461146
}
11471147

1148-
pdev = to_pci_dev(dport_dev);
1149-
update_gpf_port_dvsec(pdev, port->gpf_dvsec, 1);
1150-
update_gpf_port_dvsec(pdev, port->gpf_dvsec, 2);
1148+
pdev = to_pci_dev(dport->dport_dev);
1149+
update_gpf_port_dvsec(pdev, dport->gpf_dvsec, 1);
1150+
update_gpf_port_dvsec(pdev, dport->gpf_dvsec, 2);
11511151

11521152
return 0;
11531153
}

drivers/cxl/core/port.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,7 @@ int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd)
16781678
if (rc && rc != -EBUSY)
16791679
return rc;
16801680

1681-
cxl_gpf_port_setup(dport_dev, port);
1681+
cxl_gpf_port_setup(dport);
16821682

16831683
/* Any more ports to add between this one and the root? */
16841684
if (!dev_is_cxl_root_child(&port->dev))

drivers/cxl/cxl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ struct cxl_dax_region {
592592
* @cdat: Cached CDAT data
593593
* @cdat_available: Should a CDAT attribute be available in sysfs
594594
* @pci_latency: Upstream latency in picoseconds
595-
* @gpf_dvsec: Cached GPF port DVSEC
596595
*/
597596
struct cxl_port {
598597
struct device dev;
@@ -616,7 +615,6 @@ struct cxl_port {
616615
} cdat;
617616
bool cdat_available;
618617
long pci_latency;
619-
int gpf_dvsec;
620618
};
621619

622620
/**
@@ -664,6 +662,7 @@ struct cxl_rcrb_info {
664662
* @regs: Dport parsed register blocks
665663
* @coord: access coordinates (bandwidth and latency performance attributes)
666664
* @link_latency: calculated PCIe downstream latency
665+
* @gpf_dvsec: Cached GPF port DVSEC
667666
*/
668667
struct cxl_dport {
669668
struct device *dport_dev;
@@ -675,6 +674,7 @@ struct cxl_dport {
675674
struct cxl_regs regs;
676675
struct access_coordinate coord[ACCESS_COORDINATE_MAX];
677676
long link_latency;
677+
int gpf_dvsec;
678678
};
679679

680680
/**

0 commit comments

Comments
 (0)