[2/2] net/vhost: prevent multiple setup on reconfig

Message ID 20200218143514.553307-3-maxime.coquelin@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series Fix Vhost PMD setup |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply issues
ci/travis-robot warning Travis build: failed

Commit Message

Maxime Coquelin Feb. 18, 2020, 2:35 p.m. UTC
  Ethdev's .dev_configure callback can be called multiple
time during a device life-time, but Vhost makes the
wrong assumption that it is not the case and try to
setup again the device on reconfiguration.

This patch ensures the device hasn't been already setup
before proceeding.

Fixes: 3d01b759d267 ("net/vhost: delay driver setup")

Reported-by: Yinan Wang <yinan.wang@intel.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 drivers/net/vhost/rte_eth_vhost.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Maxime Coquelin Feb. 18, 2020, 3:26 p.m. UTC | #1
On 2/18/20 3:35 PM, Maxime Coquelin wrote:
> Ethdev's .dev_configure callback can be called multiple
> time during a device life-time, but Vhost makes the
> wrong assumption that it is not the case and try to
> setup again the device on reconfiguration.
> 
> This patch ensures the device hasn't been already setup
> before proceeding.
> 
> Fixes: 3d01b759d267 ("net/vhost: delay driver setup")
> 
> Reported-by: Yinan Wang <yinan.wang@intel.com>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  drivers/net/vhost/rte_eth_vhost.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
> index c0056bc8bf..c4643da120 100644
> --- a/drivers/net/vhost/rte_eth_vhost.c
> +++ b/drivers/net/vhost/rte_eth_vhost.c
> @@ -876,6 +876,11 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
>  	unsigned int numa_node = eth_dev->device->numa_node;
>  	const char *name = eth_dev->device->name;
>  
> +	/* Don't try to setup again if it has already been done. */
> +	list = find_internal_resource(internal->iface_name);
> +	if (list)
> +		return 0;
> +
>  	list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
>  	if (list == NULL)
>  		return -1;
> 

Following Yinan's reply to cover letter:
Tested-by: Yinan Wang <yinan.wang@intel.com>
  
Wang, Yinan Feb. 18, 2020, 3:27 p.m. UTC | #2
Tested-by: Yinan Wang <yinan.wang@intel.com>

> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: 2020年2月18日 22:35
> To: dev@dpdk.org; oda@valinux.co.jp; Wang, Yinan <yinan.wang@intel.com>;
> Bie, Tiwei <tiwei.bie@intel.com>; amorenoz@redhat.com
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
> Subject: [PATCH 2/2] net/vhost: prevent multiple setup on reconfig
> 
> Ethdev's .dev_configure callback can be called multiple time during a device
> life-time, but Vhost makes the wrong assumption that it is not the case and try
> to setup again the device on reconfiguration.
> 
> This patch ensures the device hasn't been already setup before proceeding.
> 
> Fixes: 3d01b759d267 ("net/vhost: delay driver setup")
> 
> Reported-by: Yinan Wang <yinan.wang@intel.com>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  drivers/net/vhost/rte_eth_vhost.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/vhost/rte_eth_vhost.c
> b/drivers/net/vhost/rte_eth_vhost.c
> index c0056bc8bf..c4643da120 100644
> --- a/drivers/net/vhost/rte_eth_vhost.c
> +++ b/drivers/net/vhost/rte_eth_vhost.c
> @@ -876,6 +876,11 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
>  	unsigned int numa_node = eth_dev->device->numa_node;
>  	const char *name = eth_dev->device->name;
> 
> +	/* Don't try to setup again if it has already been done. */
> +	list = find_internal_resource(internal->iface_name);
> +	if (list)
> +		return 0;
> +
>  	list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
>  	if (list == NULL)
>  		return -1;
> --
> 2.24.1
  
David Marchand Feb. 18, 2020, 4:16 p.m. UTC | #3
On Tue, Feb 18, 2020 at 3:35 PM Maxime Coquelin
<maxime.coquelin@redhat.com> wrote:
>
> Ethdev's .dev_configure callback can be called multiple
> time during a device life-time, but Vhost makes the
> wrong assumption that it is not the case and try to
> setup again the device on reconfiguration.
>
> This patch ensures the device hasn't been already setup
> before proceeding.
>
> Fixes: 3d01b759d267 ("net/vhost: delay driver setup")
>
> Reported-by: Yinan Wang <yinan.wang@intel.com>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  drivers/net/vhost/rte_eth_vhost.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
> index c0056bc8bf..c4643da120 100644
> --- a/drivers/net/vhost/rte_eth_vhost.c
> +++ b/drivers/net/vhost/rte_eth_vhost.c
> @@ -876,6 +876,11 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
>         unsigned int numa_node = eth_dev->device->numa_node;
>         const char *name = eth_dev->device->name;
>
> +       /* Don't try to setup again if it has already been done. */
> +       list = find_internal_resource(internal->iface_name);
> +       if (list)
> +               return 0;
> +
>         list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
>         if (list == NULL)
>                 return -1;
> --
> 2.24.1
>

Reviewed-by: David Marchand <david.marchand@redhat.com>
  

Patch

diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index c0056bc8bf..c4643da120 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -876,6 +876,11 @@  vhost_driver_setup(struct rte_eth_dev *eth_dev)
 	unsigned int numa_node = eth_dev->device->numa_node;
 	const char *name = eth_dev->device->name;
 
+	/* Don't try to setup again if it has already been done. */
+	list = find_internal_resource(internal->iface_name);
+	if (list)
+		return 0;
+
 	list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
 	if (list == NULL)
 		return -1;