virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] virtio_pci: modify ENOENT to EINVAL
       [not found] <20221101111655.1947-1-angus.chen@jaguarmicro.com>
@ 2022-11-02  5:34 ` Jason Wang
       [not found]   ` <TY2PR06MB342458CA2B7B5B8FDCD3366185019@TY2PR06MB3424.apcprd06.prod.outlook.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Wang @ 2022-11-02  5:34 UTC (permalink / raw)
  To: Angus Chen; +Cc: virtualization, linux-kernel, mst

On Tue, Nov 1, 2022 at 7:17 PM Angus Chen <angus.chen@jaguarmicro.com> wrote:
>
> Virtio_crypto use max_data_queues+1 to setup vqs,
> we use vp_modern_get_num_queues to protect the vq range in setup_vq.
> We could enter index >= vp_modern_get_num_queues(mdev) in setup_vq
> if common->num_queues is not set well,and it return -ENOENT.
> It is better to use -EINVAL instead.

I'm not sure I get this. It would be better to describe:

1) what kind of issues can we see if we return -ENOENT
2) why -EINVAL can help in this case

Thanks

>
> Signed-off-by: Angus Chen <angus.chen@jaguarmicro.com>
> ---
>  drivers/virtio/virtio_pci_modern.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
> index c3b9f2761849..edf2e18014cd 100644
> --- a/drivers/virtio/virtio_pci_modern.c
> +++ b/drivers/virtio/virtio_pci_modern.c
> @@ -303,7 +303,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
>         int err;
>
>         if (index >= vp_modern_get_num_queues(mdev))
> -               return ERR_PTR(-ENOENT);
> +               return ERR_PTR(-EINVAL);
>
>         /* Check if queue is either not available or already active. */
>         num = vp_modern_get_queue_size(mdev, index);
> --
> 2.25.1
>

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [PATCH] virtio_pci: modify ENOENT to EINVAL
       [not found]   ` <TY2PR06MB342458CA2B7B5B8FDCD3366185019@TY2PR06MB3424.apcprd06.prod.outlook.com>
@ 2022-11-10  3:47     ` Jason Wang
  2022-11-10  5:04     ` Michael S. Tsirkin
  1 sibling, 0 replies; 4+ messages in thread
From: Jason Wang @ 2022-11-10  3:47 UTC (permalink / raw)
  To: Angus Chen
  Cc: virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, mst@redhat.com

On Thu, Nov 10, 2022 at 11:31 AM Angus Chen <angus.chen@jaguarmicro.com> wrote:
>
> Hi Jason.
>
> > -----Original Message-----
> > From: Jason Wang <jasowang@redhat.com>
> > Sent: Wednesday, November 2, 2022 1:34 PM
> > To: Angus Chen <angus.chen@jaguarmicro.com>
> > Cc: mst@redhat.com; virtualization@lists.linux-foundation.org;
> > linux-kernel@vger.kernel.org; lingshan.zhu@intel.com
> > Subject: Re: [PATCH] virtio_pci: modify ENOENT to EINVAL
> >
> > On Tue, Nov 1, 2022 at 7:17 PM Angus Chen <angus.chen@jaguarmicro.com>
> > wrote:
> > >
> > > Virtio_crypto use max_data_queues+1 to setup vqs,
> > > we use vp_modern_get_num_queues to protect the vq range in setup_vq.
> > > We could enter index >= vp_modern_get_num_queues(mdev) in setup_vq
> > > if common->num_queues is not set well,and it return -ENOENT.
> > > It is better to use -EINVAL instead.
> >
> > I'm not sure I get this. It would be better to describe:
> >
> > 1) what kind of issues can we see if we return -ENOENT
> > 2) why -EINVAL can help in this case
> >
> > Thanks
> Thank you for your reply.
> We use a robot to test our dpu to get the return value of probe.
>  We often get ENOENT form ' setup_vq ' function because of device error.
> Most of time, my device can't handle queue_enable well.
> This time,we get 'ENOENT' because the device set max_data_queues bigger than num_queues.

Ok, I see, ENOENT is not very popular on linux but I'm not sure it's
worth bothering.

>
> I think EINVAL is used when the value of some parameter is wrong.
> Btw,it not a big deal,I can modify the robot to workaround.

Btw, the error code is not a part of the ABI, so depending on that is
kind of fragile.

Thanks

>
> >
> > >
> > > Signed-off-by: Angus Chen <angus.chen@jaguarmicro.com>
> > > ---
> > >  drivers/virtio/virtio_pci_modern.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/virtio/virtio_pci_modern.c
> > b/drivers/virtio/virtio_pci_modern.c
> > > index c3b9f2761849..edf2e18014cd 100644
> > > --- a/drivers/virtio/virtio_pci_modern.c
> > > +++ b/drivers/virtio/virtio_pci_modern.c
> > > @@ -303,7 +303,7 @@ static struct virtqueue *setup_vq(struct
> > virtio_pci_device *vp_dev,
> > >         int err;
> > >
> > >         if (index >= vp_modern_get_num_queues(mdev))
> > > -               return ERR_PTR(-ENOENT);
> > > +               return ERR_PTR(-EINVAL);
> > >
> > >         /* Check if queue is either not available or already active. */
> > >         num = vp_modern_get_queue_size(mdev, index);
> > > --
> > > 2.25.1
> > >
>

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [PATCH] virtio_pci: modify ENOENT to EINVAL
       [not found]   ` <TY2PR06MB342458CA2B7B5B8FDCD3366185019@TY2PR06MB3424.apcprd06.prod.outlook.com>
  2022-11-10  3:47     ` Jason Wang
@ 2022-11-10  5:04     ` Michael S. Tsirkin
  2022-11-10  5:19       ` Jason Wang
  1 sibling, 1 reply; 4+ messages in thread
From: Michael S. Tsirkin @ 2022-11-10  5:04 UTC (permalink / raw)
  To: Angus Chen
  Cc: linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org

On Thu, Nov 10, 2022 at 03:30:59AM +0000, Angus Chen wrote:
> Hi Jason.
> 
> > -----Original Message-----
> > From: Jason Wang <jasowang@redhat.com>
> > Sent: Wednesday, November 2, 2022 1:34 PM
> > To: Angus Chen <angus.chen@jaguarmicro.com>
> > Cc: mst@redhat.com; virtualization@lists.linux-foundation.org;
> > linux-kernel@vger.kernel.org; lingshan.zhu@intel.com
> > Subject: Re: [PATCH] virtio_pci: modify ENOENT to EINVAL
> > 
> > On Tue, Nov 1, 2022 at 7:17 PM Angus Chen <angus.chen@jaguarmicro.com>
> > wrote:
> > >
> > > Virtio_crypto use max_data_queues+1 to setup vqs,
> > > we use vp_modern_get_num_queues to protect the vq range in setup_vq.
> > > We could enter index >= vp_modern_get_num_queues(mdev) in setup_vq
> > > if common->num_queues is not set well,and it return -ENOENT.
> > > It is better to use -EINVAL instead.
> > 
> > I'm not sure I get this. It would be better to describe:
> > 
> > 1) what kind of issues can we see if we return -ENOENT
> > 2) why -EINVAL can help in this case
> > 
> > Thanks
> Thank you for your reply.
> We use a robot to test our dpu to get the return value of probe.
>  We often get ENOENT form ' setup_vq ' function because of device error.
> Most of time, my device can't handle queue_enable well.
> This time,we get 'ENOENT' because the device set max_data_queues bigger than num_queues.
> 
> I think EINVAL is used when the value of some parameter is wrong.

I think I agree. Jason?

> Btw,it not a big deal,I can modify the robot to workaround.
> 
> > 
> > >
> > > Signed-off-by: Angus Chen <angus.chen@jaguarmicro.com>
> > > ---
> > >  drivers/virtio/virtio_pci_modern.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/virtio/virtio_pci_modern.c
> > b/drivers/virtio/virtio_pci_modern.c
> > > index c3b9f2761849..edf2e18014cd 100644
> > > --- a/drivers/virtio/virtio_pci_modern.c
> > > +++ b/drivers/virtio/virtio_pci_modern.c
> > > @@ -303,7 +303,7 @@ static struct virtqueue *setup_vq(struct
> > virtio_pci_device *vp_dev,
> > >         int err;
> > >
> > >         if (index >= vp_modern_get_num_queues(mdev))
> > > -               return ERR_PTR(-ENOENT);
> > > +               return ERR_PTR(-EINVAL);
> > >
> > >         /* Check if queue is either not available or already active. */
> > >         num = vp_modern_get_queue_size(mdev, index);
> > > --
> > > 2.25.1
> > >
> 

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [PATCH] virtio_pci: modify ENOENT to EINVAL
  2022-11-10  5:04     ` Michael S. Tsirkin
