Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2462650rdb; Mon, 12 Feb 2024 05:57:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXAk0M29J9ULs5a8cROY1MTYMmJUxy3A//OvWmp2ESasEsFnrRQzwvOS1DSp1nlt4+OS1S3sD8U0SBV6cjXkfMjswtnH37vvu/7q8WyJA== X-Google-Smtp-Source: AGHT+IHkFQNFNJ/YoA3oFoFYJnpi7C2PG9y3uLB1u/fw3BNylx68VKBFRooLowDd9PV3cQGAkE0l X-Received: by 2002:a05:620a:170d:b0:785:d77f:796f with SMTP id az13-20020a05620a170d00b00785d77f796fmr3049708qkb.76.1707746261917; Mon, 12 Feb 2024 05:57:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707746261; cv=pass; d=google.com; s=arc-20160816; b=RZbJnD4LKVQocEYDpXdA/O+9KS7aRw5QdXDL6z1WZw7rVV3Asqe6Lj+KCmxupLKfB8 dJg8Pj5U3skklRthWsIDqffIg37uGDU/WfpsS3SzDdSk6345rtLaIBFjdfdexuFTmZBT Wnig1etNztMaBjFmS3sAxDvIWqhwUVzg+/pf7mwZ9o14XaHjJA6/cobzPqdfuaRibzR9 FH5UYLQR43hA4N/byB5aCW20ExJ7XxqHomwHI6GE9u4D9CDMp2My1bkZU1PB2yTc2BD0 xPHhJGJwcshZ4ET69iztkhssviDiCxyGWTj0RFNiBvJUhX/ExGGPmxLB1mXY9Z6alb+m KtDw== 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=HZKXOUHwXi/WEeBn0gsslzGQgCLVYv/KpYJnzTxg//0=; fh=176Cx+doFJ+Fuzmv/ycqVawEVyGvnW8dvUk/a7FhJ3Q=; b=iaho+OvOgIktHxCKZPAQ1vx4tHPCt7G4s8lbqS6gYgMv4ftLNIDmjTVDqeZCUOHwd1 bFSrYtSia54CmoYEh1KXSwYnKb4xj2NFBpjtRBG3VoB3y7ETy9DTJEZMZlOH8GqWGiYa PvpLxR+QcVBLkhGbgU96MnnP+XxVXxmNgf5OA0Smk/EMHqEWnnzS95G3OdUvr8HNVnyZ vSh9PR3upw/pCfN+Fw3GDoQ9AUH9qGWFct54gVBSa61p9mudXSz6xlvoKnaul2sJoX8S SzHe1W9lUzHzfr4xegj/xH+xQ7EuAXh0ogWveu0LlbQX9UgHpDdcYcXxGpenRmSA+tsh zS0w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=SoDRbSlw; 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-1966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1966-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com X-Forwarded-Encrypted: i=2; AJvYcCV1e0zgYUZLgs6Y0TLbfN+TSg9C4yF9K9Rf6WlwnGQT5EON3EfJ3sDSKqmkYeV0S2n+qNbJuE8AiLA/v0/n72LWCJaqZH9v1X7Lehj0TA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id m15-20020ae9e70f000000b007858b826b92si5629582qka.703.2024.02.12.05.57.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:57:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-1966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=SoDRbSlw; 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-1966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1966-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9C10F1C23663 for ; Mon, 12 Feb 2024 13:57:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B8A783B797; Mon, 12 Feb 2024 13:51:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b="SoDRbSlw" X-Original-To: linux-crypto@vger.kernel.org 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 E3C6F3A8ED; Mon, 12 Feb 2024 13:51:33 +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=1707745896; cv=none; b=g7ZH9bSwNK4JzjV1kAvWzAyok8FfTkmXeQ51KRA/3fvhnbgD/TqPu9thENLKePOznKeO7aYb/KskIodj/qHicTo8BjVw9z3zTqb89qm57W6dZ/P/oWsMJFBlk1ApRlluAx3DTa4sb7PnfVEoGFPv4qk2I0CimUF/JoLkyW3xUbc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707745896; c=relaxed/simple; bh=5zI8UN7fhVfdhAEgudSO3uFgTiJ7UGsZc/1lO+6mb3k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ItpUIkf6nAKIp8PusfI7kZYIqdokx/NfixMNKKuwrylb8mhYmk+dUtfp6BO8Ekb058zc/IkLN5Pw2fI6oCnOVSy+VN9YxB5JalYG1OhnTT6zAa3n0zu5e0HJZPvTvFK2ckpcAc3mGsgnBibAJNdJZ1Pnk/DNVPMG1mv9nRYDNiU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=SoDRbSlw; arc=none smtp.client-ip=37.18.73.165 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-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 1C7F7100018; Mon, 12 Feb 2024 16:51:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 1C7F7100018 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1707745892; bh=HZKXOUHwXi/WEeBn0gsslzGQgCLVYv/KpYJnzTxg//0=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=SoDRbSlwQ9aGa04RSbhxp7e6cBbZPnDETdkz7gKoFypJicr6OXwnxFATveF7lcWL4 tF5DU2YksgZKvsc7zaDDqwxlI+nZLmLaDXFcdYq9209+MRbKPJkQYY7YMSrTunBgRk r7OFtmRl8o0tv3REC2bOUqxzwwyMe5W1plfssln3GdtV6cwLgHKfVidcH7oNuA8oYF mXKNmmm5Y/8jNDkDAYHlwU9q+18NKsdKIiIz08i9lXoOmRIKE9Ao8VUSElcm2CMw3y mzbIQnXkiWCNkaOPCsVt12s94Z389urssJUWRuRZSTc7jcCn41YDgMt+F4IuLrugke xKzsc9QE6KUjQ== 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; Mon, 12 Feb 2024 16:51:31 +0300 (MSK) Received: from user-A520M-DS3H.sberdevices.ru (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; Mon, 12 Feb 2024 16:51:31 +0300 From: Alexey Romanov To: , , , , , , , , , , CC: , , , , , , Alexey Romanov Subject: [PATCH v4 04/20] drivers: crypto: meson: add MMIO helpers Date: Mon, 12 Feb 2024 16:50:52 +0300 Message-ID: <20240212135108.549755-5-avromanov@salutedevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240212135108.549755-1-avromanov@salutedevices.com> References: <20240212135108.549755-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-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 183368 [Feb 12 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;smtp.sberdevices.ru:7.1.1,5.0.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;salutedevices.com:7.1.1;127.0.0.199: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/02/12 07:49:00 #23556813 X-KSMG-AntiVirus-Status: Clean, skipped Add MMIO access helpers: meson_dma_start() and meson_dma_ready(). Signed-off-by: Alexey Romanov --- 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 54113c524ec5..372c30f72072 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -23,18 +23,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 a36b9bac63a0..59fc6a67e0a9 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.34.1