From patchwork Fri Oct 14 13:18:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taekyung Kim X-Patchwork-Id: 119035 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 39869A0542; Mon, 24 Oct 2022 17:33:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C324B42BB8; Mon, 24 Oct 2022 17:33:08 +0200 (CEST) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by mails.dpdk.org (Postfix) with ESMTP id D4F1A42C6E for ; Fri, 14 Oct 2022 15:18:46 +0200 (CEST) Received: by mail-pf1-f172.google.com with SMTP id f140so4900180pfa.1 for ; Fri, 14 Oct 2022 06:18:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=GauJimOXhJwkkdDg9L3OhpGU6Pip50sjCyMcqEbU7ho=; b=pMJ95c+6m2zbeV1vFY7DoLR/SI1GlnL9skueGbhKwrlJMNw6iBVDws1b+Dq9gdzFyP pAbwe9J8amMd3r6QANTcj/YldmteB47amL/2ByfGy7Wg6lHjS00U8qlwjEvx03F1gZ9I QJm00zKytxh27WAak7/NhCyLdPLYGDBRg1eGX+xtEN3mNRm4k72Hp2Jlze8TN9ek+DbY PCe2S0ryd1cJW18+wNEZVNEshNlbfPtrtxxFlqZT1EkQ3LmlwodQfN3zCUtLexkbfm0j 1GIn0/sl+/mxGB8E32jhzRnnlwFeW1ref/8HLq4D9DAy0hawbzHrUHBFh6oJ0JO2PpiO dQIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GauJimOXhJwkkdDg9L3OhpGU6Pip50sjCyMcqEbU7ho=; b=0lQa8Z3F1//3oG3nL9VYVh8K2udndHICjQO7sFjeTQF8EDPZC9BWPFLbKpRspDWWsU LeGr4MhZ97HSowpMudh18YHYPFJcJ/sv6MN7KSLiRXAHS9EOxO0i5galMornG/i3cNqv dLp/yM8RdEoWcKZhhcFY25b0BJc8J+4CPw/O3jfllTSetK7T/lMDToOCQwgJhozRDvVl aSa2J/QbLODMWE+WKPq89V62Dw6Lho/428pPFnRqXJD5mneuxOHDGQMdSGgfda602Q6x nLImu+guErwboZUSdhygCPYBqEXLtjiRF0/S9SF2mLIof5cgwskh5Z/2gPJQZy5ZyK1I vkAg== X-Gm-Message-State: ACrzQf35gNMZcA4dndpryBwLmKy44lCjkyXO9W78t83KeU7yDaHo6+2b 9P6cTw+oxwWPSiY0KFTxAu0miJJjOJE= X-Google-Smtp-Source: AMsMyM5fxitBkhcu8VzWl2wprzrhbO+eQQB0JgNhR9H7Ro27iVxoBCiPsvJI1o0AhPzhGAG9PjvX4Q== X-Received: by 2002:a05:6a00:2184:b0:561:4fb2:86f with SMTP id h4-20020a056a00218400b005614fb2086fmr5394309pfi.10.1665753525915; Fri, 14 Oct 2022 06:18:45 -0700 (PDT) Received: from localhost.localdomain ([121.124.172.139]) by smtp.gmail.com with ESMTPSA id x6-20020a170902a38600b00179988ca61bsm1650792pla.161.2022.10.14.06.18.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 14 Oct 2022 06:18:44 -0700 (PDT) From: Taekyung Kim X-Google-Original-From: Taekyung Kim To: dev@dpdk.org Cc: Taekyung Kim , Xiao Wang Subject: [PATCH] vdpa/ifc: fix update_datapath error handling Date: Fri, 14 Oct 2022 22:18:36 +0900 Message-Id: <20221014131836.46728-1-kim.tae.kyung@navercorp.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 24 Oct 2022 17:33:00 +0200 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. 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);