diff mbox series

[2/5] cxl/pci: Use CXL_MBOX_SUCCESS to check against mbox_cmd return code

Message ID 20220317234049.69323-3-dave@stgolabs.net
State Superseded
Headers show
Series cxl/mbox: Robustify handling of mbox_cmd.return_code | expand

Commit Message

Davidlohr Bueso March 17, 2022, 11:40 p.m. UTC
Also mention the need for the caller to check against any
errors from the hardware in return_code.

Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
---
 drivers/cxl/pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Adam Manzanares March 22, 2022, 8:30 p.m. UTC | #1
On Thu, Mar 17, 2022 at 04:40:46PM -0700, Davidlohr Bueso wrote:
> Also mention the need for the caller to check against any
> errors from the hardware in return_code.
> 
> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
> ---
>  drivers/cxl/pci.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
> index 8a7267d116b7..c77e06aff8dc 100644
> --- a/drivers/cxl/pci.c
> +++ b/drivers/cxl/pci.c
> @@ -177,9 +177,9 @@ static int __cxl_pci_mbox_send_cmd(struct cxl_dev_state *cxlds,
>  	mbox_cmd->return_code =
>  		FIELD_GET(CXLDEV_MBOX_STATUS_RET_CODE_MASK, status_reg);
>  
> -	if (mbox_cmd->return_code != 0) {
> +	if (mbox_cmd->return_code != CXL_MBOX_SUCCESS) {
>  		dev_dbg(dev, "Mailbox operation had an error\n");
> -		return 0;
> +		return 0;  /* completed but caller must check return_code */
>  	}
>  
>  	/* #7 */
> 
> -- 
> 2.26.2
> 

Reviewed by: Adam Manzanares <a.manzanares@samsung.com>
Dan Williams March 29, 2022, 11:42 p.m. UTC | #2
On Thu, Mar 17, 2022 at 4:41 PM Davidlohr Bueso <dave@stgolabs.net> wrote:
>
> Also mention the need for the caller to check against any
> errors from the hardware in return_code.
>
> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
> ---
>  drivers/cxl/pci.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
> index 8a7267d116b7..c77e06aff8dc 100644
> --- a/drivers/cxl/pci.c
> +++ b/drivers/cxl/pci.c
> @@ -177,9 +177,9 @@ static int __cxl_pci_mbox_send_cmd(struct cxl_dev_state *cxlds,
>         mbox_cmd->return_code =
>                 FIELD_GET(CXLDEV_MBOX_STATUS_RET_CODE_MASK, status_reg);
>
> -       if (mbox_cmd->return_code != 0) {
> +       if (mbox_cmd->return_code != CXL_MBOX_SUCCESS) {
>                 dev_dbg(dev, "Mailbox operation had an error\n");
> -               return 0;
> +               return 0;  /* completed but caller must check return_code */

Looks like a good clarification to me.

Applied.

...but note it won't appear anywhere until after v5.18-rc1 is out.
Dan Williams March 30, 2022, 12:21 a.m. UTC | #3
On Tue, Mar 29, 2022 at 4:42 PM Dan Williams <dan.j.williams@intel.com> wrote:
>
> On Thu, Mar 17, 2022 at 4:41 PM Davidlohr Bueso <dave@stgolabs.net> wrote:
> >
> > Also mention the need for the caller to check against any
> > errors from the hardware in return_code.
> >
> > Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
> > ---
> >  drivers/cxl/pci.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
> > index 8a7267d116b7..c77e06aff8dc 100644
> > --- a/drivers/cxl/pci.c
> > +++ b/drivers/cxl/pci.c
> > @@ -177,9 +177,9 @@ static int __cxl_pci_mbox_send_cmd(struct cxl_dev_state *cxlds,
> >         mbox_cmd->return_code =
> >                 FIELD_GET(CXLDEV_MBOX_STATUS_RET_CODE_MASK, status_reg);
> >
> > -       if (mbox_cmd->return_code != 0) {
> > +       if (mbox_cmd->return_code != CXL_MBOX_SUCCESS) {
> >                 dev_dbg(dev, "Mailbox operation had an error\n");
> > -               return 0;
> > +               return 0;  /* completed but caller must check return_code */
>
> Looks like a good clarification to me.
>
> Applied.
>
> ...but note it won't appear anywhere until after v5.18-rc1 is out.

...although given there are already feedback comments on patch 1 and 3
I also don't mind if you resend the full series for v2.
diff mbox series

Patch

diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
index 8a7267d116b7..c77e06aff8dc 100644
--- a/drivers/cxl/pci.c
+++ b/drivers/cxl/pci.c
@@ -177,9 +177,9 @@  static int __cxl_pci_mbox_send_cmd(struct cxl_dev_state *cxlds,
 	mbox_cmd->return_code =
 		FIELD_GET(CXLDEV_MBOX_STATUS_RET_CODE_MASK, status_reg);
 
-	if (mbox_cmd->return_code != 0) {
+	if (mbox_cmd->return_code != CXL_MBOX_SUCCESS) {
 		dev_dbg(dev, "Mailbox operation had an error\n");
-		return 0;
+		return 0;  /* completed but caller must check return_code */
 	}
 
 	/* #7 */