Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp402967lqg; Thu, 11 Apr 2024 06:40:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWChHZyf+/sRib8ewtmGEeV2rMoSPDgQ1Gp/2kDvO20n8+k9wunXgNt47QAYD8NnEhYvORHlo1XC89iKmpITDLUuL9LIkk/ihJPCpfufA== X-Google-Smtp-Source: AGHT+IGUO+CtLo19PPego+WV25bASIkg/RVYLKxPjq63hg1W3TANBC3+2DMf37+Y3QZEqjO/D/UF X-Received: by 2002:a05:6359:1583:b0:17e:9c8c:2c00 with SMTP id jv3-20020a056359158300b0017e9c8c2c00mr8145947rwb.10.1712842810454; Thu, 11 Apr 2024 06:40:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712842810; cv=pass; d=google.com; s=arc-20160816; b=rbRpeK31/Hvc4jBhebJvX8aGifLisyXnivn9v3uHAK8mY8JsINDu8kxuXGXawH7gZG R6Thqf6e32ApntOfDRh2pCiZ6YmF4iJzu9bF0zXE+gCyHyDuETX0kj3/rH8fwbtS7fK0 HSVX9BaG0+OIv8a8OTUVVzsxxyzFAYNQLf2Phti3EDdT5AJU4OnZ/SvX58vi/LtbSgIN lcSCEDTccdyLwqarxTUqo+WKWDlqwq0VJXoXLM4Ta8HWw3rK2ksOb9Hx5xrRMmcVhBec CI0DloxpLZjy1IQK9nMKZYHg2pLT4EJsTsutonbmfLtVxVDo5yVtMti67CyH74LW2HUO MKUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-filter; bh=NhKK43BFs9WSPEu12TubmDHMMoMRfMTyJ3HOlIxykU8=; fh=7+QqR+U+m0B5ryyywou1kgMZVOfT/GgVHz0ZH2Lvlxg=; b=At/fHHQyWLVSrejk+yA9jSZUmIfOOxg8Mpk9qug3867TLiLURjhdRRGsuP2m4W73Wn OekW/rwEEEY6Iz30yosjclu3/WlA2P0ycQ2haxakYbLSMgoupFJAVtNb0GSMgkcaFsmI SzKl/wIjPITA9zze4OsHKeWkSMLqqMmHiGzqTEjilnRly5R6NIBMtrOwEIaOr++0GhiI /vaEp/D/s/sXNBf0Kr8WSm/v138UNvOL6eJ0nb8+bb+E6SodDlhOh1MdrNF9afn7NUZX SXn+5LbQtuScyK0VpZpqrItr94aIjvuhUIqhfWADfnk01rnrsCKidMpaQWnvDzQtcSW6 vMCg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=iiZR7l8H; arc=pass (i=1 spf=pass spfdomain=salutedevices.com dkim=pass dkdomain=salutedevices.com dmarc=pass fromdomain=salutedevices.com); spf=pass (google.com: domain of linux-crypto+bounces-3457-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3457-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=salutedevices.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w24-20020a634758000000b005e45abbc54asi1286006pgk.186.2024.04.11.06.40.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 06:40:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3457-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=iiZR7l8H; arc=pass (i=1 spf=pass spfdomain=salutedevices.com dkim=pass dkdomain=salutedevices.com dmarc=pass fromdomain=salutedevices.com); spf=pass (google.com: domain of linux-crypto+bounces-3457-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3457-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id AF623286F4E for ; Thu, 11 Apr 2024 13:39:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F77D14F9F3; Thu, 11 Apr 2024 13:39:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b="iiZR7l8H" 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 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 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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, -- 2.34.1