Skip to content

Commit 4017040

Browse files
committed
Merge tag 'cxl-fixes-6.15-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl
Pull cxl fixes from Dave Jiang: "The fixes address global persistent flush (GPF) changes and CXL Features support changes that went in the 6.15 merge window. And also a fix to an issue observed on CXL 1.1 platform during device enumeration. Summary: - Fix using the wrong GPF DVSEC location: - Fix caching of dport GPF DVSEC from the first endpoint - Ensure that the GPF phase timeout is only updated once by first endpoint - Drop is_port parameter for cxl_gpf_get_dvsec() - Fix the devm_* call host device for CXL fwctl setup - Set the out_len in Set Features failure case - Fix RCD initialization by skipping unneeded mem_en check" * tag 'cxl-fixes-6.15-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl: cxl/core/regs.c: Skip Memory Space Enable check for RCD and RCH Ports cxl/feature: Update out_len in set feature failure case cxl: Fix devm host device for CXL fwctl initialization cxl/pci: Drop the parameter is_port of cxl_gpf_get_dvsec() cxl/pci: Update Port GPF timeout only when the first EP attaching cxl/core: Fix caching dport GPF DVSEC issue
2 parents c313751 + 078d3ee commit 4017040

File tree

10 files changed

+31
-30
lines changed

10 files changed

+31
-30
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/features.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,13 +528,13 @@ static void *cxlctl_set_feature(struct cxl_features_state *cxlfs,
528528
rc = cxl_set_feature(cxl_mbox, &feat_in->uuid,
529529
feat_in->version, feat_in->feat_data,
530530
data_size, flags, offset, &return_code);
531+
*out_len = sizeof(*rpc_out);
531532
if (rc) {
532533
rpc_out->retval = return_code;
533534
return no_free_ptr(rpc_out);
534535
}
535536

536537
rpc_out->retval = CXL_MBOX_CMD_RC_SUCCESS;
537-
*out_len = sizeof(*rpc_out);
538538

539539
return no_free_ptr(rpc_out);
540540
}
@@ -677,7 +677,7 @@ static void free_memdev_fwctl(void *_fwctl_dev)
677677
fwctl_put(fwctl_dev);
678678
}
679679

