Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2602278lqz; Wed, 3 Apr 2024 03:09:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUJBct9mR93ae633j2Zd6Td9Te4wTJ6MGMkDrxbw+oQsg3sF2PZscKKzDKpaUUB/3jQc9+p9KiSylPKJeCWoczpz86rQMmW6lv8+ECQqw== X-Google-Smtp-Source: AGHT+IFGHmC/bBiBqPfxxOHmtEOGrhv76BS/bzdau1xi5aD3+AuwNQF1K49rGuZJjWP0Vo1tmQBP X-Received: by 2002:a05:620a:227:b0:78b:c225:61a9 with SMTP id u7-20020a05620a022700b0078bc22561a9mr16529669qkm.37.1712138940023; Wed, 03 Apr 2024 03:09:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712138940; cv=pass; d=google.com; s=arc-20160816; b=To1cZZStrgODyoW9Jd8S/gXE1gqj8pRTjYMx0SGhxLV+mNhiHNZSmjLZqfp2xNNeSt SIaSY7Lf0KzUAgl0YwIiGlAoZIYLc9HaRpDT5Sg0IPpTPMPzAkA5o5DaoaetpPGxvoaR sbayoQE2V+LF0ArfI1J2p8ka7sEoMR5khItY+vTbu9sPKMpvzs4FJjnyA/Rd0ZqnlTDU LzZ+5FSZPQXfA6vedeoy8ncYx1bYVUjKH5zknq9epT+z9XEUeYEmnZMgcLRsHnV11GMy GJYpHJsHLS7wALRr53pGz4ipiGJeLwCdFyQClHETx4qShSbw7mURC6dG/YJNOT7Xxxbv lhHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=hUQJU7gbk3p+NCgV/w+KJx3592qNkN9vsnuFe1I41x8=; fh=VzMToBYo5MUfLaQO74C2Chjt/otG4r80qnd7ynZ/RBQ=; b=WjY/ctrHZa+KjQAxe0BmNFplTvE0l3dNhhjERFL+6+C9tzWtIsZbFl+OYbJtcwh/kT g8oU7jxdtV0QRR6kpkIntkCEMwn56HMJErfS1EgVhvTQd6+kjPiOz+8EASsJe5AfA+mA p3Wk6Jjzo8daFhjmX8X/mINIR/g+62+4Y74ZccUifLIPoPvE7Li8sHXI0roqTi8nuua7 kscYzveQgn9bxjKCve6zifp2V5/QsWxyDRXFBW5vX/NIjEcFITNiJBAUht/EJE+CDwwX fadNlMecRYhM8UaImNQGfc/kFSO1Pj6IPEvzwC43p2goNVnEPRnpW49ZylGaMCc8hOqx WFNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-crypto+bounces-3297-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3297-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h19-20020a05620a285300b0078be7ef8a9asi5972188qkp.741.2024.04.03.03.08.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 03:09:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3297-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-crypto+bounces-3297-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3297-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 54EE21C273D6 for ; Wed, 3 Apr 2024 10:08:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3841613D8BF; Wed, 3 Apr 2024 10:05:49 +0000 (UTC) X-Original-To: linux-crypto@vger.kernel.org Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4B1213DDC7; Wed, 3 Apr 2024 10:05:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712138749; cv=none; b=nlXGBPX9QczeLeiZ+vPRw4DOChVu5OqLsR91rp+e0j8Q+MZUIu911DXskBi2qSsi3xekEHPJX3I+zIyJp5Ot9tbv9u1dcLiigSrivvcMuKv3WDb1nr6u7Q5mDKccIoosR3EgbmkGCp48DPT5eCtOVlUP8qK+ZnW6u+h7PWMfUWY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712138749; c=relaxed/simple; bh=IWmag/TML6Tv6Hu6G9U6MPtnz9M6+9Xlreue3sMUpMQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=owl4i6hlKQVd6Cd16fdfTXQeWPDfJv1F/FZY0mTsUlTPN7lTJpoI5mZ8uhUu0MLoSJKN0QJ1gRJLLQw9lj4mQO6t/UNzAkbiHkgXrs0NhoBciJrJqrhz2/lRFtohWuowkhi+rHdmVCrZKIWhTifsxwZe4hD5dZoMGU6RRaaSYSM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4V8gMh6bNlzbf84; Wed, 3 Apr 2024 18:04:32 +0800 (CST) Received: from dggpemd200003.china.huawei.com (unknown [7.185.36.122]) by mail.maildlp.com (Postfix) with ESMTPS id E2F3514037B; Wed, 3 Apr 2024 18:05:27 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by dggpemd200003.china.huawei.com (7.185.36.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Wed, 3 Apr 2024 18:05:27 +0800 From: Chenghai Huang To: , CC: , , , , , , , , , , , Subject: [PATCH 3/9] crypto: hisilicon/sgl - Delete redundant parameter verification Date: Wed, 3 Apr 2024 18:00:56 +0800 Message-ID: <20240403100102.2735306-4-huangchenghai2@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240403100102.2735306-1-huangchenghai2@huawei.com> References: <20240403100102.2735306-1-huangchenghai2@huawei.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemd200003.china.huawei.com (7.185.36.122) The input parameter check in acc_get_sgl is redundant. The caller has been verified once. When the check is performed for multiple times, the performance deteriorates. So the redundant parameter verification is deleted, and the index verification is changed to the module entry function for verification. Signed-off-by: Chenghai Huang --- drivers/crypto/hisilicon/sgl.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/crypto/hisilicon/sgl.c b/drivers/crypto/hisilicon/sgl.c index 0beca257c20b..568acd0aee3f 100644 --- a/drivers/crypto/hisilicon/sgl.c +++ b/drivers/crypto/hisilicon/sgl.c @@ -161,9 +161,6 @@ static struct hisi_acc_hw_sgl *acc_get_sgl(struct hisi_acc_sgl_pool *pool, struct mem_block *block; u32 block_index, offset; - if (!pool || !hw_sgl_dma || index >= pool->count) - return ERR_PTR(-EINVAL); - block = pool->mem_block; block_index = index / pool->sgl_num_per_block; offset = index % pool->sgl_num_per_block; @@ -230,7 +227,7 @@ hisi_acc_sg_buf_map_to_hw_sgl(struct device *dev, struct scatterlist *sg; int sg_n; - if (!dev || !sgl || !pool || !hw_sgl_dma) + if (!dev || !sgl || !pool || !hw_sgl_dma || index >= pool->count) return ERR_PTR(-EINVAL); sg_n = sg_nents(sgl); -- 2.30.0