[v3] vdpa/ifc: fix update_datapath error handling

Message ID 20221107085943.116357-1-kim.tae.kyung@navercorp.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series [v3] vdpa/ifc: fix update_datapath error handling |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

Taekyung Kim Nov. 7, 2022, 8:59 a.m. UTC
  Stop and return the error code when update_datapath fails.
update_datapath prepares resources for the vdpa device.
The driver should not perform any further actions
if update_datapath returns an error.

Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
Cc: stable@dpdk.org

Signed-off-by: Taekyung Kim <kim.tae.kyung@navercorp.com>
---
v3:
* Fix coding style

v2:
* Revert the prepared resources before returning an error
* Rebase to 22.11 rc2
* Add fixes and cc for backport

---
 drivers/vdpa/ifc/ifcvf_vdpa.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)
  

Comments

Chenbo Xia Nov. 8, 2022, 1:46 a.m. UTC | #1
> -----Original Message-----
> From: Taekyung Kim <kim.tae.kyung@navercorp.com>
> Sent: Monday, November 7, 2022 5:00 PM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; maxime.coquelin@redhat.com; Xia, Chenbo
> <chenbo.xia@intel.com>; Wang, Xiao W <xiao.w.wang@intel.com>;
> kim.tae.kyung@navercorp.com
> Subject: [PATCH v3] vdpa/ifc: fix update_datapath error handling
> 
> Stop and return the error code when update_datapath fails.
> update_datapath prepares resources for the vdpa device.
> The driver should not perform any further actions
> if update_datapath returns an error.
> 
> Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Taekyung Kim <kim.tae.kyung@navercorp.com>
> ---
> v3:
> * Fix coding style
> 
> v2:
> * Revert the prepared resources before returning an error
> * Rebase to 22.11 rc2
> * Add fixes and cc for backport
> 
> ---
>  drivers/vdpa/ifc/ifcvf_vdpa.c | 26 ++++++++++++++++++++++----
>  1 file changed, 22 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
> index 8dfd49336e..0396d49122 100644
> --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> @@ -1098,7 +1098,12 @@ ifcvf_dev_config(int vid)
>  	internal = list->internal;
>  	internal->vid = vid;
>  	rte_atomic32_set(&internal->dev_attached, 1);
> -	update_datapath(internal);
> +	if (update_datapath(internal) < 0) {
> +		DRV_LOG(ERR, "failed to update datapath for vDPA device %s",
> +			vdev->device->name);
> +		rte_atomic32_set(&internal->dev_attached, 0);
> +		return -1;
> +	}
> 
>  	hw = &internal->hw;
>  	for (i = 0; i < hw->nr_vring; i++) {
> @@ -1146,7 +1151,12 @@ ifcvf_dev_close(int vid)
>  		internal->sw_fallback_running = false;
>  	} else {
>  		rte_atomic32_set(&internal->dev_attached, 0);
> -		update_datapath(internal);
> +		if (update_datapath(internal) < 0) {
> +			DRV_LOG(ERR, "failed to update datapath for vDPA
> device %s",
> +				vdev->device->name);
> +			internal->configured = 0;
> +			return -1;
> +		}
>  	}
> 
>  	internal->configured = 0;
> @@ -1752,7 +1762,14 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv
> __rte_unused,
>  	}
> 
>  	rte_atomic32_set(&internal->started, 1);
> -	update_datapath(internal);
> +	if (update_datapath(internal) < 0) {
> +		DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
> +		rte_atomic32_set(&internal->started, 0);
> +		pthread_mutex_lock(&internal_list_lock);
> +		TAILQ_REMOVE(&internal_list, list, next);
> +		pthread_mutex_unlock(&internal_list_lock);
> +		goto error;
> +	}
> 
>  	rte_kvargs_free(kvlist);
>  	return 0;
> @@ -1781,7 +1798,8 @@ ifcvf_pci_remove(struct rte_pci_device *pci_dev)
> 
>  	internal = list->internal;
>  	rte_atomic32_set(&internal->started, 0);
> -	update_datapath(internal);
> +	if (update_datapath(internal) < 0)
> +		DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
> 
>  	rte_pci_unmap_device(internal->pdev);
>  	rte_vfio_container_destroy(internal->vfio_container_fd);
> --
> 2.34.1

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  
Taekyung Kim Nov. 8, 2022, 7:30 a.m. UTC | #2
Hi Chenbo,

Thanks for your review.

On Tue, Nov 08, 2022 at 01:46:37AM +0000, Xia, Chenbo wrote:
> > -----Original Message-----
> > From: Taekyung Kim <kim.tae.kyung@navercorp.com>
> > Sent: Monday, November 7, 2022 5:00 PM
> > To: dev@dpdk.org
> > Cc: stable@dpdk.org; maxime.coquelin@redhat.com; Xia, Chenbo
> > <chenbo.xia@intel.com>; Wang, Xiao W <xiao.w.wang@intel.com>;
> > kim.tae.kyung@navercorp.com
> > Subject: [PATCH v3] vdpa/ifc: fix update_datapath error handling
> > 
> > Stop and return the error code when update_datapath fails.
> > update_datapath prepares resources for the vdpa device.
> > The driver should not perform any further actions
> > if update_datapath returns an error.
> > 
> > Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Taekyung Kim <kim.tae.kyung@navercorp.com>
> > ---
> > v3:
> > * Fix coding style
> > 
> > v2:
> > * Revert the prepared resources before returning an error
> > * Rebase to 22.11 rc2
> > * Add fixes and cc for backport
> > 
> > ---
> >  drivers/vdpa/ifc/ifcvf_vdpa.c | 26 ++++++++++++++++++++++----
> >  1 file changed, 22 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
> > index 8dfd49336e..0396d49122 100644
> > --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> > +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> > @@ -1098,7 +1098,12 @@ ifcvf_dev_config(int vid)
> >  	internal = list->internal;
> >  	internal->vid = vid;
> >  	rte_atomic32_set(&internal->dev_attached, 1);
> > -	update_datapath(internal);
> > +	if (update_datapath(internal) < 0) {
> > +		DRV_LOG(ERR, "failed to update datapath for vDPA device %s",
> > +			vdev->device->name);
> > +		rte_atomic32_set(&internal->dev_attached, 0);
> > +		return -1;
> > +	}
> > 
> >  	hw = &internal->hw;
> >  	for (i = 0; i < hw->nr_vring; i++) {
> > @@ -1146,7 +1151,12 @@ ifcvf_dev_close(int vid)
> >  		internal->sw_fallback_running = false;
> >  	} else {
> >  		rte_atomic32_set(&internal->dev_attached, 0);
> > -		update_datapath(internal);
> > +		if (update_datapath(internal) < 0) {
> > +			DRV_LOG(ERR, "failed to update datapath for vDPA
> > device %s",
> > +				vdev->device->name);
> > +			internal->configured = 0;
> > +			return -1;
> > +		}
> >  	}
> > 
> >  	internal->configured = 0;
> > @@ -1752,7 +1762,14 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv
> > __rte_unused,
> >  	}
> > 
> >  	rte_atomic32_set(&internal->started, 1);
> > -	update_datapath(internal);
> > +	if (update_datapath(internal) < 0) {
> > +		DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
> > +		rte_atomic32_set(&internal->started, 0);
> > +		pthread_mutex_lock(&internal_list_lock);
> > +		TAILQ_REMOVE(&internal_list, list, next);
> > +		pthread_mutex_unlock(&internal_list_lock);
> > +		goto error;
> > +	}
> > 
> >  	rte_kvargs_free(kvlist);
> >  	return 0;
> > @@ -1781,7 +1798,8 @@ ifcvf_pci_remove(struct rte_pci_device *pci_dev)
> > 
> >  	internal = list->internal;
> >  	rte_atomic32_set(&internal->started, 0);
> > -	update_datapath(internal);
> > +	if (update_datapath(internal) < 0)
> > +		DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
> > 
> >  	rte_pci_unmap_device(internal->pdev);
> >  	rte_vfio_container_destroy(internal->vfio_container_fd);
> > --
> > 2.34.1
> 
> Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  
Pei, Andy Nov. 8, 2022, 7:39 a.m. UTC | #3
Hi 

