diff mbox series

[5/9] cxl/pci: Don't poll doorbell for mailbox access

Message ID 20211129214721.1668325-6-ben.widawsky@intel.com
State New, archived
Headers show
Series CXL port prep work | expand

Commit Message

Ben Widawsky Nov. 29, 2021, 9:47 p.m. UTC
The expectation is that the mailbox interface ready bit will be set at
the start of any access through the mailbox interface. Therefore,
waiting for the doorbell busy bit to be clear would imply that the
mailbox interface is ready. The original driver implementation used the
doorbell timeout for the Mailbox Interface Ready bit to piggyback off
of, since the latter doesn't have a defined timeout (introduced in
commit 8adaf747c9f0 ("cxl/mem: Find device capabilities"), a timeout has
since been defined with an ECN to the 2.0 spec). With the current driver
waiting for mailbox interface ready as a part of probe() it's no longer
necessary to use the piggyback.

With the piggybacking no longer necessary it doesn't make sense to check
doorbell status when acquiring the mailbox. It will be checked during
the normal mailbox exchange protocol.

While here, make minor whitespace fix in the comment describing the
behavior.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> (v1)
Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
---
Changes since v1:
Reword commit message (Jonathan)
Drop comment block altogether (Dan)
Don't check IF ready in mbox_get() (Dan)
---
 drivers/cxl/pci.c | 36 +-----------------------------------
 1 file changed, 1 insertion(+), 35 deletions(-)
diff mbox series

Patch

diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
index b28c220d48ea..ada0d67c8194 100644
--- a/drivers/cxl/pci.c
+++ b/drivers/cxl/pci.c
@@ -219,46 +219,12 @@  static int cxl_pci_mbox_get(struct cxl_dev_state *cxlds)
 
 	mutex_lock_io(&cxlds->mbox_mutex);
 
-	/*
-	 * XXX: There is some amount of ambiguity in the 2.0 version of the spec
-	 * around the mailbox interface ready (8.2.8.5.1.1).  The purpose of the
-	 * bit is to allow firmware running on the device to notify the driver
-	 * that it's ready to receive commands. It is unclear if the bit needs
-	 * to be read for each transaction mailbox, ie. the firmware can switch
-	 * it on and off as needed. Second, there is no defined timeout for
-	 * mailbox ready, like there is for the doorbell interface.
-	 *
-	 * Assumptions:
-	 * 1. The firmware might toggle the Mailbox Interface Ready bit, check
-	 *    it for every command.
-	 *
-	 * 2. If the doorbell is clear, the firmware should have first set the
-	 *    Mailbox Interface Ready bit. Therefore, waiting for the doorbell
-	 *    to be ready is sufficient.
-	 */
-	rc = cxl_pci_mbox_wait_for_doorbell(cxlds);
-	if (rc) {
-		dev_warn(dev, "Mailbox interface not ready\n");
-		goto out;
-	}
-
-	md_status = readq(cxlds->regs.memdev + CXLMDEV_STATUS_OFFSET);
-	if (!(md_status & CXLMDEV_MBOX_IF_READY && CXLMDEV_READY(md_status))) {
-		dev_err(dev, "mbox: reported doorbell ready, but not mbox ready\n");
-		rc = -EBUSY;
-		goto out;
-	}
-
-	/*
-	 * Hardware shouldn't allow a ready status but also have failure bits
-	 * set. Spit out an error, this should be a bug report
-	 */
 	rc = check_device_status(cxlds);
 	if (rc)
 		goto out;
 
 	if (CXLMDEV_RESET_NEEDED(md_status)) {
-		dev_err(dev, "mbox: reported ready, but reset needed\n");
+		dev_err(dev, "mbox: reset needed\n");
 		rc = -EFAULT;
 		goto out;
 	}