Skip to content

Commit af0a6c3

Browse files
l1kdjbw
authored andcommitted
cxl/pci: Use CDAT DOE mailbox created by PCI core
The PCI core has just been amended to create a pci_doe_mb struct for every DOE instance on device enumeration. Drop creation of a (duplicate) CDAT DOE mailbox on cxl probing in favor of the one already created by the PCI core. Tested-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Lukas Wunner <lukas@wunner.de> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Link: https://lore.kernel.org/r/becaf70e8faf9681d474200117d62d7eaac46cca.1678543498.git.lukas@wunner.de Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent ac04840 commit af0a6c3

3 files changed

Lines changed: 5 additions & 74 deletions

File tree

drivers/cxl/core/pci.c

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -441,27 +441,6 @@ EXPORT_SYMBOL_NS_GPL(cxl_hdm_decode_init, CXL);
441441
#define CXL_DOE_TABLE_ACCESS_LAST_ENTRY 0xffff
442442
#define CXL_DOE_PROTOCOL_TABLE_ACCESS 2
443443

444-
static struct pci_doe_mb *find_cdat_doe(struct device *uport)
445-
{
446-
struct cxl_memdev *cxlmd;
447-
struct cxl_dev_state *cxlds;
448-
unsigned long index;
449-
void *entry;
450-
451-
cxlmd = to_cxl_memdev(uport);
452-
cxlds = cxlmd->cxlds;
453-
454-
xa_for_each(&cxlds->doe_mbs, index, entry) {
455-
struct pci_doe_mb *cur = entry;
456-
457-
if (pci_doe_supports_prot(cur, PCI_DVSEC_VENDOR_ID_CXL,
458-
CXL_DOE_PROTOCOL_TABLE_ACCESS))
459-
return cur;
460-
}
461-
462-
return NULL;
463-
}
464-
465444
#define CDAT_DOE_REQ(entry_handle) cpu_to_le32 \
466445
(FIELD_PREP(CXL_DOE_TABLE_ACCESS_REQ_CODE, \
467446
CXL_DOE_TABLE_ACCESS_REQ_CODE_READ) | \
@@ -559,10 +538,14 @@ void read_cdat_data(struct cxl_port *port)
559538
struct pci_doe_mb *cdat_doe;
560539
struct device *dev = &port->dev;
561540
struct device *uport = port->uport;
541+
struct cxl_memdev *cxlmd = to_cxl_memdev(uport);
542+
struct cxl_dev_state *cxlds = cxlmd->cxlds;
543+
struct pci_dev *pdev = to_pci_dev(cxlds->dev);
562544
size_t cdat_length;
563545
int rc;
564546

565-
cdat_doe = find_cdat_doe(uport);
547+
cdat_doe = pci_find_doe_mailbox(pdev, PCI_DVSEC_VENDOR_ID_CXL,
548+
CXL_DOE_PROTOCOL_TABLE_ACCESS);
566549
if (!cdat_doe) {
567550
dev_dbg(dev, "No CDAT mailbox\n");
568551
return;

drivers/cxl/cxlmem.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ struct cxl_event_state {
249249
* @component_reg_phys: register base of component registers
250250
* @info: Cached DVSEC information about the device.
251251
* @serial: PCIe Device Serial Number
252-
* @doe_mbs: PCI DOE mailbox array
253252
* @event: event log driver state
254253
* @mbox_send: @dev specific transport for transmitting mailbox commands
255254
*
@@ -287,8 +286,6 @@ struct cxl_dev_state {
287286
resource_size_t component_reg_phys;
288287
u64 serial;
289288

290-
struct xarray doe_mbs;
291-
292289
struct cxl_event_state event;
293290

294291
int (*mbox_send)(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd);

drivers/cxl/pci.c

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <linux/mutex.h>
99
#include <linux/list.h>
1010
#include <linux/pci.h>
11-
#include <linux/pci-doe.h>
1211
#include <linux/aer.h>
1312
#include <linux/io.h>
1413
#include "cxlmem.h"
@@ -357,52 +356,6 @@ static int cxl_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type,
357356
return rc;
358357
}
359358

360-
static void cxl_pci_destroy_doe(void *mbs)
361-
{
362-
xa_destroy(mbs);
363-
}
364-
365-
static void devm_cxl_pci_create_doe(struct cxl_dev_state *cxlds)
366-
{
367-
struct device *dev = cxlds->dev;
368-
struct pci_dev *pdev = to_pci_dev(dev);
369-
u16 off = 0;
370-
371-
xa_init(&cxlds->doe_mbs);
372-
if (devm_add_action(&pdev->dev, cxl_pci_destroy_doe, &cxlds->doe_mbs)) {
373-
dev_err(dev, "Failed to create XArray for DOE's\n");
374-
return;
375-
}
376-
377-
/*
378-
* Mailbox creation is best effort. Higher layers must determine if
379-
* the lack of a mailbox for their protocol is a device failure or not.
380-
*/
381-
pci_doe_for_each_off(pdev, off) {
382-
struct pci_doe_mb *doe_mb;
383-
384-
doe_mb = pcim_doe_create_mb(pdev, off);
385-
if (IS_ERR(doe_mb)) {
386-
dev_err(dev, "Failed to create MB object for MB @ %x\n",
387-
off);
388-
continue;
389-
}
390-
391-
if (!pci_request_config_region_exclusive(pdev, off,
392-
PCI_DOE_CAP_SIZEOF,
393-
dev_name(dev)))
394-
pci_err(pdev, "Failed to exclude DOE registers\n");
395-
396-
if (xa_insert(&cxlds->doe_mbs, off, doe_mb, GFP_KERNEL)) {
397-
dev_err(dev, "xa_insert failed to insert MB @ %x\n",
398-
off);
399-
continue;
400-
}
401-
402-
dev_dbg(dev, "Created DOE mailbox @%x\n", off);
403-
}
404-
}
405-
406359
/*
407360
* Assume that any RCIEP that emits the CXL memory expander class code
408361
* is an RCD
@@ -750,8 +703,6 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
750703

751704
cxlds->component_reg_phys = map.resource;
752705

753-
devm_cxl_pci_create_doe(cxlds);
754-
755706
rc = cxl_map_component_regs(&pdev->dev, &cxlds->regs.component,
756707
&map, BIT(CXL_CM_CAP_CAP_ID_RAS));
757708
if (rc)

0 commit comments

Comments
 (0)