[PATCH] 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. Signed-off-by: Taekyung Kim --- drivers/vdpa/ifc/ifcvf_vdpa.c | 20 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c index d5ac583589..795967e998 100644 --- a/drivers/vdpa/ifc/ifcvf_vdpa.c +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c @@ -1063,7 +1063,10 @@ 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: %p", vdev); + return -1; + } if (rte_vhost_host_notifier_ctrl(vid, RTE_VHOST_QUEUE_ALL, true) != 0) DRV_LOG(NOTICE, "vDPA (%s): software relay is used.", @@ -1105,7 +1108,10 @@ 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: %p", vdev); + return -1; + } } internal->configured = 0; @@ -1632,7 +1638,10 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, pthread_mutex_unlock(&internal_list_lock); 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); + return -1; + } rte_kvargs_free(kvlist); return 0; @@ -1661,7 +1670,10 @@ 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); + return -1; + } rte_pci_unmap_device(internal->pdev); rte_vfio_container_destroy(internal->vfio_container_fd); -- 2.37.0 (Apple Git-136)
[PATCH] vdpa/ifc: fix update datapath error handling
Stop and return the error code if 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. Signed-off-by: Taekyung Kim --- drivers/vdpa/ifc/ifcvf_vdpa.c | 20 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c index d5ac583589..795967e998 100644 --- a/drivers/vdpa/ifc/ifcvf_vdpa.c +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c @@ -1063,7 +1063,10 @@ 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: %p", vdev); + return -1; + } if (rte_vhost_host_notifier_ctrl(vid, RTE_VHOST_QUEUE_ALL, true) != 0) DRV_LOG(NOTICE, "vDPA (%s): software relay is used.", @@ -1105,7 +1108,10 @@ 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: %p", vdev); + return -1; + } } internal->configured = 0; @@ -1632,7 +1638,10 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, pthread_mutex_unlock(&internal_list_lock); 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); + return -1; + } rte_kvargs_free(kvlist); return 0; @@ -1661,7 +1670,10 @@ 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); + return -1; + } rte_pci_unmap_device(internal->pdev); rte_vfio_container_destroy(internal->vfio_container_fd); -- 2.30.1 (Apple Git-130)
[PATCH] vdpa/ifc: fix update_datapath error handling
Stop and return the error code if 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. Signed-off-by: Taekyung Kim --- drivers/vdpa/ifc/ifcvf_vdpa.c | 20 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c index d5ac583589..795967e998 100644 --- a/drivers/vdpa/ifc/ifcvf_vdpa.c +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c @@ -1063,7 +1063,10 @@ 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: %p", vdev); + return -1; + } if (rte_vhost_host_notifier_ctrl(vid, RTE_VHOST_QUEUE_ALL, true) != 0) DRV_LOG(NOTICE, "vDPA (%s): software relay is used.", @@ -1105,7 +1108,10 @@ 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: %p", vdev); + return -1; + } } internal->configured = 0; @@ -1632,7 +1638,10 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, pthread_mutex_unlock(&internal_list_lock); 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); + return -1; + } rte_kvargs_free(kvlist); return 0; @@ -1661,7 +1670,10 @@ 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); + return -1; + } rte_pci_unmap_device(internal->pdev); rte_vfio_container_destroy(internal->vfio_container_fd); -- 2.30.1 (Apple Git-130)
[PATCH v2] 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: sta...@dpdk.org Signed-off-by: Taekyung Kim --- 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 | 25 + 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c index 8dfd49336e..e25fb16106 100644 --- a/drivers/vdpa/ifc/ifcvf_vdpa.c +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c @@ -1098,7 +1098,11 @@ 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 +1150,11 @@ 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 +1760,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 +1796,9 @@ 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
[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: sta...@dpdk.org Signed-off-by: Taekyung Kim --- 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
Re: [PATCH v3] vdpa/ifc: fix update_datapath error handling
Hi Chenbo, Thanks for your review. On Tue, Nov 08, 2022 at 01:46:37AM +, Xia, Chenbo wrote: > > -Original Message- > > From: Taekyung Kim > > Sent: Monday, November 7, 2022 5:00 PM > > To: dev@dpdk.org > > Cc: sta...@dpdk.org; maxime.coque...@redhat.com; Xia, Chenbo > > ; Wang, Xiao W ; > > kim.tae.ky...@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: sta...@dpdk.org > > > > Signed-off-by: Taekyung Kim > > --- > > 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
Re: [PATCH v4] vdpa/ifc: fix update_datapath error handling
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: sta...@dpdk.org > > > > Signed-off-by: Taekyung Kim > > --- > > 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 > > Thanks, > Maxime >
Re: [PATCH v4] vdpa/ifc: fix update_datapath error handling
Hi Andy, Thanks for your review. On Wed, Nov 09, 2022 at 02:39:09AM +, Pei, Andy wrote: > > > > -Original Message- > > From: Taekyung Kim > > Sent: Tuesday, November 8, 2022 4:56 PM > > To: dev@dpdk.org > > Cc: Xia, Chenbo ; Pei, Andy ; > > kim.tae.ky...@navercorp.com; maxime.coque...@redhat.com; > > sta...@dpdk.org; Wang, Xiao W > > 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: sta...@dpdk.org > > > > Signed-off-by: Taekyung Kim > > --- > > 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
Re: [PATCH v4] vdpa/ifc: fix update_datapath error handling
On Thu, Nov 10, 2022 at 01:53:50AM +, Xia, Chenbo wrote: > Hi Kim, > > > -Original Message- > > From: Taekyung Kim > > Sent: Tuesday, November 8, 2022 4:56 PM > > To: dev@dpdk.org > > Cc: Xia, Chenbo ; Pei, Andy ; > > kim.tae.ky...@navercorp.com; maxime.coque...@redhat.com; sta...@dpdk.org; > > Wang, Xiao W > > 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: sta...@dpdk.org > > > > Signed-off-by: Taekyung Kim > > --- > > 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-ow...@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
[PATCH v5] 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: sta...@dpdk.org Signed-off-by: Taekyung Kim --- v5: * Resubmit to patchwork 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
Re: [PATCH v3] vdpa/ifc: fix update_datapath error handling
On Tue, Nov 08, 2022 at 07:56:18AM +, Xia, Chenbo wrote: > > -Original Message- > > From: Pei, Andy > > Sent: Tuesday, November 8, 2022 3:39 PM > > To: Xia, Chenbo ; Taekyung Kim > > ; dev@dpdk.org > > Cc: sta...@dpdk.org; maxime.coque...@redhat.com; Wang, Xiao W > > > > Subject: RE: [PATCH v3] vdpa/ifc: fix update_datapath error handling > > > > Hi > > > > See my reply inline. > > > > > -Original Message- > > > From: Xia, Chenbo > > > Sent: Tuesday, November 8, 2022 9:47 AM > > > To: Taekyung Kim ; dev@dpdk.org > > > Cc: sta...@dpdk.org; maxime.coque...@redhat.com; Wang, Xiao W > > > > > > Subject: RE: [PATCH v3] vdpa/ifc: fix update_datapath error handling > > > > > > > -Original Message- > > > > From: Taekyung Kim > > > > Sent: Monday, November 7, 2022 5:00 PM > > > > To: dev@dpdk.org > > > > Cc: sta...@dpdk.org; maxime.coque...@redhat.com; Xia, Chenbo > > > > ; Wang, Xiao W ; > > > > kim.tae.ky...@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: sta...@dpdk.org > > > > > > > > Signed-off-by: Taekyung Kim > > > > --- > > > > 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); > > > >
[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: sta...@dpdk.org Signed-off-by: Taekyung Kim --- 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
Re: [PATCH v4] vdpa/ifc: fix update_datapath error handling
On Thu, Nov 10, 2022 at 10:38:55AM +0100, David Marchand wrote: > On Thu, Nov 10, 2022 at 10:34 AM Ali Alnubani 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-ow...@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