DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev]  [PATCH] bus/pci: fix vfio device reset
@ 2017-10-28  6:22 Jerin Jacob
  2017-10-28 10:54 ` Jonas Pfefferle1
  0 siblings, 1 reply; 3+ messages in thread
From: Jerin Jacob @ 2017-10-28  6:22 UTC (permalink / raw)
  To: dev; +Cc: thomas, Jerin Jacob, Jonas Pfefferle, Anatoly Burakov

If the device is not capable of resetting, then Linux kernel updates
the errno as EINVAL.
http://elixir.free-electrons.com/linux/v4.9/source/drivers/vfio/pci/vfio_pci.c#L887

Honor the EINVAL errno value to avoid pci vfio setup failure.

Fixes: f25f8f367644 ("bus/pci: check VFIO reset ioctl error")

Cc: Jonas Pfefferle <jpf@zurich.ibm.com>
Cc: Anatoly Burakov <anatoly.burakov@intel.com>

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 drivers/bus/pci/linux/pci_vfio.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index 360eed380..11df64846 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -338,8 +338,11 @@ pci_vfio_setup_device(struct rte_pci_device *dev, int vfio_dev_fd)
 		return -1;
 	}
 
-	/* Reset the device */
-	if (ioctl(vfio_dev_fd, VFIO_DEVICE_RESET)) {
+	/*
+	 * Reset the device. If the device is not capable of resetting,
+	 * then it updates errno as EINVAL.
+	 */
+	if (ioctl(vfio_dev_fd, VFIO_DEVICE_RESET) && errno != EINVAL) {
 		RTE_LOG(ERR, EAL, "Unable to reset device! Error: %d (%s)\n",
 				errno, strerror(errno));
 		return -1;
-- 
2.14.3

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

* Re: [dpdk-dev] [PATCH] bus/pci: fix vfio device reset
  2017-10-28  6:22 [dpdk-dev] [PATCH] bus/pci: fix vfio device reset Jerin Jacob
@ 2017-10-28 10:54 ` Jonas Pfefferle1
  2017-10-31 18:24   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Jonas Pfefferle1 @ 2017-10-28 10:54 UTC (permalink / raw)
  To: Jerin Jacob; +Cc: Anatoly Burakov, dev, thomas

Jerin Jacob <jerin.jacob@caviumnetworks.com> wrote on 28/10/2017 08:22:55:

> From: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> To: dev@dpdk.org
> Cc: thomas@monjalon.net, Jerin Jacob 
> <jerin.jacob@caviumnetworks.com>, Jonas Pfefferle 
> <jpf@zurich.ibm.com>, Anatoly Burakov <anatoly.burakov@intel.com>
> Date: 28/10/2017 08:23
> Subject: [dpdk-dev] [PATCH] bus/pci: fix vfio device reset
> 
> If the device is not capable of resetting, then Linux kernel updates
> the errno as EINVAL.
> https://urldefense.proofpoint.com/v2/url?
> u=http-3A__elixir.free-2Delectrons.com_linux_v4.
> 9_source_drivers_vfio_pci_vfio-5Fpci.c-23L887&d=DwIBAg&c=jf_iaSHvJObTbx-
> siA1ZOg&r=rOdXhRsgn8Iur7bDE0vgwvo6TC8OpoDN-pXjigIjRW0&m=V-
> sbOkvx7qxOMbwyk3n1Fb_1NCjAhl0io-
> hqldJ0r6M&s=OXV7lrxTpahVIsA3J3nCNUlLqW21nlMiQiYveAzyQhc&e=
> 
> Honor the EINVAL errno value to avoid pci vfio setup failure.
> 
> Fixes: f25f8f367644 ("bus/pci: check VFIO reset ioctl error")
> 
> Cc: Jonas Pfefferle <jpf@zurich.ibm.com>
> Cc: Anatoly Burakov <anatoly.burakov@intel.com>
> 
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> ---
>  drivers/bus/pci/linux/pci_vfio.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/
> linux/pci_vfio.c
> index 360eed380..11df64846 100644
> --- a/drivers/bus/pci/linux/pci_vfio.c
> +++ b/drivers/bus/pci/linux/pci_vfio.c
> @@ -338,8 +338,11 @@ pci_vfio_setup_device(struct rte_pci_device 
> *dev, int vfio_dev_fd)
>        return -1;
>     }
> 
> -   /* Reset the device */
> -   if (ioctl(vfio_dev_fd, VFIO_DEVICE_RESET)) {
> +   /*
> +    * Reset the device. If the device is not capable of resetting,
> +    * then it updates errno as EINVAL.
> +    */
> +   if (ioctl(vfio_dev_fd, VFIO_DEVICE_RESET) && errno != EINVAL) {
>        RTE_LOG(ERR, EAL, "Unable to reset device! Error: %d (%s)\n",
>              errno, strerror(errno));
>        return -1;
> -- 
> 2.14.3
> 

Looks good to me.

Reviewed-by: Jonas Pfefferle <jpf@zurich.ibm.com>

Thanks,
Jonas

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

* Re: [dpdk-dev] [PATCH] bus/pci: fix vfio device reset
  2017-10-28 10:54 ` Jonas Pfefferle1
@ 2017-10-31 18:24   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2017-10-31 18:24 UTC (permalink / raw)
  To: Jerin Jacob; +Cc: dev, Jonas Pfefferle1, Anatoly Burakov

28/10/2017 12:54, Jonas Pfefferle1:
> Jerin Jacob <jerin.jacob@caviumnetworks.com> wrote on 28/10/2017 08:22:55:
> > If the device is not capable of resetting, then Linux kernel updates
> > the errno as EINVAL.
> > https://urldefense.proofpoint.com/v2/url?
> > u=http-3A__elixir.free-2Delectrons.com_linux_v4.
> > 9_source_drivers_vfio_pci_vfio-5Fpci.c-23L887&d=DwIBAg&c=jf_iaSHvJObTbx-
> > siA1ZOg&r=rOdXhRsgn8Iur7bDE0vgwvo6TC8OpoDN-pXjigIjRW0&m=V-
> > sbOkvx7qxOMbwyk3n1Fb_1NCjAhl0io-
> > hqldJ0r6M&s=OXV7lrxTpahVIsA3J3nCNUlLqW21nlMiQiYveAzyQhc&e=
> > 
> > Honor the EINVAL errno value to avoid pci vfio setup failure.
> > 
> > Fixes: f25f8f367644 ("bus/pci: check VFIO reset ioctl error")
> > 
> > Cc: Jonas Pfefferle <jpf@zurich.ibm.com>
> > Cc: Anatoly Burakov <anatoly.burakov@intel.com>
> > 
> > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> 
> Looks good to me.
> 
> Reviewed-by: Jonas Pfefferle <jpf@zurich.ibm.com>
> 
> Thanks,
> Jonas

Applied, thanks

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

end of thread, other threads:[~2017-10-31 18:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-28  6:22 [dpdk-dev] [PATCH] bus/pci: fix vfio device reset Jerin Jacob
2017-10-28 10:54 ` Jonas Pfefferle1
2017-10-31 18:24   ` Thomas Monjalon

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