From nobody Sun Nov 24 03:01:07 2024 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) (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 491F61E2833; Fri, 8 Nov 2024 10:29:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.89.224.132 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731061779; cv=none; b=IcWxMKo9SMtzZcYU+JI5jDx2TYC7UtOewJovicgf5tuUCHkQ0Yg+QRKPRtRmgjGpovdz1KpZ3sSmYycmRpOZxcPysxoSAm63EcYfR2pFmvsktTErWBENiZbIL1w5/JDQzNX6JODsDQeukkW5HBQD00+9kNGkfgJdlgyp/JkcZbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731061779; c=relaxed/simple; bh=1W4DlhR/IhanJgMHK+L2zGsMXOa4UBLkytqTrnoCPRw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bY+EZ1o2ic8mZW04HdD957ToCBCyQ3uAV/lVMRxepYyJJ77jyKTYF+ZzXJCoVtYoO/+kIRxurTS9PzfhZIHgY76QM1Z3QQl21lA3uc7ZxyM2h3QXdh3W0/P8C7+pYjl/927dl8byAquKtSfxm3nP0FJcTNo64kNL8zo/Mp42yrY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=salutedevices.com; spf=pass smtp.mailfrom=salutedevices.com; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b=Ay+oooWy; arc=none smtp.client-ip=45.89.224.132 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=salutedevices.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=salutedevices.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b="Ay+oooWy" Received: from p-infra-ksmg-sc-msk02.sberdevices.ru (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 41199120034; Fri, 8 Nov 2024 13:29:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 41199120034 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1731061773; bh=Wy9OiI+7szsDjno2sdPj55bgsp0gdMIN+aJDlIWoX/c=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=Ay+oooWyCHxMrmqch4p4J/n9anINvu13TG7L3q1q1hiCz9/0hEVbraoU2pCLHfck1 2EAIfa3sGOZstL7G61IBzWIPyCz6Wg1j7vGNOoQ5gu354uAwDbzit9y3kwcXHvo8aY mDLIAirIWm08M92ZTqa8IPZjx5rKlUTu0PoKxlmF5or7o7phVPw39aDXwKhSGgxDue M8XxzmIg0fAFTWiBM4SXVjESlsG9MebE9t9w7S6o7PoKnc6iEtV7cD53MCbOM98bvi e3zCQ1NS4WS42FG1fheZ7t36Cc97PXibwnr1RmIa9tpn56IjBh6+o0/qzzT2qIN5v+ RkxBbvqLBQzQA== Received: from smtp.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Fri, 8 Nov 2024 13:29:33 +0300 (MSK) From: Alexey Romanov To: , , , , , , , , , , , CC: , , , , , , "Alexey Romanov" Subject: [PATCH v10 04/22] crypto: amlogic - Add MMIO helpers Date: Fri, 8 Nov 2024 13:28:49 +0300 Message-ID: <20241108102907.1788584-5-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241108102907.1788584-1-avromanov@salutedevices.com> References: <20241108102907.1788584-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: p-i-exch-a-m2.sberdevices.ru (172.24.196.120) To p-i-exch-a-m1.sberdevices.ru (172.24.196.116) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 189039 [Nov 08 2024] X-KSMG-AntiSpam-Version: 6.1.1.7 X-KSMG-AntiSpam-Envelope-From: avromanov@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 41 0.3.41 623e98d5198769c015c72f45fabbb9f77bdb702b, {Tracking_from_domain_doesnt_match_to}, salutedevices.com:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;smtp.sberdevices.ru:7.1.1,5.0.1;127.0.0.199:7.1.2, FromAlignment: s X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2024/11/08 08:34:00 #26834472 X-KSMG-AntiVirus-Status: Clean, skipped Content-Type: text/plain; charset="utf-8" Add MMIO access helpers: meson_dma_start() and meson_dma_ready(). Signed-off-by: Alexey Romanov Reviewed-by: Neil Armstrong --- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 2 +- drivers/crypto/amlogic/amlogic-gxl-core.c | 24 ++++++++++++++++----- drivers/crypto/amlogic/amlogic-gxl.h | 2 ++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/crypto/amlogic/amlogic-gxl-cipher.c b/drivers/crypto/a= mlogic/amlogic-gxl-cipher.c index 7eff3ae7356f..1fe916b0a138 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-cipher.c +++ b/drivers/crypto/amlogic/amlogic-gxl-cipher.c @@ -225,7 +225,7 @@ static int meson_cipher(struct skcipher_request *areq) =20 reinit_completion(&mc->chanlist[flow].complete); mc->chanlist[flow].status =3D 0; - writel(mc->chanlist[flow].t_phy | 2, mc->base + ((mc->pdata->descs_reg + = flow) << 2)); + meson_dma_start(mc, flow); wait_for_completion_interruptible_timeout(&mc->chanlist[flow].complete, msecs_to_jiffies(500)); if (mc->chanlist[flow].status =3D=3D 0) { diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/aml= ogic/amlogic-gxl-core.c index 90b539401b71..e617dddf5e2b 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -22,18 +22,32 @@ =20 #include "amlogic-gxl.h" =20 +void meson_dma_start(struct meson_dev *mc, int flow) +{ + u32 offset =3D (mc->pdata->descs_reg + flow) << 2; + + writel(mc->chanlist[flow].t_phy | 2, mc->base + offset); +} + +static bool meson_dma_ready(struct meson_dev *mc, int flow) +{ + u32 offset =3D (mc->pdata->status_reg + flow) << 2; + u32 data =3D readl(mc->base + offset); + + if (data) + writel_relaxed(0xF, mc->base + offset); + + return data; +} + static irqreturn_t meson_irq_handler(int irq, void *data) { struct meson_dev *mc =3D (struct meson_dev *)data; int flow; - u32 p; =20 for (flow =3D 0; flow < mc->flow_cnt; flow++) { if (mc->chanlist[flow].irq =3D=3D irq) { - p =3D readl(mc->base + ((mc->pdata->status_reg + flow) << 2)); - if (p) { - writel_relaxed(0xF, mc->base + - ((mc->pdata->status_reg + flow) << 2)); + if (meson_dma_ready(mc, flow)) { mc->chanlist[flow].status =3D 1; complete(&mc->chanlist[flow].complete); return IRQ_HANDLED; diff --git a/drivers/crypto/amlogic/amlogic-gxl.h b/drivers/crypto/amlogic/= amlogic-gxl.h index e0bc5c39bf2c..0ccf6542995f 100644 --- a/drivers/crypto/amlogic/amlogic-gxl.h +++ b/drivers/crypto/amlogic/amlogic-gxl.h @@ -161,6 +161,8 @@ struct meson_alg_template { #endif }; =20 +void meson_dma_start(struct meson_dev *mc, int flow); + int meson_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen); int meson_cipher_init(struct crypto_tfm *tfm); --=20 2.34.1