See my reply inline.

> -----Original Message-----
> From: Xia, Chenbo <chenbo.xia@intel.com>
> Sent: Tuesday, November 8, 2022 9:47 AM
> To: Taekyung Kim <kim.tae.kyung@navercorp.com>; dev@dpdk.org
> Cc: stable@dpdk.org; maxime.coquelin@redhat.com; Wang, Xiao W
> <xiao.w.wang@intel.com>
> Subject: RE: [PATCH v3] vdpa/ifc: fix update_datapath error handling
> 
> > -----Original Message-----
> > From: Taekyung Kim <kim.tae.kyung@navercorp.com>
> > Sent: Monday, November 7, 2022 5:00 PM
> > To: dev@dpdk.org
> > Cc: stable@dpdk.org; maxime.coquelin@redhat.com; Xia, Chenbo
> > <chenbo.xia@intel.com>; Wang, Xiao W <xiao.w.wang@intel.com>;
> > kim.tae.kyung@navercorp.com
> > Subject: [PATCH v3] vdpa/ifc: fix update_datapath error handling
> >
> > Stop and return the error code when update_datapath fails.
> > update_datapath prepares resources for the vdpa device.
> > The driver should not perform any further actions if update_datapath
> > returns an error.
> >
> > Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Taekyung Kim <kim.tae.kyung@navercorp.com>
> > ---
> > v3:
> > * Fix coding style
> >
> > v2:
> > * Revert the prepared resources before returning an error
> > * Rebase to 22.11 rc2
> > * Add fixes and cc for backport
> >
> > ---
> >  drivers/vdpa/ifc/ifcvf_vdpa.c | 26 ++++++++++++++++++++++----
> >  1 file changed, 22 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c
> > b/drivers/vdpa/ifc/ifcvf_vdpa.c index 8dfd49336e..0396d49122 100644
> > --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> > +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> > @@ -1098,7 +1098,12 @@ ifcvf_dev_config(int vid)
> >  	internal = list->internal;
> >  	internal->vid = vid;
> >  	rte_atomic32_set(&internal->dev_attached, 1);
> > -	update_datapath(internal);
> > +	if (update_datapath(internal) < 0) {
> > +		DRV_LOG(ERR, "failed to update datapath for vDPA device %s",
> > +			vdev->device->name);
> > +		rte_atomic32_set(&internal->dev_attached, 0);
> > +		return -1;
> > +	}
> >
> >  	hw = &internal->hw;
> >  	for (i = 0; i < hw->nr_vring; i++) { @@ -1146,7 +1151,12 @@
> > ifcvf_dev_close(int vid)
> >  		internal->sw_fallback_running = false;
> >  	} else {
> >  		rte_atomic32_set(&internal->dev_attached, 0);
> > -		update_datapath(internal);
> > +		if (update_datapath(internal) < 0) {
> > +			DRV_LOG(ERR, "failed to update datapath for vDPA
> > device %s",
> > +				vdev->device->name);
> > +			internal->configured = 0;
> > +			return -1;
> > +		}
> >  	}
> >
> >  	internal->configured = 0;
> > @@ -1752,7 +1762,14 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv
> > __rte_unused,
> >  	}
> >
> >  	rte_atomic32_set(&internal->started, 1);
> > -	update_datapath(internal);
> > +	if (update_datapath(internal) < 0) {
> > +		DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
> > +		rte_atomic32_set(&internal->started, 0);
> > +		pthread_mutex_lock(&internal_list_lock);
> > +		TAILQ_REMOVE(&internal_list, list, next);
> > +		pthread_mutex_unlock(&internal_list_lock);
> > +		goto error;
> > +	}
> >

Is it necessary to unregister vdpa device?

