Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1219759rdd; Wed, 10 Jan 2024 12:22:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IE2+JFNsGXMcU7kfBqTz49cAsSAf61bbso166ye+KM+s6bn+TPDH0fXPZcmoI6/5whSAkb/ X-Received: by 2002:a05:6402:36f:b0:553:671f:5caf with SMTP id s15-20020a056402036f00b00553671f5cafmr34905edw.16.1704918141835; Wed, 10 Jan 2024 12:22:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704918141; cv=none; d=google.com; s=arc-20160816; b=FjmJfKkpNnhQtRumw9PaWIsi63c9NJzAFkYAiI7SDS0fJtrkyHOMvKpf4KfPooCXWC S+qxWS0Gxx/14GGJq5PHjc/e9oqpR2pUUWYRJNHtq3yKN3ic20np8bZsL9MdrADwY36/ kHop3+OIiOdhgnqsuTHSdf1k1b7BrA5IxOPT3tGhJroeeL0wT8PB9ex//9Ypq5yVxLxa 27lLHhz38FIDyCkAE/cvoLvrRNL1cgd4btBfxiJfnDaYmiA2D++1U5m+vHFsz0lmAS4L ox2nN8MbviHRaq7NZnxZjHZxn/S8QIQ0Lyxa+wM7BjIEk8n99XxuJeXYLnLxpWo2vjQ8 +6yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-filter; bh=1he/c2G0yVN+BRzRmBqXeVPHKserzYkABpzO0rRQ7Gs=; fh=xqZfsPOLLQ1RF7LkBXx/kRFfEkVi9B7ONxo86th2grk=; b=IETYx/GHUEaGB1ArYw9gKdkOw73wocBiy9eN/ppDn2TjL/bF1x1GgIZgjiFI//xUet DG8z0rnNbH35RzakI8qNOPzhCkFiqv7iWPwxulKkHQIBrW4hKstk8EuaJC6DESyiAHDo 1oS7IkjPwNVw8cvXQboFPhnn+XpuPApMpwXgFaTCwowopEoT2b1Aev3uKsybxBL0TNQZ Ro3WcTUWGeqbim0yWi5BSmMMUZHExaDSSdscvQIN1dG+v3jqdN6iankpoSijIt8/AQwM 0/X0D1o8biBelOZaVYrXU/qkUKg3aPhJutpd86/iqO7VPRZeBTZ7RxCzCzM/LKaNvixH 7QNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=ETK2hyk9; spf=pass (google.com: domain of linux-crypto+bounces-1362-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1362-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f1-20020a50d541000000b005533fa17a45si1962205edj.526.2024.01.10.12.22.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 12:22:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-1362-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=ETK2hyk9; spf=pass (google.com: domain of linux-crypto+bounces-1362-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1362-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 95F6B1F26E72 for ; Wed, 10 Jan 2024 20:21:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C20B4F5EA; Wed, 10 Jan 2024 20:20:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b="ETK2hyk9" X-Original-To: linux-crypto@vger.kernel.org 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 527B24E1C8; Wed, 10 Jan 2024 20:19:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=salutedevices.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=salutedevices.com Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 9A47B12001A; Wed, 10 Jan 2024 23:12:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 9A47B12001A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1704917548; bh=1he/c2G0yVN+BRzRmBqXeVPHKserzYkABpzO0rRQ7Gs=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=ETK2hyk9o1f7Ds1MCi9GXH0o4P+SvujhxiZbe5S1yuU3m079zSGsOOuk/oN9xmpQG MT/nyFB0NcibRq3p4jDVkGsJnDS7BwuaSufTQfI3THJ3t/dvrnR1BTANV2A861hfCR bghO1vAmIiQE7DE80Q2o89iVmfxs2yQQjuLA+V/qfFXPD4U58XTMsH8mwPcbObXQH6 X0zY0BlvbFCFeMiTucxMXTCLSg9qMCoCjIQ/HvoOvmjMT2H681QHjCm8wN9mQ2Pk4R j/jItqV3+7YD/eL7I53bNHhpb0br1yWKc1O4juaeacT9iHnqzJo6pXWsT3gWV0RyZG aPedMz7OSRoQA== Received: from smtp.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Wed, 10 Jan 2024 23:12:28 +0300 (MSK) Received: from localhost.localdomain (100.64.160.123) by p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Wed, 10 Jan 2024 23:12:27 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov , Jan Dakinevich Subject: [PATCH v1 04/24] drivers: crypto: meson: add MMIO helpers Date: Wed, 10 Jan 2024 23:11:20 +0300 Message-ID: <20240110201216.18016-5-avromanov@salutedevices.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240110201216.18016-1-avromanov@salutedevices.com> References: <20240110201216.18016-1-avromanov@salutedevices.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 182544 [Jan 10 2024] X-KSMG-AntiSpam-Version: 6.1.0.3 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: 7 0.3.7 6d6bf5bd8eea7373134f756a2fd73e9456bb7d1a, {Tracking_from_domain_doesnt_match_to}, 100.64.160.123:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;salutedevices.com:7.1.1;127.0.0.199: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/01/10 17:01:00 #23071477 X-KSMG-AntiVirus-Status: Clean, skipped Add MMIO access helpers: meson_dma_start() and meson_dma_ready(). Signed-off-by: Alexey Romanov Signed-off-by: Jan Dakinevich --- 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 58de925caae7..7ea88a9f78a5 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 a83c00922b48..78b70c17862d 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -20,18 +20,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 c8ba726ccc8b..80b7a2492168 100644 --- a/drivers/crypto/amlogic/amlogic-gxl.h +++ b/drivers/crypto/amlogic/amlogic-gxl.h @@ -163,6 +163,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, -- 2.30.1