From patchwork Thu Nov 10 04:09:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taekyung Kim X-Patchwork-Id: 119695 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 45534A04FD; Thu, 10 Nov 2022 05:09:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DB8FF400EF; Thu, 10 Nov 2022 05:09:53 +0100 (CET) Received: from cvbackendsmtp001.nmdf.navercorp.com (cvbackendsmtp001.nmdf.navercorp.com [125.209.246.148]) by mails.dpdk.org (Postfix) with ESMTP id DF9E9400D4; Thu, 10 Nov 2022 05:09:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=navercorp.com; s=s20171120; t=1668053390; bh=8LxgeVz5eHPmcJzmhEsoku5mbeNONXbjro5DRaqyKDQ=; h=From:To:Subject:Date:Message-Id:From:Subject:Feedback-ID: X-Works-Security; b=jUuEutxePhdHoPX4A0EWhDz1tOZAJ0Mk3RABx0T8U3hJ/OdcZRA85nO+AieNfwwmq LABQLpSxiO4+19YXlFyBlaz10zycJM1CLLtDtdoiEwwQ1/crzhIuCq+j5lI5WH0cxg IS0auPcDAwRfn/eDIp/wG3AQ5xQqn0h7L4QeGfNpqPngI5UnPpYHdMf3hxSrb5VK31 htFvSlXoJOR7syBO+VnDd2w+wqSq1JujWn7fafoztOjkWmfZf3gpTJp4ohTfb7sW/2 7M8QSXYxKKdOoH9anxqRCjJLh2tVByKJul1a5ZTgyCrhF1cgZ5l9MX86HYd0xT2ZiO RzWc7hdJLXM2A== X-Session-ID: N3DQVdF6TwSEi80gChU8Yg X-Works-Smtp-Source: XrbZKA2rFoJCpNmmaxvmWHF0 Received: from dev-tkkim-git-send-email-ncl.nfra.io ([10.113.149.62]) by cvbackendsmtp001.nmdf.navercorp.com with ESMTP id N3DQVdF6TwSEi80gChU8Yg for ; Thu, 10 Nov 2022 04:09:50 -0000 From: Taekyung Kim To: dev@dpdk.org Cc: chenbo.xia@intel.com, andy.pei@intel.com, kim.tae.kyung@navercorp.com, maxime.coquelin@redhat.com, stable@dpdk.org, xiao.w.wang@intel.com Subject: [PATCH v5] vdpa/ifc: fix update_datapath error handling Date: Thu, 10 Nov 2022 13:09:43 +0900 Message-Id: <20221110040943.82876-1-kim.tae.kyung@navercorp.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Reviewed-by: Chenbo Xia --- 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);