> >  	rte_kvargs_free(kvlist);
> >  	return 0;
> > @@ -1781,7 +1798,8 @@ ifcvf_pci_remove(struct rte_pci_device *pci_dev)
> >
> >  	internal = list->internal;
> >  	rte_atomic32_set(&internal->started, 0);
> > -	update_datapath(internal);
> > +	if (update_datapath(internal) < 0)
> > +		DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
> >
> >  	rte_pci_unmap_device(internal->pdev);
> >  	rte_vfio_container_destroy(internal->vfio_container_fd);
> > --
> > 2.34.1
> 
> Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  
Chenbo Xia Nov. 8, 2022, 7:56 a.m. UTC | #4
> -----Original Message-----
> From: Pei, Andy <andy.pei@intel.com>
> Sent: Tuesday, November 8, 2022 3:39 PM
> To: Xia, Chenbo <chenbo.xia@intel.com>; Taekyung Kim
> <kim.tae.kyung@navercorp.com>; dev@dpdk.org
> Cc: stable@dpdk.org; maxime.coquelin@redhat.com; Wang, Xiao W
> <xiao.w.wang@intel.com>
> Subject: RE: [PATCH v3] vdpa/ifc: fix update_datapath error handling
> 
> Hi
> 
> See my reply inline.
> 
> > -----Original Message-----
> > From: Xia, Chenbo <chenbo.xia@intel.com>
> > Sent: Tuesday, November 8, 2022 9:47 AM
> > To: Taekyung Kim <kim.tae.kyung@navercorp.com>; dev@dpdk.org
> > Cc: stable@dpdk.org; maxime.coquelin@redhat.com; Wang, Xiao W
> > <xiao.w.wang@intel.com>
> > Subject: RE: [PATCH v3] vdpa/ifc: fix update_datapath error handling
> >
> > > -----Original Message-----
> > > From: Taekyung Kim <kim.tae.kyung@navercorp.com>
> > > Sent: Monday, November 7, 2022 5:00 PM
> > > To: dev@dpdk.org
> > > Cc: stable@dpdk.org; maxime.coquelin@redhat.com; Xia, Chenbo
> > > <chenbo.xia@intel.com>; Wang, Xiao W <xiao.w.wang@intel.com>;
> > > kim.tae.kyung@navercorp.com
> > > Subject: [PATCH v3] vdpa/ifc: fix update_datapath error handling
> > >
> > > Stop and return the error code when update_datapath fails.
> > > update_datapath prepares resources for the vdpa device.
> > > The driver should not perform any further actions if update_datapath
> > > returns an error.
> > >
> > > Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
> > > Cc: stable@dpdk.org
> > >
> > > Signed-off-by: Taekyung Kim <kim.tae.kyung@navercorp.com>
> > > ---
> > > v3:
> > > * Fix coding style
> > >
> > > v2:
> > > * Revert the prepared resources before returning an error
> > > * Rebase to 22.11 rc2
> > > * Add fixes and cc for backport
> > >
> > > ---
> > >  drivers/vdpa/ifc/ifcvf_vdpa.c | 26 ++++++++++++++++++++++----
> > >  1 file changed, 22 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c
> > > b/drivers/vdpa/ifc/ifcvf_vdpa.c index 8dfd49336e..0396d49122 100644
> > > --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> > > +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> > > @@ -1098,7 +1098,12 @@ ifcvf_dev_config(int vid)
> > >  	internal = list->internal;
> > >  	internal->vid = vid;
> > >  	rte_atomic32_set(&internal->dev_attached, 1);
> > > -	update_datapath(internal);
> > > +	if (update_datapath(internal) < 0) {
> > > +		DRV_LOG(ERR, "failed to update datapath for vDPA device %s",
> > > +			vdev->device->name);
> > > +		rte_atomic32_set(&internal->dev_attached, 0);
> > > +		return -1;
> > > +	}
> > >
> > >  	hw = &internal->hw;
> > >  	for (i = 0; i < hw->nr_vring; i++) { @@ -1146,7 +1151,12 @@
> > > ifcvf_dev_close(int vid)
> > >  		internal->sw_fallback_running = false;
> > >  	} else {
> > >  		rte_atomic32_set(&internal->dev_attached, 0);
> > > -		update_datapath(internal);
> > > +		if (update_datapath(internal) < 0) {
> > > +			DRV_LOG(ERR, "failed to update datapath for vDPA
> > > device %s",
> > > +				vdev->device->name);
> > > +			internal->configured = 0;
> > > +			return -1;
> > > +		}
> > >  	}
> > >
> > >  	internal->configured = 0;
> > > @@ -1752,7 +1762,14 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv
> > > __rte_unused,
> > >  	}
> > >
> > >  	rte_atomic32_set(&internal->started, 1);
> > > -	update_datapath(internal);
> > > +	if (update_datapath(internal) < 0) {
> > > +		DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
> > > +		rte_atomic32_set(&internal->started, 0);
> > > +		pthread_mutex_lock(&internal_list_lock);
> > > +		TAILQ_REMOVE(&internal_list, list, next);
> > > +		pthread_mutex_unlock(&internal_list_lock);
> > > +		goto error;
> > > +	}
> > >
> 
> Is it necessary to unregister vdpa device?

Good catch, yes it's needed.

Kim, please add the unregistration.

Thanks,
Chenbo

