From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B50B4A057C; Tue, 24 Mar 2020 15:24:58 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7F2611C045; Tue, 24 Mar 2020 15:24:49 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 333474C8E for ; Tue, 24 Mar 2020 15:24:46 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from asafp@mellanox.com) with ESMTPS (AES256-SHA encrypted); 24 Mar 2020 16:24:42 +0200 Received: from pegasus07.mtr.labs.mlnx (pegasus07.mtr.labs.mlnx [10.210.16.112]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 02OEOgQe022008; Tue, 24 Mar 2020 16:24:42 +0200 From: Asaf Penso To: dev@dpdk.org Cc: Viacheslav Ovsiienko , Shahaf Shuler , Maxime Coquelin , Matan Azrad Date: Tue, 24 Mar 2020 14:24:36 +0000 Message-Id: <1585059877-2369-4-git-send-email-asafp@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1585059877-2369-1-git-send-email-asafp@mellanox.com> References: <1585059877-2369-1-git-send-email-asafp@mellanox.com> Subject: [dpdk-dev] [PATCH 3/4] vdpa/mlx5: validate notifier configuration X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Matan Azrad When both, direct and indirect notifier management cannot be configured, return an error. Signed-off-by: Matan Azrad Acked-by: Viacheslav Ovsiienko --- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c index 6390385..8bebb92 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c @@ -46,7 +46,7 @@ int retries = MLX5_VDPA_INTR_RETRIES; int ret = -EAGAIN; - if (virtq->intr_handle.fd) { + if (virtq->intr_handle.fd != -1) { while (retries-- && ret == -EAGAIN) { ret = rte_intr_callback_unregister(&virtq->intr_handle, mlx5_vdpa_virtq_handler, @@ -59,7 +59,7 @@ usleep(MLX5_VDPA_INTR_RETRIES_USEC); } } - memset(&virtq->intr_handle, 0, sizeof(virtq->intr_handle)); + virtq->intr_handle.fd = -1; } if (virtq->virtq) { claim_zero(mlx5_devx_cmd_destroy(virtq->virtq)); @@ -255,15 +255,25 @@ rte_write32(virtq->index, priv->virtq_db_addr); /* Setup doorbell mapping. */ virtq->intr_handle.fd = vq.kickfd; - virtq->intr_handle.type = RTE_INTR_HANDLE_EXT; - if (rte_intr_callback_register(&virtq->intr_handle, - mlx5_vdpa_virtq_handler, virtq)) { - virtq->intr_handle.fd = 0; - DRV_LOG(ERR, "Failed to register virtq %d interrupt.", index); - goto error; + if (virtq->intr_handle.fd == -1) { + DRV_LOG(WARNING, "Virtq %d kickfd is invalid.", index); + if (!priv->direct_notifier) { + DRV_LOG(ERR, "Virtq %d cannot be notified.", index); + goto error; + } } else { - DRV_LOG(DEBUG, "Register fd %d interrupt for virtq %d.", - virtq->intr_handle.fd, index); + virtq->intr_handle.type = RTE_INTR_HANDLE_EXT; + if (rte_intr_callback_register(&virtq->intr_handle, + mlx5_vdpa_virtq_handler, + virtq)) { + virtq->intr_handle.fd = -1; + DRV_LOG(ERR, "Failed to register virtq %d interrupt.", + index); + goto error; + } else { + DRV_LOG(DEBUG, "Register fd %d interrupt for virtq %d.", + virtq->intr_handle.fd, index); + } } return 0; error: -- 1.8.3.1