[v3,2/2] net/virtio: avoid annoying IOPL call related errors

Message ID 20181123153920.12398-3-i.maximets@samsung.com (mailing list archive)
State Accepted, archived
Headers
Series IOPL related fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ilya Maximets Nov. 23, 2018, 3:39 p.m. UTC
  In case of running with not enough capabilities, i.e. running as
non-root user any application linked with DPDK prints the message
about IOPL call failure even if it was just called like
'./testpmd --help'. For example, this breaks most of the OVS unit
tests if it built with DPDK support.

Let's register the virtio driver unconditionally and print error
message while probing the device. Silent iopl() call left in the
constructor to have privileges as early as possible as it was before.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/virtio/virtio_ethdev.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
  

Comments

Maxime Coquelin Nov. 23, 2018, 5:34 p.m. UTC | #1
On 11/23/18 4:39 PM, Ilya Maximets wrote:
> In case of running with not enough capabilities, i.e. running as
> non-root user any application linked with DPDK prints the message
> about IOPL call failure even if it was just called like
> './testpmd --help'. For example, this breaks most of the OVS unit
> tests if it built with DPDK support.
> 
> Let's register the virtio driver unconditionally and print error
> message while probing the device. Silent iopl() call left in the
> constructor to have privileges as early as possible as it was before.
> 
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
> Reviewed-by: David Marchand <david.marchand@redhat.com>
> ---
>   drivers/net/virtio/virtio_ethdev.c | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
> index e1fe36a23..2ba66d291 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -1760,6 +1760,11 @@ vdpa_mode_selected(struct rte_devargs *devargs)
>   static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
>   	struct rte_pci_device *pci_dev)
>   {
> +	if (rte_eal_iopl_init() != 0) {
> +		PMD_INIT_LOG(ERR, "IOPL call failed - cannot use virtio PMD");
> +		return 1;
> +	}
> +
>   	/* virtio pmd skips probe if device needs to work in vdpa mode */
>   	if (vdpa_mode_selected(pci_dev->device.devargs))
>   		return 1;
> @@ -1785,11 +1790,7 @@ static struct rte_pci_driver rte_virtio_pmd = {
>   
>   RTE_INIT(rte_virtio_pmd_init)
>   {
> -	if (rte_eal_iopl_init() != 0) {
> -		PMD_INIT_LOG(ERR, "IOPL call failed - cannot use virtio PMD");
> -		return;
> -	}
> -
> +	rte_eal_iopl_init();
>   	rte_pci_register(&rte_virtio_pmd);
>   }
>   
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  

Patch

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index e1fe36a23..2ba66d291 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1760,6 +1760,11 @@  vdpa_mode_selected(struct rte_devargs *devargs)
 static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	struct rte_pci_device *pci_dev)
 {
+	if (rte_eal_iopl_init() != 0) {
+		PMD_INIT_LOG(ERR, "IOPL call failed - cannot use virtio PMD");
+		return 1;
+	}
+
 	/* virtio pmd skips probe if device needs to work in vdpa mode */
 	if (vdpa_mode_selected(pci_dev->device.devargs))
 		return 1;
@@ -1785,11 +1790,7 @@  static struct rte_pci_driver rte_virtio_pmd = {
 
 RTE_INIT(rte_virtio_pmd_init)
 {
-	if (rte_eal_iopl_init() != 0) {
-		PMD_INIT_LOG(ERR, "IOPL call failed - cannot use virtio PMD");
-		return;
-	}
-
+	rte_eal_iopl_init();
 	rte_pci_register(&rte_virtio_pmd);
 }