680-
int devm_cxl_setup_fwctl(struct cxl_memdev *cxlmd)
680+
int devm_cxl_setup_fwctl(struct device *host, struct cxl_memdev *cxlmd)
681681
{
682682
struct cxl_dev_state *cxlds = cxlmd->cxlds;
683683
struct cxl_features_state *cxlfs;
@@ -700,7 +700,7 @@ int devm_cxl_setup_fwctl(struct cxl_memdev *cxlmd)
700700
if (rc)
701701
return rc;
702702

703-
return devm_add_action_or_reset(&cxlmd->dev, free_memdev_fwctl,
703+
return devm_add_action_or_reset(host, free_memdev_fwctl,
704704
no_free_ptr(fwctl_dev));
705705
}
706706
EXPORT_SYMBOL_NS_GPL(devm_cxl_setup_fwctl, "CXL");

drivers/cxl/core/pci.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,14 +1072,20 @@ int cxl_pci_get_bandwidth(struct pci_dev *pdev, struct access_coordinate *c)
10721072
#define GPF_TIMEOUT_BASE_MAX 2
10731073
#define GPF_TIMEOUT_SCALE_MAX 7 /* 10 seconds */
10741074

1075-
u16 cxl_gpf_get_dvsec(struct device *dev, bool is_port)
1075+
u16 cxl_gpf_get_dvsec(struct device *dev)
10761076
{
1077+
struct pci_dev *pdev;
1078+
bool is_port = true;
10771079
u16 dvsec;
10781080

10791081
if (!dev_is_pci(dev))
10801082
return 0;
10811083

1082-
dvsec = pci_find_dvsec_capability(to_pci_dev(dev), PCI_VENDOR_ID_CXL,
1084+
pdev = to_pci_dev(dev);
1085+
if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ENDPOINT)
1086+
is_port = false;
1087+
1088+
dvsec = pci_find_dvsec_capability(pdev, PCI_VENDOR_ID_CXL,
10831089
is_port ? CXL_DVSEC_PORT_GPF : CXL_DVSEC_DEVICE_GPF);
10841090
if (!dvsec)
10851091
dev_warn(dev, "%s GPF DVSEC not present\n",
@@ -1128,26 +1134,24 @@ static int update_gpf_port_dvsec(struct pci_dev *pdev, int dvsec, int phase)
11281134
return rc;
11291135
}
11301136

1131-
int cxl_gpf_port_setup(struct device *dport_dev, struct cxl_port *port)
1137+
int cxl_gpf_port_setup(struct cxl_dport *dport)
11321138
{
1133-
struct pci_dev *pdev;
1134-
1135-
if (!port)
1139+
if (!dport)
11361140
return -EINVAL;
11371141

1138-
if (!port->gpf_dvsec) {
1142+
if (!dport->gpf_dvsec) {
1143+
struct pci_dev *pdev;
11391144
int dvsec;
11401145

1141-
dvsec = cxl_gpf_get_dvsec(dport_dev, true);
1146+
dvsec = cxl_gpf_get_dvsec(dport->dport_dev);
11421147
if (!dvsec)
11431148
return -EINVAL;
11441149

1145-
port->gpf_dvsec = dvsec;
1150+
dport->gpf_dvsec = dvsec;
1151+
pdev = to_pci_dev(dport->dport_dev);
1152+
update_gpf_port_dvsec(pdev, dport->gpf_dvsec, 1);
1153+
update_gpf_port_dvsec(pdev, dport->gpf_dvsec, 2);
11461154
}
11471155

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);
1151-
11521156
return 0;
11531157
}

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/core/regs.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,6 @@ resource_size_t __rcrb_to_component(struct device *dev, struct cxl_rcrb_info *ri
581581
resource_size_t rcrb = ri->base;
582582
void __iomem *addr;
583583
u32 bar0, bar1;
584-
u16 cmd;
585584
u32 id;
586585

587586
if (which == CXL_RCRB_UPSTREAM)
@@ -603,7 +602,6 @@ resource_size_t __rcrb_to_component(struct device *dev, struct cxl_rcrb_info *ri
603602
}
604603

605604
id = readl(addr + PCI_VENDOR_ID);
606-
cmd = readw(addr + PCI_COMMAND);
607605
bar0 = readl(addr + PCI_BASE_ADDRESS_0);
608606
bar1 = readl(addr + PCI_BASE_ADDRESS_1);
609607
iounmap(addr);
@@ -618,8 +616,6 @@ resource_size_t __rcrb_to_component(struct device *dev, struct cxl_rcrb_info *ri
618616
dev_err(dev, "Failed to access Downstream Port RCRB\n");
619617
return CXL_RESOURCE_NONE;
620618
}
621-
if (!(cmd & PCI_COMMAND_MEMORY))
622-
return CXL_RESOURCE_NONE;
623619
/* The RCRB is a Memory Window, and the MEM_TYPE_1M bit is obsolete */
624620
if (bar0 & (PCI_BASE_ADDRESS_MEM_TYPE_1M | PCI_BASE_ADDRESS_SPACE_IO))
625621
return CXL_RESOURCE_NONE;

drivers/cxl/cxl.h

Lines changed: 3 additions & 3 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
/**
@@ -910,6 +910,6 @@ bool cxl_endpoint_decoder_reset_detected(struct cxl_port *port);
910910
#define __mock static
911911
#endif
912912

913-
u16 cxl_gpf_get_dvsec(struct device *dev, bool is_port);
913+
u16 cxl_gpf_get_dvsec(struct device *dev);
914914

915915
#endif /* __CXL_H__ */

drivers/cxl/pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
10181018
if (rc)
10191019
return rc;
10201020

1021-
rc = devm_cxl_setup_fwctl(cxlmd);
1021+
rc = devm_cxl_setup_fwctl(&pdev->dev, cxlmd);
10221022
if (rc)
10231023
dev_dbg(&pdev->dev, "No CXL FWCTL setup\n");
10241024

drivers/cxl/pmem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static void cxl_nvdimm_arm_dirty_shutdown_tracking(struct cxl_nvdimm *cxl_nvd)
108108
return;
109109
}
110110

111-
if (!cxl_gpf_get_dvsec(cxlds->dev, false))
111+
if (!cxl_gpf_get_dvsec(cxlds->dev))
112112
return;
113113

114114
if (cxl_get_dirty_count(mds, &count)) {

include/cxl/features.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct cxl_memdev;
6666
#ifdef CONFIG_CXL_FEATURES
6767
inline struct cxl_features_state *to_cxlfs(struct cxl_dev_state *cxlds);
6868
int devm_cxl_setup_features(struct cxl_dev_state *cxlds);
69-
int devm_cxl_setup_fwctl(struct cxl_memdev *cxlmd);
69+
int devm_cxl_setup_fwctl(struct device *host, struct cxl_memdev *cxlmd);
7070
#else
7171
static inline struct cxl_features_state *to_cxlfs(struct cxl_dev_state *cxlds)
7272
{
@@ -78,7 +78,8 @@ static inline int devm_cxl_setup_features(struct cxl_dev_state *cxlds)
7878
return -EOPNOTSUPP;
7979
}
8080

81-
static inline int devm_cxl_setup_fwctl(struct cxl_memdev *cxlmd)
81+
static inline int devm_cxl_setup_fwctl(struct device *host,
82+
struct cxl_memdev *cxlmd)
8283
{
8384
return -EOPNOTSUPP;
8485
}

tools/testing/cxl/test/mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1780,7 +1780,7 @@ static int cxl_mock_mem_probe(struct platform_device *pdev)
17801780
if (rc)
17811781
return rc;
17821782

1783-
rc = devm_cxl_setup_fwctl(cxlmd);
1783+
rc = devm_cxl_setup_fwctl(&pdev->dev, cxlmd);
17841784
if (rc)
17851785
dev_dbg(dev, "No CXL FWCTL setup\n");
17861786

0 commit comments

Comments
 (0)