diff mbox series

[RFC,V2,01/11] cxl/mbox: Add debug of hardware error code

Message ID 20221010224131.1866246-2-ira.weiny@intel.com
State Superseded
Headers show
Series CXL: Process event logs | expand

Commit Message

Ira Weiny Oct. 10, 2022, 10:41 p.m. UTC
From: Ira Weiny <ira.weiny@intel.com>

If a mailbox command fails the driver always reports ENXIO.  But this
may not be enough information to understand why the hardware, or in my
case Qemu, was failing.

Add a debug print of the error code returned from the hardware.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
 drivers/cxl/core/mbox.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Jonathan Cameron Oct. 11, 2022, 10:41 a.m. UTC | #1
On Mon, 10 Oct 2022 15:41:21 -0700
ira.weiny@intel.com wrote:

> From: Ira Weiny <ira.weiny@intel.com>
> 
> If a mailbox command fails the driver always reports ENXIO.  But this
> may not be enough information to understand why the hardware, or in my
> case Qemu, was failing.
> 
> Add a debug print of the error code returned from the hardware.
> 
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Seems very sensible to me.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/cxl/core/mbox.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
> index 16176b9278b4..6c4d024ad0e8 100644
> --- a/drivers/cxl/core/mbox.c
> +++ b/drivers/cxl/core/mbox.c
> @@ -181,8 +181,11 @@ int cxl_mbox_send_cmd(struct cxl_dev_state *cxlds, u16 opcode, void *in,
>  	if (rc)
>  		return rc;
>  
> -	if (mbox_cmd.return_code != CXL_MBOX_CMD_RC_SUCCESS)
> +	if (mbox_cmd.return_code != CXL_MBOX_CMD_RC_SUCCESS) {
> +		dev_dbg(cxlds->dev, "MB error : %s\n",
> +			cxl_mbox_cmd_rc2str(&mbox_cmd));
>  		return cxl_mbox_cmd_rc2errno(&mbox_cmd);
> +	}
>  
>  	/*
>  	 * Variable sized commands can't be validated and so it's up to the
Davidlohr Bueso Oct. 14, 2022, 4:29 p.m. UTC | #2
On Mon, 10 Oct 2022, ira.weiny@intel.com wrote:

>From: Ira Weiny <ira.weiny@intel.com>
>
>If a mailbox command fails the driver always reports ENXIO.  But this
>may not be enough information to understand why the hardware, or in my
>case Qemu, was failing.
>
>Add a debug print of the error code returned from the hardware.

Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>

with a nit below.

>
>Signed-off-by: Ira Weiny <ira.weiny@intel.com>
>---
> drivers/cxl/core/mbox.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
>index 16176b9278b4..6c4d024ad0e8 100644
>--- a/drivers/cxl/core/mbox.c
>+++ b/drivers/cxl/core/mbox.c
>@@ -181,8 +181,11 @@ int cxl_mbox_send_cmd(struct cxl_dev_state *cxlds, u16 opcode, void *in,
>	if (rc)
>		return rc;
>
>-	if (mbox_cmd.return_code != CXL_MBOX_CMD_RC_SUCCESS)
>+	if (mbox_cmd.return_code != CXL_MBOX_CMD_RC_SUCCESS) {
>+		dev_dbg(cxlds->dev, "MB error : %s\n",

Maybe s/MB/mbox?

>+			cxl_mbox_cmd_rc2str(&mbox_cmd));
>		return cxl_mbox_cmd_rc2errno(&mbox_cmd);
>+	}
>
>	/*
>	 * Variable sized commands can't be validated and so it's up to the
>--
>2.37.2
>
Davidlohr Bueso Oct. 14, 2022, 4:31 p.m. UTC | #3
On Fri, 14 Oct 2022, Davidlohr Bueso wrote:
>>-	if (mbox_cmd.return_code != CXL_MBOX_CMD_RC_SUCCESS)
>>+	if (mbox_cmd.return_code != CXL_MBOX_CMD_RC_SUCCESS) {
>>+		dev_dbg(cxlds->dev, "MB error : %s\n",
>
>Maybe s/MB/mbox?

Actually 'Mailbox' seems to be the standard:

core/regs.c:			dev_dbg(dev, "found Mailbox capability (0x%x)\n", offset);
core/regs.c:			dev_dbg(dev, "found Secondary Mailbox capability (0x%x)\n", offset);
pci.c:		dev_dbg(dev, "Mailbox operation had an error\n");
pci.c:		dev_err(cxlds->dev, "Mailbox is too small (%zub)",
pci.c:	dev_dbg(cxlds->dev, "Mailbox payload sized %zu",
Ira Weiny Oct. 14, 2022, 5 p.m. UTC | #4
On Fri, Oct 14, 2022 at 09:31:49AM -0700, Davidlohr Bueso wrote:
> On Fri, 14 Oct 2022, Davidlohr Bueso wrote:
> > > -	if (mbox_cmd.return_code != CXL_MBOX_CMD_RC_SUCCESS)
> > > +	if (mbox_cmd.return_code != CXL_MBOX_CMD_RC_SUCCESS) {
> > > +		dev_dbg(cxlds->dev, "MB error : %s\n",
> > 
> > Maybe s/MB/mbox?
> 
> Actually 'Mailbox' seems to be the standard:

Good point!  Changed.

Thanks!
Ira

> 
> core/regs.c:			dev_dbg(dev, "found Mailbox capability (0x%x)\n", offset);
> core/regs.c:			dev_dbg(dev, "found Secondary Mailbox capability (0x%x)\n", offset);
> pci.c:		dev_dbg(dev, "Mailbox operation had an error\n");
> pci.c:		dev_err(cxlds->dev, "Mailbox is too small (%zub)",
> pci.c:	dev_dbg(cxlds->dev, "Mailbox payload sized %zu",
diff mbox series

Patch

diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
index 16176b9278b4..6c4d024ad0e8 100644
--- a/drivers/cxl/core/mbox.c
+++ b/drivers/cxl/core/mbox.c
@@ -181,8 +181,11 @@  int cxl_mbox_send_cmd(struct cxl_dev_state *cxlds, u16 opcode, void *in,
 	if (rc)
 		return rc;
 
-	if (mbox_cmd.return_code != CXL_MBOX_CMD_RC_SUCCESS)
+	if (mbox_cmd.return_code != CXL_MBOX_CMD_RC_SUCCESS) {
+		dev_dbg(cxlds->dev, "MB error : %s\n",
+			cxl_mbox_cmd_rc2str(&mbox_cmd));
 		return cxl_mbox_cmd_rc2errno(&mbox_cmd);
+	}
 
 	/*
 	 * Variable sized commands can't be validated and so it's up to the