linux-nvdimm.lists.01.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libnvdimm/bus: return the outvar 'cmd_rc' error code in __nd_ioctl()
@ 2020-01-22 15:53 Vaibhav Jain
  2020-02-18 21:00 ` Jeff Moyer
  0 siblings, 1 reply; 5+ messages in thread
From: Vaibhav Jain @ 2020-01-22 15:53 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: Vaibhav Jain, Aneesh Kumar K.V, linuxppc-dev

Presently the error code returned via out variable 'cmd_rc' from the
nvdimm-bus controller function is ignored when called from
__nd_ioctl() and never communicated back to user-space code that called
an ioctl on dimm/bus.

This minor patch updates __nd_ioctl() to propagate the value of out
variable 'cmd_rc' back to user-space in case it reports an error.

Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
---
 drivers/nvdimm/bus.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index a8b515968569..5b687a27fdf2 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -1153,6 +1153,11 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
 	if (rc < 0)
 		goto out_unlock;
 
+	if (cmd_rc < 0) {
+		rc = cmd_rc;
+		goto out_unlock;
+	}
+
 	if (!nvdimm && cmd == ND_CMD_CLEAR_ERROR && cmd_rc >= 0) {
 		struct nd_cmd_clear_error *clear_err = buf;
 
-- 
2.24.1
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] libnvdimm/bus: return the outvar 'cmd_rc' error code in __nd_ioctl()
  2020-01-22 15:53 [PATCH] libnvdimm/bus: return the outvar 'cmd_rc' error code in __nd_ioctl() Vaibhav Jain
@ 2020-02-18 21:00 ` Jeff Moyer
  2020-02-18 21:03   ` Dan Williams
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Moyer @ 2020-02-18 21:00 UTC (permalink / raw)
  To: Vaibhav Jain; +Cc: linux-nvdimm, Aneesh Kumar K.V, linuxppc-dev

Vaibhav Jain <vaibhav@linux.ibm.com> writes:

> Presently the error code returned via out variable 'cmd_rc' from the
> nvdimm-bus controller function is ignored when called from
> __nd_ioctl() and never communicated back to user-space code that called
> an ioctl on dimm/bus.
>
> This minor patch updates __nd_ioctl() to propagate the value of out
> variable 'cmd_rc' back to user-space in case it reports an error.
>
> Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
> ---
>  drivers/nvdimm/bus.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
> index a8b515968569..5b687a27fdf2 100644
> --- a/drivers/nvdimm/bus.c
> +++ b/drivers/nvdimm/bus.c
> @@ -1153,6 +1153,11 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
>  	if (rc < 0)
>  		goto out_unlock;
>  
> +	if (cmd_rc < 0) {
> +		rc = cmd_rc;
> +		goto out_unlock;
> +	}
> +
>  	if (!nvdimm && cmd == ND_CMD_CLEAR_ERROR && cmd_rc >= 0) {
>  		struct nd_cmd_clear_error *clear_err = buf;

Looks good to me.

Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] libnvdimm/bus: return the outvar 'cmd_rc' error code in __nd_ioctl()
  2020-02-18 21:00 ` Jeff Moyer
@ 2020-02-18 21:03   ` Dan Williams
  2020-02-29  2:37     ` Dan Williams
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Williams @ 2020-02-18 21:03 UTC (permalink / raw)
  To: Jeff Moyer; +Cc: Vaibhav Jain, linux-nvdimm, Aneesh Kumar K.V, linuxppc-dev

On Tue, Feb 18, 2020 at 1:00 PM Jeff Moyer <jmoyer@redhat.com> wrote:
>
> Vaibhav Jain <vaibhav@linux.ibm.com> writes:
>
> > Presently the error code returned via out variable 'cmd_rc' from the
> > nvdimm-bus controller function is ignored when called from
> > __nd_ioctl() and never communicated back to user-space code that called
> > an ioctl on dimm/bus.
> >
> > This minor patch updates __nd_ioctl() to propagate the value of out
> > variable 'cmd_rc' back to user-space in case it reports an error.
> >
> > Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
> > ---
> >  drivers/nvdimm/bus.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
> > index a8b515968569..5b687a27fdf2 100644
> > --- a/drivers/nvdimm/bus.c
> > +++ b/drivers/nvdimm/bus.c
> > @@ -1153,6 +1153,11 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
> >       if (rc < 0)
> >               goto out_unlock;
> >
> > +     if (cmd_rc < 0) {
> > +             rc = cmd_rc;
> > +             goto out_unlock;
> > +     }
> > +
> >       if (!nvdimm && cmd == ND_CMD_CLEAR_ERROR && cmd_rc >= 0) {
> >               struct nd_cmd_clear_error *clear_err = buf;
>
> Looks good to me.
>
> Reviewed-by: Jeff Moyer <jmoyer@redhat.com>

Applied.
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] libnvdimm/bus: return the outvar 'cmd_rc' error code in __nd_ioctl()
  2020-02-18 21:03   ` Dan Williams
@ 2020-02-29  2:37     ` Dan Williams
  2020-03-02  4:21       ` Vaibhav Jain
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Williams @ 2020-02-29  2:37 UTC (permalink / raw)
  To: Jeff Moyer; +Cc: Vaibhav Jain, linux-nvdimm, Aneesh Kumar K.V, linuxppc-dev

On Tue, Feb 18, 2020 at 1:03 PM Dan Williams <dan.j.williams@intel.com> wrote:
>
> On Tue, Feb 18, 2020 at 1:00 PM Jeff Moyer <jmoyer@redhat.com> wrote:
> >
> > Vaibhav Jain <vaibhav@linux.ibm.com> writes:
> >
> > > Presently the error code returned via out variable 'cmd_rc' from the
> > > nvdimm-bus controller function is ignored when called from
> > > __nd_ioctl() and never communicated back to user-space code that called
> > > an ioctl on dimm/bus.
> > >
> > > This minor patch updates __nd_ioctl() to propagate the value of out
> > > variable 'cmd_rc' back to user-space in case it reports an error.
> > >
> > > Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
> > > ---
> > >  drivers/nvdimm/bus.c | 5 +++++
> > >  1 file changed, 5 insertions(+)
> > >
> > > diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
> > > index a8b515968569..5b687a27fdf2 100644
> > > --- a/drivers/nvdimm/bus.c
> > > +++ b/drivers/nvdimm/bus.c
> > > @@ -1153,6 +1153,11 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
> > >       if (rc < 0)
> > >               goto out_unlock;
> > >
> > > +     if (cmd_rc < 0) {
> > > +             rc = cmd_rc;
> > > +             goto out_unlock;
> > > +     }
> > > +
> > >       if (!nvdimm && cmd == ND_CMD_CLEAR_ERROR && cmd_rc >= 0) {
> > >               struct nd_cmd_clear_error *clear_err = buf;
> >
> > Looks good to me.
> >
> > Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
>
> Applied.

Unapplied. This breaks the NVDIMM unit test, and now that I look
closer you are likely overlooking the fact that cmd_rc is a
translation of the firmware status, while the ioctl rc is whether the
command was successfully submitted. If you want the equivalent of
cmd_rc in userspace you need to translate the firmware status. See
ndctl_cmd_submit_xlat() in libndctl as an example of how the
equivalent of cmd_rc is generated from the firmware status.
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] libnvdimm/bus: return the outvar 'cmd_rc' error code in __nd_ioctl()
  2020-02-29  2:37     ` Dan Williams
