All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: linux-cxl@vger.kernel.org, Ben Widawsky <ben.widawsky@intel.com>,
	"Weiny, Ira" <ira.weiny@intel.com>,
	Vishal L Verma <vishal.l.verma@intel.com>,
	"Schofield, Alison" <alison.schofield@intel.com>
Subject: Re: [PATCH 4/5] cxl/mbox: Use new return_code handling
Date: Tue, 29 Mar 2022 17:24:27 -0700	[thread overview]
Message-ID: <CAPcyv4i=tV1dL3V=jCeZuxLbfqH8K0RCmQkutvnhxuqc3Z4rgw@mail.gmail.com> (raw)
In-Reply-To: <20220317234049.69323-5-dave@stgolabs.net>

On Thu, Mar 17, 2022 at 4:41 PM Davidlohr Bueso <dave@stgolabs.net> wrote:
>
> 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>
> ---
>  drivers/cxl/core/mbox.c | 7 ++++---
>  drivers/cxl/pci.c       | 3 ++-
>  2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
> index d4d4a16820b7..fa9e7043f158 100644
> --- a/drivers/cxl/core/mbox.c
> +++ b/drivers/cxl/core/mbox.c
> @@ -170,9 +170,10 @@ 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;
> +       if (mbox_cmd.return_code != CXL_MBOX_CMD_RC_SUCCESS) {
> +               int err = cxl_mbox_cmd_rc2errno(&mbox_cmd);
> +               return -err;

I don't like the need for a local variable and adding the negation.
Just store the negative value directly and call the helper
cxl_mbox_cmd_rc2err() so that this can just do "return
cxl_mbox_cmd_rc2err(&mbox_cmd);".

> +       }
>
>         /*
>          * Variable sized commands can't be validated and so it's up to the
> diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
> index 0c36d111232b..67ec0220826f 100644
> --- a/drivers/cxl/pci.c
> +++ b/drivers/cxl/pci.c
> @@ -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));

Looks good.

  parent reply	other threads:[~2022-03-30  0:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-17 23:40 [PATCH 0/5] cxl/mbox: Robustify handling of mbox_cmd.return_code Davidlohr Bueso
2022-03-17 23:40 ` [PATCH 1/5] cxl/mbox: Move mbox_mutex usage comment Davidlohr Bueso
     [not found]   ` <CGME20220322192819uscas1p295d53f4302435e98c58de1226fb2a1db@uscas1p2.samsung.com>
2022-03-22 19:28     ` Adam Manzanares
2022-03-29 22:40   ` Dan Williams
2022-03-17 23:40 ` [PATCH 2/5] cxl/pci: Use CXL_MBOX_SUCCESS to check against mbox_cmd return code Davidlohr Bueso
     [not found]   ` <CGME20220322203027uscas1p1b141b932ca4659a7b2cee1faf9dddf50@uscas1p1.samsung.com>
2022-03-22 20:30     ` Adam Manzanares
2022-03-29 23:42   ` Dan Williams
2022-03-30  0:21     ` Dan Williams
2022-03-17 23:40 ` [PATCH 3/5] cxl/mbox: Improve handling of mbox_cmd return codes Davidlohr Bueso
     [not found]   ` <CGME20220322205612uscas1p17d7f32b9b23dbadc106ae0daf69477f9@uscas1p1.samsung.com>
2022-03-22 20:56     ` Adam Manzanares
2022-03-22 21:50       ` Davidlohr Bueso
2022-03-30  0:18   ` Dan Williams
2022-03-17 23:40 ` [PATCH 4/5] cxl/mbox: Use new return_code handling Davidlohr Bueso
     [not found]   ` <CGME20220322210159uscas1p2b7bfb832c275068e1a159cc1183057c2@uscas1p2.samsung.com>
2022-03-22 21:01     ` Adam Manzanares
2022-03-30  0:24   ` Dan Williams [this message]
2022-03-17 23:40 ` [PATCH 5/5] cxl/mbox: Retry sending mbox command upon RETRY return_code Davidlohr Bueso
     [not found]   ` <CGME20220322211013uscas1p2fe8d81180e00417559e3971ddf5bc2fc@uscas1p2.samsung.com>
2022-03-22 21:10     ` Adam Manzanares
2022-03-30  0:42   ` Dan Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPcyv4i=tV1dL3V=jCeZuxLbfqH8K0RCmQkutvnhxuqc3Z4rgw@mail.gmail.com' \
    --to=dan.j.williams@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=ben.widawsky@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.