> 
> > >  	rte_kvargs_free(kvlist);
> > >  	return 0;
> > > @@ -1781,7 +1798,8 @@ ifcvf_pci_remove(struct rte_pci_device *pci_dev)
> > >
> > >  	internal = list->internal;
> > >  	rte_atomic32_set(&internal->started, 0);
> > > -	update_datapath(internal);
> > > +	if (update_datapath(internal) < 0)
> > > +		DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
> > >
> > >  	rte_pci_unmap_device(internal->pdev);
> > >  	rte_vfio_container_destroy(internal->vfio_container_fd);
> > > --
> > > 2.34.1
> >
> > Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  
Taekyung Kim Nov. 8, 2022, 8:27 a.m. UTC | #5
On Tue, Nov 08, 2022 at 07:56:18AM +0000, Xia, Chenbo wrote:
> > -----Original Message-----
> > From: Pei, Andy <andy.pei@intel.com>
> > Sent: Tuesday, November 8, 2022 3:39 PM
> > To: Xia, Chenbo <chenbo.xia@intel.com>; Taekyung Kim
> > <kim.tae.kyung@navercorp.com>; dev@dpdk.org
> > Cc: stable@dpdk.org; maxime.coquelin@redhat.com; Wang, Xiao W
> > <xiao.w.wang@intel.com>
> > Subject: RE: [PATCH v3] vdpa/ifc: fix update_datapath error handling
> > 
> > Hi
> > 
> > See my reply inline.
> > 
> > > -----Original Message-----
> > > From: Xia, Chenbo <chenbo.xia@intel.com>
> > > Sent: Tuesday, November 8, 2022 9:47 AM
> > > To: Taekyung Kim <kim.tae.kyung@navercorp.com>; dev@dpdk.org
> > > Cc: stable@dpdk.org; maxime.coquelin@redhat.com; Wang, Xiao W
> > > <xiao.w.wang@intel.com>
> > > Subject: RE: [PATCH v3] vdpa/ifc: fix update_datapath error handling
> > >
> > > > -----Original Message-----
> > > > From: Taekyung Kim <kim.tae.kyung@navercorp.com>
> > > > Sent: Monday, November 7, 2022 5:00 PM
> > > > To: dev@dpdk.org
> > > > Cc: stable@dpdk.org; maxime.coquelin@redhat.com; Xia, Chenbo
> > > > <chenbo.xia@intel.com>; Wang, Xiao W <xiao.w.wang@intel.com>;
> > > > kim.tae.kyung@navercorp.com
> > > > Subject: [PATCH v3] vdpa/ifc: fix update_datapath error handling
> > > >
> > > > Stop and return the error code when update_datapath fails.
> > > > update_datapath prepares resources for the vdpa device.
> > > > The driver should not perform any further actions if update_datapath
> > > > returns an error.
> > > >
> > > > Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
> > > > Cc: stable@dpdk.org
> > > >
> > > > Signed-off-by: Taekyung Kim <kim.tae.kyung@navercorp.com>
> > > > ---
> > > > v3:
> > > > * Fix coding style
> > > >
> > > > v2:
> > > > * Revert the prepared resources before returning an error
> > > > * Rebase to 22.11 rc2
> > > > * Add fixes and cc for backport
> > > >
> > > > ---
> > > >  drivers/vdpa/ifc/ifcvf_vdpa.c | 26 ++++++++++++++++++++++----
> > > >  1 file changed, 22 insertions(+), 4 deletions(-)
> > > >
> > > > diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c
> > > > b/drivers/vdpa/ifc/ifcvf_vdpa.c index 8dfd49336e..0396d49122 100644
> > > > --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> > > > +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> > > > @@ -1098,7 +1098,12 @@ ifcvf_dev_config(int vid)
> > > >  	internal = list->internal;
> > > >  	internal->vid = vid;
> > > >  	rte_atomic32_set(&internal->dev_attached, 1);
> > > > -	update_datapath(internal);
> > > > +	if (update_datapath(internal) < 0) {
> > > > +		DRV_LOG(ERR, "failed to update datapath for vDPA device %s",
> > > > +			vdev->device->name);
> > > > +		rte_atomic32_set(&internal->dev_attached, 0);
> > > > +		return -1;
> > > > +	}
> > > >
> > > >  	hw = &internal->hw;
> > > >  	for (i = 0; i < hw->nr_vring; i++) { @@ -1146,7 +1151,12 @@
> > > > ifcvf_dev_close(int vid)
> > > >  		internal->sw_fallback_running = false;
> > > >  	} else {
> > > >  		rte_atomic32_set(&internal->dev_attached, 0);
> > > > -		update_datapath(internal);
> > > > +		if (update_datapath(internal) < 0) {
> > > > +			DRV_LOG(ERR, "failed to update datapath for vDPA
> > > > device %s",
> > > > +				vdev->device->name);
> > > > +			internal->configured = 0;
> > > > +			return -1;
> > > > +		}
> > > >  	}
> > > >
> > > >  	internal->configured = 0;
> > > > @@ -1752,7 +1762,14 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv
> > > > __rte_unused,
> > > >  	}
> > > >
> > > >  	rte_atomic32_set(&internal->started, 1);
> > > > -	update_datapath(internal);
> > > > +	if (update_datapath(internal) < 0) {
> > > > +		DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
> > > > +		rte_atomic32_set(&internal->started, 0);
> > > > +		pthread_mutex_lock(&internal_list_lock);
> > > > +		TAILQ_REMOVE(&internal_list, list, next);
> > > > +		pthread_mutex_unlock(&internal_list_lock);
> > > > +		goto error;
> > > > +	}
> > > >
> > 
> > Is it necessary to unregister vdpa device?
> 
> Good catch, yes it's needed.
> 
> Kim, please add the unregistration.
> 
> Thanks,
> Chenbo

Hi Andy and Chenbo,

Thanks for your comments.
I forgot to add `rte_vdpa_unregister_device(internal->vdev)`.
I will send a new patch soon.

By the way, it seems that deallocation for `ifcvf_vfio_setup(internal)`
is also ommitted in `ifcvf_pci_probe(...)`.
I will submit another commit to split `error:` into `error2:` and `error1:`,
which calls `rte_pci_unmap_device(...)` and `rte_vfio_container_destroy(...)`.

Thanks,
Taekyung

> 
> > 
> > > >  	rte_kvargs_free(kvlist);
> > > >  	return 0;
> > > > @@ -1781,7 +1798,8 @@ ifcvf_pci_remove(struct rte_pci_device *pci_dev)
> > > >
> > > >  	internal = list->internal;
> > > >  	rte_atomic32_set(&internal->started, 0);
> > > > -	update_datapath(internal);
> > > > +	if (update_datapath(internal) < 0)
> > > > +		DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
> > > >
> > > >  	rte_pci_unmap_device(internal->pdev);
> > > >  	rte_vfio_container_destroy(internal->vfio_container_fd);
> > > > --
> > > > 2.34.1
> > >
> > > Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  
Maxime Coquelin Nov. 8, 2022, 1:49 p.m. UTC | #6
Hi Taekyung,

On 11/8/22 09:56, Taekyung Kim wrote:
> Stop and return the error code when update_datapath fails.
> update_datapath prepares resources for the vdpa device.
> The driver should not perform any further actions
> if update_datapath returns an error.
> 
> Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Taekyung Kim <kim.tae.kyung@navercorp.com>
> ---
> v4:
> * Add rte_vdpa_unregister_device in ifcvf_pci_probe
> 
> v3:
> * Fix coding style
> 
> v2:
> * Revert the prepared resources before returning an error
> * Rebase to 22.11 rc2
> * Add fixes and cc for backport
> 
> ---
>   drivers/vdpa/ifc/ifcvf_vdpa.c | 27 +++++++++++++++++++++++----
>   1 file changed, 23 insertions(+), 4 deletions(-)
> 

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

Thanks,
Maxime
  