@ 2022-11-10  5:19       ` Jason Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Wang @ 2022-11-10  5:19 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, Angus Chen

On Thu, Nov 10, 2022 at 1:04 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Thu, Nov 10, 2022 at 03:30:59AM +0000, Angus Chen wrote:
> > Hi Jason.
> >
> > > -----Original Message-----
> > > From: Jason Wang <jasowang@redhat.com>
> > > Sent: Wednesday, November 2, 2022 1:34 PM
> > > To: Angus Chen <angus.chen@jaguarmicro.com>
> > > Cc: mst@redhat.com; virtualization@lists.linux-foundation.org;
> > > linux-kernel@vger.kernel.org; lingshan.zhu@intel.com
> > > Subject: Re: [PATCH] virtio_pci: modify ENOENT to EINVAL
> > >
> > > On Tue, Nov 1, 2022 at 7:17 PM Angus Chen <angus.chen@jaguarmicro.com>
> > > wrote:
> > > >
> > > > Virtio_crypto use max_data_queues+1 to setup vqs,
> > > > we use vp_modern_get_num_queues to protect the vq range in setup_vq.
> > > > We could enter index >= vp_modern_get_num_queues(mdev) in setup_vq
> > > > if common->num_queues is not set well,and it return -ENOENT.
> > > > It is better to use -EINVAL instead.
> > >
> > > I'm not sure I get this. It would be better to describe:
> > >
> > > 1) what kind of issues can we see if we return -ENOENT
> > > 2) why -EINVAL can help in this case
> > >
> > > Thanks
> > Thank you for your reply.
> > We use a robot to test our dpu to get the return value of probe.
> >  We often get ENOENT form ' setup_vq ' function because of device error.
> > Most of time, my device can't handle queue_enable well.
> > This time,we get 'ENOENT' because the device set max_data_queues bigger than num_queues.
> >
> > I think EINVAL is used when the value of some parameter is wrong.
>
> I think I agree. Jason?

I'm fine with this then.

Thanks

>
> > Btw,it not a big deal,I can modify the robot to workaround.
> >
> > >
> > > >
> > > > Signed-off-by: Angus Chen <angus.chen@jaguarmicro.com>
> > > > ---
> > > >  drivers/virtio/virtio_pci_modern.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/virtio/virtio_pci_modern.c
> > > b/drivers/virtio/virtio_pci_modern.c
> > > > index c3b9f2761849..edf2e18014cd 100644
> > > > --- a/drivers/virtio/virtio_pci_modern.c
> > > > +++ b/drivers/virtio/virtio_pci_modern.c
> > > > @@ -303,7 +303,7 @@ static struct virtqueue *setup_vq(struct
> > > virtio_pci_device *vp_dev,
> > > >         int err;
> > > >
> > > >         if (index >= vp_modern_get_num_queues(mdev))
> > > > -               return ERR_PTR(-ENOENT);
> > > > +               return ERR_PTR(-EINVAL);
> > > >
> > > >         /* Check if queue is either not available or already active. */
> > > >         num = vp_modern_get_queue_size(mdev, index);
> > > > --
> > > > 2.25.1
> > > >
> >
>

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

end of thread, other threads:[~2022-11-10  5:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20221101111655.1947-1-angus.chen@jaguarmicro.com>
2022-11-02  5:34 ` [PATCH] virtio_pci: modify ENOENT to EINVAL Jason Wang
     [not found]   ` <TY2PR06MB342458CA2B7B5B8FDCD3366185019@TY2PR06MB3424.apcprd06.prod.outlook.com>
2022-11-10  3:47     ` Jason Wang
2022-11-10  5:04     ` Michael S. Tsirkin
2022-11-10  5:19       ` Jason Wang

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).