From patchwork Thu Apr 11 13:38:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788052 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) (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 28291335BC; Thu, 11 Apr 2024 13:38:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.18.73.165 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842737; cv=none; b=p8ApIkCgx34t/cqYXwX0FcHenDa/1BivyDroK5sGqKnNsSq+qTT3/itaXs/v5HgNhHxctiG1XQA8nHLyLdEQ4SKZf/GqjooYhm9hbnxRuiWiBCV3tIp+IXV3GUM7mwDJM5EhsgYgDkhMisYY7/Dk2fIIpM+0gO2TK3KpZQjlFQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842737; c=relaxed/simple; bh=K7UieHG9RsHgDBpcjxeQWQsIDLszF4my3Mke2V00m8I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RpNVYfgXmkY9yQKPvCGVCbFeSyDSGmXPDvuFbUefdtrVla3o0tcU4FnWmC/4OJVa81M0cCSuiMyVWkcQsLafqK996xfXyRDziJpxHA7SVf2Mx8WQmyOG2PNXMi23sJiHDx9HIx1o4azIhGUMCvO5Lj2oDaRf+dfXez05f0ypZFY= 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=ttoqNhMj; arc=none smtp.client-ip=37.18.73.165 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="ttoqNhMj" Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 9470410003D; Thu, 11 Apr 2024 16:38:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 9470410003D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842730; bh=T4w8YmD8VWdxpwAM+qh0428tx6ubcLSqso0bV80y5tA=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=ttoqNhMjDtLuKouzL2qt6Dgi5NdnqUppUBQnogoEcCSRroXNNc8ZSOIGTDoCn53cj 983FvsnsLs6pRRjVHC7gWuqfiXNsSxOcfUU3GoqvKxhltFHT1FFCka9GcfI8gImZxy DtSXHWbO/S96T6RXMgTJA9tkBDRofyeIAr4stWRuzll5qIJgB3eeLAAfKeXKY4IQ6H 6osghsnW4n8ZdN/e4DjqCUsTjCNi9DO+6jtXy8UsQ8FLhtR497tIq2UuB9iHcKpSot 0n8uB1kpSZ94ojSa9Fuy4ljuCczbM5GHCKgl9WCJb4GFLTSz648ipkACo+2E5cNWfl fmzw5hQlPk35A== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:38:50 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:38:48 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 01/23] drivers: crypto: meson: don't hardcode IRQ count Date: Thu, 11 Apr 2024 16:38:10 +0300 Message-ID: <20240411133832.2896463-2-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 100.64.160.123:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 127.0.0.199:7.1.2; salutedevices.com:7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped IRQ count is no longer hardcoded, and make it part of struct meson_flow. We need this for extend driver support for other Amlogic SoC's. Signed-off-by: Alexey Romanov --- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 2 +- drivers/crypto/amlogic/amlogic-gxl-core.c | 47 ++++++++++++--------- drivers/crypto/amlogic/amlogic-gxl.h | 8 ++-- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/drivers/crypto/amlogic/amlogic-gxl-cipher.c b/drivers/crypto/amlogic/amlogic-gxl-cipher.c index 29048da6f50a..b19032f92415 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-cipher.c +++ b/drivers/crypto/amlogic/amlogic-gxl-cipher.c @@ -19,7 +19,7 @@ static int get_engine_number(struct meson_dev *mc) { - return atomic_inc_return(&mc->flow) % MAXFLOW; + return atomic_inc_return(&mc->flow) % mc->flow_cnt; } static bool meson_cipher_need_fallback(struct skcipher_request *areq) diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c index f54ab0d0b1e8..35ec64df5b3a 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -28,8 +28,8 @@ static irqreturn_t meson_irq_handler(int irq, void *data) int flow; u32 p; - for (flow = 0; flow < MAXFLOW; flow++) { - if (mc->irqs[flow] == irq) { + for (flow = 0; flow < mc->flow_cnt; flow++) { + if (mc->chanlist[flow].irq == irq) { p = readl(mc->base + ((0x04 + flow) << 2)); if (p) { writel_relaxed(0xF, mc->base + ((0x4 + flow) << 2)); @@ -110,7 +110,7 @@ static int meson_debugfs_show(struct seq_file *seq, void *v) struct meson_dev *mc __maybe_unused = seq->private; int i; - for (i = 0; i < MAXFLOW; i++) + for (i = 0; i < mc->flow_cnt; i++) seq_printf(seq, "Channel %d: nreq %lu\n", i, #ifdef CONFIG_CRYPTO_DEV_AMLOGIC_GXL_DEBUG mc->chanlist[i].stat_req); @@ -153,14 +153,32 @@ static void meson_free_chanlist(struct meson_dev *mc, int i) */ static int meson_allocate_chanlist(struct meson_dev *mc) { + struct platform_device *pdev = to_platform_device(mc->dev); int i, err; - mc->chanlist = devm_kcalloc(mc->dev, MAXFLOW, + mc->flow_cnt = platform_irq_count(pdev); + if (mc->flow_cnt <= 0) { + dev_err(mc->dev, "No IRQs defined\n"); + return -ENODEV; + } + + mc->chanlist = devm_kcalloc(mc->dev, mc->flow_cnt, sizeof(struct meson_flow), GFP_KERNEL); if (!mc->chanlist) return -ENOMEM; - for (i = 0; i < MAXFLOW; i++) { + for (i = 0; i < mc->flow_cnt; i++) { + mc->chanlist[i].irq = platform_get_irq(pdev, i); + if (mc->chanlist[i].irq < 0) + return mc->chanlist[i].irq; + + err = devm_request_irq(mc->dev, mc->chanlist[i].irq, + meson_irq_handler, 0, "aml-crypto", mc); + if (err < 0) { + dev_err(mc->dev, "Cannot request IRQ for flow %d\n", i); + return err; + } + init_completion(&mc->chanlist[i].complete); mc->chanlist[i].engine = crypto_engine_alloc_init(mc->dev, true); @@ -230,7 +248,7 @@ static void meson_unregister_algs(struct meson_dev *mc) static int meson_crypto_probe(struct platform_device *pdev) { struct meson_dev *mc; - int err, i; + int err; mc = devm_kzalloc(&pdev->dev, sizeof(*mc), GFP_KERNEL); if (!mc) @@ -252,19 +270,6 @@ static int meson_crypto_probe(struct platform_device *pdev) return err; } - for (i = 0; i < MAXFLOW; i++) { - mc->irqs[i] = platform_get_irq(pdev, i); - if (mc->irqs[i] < 0) - return mc->irqs[i]; - - err = devm_request_irq(&pdev->dev, mc->irqs[i], meson_irq_handler, 0, - "gxl-crypto", mc); - if (err < 0) { - dev_err(mc->dev, "Cannot request IRQ for flow %d\n", i); - return err; - } - } - err = clk_prepare_enable(mc->busclk); if (err != 0) { dev_err(&pdev->dev, "Cannot prepare_enable busclk\n"); @@ -294,7 +299,7 @@ static int meson_crypto_probe(struct platform_device *pdev) error_alg: meson_unregister_algs(mc); error_flow: - meson_free_chanlist(mc, MAXFLOW - 1); + meson_free_chanlist(mc, mc->flow_cnt - 1); clk_disable_unprepare(mc->busclk); return err; } @@ -309,7 +314,7 @@ static void meson_crypto_remove(struct platform_device *pdev) meson_unregister_algs(mc); - meson_free_chanlist(mc, MAXFLOW - 1); + meson_free_chanlist(mc, mc->flow_cnt - 1); clk_disable_unprepare(mc->busclk); } diff --git a/drivers/crypto/amlogic/amlogic-gxl.h b/drivers/crypto/amlogic/amlogic-gxl.h index 1013a666c932..79177cfa8b88 100644 --- a/drivers/crypto/amlogic/amlogic-gxl.h +++ b/drivers/crypto/amlogic/amlogic-gxl.h @@ -22,8 +22,6 @@ #define MESON_OPMODE_ECB 0 #define MESON_OPMODE_CBC 1 -#define MAXFLOW 2 - #define MAXDESC 64 #define DESC_LAST BIT(18) @@ -62,6 +60,7 @@ struct meson_desc { * @keylen: keylen for this flow operation * @complete: completion for the current task on this flow * @status: set to 1 by interrupt if task is done + * @irq: IRQ number for amlogic-crypto * @t_phy: Physical address of task * @tl: pointer to the current ce_task for this flow * @stat_req: number of request done by this flow @@ -70,6 +69,7 @@ struct meson_flow { struct crypto_engine *engine; struct completion complete; int status; + int irq; unsigned int keylen; dma_addr_t t_phy; struct meson_desc *tl; @@ -85,7 +85,7 @@ struct meson_flow { * @dev: the platform device * @chanlist: array of all flow * @flow: flow to use in next request - * @irqs: IRQ numbers for amlogic-crypto + * @flow_cnt: flow count for amlogic-crypto * @dbgfs_dir: Debugfs dentry for statistic directory * @dbgfs_stats: Debugfs dentry for statistic counters */ @@ -95,7 +95,7 @@ struct meson_dev { struct device *dev; struct meson_flow *chanlist; atomic_t flow; - int irqs[MAXFLOW]; + int flow_cnt; #ifdef CONFIG_CRYPTO_DEV_AMLOGIC_GXL_DEBUG struct dentry *dbgfs_dir; #endif From patchwork Thu Apr 11 13:38:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788632 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 2D53C1EF01; Thu, 11 Apr 2024 13:38:54 +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=1712842738; cv=none; b=QvkRW79JC0TdxJpNLK1tYeQqe0WDF9nFwrxdwHbOeES1KJMFst0/D3hVMUt6OeqB5/ekV/lv1KKbt3qmcUTSdVz7XOO17AlB8UL3qtz7vzEE3rIev/KEviZ/Ca4WheGQv68+m23MNhwQrNrYh3Vc01CyI/xThNIT9IgdhD8hO18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842738; c=relaxed/simple; bh=OBHA3EskLCh9U+qWy0Rgh3w86yBFud/cEGQWQvUQdfA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oINJa16M5HtRW32vc6FnKXJuWgCxOD3gCYuhgwXcuxWDwQ2U58qQ8lGunGSSIHErR+69lUzs/T+s1r0XAPv04IjHIN4hGRQCdz8j6bbNYKJYWdHXMSU+6bhOAryEv2nTs29YKhJTpIaEb0C9rjYoSccxWRhd2gDRWxqU+ERhdDQ= 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=Glh4mXzu; 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="Glh4mXzu" Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 9466912006C; Thu, 11 Apr 2024 16:38:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 9466912006C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842732; bh=eriiuV0GykLlbuAXJSOmUH2Oy4ZLAtT7rwXfRbbGWeQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=Glh4mXzuOcinAYo9U0v4LM1kjUq2IpM7vnI+bip5+e9xH22pFPQunaT+qzcP9Ills BI2tlqgmGTnVJdoOj92ItlSfo0g/uRPGG8O23fLYH8KNC0j9vNMuTd3fX2YirXTpjN I7P5ARWlEYJrpbBQEddfXgIijMH85LlT5+PIjsD5I2BC1UKOEntqAev13LI0/tV61h +Sk/B55POpU5B0/5Bq1hqRaqvd9FnRZyG8yjMr/Svyh9yoAE9MF4UsYDwaK40H263L k7V45u/AvAyrhyfAmGUF5iyEC4hFyucyxAl2e+5gPg3FaOMGFBvNFl3ZzR7klKTn6h vcA8s2GvqFU4A== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:38:52 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:38:50 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 02/23] drviers: crypto: meson: add platform data Date: Thu, 11 Apr 2024 16:38:11 +0300 Message-ID: <20240411133832.2896463-3-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 127.0.0.199:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; salutedevices.com:7.1.1; 100.64.160.123:7.1.2, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped To support other Amlogic SoC's we have to use platform data: descriptors and status registers offsets are individual for each SoC series. Signed-off-by: Alexey Romanov --- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 2 +- drivers/crypto/amlogic/amlogic-gxl-core.c | 22 +++++++++++++++++---- drivers/crypto/amlogic/amlogic-gxl.h | 11 +++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/amlogic/amlogic-gxl-cipher.c b/drivers/crypto/amlogic/amlogic-gxl-cipher.c index b19032f92415..7eff3ae7356f 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) reinit_completion(&mc->chanlist[flow].complete); mc->chanlist[flow].status = 0; - writel(mc->chanlist[flow].t_phy | 2, mc->base + (flow << 2)); + writel(mc->chanlist[flow].t_phy | 2, mc->base + ((mc->pdata->descs_reg + flow) << 2)); wait_for_completion_interruptible_timeout(&mc->chanlist[flow].complete, msecs_to_jiffies(500)); if (mc->chanlist[flow].status == 0) { diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c index 35ec64df5b3a..e9e733ed98e0 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "amlogic-gxl.h" @@ -30,9 +31,10 @@ static irqreturn_t meson_irq_handler(int irq, void *data) for (flow = 0; flow < mc->flow_cnt; flow++) { if (mc->chanlist[flow].irq == irq) { - p = readl(mc->base + ((0x04 + flow) << 2)); + p = readl(mc->base + ((mc->pdata->status_reg + flow) << 2)); if (p) { - writel_relaxed(0xF, mc->base + ((0x4 + flow) << 2)); + writel_relaxed(0xF, mc->base + + ((mc->pdata->status_reg + flow) << 2)); mc->chanlist[flow].status = 1; complete(&mc->chanlist[flow].complete); return IRQ_HANDLED; @@ -254,6 +256,10 @@ static int meson_crypto_probe(struct platform_device *pdev) if (!mc) return -ENOMEM; + mc->pdata = of_device_get_match_data(&pdev->dev); + if (!mc->pdata) + return -EINVAL; + mc->dev = &pdev->dev; platform_set_drvdata(pdev, mc); @@ -319,9 +325,17 @@ static void meson_crypto_remove(struct platform_device *pdev) clk_disable_unprepare(mc->busclk); } +static const struct meson_pdata meson_gxl_pdata = { + .descs_reg = 0x0, + .status_reg = 0x4, +}; + static const struct of_device_id meson_crypto_of_match_table[] = { - { .compatible = "amlogic,gxl-crypto", }, - {} + { + .compatible = "amlogic,gxl-crypto", + .data = &meson_gxl_pdata, + }, + {}, }; MODULE_DEVICE_TABLE(of, meson_crypto_of_match_table); diff --git a/drivers/crypto/amlogic/amlogic-gxl.h b/drivers/crypto/amlogic/amlogic-gxl.h index 79177cfa8b88..9ad75da214ff 100644 --- a/drivers/crypto/amlogic/amlogic-gxl.h +++ b/drivers/crypto/amlogic/amlogic-gxl.h @@ -78,6 +78,16 @@ struct meson_flow { #endif }; +/* + * struct meson_pdata - SoC series dependent data. + * @reg_descs: offset to descriptors register + * @reg_status: offset to status register + */ +struct meson_pdata { + u32 descs_reg; + u32 status_reg; +}; + /* * struct meson_dev - main container for all this driver information * @base: base address of amlogic-crypto @@ -93,6 +103,7 @@ struct meson_dev { void __iomem *base; struct clk *busclk; struct device *dev; + const struct meson_pdata *pdata; struct meson_flow *chanlist; atomic_t flow; int flow_cnt; From patchwork Thu Apr 11 13:38:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788051 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) (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 7599B14D428; Thu, 11 Apr 2024 13:38:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.18.73.165 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842738; cv=none; b=az7OuzNsJuhVTp8pOB/pZWW4bKioScLF0l/U0VPAfbe2M9bSuJ9XJ9K+mEwEwI1A5M8sHtPyv6fc3JrytZ+7BpUDPePifENXj2dX0gtKEUSsLJcvbmDA089lN6rr2EJ2OCXga9lP1Ju30k0pwRnaj7VdidD3ULq4h+bnKDchINk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842738; c=relaxed/simple; bh=5nLH5t7ySGq5EY/n7ikVY0jUSS636Sdsw76fKnUEKQk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FRYoDTy0asiWOJfJRGaw8SvuigaZ4188fOliLHAvycRqHEudRdgZdD4A/9z9QKsNXuCJzf6txwyBIklQHl+CbA6odYWbzHZ2yIBY2Ue3thONHQ7zFWgt12MvuAtDe29Yp6gY1VCetBs/VlCsIJ0pJElPmO6JYZYJbu7fMQ7M/4E= 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=C8Hb8KiH; arc=none smtp.client-ip=37.18.73.165 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="C8Hb8KiH" Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 3699610003E; Thu, 11 Apr 2024 16:38:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 3699610003E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842734; bh=HfV9iF0dvGOWT3RLcCjTwSmOj3751yeXQaYbGDhTmqU=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=C8Hb8KiHbr7f4KC1K+Dh23jlUQSGAYXHDn+XQGGZoSTliTIHZzjsxHpw+Z1MAshH0 dgQ3R3v5thsBZgYKwPrmrmF+3j1amXvuHvldCyzl+to+wEwukP6W68RZn6EpVpawOf UxXgQyjb08v509jEQIYCuOn99uwSsj8JQM7y3Or3naiREXgcaAYAvngYvBf9Bu+3Ar hLI3EXcZFXc1yY45iOZOwrpxcUL7UR0nqAudegN3IcA9eKpo6hO54K5X+908PP91Ag 1NBumiRWBGydL4AyGJSW7qEFaHl7Y0YlOwyHeBb7Xqn04VqYg/teJMvL9JjRtRbY3h 3hW1MKGsgWJpw== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:38:54 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:38:52 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 03/23] drivers: crypto: meson: remove clock input Date: Thu, 11 Apr 2024 16:38:12 +0300 Message-ID: <20240411133832.2896463-4-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 100.64.160.123:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 127.0.0.199:7.1.2; salutedevices.com:7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped Amlogic crypto IP, which uses DMA crypto engine, doesn't take a clock input. Fixes: 48fe583fe541 ("crypto: amlogic - Add crypto accelerator for amlogic GXL") Signed-off-by: Alexey Romanov --- drivers/crypto/amlogic/amlogic-gxl-core.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c index e9e733ed98e0..9d92115043c3 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -269,18 +268,6 @@ static int meson_crypto_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Cannot request MMIO err=%d\n", err); return err; } - mc->busclk = devm_clk_get(&pdev->dev, "blkmv"); - if (IS_ERR(mc->busclk)) { - err = PTR_ERR(mc->busclk); - dev_err(&pdev->dev, "Cannot get core clock err=%d\n", err); - return err; - } - - err = clk_prepare_enable(mc->busclk); - if (err != 0) { - dev_err(&pdev->dev, "Cannot prepare_enable busclk\n"); - return err; - } err = meson_allocate_chanlist(mc); if (err) @@ -306,7 +293,6 @@ static int meson_crypto_probe(struct platform_device *pdev) meson_unregister_algs(mc); error_flow: meson_free_chanlist(mc, mc->flow_cnt - 1); - clk_disable_unprepare(mc->busclk); return err; } @@ -321,8 +307,6 @@ static void meson_crypto_remove(struct platform_device *pdev) meson_unregister_algs(mc); meson_free_chanlist(mc, mc->flow_cnt - 1); - - clk_disable_unprepare(mc->busclk); } static const struct meson_pdata meson_gxl_pdata = { From patchwork Thu Apr 11 13:38:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788631 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 1D0DB14D6E9; Thu, 11 Apr 2024 13:38:57 +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=1712842740; cv=none; b=qo0OlE/fuWffqckYmvsRFkBLMmUkDCRtqbtyK6glKm4RnF4Z6OfyRxwgDRZbtHZTBgvqFevaKApgdrYCSR0A+hysbe9tqfOSKprdMnzf/koDAix/DtWqxHkdDJm/1nvftQQthlMFhe7d/F58eTJtJYRfMQzFNCSYSKzP+csix5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842740; c=relaxed/simple; bh=g7v5y5TqQIYlFtzFUceKyepZT8VSU3QRJHcH6erE3nk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Lvze8BfUPlEPV8HNivFxCAjJ1D5pXSWPHwvV/dBDDkiNExTi35PtDTt8e2Ajl404GCE4PNzLWElbdB2WzSFPal82RWLNiv/nqisBD12XWdJc6TVsnmL7wgKAwGAAgpCyHNiLZS/8emxW9szKsgNmx5ED5JC/Quv8xqjhCd/a33w= 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=iiZR7l8H; 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="iiZR7l8H" Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 541E3120077; Thu, 11 Apr 2024 16:38:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 541E3120077 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842736; bh=NhKK43BFs9WSPEu12TubmDHMMoMRfMTyJ3HOlIxykU8=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=iiZR7l8HxCnAGbYj1+LYrc5sTm/hxHqQVMv092gfRJzzgeZNQrTy2FU7YBBps3vgA qsXbpzzqKcq5ZsAUxklI4LHdj8WcWOZ8ok2hurI5k2oDGEyyc3yA6WZ8gaT3+rdD8Y 0NIn/n5iRU6uwMw8xbShO0YpK76bFY35WUBnlzWDmhMVW5gHjhUXX+iSqB6an1ioTZ 98tU6KsBIDotdyWoOuLleqTGmGKdf63Pwsj1aJB1qpA6TyRXLwbZpZFozLTRv6YGea YZbPPYxoijLVhomNylsY11q4WWKAkLz17lg+f/TmE3TWyNfXWXTLjotuns8M13fvkG zB6LWTMAaZ6sA== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:38:56 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:38:54 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 04/23] drivers: crypto: meson: add MMIO helpers Date: Thu, 11 Apr 2024 16:38:13 +0300 Message-ID: <20240411133832.2896463-5-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 127.0.0.199:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; salutedevices.com:7.1.1; 100.64.160.123:7.1.2, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped 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/amlogic/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) reinit_completion(&mc->chanlist[flow].complete); mc->chanlist[flow].status = 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 == 0) { diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c index 9d92115043c3..0698ac5e2a6a 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -22,18 +22,32 @@ #include "amlogic-gxl.h" +void meson_dma_start(struct meson_dev *mc, int flow) +{ + u32 offset = (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 = (mc->pdata->status_reg + flow) << 2; + u32 data = 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 = (struct meson_dev *)data; int flow; - u32 p; for (flow = 0; flow < mc->flow_cnt; flow++) { if (mc->chanlist[flow].irq == irq) { - p = 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 = 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 9ad75da214ff..8670f7ebcdda 100644 --- a/drivers/crypto/amlogic/amlogic-gxl.h +++ b/drivers/crypto/amlogic/amlogic-gxl.h @@ -161,6 +161,8 @@ struct meson_alg_template { #endif }; +void meson_dma_start(struct meson_dev *mc, int flow); + int meson_enqueue(struct crypto_async_request *areq, u32 type); int meson_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, From patchwork Thu Apr 11 13:38:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788050 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) (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 ADA0014EC67; Thu, 11 Apr 2024 13:38:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.18.73.165 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842741; cv=none; b=IFVlHgkaWyelz4e7j9iGWYhayOuzwdGkIOWTLuXilXDwcKaWlxDoJgE+AfQTsxnbIaW68Ke8+UW6FQqtQ56HABA62XvkAw+osfOWZ4Y8r3RRNKVLF/YozAAL9B6zNQo8ee8vnNlNijasc+RKE3a9JgQLbzlTRQHZTP3otbZen1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842741; c=relaxed/simple; bh=eKiX+/Kz2JJwdjMCuGv51OdF9N3/l/bTum2+ZwPcTTQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uv/fNykpPJHIW82Zadia/CWLcAhSNGfUun5uCDr56qTpeEXtslRnBRrqITeICwJjA8D0ZxDMOgdSHbHsrCNu0oBgoR4S+DFq2QBihc1LhRYFKhVZq8VDUILLUAE6bxDzWSvoKC4CY0utXb1K3zsxvbdqQuu4qMrYVUZilgoaqkw= 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=BNk87Vc6; arc=none smtp.client-ip=37.18.73.165 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="BNk87Vc6" Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 0264A100040; Thu, 11 Apr 2024 16:38:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 0264A100040 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842738; bh=kbk01LZx5Gx3XlSl8eks76phYzgWifOc69jIi3h8WLs=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=BNk87Vc6Z4FNEg7gMOBiN2EZVZtZvMsqZCd9n1sx3vm4vG1Xm1WvoXA2doHYvyhTS C1HeOeeV/m8Lcs838MaH5h8WKv5uazFAmNyHRwCijn/MstUVF8Zk8DS2nEO8HyaqkR K+ocklUq6kquIS7fL7AkKUZXk3kZTh4m6gQ5Ka92E0xZoSCxuLB+ckRQuUMaChN+Ae hqd4023y7eo/S1aYVM7O9BUe5i71UyPkPQOE4aB1t8NivRx1fqw5SzeupJdD7A6ARr HVrysCOAyeF2LkkJbeDSQ+JggqrrQwwULLxiCJNsDjaHpV1X1d8aLt+3LMZcfy0Bfk LYFcV2bJKClHw== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:38:57 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:38:56 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 05/23] drivers: crypto: meson: move get_engine_number() Date: Thu, 11 Apr 2024 16:38:14 +0300 Message-ID: <20240411133832.2896463-6-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 100.64.160.123:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 127.0.0.199:7.1.2; salutedevices.com:7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped Move get_engine_number() function from cipher.c to core.c Signed-off-by: Alexey Romanov Reviewed-by: Neil Armstrong --- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 9 ++------- drivers/crypto/amlogic/amlogic-gxl-core.c | 5 +++++ drivers/crypto/amlogic/amlogic-gxl.h | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/amlogic/amlogic-gxl-cipher.c b/drivers/crypto/amlogic/amlogic-gxl-cipher.c index 1fe916b0a138..18e9e2d39b1f 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-cipher.c +++ b/drivers/crypto/amlogic/amlogic-gxl-cipher.c @@ -17,11 +17,6 @@ #include #include "amlogic-gxl.h" -static int get_engine_number(struct meson_dev *mc) -{ - return atomic_inc_return(&mc->flow) % mc->flow_cnt; -} - static bool meson_cipher_need_fallback(struct skcipher_request *areq) { struct scatterlist *src_sg = areq->src; @@ -282,7 +277,7 @@ int meson_skdecrypt(struct skcipher_request *areq) rctx->op_dir = MESON_DECRYPT; if (meson_cipher_need_fallback(areq)) return meson_cipher_do_fallback(areq); - e = get_engine_number(op->mc); + e = meson_get_engine_number(op->mc); engine = op->mc->chanlist[e].engine; rctx->flow = e; @@ -300,7 +295,7 @@ int meson_skencrypt(struct skcipher_request *areq) rctx->op_dir = MESON_ENCRYPT; if (meson_cipher_need_fallback(areq)) return meson_cipher_do_fallback(areq); - e = get_engine_number(op->mc); + e = meson_get_engine_number(op->mc); engine = op->mc->chanlist[e].engine; rctx->flow = e; diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c index 0698ac5e2a6a..52317f111c6c 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -22,6 +22,11 @@ #include "amlogic-gxl.h" +int meson_get_engine_number(struct meson_dev *mc) +{ + return atomic_inc_return(&mc->flow) % mc->flow_cnt; +} + void meson_dma_start(struct meson_dev *mc, int flow) { u32 offset = (mc->pdata->descs_reg + flow) << 2; diff --git a/drivers/crypto/amlogic/amlogic-gxl.h b/drivers/crypto/amlogic/amlogic-gxl.h index 8670f7ebcdda..dc54bd533a2d 100644 --- a/drivers/crypto/amlogic/amlogic-gxl.h +++ b/drivers/crypto/amlogic/amlogic-gxl.h @@ -161,6 +161,8 @@ struct meson_alg_template { #endif }; +int meson_get_engine_number(struct meson_dev *mc); + void meson_dma_start(struct meson_dev *mc, int flow); int meson_enqueue(struct crypto_async_request *areq, u32 type); From patchwork Thu Apr 11 13:38:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788630 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 4B1FF1EF01; Thu, 11 Apr 2024 13:39:01 +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=1712842744; cv=none; b=H0oAM2RIWFtqSxl5/1O5VimTHv8Eu948WbnmBNBmWlsXM+24rnDaTrA3AccH3NA7QUl4ZuDQgwsckUzAkjcGpzKFDJjamfTt+elkcZaIDSQymOAXGBXW0huwO7a28dHQQ+r/MmS1UX3c//Cxh3D3UzMxMeDf1IM+hf99VXYVV3Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842744; c=relaxed/simple; bh=QOYczxIU6FV0cOJGzOIxWZJrUesyGdwkLjpDpR1WMiY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u2EGrgndngyS4c3BfturbNXKQhDX4Jp/pFuvzhwpicPmaH72W2Cs5lNz+G3RYbeo6fwlqzQ7bv/6PrQAldw59e/OmMHP+XXVF6nJfzN2jETENIqFINlzDHaDF120kgvl5VakC6/CEROkI46IRapov41fT5MdXzmWGX5sfXZIvlg= 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=HZrZj/rt; 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="HZrZj/rt" Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id E5134120065; Thu, 11 Apr 2024 16:38:59 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru E5134120065 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842739; bh=6wrU1/sGluytgSBoZtiBi/2AtIb9XSpi3qvvAJFAO6Q=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=HZrZj/rtgKolWJH6ifKLZmAzsEpk30nsIIY+nRpYzS/1LAtlCTwEUxqNl0We3ocGB iRc4L1Jw+lKN4ABNvONfF7SOClkeQ4MahryTckK+tlx/1Hq/Zl0rBSoK5elRZcyaKo 43hYdMJE0WdENwXRg1g9lytZsw0x+NddtelDfrswSvJhUn/8MZbyYEAUHN5mPtc56B nGW4YnCnISUQgBPy4GSb5rUluQ87ZpC4Qln7+DirkCkQ4UxayJcIquBaNHehymeZwo 5Y3DAUKzNHg+Gl6mqcDR/9iLENetmBGpfJ+/pcigejs/bNugUiLwuWDp42rNgLV5Kz JYgqhL3ax1ulg== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:38:59 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:38:58 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 06/23] drivers: crypto: meson: drop status field from meson_flow Date: Thu, 11 Apr 2024 16:38:15 +0300 Message-ID: <20240411133832.2896463-7-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 127.0.0.199:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; salutedevices.com:7.1.1; 100.64.160.123:7.1.2, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped This field is used only to check for timeout. But there is more convenient way to achive the same goal. Signed-off-by: Alexey Romanov Reviewed-by: Neil Armstrong --- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 13 +++++++++---- drivers/crypto/amlogic/amlogic-gxl-core.c | 1 - drivers/crypto/amlogic/amlogic-gxl.h | 2 -- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/amlogic/amlogic-gxl-cipher.c b/drivers/crypto/amlogic/amlogic-gxl-cipher.c index 18e9e2d39b1f..dc0b100c5de2 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-cipher.c +++ b/drivers/crypto/amlogic/amlogic-gxl-cipher.c @@ -219,13 +219,18 @@ static int meson_cipher(struct skcipher_request *areq) } reinit_completion(&mc->chanlist[flow].complete); - mc->chanlist[flow].status = 0; meson_dma_start(mc, flow); - wait_for_completion_interruptible_timeout(&mc->chanlist[flow].complete, - msecs_to_jiffies(500)); - if (mc->chanlist[flow].status == 0) { + + err = wait_for_completion_interruptible_timeout(&mc->chanlist[flow].complete, + msecs_to_jiffies(500)); + if (err == 0) { dev_err(mc->dev, "DMA timeout for flow %d\n", flow); err = -EINVAL; + } else if (err < 0) { + dev_err(mc->dev, "Waiting for DMA completion is failed (%d)\n", err); + } else { + /* No error */ + err = 0; } dma_unmap_single(mc->dev, phykeyiv, keyivlen, DMA_TO_DEVICE); diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c index 52317f111c6c..4d04bb0ddc4e 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -53,7 +53,6 @@ static irqreturn_t meson_irq_handler(int irq, void *data) for (flow = 0; flow < mc->flow_cnt; flow++) { if (mc->chanlist[flow].irq == irq) { if (meson_dma_ready(mc, flow)) { - mc->chanlist[flow].status = 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 dc54bd533a2d..4d60a0cc2dca 100644 --- a/drivers/crypto/amlogic/amlogic-gxl.h +++ b/drivers/crypto/amlogic/amlogic-gxl.h @@ -59,7 +59,6 @@ struct meson_desc { * @engine: ptr to the crypto_engine for this flow * @keylen: keylen for this flow operation * @complete: completion for the current task on this flow - * @status: set to 1 by interrupt if task is done * @irq: IRQ number for amlogic-crypto * @t_phy: Physical address of task * @tl: pointer to the current ce_task for this flow @@ -68,7 +67,6 @@ struct meson_desc { struct meson_flow { struct crypto_engine *engine; struct completion complete; - int status; int irq; unsigned int keylen; dma_addr_t t_phy; From patchwork Thu Apr 11 13:38:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788049 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) (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 47E7214D430; Thu, 11 Apr 2024 13:39:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.18.73.165 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842745; cv=none; b=MpQU9J22khPH4w9OZDOdN7on+mj4FJOvgUK/LtM9Apz/jLhJRH0icjizmvqkh7HYgbJjbUJqWZfIpt2ALYq9llaeBikZPSzGmvmRUOtGgX1MV/92ZMiGvlx4RsgYPG074etju310aJ+xuJst6yYKPIxsDYmaaBllVtF1s59uZjA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842745; c=relaxed/simple; bh=dpOYeQeyAYNG9UFoeKb/7A2ZsVex3CU1Tol1fRvW/h0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Jll0VAHp9mVtfWDOWDFc1iZ/Wx4C17ahiyCG+xRsleGliNiZllDdSfnnllyNEPoFr1xG6xmZ65xGYV5/wUvsm9oDbv3y+djAH7PcI+SYbwJkjkcZnv/yJNPBtvdivQ+xwibneLsTKVx97hlATnWV40vNKEFLshItkw9wwhkXzXg= 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=OyHHlh5B; arc=none smtp.client-ip=37.18.73.165 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="OyHHlh5B" Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id C64A510003D; Thu, 11 Apr 2024 16:39:01 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru C64A510003D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842741; bh=xd50a9O8l/OoDbRWK5Wjbyxk+fhaws83XQi0oGXEMk0=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=OyHHlh5Bn7GBPXgfPCVZhOc8EfMXyaCo31ZL1VSTlALa1oooP4/eg3BFC5bM1Cgqw V79RDR7r+lProheCvP2umWROCPzjG/V0Fkemixapj8fTVVrD0mtDTGAj9a+Yi8n2V8 u2xbU3Rl46GmGgVzNUuvC8CpMNrj7WtZ6dpjua7fSQePEx1aBlcsa4b7wazq9XDabf v9rhg23OfUYtsQ2TSjFoFnkVBaLB9QECA2OKzaoCwnsGb7iAJJJhzMhYhitT7so1im JsH+zIIrNJPRv1EWvoN6UQoVhIBxs2uNl3eLerakOwnVX917xnlhNDhFZ4Dy8cAnD4 OoxStCvKd9tnA== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:39:01 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:39:00 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 07/23] drivers: crypto: meson: move algs definition and cipher API to cipher.c Date: Thu, 11 Apr 2024 16:38:16 +0300 Message-ID: <20240411133832.2896463-8-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 100.64.160.123:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 127.0.0.199:7.1.2; salutedevices.com:7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped Because that is proper place for them. In particular, it takes less of exported symbol between compiling entities. Signed-off-by: Alexey Romanov Reviewed-by: Neil Armstrong --- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 98 +++++++++++++++-- drivers/crypto/amlogic/amlogic-gxl-core.c | 110 ++++---------------- drivers/crypto/amlogic/amlogic-gxl.h | 14 +-- 3 files changed, 119 insertions(+), 103 deletions(-) diff --git a/drivers/crypto/amlogic/amlogic-gxl-cipher.c b/drivers/crypto/amlogic/amlogic-gxl-cipher.c index dc0b100c5de2..bc3092a8a2c2 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-cipher.c +++ b/drivers/crypto/amlogic/amlogic-gxl-cipher.c @@ -271,7 +271,7 @@ int meson_handle_cipher_request(struct crypto_engine *engine, void *areq) return 0; } -int meson_skdecrypt(struct skcipher_request *areq) +static int meson_skdecrypt(struct skcipher_request *areq) { struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); @@ -289,7 +289,7 @@ int meson_skdecrypt(struct skcipher_request *areq) return crypto_transfer_skcipher_request_to_engine(engine, areq); } -int meson_skencrypt(struct skcipher_request *areq) +static int meson_skencrypt(struct skcipher_request *areq) { struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); @@ -307,7 +307,7 @@ int meson_skencrypt(struct skcipher_request *areq) return crypto_transfer_skcipher_request_to_engine(engine, areq); } -int meson_cipher_init(struct crypto_tfm *tfm) +static int meson_cipher_init(struct crypto_tfm *tfm) { struct meson_cipher_tfm_ctx *op = crypto_tfm_ctx(tfm); struct meson_alg_template *algt; @@ -333,7 +333,7 @@ int meson_cipher_init(struct crypto_tfm *tfm) return 0; } -void meson_cipher_exit(struct crypto_tfm *tfm) +static void meson_cipher_exit(struct crypto_tfm *tfm) { struct meson_cipher_tfm_ctx *op = crypto_tfm_ctx(tfm); @@ -341,8 +341,8 @@ void meson_cipher_exit(struct crypto_tfm *tfm) crypto_free_skcipher(op->fallback_tfm); } -int meson_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, - unsigned int keylen) +static int meson_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, + unsigned int keylen) { struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); struct meson_dev *mc = op->mc; @@ -369,3 +369,89 @@ int meson_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, return crypto_skcipher_setkey(op->fallback_tfm, key, keylen); } + +static struct meson_alg_template algs[] = { +{ + .type = CRYPTO_ALG_TYPE_SKCIPHER, + .blockmode = MESON_OPMODE_CBC, + .alg.skcipher.base = { + .base = { + .cra_name = "cbc(aes)", + .cra_driver_name = "cbc-aes-gxl", + .cra_priority = 400, + .cra_blocksize = AES_BLOCK_SIZE, + .cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | + CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY | + CRYPTO_ALG_NEED_FALLBACK, + .cra_ctxsize = sizeof(struct meson_cipher_tfm_ctx), + .cra_module = THIS_MODULE, + .cra_alignmask = 0xf, + .cra_init = meson_cipher_init, + .cra_exit = meson_cipher_exit, + }, + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .ivsize = AES_BLOCK_SIZE, + .setkey = meson_aes_setkey, + .encrypt = meson_skencrypt, + .decrypt = meson_skdecrypt, + }, + .alg.skcipher.op = { + .do_one_request = meson_handle_cipher_request, + }, +}, +{ + .type = CRYPTO_ALG_TYPE_SKCIPHER, + .blockmode = MESON_OPMODE_ECB, + .alg.skcipher.base = { + .base = { + .cra_name = "ecb(aes)", + .cra_driver_name = "ecb-aes-gxl", + .cra_priority = 400, + .cra_blocksize = AES_BLOCK_SIZE, + .cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | + CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY | + CRYPTO_ALG_NEED_FALLBACK, + .cra_ctxsize = sizeof(struct meson_cipher_tfm_ctx), + .cra_module = THIS_MODULE, + .cra_alignmask = 0xf, + .cra_init = meson_cipher_init, + .cra_exit = meson_cipher_exit, + }, + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .setkey = meson_aes_setkey, + .encrypt = meson_skencrypt, + .decrypt = meson_skdecrypt, + }, + .alg.skcipher.op = { + .do_one_request = meson_handle_cipher_request, + }, +}, +}; + +int meson_cipher_register(struct meson_dev *mc) +{ + return meson_register_algs(mc, algs, ARRAY_SIZE(algs)); +} + +void meson_cipher_unregister(struct meson_dev *mc) +{ + meson_unregister_algs(mc, algs, ARRAY_SIZE(algs)); +} + +void meson_cipher_debugfs_show(struct seq_file *seq, void *v) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(algs); i++) { + seq_printf(seq, "%s %s %lu %lu\n", + algs[i].alg.skcipher.base.base.cra_driver_name, + algs[i].alg.skcipher.base.base.cra_name, +#ifdef CONFIG_CRYPTO_DEV_AMLOGIC_GXL_DEBUG + algs[i].stat_req, algs[i].stat_fb); +#else + 0ul, 0ul); +#endif + } +} diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c index 4d04bb0ddc4e..98e63e67aa6e 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -64,66 +64,6 @@ static irqreturn_t meson_irq_handler(int irq, void *data) return IRQ_HANDLED; } -static struct meson_alg_template mc_algs[] = { -{ - .type = CRYPTO_ALG_TYPE_SKCIPHER, - .blockmode = MESON_OPMODE_CBC, - .alg.skcipher.base = { - .base = { - .cra_name = "cbc(aes)", - .cra_driver_name = "cbc-aes-gxl", - .cra_priority = 400, - .cra_blocksize = AES_BLOCK_SIZE, - .cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | - CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY | - CRYPTO_ALG_NEED_FALLBACK, - .cra_ctxsize = sizeof(struct meson_cipher_tfm_ctx), - .cra_module = THIS_MODULE, - .cra_alignmask = 0xf, - .cra_init = meson_cipher_init, - .cra_exit = meson_cipher_exit, - }, - .min_keysize = AES_MIN_KEY_SIZE, - .max_keysize = AES_MAX_KEY_SIZE, - .ivsize = AES_BLOCK_SIZE, - .setkey = meson_aes_setkey, - .encrypt = meson_skencrypt, - .decrypt = meson_skdecrypt, - }, - .alg.skcipher.op = { - .do_one_request = meson_handle_cipher_request, - }, -}, -{ - .type = CRYPTO_ALG_TYPE_SKCIPHER, - .blockmode = MESON_OPMODE_ECB, - .alg.skcipher.base = { - .base = { - .cra_name = "ecb(aes)", - .cra_driver_name = "ecb-aes-gxl", - .cra_priority = 400, - .cra_blocksize = AES_BLOCK_SIZE, - .cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | - CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY | - CRYPTO_ALG_NEED_FALLBACK, - .cra_ctxsize = sizeof(struct meson_cipher_tfm_ctx), - .cra_module = THIS_MODULE, - .cra_alignmask = 0xf, - .cra_init = meson_cipher_init, - .cra_exit = meson_cipher_exit, - }, - .min_keysize = AES_MIN_KEY_SIZE, - .max_keysize = AES_MAX_KEY_SIZE, - .setkey = meson_aes_setkey, - .encrypt = meson_skencrypt, - .decrypt = meson_skdecrypt, - }, - .alg.skcipher.op = { - .do_one_request = meson_handle_cipher_request, - }, -}, -}; - static int meson_debugfs_show(struct seq_file *seq, void *v) { struct meson_dev *mc __maybe_unused = seq->private; @@ -137,20 +77,8 @@ static int meson_debugfs_show(struct seq_file *seq, void *v) 0ul); #endif - for (i = 0; i < ARRAY_SIZE(mc_algs); i++) { - switch (mc_algs[i].type) { - case CRYPTO_ALG_TYPE_SKCIPHER: - seq_printf(seq, "%s %s %lu %lu\n", - mc_algs[i].alg.skcipher.base.base.cra_driver_name, - mc_algs[i].alg.skcipher.base.base.cra_name, -#ifdef CONFIG_CRYPTO_DEV_AMLOGIC_GXL_DEBUG - mc_algs[i].stat_req, mc_algs[i].stat_fb); -#else - 0ul, 0ul); -#endif - break; - } - } + meson_cipher_debugfs_show(seq, v); + return 0; } DEFINE_SHOW_ATTRIBUTE(meson_debugfs); @@ -227,19 +155,20 @@ static int meson_allocate_chanlist(struct meson_dev *mc) return err; } -static int meson_register_algs(struct meson_dev *mc) +int meson_register_algs(struct meson_dev *mc, struct meson_alg_template *algs, + unsigned int count) { int err, i; - for (i = 0; i < ARRAY_SIZE(mc_algs); i++) { - mc_algs[i].mc = mc; - switch (mc_algs[i].type) { + for (i = 0; i < count; i++) { + algs[i].mc = mc; + switch (algs[i].type) { case CRYPTO_ALG_TYPE_SKCIPHER: - err = crypto_engine_register_skcipher(&mc_algs[i].alg.skcipher); + err = crypto_engine_register_skcipher(&algs[i].alg.skcipher); if (err) { dev_err(mc->dev, "Fail to register %s\n", - mc_algs[i].alg.skcipher.base.base.cra_name); - mc_algs[i].mc = NULL; + algs[i].alg.skcipher.base.base.cra_name); + meson_unregister_algs(mc, algs, count); return err; } break; @@ -249,16 +178,17 @@ static int meson_register_algs(struct meson_dev *mc) return 0; } -static void meson_unregister_algs(struct meson_dev *mc) +void meson_unregister_algs(struct meson_dev *mc, struct meson_alg_template *algs, + unsigned int count) { int i; - for (i = 0; i < ARRAY_SIZE(mc_algs); i++) { - if (!mc_algs[i].mc) + for (i = 0; i < count; i++) { + if (!algs[i].mc) continue; - switch (mc_algs[i].type) { + switch (algs[i].type) { case CRYPTO_ALG_TYPE_SKCIPHER: - crypto_engine_unregister_skcipher(&mc_algs[i].alg.skcipher); + crypto_engine_unregister_skcipher(&algs[i].alg.skcipher); break; } } @@ -291,9 +221,9 @@ static int meson_crypto_probe(struct platform_device *pdev) if (err) goto error_flow; - err = meson_register_algs(mc); + err = meson_cipher_register(mc); if (err) - goto error_alg; + goto error_flow; if (IS_ENABLED(CONFIG_CRYPTO_DEV_AMLOGIC_GXL_DEBUG)) { struct dentry *dbgfs_dir; @@ -307,8 +237,6 @@ static int meson_crypto_probe(struct platform_device *pdev) } return 0; -error_alg: - meson_unregister_algs(mc); error_flow: meson_free_chanlist(mc, mc->flow_cnt - 1); return err; @@ -322,7 +250,7 @@ static void meson_crypto_remove(struct platform_device *pdev) debugfs_remove_recursive(mc->dbgfs_dir); #endif - meson_unregister_algs(mc); + meson_cipher_unregister(mc); meson_free_chanlist(mc, mc->flow_cnt - 1); } diff --git a/drivers/crypto/amlogic/amlogic-gxl.h b/drivers/crypto/amlogic/amlogic-gxl.h index 4d60a0cc2dca..9d66903aa73d 100644 --- a/drivers/crypto/amlogic/amlogic-gxl.h +++ b/drivers/crypto/amlogic/amlogic-gxl.h @@ -165,10 +165,12 @@ void meson_dma_start(struct meson_dev *mc, int flow); int meson_enqueue(struct crypto_async_request *areq, u32 type); -int meson_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, - unsigned int keylen); -int meson_cipher_init(struct crypto_tfm *tfm); -void meson_cipher_exit(struct crypto_tfm *tfm); -int meson_skdecrypt(struct skcipher_request *areq); -int meson_skencrypt(struct skcipher_request *areq); +int meson_register_algs(struct meson_dev *mc, struct meson_alg_template *algs, + unsigned int count); +void meson_unregister_algs(struct meson_dev *mc, struct meson_alg_template *algs, + unsigned int count); + +int meson_cipher_register(struct meson_dev *mc); +void meson_cipher_unregister(struct meson_dev *mc); +void meson_cipher_debugfs_show(struct seq_file *seq, void *v); int meson_handle_cipher_request(struct crypto_engine *engine, void *areq); From patchwork Thu Apr 11 13:38:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788629 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 A600B14D43A; Thu, 11 Apr 2024 13:39:05 +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=1712842747; cv=none; b=NMZbVdlhUxqOQgWerxfEDYysjLn7ouGavmj8kUHs3fM+KGB16MK6+uJJzmTP3mKmCNatgtFpcppnH7HWVEmsqjKbB4usslc/v73A49SW99r+21bvcAN2KhkrOX8dvN1c4skRctvsrOpLrJkGGGoJ+WMCkKckA100nBUt8heE0nY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842747; c=relaxed/simple; bh=ET2JZjaQMoxPobb8Q3LebeiOiy555rrS8rvJOuPLhyg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Fmv+2w8Ks9iTjXml/Roo1bS/Wl1fujoFxHAjZsV7y/OtvxhpJD2iG4Lsj5Udvzgd8WeZASYeO+T1sOW8mCl3gyHsXYAPa/XJ0tEuFa6IL8HV4T6onM7f8t1m7sE/wyfEXPQ0mGNBqlEpGOeAL+1PDpS3sAi/lOqWPE4p60vdAyE= 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=mdMZtmcb; 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="mdMZtmcb" Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 69560120071; Thu, 11 Apr 2024 16:39:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 69560120071 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842743; bh=roUwNBdU2vfmeGO0/uPIeWXRlle4l1zNhmfrHjctP+E=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=mdMZtmcbYJJaWoG5X0ggdlwKdJXHS0SG3rnLh4W0A1a2uy9w4x9qJqMWDvVVQ9I6w R6ZKlATzq9Z+AuT3R/cS0cAkV8t6CQLT1mW0MVbllzEIioNGsqyQCW/F1dwy+VbCZT 5vzZCmBRPOaJMztDT+Kv4Yremmro7m2EJzAmqPWvXyvjqc1DBWzCcFurVfrnF/wcA0 72ZAwdACg3yjFPgNzVL9kyaZGoWuu/QKWlNoLdHOp4k7pTNa7H5rHTaYz950Eyv0ZY nSQ9FvM1eWAwcrutcRi0yAKt2PCzYgoANxOWoS09YyVTrc61G1SNkagtrSVEXk5nRT hBU/hs2wJb00Q== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:39:03 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:39:01 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 08/23] drivers: crypto: meson: cleanup defines Date: Thu, 11 Apr 2024 16:38:17 +0300 Message-ID: <20240411133832.2896463-9-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 127.0.0.199:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; salutedevices.com:7.1.1; 100.64.160.123:7.1.2, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped It is bad to use hardcoded values directly in the code. Signed-off-by: Alexey Romanov Reviewed-by: Neil Armstrong --- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 24 ++++++++++----------- drivers/crypto/amlogic/amlogic-gxl.h | 16 ++++++++------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/crypto/amlogic/amlogic-gxl-cipher.c b/drivers/crypto/amlogic/amlogic-gxl-cipher.c index bc3092a8a2c2..c662c4b86e97 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-cipher.c +++ b/drivers/crypto/amlogic/amlogic-gxl-cipher.c @@ -141,8 +141,8 @@ static int meson_cipher(struct skcipher_request *areq) ivsize, 0); } } - if (keyivlen == 24) - keyivlen = 32; + if (keyivlen == AES_KEYSIZE_192) + keyivlen = AES_MAX_KEY_SIZE; phykeyiv = dma_map_single(mc->dev, bkeyiv, keyivlen, DMA_TO_DEVICE); @@ -161,7 +161,7 @@ static int meson_cipher(struct skcipher_request *areq) todo = min(keyivlen - eat, 16u); desc->t_src = cpu_to_le32(phykeyiv + i * 16); desc->t_dst = cpu_to_le32(i * 16); - v = (MODE_KEY << 20) | DESC_OWN | 16; + v = DESC_MODE_KEY | DESC_OWN | 16; desc->t_status = cpu_to_le32(v); eat += todo; @@ -205,7 +205,7 @@ static int meson_cipher(struct skcipher_request *areq) desc->t_src = cpu_to_le32(sg_dma_address(src_sg)); desc->t_dst = cpu_to_le32(sg_dma_address(dst_sg)); todo = min(len, sg_dma_len(src_sg)); - v = (op->keymode << 20) | DESC_OWN | todo | (algt->blockmode << 26); + v = op->keymode | DESC_OWN | todo | algt->blockmode; if (rctx->op_dir) v |= DESC_ENCRYPTION; len -= todo; @@ -348,14 +348,14 @@ static int meson_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, struct meson_dev *mc = op->mc; switch (keylen) { - case 128 / 8: - op->keymode = MODE_AES_128; + case AES_KEYSIZE_128: + op->keymode = DESC_MODE_AES_128; break; - case 192 / 8: - op->keymode = MODE_AES_192; + case AES_KEYSIZE_192: + op->keymode = DESC_MODE_AES_192; break; - case 256 / 8: - op->keymode = MODE_AES_256; + case AES_KEYSIZE_256: + op->keymode = DESC_MODE_AES_256; break; default: dev_dbg(mc->dev, "ERROR: Invalid keylen %u\n", keylen); @@ -373,7 +373,7 @@ static int meson_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, static struct meson_alg_template algs[] = { { .type = CRYPTO_ALG_TYPE_SKCIPHER, - .blockmode = MESON_OPMODE_CBC, + .blockmode = DESC_OPMODE_CBC, .alg.skcipher.base = { .base = { .cra_name = "cbc(aes)", @@ -402,7 +402,7 @@ static struct meson_alg_template algs[] = { }, { .type = CRYPTO_ALG_TYPE_SKCIPHER, - .blockmode = MESON_OPMODE_ECB, + .blockmode = DESC_OPMODE_ECB, .alg.skcipher.base = { .base = { .cra_name = "ecb(aes)", diff --git a/drivers/crypto/amlogic/amlogic-gxl.h b/drivers/crypto/amlogic/amlogic-gxl.h index 9d66903aa73d..1ab3462dea42 100644 --- a/drivers/crypto/amlogic/amlogic-gxl.h +++ b/drivers/crypto/amlogic/amlogic-gxl.h @@ -11,19 +11,21 @@ #include #include -#define MODE_KEY 1 -#define MODE_AES_128 0x8 -#define MODE_AES_192 0x9 -#define MODE_AES_256 0xa - #define MESON_DECRYPT 0 #define MESON_ENCRYPT 1 -#define MESON_OPMODE_ECB 0 -#define MESON_OPMODE_CBC 1 +#define DESC_MODE_KEY (0x1 << 20) +#define DESC_MODE_AES_128 (0x8 << 20) +#define DESC_MODE_AES_192 (0x9 << 20) +#define DESC_MODE_AES_256 (0xa << 20) #define MAXDESC 64 +#define DESC_OPMODE_ECB (0 << 26) +#define DESC_OPMODE_CBC (1 << 26) + +#define DESC_MAXLEN GENMASK(16, 0) + #define DESC_LAST BIT(18) #define DESC_ENCRYPTION BIT(28) #define DESC_OWN BIT(31) From patchwork Thu Apr 11 13:38:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788048 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) (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 66A65152522; Thu, 11 Apr 2024 13:39:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.18.73.165 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842749; cv=none; b=MM8vm2Tvm8Mnh6MvkdSxkUSH++ZetnoE37RofhY8qs0kRbLmN2kRcgPkKluyQxRXaR75nM9XbJ4tYLjT5mxrgFgKqioY/Fc+8L52TbERyBNShVxdIwS9Og3mmGoglIWzMYLDOFix0CnO88OL57Gc5OABIs27Mue27Pif4h9yJu4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842749; c=relaxed/simple; bh=sRVzDtLuAYid7bpL1vEiJDXSCoFwNdDImg0HLGp1GxI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jZr5dpmx6Reef1jhvwsjEUCKfdyfTEl9ixYdcG5+TTqI6Lr0UyzogvQ7szoSVOdsdQQTgKZA9xF193qH9GZJcoFy4qedMiBOb0JPSkkmhXBWhSogXPTN7cMKhJzuA6B+Zm5zQbzW8eRDJJOjIbDk7WuP4cx4f54yMUQQ2VzjdyM= 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=VGjYg8sY; arc=none smtp.client-ip=37.18.73.165 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="VGjYg8sY" Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id AA3A210003E; Thu, 11 Apr 2024 16:39:05 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru AA3A210003E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842745; bh=oSSG1nFN48Pp27lrPpipw+gU7eoF+L7UQCvM42iFT9k=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=VGjYg8sYmM/LjkpQJGvLAj/wildQxch++DddYiGkld5GOUKm7wMqxO4+83Cy3Gpie 9W/x8iruZc824NvQ6Qidbg788Nu1cXGHh4DlF8YytzkY/Tl1oXBdN7BKkX16Vsx1go 0V3b+UmYOSRPZk+gudL8xbHO9nTK1BcUyRQr3u62MUEXgfNwEGI8XU4Y+BrjcyJ198 3QK4XhABU+GQ+M9vJxUEpzUoc5MdGXSezLOnW34oxhz4fNqOk0DzN/QQD+V9igcU8r bhUbjkVo3Y5D1w+YuCQ/91DX9tifZzfWRbHw2CAOCvdIZIA7OePgKau5VFHoJWed3P yLIM777szh0AA== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:39:05 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:39:03 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 09/23] drivers: crypto: meson: process more than MAXDESCS descriptors Date: Thu, 11 Apr 2024 16:38:18 +0300 Message-ID: <20240411133832.2896463-10-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 100.64.160.123:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 127.0.0.199:7.1.2; salutedevices.com:7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped 1. The old alhorithm was not designed to process a large amount of memory, and therefore gave incorrect results. 2. Not all Amlogic SoC's use 3 KEY/IV descriptors. Add keyiv descriptors count parameter to platform data. Signed-off-by: Alexey Romanov --- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 445 ++++++++++++-------- drivers/crypto/amlogic/amlogic-gxl-core.c | 1 + drivers/crypto/amlogic/amlogic-gxl.h | 2 + 3 files changed, 283 insertions(+), 165 deletions(-) diff --git a/drivers/crypto/amlogic/amlogic-gxl-cipher.c b/drivers/crypto/amlogic/amlogic-gxl-cipher.c index c662c4b86e97..dd2478ae7c54 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-cipher.c +++ b/drivers/crypto/amlogic/amlogic-gxl-cipher.c @@ -17,35 +17,41 @@ #include #include "amlogic-gxl.h" -static bool meson_cipher_need_fallback(struct skcipher_request *areq) +static bool meson_cipher_need_fallback_sg(struct skcipher_request *areq, + struct scatterlist *sg) { - struct scatterlist *src_sg = areq->src; - struct scatterlist *dst_sg = areq->dst; + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); + unsigned int blocksize = crypto_skcipher_blocksize(tfm); + unsigned int cryptlen = areq->cryptlen; + + while (cryptlen) { + unsigned int len = min(cryptlen, sg->length); + + if (!IS_ALIGNED(sg->offset, sizeof(u32))) + return true; + if (len % blocksize != 0) + return true; + + cryptlen -= len; + sg = sg_next(sg); + } + + return false; +} +static bool meson_cipher_need_fallback(struct skcipher_request *areq) +{ if (areq->cryptlen == 0) return true; - if (sg_nents(src_sg) != sg_nents(dst_sg)) + if (meson_cipher_need_fallback_sg(areq, areq->src)) return true; - /* KEY/IV descriptors use 3 desc */ - if (sg_nents(src_sg) > MAXDESC - 3 || sg_nents(dst_sg) > MAXDESC - 3) - return true; + if (areq->dst == areq->src) + return false; - while (src_sg && dst_sg) { - if ((src_sg->length % 16) != 0) - return true; - if ((dst_sg->length % 16) != 0) - return true; - if (src_sg->length != dst_sg->length) - return true; - if (!IS_ALIGNED(src_sg->offset, sizeof(u32))) - return true; - if (!IS_ALIGNED(dst_sg->offset, sizeof(u32))) - return true; - src_sg = sg_next(src_sg); - dst_sg = sg_next(dst_sg); - } + if (meson_cipher_need_fallback_sg(areq, areq->dst)) + return true; return false; } @@ -76,184 +82,293 @@ static int meson_cipher_do_fallback(struct skcipher_request *areq) return err; } -static int meson_cipher(struct skcipher_request *areq) +struct cipher_ctx { + struct { + dma_addr_t addr; + unsigned int len; + } keyiv; + + struct skcipher_request *areq; + struct scatterlist *src_sg; + struct scatterlist *dst_sg; + void *bkeyiv; + + unsigned int src_offset; + unsigned int dst_offset; + unsigned int cryptlen; + unsigned int tloffset; +}; + +static int meson_map_scatterlist(struct skcipher_request *areq, struct meson_dev *mc) { - struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); - struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); - struct meson_cipher_req_ctx *rctx = skcipher_request_ctx(areq); - struct meson_dev *mc = op->mc; - struct skcipher_alg *alg = crypto_skcipher_alg(tfm); - struct meson_alg_template *algt; - int flow = rctx->flow; - unsigned int todo, eat, len; - struct scatterlist *src_sg = areq->src; - struct scatterlist *dst_sg = areq->dst; - struct meson_desc *desc; int nr_sgs, nr_sgd; - int i, err = 0; - unsigned int keyivlen, ivsize, offset, tloffset; - dma_addr_t phykeyiv; - void *backup_iv = NULL, *bkeyiv; - u32 v; - - algt = container_of(alg, struct meson_alg_template, alg.skcipher.base); - - dev_dbg(mc->dev, "%s %s %u %x IV(%u) key=%u flow=%d\n", __func__, - crypto_tfm_alg_name(areq->base.tfm), - areq->cryptlen, - rctx->op_dir, crypto_skcipher_ivsize(tfm), - op->keylen, flow); - -#ifdef CONFIG_CRYPTO_DEV_AMLOGIC_GXL_DEBUG - algt->stat_req++; - mc->chanlist[flow].stat_req++; -#endif - - /* - * The hardware expect a list of meson_desc structures. - * The 2 first structures store key - * The third stores IV - */ - bkeyiv = kzalloc(48, GFP_KERNEL | GFP_DMA); - if (!bkeyiv) - return -ENOMEM; - - memcpy(bkeyiv, op->key, op->keylen); - keyivlen = op->keylen; - - ivsize = crypto_skcipher_ivsize(tfm); - if (areq->iv && ivsize > 0) { - if (ivsize > areq->cryptlen) { - dev_err(mc->dev, "invalid ivsize=%d vs len=%d\n", ivsize, areq->cryptlen); - err = -EINVAL; - goto theend; - } - memcpy(bkeyiv + 32, areq->iv, ivsize); - keyivlen = 48; - if (rctx->op_dir == MESON_DECRYPT) { - backup_iv = kzalloc(ivsize, GFP_KERNEL); - if (!backup_iv) { - err = -ENOMEM; - goto theend; - } - offset = areq->cryptlen - ivsize; - scatterwalk_map_and_copy(backup_iv, areq->src, offset, - ivsize, 0); - } - } - if (keyivlen == AES_KEYSIZE_192) - keyivlen = AES_MAX_KEY_SIZE; - - phykeyiv = dma_map_single(mc->dev, bkeyiv, keyivlen, - DMA_TO_DEVICE); - err = dma_mapping_error(mc->dev, phykeyiv); - if (err) { - dev_err(mc->dev, "Cannot DMA MAP KEY IV\n"); - goto theend; - } - - tloffset = 0; - eat = 0; - i = 0; - while (keyivlen > eat) { - desc = &mc->chanlist[flow].tl[tloffset]; - memset(desc, 0, sizeof(struct meson_desc)); - todo = min(keyivlen - eat, 16u); - desc->t_src = cpu_to_le32(phykeyiv + i * 16); - desc->t_dst = cpu_to_le32(i * 16); - v = DESC_MODE_KEY | DESC_OWN | 16; - desc->t_status = cpu_to_le32(v); - - eat += todo; - i++; - tloffset++; - } if (areq->src == areq->dst) { nr_sgs = dma_map_sg(mc->dev, areq->src, sg_nents(areq->src), DMA_BIDIRECTIONAL); if (!nr_sgs) { dev_err(mc->dev, "Invalid SG count %d\n", nr_sgs); - err = -EINVAL; - goto theend; + return -EINVAL; } - nr_sgd = nr_sgs; } else { nr_sgs = dma_map_sg(mc->dev, areq->src, sg_nents(areq->src), DMA_TO_DEVICE); - if (!nr_sgs || nr_sgs > MAXDESC - 3) { + if (!nr_sgs) { dev_err(mc->dev, "Invalid SG count %d\n", nr_sgs); - err = -EINVAL; - goto theend; + return -EINVAL; } + nr_sgd = dma_map_sg(mc->dev, areq->dst, sg_nents(areq->dst), DMA_FROM_DEVICE); - if (!nr_sgd || nr_sgd > MAXDESC - 3) { + if (!nr_sgd) { + dma_unmap_sg(mc->dev, areq->src, sg_nents(areq->src), DMA_TO_DEVICE); dev_err(mc->dev, "Invalid SG count %d\n", nr_sgd); - err = -EINVAL; - goto theend; + return -EINVAL; } } - src_sg = areq->src; - dst_sg = areq->dst; - len = areq->cryptlen; - while (src_sg) { - desc = &mc->chanlist[flow].tl[tloffset]; - memset(desc, 0, sizeof(struct meson_desc)); - - desc->t_src = cpu_to_le32(sg_dma_address(src_sg)); - desc->t_dst = cpu_to_le32(sg_dma_address(dst_sg)); - todo = min(len, sg_dma_len(src_sg)); - v = op->keymode | DESC_OWN | todo | algt->blockmode; - if (rctx->op_dir) - v |= DESC_ENCRYPTION; - len -= todo; - - if (!sg_next(src_sg)) - v |= DESC_LAST; - desc->t_status = cpu_to_le32(v); - tloffset++; - src_sg = sg_next(src_sg); - dst_sg = sg_next(dst_sg); + return 0; +} + +static void meson_unmap_scatterlist(struct skcipher_request *areq, struct meson_dev *mc) +{ + if (areq->src == areq->dst) { + dma_unmap_sg(mc->dev, areq->src, sg_nents(areq->src), DMA_BIDIRECTIONAL); + } else { + dma_unmap_sg(mc->dev, areq->src, sg_nents(areq->src), DMA_TO_DEVICE); + dma_unmap_sg(mc->dev, areq->dst, sg_nents(areq->dst), DMA_FROM_DEVICE); } +} - reinit_completion(&mc->chanlist[flow].complete); - meson_dma_start(mc, flow); +static void meson_setup_keyiv_descs(struct cipher_ctx *ctx) +{ + struct meson_cipher_req_ctx *rctx = skcipher_request_ctx(ctx->areq); + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(ctx->areq); + struct skcipher_alg *alg = crypto_skcipher_alg(tfm); + struct meson_alg_template *algt = container_of(alg, + struct meson_alg_template, alg.skcipher.base); + struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct meson_dev *mc = op->mc; + unsigned int ivsize = crypto_skcipher_ivsize(tfm); + unsigned int blockmode = algt->blockmode; + int i; + + if (ctx->tloffset) + return; + + if (blockmode == DESC_OPMODE_CBC) { + memcpy(ctx->bkeyiv + AES_MAX_KEY_SIZE, ctx->areq->iv, ivsize); + dma_sync_single_for_device(mc->dev, ctx->keyiv.addr, + ctx->keyiv.len, DMA_TO_DEVICE); + } + + for (i = 0; i < mc->pdata->setup_desc_cnt; i++) { + struct meson_desc *desc = + &mc->chanlist[rctx->flow].tl[ctx->tloffset]; + int offset = i * 16; + + desc->t_src = cpu_to_le32(ctx->keyiv.addr + offset); + desc->t_dst = cpu_to_le32(offset); + desc->t_status = cpu_to_le32(DESC_OWN | DESC_MODE_KEY | ctx->keyiv.len); + + ctx->tloffset++; + } +} - err = wait_for_completion_interruptible_timeout(&mc->chanlist[flow].complete, +static bool meson_setup_data_descs(struct cipher_ctx *ctx) +{ + struct meson_cipher_req_ctx *rctx = skcipher_request_ctx(ctx->areq); + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(ctx->areq); + struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct skcipher_alg *alg = crypto_skcipher_alg(tfm); + struct meson_alg_template *algt = container_of(alg, + struct meson_alg_template, + alg.skcipher.base); + struct meson_dev *mc = op->mc; + struct meson_desc *desc = &mc->chanlist[rctx->flow].tl[ctx->tloffset]; + unsigned int blocksize = crypto_skcipher_blocksize(tfm); + unsigned int blockmode = algt->blockmode; + unsigned int maxlen = rounddown(DESC_MAXLEN, blocksize); + unsigned int todo; + u32 v; + + ctx->tloffset++; + + todo = min(ctx->cryptlen, maxlen); + todo = min(todo, ctx->cryptlen); + todo = min(todo, sg_dma_len(ctx->src_sg) - ctx->src_offset); + todo = min(todo, sg_dma_len(ctx->dst_sg) - ctx->dst_offset); + + desc->t_src = cpu_to_le32(sg_dma_address(ctx->src_sg) + ctx->src_offset); + desc->t_dst = cpu_to_le32(sg_dma_address(ctx->dst_sg) + ctx->dst_offset); + + ctx->cryptlen -= todo; + ctx->src_offset += todo; + ctx->dst_offset += todo; + + v = DESC_OWN | blockmode | op->keymode | todo; + if (rctx->op_dir == MESON_ENCRYPT) + v |= DESC_ENCRYPTION; + + if (!ctx->cryptlen || ctx->tloffset == MAXDESC) + v |= DESC_LAST; + + desc->t_status = cpu_to_le32(v); + + return v & DESC_LAST; +} + +static int meson_kick_hardware(struct cipher_ctx *ctx) +{ + struct meson_cipher_req_ctx *rctx = skcipher_request_ctx(ctx->areq); + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(ctx->areq); + struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct skcipher_alg *alg = crypto_skcipher_alg(tfm); + struct meson_alg_template *algt = container_of(alg, + struct meson_alg_template, + alg.skcipher.base); + struct meson_dev *mc = op->mc; + unsigned int ivsize = crypto_skcipher_ivsize(tfm); + unsigned int blockmode = algt->blockmode; + enum dma_data_direction new_iv_dir; + dma_addr_t new_iv_phys; + void *new_iv; + int err; + + if (blockmode == DESC_OPMODE_CBC) { + struct scatterlist *sg; + unsigned int offset; + + if (rctx->op_dir == MESON_ENCRYPT) { + sg = ctx->dst_sg; + offset = ctx->dst_offset; + new_iv_dir = DMA_FROM_DEVICE; + } else { + sg = ctx->src_sg; + offset = ctx->src_offset; + new_iv_dir = DMA_TO_DEVICE; + } + + if (ctx->areq->src == ctx->areq->dst) + new_iv_dir = DMA_BIDIRECTIONAL; + + offset -= ivsize; + new_iv = sg_virt(sg) + offset; + new_iv_phys = sg_dma_address(sg) + offset; + } + + if (blockmode == DESC_OPMODE_CBC && + rctx->op_dir == MESON_DECRYPT) { + dma_sync_single_for_cpu(mc->dev, new_iv_phys, + ivsize, new_iv_dir); + memcpy(ctx->areq->iv, new_iv, ivsize); + } + + reinit_completion(&mc->chanlist[rctx->flow].complete); + meson_dma_start(mc, rctx->flow); + err = wait_for_completion_interruptible_timeout(&mc->chanlist[rctx->flow].complete, msecs_to_jiffies(500)); if (err == 0) { - dev_err(mc->dev, "DMA timeout for flow %d\n", flow); - err = -EINVAL; + dev_err(mc->dev, "DMA timeout for flow %d\n", rctx->flow); + return -EINVAL; } else if (err < 0) { dev_err(mc->dev, "Waiting for DMA completion is failed (%d)\n", err); - } else { - /* No error */ - err = 0; + return err; } - dma_unmap_single(mc->dev, phykeyiv, keyivlen, DMA_TO_DEVICE); + if (blockmode == DESC_OPMODE_CBC && + rctx->op_dir == MESON_ENCRYPT) { + dma_sync_single_for_cpu(mc->dev, new_iv_phys, + ivsize, new_iv_dir); + memcpy(ctx->areq->iv, new_iv, ivsize); + } - if (areq->src == areq->dst) { - dma_unmap_sg(mc->dev, areq->src, sg_nents(areq->src), DMA_BIDIRECTIONAL); - } else { - dma_unmap_sg(mc->dev, areq->src, sg_nents(areq->src), DMA_TO_DEVICE); - dma_unmap_sg(mc->dev, areq->dst, sg_nents(areq->dst), DMA_FROM_DEVICE); + ctx->tloffset = 0; + + return 0; +} + +static int meson_cipher(struct skcipher_request *areq) +{ + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); + struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct meson_cipher_req_ctx *rctx = skcipher_request_ctx(areq); + struct meson_dev *mc = op->mc; + struct skcipher_alg *alg = crypto_skcipher_alg(tfm); + struct meson_alg_template *algt; + struct cipher_ctx ctx = { + .areq = areq, + .src_offset = 0, + .dst_offset = 0, + .src_sg = areq->src, + .dst_sg = areq->dst, + .cryptlen = areq->cryptlen, + }; + int err; + + dev_dbg(mc->dev, "%s %s %u %x IV(%u) key=%u ctx.flow=%d\n", __func__, + crypto_tfm_alg_name(areq->base.tfm), + areq->cryptlen, + rctx->op_dir, crypto_skcipher_ivsize(tfm), + op->keylen, rctx->flow); + + algt = container_of(alg, struct meson_alg_template, alg.skcipher.base); + +#ifdef CONFIG_CRYPTO_DEV_AMLOGIC_GXL_DEBUG + algt->stat_req++; + mc->chanlist[rctx->flow].stat_req++; +#endif + + ctx.bkeyiv = kzalloc(48, GFP_KERNEL | GFP_DMA); + if (!ctx.bkeyiv) + return -ENOMEM; + + memcpy(ctx.bkeyiv, op->key, op->keylen); + ctx.keyiv.len = op->keylen; + if (ctx.keyiv.len == AES_KEYSIZE_192) + ctx.keyiv.len = AES_MAX_KEY_SIZE; + + ctx.keyiv.addr = dma_map_single(mc->dev, ctx.bkeyiv, ctx.keyiv.len, + DMA_TO_DEVICE); + err = dma_mapping_error(mc->dev, ctx.keyiv.addr); + if (err) { + dev_err(mc->dev, "Cannot DMA MAP KEY IV\n"); + goto free_keyiv; } - if (areq->iv && ivsize > 0) { - if (rctx->op_dir == MESON_DECRYPT) { - memcpy(areq->iv, backup_iv, ivsize); - } else { - scatterwalk_map_and_copy(areq->iv, areq->dst, - areq->cryptlen - ivsize, - ivsize, 0); + err = meson_map_scatterlist(areq, mc); + if (err) + goto unmap_keyiv; + + ctx.tloffset = 0; + + while (ctx.cryptlen) { + meson_setup_keyiv_descs(&ctx); + + if (meson_setup_data_descs(&ctx)) { + err = meson_kick_hardware(&ctx); + if (err) + break; + } + + if (ctx.src_offset == sg_dma_len(ctx.src_sg)) { + ctx.src_offset = 0; + ctx.src_sg = sg_next(ctx.src_sg); + } + + if (ctx.dst_offset == sg_dma_len(ctx.dst_sg)) { + ctx.dst_offset = 0; + ctx.dst_sg = sg_next(ctx.dst_sg); } } -theend: - kfree_sensitive(bkeyiv); - kfree_sensitive(backup_iv); + + meson_unmap_scatterlist(areq, mc); + +unmap_keyiv: + dma_unmap_single(mc->dev, ctx.keyiv.addr, ctx.keyiv.len, DMA_TO_DEVICE); + +free_keyiv: + kfree_sensitive(ctx.bkeyiv); return err; } diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c index 98e63e67aa6e..5fea95e9876b 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -258,6 +258,7 @@ static void meson_crypto_remove(struct platform_device *pdev) static const struct meson_pdata meson_gxl_pdata = { .descs_reg = 0x0, .status_reg = 0x4, + .setup_desc_cnt = 3, }; static const struct of_device_id meson_crypto_of_match_table[] = { diff --git a/drivers/crypto/amlogic/amlogic-gxl.h b/drivers/crypto/amlogic/amlogic-gxl.h index 1ab3462dea42..f3455babb52a 100644 --- a/drivers/crypto/amlogic/amlogic-gxl.h +++ b/drivers/crypto/amlogic/amlogic-gxl.h @@ -82,10 +82,12 @@ struct meson_flow { * struct meson_pdata - SoC series dependent data. * @reg_descs: offset to descriptors register * @reg_status: offset to status register + * @setup_desc_cnt: number of setup descriptor to configure. */ struct meson_pdata { u32 descs_reg; u32 status_reg; + u32 setup_desc_cnt; }; /* From patchwork Thu Apr 11 13:38:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788628 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 9385514D447; Thu, 11 Apr 2024 13:39:08 +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=1712842750; cv=none; b=OC9pqvcqvAjv8Euy9s9I/tFbkduxloYw/SVwpLeq8fxDARNgnLZwNcppCafV7zrzZn8NhaiD81jdqsoyYNhyHH21y8/XUjgezIdsEg+HG+wPKwB/RUVxRXMfVRupskTJRKl5VVBlSvT4p37rGx4RZU4pPZaljJ9lSg7pp70k/yc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842750; c=relaxed/simple; bh=YYVVVgS1XhatDg24b9y5zpuioEOCh6zKrTqYO5Fev5s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QJq9wcvdMzao4jCr/Lp2pBy54niH4fTAsCjvq8q/fwA4YLroNzTIR/x5vLR42SGedOD7hI1o/E4IJKZrHdMyP277fV896I74wXpK2Yzeqw5dCkjlS2PqK5KOlb1dSuHTMkFYXuiiAJe+tRD3HYgXLBGK0Qm0UrFQShkP2GTZCyQ= 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=ivRhdBd0; 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="ivRhdBd0" Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 76E4512006C; Thu, 11 Apr 2024 16:39:06 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 76E4512006C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842746; bh=U/xc+lJ4rD3tiF8KGs/aLV2vWaaWS8LW/o7xAJdxLoM=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=ivRhdBd0VEqly2kYZMOEoUziDY1ELjrv4Ema6o8KErwD0GhEFojGvrJozukzsfLck PO3iSBt2HnyP8BsusFBFQnlcigAle5N8YEi27GpFmHbMiCvW5FlufUO2M3l50S3PUN EHI9Nyz/4itzkT1UL2ZrVGiitPK7AdpugZ7ViYio+WT33f+lwE5YEuzWl0mM3+iJUz //KaQ49X0lqR2wDPgOtWEjNcsxIzKGkR80dfaMSz+XNNzb+H3jOaiGF4NOXOjT+N08 uKx3Pnra1ibXvlWrlZbc8jjOOcjAZDOWn1cu6TjsZxGbhApJie0XDR0yer2x+97Jjl vSvqdLCUzArWg== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:39:06 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:39:05 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 10/23] drivers: crypto: meson: avoid kzalloc in engine thread Date: Thu, 11 Apr 2024 16:38:19 +0300 Message-ID: <20240411133832.2896463-11-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 127.0.0.199:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; salutedevices.com:7.1.1; 100.64.160.123:7.1.2, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped It makes no sense to allocate memory via kzalloc, we can use static buffer, speedup data processing and don't think about kfree() calls. Signed-off-by: Alexey Romanov Reviewed-by: Neil Armstrong --- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 52 +++++++++------------ drivers/crypto/amlogic/amlogic-gxl.h | 4 +- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/drivers/crypto/amlogic/amlogic-gxl-cipher.c b/drivers/crypto/amlogic/amlogic-gxl-cipher.c index dd2478ae7c54..eeb86c900f84 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-cipher.c +++ b/drivers/crypto/amlogic/amlogic-gxl-cipher.c @@ -59,7 +59,7 @@ static bool meson_cipher_need_fallback(struct skcipher_request *areq) static int meson_cipher_do_fallback(struct skcipher_request *areq) { struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); - struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx_dma(tfm); struct meson_cipher_req_ctx *rctx = skcipher_request_ctx(areq); int err; #ifdef CONFIG_CRYPTO_DEV_AMLOGIC_GXL_DEBUG @@ -91,7 +91,6 @@ struct cipher_ctx { struct skcipher_request *areq; struct scatterlist *src_sg; struct scatterlist *dst_sg; - void *bkeyiv; unsigned int src_offset; unsigned int dst_offset; @@ -147,7 +146,7 @@ static void meson_setup_keyiv_descs(struct cipher_ctx *ctx) struct skcipher_alg *alg = crypto_skcipher_alg(tfm); struct meson_alg_template *algt = container_of(alg, struct meson_alg_template, alg.skcipher.base); - struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx_dma(tfm); struct meson_dev *mc = op->mc; unsigned int ivsize = crypto_skcipher_ivsize(tfm); unsigned int blockmode = algt->blockmode; @@ -157,7 +156,7 @@ static void meson_setup_keyiv_descs(struct cipher_ctx *ctx) return; if (blockmode == DESC_OPMODE_CBC) { - memcpy(ctx->bkeyiv + AES_MAX_KEY_SIZE, ctx->areq->iv, ivsize); + memcpy(op->keyiv + AES_MAX_KEY_SIZE, ctx->areq->iv, ivsize); dma_sync_single_for_device(mc->dev, ctx->keyiv.addr, ctx->keyiv.len, DMA_TO_DEVICE); } @@ -179,7 +178,7 @@ static bool meson_setup_data_descs(struct cipher_ctx *ctx) { struct meson_cipher_req_ctx *rctx = skcipher_request_ctx(ctx->areq); struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(ctx->areq); - struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx_dma(tfm); struct skcipher_alg *alg = crypto_skcipher_alg(tfm); struct meson_alg_template *algt = container_of(alg, struct meson_alg_template, @@ -222,7 +221,7 @@ static int meson_kick_hardware(struct cipher_ctx *ctx) { struct meson_cipher_req_ctx *rctx = skcipher_request_ctx(ctx->areq); struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(ctx->areq); - struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx_dma(tfm); struct skcipher_alg *alg = crypto_skcipher_alg(tfm); struct meson_alg_template *algt = container_of(alg, struct meson_alg_template, @@ -291,7 +290,7 @@ static int meson_kick_hardware(struct cipher_ctx *ctx) static int meson_cipher(struct skcipher_request *areq) { struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); - struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx_dma(tfm); struct meson_cipher_req_ctx *rctx = skcipher_request_ctx(areq); struct meson_dev *mc = op->mc; struct skcipher_alg *alg = crypto_skcipher_alg(tfm); @@ -304,6 +303,7 @@ static int meson_cipher(struct skcipher_request *areq) .dst_sg = areq->dst, .cryptlen = areq->cryptlen, }; + unsigned int ivsize = crypto_skcipher_ivsize(tfm); int err; dev_dbg(mc->dev, "%s %s %u %x IV(%u) key=%u ctx.flow=%d\n", __func__, @@ -319,21 +319,21 @@ static int meson_cipher(struct skcipher_request *areq) mc->chanlist[rctx->flow].stat_req++; #endif - ctx.bkeyiv = kzalloc(48, GFP_KERNEL | GFP_DMA); - if (!ctx.bkeyiv) - return -ENOMEM; - - memcpy(ctx.bkeyiv, op->key, op->keylen); ctx.keyiv.len = op->keylen; if (ctx.keyiv.len == AES_KEYSIZE_192) ctx.keyiv.len = AES_MAX_KEY_SIZE; - ctx.keyiv.addr = dma_map_single(mc->dev, ctx.bkeyiv, ctx.keyiv.len, + if (algt->blockmode == DESC_OPMODE_CBC) { + memcpy(op->keyiv + AES_MAX_KEY_SIZE, areq->iv, ivsize); + ctx.keyiv.len = AES_MAX_KEY_SIZE + ivsize; + } + + ctx.keyiv.addr = dma_map_single(mc->dev, op->keyiv, ctx.keyiv.len, DMA_TO_DEVICE); err = dma_mapping_error(mc->dev, ctx.keyiv.addr); if (err) { dev_err(mc->dev, "Cannot DMA MAP KEY IV\n"); - goto free_keyiv; + return err; } err = meson_map_scatterlist(areq, mc); @@ -367,9 +367,6 @@ static int meson_cipher(struct skcipher_request *areq) unmap_keyiv: dma_unmap_single(mc->dev, ctx.keyiv.addr, ctx.keyiv.len, DMA_TO_DEVICE); -free_keyiv: - kfree_sensitive(ctx.bkeyiv); - return err; } @@ -389,7 +386,7 @@ int meson_handle_cipher_request(struct crypto_engine *engine, void *areq) static int meson_skdecrypt(struct skcipher_request *areq) { struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); - struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx_dma(tfm); struct meson_cipher_req_ctx *rctx = skcipher_request_ctx(areq); struct crypto_engine *engine; int e; @@ -407,7 +404,7 @@ static int meson_skdecrypt(struct skcipher_request *areq) static int meson_skencrypt(struct skcipher_request *areq) { struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); - struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx_dma(tfm); struct meson_cipher_req_ctx *rctx = skcipher_request_ctx(areq); struct crypto_engine *engine; int e; @@ -424,7 +421,7 @@ static int meson_skencrypt(struct skcipher_request *areq) static int meson_cipher_init(struct crypto_tfm *tfm) { - struct meson_cipher_tfm_ctx *op = crypto_tfm_ctx(tfm); + struct meson_cipher_tfm_ctx *op = crypto_tfm_ctx_dma(tfm); struct meson_alg_template *algt; const char *name = crypto_tfm_alg_name(tfm); struct crypto_skcipher *sktfm = __crypto_skcipher_cast(tfm); @@ -450,16 +447,15 @@ static int meson_cipher_init(struct crypto_tfm *tfm) static void meson_cipher_exit(struct crypto_tfm *tfm) { - struct meson_cipher_tfm_ctx *op = crypto_tfm_ctx(tfm); + struct meson_cipher_tfm_ctx *op = crypto_tfm_ctx_dma(tfm); - kfree_sensitive(op->key); crypto_free_skcipher(op->fallback_tfm); } static int meson_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen) { - struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx_dma(tfm); struct meson_dev *mc = op->mc; switch (keylen) { @@ -476,11 +472,9 @@ static int meson_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, dev_dbg(mc->dev, "ERROR: Invalid keylen %u\n", keylen); return -EINVAL; } - kfree_sensitive(op->key); + + memcpy(op->keyiv, key, keylen); op->keylen = keylen; - op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA); - if (!op->key) - return -ENOMEM; return crypto_skcipher_setkey(op->fallback_tfm, key, keylen); } @@ -498,7 +492,7 @@ static struct meson_alg_template algs[] = { .cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY | CRYPTO_ALG_NEED_FALLBACK, - .cra_ctxsize = sizeof(struct meson_cipher_tfm_ctx), + .cra_ctxsize = sizeof(struct meson_cipher_tfm_ctx) + CRYPTO_DMA_PADDING, .cra_module = THIS_MODULE, .cra_alignmask = 0xf, .cra_init = meson_cipher_init, @@ -527,7 +521,7 @@ static struct meson_alg_template algs[] = { .cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY | CRYPTO_ALG_NEED_FALLBACK, - .cra_ctxsize = sizeof(struct meson_cipher_tfm_ctx), + .cra_ctxsize = sizeof(struct meson_cipher_tfm_ctx) + CRYPTO_DMA_PADDING, .cra_module = THIS_MODULE, .cra_alignmask = 0xf, .cra_init = meson_cipher_init, diff --git a/drivers/crypto/amlogic/amlogic-gxl.h b/drivers/crypto/amlogic/amlogic-gxl.h index f3455babb52a..9b950c83e79d 100644 --- a/drivers/crypto/amlogic/amlogic-gxl.h +++ b/drivers/crypto/amlogic/amlogic-gxl.h @@ -127,14 +127,14 @@ struct meson_cipher_req_ctx { /* * struct meson_cipher_tfm_ctx - context for a skcipher TFM - * @key: pointer to key data + * @keyiv: key data * @keylen: len of the key * @keymode: The keymode(type and size of key) associated with this TFM * @mc: pointer to the private data of driver handling this TFM * @fallback_tfm: pointer to the fallback TFM */ struct meson_cipher_tfm_ctx { - u32 *key; + u8 keyiv[AES_MAX_KEY_SIZE + AES_BLOCK_SIZE]; u32 keylen; u32 keymode; struct meson_dev *mc; From patchwork Thu Apr 11 13:38:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788047 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) (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 1D99B152DF1; Thu, 11 Apr 2024 13:39:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.18.73.165 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842751; cv=none; b=cypEdaJ+G8IDp74b5OvTANz9RSwg2psc3cnRugGnZ51GADHkhiqKCWHyGqlt9+JOdWHypZ0VtGhzjKipuXT/9GkAnPHJ0wx45NsU8VYpLdijFcGohk1Faq162hXey7E/qNG3Lyke0O3dExdrWGD02NHGR2jdeRAgsylW/TyNyg0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842751; c=relaxed/simple; bh=fe33LzaBF7aIt8gcbsm1Cxtgcwd/bOMQIIGoQ+Z0JVY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DIesRxgJiTf7u2xQb/IsUlF28LYWtjkWOBTb8RxbeA97fjw7UgL1Xu3Hk1Ps1iX1Ui577jp8UtmF6OybmQqga8TitCsaVFZLQuYpOgH3vQvUB/vcqbZYEVEoibtd9/F8Qvk22zfaZHkYW4BY3DaMnhN7lOXgeFiLAwoNbsjJdZs= 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=DZkPygK1; arc=none smtp.client-ip=37.18.73.165 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="DZkPygK1" Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 6EF5610003F; Thu, 11 Apr 2024 16:39:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 6EF5610003F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842747; bh=4CqiCocZGoGFcoL1cYU2QF9ov28UNP/HslAP5gXjsb4=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=DZkPygK12v2Sbi9IP2P1qN2Dkdm9IQ9/zU3ekOtXznioc/+h3NRJVLDLVa/qWFJFr ZC6vQwtDxob9lzswFFpqxnfgJ8yn6xdjY7O+ouzuqAKSxqY/snfJ6VOFGIZjMnOPRb HV3pJ5ehBp5ttoTr/vTEoLiUdH/a786LD1AzMQP7OqvwDALb9hbhBVkK7NNc03EWWn ylbTrWPN5V1uxEzVtHZyzaSdec3qkKXXlCd169ESuV35YwQ0hoEvdiwcDSXTIFiiNv A0zMXq/YqIH1nYQOPBi/ge7oqtshRpsClzRpb6eDGm4E9L2oujh+MP8cHtF0Z14YcX 5MwuhJ4+8ouMg== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:39:07 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:39:06 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 11/23] drivers: crypto: meson: introduce hasher Date: Thu, 11 Apr 2024 16:38:20 +0300 Message-ID: <20240411133832.2896463-12-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 100.64.160.123:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 127.0.0.199:7.1.2; salutedevices.com:7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped Introduce support for SHA1/SHA224/SHA256 hash algos. Tested via tcrypt and custom tests. Signed-off-by: Alexey Romanov --- drivers/crypto/amlogic/Makefile | 2 +- drivers/crypto/amlogic/amlogic-gxl-core.c | 25 +- drivers/crypto/amlogic/amlogic-gxl-hasher.c | 482 ++++++++++++++++++++ drivers/crypto/amlogic/amlogic-gxl.h | 51 +++ 4 files changed, 558 insertions(+), 2 deletions(-) create mode 100644 drivers/crypto/amlogic/amlogic-gxl-hasher.c diff --git a/drivers/crypto/amlogic/Makefile b/drivers/crypto/amlogic/Makefile index 39057e62c13e..4b6b388b7880 100644 --- a/drivers/crypto/amlogic/Makefile +++ b/drivers/crypto/amlogic/Makefile @@ -1,2 +1,2 @@ obj-$(CONFIG_CRYPTO_DEV_AMLOGIC_GXL) += amlogic-gxl-crypto.o -amlogic-gxl-crypto-y := amlogic-gxl-core.o amlogic-gxl-cipher.o +amlogic-gxl-crypto-y := amlogic-gxl-core.o amlogic-gxl-cipher.o amlogic-gxl-hasher.o diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c index 5fea95e9876b..a1aff009f913 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -19,6 +19,9 @@ #include #include #include +#include +#include +#include #include "amlogic-gxl.h" @@ -172,6 +175,15 @@ int meson_register_algs(struct meson_dev *mc, struct meson_alg_template *algs, return err; } break; + case CRYPTO_ALG_TYPE_AHASH: + err = crypto_engine_register_ahash(&algs[i].alg.ahash); + if (err) { + dev_err(mc->dev, "Fail to register %s\n", + algs[i].alg.ahash.base.halg.base.cra_name); + meson_unregister_algs(mc, algs, count); + return err; + } + break; } } @@ -190,6 +202,9 @@ void meson_unregister_algs(struct meson_dev *mc, struct meson_alg_template *algs case CRYPTO_ALG_TYPE_SKCIPHER: crypto_engine_unregister_skcipher(&algs[i].alg.skcipher); break; + case CRYPTO_ALG_TYPE_AHASH: + crypto_engine_unregister_ahash(&algs[i].alg.ahash); + break; } } } @@ -230,13 +245,20 @@ static int meson_crypto_probe(struct platform_device *pdev) dbgfs_dir = debugfs_create_dir("gxl-crypto", NULL); debugfs_create_file("stats", 0444, dbgfs_dir, mc, &meson_debugfs_fops); - #ifdef CONFIG_CRYPTO_DEV_AMLOGIC_GXL_DEBUG mc->dbgfs_dir = dbgfs_dir; #endif } + err = meson_hasher_register(mc); + if (err) + goto error_hasher; + return 0; + +error_hasher: + meson_cipher_unregister(mc); + error_flow: meson_free_chanlist(mc, mc->flow_cnt - 1); return err; @@ -259,6 +281,7 @@ static const struct meson_pdata meson_gxl_pdata = { .descs_reg = 0x0, .status_reg = 0x4, .setup_desc_cnt = 3, + .hasher_supported = false, }; static const struct of_device_id meson_crypto_of_match_table[] = { diff --git a/drivers/crypto/amlogic/amlogic-gxl-hasher.c b/drivers/crypto/amlogic/amlogic-gxl-hasher.c new file mode 100644 index 000000000000..674c7cee562f --- /dev/null +++ b/drivers/crypto/amlogic/amlogic-gxl-hasher.c @@ -0,0 +1,482 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Hardware asynchronous hasher for Amlogic SoC's. + * + * Copyright (c) 2023, SaluteDevices. All Rights Reserved. + * + * Author: Alexey Romanov + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "amlogic-gxl.h" + +static int meson_sha_init(struct ahash_request *req) +{ + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); + struct meson_hasher_tfm_ctx *tctx = crypto_ahash_ctx(tfm); + struct meson_hasher_req_ctx *rctx = ahash_request_ctx(req); + + memset(rctx, 0, sizeof(struct meson_hasher_req_ctx)); + + rctx->flow = meson_get_engine_number(tctx->mc); + rctx->begin_req = true; + + return 0; +} + +static int meson_sha_update(struct ahash_request *req) +{ + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); + struct meson_hasher_tfm_ctx *tctx = crypto_ahash_ctx(tfm); + struct meson_hasher_req_ctx *rctx = ahash_request_ctx(req); + struct crypto_engine *engine = tctx->mc->chanlist[rctx->flow].engine; + + return crypto_transfer_hash_request_to_engine(engine, req); +} + +static int meson_sha_final(struct ahash_request *req) +{ + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); + struct meson_hasher_tfm_ctx *tctx = crypto_ahash_ctx(tfm); + struct meson_hasher_req_ctx *rctx = ahash_request_ctx(req); + struct crypto_engine *engine = tctx->mc->chanlist[rctx->flow].engine; + + rctx->final_req = true; + + return crypto_transfer_hash_request_to_engine(engine, req); +} + +static int meson_hasher_req_map(struct ahash_request *req) +{ + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); + struct meson_hasher_tfm_ctx *tctx = crypto_ahash_ctx(tfm); + struct meson_dev *mc = tctx->mc; + int ret; + + if (!req->nbytes) + return 0; + + ret = dma_map_sg(mc->dev, req->src, sg_nents(req->src), DMA_TO_DEVICE); + if (!ret) { + dev_err(mc->dev, "Cannot DMA MAP request data\n"); + return -ENOMEM; + } + + return 0; +} + +static void meson_hasher_req_unmap(struct ahash_request *req) +{ + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); + struct meson_hasher_tfm_ctx *tctx = crypto_ahash_ctx(tfm); + struct meson_dev *mc = tctx->mc; + + if (!req->nbytes) + return; + + dma_unmap_sg(mc->dev, req->src, sg_nents(req->src), DMA_TO_DEVICE); +} + +struct hasher_ctx { + struct crypto_async_request *areq; + + unsigned int tloffset; + unsigned int nbytes; + unsigned int todo; + + dma_addr_t state_addr; + dma_addr_t src_addr; + unsigned int src_offset; + struct scatterlist *src_sg; +}; + +static bool meson_final(struct hasher_ctx *ctx) +{ + struct ahash_request *req = ahash_request_cast(ctx->areq); + struct meson_hasher_req_ctx *rctx = ahash_request_ctx(req); + + return !ctx->nbytes && rctx->final_req; +} + +static int meson_fill_partial_buffer(struct hasher_ctx *ctx, unsigned int len) +{ + struct ahash_request *req = ahash_request_cast(ctx->areq); + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); + struct meson_hasher_tfm_ctx *tctx = crypto_ahash_ctx(tfm); + struct meson_hasher_req_ctx *rctx = ahash_request_ctx(req); + struct meson_dev *mc = tctx->mc; + unsigned int blocksize = crypto_ahash_blocksize(tfm); + unsigned int copy; + + if (len) { + copy = min(blocksize - rctx->partial_size, len); + memcpy(rctx->partial + rctx->partial_size, + sg_virt(ctx->src_sg) + ctx->src_offset, copy); + + rctx->partial_size += copy; + ctx->nbytes -= copy; + ctx->src_offset += copy; + } + + if (rctx->partial_size == blocksize || meson_final(ctx)) { + rctx->partial_addr = dma_map_single(mc->dev, + rctx->partial, + rctx->partial_size, + DMA_TO_DEVICE); + if (dma_mapping_error(mc->dev, rctx->partial_addr)) { + dev_err(mc->dev, "Cannot DMA MAP SHA partial buffer\n"); + return -ENOMEM; + } + + rctx->partial_mapped = true; + ctx->todo = rctx->partial_size; + ctx->src_addr = rctx->partial_addr; + } + + return 0; +} + +static unsigned int meson_setup_data_descs(struct hasher_ctx *ctx) +{ + struct ahash_request *req = ahash_request_cast(ctx->areq); + struct meson_hasher_req_ctx *rctx = ahash_request_ctx(req); + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); + struct meson_hasher_tfm_ctx *tctx = crypto_ahash_ctx(tfm); + struct meson_dev *mc = tctx->mc; + struct meson_flow *flow = &mc->chanlist[rctx->flow]; + struct hash_alg_common *alg = crypto_hash_alg_common(tfm); + struct meson_alg_template *algt = container_of(alg, + struct meson_alg_template, alg.ahash.base.halg); + struct meson_desc *desc = &flow->tl[ctx->tloffset]; + u32 v; + + ctx->tloffset++; + + v = DESC_OWN | DESC_ENCRYPTION | DESC_OPMODE_SHA | + ctx->todo | algt->blockmode; + if (rctx->begin_req) { + rctx->begin_req = false; + v |= DESC_BEGIN; + } + + if (!ctx->nbytes && rctx->final_req) { + rctx->final_req = false; + v |= DESC_END; + } + + if (!ctx->nbytes || ctx->tloffset == MAXDESC || rctx->partial_mapped) + v |= DESC_LAST; + + desc->t_src = cpu_to_le32(ctx->src_addr); + desc->t_dst = cpu_to_le32(ctx->state_addr); + desc->t_status = cpu_to_le32(v); + + return v & DESC_LAST; +} + +static int meson_kick_hardware(struct hasher_ctx *ctx) +{ + struct ahash_request *req = ahash_request_cast(ctx->areq); + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); + struct meson_hasher_req_ctx *rctx = ahash_request_ctx(req); + struct meson_hasher_tfm_ctx *tctx = crypto_ahash_ctx(tfm); + struct meson_dev *mc = tctx->mc; + struct meson_flow *flow = &mc->chanlist[rctx->flow]; + int ret; + + reinit_completion(&flow->complete); + meson_dma_start(mc, rctx->flow); + + ret = wait_for_completion_timeout(&flow->complete, + msecs_to_jiffies(500)); + if (ret == 0) { + dev_err(mc->dev, "DMA timeout for flow %d\n", rctx->flow); + return -EINVAL; + } else if (ret < 0) { + dev_err(mc->dev, "Waiting for DMA completion is failed (%d)\n", ret); + return ret; + } + + if (rctx->partial_mapped) { + dma_unmap_single(mc->dev, rctx->partial_addr, + rctx->partial_size, + DMA_TO_DEVICE); + rctx->partial_size = 0; + rctx->partial_mapped = false; + } + + ctx->tloffset = 0; + + return 0; +} + +static void meson_setup_state_descs(struct hasher_ctx *ctx) +{ + struct ahash_request *req = ahash_request_cast(ctx->areq); + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); + struct meson_hasher_req_ctx *rctx = ahash_request_ctx(req); + struct meson_hasher_tfm_ctx *tctx = crypto_ahash_ctx(tfm); + struct meson_dev *mc = tctx->mc; + struct meson_desc *desc; + int i; + + if (ctx->tloffset || rctx->begin_req) + return; + + for (i = 0; i < mc->pdata->setup_desc_cnt; i++) { + int offset = i * 16; + + desc = &mc->chanlist[rctx->flow].tl[ctx->tloffset]; + desc->t_src = cpu_to_le32(ctx->state_addr + offset); + desc->t_dst = cpu_to_le32(offset); + desc->t_status = cpu_to_le32(MESON_SHA_BUFFER_SIZE | + DESC_MODE_KEY | DESC_OWN); + + ctx->tloffset++; + } +} + +static int meson_hasher_do_one_request(struct crypto_engine *engine, void *areq) +{ + struct ahash_request *req = ahash_request_cast(areq); + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); + struct meson_hasher_tfm_ctx *tctx = crypto_ahash_ctx(tfm); + struct meson_hasher_req_ctx *rctx = ahash_request_ctx(req); + struct meson_dev *mc = tctx->mc; + struct hasher_ctx ctx = { + .tloffset = 0, + .src_offset = 0, + .nbytes = req->nbytes, + .src_sg = req->src, + .areq = areq, + }; + unsigned int blocksize = crypto_ahash_blocksize(tfm); + unsigned int digest_size = crypto_ahash_digestsize(tfm); + bool final_req = rctx->final_req; + int ret; + + ctx.state_addr = dma_map_single(mc->dev, rctx->state, + sizeof(rctx->state), DMA_BIDIRECTIONAL); + ret = dma_mapping_error(mc->dev, ctx.state_addr); + if (ret) { + dev_err(mc->dev, "Cannot DMA MAP SHA state buffer"); + goto fail_map_single; + } + + ret = meson_hasher_req_map(req); + if (ret) + goto fail_map_req; + + for (;;) { + unsigned int len = ctx.src_sg ? + min(sg_dma_len(ctx.src_sg) - ctx.src_offset, ctx.nbytes) : 0; + + ctx.src_addr = 0; + ctx.todo = 0; + + if (!rctx->final_req && !ctx.nbytes) + break; + + meson_setup_state_descs(&ctx); + + if (rctx->partial_size && rctx->partial_size < blocksize) { + ret = meson_fill_partial_buffer(&ctx, len); + if (ret) + goto fail; + } else if (len && len < blocksize) { + memcpy(rctx->partial, sg_virt(ctx.src_sg) + ctx.src_offset, len); + + rctx->partial_size = len; + ctx.nbytes -= len; + ctx.src_offset += len; + } else if (len) { + ctx.src_addr = sg_dma_address(ctx.src_sg) + ctx.src_offset; + ctx.todo = min(rounddown(DESC_MAXLEN, blocksize), + rounddown(len, blocksize)); + ctx.nbytes -= ctx.todo; + ctx.src_offset += ctx.todo; + } + + if (ctx.src_sg && ctx.src_offset == sg_dma_len(ctx.src_sg)) { + ctx.src_offset = 0; + ctx.src_sg = sg_next(ctx.src_sg); + } + + if (!ctx.todo && ctx.nbytes) + continue; + + if (!ctx.todo && !rctx->final_req && !ctx.tloffset) + continue; + + if (meson_setup_data_descs(&ctx)) { + ret = meson_kick_hardware(&ctx); + if (ret) + goto fail; + } + } + +fail: + meson_hasher_req_unmap(req); + +fail_map_req: + dma_unmap_single(mc->dev, ctx.state_addr, sizeof(rctx->state), + DMA_BIDIRECTIONAL); + +fail_map_single: + if (final_req && ret == 0) + memcpy(req->result, rctx->state, digest_size); + + local_bh_disable(); + crypto_finalize_hash_request(engine, req, ret); + local_bh_enable(); + + return ret; +} + +static int meson_hasher_export(struct ahash_request *req, void *out) +{ + struct meson_hasher_req_ctx *rctx = ahash_request_ctx(req); + + memcpy(out, rctx, sizeof(*rctx)); + return 0; +} + +static int meson_hasher_import(struct ahash_request *req, const void *in) +{ + struct meson_hasher_req_ctx *rctx = ahash_request_ctx(req); + + memcpy(rctx, in, sizeof(*rctx)); + return 0; +} + +static int meson_hasher_init(struct crypto_tfm *tfm) +{ + struct meson_hasher_tfm_ctx *tctx = crypto_tfm_ctx(tfm); + struct crypto_ahash *atfm = __crypto_ahash_cast(tfm); + struct hash_alg_common *alg = crypto_hash_alg_common(atfm); + struct meson_alg_template *algt = container_of(alg, + struct meson_alg_template, alg.ahash.base.halg); + + crypto_ahash_set_reqsize(atfm, crypto_ahash_statesize(atfm)); + + memset(tctx, 0, sizeof(struct meson_hasher_tfm_ctx)); + + tctx->mc = algt->mc; + + return 0; +} + +static struct meson_alg_template mc_algs[] = { +{ + .type = CRYPTO_ALG_TYPE_AHASH, + .blockmode = DESC_MODE_SHA1, + .alg.ahash.base = { + .halg = { + .base = { + .cra_name = "sha1", + .cra_driver_name = "sha1-gxl", + .cra_priority = 400, + .cra_blocksize = SHA1_BLOCK_SIZE, + .cra_flags = CRYPTO_ALG_ASYNC, + .cra_ctxsize = sizeof(struct meson_hasher_tfm_ctx), + .cra_module = THIS_MODULE, + .cra_alignmask = 0, + .cra_init = meson_hasher_init, + }, + .digestsize = SHA1_DIGEST_SIZE, + .statesize = sizeof(struct meson_hasher_req_ctx), + }, + .init = meson_sha_init, + .update = meson_sha_update, + .final = meson_sha_final, + .export = meson_hasher_export, + .import = meson_hasher_import, + }, + .alg.ahash.op = { + .do_one_request = meson_hasher_do_one_request, + }, +}, +{ + .type = CRYPTO_ALG_TYPE_AHASH, + .blockmode = DESC_MODE_SHA224, + .alg.ahash.base = { + .halg = { + .base = { + .cra_name = "sha224", + .cra_driver_name = "sha224-gxl", + .cra_priority = 400, + .cra_blocksize = SHA224_BLOCK_SIZE, + .cra_flags = CRYPTO_ALG_ASYNC, + .cra_ctxsize = sizeof(struct meson_hasher_tfm_ctx), + .cra_module = THIS_MODULE, + .cra_alignmask = 0, + .cra_init = meson_hasher_init, + }, + .digestsize = SHA224_DIGEST_SIZE, + .statesize = sizeof(struct meson_hasher_req_ctx), + }, + .init = meson_sha_init, + .update = meson_sha_update, + .final = meson_sha_final, + .export = meson_hasher_export, + .import = meson_hasher_import, + }, + .alg.ahash.op = { + .do_one_request = meson_hasher_do_one_request, + }, +}, +{ + .type = CRYPTO_ALG_TYPE_AHASH, + .blockmode = DESC_MODE_SHA256, + .alg.ahash.base = { + .halg = { + .base = { + .cra_name = "sha256", + .cra_driver_name = "sha256-gxl", + .cra_priority = 400, + .cra_blocksize = SHA256_BLOCK_SIZE, + .cra_flags = CRYPTO_ALG_ASYNC, + .cra_ctxsize = sizeof(struct meson_hasher_tfm_ctx), + .cra_module = THIS_MODULE, + .cra_alignmask = 0, + .cra_init = meson_hasher_init, + }, + .digestsize = SHA256_DIGEST_SIZE, + .statesize = sizeof(struct meson_hasher_req_ctx), + }, + .init = meson_sha_init, + .update = meson_sha_update, + .final = meson_sha_final, + .export = meson_hasher_export, + .import = meson_hasher_import, + }, + .alg.ahash.op = { + .do_one_request = meson_hasher_do_one_request, + }, +}, +}; + +int meson_hasher_register(struct meson_dev *mc) +{ + if (!mc->pdata->hasher_supported) { + pr_info("amlogic-gxl-hasher: hasher not supported at current platform"); + return 0; + } + + return meson_register_algs(mc, mc_algs, ARRAY_SIZE(mc_algs)); +} + +void meson_hasher_unregister(struct meson_dev *mc) +{ + if (!mc->pdata->hasher_supported) + return; + + meson_unregister_algs(mc, mc_algs, ARRAY_SIZE(mc_algs)); +} diff --git a/drivers/crypto/amlogic/amlogic-gxl.h b/drivers/crypto/amlogic/amlogic-gxl.h index 9b950c83e79d..6146e046ee40 100644 --- a/drivers/crypto/amlogic/amlogic-gxl.h +++ b/drivers/crypto/amlogic/amlogic-gxl.h @@ -5,6 +5,7 @@ * Copyright (C) 2018-2019 Corentin LABBE */ #include +#include #include #include #include @@ -23,13 +24,25 @@ #define DESC_OPMODE_ECB (0 << 26) #define DESC_OPMODE_CBC (1 << 26) +#define DESC_OPMODE_SHA (0 << 26) #define DESC_MAXLEN GENMASK(16, 0) +#define DESC_MODE_SHA1 (0x5 << 20) +#define DESC_MODE_SHA224 (0x7 << 20) +#define DESC_MODE_SHA256 (0x6 << 20) + #define DESC_LAST BIT(18) +#define DESC_BEGIN BIT(24) +#define DESC_END BIT(25) #define DESC_ENCRYPTION BIT(28) #define DESC_OWN BIT(31) +#define MESON_SHA_BUFFER_SIZE (SHA256_DIGEST_SIZE + 16) + +#define MESON_SHA_BEGIN BIT(1) +#define MESON_SHA_FINAL BIT(2) + /* * struct meson_desc - Descriptor for DMA operations * Note that without datasheet, some are unknown @@ -83,11 +96,13 @@ struct meson_flow { * @reg_descs: offset to descriptors register * @reg_status: offset to status register * @setup_desc_cnt: number of setup descriptor to configure. + * @hasher_supported: indecates whether hasher is supported. */ struct meson_pdata { u32 descs_reg; u32 status_reg; u32 setup_desc_cnt; + bool hasher_supported; }; /* @@ -141,6 +156,38 @@ struct meson_cipher_tfm_ctx { struct crypto_skcipher *fallback_tfm; }; +/* + * struct meson_hasher_req_ctx - context for a hasher request + * @state: state data + * @partial: partial buffer data. Contains sent data which + * size < blocksize + * @partial_size: size of the partial buffer + * @partial_addr: physical address of partial buffer + * @partial_mapped: indicates is partial buffer currently mapped or not + * @flags: request flags (for example, is this final req or not) + * @flow: the flow to use for this request + */ +struct meson_hasher_req_ctx { + u8 state[SHA256_DIGEST_SIZE + 16] ____cacheline_aligned; + u8 partial[SHA256_BLOCK_SIZE] ____cacheline_aligned; + unsigned int partial_size ____cacheline_aligned; + dma_addr_t partial_addr; + bool partial_mapped; + + bool begin_req; + bool final_req; + int flow; +}; + +/* + * struct meson_hasher_tfm_ctx - context for a hasher TFM + * @enginectx: crypto_engine used by this TFM + * @mc: pointer to the private data of driver handling this TFM + */ +struct meson_hasher_tfm_ctx { + struct meson_dev *mc; +}; + /* * struct meson_alg_template - crypto_alg template * @type: the CRYPTO_ALG_TYPE for this template @@ -155,6 +202,7 @@ struct meson_alg_template { u32 blockmode; union { struct skcipher_engine_alg skcipher; + struct ahash_engine_alg ahash; } alg; struct meson_dev *mc; #ifdef CONFIG_CRYPTO_DEV_AMLOGIC_GXL_DEBUG @@ -178,3 +226,6 @@ int meson_cipher_register(struct meson_dev *mc); void meson_cipher_unregister(struct meson_dev *mc); void meson_cipher_debugfs_show(struct seq_file *seq, void *v); int meson_handle_cipher_request(struct crypto_engine *engine, void *areq); + +int meson_hasher_register(struct meson_dev *mc); +void meson_hasher_unregister(struct meson_dev *mc); From patchwork Thu Apr 11 13:38:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788627 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 4B9E31534E8; Thu, 11 Apr 2024 13:39:10 +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=1712842752; cv=none; b=upabpXcQgwzmeJOtZoD62/NfbdFUdtOcL3LlpNm7KV3qn+WZEAEDrN5r7ILJWa2VKjjbi1Q0fRgbJYFl3aRrprIVREH7oprGhJ96f5lBZLWnjpH5Vido208iAByGfQJ9kZbyHGATDXDW5zPIBBhdtA7tqkYYv+MnhoBeFlbeZiM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842752; c=relaxed/simple; bh=bmEMuelBFPHYQZwrcPMnPR4/AV+kt7K8jTlfvJ6GyXg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dq5viIl8cbk4IlE2P7qvQ/YgRpkf5fiqzDnEBWgaihJwBiQ9E/C/H5N3I+EJQHuYpQhwCqhFNMCy/0b1QRLM7Xb1W+44yKjjw3W/HsRG8ZIw810cqZxeetit6YDAU8aFGv2UzrF0GtA7rKjy7HI3waMTl5RJoJ4l6C61P7//tAc= 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=c2H0JzIo; 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="c2H0JzIo" Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 68425120076; Thu, 11 Apr 2024 16:39:08 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 68425120076 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842748; bh=BfuomMMrX9TDLcqETvGG/BmqFCylPMtTiHkbB+8Vhnw=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=c2H0JzIob+mAw+P7s99ZISSZ/VduuuLLxIMRJZABrfwutiuodCZgcFz0oWIel68+x uzI0lypIwesa6sIm0Ftlms4VzCUnKZK91o+8phDh4a6Sn8y1xmYXcNOrWhQD0KGdkW zqbAxFXiJOy2EgbG2GSme6zK7e02mUNjFQxQrdnvDOU4H40oC1ZeZcjdgumEJJMuR5 ZjXDFs/nlwHMvnQKGHdFanBkqCv1H3JHQG3pcOKqsqmzJkIo19CtHj+Retg7KAoo6E oXQP4XVuvykPv2UNco7N5KlprD14sqFER0Bt+kiMa4MUfqunVyfcTG5hO9cFS/UjOG rkae9S3O6pSvA== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:39:08 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:39:07 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 12/23] drivers: crypto: meson: add support for AES-CTR Date: Thu, 11 Apr 2024 16:38:21 +0300 Message-ID: <20240411133832.2896463-13-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 127.0.0.199:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; salutedevices.com:7.1.1; 100.64.160.123:7.1.2, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped This patch adds support for AES-CTR algorithm. Tested via tcrypt and custom tests. Signed-off-by: Alexey Romanov --- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 59 +++++++++++++++++++-- drivers/crypto/amlogic/amlogic-gxl-core.c | 1 + drivers/crypto/amlogic/amlogic-gxl.h | 2 + 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/amlogic/amlogic-gxl-cipher.c b/drivers/crypto/amlogic/amlogic-gxl-cipher.c index eeb86c900f84..14621495de84 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-cipher.c +++ b/drivers/crypto/amlogic/amlogic-gxl-cipher.c @@ -139,6 +139,15 @@ static void meson_unmap_scatterlist(struct skcipher_request *areq, struct meson_ } } +static void reverse_keyiv(u32 *keyiv, u32 *iv) +{ + int size = AES_BLOCK_SIZE / sizeof(u32); + int i; + + for (i = 0; i < size; i++) + *(keyiv + size - i - 1) = cpu_to_be32(*(iv + i)); +} + static void meson_setup_keyiv_descs(struct cipher_ctx *ctx) { struct meson_cipher_req_ctx *rctx = skcipher_request_ctx(ctx->areq); @@ -155,8 +164,12 @@ static void meson_setup_keyiv_descs(struct cipher_ctx *ctx) if (ctx->tloffset) return; - if (blockmode == DESC_OPMODE_CBC) { - memcpy(op->keyiv + AES_MAX_KEY_SIZE, ctx->areq->iv, ivsize); + if (blockmode == DESC_OPMODE_CBC || blockmode == DESC_OPMODE_CTR) { + if (blockmode == DESC_OPMODE_CTR && mc->pdata->reverse_keyiv) + reverse_keyiv((u32 *)(op->keyiv + AES_MAX_KEY_SIZE), (u32 *)ctx->areq->iv); + else + memcpy(op->keyiv + AES_MAX_KEY_SIZE, ctx->areq->iv, ivsize); + dma_sync_single_for_device(mc->dev, ctx->keyiv.addr, ctx->keyiv.len, DMA_TO_DEVICE); } @@ -187,6 +200,7 @@ static bool meson_setup_data_descs(struct cipher_ctx *ctx) struct meson_desc *desc = &mc->chanlist[rctx->flow].tl[ctx->tloffset]; unsigned int blocksize = crypto_skcipher_blocksize(tfm); unsigned int blockmode = algt->blockmode; + unsigned int ivsize = crypto_skcipher_ivsize(tfm); unsigned int maxlen = rounddown(DESC_MAXLEN, blocksize); unsigned int todo; u32 v; @@ -205,8 +219,15 @@ static bool meson_setup_data_descs(struct cipher_ctx *ctx) ctx->src_offset += todo; ctx->dst_offset += todo; + if (blockmode == DESC_OPMODE_CTR) { + unsigned int nblocks = todo / blocksize; + + while (nblocks--) + crypto_inc(ctx->areq->iv, ivsize); + } + v = DESC_OWN | blockmode | op->keymode | todo; - if (rctx->op_dir == MESON_ENCRYPT) + if (rctx->op_dir == MESON_ENCRYPT || blockmode == DESC_OPMODE_CTR) v |= DESC_ENCRYPTION; if (!ctx->cryptlen || ctx->tloffset == MAXDESC) @@ -323,7 +344,8 @@ static int meson_cipher(struct skcipher_request *areq) if (ctx.keyiv.len == AES_KEYSIZE_192) ctx.keyiv.len = AES_MAX_KEY_SIZE; - if (algt->blockmode == DESC_OPMODE_CBC) { + if (algt->blockmode == DESC_OPMODE_CBC || + algt->blockmode == DESC_OPMODE_CTR) { memcpy(op->keyiv + AES_MAX_KEY_SIZE, areq->iv, ivsize); ctx.keyiv.len = AES_MAX_KEY_SIZE + ivsize; } @@ -537,6 +559,35 @@ static struct meson_alg_template algs[] = { .do_one_request = meson_handle_cipher_request, }, }, +{ + .type = CRYPTO_ALG_TYPE_SKCIPHER, + .blockmode = DESC_OPMODE_CTR, + .alg.skcipher.base = { + .base = { + .cra_name = "ctr(aes)", + .cra_driver_name = "ctr-aes-gxl", + .cra_priority = 400, + .cra_blocksize = AES_BLOCK_SIZE, + .cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | + CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY | + CRYPTO_ALG_NEED_FALLBACK, + .cra_ctxsize = sizeof(struct meson_cipher_tfm_ctx) + CRYPTO_DMA_PADDING, + .cra_module = THIS_MODULE, + .cra_alignmask = 0xf, + .cra_init = meson_cipher_init, + .cra_exit = meson_cipher_exit, + }, + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .ivsize = AES_BLOCK_SIZE, + .setkey = meson_aes_setkey, + .encrypt = meson_skencrypt, + .decrypt = meson_skdecrypt, + }, + .alg.skcipher.op = { + .do_one_request = meson_handle_cipher_request, + }, +}, }; int meson_cipher_register(struct meson_dev *mc) diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c index a1aff009f913..2c8387906655 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -282,6 +282,7 @@ static const struct meson_pdata meson_gxl_pdata = { .status_reg = 0x4, .setup_desc_cnt = 3, .hasher_supported = false, + .reverse_keyiv = true, }; static const struct of_device_id meson_crypto_of_match_table[] = { diff --git a/drivers/crypto/amlogic/amlogic-gxl.h b/drivers/crypto/amlogic/amlogic-gxl.h index 6146e046ee40..2eee3e0ea0b2 100644 --- a/drivers/crypto/amlogic/amlogic-gxl.h +++ b/drivers/crypto/amlogic/amlogic-gxl.h @@ -24,6 +24,7 @@ #define DESC_OPMODE_ECB (0 << 26) #define DESC_OPMODE_CBC (1 << 26) +#define DESC_OPMODE_CTR (2 << 26) #define DESC_OPMODE_SHA (0 << 26) #define DESC_MAXLEN GENMASK(16, 0) @@ -103,6 +104,7 @@ struct meson_pdata { u32 status_reg; u32 setup_desc_cnt; bool hasher_supported; + bool reverse_keyiv; }; /* From patchwork Thu Apr 11 13:38:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788046 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) (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 C4DF014D6E4; Thu, 11 Apr 2024 13:39:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.18.73.165 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842752; cv=none; b=Oer29O/KKqKQAfEO4D2VTHOhqXBa4NzStHp7QW6dbl4qeeluZFiWLLRlYXoXpjWe42Y3s9EynIeGqWUDvr+OjY+M82QLDzx/WLP1QzeU94xv1wuMfjahD/1SnB/H8XXf9w+OaNAawl3JjMzxvrJTz8mef9DPv5SGiiPYWifq59c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842752; c=relaxed/simple; bh=Fspv0VUWIGgqAF6DPsEB4r8hOKmcOHqMGaxpyD+TtQE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZZK4yl2ZGi24EHEWgNpyAzFCH0meFEfsu2QiqxyVfGv56u9HlGxmI/ql5iX6DH80kC7jJcZXjemjITVW7Uvl//m65OIaaVnmAFIUacZkdLJOzeDlDsq51vRE5pGp/+GW+up+06tNTaF0YrMsHvXzR8p29NgRX1rwnwLQEMLJJmQ= 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=kCB3bg05; arc=none smtp.client-ip=37.18.73.165 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="kCB3bg05" Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 1CDBF10003D; Thu, 11 Apr 2024 16:39:09 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 1CDBF10003D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842749; bh=Sz/WVCf45FY5vSFypYhGtRQCfa45fyJnzDpf+z86rS0=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=kCB3bg05yS7Kx2qvqpWJR9Wrvy7Pvjmp0bYEdBEINy2QyvhEIIawMk0Db/bDilCek YOqYPype5uDoEdlc3TKRS2rdFrBSZ5OzhXej1ho8SALFKkLq3RGasNsWcNQwtdw4Qq Dw4z2GUbxzBPv1i6XaKoyrJsn4PFYUKuxrXOwcxXSAwRPkvRTj1pupZJGLsVVR0Ind nBj3ZjqS0DsAEb+6/c8e9jUo1pHgHlaahVvUmb28wUxmPPx/z8jC7g8mbsY6A0cfJP AThx4e9YIASyYzp6hChSWiPpmh9PJ4IesN+hKj7IP2pp4DAOy1Ppkc2KUgqWqXRhsn Jf5VKjpj3CjgA== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:39:08 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:39:08 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 13/23] drivers: crypto: meson: use fallback for 192-bit keys Date: Thu, 11 Apr 2024 16:38:22 +0300 Message-ID: <20240411133832.2896463-14-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 100.64.160.123:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 127.0.0.199:7.1.2; salutedevices.com:7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped Unforunately, not all Amlogic SoC's have a 192-bit key support for AES algo. In this case, use fallback. Signed-off-by: Alexey Romanov --- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 7 +++++++ drivers/crypto/amlogic/amlogic-gxl-core.c | 1 + drivers/crypto/amlogic/amlogic-gxl.h | 2 ++ 3 files changed, 10 insertions(+) diff --git a/drivers/crypto/amlogic/amlogic-gxl-cipher.c b/drivers/crypto/amlogic/amlogic-gxl-cipher.c index 14621495de84..30f248ca31c7 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-cipher.c +++ b/drivers/crypto/amlogic/amlogic-gxl-cipher.c @@ -41,6 +41,13 @@ static bool meson_cipher_need_fallback_sg(struct skcipher_request *areq, static bool meson_cipher_need_fallback(struct skcipher_request *areq) { + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); + struct meson_cipher_tfm_ctx *op = crypto_skcipher_ctx_dma(tfm); + struct meson_dev *mc = op->mc; + + if (op->keymode == DESC_MODE_AES_192 && !mc->pdata->support_192bit_key) + return true; + if (areq->cryptlen == 0) return true; diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c index 2c8387906655..4acacd925a21 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -283,6 +283,7 @@ static const struct meson_pdata meson_gxl_pdata = { .setup_desc_cnt = 3, .hasher_supported = false, .reverse_keyiv = true, + .support_192bit_key = true, }; static const struct of_device_id meson_crypto_of_match_table[] = { diff --git a/drivers/crypto/amlogic/amlogic-gxl.h b/drivers/crypto/amlogic/amlogic-gxl.h index 2eee3e0ea0b2..86dd9f10debe 100644 --- a/drivers/crypto/amlogic/amlogic-gxl.h +++ b/drivers/crypto/amlogic/amlogic-gxl.h @@ -98,6 +98,7 @@ struct meson_flow { * @reg_status: offset to status register * @setup_desc_cnt: number of setup descriptor to configure. * @hasher_supported: indecates whether hasher is supported. + * @support_192bit_key: indicates whether platform support AES 192-bit key */ struct meson_pdata { u32 descs_reg; @@ -105,6 +106,7 @@ struct meson_pdata { u32 setup_desc_cnt; bool hasher_supported; bool reverse_keyiv; + bool support_192bit_key; }; /* From patchwork Thu Apr 11 13:38:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788626 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 1DF8F153567; Thu, 11 Apr 2024 13:39:11 +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=1712842754; cv=none; b=simu1/I/798PrFOF/hen9vJlJASLfin33E54hgpjAFX+pmXvt2LfUmPAQlkDePE2I85uIv7LSTybx4rYzD3Wzy1bmnxVkAfxTq5nRI/ZfqVY4R8z6WrM8t6aOs7nIetMglhhH92vDyjyuLDjK2CTjPwugi0brcqrRx1oDlmSYOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842754; c=relaxed/simple; bh=j12ia4XX8VMgrIj/I5g+9bpm+MP/MwxyhKQrMLIFPoA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ji9qwBnDnRvsTFpI1GOLDMsNPlXTaaAl0nK6RUP6SvXEt/BbtuKhbLLQ3Pl+W2+li+opCwMTg3BL1xJOlS/+Wr8wXmjpJcOTvBMszqdtcgcsqTBlCmJc4Sh4v8v08NUfwqMHr9yHu+oxPO5+4OdFFz7ntaD4oekbuQ+qzEerHdU= 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=CfH/GND/; 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="CfH/GND/" Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 5BB68120078; Thu, 11 Apr 2024 16:39:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 5BB68120078 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842750; bh=NCOKTVg0nWMYZZiioHHnALckHQGoR5CtX9QXQdy+RvQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=CfH/GND/Nr7HpasJyS10pE6S+mPqsCpPA8/req6wvuPp9qN/ZdBb6gXcSarwhw2Q0 fj8/H+KgkBin6CFQiatgBiF/BinNNdoILJwoi0oCxsQsk72LCnmkhKHtMp9TY/H3d2 xiY19qBZkdPiCAjCA+oHY6YbF9Me6vBlzWoi5WUruFvqbULVvaCAB9Ktwgi4MNJd+Z JFbFJgAaqjREXIn89DDjuSVHdODwEg1hbclLfI8ghNOVva4hUOz9vluYPMtkUnqSXT bR1QsJfD+yIn01hiyDQYwM5x9PRfrS7J7iqp0bogr8dvpONEVmIR4y9E10h0Yvhsq8 TvbxbKaOz8hfg== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:39:09 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:39:09 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 14/23] drivers: crypto: meson: add support for G12-series Date: Thu, 11 Apr 2024 16:38:23 +0300 Message-ID: <20240411133832.2896463-15-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, salutedevices.com:7.1.1; 127.0.0.199:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 100.64.160.123:7.1.2; smtp.sberdevices.ru:5.0.1,7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped Tested via tcrypt module and with custom tests. Signed-off-by: Alexey Romanov --- drivers/crypto/amlogic/amlogic-gxl-core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c index 4acacd925a21..928751a6fc31 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -286,11 +286,24 @@ static const struct meson_pdata meson_gxl_pdata = { .support_192bit_key = true, }; +static const struct meson_pdata meson_g12a_pdata = { + .descs_reg = 0x0, + .status_reg = 0x8, + .setup_desc_cnt = 1, + .hasher_supported = true, + .reverse_keyiv = true, + .support_192bit_key = false, +}; + static const struct of_device_id meson_crypto_of_match_table[] = { { .compatible = "amlogic,gxl-crypto", .data = &meson_gxl_pdata, }, + { + .compatible = "amlogic,g12a-crypto", + .data = &meson_g12a_pdata, + }, {}, }; MODULE_DEVICE_TABLE(of, meson_crypto_of_match_table); From patchwork Thu Apr 11 13:38:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788045 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) (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 4C260153571; Thu, 11 Apr 2024 13:39:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.18.73.165 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842754; cv=none; b=m2Nqg9xhTOTbqMUtrPHF5B2FVY/Lc3ChlK0nfVYbm9IkBKWnakun5E0AckF/gsp26Ut+IP9GeVhJe6SfKB3YRZ2fLONRlL7JQKrVZVkQMNYmpwmuqwAnfg0CmTTI1LTtswAPF+4XVx8J+qIZsbmRc7Je13icEOPn+tX/PYCnv6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842754; c=relaxed/simple; bh=uNX8s62PbprtUTXwxPSHV8sKfMZeM/btiSjxQHaknFQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=U5HZTofGJpj2NBT9zauf0+VEM7sKxLtBJylZHtB2PsiNuIS+UvMEo32Ib7GMucdp6EFb3j4RtSu6Ffwp3ffS+FcCeobK0WeAFES063G6g2gB9S3/Xtzaj8Lrn/dS+X6o+nx/6OC6MvLBhxyBd8dBN+2GsxQ1ocYrDm5GJu80WSs= 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=FOnM3Y62; arc=none smtp.client-ip=37.18.73.165 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="FOnM3Y62" Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id B2A4E100042; Thu, 11 Apr 2024 16:39:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru B2A4E100042 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842750; bh=Rh3JfsszeFzuirlBwoJubdS+Ixn9+e7gJuttUmBiLyg=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=FOnM3Y62Ab18scHykZvK8t8Q3uiMnweOqUCvg74kZeGFTLWqvyDm+fUoTRh3o38Fy PRiJMEcVUhAWoLJhu8q7aCsx96RZFzdeom0KW4xpaMhY2Pfk8CW57xfkJeYTe84sFi yPK7FG0BByVFPqedecvNgBOT4ZjHOhtOXcYy3kqyA3GBaxAlH9mFF/Yw0pKEcgnPqo 4IMt8U9XmnRS8R17eZL0C4tkHe0L3o3jJwANSJtCV3Ex2GzSETb1qXtX/du11oBdyF JGDhoewQHtlaI1OuCvr2weo4O/fBBbvuSpdRBYN2QLixZEqcPRe58Zs2D6FJstb6Nn CHuGe1wFWRJ8Q== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:39:10 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:39:10 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 15/23] drivers: crypto: meson: add support for AXG-series Date: Thu, 11 Apr 2024 16:38:24 +0300 Message-ID: <20240411133832.2896463-16-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 100.64.160.123:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 127.0.0.199:7.1.2; salutedevices.com:7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped Tested via tcrypt module and with custom tests. Signed-off-by: Alexey Romanov --- drivers/crypto/amlogic/amlogic-gxl-core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c index 928751a6fc31..4275f467d1c6 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -295,6 +295,15 @@ static const struct meson_pdata meson_g12a_pdata = { .support_192bit_key = false, }; +static const struct meson_pdata meson_axg_pdata = { + .descs_reg = 0x0, + .status_reg = 0x8, + .setup_desc_cnt = 3, + .hasher_supported = true, + .reverse_keyiv = true, + .support_192bit_key = true, +}; + static const struct of_device_id meson_crypto_of_match_table[] = { { .compatible = "amlogic,gxl-crypto", @@ -304,6 +313,10 @@ static const struct of_device_id meson_crypto_of_match_table[] = { .compatible = "amlogic,g12a-crypto", .data = &meson_g12a_pdata, }, + { + .compatible = "amlogic,axg-crypto", + .data = &meson_axg_pdata, + }, {}, }; MODULE_DEVICE_TABLE(of, meson_crypto_of_match_table); From patchwork Thu Apr 11 13:38:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788625 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 2C206153828; Thu, 11 Apr 2024 13:39:12 +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=1712842755; cv=none; b=UzTujJ3bFK1uJuRJOSQQ+KbuSe5OateYvHZl8MeWHAravxbROFvV4NHkD0A66ZGqB3qV/dZS4XHImYdm1cR4F/rsuY5IMm6H9MxKZaPS6ogFQvixR1ZRGiHKhdmhlClV4mAfydbhTNknjtSWk/+mUtIslcAzJrqwz/pWtJYyjQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842755; c=relaxed/simple; bh=PtOIrOIx5hjcB+Q7wPe9wVjS9biaNysocDsQ1q6F+uc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TC+Da5mKLJQ/HER4O/3L/jDRd6bH5rtahIK+Gxb+hEHsoXbILXITmiXO/nKQ5HRdIAIOqDKVNiNoH5x34l/6nLROt2NPXQtoE4q/4rx3ghFZVsS7IH9yxd299zLS4gS5VeouRIl9bIxCxC2w/kW6ing51ehcI+aCymh37DFeZhc= 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=FZZPJsCo; 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="FZZPJsCo" Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 79A3512007B; Thu, 11 Apr 2024 16:39:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 79A3512007B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842751; bh=iBwlgGHbj3XicCkmDtCtqP7003eXdu/OMJAEfVLMc44=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=FZZPJsCoGwcIkkKq8kY7EnopPUe7QWi4E7JyW/+s819/vhdIMDq8b9N2GkKDlXYuz xjzsH3oDB4DRPGrL0xjJo7hyfDaPZeFTEzZR4bR6bukkTOHsZhoJeDxg0TrZ0YlKf1 PqPSaM7nfVxYhbmpH/6gATJJvOB/TWyHtYvGWVYP3xFsNJ9/2UfwmvkZd+00SqqrbP iCwB17MBQbjBeSWXj1IdbuOXOH7twQX5G8VhBsdghteirPR3lO5ByGbbkoQGPulx+y TWn78V1KqlbSVaonCX3baTE1nJW4NEs/XeXqYuPmSXrW9wWsGT9gVY+US8FX+SWPMC OsMAdd5Qufn2A== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:39:11 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:39:10 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 16/23] drivers: crypto: meson: add support for A1-series Date: Thu, 11 Apr 2024 16:38:25 +0300 Message-ID: <20240411133832.2896463-17-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, salutedevices.com:7.1.1; 127.0.0.199:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 100.64.160.123:7.1.2; smtp.sberdevices.ru:5.0.1,7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped This platform data also can be used for S4 as fallback. Tested via tcrypt module and with custom tests. Signed-off-by: Alexey Romanov --- drivers/crypto/amlogic/amlogic-gxl-core.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c index 4275f467d1c6..43cedc10294f 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -304,6 +304,15 @@ static const struct meson_pdata meson_axg_pdata = { .support_192bit_key = true, }; +static const struct meson_pdata meson_a1_pdata = { + .descs_reg = 0x0, + .status_reg = 0x8, + .setup_desc_cnt = 1, + .hasher_supported = true, + .reverse_keyiv = false, + .support_192bit_key = false, +}; + static const struct of_device_id meson_crypto_of_match_table[] = { { .compatible = "amlogic,gxl-crypto", @@ -317,6 +326,14 @@ static const struct of_device_id meson_crypto_of_match_table[] = { .compatible = "amlogic,axg-crypto", .data = &meson_axg_pdata, }, + { + .compatible = "amlogic,a1-crypto", + .data = &meson_a1_pdata, + }, + { + .compatible = "amlogic,s4-crypto", + .data = &meson_a1_pdata, + }, {}, }; MODULE_DEVICE_TABLE(of, meson_crypto_of_match_table); From patchwork Thu Apr 11 13:38:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788044 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) (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 3DCEB153BE5; Thu, 11 Apr 2024 13:39:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.18.73.165 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842756; cv=none; b=AlpY+mwDQmLQhCf+yghZi7rYGUppCTbfw2JbHwesLu4eNoGOVeNaE933kcFkdgSKhlp9/dIpw51GYobYFpYdYz1dPJJsbF4HaS4iWybsCX5xCoIFRQdauQWCxqN7cA51yRL42BnGVBkKog8yZkwFg/3GV+9irRhe8Eg2VnNXdx4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842756; c=relaxed/simple; bh=qcFvBBsgrWAF4ol83SNoCBZDUlZMgSblpx4Je85PAYI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rjEtrGSjDp920agm3yfn8QALcoQKgveO+fv9DRwkwgPUS6g/I/doYcOFnksxr/2H8lyTXopH7nhbZwJF9XbXYj1MI3wVpdBcI8EAJ5/XzjsrNGJ18sdhmjGrNGK7F05cE/u8RcVnr7gd/5QSOGtAx8MMTyLATCD7Su+6/enN/TQ= 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=QEKfvp+G; arc=none smtp.client-ip=37.18.73.165 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="QEKfvp+G" Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 62FD910007C; Thu, 11 Apr 2024 16:39:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 62FD910007C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842752; bh=SxNhHfDpwlA3LGHnXoBMJjg7min6JcpppRV/2vmmdxQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=QEKfvp+GPljBTkpGOLt7DyXFusip+AAQKKvTbS+KRSX4ndluwZacAp8MObhxETjgv FwmQ8Wu8aJni9lLobUaViIEbo04baBao5RonoHSy4a9TKf7A/MsmqvnABIMcu5YKF7 2eWtdB4s5lEVPvqE4VGC/qY5GaS8+r5TzSM9J7rwRBJ/ogaxdQi43UEAr0/ZGGlw9r 5KW4hTLbY2ecY2h+dsJ3yJc9tWoTKRz6sMnAvBFW8SpGDkUrxuOeHoefxA+8GRvtAj Mvr3ZoHTMRN6IwqhVquKmiSsJ6uOVE2Rfmu0fA78YPqN52OmWH63/lDxEQfjeSGNWh cQytGieoli4bg== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:39:12 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:39:11 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 17/23] dt-bindings: crypto: meson: remove clk and second interrupt line for GXL Date: Thu, 11 Apr 2024 16:38:26 +0300 Message-ID: <20240411133832.2896463-18-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 100.64.160.123:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 127.0.0.199:7.1.2; salutedevices.com:7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped GXL crypto IP isn't connected to clk and seconnd interrput line, so we must remove them from dt-bindings. Fixes: 7f7d115dfb51 ("dt-bindings: crypto: Add DT bindings documentation for amlogic-crypto") Signed-off-by: Alexey Romanov --- .../bindings/crypto/amlogic,gxl-crypto.yaml | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/Documentation/devicetree/bindings/crypto/amlogic,gxl-crypto.yaml b/Documentation/devicetree/bindings/crypto/amlogic,gxl-crypto.yaml index 948e11ebe4ee..d3af7b4d5f39 100644 --- a/Documentation/devicetree/bindings/crypto/amlogic,gxl-crypto.yaml +++ b/Documentation/devicetree/bindings/crypto/amlogic,gxl-crypto.yaml @@ -20,20 +20,11 @@ properties: interrupts: items: - description: Interrupt for flow 0 - - description: Interrupt for flow 1 - - clocks: - maxItems: 1 - - clock-names: - const: blkmv required: - compatible - reg - interrupts - - clocks - - clock-names additionalProperties: false @@ -46,7 +37,5 @@ examples: crypto: crypto-engine@c883e000 { compatible = "amlogic,gxl-crypto"; reg = <0xc883e000 0x36>; - interrupts = , ; - clocks = <&clkc CLKID_BLKMV>; - clock-names = "blkmv"; + interrupts = ; }; From patchwork Thu Apr 11 13:38:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788624 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 C6DAE154440; Thu, 11 Apr 2024 13:39:14 +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=1712842756; cv=none; b=bUsePWq7iCXD5lGqluP3vSjODUGvchUCZ8DT3ADz8uEAU2CxS1gPntHp0BhnkOjuNjGcyUvcPY9btkUOXs8iLFpH3OBYunHKqepqBapuOMZ52W7hZ94oZdR+PxbvvRzOg2uty13gNJaN2jbcto4x7FRJkkGzXrsEzuXHADQh1Xw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842756; c=relaxed/simple; bh=V8uG2V1CJ/m/GL52ipD3pItFJff8Bj7JVK2UXrrdiio=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Q+So92NfkPyi+RvoRLyF5ncU9sRNSGwvCRn4CeaaYdmnpOOLYBu4cvuD8aEP4e0g3wA08zbuugwz5Z0OKkI394RV/FKUz09bzqgZA5IfzIB8GWoGPeq+mo7hsUb1c3IhmHo6qSxFDuPlhtvDpyypxDs4OTQ4U8auxKGnfymjjM0= 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=u0o9s0ih; 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="u0o9s0ih" Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 1FB2812007A; Thu, 11 Apr 2024 16:39:13 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 1FB2812007A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842753; bh=YSpSbNnMl7asR+J51NiJ7BUDCmmrs7E5XrPbix7b+AE=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=u0o9s0ihuks/SoNbXMpJHBdt9xS+8MV4xQp6UB4s0yzaJUMHwTBi+uzcE4K0IDUpV Z9YjNz2fzl7cbttFA1Cwxz6b6Lh7RKLrtKc1/iVq2BqQEbo6pnt8wwI/blQvELptO5 VOvYceu5USXeIG5JkS4A4ZIzcLRM7s1XYeKRaLrs4b3/dyio58yFsF/ZnEx5tmDkmc TQJM3s6C+HBOdxVig2VFazf4ncCjiuAtWMQzEovLMubkBLhueiFVoToFD62MlIFzgp Ugx743TeaL6sfR8grfrc0CIuIsAGEYX3jj5v3xw0WWKn8rhFDEJvZNXmF1tuPve4gR 2r+yaRwOEkndg== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:39:12 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:39:12 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 18/23] arch: arm64: dts: meson: gxl: correct crypto node definition Date: Thu, 11 Apr 2024 16:38:27 +0300 Message-ID: <20240411133832.2896463-19-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, salutedevices.com:7.1.1; 127.0.0.199:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 100.64.160.123:7.1.2; smtp.sberdevices.ru:5.0.1,7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped GXL crypto IP isn't connected to clk and seconnd interrput line, so we must remove them from device tree. Fixes: c4a0457eb858 ("ARM64: dts: amlogic: adds crypto hardware node") Signed-off-by: Alexey Romanov --- arch/arm64/boot/dts/amlogic/meson-gxl.dtsi | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi index 17bcfa4702e1..731b0a11a8da 100644 --- a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi @@ -68,10 +68,7 @@ acodec: audio-controller@c8832000 { crypto: crypto@c883e000 { compatible = "amlogic,gxl-crypto"; reg = <0x0 0xc883e000 0x0 0x36>; - interrupts = , - ; - clocks = <&clkc CLKID_BLKMV>; - clock-names = "blkmv"; + interrupts = ; status = "okay"; }; }; From patchwork Thu Apr 11 13:38:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788043 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) (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 82A4915887C; Thu, 11 Apr 2024 13:39:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.18.73.165 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842757; cv=none; b=eNjS80tpaAq/V98S2cNrDhLbtVNm0ODy+wruopTLGUUvT7VB6+GgqK0ddHFNjrasrpS9iIOGFZZRSrtiS5jWdWVDb4mkk/ERZwal7J++D6rYNxpHLvkvhbjLX1Oj/E0u+Xq91vpnBuElWqydTFtw3Q904F/8pYwmYXB0F5eEBXk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842757; c=relaxed/simple; bh=fuWmae+ny7hDhb4myzpAdFrW2LPO4DIPQaEGv4K6uY0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IwjULrOGrmCQhDKcnbfMkWKBdU1S9vhmIj23AT6vSWCNsenwT+ejykAswnLZD39NhtHULP3dD+Q1IoY/qOKHg5OgYpnWoR1BZEq7Y0S2hr4Cz+vrlkVmPDG+wG1er44QVYem0tAuoAkYQosrtjDwgQU/6trMIYYyyEaJu1nzOfo= 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=iwtg82PZ; arc=none smtp.client-ip=37.18.73.165 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="iwtg82PZ" Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id D305710003E; Thu, 11 Apr 2024 16:39:13 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru D305710003E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842753; bh=Dhzi6StlM85b+jeNGJU/1RXZUXKsrml0JHwX7MzHPL8=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=iwtg82PZiOsV7nTiIh9qzwMvld8yqRZT7uNU5zzi51G9vN6yrm6/GSPBuAgi8QWoU KHd6KiJBMpqVhjeOACYJ0og2gRRvdoDSbLWhhiDyTmZTVyTyjwIengBzXTssdY1jbB gdICOIqoZwDHngcQq6oXVgBc9i6OP7ygR7u40L2pv2u7VqYmRgg4uPNjt3sqJKg/3t /YH/bc1NDw57Lo4W4ssLwRMoV0r7BUPEygfhgoe4Z2n5Iqfius1ZtUft5Axqejo1V+ VEUcXZbOPRlWUrmynZBkEKFGWe/4bfbSF9/zya96hOFQe6LnJK2J9oGHEbvXnZ0hzs BhNT4De/KgwrA== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:39:13 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:39:13 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 19/23] dt-bindings: crypto: meson: support new SoC's Date: Thu, 11 Apr 2024 16:38:28 +0300 Message-ID: <20240411133832.2896463-20-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 100.64.160.123:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 127.0.0.199:7.1.2; salutedevices.com:7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped Now crypto module available at G12A/G12B/S4/A1/SM1/AXG. 1. Add new compatibles: - amlogic,g12a-crypto - amlogic,axg-crypto - amlogic,a1-crypto - amlogic,s4-crypto (uses a1-crypto as fallback) 2. Add power-domains in schema, which is required only for A1. Signed-off-by: Alexey Romanov --- .../bindings/crypto/amlogic,gxl-crypto.yaml | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/crypto/amlogic,gxl-crypto.yaml b/Documentation/devicetree/bindings/crypto/amlogic,gxl-crypto.yaml index d3af7b4d5f39..23743701952a 100644 --- a/Documentation/devicetree/bindings/crypto/amlogic,gxl-crypto.yaml +++ b/Documentation/devicetree/bindings/crypto/amlogic,gxl-crypto.yaml @@ -11,8 +11,16 @@ maintainers: properties: compatible: - items: - - const: amlogic,gxl-crypto + oneOf: + - items: + - enum: + - amlogic,s4-crypto + - const: amlogic,a1-crypto + - enum: + - amlogic,gxl-crypto + - amlogic,axg-crypto + - amlogic,g12a-crypto + - amlogic,a1-crypto reg: maxItems: 1 @@ -21,11 +29,23 @@ properties: items: - description: Interrupt for flow 0 + power-domains: + maxItems: 1 + required: - compatible - reg - interrupts +allOf: + - if: + properties: + compatible: + const: amlogic,a1-crypto + then: + required: + - power-domains + additionalProperties: false examples: From patchwork Thu Apr 11 13:38:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788623 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 7171E159904; Thu, 11 Apr 2024 13:39:16 +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=1712842758; cv=none; b=kTKOFp73saQRoq7/h7TXkL3ZrHOrvBGhips93IarfikxXzgRRjgJyhOxiPkuZai6fsK3bJKwvM81RTnA/CWFlS+IMdqGzli/5BQuWmNuEa8HfU/nZFoTT9XjpxTuBO0158sE5+je4/nNZDEySQDBlU2/S+woJq3zaX/Qn3D2g0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842758; c=relaxed/simple; bh=58grLApUsqgfMeAt0DknmkZBIM00JKGeL7zVf6Oq3MQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IQWlWti4hNrjTOETTAeRQ3mQIQGG7591IIlQvqPUIiy8fjLHjDFkq7rfqWlBtQXsdFB6/4xfP+yFPWmOSfajHRsTwpH7iB097ch3gY+Ke+fed8iRQyH5aGqhXvvwh2b9RS9NKB1wdHqwCSnTs4vDtWt6lb2zPm3vsyoSzLNIbAM= 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=ZZOL8F+3; 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="ZZOL8F+3" Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id ADAA912006C; Thu, 11 Apr 2024 16:39:14 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru ADAA912006C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842754; bh=DKK2Z9jjmIQ9SsxU1MQIRpmgjJ49Oa07gnHv7o+Npus=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=ZZOL8F+3aWNnS5lwHkeTvFQbSzqY2+K/4AnFeNGl8beT4tzeOtqTcTmSwo6f1WBvi GdnW9seK7nOjAImHSSKZT+tZZhm87RIque/a81z3QD7bAGKe1FTEaMvTEaxD8BTooK PaYsgyrIhGh3z+eYidz6yOh8aPpRm6RlJ8jkSUaj+pi4ly1jaqTRVRxjRYtE9356bC p32bcEGBUzZoQIzSqV7GkwyhRD2R3cPWLMFPhAyQvrGFWiA4UJpCI4nB4xD9jPZerO tnduM95/+26Wx6LUh7FQugNANVWBRktboyJph1VL2nzOk0oqr+gdKWt89xeZ/kIHqO 7Jb/08aPGsI4w== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:39:14 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:39:14 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 20/23] arch: arm64: dts: meson: a1: add crypto node Date: Thu, 11 Apr 2024 16:38:29 +0300 Message-ID: <20240411133832.2896463-21-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, salutedevices.com:7.1.1; 127.0.0.199:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 100.64.160.123:7.1.2; smtp.sberdevices.ru:5.0.1,7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped This patch adds a crypto node declaration. With the Amlogic crypto driver we can use HW implementation of SHA1/224/256 and AES algo. Signed-off-by: Alexey Romanov --- arch/arm64/boot/dts/amlogic/meson-a1.dtsi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/boot/dts/amlogic/meson-a1.dtsi b/arch/arm64/boot/dts/amlogic/meson-a1.dtsi index c57c7c1cd5f8..97338856e881 100644 --- a/arch/arm64/boot/dts/amlogic/meson-a1.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-a1.dtsi @@ -978,6 +978,13 @@ sd_emmc: sd@10000 { status = "disabled"; }; + crypto: crypto@6000 { + compatible = "amlogic,a1-crypto"; + reg = <0x0 0x6000 0x0 0x48>; + interrupts = ; + power-domains = <&pwrc PWRC_DMA_ID>; + }; + acodec: audio-controller@4800 { compatible = "amlogic,t9015-a1"; reg = <0x0 0x4800 0x0 0x14>; From patchwork Thu Apr 11 13:38:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788042 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) (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 7905C15A4AE; Thu, 11 Apr 2024 13:39:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.18.73.165 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842759; cv=none; b=Bxf+d2HcX1XnnJqEUWxg7m8j1/zvuUH0G9pjjQyci/a+THh6ps6b7r7pFaXWQrCz5V4Er2wEA65xMZZ5Xg3pN1oeiv/WRMsacyeNLkOGnlvM0opUn/z6P/6RLh8D99y/JcJBM8WmFeKNbqz0/jrvT/0mf5WcQwnk0RJIypsjBUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842759; c=relaxed/simple; bh=Xr3h2y2FtEXnJDLD1B+gduPvyWStA/n7A9csFHExcGQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=k7BYEGMFJrHKGNY6txbC8oGZdZXL+T77VPKtCNVxcZWfxSD8pxqpCsEEQ9++kZIF5A3TQ5J7PUiGsVfJqHp3NLGmdHyFbUoCZeSzFxJ13RurOFiza+5qfQIaXnbSf30o/ghnCF+ownRl8LvVApeiDAgyvIrKJzyWZoijcAcsmyM= 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=FLPn7RFk; arc=none smtp.client-ip=37.18.73.165 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="FLPn7RFk" Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id CA8F8100081; Thu, 11 Apr 2024 16:39:15 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru CA8F8100081 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842755; bh=hhW0fsFXRNh2iou++b1KHrVo2xUFJv6U/V2MuqxBJ+Y=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=FLPn7RFkL7DJlYBHtjMbWIs3MQaQj801lHIen1ZbUEDa1JfltsuOXLGf4N4/xrHmz 9yIZ75cU2ZkBaAaz1bNtbuaUkWpPuRDmwRTqyCj033LWY8cWj0/y7KPlhvXlNf4uW3 XP3N2q+UIzGOw9spMFkFYEYjVO1ouRzIv22rvjO3TJauq5zJ/OZ+PImtJV35uZgzKA 1UVrvVDpYcHaE2mLF6/pQGcrx+36Dn+fM8QWxm3z9mGLQJXWcn+ZjPVeX0h9kh48/O hGjKqVcBdSkCePG7xXVEFaTZJ8/80NJ92LicPz+G4kVpS1Q/15nWPsNuvh4YFlfztN UUoLybM3+8R2Q== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:39:15 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:39:14 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 21/23] arch: arm64: dts: meson: s4: add crypto node Date: Thu, 11 Apr 2024 16:38:30 +0300 Message-ID: <20240411133832.2896463-22-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 100.64.160.123:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 127.0.0.199:7.1.2; salutedevices.com:7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped This patch adds a crypto node declaration for Amlogic S4-series. With the Amlogic crypto driver we can use HW implementation of SHA1/224/256 and AES algo. Signed-off-by: Alexey Romanov --- arch/arm64/boot/dts/amlogic/meson-s4.dtsi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/boot/dts/amlogic/meson-s4.dtsi b/arch/arm64/boot/dts/amlogic/meson-s4.dtsi index ce90b35686a2..11259d42bfaf 100644 --- a/arch/arm64/boot/dts/amlogic/meson-s4.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-s4.dtsi @@ -339,6 +339,12 @@ mux { }; + crypto: crypto@440400 { + compatible = "amlogic,s4-crypto", "amlogic,a1-crypto"; + reg = <0x0 0x440400 0x0 0x48>; + interrupts = ; + }; + gpio_intc: interrupt-controller@4080 { compatible = "amlogic,meson-s4-gpio-intc", "amlogic,meson-gpio-intc"; From patchwork Thu Apr 11 13:38:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788622 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 8A39A15AAD7; Thu, 11 Apr 2024 13:39:18 +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=1712842760; cv=none; b=QOKvlsSISYP9IXiBD+KvgmPDFZGJMYpkzScpyEJB/eipR3qnwyKDkokf6s7KtSUTatvKnccqSoWoXOOzCdsVw9bOhfpDvV2kdb+xP1Tykx1QwPT5YyQY4YZUayaCMMhlBK9GGTCbIda+dp0SUOLBVYoxn8ptbg/W8tBhUY7Btmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842760; c=relaxed/simple; bh=pJ2tZogkjA9MbHhc2l5DTPbiP1SL/3dZZerTR5/Yk4M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GxwG9nxrhlNQ5pb8e1osKS8IUv60e1MgPJRVJ5k+wMBOrUfM6mDCFtVCfdzwd89Wvws2UXyvKetovWil8OES26+la7BYJOf9ZKbmC28q63rpconYuRs9cgFAlofRNI/nKctzkpFhryDwmqZ3BCQK+rk1ai3AQwJ4IgFPf+LbR6U= 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=rZC+eIpo; 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="rZC+eIpo" Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id E7357120071; Thu, 11 Apr 2024 16:39:16 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru E7357120071 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842756; bh=jSoviVVK1iz1k7MYUkXJBqES1AQfJEvBUgn3xP97XnI=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=rZC+eIpoljhC9bAXkb0K0Tp1R248MEeRQmQFJsv1gfeQW8r1ui1Us+i9Iv4PV+VJk VxOEWaSh8lVi23MleLIZBmyYyLzC9RCpF/vOIn7zwyBRrGy9uqDMYfbMBpIYAWJ/+R dsuX0NsEcR5WLhrXJvjMpnvXRz7l04FxlijB9zzJXZKebb0gvhFGQDPcpUlNV3hGy6 kXLj4Lx/RulYv3TVA36w+loAHdzKrQlff9LRlBzs+iGUcB3REdXe5c0ggxZP5aV3SU 72zk78I4bHPGDJ39FVVvSMRQBRJ+/bc2mFhP65cyoVfJWGt54jo9A6XqFncn6Pxo4Z HKymsrLrXQqsQ== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:39:16 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:39:16 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 22/23] arch: arm64: dts: meson: g12: add crypto node Date: Thu, 11 Apr 2024 16:38:31 +0300 Message-ID: <20240411133832.2896463-23-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, salutedevices.com:7.1.1; 127.0.0.199:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 100.64.160.123:7.1.2; smtp.sberdevices.ru:5.0.1,7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped This patch adds a crypto node declaration for Amlogic G12-series. With the Amlogic crypto driver we can use HW implementation of SHA1/224/256 and AES algo. Signed-off-by: Alexey Romanov Reviewed-by: Neil Armstrong --- arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi index ff68b911b729..f6d7047a579c 100644 --- a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi @@ -1709,6 +1709,12 @@ internal_ephy: ethernet-phy@8 { }; }; }; + + crypto: crypto@3e000 { + compatible = "amlogic,g12a-crypto"; + reg = <0x0 0x3e000 0x0 0x48>; + interrupts = ; + }; }; aobus: bus@ff800000 { From patchwork Thu Apr 11 13:38:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Romanov X-Patchwork-Id: 788041 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) (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 8B5FC15B0FC; Thu, 11 Apr 2024 13:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.18.73.165 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842761; cv=none; b=gH/SEQTMtl6+PwsbBZ/2MUKraft5GnRowe1PD3JEj2kLEl2/1glywRu2JYesSHEe+rSeuGlXm1e3/Mdk6ZgAqrV//glxBfapwv5vSXJdXDOer20a/6vr+6nW0KSq//cD+Zc9gp3ceoWP94Prd5hLP9SrhTkpAIqJ1/iln5gE1yg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712842761; c=relaxed/simple; bh=ASKmb+SEBQEY4yNlx27rQ29qNcsZMWBy2L7Jl0+lRLI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gv+ofzKX0yD1iy5C5Efb9UhMImqWGPTWUV5pjsXZOEL1GpZb3xiuJPka5QqT07M/2BYCRKppIRj2sdeK7IRMbVGIhE7wFCqdJglabRkFNBbI3t738P/t3BUvJFtZvizlwvWlMfTv+PlryMeico3z/v7f2zW7oeN8CS5S8Nscsh4= 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=Al+XlUuV; arc=none smtp.client-ip=37.18.73.165 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="Al+XlUuV" Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id D500510007E; Thu, 11 Apr 2024 16:39:17 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru D500510007E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712842757; bh=A57FStZMZTG57y300fP+OYKnrsCuYIERChukcAKBT4Q=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=Al+XlUuV3SO/xImvsUUsqZPO2cZqbbmsQBZDlsDhyfyLzOs53mQFzXRZN04VwHjYz rAYRIpsO7Mn6ImgVtHsJRDWeX65h/dGJKtNADNaie3/pXWLR4HKdJ53PRGqKzlUf05 QbImjYJiUnYfu4bjtYjAX/wwLhqWFYOKTqpitl1QlvsF/wvaHDmW/8TJtGGr7Uzb2H d22BO5045GSaxH1KBzJd8GeLCC7Gybm/YcYQdrt9J+7msgp2M8VGxLBpSJGOh1y/oG O16z9/QGxr+0avVi1WYWtslfosgbNFnGvc+pg29XYAR6cETE7lNoQ7pgNfJEfXAJYI S5o6dr4T+tnMA== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 16:39:17 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 16:39:17 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v7 23/23] arch: arm64: dts: meson: axg: add crypto node Date: Thu, 11 Apr 2024 16:38:32 +0300 Message-ID: <20240411133832.2896463-24-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411133832.2896463-1-avromanov@salutedevices.com> References: <20240411133832.2896463-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184672 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; 100.64.160.123:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 127.0.0.199:7.1.2; salutedevices.com:7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 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/04/11 09:22:00 #24744908 X-KSMG-AntiVirus-Status: Clean, skipped This patch adds a crypto node declaration. With the Amlogic crypto driver we can use HW implementation of SHA1/224/256 and AES algo. Signed-off-by: Alexey Romanov Reviewed-by: Neil Armstrong --- arch/arm64/boot/dts/amlogic/meson-axg.dtsi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi index 6d12b760b90f..b19be72abdd6 100644 --- a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi @@ -294,6 +294,12 @@ ethmac: ethernet@ff3f0000 { status = "disabled"; }; + crypto: crypto@ff63e000 { + compatible = "amlogic,axg-crypto"; + reg = <0x0 0xff63e000 0x0 0x48>; + interrupts = ; + }; + pcie_phy: phy@ff644000 { compatible = "amlogic,axg-pcie-phy"; reg = <0x0 0xff644000 0x0 0x1c>;