Pei, Andy Nov. 9, 2022, 2:39 a.m. UTC | #7
> -----Original Message-----
> From: Taekyung Kim <kim.tae.kyung@navercorp.com>
> Sent: Tuesday, November 8, 2022 4:56 PM
> To: dev@dpdk.org
> Cc: Xia, Chenbo <Chenbo.Xia@intel.com>; Pei, Andy <andy.pei@intel.com>;
> kim.tae.kyung@navercorp.com; maxime.coquelin@redhat.com;
> stable@dpdk.org; Wang, Xiao W <xiao.w.wang@intel.com>
> Subject: [PATCH v4] vdpa/ifc: fix update_datapath error handling
> 
> Stop and return the error code when update_datapath fails.
> update_datapath prepares resources for the vdpa device.
> The driver should not perform any further actions if update_datapath returns an
> error.
> 
> Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Taekyung Kim <kim.tae.kyung@navercorp.com>
> ---
> v4:
> * Add rte_vdpa_unregister_device in ifcvf_pci_probe
> 
> v3:
> * Fix coding style
> 
> v2:
> * Revert the prepared resources before returning an error
> * Rebase to 22.11 rc2
> * Add fixes and cc for backport
> 
> ---
>  drivers/vdpa/ifc/ifcvf_vdpa.c | 27 +++++++++++++++++++++++----
>  1 file changed, 23 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c index
> 8dfd49336e..49d68ad1b1 100644
> --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> @@ -1098,7 +1098,12 @@ ifcvf_dev_config(int vid)
>  	internal = list->internal;
>  	internal->vid = vid;
>  	rte_atomic32_set(&internal->dev_attached, 1);
> -	update_datapath(internal);
> +	if (update_datapath(internal) < 0) {
> +		DRV_LOG(ERR, "failed to update datapath for vDPA device %s",
> +			vdev->device->name);
> +		rte_atomic32_set(&internal->dev_attached, 0);
> +		return -1;
> +	}
> 
>  	hw = &internal->hw;
>  	for (i = 0; i < hw->nr_vring; i++) {
> @@ -1146,7 +1151,12 @@ ifcvf_dev_close(int vid)
>  		internal->sw_fallback_running = false;
>  	} else {
>  		rte_atomic32_set(&internal->dev_attached, 0);
> -		update_datapath(internal);
> +		if (update_datapath(internal) < 0) {
> +			DRV_LOG(ERR, "failed to update datapath for vDPA
> device %s",
> +				vdev->device->name);
> +			internal->configured = 0;
> +			return -1;
> +		}
>  	}
> 
>  	internal->configured = 0;
> @@ -1752,7 +1762,15 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv
> __rte_unused,
>  	}
> 
>  	rte_atomic32_set(&internal->started, 1);
> -	update_datapath(internal);
> +	if (update_datapath(internal) < 0) {
> +		DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
> +		rte_atomic32_set(&internal->started, 0);
> +		rte_vdpa_unregister_device(internal->vdev);
> +		pthread_mutex_lock(&internal_list_lock);
> +		TAILQ_REMOVE(&internal_list, list, next);
> +		pthread_mutex_unlock(&internal_list_lock);
> +		goto error;
> +	}
> 
>  	rte_kvargs_free(kvlist);
>  	return 0;
> @@ -1781,7 +1799,8 @@ ifcvf_pci_remove(struct rte_pci_device *pci_dev)
> 
>  	internal = list->internal;
>  	rte_atomic32_set(&internal->started, 0);
> -	update_datapath(internal);
> +	if (update_datapath(internal) < 0)
> +		DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
> 
>  	rte_pci_unmap_device(internal->pdev);
>  	rte_vfio_container_destroy(internal->vfio_container_fd);
> --
> 2.34.1

Acked-by: Andy Pei <andy.pei@intel.com>
  
Taekyung Kim Nov. 9, 2022, 10:45 a.m. UTC | #8
Hi Maxime,

Thanks for your review.

On Tue, Nov 08, 2022 at 02:49:39PM +0100, Maxime Coquelin wrote:
> Hi Taekyung,
> 
> On 11/8/22 09:56, Taekyung Kim wrote:
> > Stop and return the error code when update_datapath fails.
> > update_datapath prepares resources for the vdpa device.
> > The driver should not perform any further actions
> > if update_datapath returns an error.
> > 
> > Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Taekyung Kim <kim.tae.kyung@navercorp.com>
> > ---
> > v4:
> > * Add rte_vdpa_unregister_device in ifcvf_pci_probe
> > 
> > v3:
> > * Fix coding style
> > 
> > v2:
> > * Revert the prepared resources before returning an error
> > * Rebase to 22.11 rc2
> > * Add fixes and cc for backport
> > 
> > ---
> >   drivers/vdpa/ifc/ifcvf_vdpa.c | 27 +++++++++++++++++++++++----
> >   1 file changed, 23 insertions(+), 4 deletions(-)
> > 
> 
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> 
> Thanks,
> Maxime
>
  
Taekyung Kim Nov. 9, 2022, 10:47 a.m. UTC | #9
Hi Andy,

Thanks for your review.

On Wed, Nov 09, 2022 at 02:39:09AM +0000, Pei, Andy wrote:
> 
> 
> > -----Original Message-----
> > From: Taekyung Kim <kim.tae.kyung@navercorp.com>
> > Sent: Tuesday, November 8, 2022 4:56 PM
> > To: dev@dpdk.org
> > Cc: Xia, Chenbo <Chenbo.Xia@intel.com>; Pei, Andy <andy.pei@intel.com>;
> > kim.tae.kyung@navercorp.com; maxime.coquelin@redhat.com;
> > stable@dpdk.org; Wang, Xiao W <xiao.w.wang@intel.com>
> > Subject: [PATCH v4] vdpa/ifc: fix update_datapath error handling
> > 
> > Stop and return the error code when update_datapath fails.
> > update_datapath prepares resources for the vdpa device.
> > The driver should not perform any further actions if update_datapath returns an
> > error.
> > 
> > Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Taekyung Kim <kim.tae.kyung@navercorp.com>
> > ---
> > v4:
> > * Add rte_vdpa_unregister_device in ifcvf_pci_probe
> > 
> > v3:
> > * Fix coding style
> > 
> > v2:
> > * Revert the prepared resources before returning an error
> > * Rebase to 22.11 rc2
> > * Add fixes and cc for backport
> > 
> > ---
> >  drivers/vdpa/ifc/ifcvf_vdpa.c | 27 +++++++++++++++++++++++----
> >  1 file changed, 23 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c index
> > 8dfd49336e..49d68ad1b1 100644
> > --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> > +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> > @@ -1098,7 +1098,12 @@ ifcvf_dev_config(int vid)
> >  	internal = list->internal;
> >  	internal->vid = vid;
> >  	rte_atomic32_set(&internal->dev_attached, 1);
> > -	update_datapath(internal);
> > +	if (update_datapath(internal) < 0) {
> > +		DRV_LOG(ERR, "failed to update datapath for vDPA device %s",
> > +			vdev->device->name);
> > +		rte_atomic32_set(&internal->dev_attached, 0);
> > +		return -1;
> > +	}
> > 
> >  	hw = &internal->hw;
> >  	for (i = 0; i < hw->nr_vring; i++) {
> > @@ -1146,7 +1151,12 @@ ifcvf_dev_close(int vid)
> >  		internal->sw_fallback_running = false;
> >  	} else {
> >  		rte_atomic32_set(&internal->dev_attached, 0);
> > -		update_datapath(internal);
> > +		if (update_datapath(internal) < 0) {
> > +			DRV_LOG(ERR, "failed to update datapath for vDPA
> > device %s",
> > +				vdev->device->name);
> > +			internal->configured = 0;
> > +			return -1;
> > +		}
> >  	}
> > 
> >  	internal->configured = 0;
> > @@ -1752,7 +1762,15 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv
> > __rte_unused,
> >  	}
> > 
> >  	rte_atomic32_set(&internal->started, 1);
> > -	update_datapath(internal);
> > +	if (update_datapath(internal) < 0) {
> > +		DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
> > +		rte_atomic32_set(&internal->started, 0);
> > +		rte_vdpa_unregister_device(internal->vdev);
> > +		pthread_mutex_lock(&internal_list_lock);
> > +		TAILQ_REMOVE(&internal_list, list, next);
> > +		pthread_mutex_unlock(&internal_list_lock);
> > +		goto error;
> > +	}
> > 
> >  	rte_kvargs_free(kvlist);
> >  	return 0;
> > @@ -1781,7 +1799,8 @@ ifcvf_pci_remove(struct rte_pci_device *pci_dev)
> > 
> >  	internal = list->internal;
> >  	rte_atomic32_set(&internal->started, 0);
> > -	update_datapath(internal);
> > +	if (update_datapath(internal) < 0)
> > +		DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
> > 
> >  	rte_pci_unmap_device(internal->pdev);
> >  	rte_vfio_container_destroy(internal->vfio_container_fd);
> > --
> > 2.34.1
> 
> Acked-by: Andy Pei <andy.pei@intel.com>
  
