From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 54FFE424D8; Wed, 12 Jun 2024 06:37:09 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D60D040DF5; Wed, 12 Jun 2024 06:36:45 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by mails.dpdk.org (Postfix) with ESMTP id 5D2A940DF5 for ; Wed, 12 Jun 2024 06:36:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718167005; x=1749703005; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7dnIseQgIXgimXPpCDr5fnXymXqv8SX7maygOcS5F5s=; b=cOiRh6byEel5DqWu+r2wPcHq572JgmGj/KXIufzKFzSvsjygSnPy5Qpl IRX8VbUft48x8ikpfKJJxsJBLdzxiRMBRgV8r+o4mtNe5+BIX90UtA3bh Swu8bDpI5gTeLR4zwunb071BXs2ZbB4NpfWIslwEFLEN9W/Ch+0POAvDj +hRMo8yFFnDEwJIbKdPzpX8yEII7uapJ5snNlyxFunJlxwzZdf/KtGRhm bJ324YP3p1Oq1HQFqozPtleRLYS76VZUq/LsYa+L5KGli8uZhiKHBmwv7 3g3PdVADr9mFY7eDuxAwONMAxiIs3jy1HZZRUcODdLqYWtUjwSURGyeQ5 w==; X-CSE-ConnectionGUID: n0FLB9kPQjCws66t2CQmFg== X-CSE-MsgGUID: nULwSP2yQKedKkpD/GErKw== X-IronPort-AV: E=McAfee;i="6600,9927,11100"; a="18742183" X-IronPort-AV: E=Sophos;i="6.08,232,1712646000"; d="scan'208";a="18742183" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2024 21:36:44 -0700 X-CSE-ConnectionGUID: pEbDOeboSvCS6kEOddCqMw== X-CSE-MsgGUID: 94dlLFVzQ8KV8CM+OlZKQg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,232,1712646000"; d="scan'208";a="40281911" Received: from unknown (HELO npf-hyd-clx-03..) ([10.145.170.182]) by orviesa008.jf.intel.com with ESMTP; 11 Jun 2024 21:36:42 -0700 From: Soumyadeep Hore To: bruce.richardson@intel.com, anatoly.burakov@intel.com Cc: dev@dpdk.org Subject: [PATCH v3 05/22] common/idpf: avoid defensive programming Date: Wed, 12 Jun 2024 03:52:40 +0000 Message-ID: <20240612035257.2245824-6-soumyadeep.hore@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240612035257.2245824-1-soumyadeep.hore@intel.com> References: <20240604080611.2197835-1-soumyadeep.hore@intel.com> <20240612035257.2245824-1-soumyadeep.hore@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Based on the upstream feedback, driver should not use any defensive programming strategy by checking for NULL pointers and other conditional checks unnecessarily in the code flow to fall back, instead fail and fix the bug in a proper way. Some of the checks are identified and removed/wrapped in this patch: - As the control queue is freed and deleted from the list after the idpf_ctlq_shutdown call, there is no need to have the ring_size check in idpf_ctlq_shutdown. - From the upstream perspective shared code is part of the Linux driver and it doesn't make sense to add zero 'len' and 'buf_size' check in idpf_ctlq_add as to start with, driver provides valid sizes, if not it is a bug. - Remove cq NULL and zero ring_size check wherever possible as the IDPF driver code flow does not pass any NULL cq pointer to the control queue callbacks. If it passes then it is a bug and should be fixed rather than checking for NULL pointer and falling back which is not the right way. Signed-off-by: Soumyadeep Hore --- drivers/common/idpf/base/idpf_controlq.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/common/idpf/base/idpf_controlq.c b/drivers/common/idpf/base/idpf_controlq.c index bada75abfc..b5ba9c3bd0 100644 --- a/drivers/common/idpf/base/idpf_controlq.c +++ b/drivers/common/idpf/base/idpf_controlq.c @@ -98,9 +98,6 @@ static void idpf_ctlq_shutdown(struct idpf_hw *hw, struct idpf_ctlq_info *cq) { idpf_acquire_lock(&cq->cq_lock); - if (!cq->ring_size) - goto shutdown_sq_out; - #ifdef SIMICS_BUILD wr32(hw, cq->reg.head, 0); wr32(hw, cq->reg.tail, 0); @@ -115,7 +112,6 @@ static void idpf_ctlq_shutdown(struct idpf_hw *hw, struct idpf_ctlq_info *cq) /* Set ring_size to 0 to indicate uninitialized queue */ cq->ring_size = 0; -shutdown_sq_out: idpf_release_lock(&cq->cq_lock); idpf_destroy_lock(&cq->cq_lock); } -- 2.43.0