Skip to content

Commit 2f84d07

Browse files
aluceropdavejiang
authored andcommitted
cxl/pci: Add CXL Type 1/2 support to cxl_dvsec_rr_decode()
In cxl_dvsec_rr_decode() the pci driver expects to retrieve a cxlds, struct cxl_dev_state, from the driver_data field of struct device. While that works for Type 3, drivers for Type 1/2 devices may not put a cxlds in the driver_data field. In preparation for supporting Type 1/2 devices, replace parameter 'struct device' with 'struct cxl_dev_state' in cxl_dvsec_rr_decode(). Remove the unused parameter 'cxl_port' in cxl_dvsec_rr_decode(). Signed-off-by: Alejandro Lucero <alucerop@amd.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Alison Schofield <alison.schofield@intel.com> Link: https://patch.msgid.link/20241203162112.5088-1-alucerop@amd.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent c8e88de commit 2f84d07

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

drivers/cxl/core/pci.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,11 @@ static int devm_cxl_enable_hdm(struct device *host, struct cxl_hdm *cxlhdm)
291291
return devm_add_action_or_reset(host, disable_hdm, cxlhdm);
292292
}
293293

294-
int cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port,
294+
int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds,
295295
struct cxl_endpoint_dvsec_info *info)
296296
{
297-
struct pci_dev *pdev = to_pci_dev(dev);
298-
struct cxl_dev_state *cxlds = pci_get_drvdata(pdev);
297+
struct pci_dev *pdev = to_pci_dev(cxlds->dev);
298+
struct device *dev = cxlds->dev;
299299
int hdm_count, rc, i, ranges = 0;
300300
int d = cxlds->cxl_dvsec;
301301
u16 cap, ctrl;

drivers/cxl/cxl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,8 @@ struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port,
821821
int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm,
822822
struct cxl_endpoint_dvsec_info *info);
823823
int devm_cxl_add_passthrough_decoder(struct cxl_port *port);
824-
int cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port,
824+
struct cxl_dev_state;
825+
int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds,
825826
struct cxl_endpoint_dvsec_info *info);
826827

827828
bool is_cxl_region(struct device *dev);

drivers/cxl/port.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static int cxl_endpoint_port_probe(struct cxl_port *port)
9898
struct cxl_port *root;
9999
int rc;
100100

101-
rc = cxl_dvsec_rr_decode(cxlds->dev, port, &info);
101+
rc = cxl_dvsec_rr_decode(cxlds, &info);
102102
if (rc < 0)
103103
return rc;
104104

tools/testing/cxl/test/mock.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,16 @@ int __wrap_cxl_hdm_decode_init(struct cxl_dev_state *cxlds,
228228
}
229229
EXPORT_SYMBOL_NS_GPL(__wrap_cxl_hdm_decode_init, "CXL");
230230

231-
int __wrap_cxl_dvsec_rr_decode(struct device *dev, struct cxl_port *port,
231+
int __wrap_cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds,
232232
struct cxl_endpoint_dvsec_info *info)
233233
{
234234
int rc = 0, index;
235235
struct cxl_mock_ops *ops = get_cxl_mock_ops(&index);
236236

237-
if (ops && ops->is_mock_dev(dev))
237+
if (ops && ops->is_mock_dev(cxlds->dev))
238238
rc = 0;
239239
else
240-
rc = cxl_dvsec_rr_decode(dev, port, info);
240+
rc = cxl_dvsec_rr_decode(cxlds, info);
241241
put_cxl_mock_ops(index);
242242

243243
return rc;

0 commit comments

Comments
 (0)