Chenbo Xia Nov. 10, 2022, 1:53 a.m. UTC | #10
Hi Kim,

> -----Original Message-----
> From: Taekyung Kim <kim.tae.kyung@navercorp.com>
> Sent: Tuesday, November 8, 2022 4:56 PM
> To: dev@dpdk.org
> Cc: Xia, Chenbo <chenbo.xia@intel.com>; Pei, Andy <andy.pei@intel.com>;
> kim.tae.kyung@navercorp.com; maxime.coquelin@redhat.com; stable@dpdk.org;
> Wang, Xiao W <xiao.w.wang@intel.com>
> Subject: [PATCH v4] vdpa/ifc: fix update_datapath error handling
> 
> Stop and return the error code when update_datapath fails.
> update_datapath prepares resources for the vdpa device.
> The driver should not perform any further actions
> if update_datapath returns an error.
> 
> Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Taekyung Kim <kim.tae.kyung@navercorp.com>
> ---
> v4:
> * Add rte_vdpa_unregister_device in ifcvf_pci_probe
> 
> v3:
> * Fix coding style
> 
> v2:
> * Revert the prepared resources before returning an error
> * Rebase to 22.11 rc2
> * Add fixes and cc for backport
> 
> ---
>  drivers/vdpa/ifc/ifcvf_vdpa.c | 27 +++++++++++++++++++++++----
>  1 file changed, 23 insertions(+), 4 deletions(-)

I can't find your patch in patchwork:

http://patchwork.dpdk.org/project/dpdk/list/?series=&submitter=2877&state=*&q=&archive=both&delegate=

so it's difficult to review and merge. Do you know why or is it possible
that you send a new version to make it show on Patchwork today?

Thanks,
Chenbo
  
Taekyung Kim Nov. 10, 2022, 4:02 a.m. UTC | #11
On Thu, Nov 10, 2022 at 01:53:50AM +0000, Xia, Chenbo wrote:
> Hi Kim,
> 
> > -----Original Message-----
> > From: Taekyung Kim <kim.tae.kyung@navercorp.com>
> > Sent: Tuesday, November 8, 2022 4:56 PM
> > To: dev@dpdk.org
> > Cc: Xia, Chenbo <chenbo.xia@intel.com>; Pei, Andy <andy.pei@intel.com>;
> > kim.tae.kyung@navercorp.com; maxime.coquelin@redhat.com; stable@dpdk.org;
> > Wang, Xiao W <xiao.w.wang@intel.com>
> > Subject: [PATCH v4] vdpa/ifc: fix update_datapath error handling
> > 
> > Stop and return the error code when update_datapath fails.
> > update_datapath prepares resources for the vdpa device.
> > The driver should not perform any further actions
> > if update_datapath returns an error.
> > 
> > Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Taekyung Kim <kim.tae.kyung@navercorp.com>
> > ---
> > v4:
> > * Add rte_vdpa_unregister_device in ifcvf_pci_probe
> > 
> > v3:
> > * Fix coding style
> > 
> > v2:
> > * Revert the prepared resources before returning an error
> > * Rebase to 22.11 rc2
> > * Add fixes and cc for backport
> > 
> > ---
> >  drivers/vdpa/ifc/ifcvf_vdpa.c | 27 +++++++++++++++++++++++----
> >  1 file changed, 23 insertions(+), 4 deletions(-)
> 
> I can't find your patch in patchwork:
> 
> http://patchwork.dpdk.org/project/dpdk/list/?series=&submitter=2877&state=*&q=&archive=both&delegate=
> 
> so it's difficult to review and merge. Do you know why or is it possible
> that you send a new version to make it show on Patchwork today?
> 
> Thanks,
> Chenbo
> 

Hi Chenbo,

First, thanks for your review.
I will send a new version for this patch soon.

I think the mail for v4 is lost.
Whenever I send a patch, I received "Your message to dev awaits moderator approval"
from dev-owner@dpdk.org with the reason "Post by non-member to a members-only list".
Maybe, the reason is that this is the first time that I submit a patch.

Thanks,
Taekyung
  
Maxime Coquelin Nov. 10, 2022, 9:20 a.m. UTC | #12
Hi Taekyung,

Adding Thomas and Ali who maintains the patchwork instance.

On 11/10/22 05:02, Taekyung Kim wrote:
> On Thu, Nov 10, 2022 at 01:53:50AM +0000, Xia, Chenbo wrote:
>> Hi Kim,
>>
>>> -----Original Message-----
>>> From: Taekyung Kim <kim.tae.kyung@navercorp.com>
>>> Sent: Tuesday, November 8, 2022 4:56 PM
>>> To: dev@dpdk.org
>>> Cc: Xia, Chenbo <chenbo.xia@intel.com>; Pei, Andy <andy.pei@intel.com>;
>>> kim.tae.kyung@navercorp.com; maxime.coquelin@redhat.com; stable@dpdk.org;
>>> Wang, Xiao W <xiao.w.wang@intel.com>
>>> Subject: [PATCH v4] vdpa/ifc: fix update_datapath error handling
>>>
>>> Stop and return the error code when update_datapath fails.
>>> update_datapath prepares resources for the vdpa device.
>>> The driver should not perform any further actions
>>> if update_datapath returns an error.
>>>
>>> Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
>>> Cc: stable@dpdk.org
>>>
>>> Signed-off-by: Taekyung Kim <kim.tae.kyung@navercorp.com>
>>> ---
>>> v4:
>>> * Add rte_vdpa_unregister_device in ifcvf_pci_probe
>>>
>>> v3:
>>> * Fix coding style
>>>
>>> v2:
>>> * Revert the prepared resources before returning an error
>>> * Rebase to 22.11 rc2
>>> * Add fixes and cc for backport
>>>
>>> ---
>>>   drivers/vdpa/ifc/ifcvf_vdpa.c | 27 +++++++++++++++++++++++----
>>>   1 file changed, 23 insertions(+), 4 deletions(-)
>>
>> I can't find your patch in patchwork:
>>
>> http://patchwork.dpdk.org/project/dpdk/list/?series=&submitter=2877&state=*&q=&archive=both&delegate=
>>
>> so it's difficult to review and merge. Do you know why or is it possible
>> that you send a new version to make it show on Patchwork today?
>>
>> Thanks,
>> Chenbo
>>
> 
> Hi Chenbo,
> 
> First, thanks for your review.
> I will send a new version for this patch soon.
> 
> I think the mail for v4 is lost.
> Whenever I send a patch, I received "Your message to dev awaits moderator approval"
> from dev-owner@dpdk.org with the reason "Post by non-member to a members-only list".
> Maybe, the reason is that this is the first time that I submit a patch.

