Skip to content

Commit 58709b9

Browse files
l1kdjbw
authored andcommitted
cxl/pci: Use synchronous API for DOE
A synchronous API for DOE has just been introduced. Convert CXL CDAT retrieval over to it. 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> Cc: Dan Williams <dan.j.williams@intel.com> Link: https://lore.kernel.org/r/c329c0a21c11c3b524ce2336b0bbb3c80a28c415.1678543498.git.lukas@wunner.de Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 62e8b17 commit 58709b9

1 file changed

Lines changed: 22 additions & 44 deletions

File tree

drivers/cxl/core/pci.c

Lines changed: 22 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -469,51 +469,26 @@ static struct pci_doe_mb *find_cdat_doe(struct device *uport)
469469
CXL_DOE_TABLE_ACCESS_TABLE_TYPE_CDATA) | \
470470
FIELD_PREP(CXL_DOE_TABLE_ACCESS_ENTRY_HANDLE, (entry_handle)))
471471

472-
static void cxl_doe_task_complete(struct pci_doe_task *task)
473-
{
474-
complete(task->private);
475-
}
476-
477-
struct cdat_doe_task {
478-
__le32 request_pl;
479-
__le32 response_pl[32];
480-
struct completion c;
481-
struct pci_doe_task task;
482-
};
483-
484-
#define DECLARE_CDAT_DOE_TASK(req, cdt) \
485-
struct cdat_doe_task cdt = { \
486-
.c = COMPLETION_INITIALIZER_ONSTACK(cdt.c), \
487-
.request_pl = req, \
488-
.task = { \
489-
.prot.vid = PCI_DVSEC_VENDOR_ID_CXL, \
490-
.prot.type = CXL_DOE_PROTOCOL_TABLE_ACCESS, \
491-
.request_pl = &cdt.request_pl, \
492-
.request_pl_sz = sizeof(cdt.request_pl), \
493-
.response_pl = cdt.response_pl, \
494-
.response_pl_sz = sizeof(cdt.response_pl), \
495-
.complete = cxl_doe_task_complete, \
496-
.private = &cdt.c, \
497-
} \
498-
}
499-
500472
static int cxl_cdat_get_length(struct device *dev,
501473
struct pci_doe_mb *cdat_doe,
502474
size_t *length)
503475
{
504-
DECLARE_CDAT_DOE_TASK(CDAT_DOE_REQ(0), t);
476+
__le32 request = CDAT_DOE_REQ(0);
477+
__le32 response[32];
505478
int rc;
506479

507-
rc = pci_doe_submit_task(cdat_doe, &t.task);
480+
rc = pci_doe(cdat_doe, PCI_DVSEC_VENDOR_ID_CXL,
481+
CXL_DOE_PROTOCOL_TABLE_ACCESS,
482+
&request, sizeof(request),
483+
&response, sizeof(response));
508484
if (rc < 0) {
509-
dev_err(dev, "DOE submit failed: %d", rc);
485+
dev_err(dev, "DOE failed: %d", rc);
510486
return rc;
511487
}
512-
wait_for_completion(&t.c);
513-
if (t.task.rv < 2 * sizeof(__le32))
488+
if (rc < 2 * sizeof(__le32))
514489
return -EIO;
515490

516-
*length = le32_to_cpu(t.response_pl[1]);
491+
*length = le32_to_cpu(response[1]);
517492
dev_dbg(dev, "CDAT length %zu\n", *length);
518493

519494
return 0;
@@ -528,31 +503,34 @@ static int cxl_cdat_read_table(struct device *dev,
528503
int entry_handle = 0;
529504

530505
do {
531-
DECLARE_CDAT_DOE_TASK(CDAT_DOE_REQ(entry_handle), t);
506+
__le32 request = CDAT_DOE_REQ(entry_handle);
532507
struct cdat_entry_header *entry;
508+
__le32 response[32];
533509
size_t entry_dw;
534510
int rc;
535511

536-
rc = pci_doe_submit_task(cdat_doe, &t.task);
512+
rc = pci_doe(cdat_doe, PCI_DVSEC_VENDOR_ID_CXL,
513+
CXL_DOE_PROTOCOL_TABLE_ACCESS,
514+
&request, sizeof(request),
515+
&response, sizeof(response));
537516
if (rc < 0) {
538-
dev_err(dev, "DOE submit failed: %d", rc);
517+
dev_err(dev, "DOE failed: %d", rc);
539518
return rc;
540519
}
541-
wait_for_completion(&t.c);
542520

543521
/* 1 DW Table Access Response Header + CDAT entry */
544-
entry = (struct cdat_entry_header *)(t.response_pl + 1);
522+
entry = (struct cdat_entry_header *)(response + 1);
545523
if ((entry_handle == 0 &&
546-
t.task.rv != sizeof(__le32) + sizeof(struct cdat_header)) ||
524+
rc != sizeof(__le32) + sizeof(struct cdat_header)) ||
547525
(entry_handle > 0 &&
548-
(t.task.rv < sizeof(__le32) + sizeof(*entry) ||
549-
t.task.rv != sizeof(__le32) + le16_to_cpu(entry->length))))
526+
(rc < sizeof(__le32) + sizeof(*entry) ||
527+
rc != sizeof(__le32) + le16_to_cpu(entry->length))))
550528
return -EIO;
551529

552530
/* Get the CXL table access header entry handle */
553531
entry_handle = FIELD_GET(CXL_DOE_TABLE_ACCESS_ENTRY_HANDLE,
554-
le32_to_cpu(t.response_pl[0]));
555-
entry_dw = t.task.rv / sizeof(__le32);
532+
le32_to_cpu(response[0]));
533+
entry_dw = rc / sizeof(__le32);
556534
/* Skip Header */
557535
entry_dw -= 1;
558536
entry_dw = min(length / sizeof(__le32), entry_dw);

0 commit comments

Comments
 (0)