From patchwork Thu Dec 14 11:42:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Md Sadre Alam X-Patchwork-Id: 178681 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8478694dys; Thu, 14 Dec 2023 03:43:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbtIn+F3J79LwcT93B38XPUo00W/d6/pHoa4gR/OHabjByg935XTqWAi0dVx+X1R/+r/HS X-Received: by 2002:a05:6808:1294:b0:3b8:b063:5058 with SMTP id a20-20020a056808129400b003b8b0635058mr10142419oiw.89.1702554199186; Thu, 14 Dec 2023 03:43:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702554199; cv=none; d=google.com; s=arc-20160816; b=qwbrO4RNDfn1WsAIAAZkAg1SAUvdw1ronW7dImjwJhTIseRFimseAnmBq06X0NTW1w thntk22atPBTiDLP3UuuAwz3mNRKU5HOS79/GQD4sM+Sr/rjqfEHMf/MqrF1yD/9pd7W 9e2KhpmOOEPInB5XnLEtg5xYArKb3ONVLIKZgdnM5nUsyZ6i8lvBHj2c9PWsbUCyrEzw 6A+fzEMluezp85rhrBK/Sstqc4Ywt+wH+7aZ8MdGOlWU5QbWr+c1DbV4ne89dU0JBuH7 zQTtwJi2iZrthhLEyFvPRyoHidpHVeS16hM5KQl+DroIkmdblkJVp1a8NX5Cq3mkABKQ cv3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wFSa4XbhxhY/eUFYQapfTu49LcidIL4qfDML5fBRy48=; fh=TEn06IatapHMgkFhNRCYXHrnqycBlFaJECTG22CvvEc=; b=mYwAK59CbcgiB51jGyRhJwX8IXgd2XPF+tsIJKKVBhRomLvwXl8105KHlCuyMBGsZy ZZj/wp9jtZtrlVr1yMiKnA7Dl7aeIdM94JZ3KjdXjTFUy2NEUKaoIt9/qEs2UhPnksRe y5KZaV6DBY+eyYUYn1o/LqrRmfjsGNR18F2x+UUW6C6CbYm3to7178D2K4loYb5kKzep H79rPXpnER+2SLjVq7Typ7Yf+HGKfagxZEQ2NiDlGRagazvS90RkON/9Tzt5NVWxwG2S 4zLB+zMi3BOChRSAQjBqeq767C3po/Gx7yUpakR69/EtA2lxoHANMkGGcRjRPXirVx/i Wdaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Rb0G1WOH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id k3-20020aa788c3000000b006cde0cf5f88si11361601pff.51.2023.12.14.03.43.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:43:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Rb0G1WOH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 398198026ACA; Thu, 14 Dec 2023 03:43:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444115AbjLNLnA (ORCPT + 99 others); Thu, 14 Dec 2023 06:43:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444019AbjLNLmv (ORCPT ); Thu, 14 Dec 2023 06:42:51 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44CD9113; Thu, 14 Dec 2023 03:42:57 -0800 (PST) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BE8vLAZ014002; Thu, 14 Dec 2023 11:42:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=qcppdkim1; bh=wFSa4Xb hxhY/eUFYQapfTu49LcidIL4qfDML5fBRy48=; b=Rb0G1WOHvRZOvOIQ3cti9Tg 1sFPayY1LExNQUEVdcacA94O8rv9SP5myUlFUVIAeu3M1qTBvG54uBnngkSJWWpq Y9zNURoGiCVkHy8vxDYhkwv/XDBgwcuZU+5r/Lxrd0uN0QyVv5A4ilI7kRuem59m JbH56gLtCJWqwUTfFaAjTpyCZ3Qg/MF0i4DEORMDZ75wkMxwpIxoy8Y1Za6M1s1L 62o8oLyZCWCO3gd4aQW7iwl/AV2Bwr2qw12/0X8MBge5pwkOHFq/WUauIACZwRoo jIQ649S364hg5T3dPIKlAYwAKDCpjiRAzqX43+Bbvt5xH9XCjbxsUg8Kcy2W3BQ= = Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uyqgt159w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Dec 2023 11:42:47 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 3BEBgiLV003250; Thu, 14 Dec 2023 11:42:44 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3uvhaktchd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Dec 2023 11:42:44 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3BEBgh1C002935; Thu, 14 Dec 2023 11:42:44 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-mdalam-blr.qualcomm.com [10.131.36.157]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3BEBgic6003206 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Dec 2023 11:42:44 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 466583) id 9BB7141673; Thu, 14 Dec 2023 17:12:42 +0530 (+0530) From: Md Sadre Alam To: thara.gopinath@gmail.com, herbert@gondor.apana.org.au, davem@davemloft.net, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, vkoul@kernel.org, linux-crypto@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, quic_srichara@quicinc.com, quic_varada@quicinc.com Cc: quic_mdalam@quicinc.com Subject: [PATCH 08/11] crypto: qce - Add support for lock aquire,lock release api. Date: Thu, 14 Dec 2023 17:12:36 +0530 Message-Id: <20231214114239.2635325-9-quic_mdalam@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231214114239.2635325-1-quic_mdalam@quicinc.com> References: <20231214114239.2635325-1-quic_mdalam@quicinc.com> MIME-Version: 1.0 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: HTiBrGur5d00_fZ2R78aNte1E_sUWF1t X-Proofpoint-ORIG-GUID: HTiBrGur5d00_fZ2R78aNte1E_sUWF1t X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 clxscore=1015 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312140080 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 14 Dec 2023 03:43:18 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785257471962971670 X-GMAIL-MSGID: 1785257471962971670 Add support for lock acquire and lock release api. When multiple EE's(Execution Environment) want to access CE5 then there will be race condition b/w multiple EE's. Since each EE's having their dedicated BAM pipe, BAM allows Locking and Unlocking on BAM pipe. So if one EE's requesting for CE5 access then that EE's first has to LOCK the BAM pipe while setting LOCK bit on command descriptor and then access it. After finishing the request EE's has to UNLOCK the BAM pipe so in this way we race condition will not happen. Added these two API qce_bam_acquire_lock() and qce_bam_release_lock() for the same. Signed-off-by: Md Sadre Alam --- drivers/crypto/qce/common.c | 38 +++++++++++++++++++++++++++++++++++++ drivers/crypto/qce/core.h | 2 ++ 2 files changed, 40 insertions(+) diff --git a/drivers/crypto/qce/common.c b/drivers/crypto/qce/common.c index ff96f6ba1fc5..d3b461331b24 100644 --- a/drivers/crypto/qce/common.c +++ b/drivers/crypto/qce/common.c @@ -617,3 +617,41 @@ void qce_get_version(struct qce_device *qce, u32 *major, u32 *minor, u32 *step) *minor = (val & CORE_MINOR_REV_MASK) >> CORE_MINOR_REV_SHIFT; *step = (val & CORE_STEP_REV_MASK) >> CORE_STEP_REV_SHIFT; } + +int qce_bam_acquire_lock(struct qce_device *qce) +{ + u32 val = 0; + int ret; + + qce_clear_bam_transaction(qce); + + /* This is just a dummy read to acquire lock bam pipe */ + qce_read_reg_dma(qce, REG_STATUS2, &val, 1); + + ret = qce_submit_cmd_desc(qce, QCE_DMA_DESC_FLAG_LOCK); + if (ret) { + dev_err(qce->dev, "Error in LOCK cmd descriptor\n"); + return ret; + } + + return 0; +} + +int qce_bam_release_lock(struct qce_device *qce) +{ + u32 val = 0; + int ret; + + qce_clear_bam_transaction(qce); + + /* This just dummy read to release lock on bam pipe*/ + qce_read_reg_dma(qce, REG_STATUS2, &val, 1); + + ret = qce_submit_cmd_desc(qce, QCE_DMA_DESC_FLAG_UNLOCK); + if (ret) { + dev_err(qce->dev, "Error in LOCK cmd descriptor\n"); + return ret; + } + + return 0; +} diff --git a/drivers/crypto/qce/core.h b/drivers/crypto/qce/core.h index bf28dedd1509..d01d810b60ad 100644 --- a/drivers/crypto/qce/core.h +++ b/drivers/crypto/qce/core.h @@ -68,4 +68,6 @@ int qce_read_reg_dma(struct qce_device *qce, unsigned int offset, void *buff, void qce_clear_bam_transaction(struct qce_device *qce); int qce_submit_cmd_desc(struct qce_device *qce, unsigned long flags); struct qce_bam_transaction *qce_alloc_bam_txn(struct qce_dma_data *dma); +int qce_bam_acquire_lock(struct qce_device *qce); +int qce_bam_release_lock(struct qce_device *qce); #endif /* _CORE_H_ */