No, I don't think subscription is needed, there should be another issue.
Ali & Thomas, any idea why it happens?

Thanks,
Maxime

> Thanks,
> Taekyung
>
  
Ali Alnubani Nov. 10, 2022, 9:34 a.m. UTC | #13
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Thursday, November 10, 2022 11:20 AM
> To: Taekyung Kim <kim.tae.kyung@navercorp.com>; NBU-Contact-Thomas
> Monjalon (EXTERNAL) <thomas@monjalon.net>; Ali Alnubani
> <alialnu@nvidia.com>
> Cc: dev@dpdk.org; Pei, Andy <andy.pei@intel.com>; stable@dpdk.org;
> Wang, Xiao W <xiao.w.wang@intel.com>; Xia, Chenbo
> <chenbo.xia@intel.com>
> Subject: Re: [PATCH v4] vdpa/ifc: fix update_datapath error handling
> 
> Hi Taekyung,
> 
> Adding Thomas and Ali who maintains the patchwork instance.
> 
> On 11/10/22 05:02, Taekyung Kim wrote:
> > On Thu, Nov 10, 2022 at 01:53:50AM +0000, Xia, Chenbo wrote:
> >> Hi Kim,
> >>
> >>> -----Original Message-----
> >>> From: Taekyung Kim <kim.tae.kyung@navercorp.com>
> >>> Sent: Tuesday, November 8, 2022 4:56 PM
> >>> To: dev@dpdk.org
> >>> Cc: Xia, Chenbo <chenbo.xia@intel.com>; Pei, Andy
> <andy.pei@intel.com>;
> >>> kim.tae.kyung@navercorp.com; maxime.coquelin@redhat.com;
> stable@dpdk.org;
> >>> Wang, Xiao W <xiao.w.wang@intel.com>
> >>> Subject: [PATCH v4] vdpa/ifc: fix update_datapath error handling
> >>>
> >>> Stop and return the error code when update_datapath fails.
> >>> update_datapath prepares resources for the vdpa device.
> >>> The driver should not perform any further actions
> >>> if update_datapath returns an error.
> >>>
> >>> Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
> >>> Cc: stable@dpdk.org
> >>>
> >>> Signed-off-by: Taekyung Kim <kim.tae.kyung@navercorp.com>
> >>> ---
> >>> v4:
> >>> * Add rte_vdpa_unregister_device in ifcvf_pci_probe
> >>>
> >>> v3:
> >>> * Fix coding style
> >>>
> >>> v2:
> >>> * Revert the prepared resources before returning an error
> >>> * Rebase to 22.11 rc2
> >>> * Add fixes and cc for backport
> >>>
> >>> ---
> >>>   drivers/vdpa/ifc/ifcvf_vdpa.c | 27 +++++++++++++++++++++++----
> >>>   1 file changed, 23 insertions(+), 4 deletions(-)
> >>
> >> I can't find your patch in patchwork:
> >>
> >>
> http://patchwork.dpdk.org/project/dpdk/list/?series=&submitter=2877&sta
> te=*&q=&archive=both&delegate=
> >>
> >> so it's difficult to review and merge. Do you know why or is it possible
> >> that you send a new version to make it show on Patchwork today?
> >>
> >> Thanks,
> >> Chenbo
> >>
> >
> > Hi Chenbo,
> >
> > First, thanks for your review.
> > I will send a new version for this patch soon.
> >
> > I think the mail for v4 is lost.
> > Whenever I send a patch, I received "Your message to dev awaits
> moderator approval"
> > from dev-owner@dpdk.org with the reason "Post by non-member to a
> members-only list".
> > Maybe, the reason is that this is the first time that I submit a patch.
> 
> No, I don't think subscription is needed, there should be another issue.
> Ali & Thomas, any idea why it happens?
> 

Hello,

Subscription to the dev mailing list is required for posting without moderator approval.
I see that Taekyung is a member only since Nov 08. Postings prior to his subscription are waiting moderation.

Thanks,
Ali
  
David Marchand Nov. 10, 2022, 9:38 a.m. UTC | #14
On Thu, Nov 10, 2022 at 10:34 AM Ali Alnubani <alialnu@nvidia.com> wrote:
> > > I think the mail for v4 is lost.
> > > Whenever I send a patch, I received "Your message to dev awaits
> > moderator approval"
> > > from dev-owner@dpdk.org with the reason "Post by non-member to a
> > members-only list".
> > > Maybe, the reason is that this is the first time that I submit a patch.
> >
> > No, I don't think subscription is needed, there should be another issue.
> > Ali & Thomas, any idea why it happens?
> >
>
> Hello,
>
> Subscription to the dev mailing list is required for posting without moderator approval.
> I see that Taekyung is a member only since Nov 08. Postings prior to his subscription are waiting moderation.

Indeed, I just flushed the queue.
  
