cxl/mbox: Use new return_code handling
authorDavidlohr Bueso <dave@stgolabs.net>
Mon, 4 Apr 2022 02:12:16 +0000 (19:12 -0700)
committerDan Williams <dan.j.williams@intel.com>
Tue, 12 Apr 2022 23:07:02 +0000 (16:07 -0700)
Use the global cxl_mbox_cmd_rc table to improve debug messaging
in __cxl_pci_mbox_send_cmd() and allow cxl_mbox_send_cmd()
to map to proper kernel style errno codes - this patch
continues to use -ENXIO only so no change in semantics.

Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
Reviewed by: Adam Manzanares <a.manzanares@samsung.com>
Link: https://lore.kernel.org/r/20220404021216.66841-5-dave@stgolabs.net
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/cxl/core/mbox.c
drivers/cxl/pci.c

index 5adc0ddb1737ba7af303b11c881ecbbdbe8f28a4..8a8388599a85fa28f08865d4771cae2e2d928616 100644 (file)
@@ -180,9 +180,8 @@ int cxl_mbox_send_cmd(struct cxl_dev_state *cxlds, u16 opcode, void *in,
        if (rc)
                return rc;
 
-       /* TODO: Map return code to proper kernel style errno */
        if (mbox_cmd.return_code != CXL_MBOX_CMD_RC_SUCCESS)
-               return -ENXIO;
+               return cxl_mbox_cmd_rc2errno(&mbox_cmd);
 
        /*
         * Variable sized commands can't be validated and so it's up to the
index 88fcd6cc38a36db4faca857eee814a088f0a1634..39694cc63381da76beea4bd803ddd4260c679652 100644 (file)
@@ -178,7 +178,8 @@ static int __cxl_pci_mbox_send_cmd(struct cxl_dev_state *cxlds,
                FIELD_GET(CXLDEV_MBOX_STATUS_RET_CODE_MASK, status_reg);
 
        if (mbox_cmd->return_code != CXL_MBOX_CMD_RC_SUCCESS) {
-               dev_dbg(dev, "Mailbox operation had an error\n");
+               dev_dbg(dev, "Mailbox operation had an error: %s\n",
+                       cxl_mbox_cmd_rc2str(mbox_cmd));
                return 0; /* completed but caller must check return_code */
        }