@ 2020-03-02  4:21       ` Vaibhav Jain
  0 siblings, 0 replies; 5+ messages in thread
From: Vaibhav Jain @ 2020-03-02  4:21 UTC (permalink / raw)
  To: Dan Williams, Jeff Moyer
  Cc: Vaibhav Jain, linuxppc-dev, Aneesh Kumar K.V, linux-nvdimm

Hi Dan,

Apologies for responding late to this. My response below

Dan Williams <dan.j.williams@intel.com> writes:

> On Tue, Feb 18, 2020 at 1:03 PM Dan Williams <dan.j.williams@intel.com> wrote:
>>
>> On Tue, Feb 18, 2020 at 1:00 PM Jeff Moyer <jmoyer@redhat.com> wrote:
>> >
>> > Vaibhav Jain <vaibhav@linux.ibm.com> writes:
>> >
>> > > Presently the error code returned via out variable 'cmd_rc' from the
>> > > nvdimm-bus controller function is ignored when called from
>> > > __nd_ioctl() and never communicated back to user-space code that called
>> > > an ioctl on dimm/bus.
>> > >
>> > > This minor patch updates __nd_ioctl() to propagate the value of out
>> > > variable 'cmd_rc' back to user-space in case it reports an error.
>> > >
>> > > Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
>> > > ---
>> > >  drivers/nvdimm/bus.c | 5 +++++
>> > >  1 file changed, 5 insertions(+)
>> > >
>> > > diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
>> > > index a8b515968569..5b687a27fdf2 100644
>> > > --- a/drivers/nvdimm/bus.c
>> > > +++ b/drivers/nvdimm/bus.c
>> > > @@ -1153,6 +1153,11 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
>> > >       if (rc < 0)
>> > >               goto out_unlock;
>> > >
>> > > +     if (cmd_rc < 0) {
>> > > +             rc = cmd_rc;
>> > > +             goto out_unlock;
>> > > +     }
>> > > +
>> > >       if (!nvdimm && cmd == ND_CMD_CLEAR_ERROR && cmd_rc >= 0) {
>> > >               struct nd_cmd_clear_error *clear_err = buf;
>> >
>> > Looks good to me.
>> >
>> > Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
>>
>> Applied.
>
> Unapplied. This breaks the NVDIMM unit test, and now that I look
> closer you are likely overlooking the fact that cmd_rc is a
> translation of the firmware status, while the ioctl rc is whether the
> command was successfully submitted. If you want the equivalent of
> cmd_rc in userspace you need to translate the firmware status. See
> ndctl_cmd_submit_xlat() in libndctl as an example of how the
> equivalent of cmd_rc is generated from the firmware status.

This seems to be departure from rest of the libndvdimm where a non zero
value of out-var 'cmd_rc' is treated as an error and communicated back to the
caller. 

However I agree to the points you made that semantics for __nd_ioctl()
are different hence 'cmd_rc' need not be treated the same way as others.
I think it will be better if these points are documented as
code-comments in this function to make it more clearer as to why
negative value 'cmd_rd' will be ignored and how userspace can get hold
of it if needed.

-- 
Vaibhav Jain <vaibhav@linux.ibm.com>
Linux Technology Center, IBM India Pvt. Ltd.
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-02  4:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-22 15:53 [PATCH] libnvdimm/bus: return the outvar 'cmd_rc' error code in __nd_ioctl() Vaibhav Jain
2020-02-18 21:00 ` Jeff Moyer
2020-02-18 21:03   ` Dan Williams
2020-02-29  2:37     ` Dan Williams
2020-03-02  4:21       ` Vaibhav Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).