Maxime Coquelin Nov. 10, 2022, 9:42 a.m. UTC | #15
On 11/10/22 10:34, Ali Alnubani wrote:
>> -----Original Message-----
>> From: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Sent: Thursday, November 10, 2022 11:20 AM
>> To: Taekyung Kim <kim.tae.kyung@navercorp.com>; NBU-Contact-Thomas
>> Monjalon (EXTERNAL) <thomas@monjalon.net>; Ali Alnubani
>> <alialnu@nvidia.com>
>> Cc: dev@dpdk.org; Pei, Andy <andy.pei@intel.com>; stable@dpdk.org;
>> Wang, Xiao W <xiao.w.wang@intel.com>; Xia, Chenbo
>> <chenbo.xia@intel.com>
>> Subject: Re: [PATCH v4] vdpa/ifc: fix update_datapath error handling
>>
>> Hi Taekyung,
>>
>> Adding Thomas and Ali who maintains the patchwork instance.
>>
>> On 11/10/22 05:02, Taekyung Kim wrote:
>>> On Thu, Nov 10, 2022 at 01:53:50AM +0000, Xia, Chenbo wrote:
>>>> Hi Kim,
>>>>
>>>>> -----Original Message-----
>>>>> From: Taekyung Kim <kim.tae.kyung@navercorp.com>
>>>>> Sent: Tuesday, November 8, 2022 4:56 PM
>>>>> To: dev@dpdk.org
>>>>> Cc: Xia, Chenbo <chenbo.xia@intel.com>; Pei, Andy
>> <andy.pei@intel.com>;
>>>>> kim.tae.kyung@navercorp.com; maxime.coquelin@redhat.com;
>> stable@dpdk.org;
>>>>> Wang, Xiao W <xiao.w.wang@intel.com>
>>>>> Subject: [PATCH v4] vdpa/ifc: fix update_datapath error handling
>>>>>
>>>>> Stop and return the error code when update_datapath fails.
>>>>> update_datapath prepares resources for the vdpa device.
>>>>> The driver should not perform any further actions
>>>>> if update_datapath returns an error.
>>>>>
>>>>> Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
>>>>> Cc: stable@dpdk.org
>>>>>
>>>>> Signed-off-by: Taekyung Kim <kim.tae.kyung@navercorp.com>
>>>>> ---
>>>>> v4:
>>>>> * Add rte_vdpa_unregister_device in ifcvf_pci_probe
>>>>>
>>>>> v3:
>>>>> * Fix coding style
>>>>>
>>>>> v2:
>>>>> * Revert the prepared resources before returning an error
>>>>> * Rebase to 22.11 rc2
>>>>> * Add fixes and cc for backport
>>>>>
>>>>> ---
>>>>>    drivers/vdpa/ifc/ifcvf_vdpa.c | 27 +++++++++++++++++++++++----
>>>>>    1 file changed, 23 insertions(+), 4 deletions(-)
>>>>
>>>> I can't find your patch in patchwork:
>>>>
>>>>
>> http://patchwork.dpdk.org/project/dpdk/list/?series=&submitter=2877&sta
>> te=*&q=&archive=both&delegate=
>>>>
>>>> so it's difficult to review and merge. Do you know why or is it possible
>>>> that you send a new version to make it show on Patchwork today?
>>>>
>>>> Thanks,
>>>> Chenbo
>>>>
>>>
>>> Hi Chenbo,
>>>
>>> First, thanks for your review.
>>> I will send a new version for this patch soon.
>>>
>>> I think the mail for v4 is lost.
>>> Whenever I send a patch, I received "Your message to dev awaits
>> moderator approval"
>>> from dev-owner@dpdk.org with the reason "Post by non-member to a
>> members-only list".
>>> Maybe, the reason is that this is the first time that I submit a patch.
>>
>> No, I don't think subscription is needed, there should be another issue.
>> Ali & Thomas, any idea why it happens?
>>
> 
> Hello,
> 
> Subscription to the dev mailing list is required for posting without moderator approval.
> I see that Taekyung is a member only since Nov 08. Postings prior to his subscription are waiting moderation.

Ok, thanks. I did not know!

Maxime

> Thanks,
> Ali
  
Taekyung Kim Nov. 10, 2022, 9:45 a.m. UTC | #16
On Thu, Nov 10, 2022 at 10:38:55AM +0100, David Marchand wrote:
> On Thu, Nov 10, 2022 at 10:34 AM Ali Alnubani <alialnu@nvidia.com> wrote:
> > > > I think the mail for v4 is lost.
> > > > Whenever I send a patch, I received "Your message to dev awaits
> > > moderator approval"
> > > > from dev-owner@dpdk.org with the reason "Post by non-member to a
> > > members-only list".
> > > > Maybe, the reason is that this is the first time that I submit a patch.
> > >
> > > No, I don't think subscription is needed, there should be another issue.
> > > Ali & Thomas, any idea why it happens?
> > >
> >
> > Hello,
> >
> > Subscription to the dev mailing list is required for posting without moderator approval.
> > I see that Taekyung is a member only since Nov 08. Postings prior to his subscription are waiting moderation.
> 
> Indeed, I just flushed the queue.
> 
> 
> -- 
> David Marchand
> 

Hello,

I fully understand what was the problem. It was my mistake.
I will be more cautious before sending a patch.
Thanks for your detailed explanation.

Thanks,
Taekyung
  

Patch

diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index 8dfd49336e..0396d49122 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -1098,7 +1098,12 @@  ifcvf_dev_config(int vid)
 	internal = list->internal;
 	internal->vid = vid;
 	rte_atomic32_set(&internal->dev_attached, 1);
-	update_datapath(internal);
+	if (update_datapath(internal) < 0) {
+		DRV_LOG(ERR, "failed to update datapath for vDPA device %s",
+			vdev->device->name);
+		rte_atomic32_set(&internal->dev_attached, 0);
+		return -1;
+	}
 
 	hw = &internal->hw;
 	for (i = 0; i < hw->nr_vring; i++) {
@@ -1146,7 +1151,12 @@  ifcvf_dev_close(int vid)
 		internal->sw_fallback_running = false;
 	} else {
 		rte_atomic32_set(&internal->dev_attached, 0);
-		update_datapath(internal);
+		if (update_datapath(internal) < 0) {
+			DRV_LOG(ERR, "failed to update datapath for vDPA device %s",
+				vdev->device->name);
+			internal->configured = 0;
+			return -1;
+		}
 	}
 
 	internal->configured = 0;
@@ -1752,7 +1762,14 @@  ifcvf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	}
 
 	rte_atomic32_set(&internal->started, 1);
-	update_datapath(internal);
+	if (update_datapath(internal) < 0) {
+		DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
+		rte_atomic32_set(&internal->started, 0);
+		pthread_mutex_lock(&internal_list_lock);
+		TAILQ_REMOVE(&internal_list, list, next);
+		pthread_mutex_unlock(&internal_list_lock);
+		goto error;
+	}
 
 	rte_kvargs_free(kvlist);
 	return 0;
@@ -1781,7 +1798,8 @@  ifcvf_pci_remove(struct rte_pci_device *pci_dev)
 
 	internal = list->internal;
 	rte_atomic32_set(&internal->started, 0);
-	update_datapath(internal);
+	if (update_datapath(internal) < 0)
+		DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
 
 	rte_pci_unmap_device(internal->pdev);
 	rte_vfio_container_destroy(internal->vfio_container_fd);