From patchwork Tue Sep 2 13:21:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1103 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5159A2FE599 for ; Tue, 2 Sep 2025 13:22:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819380; cv=none; b=psZAI4mrCQIF3Edd7QHR78uN/Wl4sHbr6H+ziXCCVQi/F+4l5h2izr6HVnpD4RFBDXv4UJWghWO6/h4vR6YLl8e6D5njb6fcrQHIZTpO1aDc1rYHRF2QEkwUV3ndeq6fitZhqOzCXL14t4YsojTlKUeaC66kdkfzr8ibQT3zwHE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819380; c=relaxed/simple; bh=JhryCQPIHZMBHN4Dh3iGOODDbabwR0S+i4gukSM6ud0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ne9DJ1Ag70ySHgfFxDxjuNd/XEREzuZ9yZiuwrGlGzsXHCujpDQh2FOqfMhv63X8P1RA3lJUmkDBjPoHbaasizFWbGenMmQHCsVP+y9xAf1SWqHv9hN6px/tSk+EMYKan1qd8bawwJale3J6qsjGMjNbhHHSIkU9M007cdjIF4A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lUkX5uIh; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lUkX5uIh" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-45b84367affso28831675e9.3 for ; Tue, 02 Sep 2025 06:22:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756819377; x=1757424177; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yzXOYoDcw0s4gQ4w74V4qvU2nwkX5U7En2+CKV1FmvU=; b=lUkX5uIhD9OcPKGU4lHp+MgNaLR9wUMMQWXCCPTXyV3uHO9QORNOe0+L3KmWkS9hjs KvaztgiNxvM9nDPbuNAeYJrce7bzHkrQY7zCanyVmIOIa273dLV+d96UnBDfgsPesVg/ VfXNCDQP2nGEo4ZfJoBDIoXcvdnsCHwTFnDR8adiow/+Om5ZAX0D96IEE2XXp7wVOA8y jZvsBTxZtWhhcv/C4iDd/QMAbrHTJbwa7ztWyBpxyYkGNmIRzoj1kMvKmiSqvl9FeXXv 9qyuRRIFcwKcHNuvNDqoIUk3Mjtryf/GUY3bybXq9Yfx5bIB/GX8T0uu/BmsOklsKaOe CRjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756819377; x=1757424177; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yzXOYoDcw0s4gQ4w74V4qvU2nwkX5U7En2+CKV1FmvU=; b=OmpRPuZypOhNWx3eb4ODLqNfp4c9iE581oxWGF13nhioeOkvWtYLekd/Y/QMgrE+JG E9k9SDqXKAWv7VGaiw2LYGrfb03pnkXq++KwMYFlokIJ1Af/KQadz+zWE6xHozC70vnF 3zvuO51uY6TmNnNmY7yiwaDwdcQNzLfDvQ8zQrd7PbEauGjox4lD/GIcP+BdQaADWMd1 c1sWBC5pFRfepEL6inLlbOcdJMrzakWt/2cAgAe1E4hX3bnNgW+V+rJAonDuY7lukm7/ q8jByLtKyURfKioq/w4Ahr5JBjWXX1v8na8wc9GNUrKwA0xwCjj8SQplPw16sea7cLGz 3r4Q== X-Forwarded-Encrypted: i=1; AJvYcCVL6yFMmHw3u7LOd8OUc0MbR4hMwbLQQt2KGArM/uKUF8pf+qdCfRzHDVXInstw/OS41pA1g2K0c1H5HA==@lists.linux.dev X-Gm-Message-State: AOJu0YzWHcN3b1m7OfCsUBxWcRAKW78GzudLzY2NvD/BEvWJDX7ox0LN Mnq5EAyttrKytK6v+gjpUYulgZM+OZphlxxqtpvB9F/MsiNisJmAt8xE X-Gm-Gg: ASbGncuI2hfUnlll0D+513Kh0Q1hV8QjFTvSEHIzRzDsbfOi6iIAxbHqKVfZLZmAzuK a+bNTsmNuXNMEMKPggdyuVK0fqP+WS4ZneSx7HsH48SSi9WEwdrI5jXG4R9bG3j1TYtAra2I6+e JvTLN9duGVzYtkHzxT0YYuQMMjHgSXNQKczqSVHjDBXBwOPJkVnwstFfb37R9iBus8sIDnNvX3Q 3+0MqE5uGnvKW+nE+0hMjj4vsrFMYFA4bU2jFEgn62+E2UTsGP1qG2is4oLqr8Dn/27jNKYJMos NdxNcEt5tah/ZhtmQAX+tStwmld2g72NJ05raEqwiB4573M1E9Gk+bNHajw8Z40NqxKyMuan0GG 31pbNbgfU50TWxbj2U5ImN5XdkZMbaoCDtA== X-Google-Smtp-Source: AGHT+IFt+jAuwZmgoKT1RiQF+kj0FR8UU7YL3V14hPMpMmBPvbwYtZIzf4vHPonAarMjK9TcaNg3/A== X-Received: by 2002:a05:600c:3b28:b0:459:d46a:ee3d with SMTP id 5b1f17b1804b1-45b872e711emr80758545e9.2.1756819376326; Tue, 02 Sep 2025 06:22:56 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:c207:b600:978:f6fa:583e:b091]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b945332adsm44452155e9.4.2025.09.02.06.22.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Sep 2025 06:22:55 -0700 (PDT) From: Ovidiu Panait To: clabbe.montjoie@gmail.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org Cc: wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Ovidiu Panait Subject: [PATCH v3 1/9] crypto: sun8i-ce - remove channel timeout field Date: Tue, 2 Sep 2025 16:21:26 +0300 Message-ID: <20250902132134.3287515-2-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> References: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Status: O Using the number of bytes in the request as DMA timeout is really inconsistent, as large requests could possibly set a timeout of hundreds of seconds. Remove the per-channel timeout field and use a single, static DMA timeout of 3 seconds for all requests. Signed-off-by: Ovidiu Panait Tested-by: Corentin LABBE Reviewed-by: Corentin LABBE --- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c | 1 - drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 5 ++--- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 2 -- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c | 1 - drivers/crypto/allwinner/sun8i-ce/sun8i-ce-trng.c | 1 - drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h | 2 +- 6 files changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c index 5663df49dd81..113a1100f2ae 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -276,7 +276,6 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req goto theend_sgs; } - chan->timeout = areq->cryptlen; rctx->nr_sgs = ns; rctx->nr_sgd = nd; return 0; diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c index 658f520cee0c..79ec172e5c99 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c @@ -210,11 +210,10 @@ int sun8i_ce_run_task(struct sun8i_ce_dev *ce, int flow, const char *name) mutex_unlock(&ce->mlock); wait_for_completion_interruptible_timeout(&ce->chanlist[flow].complete, - msecs_to_jiffies(ce->chanlist[flow].timeout)); + msecs_to_jiffies(CE_DMA_TIMEOUT_MS)); if (ce->chanlist[flow].status == 0) { - dev_err(ce->dev, "DMA timeout for %s (tm=%d) on flow %d\n", name, - ce->chanlist[flow].timeout, flow); + dev_err(ce->dev, "DMA timeout for %s on flow %d\n", name, flow); err = -EFAULT; } /* No need to lock for this read, the channel is locked so diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c index 13bdfb8a2c62..b26f5427c1e0 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c @@ -446,8 +446,6 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) else cet->t_dlen = cpu_to_le32(areq->nbytes / 4 + j); - chan->timeout = areq->nbytes; - err = sun8i_ce_run_task(ce, flow, crypto_ahash_alg_name(tfm)); dma_unmap_single(ce->dev, addr_pad, j * 4, DMA_TO_DEVICE); diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c index 762459867b6c..d0a1ac66738b 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c @@ -137,7 +137,6 @@ int sun8i_ce_prng_generate(struct crypto_rng *tfm, const u8 *src, cet->t_dst[0].addr = desc_addr_val_le32(ce, dma_dst); cet->t_dst[0].len = cpu_to_le32(todo / 4); - ce->chanlist[flow].timeout = 2000; err = sun8i_ce_run_task(ce, 3, "PRNG"); mutex_unlock(&ce->rnglock); diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-trng.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-trng.c index e1e8bc15202e..244529bf0616 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-trng.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-trng.c @@ -79,7 +79,6 @@ static int sun8i_ce_trng_read(struct hwrng *rng, void *data, size_t max, bool wa cet->t_dst[0].addr = desc_addr_val_le32(ce, dma_dst); cet->t_dst[0].len = cpu_to_le32(todo / 4); - ce->chanlist[flow].timeout = todo; err = sun8i_ce_run_task(ce, 3, "TRNG"); mutex_unlock(&ce->rnglock); diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h index 0f9a89067016..f12c32d1843f 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h @@ -106,6 +106,7 @@ #define MAX_SG 8 #define CE_MAX_CLOCKS 4 +#define CE_DMA_TIMEOUT_MS 3000 #define MAXFLOW 4 @@ -196,7 +197,6 @@ struct sun8i_ce_flow { struct completion complete; int status; dma_addr_t t_phy; - int timeout; struct ce_task *tl; void *backup_iv; void *bounce_iv; From patchwork Tue Sep 2 13:21:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1102 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BC09307489 for ; Tue, 2 Sep 2025 13:22:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819381; cv=none; b=bXz3mJtJizq4J13VV8p/Gm/diZIrruw624OHMqwS4v/7Bp3g7WsirN0g1ynmrqOTUkisxwBNozbRwdh1/WQmO5wqXYe9vPiqwN+xXjh69RNBDm90sxKYey5FrwORMVT98sNBkHQiopoD98J9hNYi9srqSw5jZaDoUWbxun7B3W0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819381; c=relaxed/simple; bh=kyASvvV0C6502P156s4uvhgiJ2anCkqmkQU+DPnmJLM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g3FdYD5u3CB1w5B8Bx7cQ4j3k3sViSkTbDKx6wgpEhGPD8qyvZ+WnBckXqCkzPGnsOBkxX+iT1Gb6GNCUzT9Pp3wxyfed57lXHJRhmxXUInNYzh3tbtpOh1ZqJu3EYh2CxAWBCTHBRmVaA48jSHY2bEh4bAFRkiTdfTwtCx/2bc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fw4xojRa; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fw4xojRa" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-45b883aa3c9so16690525e9.2 for ; Tue, 02 Sep 2025 06:22:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756819378; x=1757424178; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6ElWdGUyg9Q9uvasE/0knQrvGqeT+AHFO5zlC/AHADc=; b=fw4xojRaBWMUqUa3ai7hGKv+qp4Rw6FR93H/HEZZaNSiului/bwQwQDpnODeFtHI1b eLrcWvyLkmbw/KKV+Qj838J9rs6YaXxrTek+QeKaG7WI5Z9ax2fJ7H2o/BkqKCPJ0ON2 +1i5htwvW/nBJz4+HjXnRobFdVTIL4kQKHLSz+tIQ9CDvCozZ+eTQORSH98/i62/eHdA UYk3KXRZ1eJ7BfNl9J0Er5wGCGClsjRzY81VpWo4VFDLV2OdxkcYw0X4qECh7CTIUgir uIKxHrZAnFYV3sSz3o8kLdN/4eAQaHo/NauC3tgMboncvZ2JHDNr6vZ5KA+20kuxBiBy +a+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756819378; x=1757424178; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6ElWdGUyg9Q9uvasE/0knQrvGqeT+AHFO5zlC/AHADc=; b=Z3p8sz7Rsi76Jkt2902zwl7+Sikv8l9UNY66mkbI0A8VBX0dtjcW++O1iKB75SPQsc RP+4RTNxpxRygCopYi/8h5DUCXe4yeLbyV/qElva4WYZfiGz+gYvI6KujgeZ3CC1uq18 2HXc6J+UwVlcw7bDEAaJztnbNKD5UjTHRosufJ/Yi3biB2PJ3agwPuHCec4pG8jvoaOu BpLNxof6CA9/9JwSfqi0ba8xtpgs6za9oTHQ/hgWRNTIRAvTTVkDRXiJQ0fmUiD5d1Lr zSy5ZkAZ3DlrbjH2y7x2+011pOfm6VjhiwMmw/nTJ4gzTXNlZlrJI5qqL44AP+AQX3n2 fPrA== X-Forwarded-Encrypted: i=1; AJvYcCVTdsz6XcoSWoZEq8TROZzhH8ICijjguES+WdSyHfFN+ZsqLGcUQxf5bYJVgdviIgjSGLvkRYltGiVy3w==@lists.linux.dev X-Gm-Message-State: AOJu0YxSS7aKd/XtJzuv8tt3B5sAdiL4GgHyYAUiJz5jtzPu2zHDDRlt Ph5nsEBsCt69UrBKFTxQ3l55I+6JhpU7P2CylJumiIgMIMD5TiZxjvpX X-Gm-Gg: ASbGncva+TO9JP8h7Da+r0FoRcBoU9fdoj4HgCAT10mcis1l7v2sAB4RqevE0KZSEJi 8odQFygYJtwUuClUH7ppBI9F36E0Xu02F9D45dz9vUD87p7CXqzcS5JY0X+5BoF9QApgMJHhDNb ChpJ4ELCLC1E90O2RQXpTVDUqI9uKf59m0NI7oa3LQP54r/rJYHEeg3bvGrJVe21O8LZPucZ0+u TuL2HD1CgvsmEo2ZjWnBS8n3MXM6zIhKF3HMbf06P7T21kkiz9MxYWKnQ7KjBXaevAofNyiIzxD 60iA+XkERogIXwsnxrgAYsAXo0cBQkh0y4F75mrNOCBXQBbCMaY7BTZb2sx+pV1oNqIqRlCx8oK Np/XpxAvi5NLr9W+pdsd05LZlQUPaVfsHvQ== X-Google-Smtp-Source: AGHT+IHcyDVYiBnpcbLNKDERC0dfFteGZiJ+qGt3KiUljAkJChMcYHaPXwrQyaik6ZY9zKUEaa9wZw== X-Received: by 2002:a05:600c:4c06:b0:45c:4470:270a with SMTP id 5b1f17b1804b1-45c447028b8mr66195e9.9.1756819377579; Tue, 02 Sep 2025 06:22:57 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:c207:b600:978:f6fa:583e:b091]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b945332adsm44452155e9.4.2025.09.02.06.22.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Sep 2025 06:22:57 -0700 (PDT) From: Ovidiu Panait To: clabbe.montjoie@gmail.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org Cc: wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Ovidiu Panait Subject: [PATCH v3 2/9] crypto: sun8i-ce - remove boilerplate in sun8i_ce_hash_digest() Date: Tue, 2 Sep 2025 16:21:27 +0300 Message-ID: <20250902132134.3287515-3-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> References: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Status: O Retrieve the dev pointer from tfm context to eliminate some boilerplate code in sun8i_ce_hash_digest(). Signed-off-by: Ovidiu Panait Tested-by: Corentin LABBE Reviewed-by: Corentin LABBE --- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c index b26f5427c1e0..61e8d968fdcc 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c @@ -238,19 +238,15 @@ static bool sun8i_ce_hash_need_fallback(struct ahash_request *areq) int sun8i_ce_hash_digest(struct ahash_request *areq) { struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); - struct ahash_alg *alg = __crypto_ahash_alg(tfm->base.__crt_alg); + struct sun8i_ce_hash_tfm_ctx *ctx = crypto_ahash_ctx(tfm); struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx(areq); - struct sun8i_ce_alg_template *algt; - struct sun8i_ce_dev *ce; + struct sun8i_ce_dev *ce = ctx->ce; struct crypto_engine *engine; int e; if (sun8i_ce_hash_need_fallback(areq)) return sun8i_ce_hash_digest_fb(areq); - algt = container_of(alg, struct sun8i_ce_alg_template, alg.hash.base); - ce = algt->ce; - e = sun8i_ce_get_engine_number(ce); rctx->flow = e; engine = ce->chanlist[e].engine; From patchwork Tue Sep 2 13:21:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1101 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 960E9307AC0 for ; Tue, 2 Sep 2025 13:23:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819382; cv=none; b=BG+dXF/JVzhBah1OAoOUss1dmAOlmRlFYNnpRVQlTAO12x8SjOfmQZfrNXXeQZETNhejR6sZI3sIAdmi21pXEla6I1LiN7vQXXkrWn6Ui+xiDp0pp6SzxUUWcQludLnG+yOYHtE/42UYR86iAt7QmHuIVC0Hy5FMKYOPcWQgIZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819382; c=relaxed/simple; bh=bsrtN/UNG9iIkOTFtbf/aBs98lsRgQ3mXT6PfL4G5aE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rOvW11vfMprElTNdPf7g0/pH1RzXm4NfZAga3s/juyVToghn3mqOfbTQ5R68A0h0JugbLnjbYgQMRT92DmZ8XNts+aIcPhEe27jE2kGqEUlUINkeKZ9NCou36PosLD2sit7u8SoDplsqy5fVCmecAXgf21A0CR+uspL9wdoSZ2o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dusCXfUS; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dusCXfUS" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-45b9c35bc0aso3561515e9.2 for ; Tue, 02 Sep 2025 06:23:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756819379; x=1757424179; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9SQo1VWDa8L0gOXuwTFV8cUa7G4/T2C+1QUOVeEgYOo=; b=dusCXfUSrlfQMTrn+0vbKQ1CkIepM3M/NNoY38iP13MSknxbHtHjvSrQkYKDXZWgB6 9C+wKpR62HqcxDf2NvnSKyWQjCsAxUASvTd41HhOW//0CPabPTxIIY+TxGyi8TGroUe/ ZWqs/OsRqCnuCgAuE3UPA6NLKrah1/QMlVWpLIS+rjOKsRH+C61Hy4BDeY0SCAF0yTU8 V4AMHNnQYIivRzk5iVoyZ4P4tfN1m9uh7Y4V/F08cG2rfEdM4Mo+uJEMGPvJhAMzRoeZ 2Lq7o1B2koTD5fP24vFV7zj9TiGHvLeJ0hdbjrqC2enu6Fvz8qnJEIfxZJPsnbMOnIh9 AqAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756819379; x=1757424179; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9SQo1VWDa8L0gOXuwTFV8cUa7G4/T2C+1QUOVeEgYOo=; b=sCHF2LeCvJG7XJ2Yzboc89BcULZZBTO5YY2BpPrDMZIDVQ8SFJVkMZhWEglOdLf0p4 SRzcGxmMSuPsphjQXBOsTmiqhEzFuVVcGumxYfqoayvw1ip1kNqPJa3tLYr6rDjUhAMO Kjsi/vXDlBVCYWllGoXnPK+pCL+hG2o6lEYdfWLjm0X+43ddSXsWp3wwF9ZrdYyhHfYu AYDgAG37P1Z0Lzuc1NqN9p7imyP75p/pjqa6ga7HXyT0vcPOnZPLhwPj1ASJ8kiBtjT0 4vHB6hdkHlRhzyvYZmwocmnH18FCRqIWfNYu6DnbPmO8r/VLQt/voAT5p1Vor/UiI62Y Es0Q== X-Forwarded-Encrypted: i=1; AJvYcCVtlK/gMfsFet0B4uns2BLwOkvFOLP4Lw7+j2fppi560OSeG2Sz0RRLeQEOTsJk/zEtMBNUngpxpZxjOw==@lists.linux.dev X-Gm-Message-State: AOJu0YxAb8kuYF3iCS5E9n7vrbczHAv0tCb3hD1tl9f//a9n3QTX7QTV bhKDXelynzQRtY5XTwfOUfN5YOxBrWNQlSmn64u63QxqPz0WllR/oVIY X-Gm-Gg: ASbGnctaYsbCeESV44DPmRf6lX8LAfjfap11Ae4NYLyUPDR6vpPJncLdyzYS2G7yIC3 Iry77d7u7oiD1jxb8KkOgFATpIN+dWm/+qT0pqpn0rFkF1K16h//Hp33vZBIvCv2H0iA5TD+XTu VYTwaAja0IE4UniQDhkoT+ncBD/yoXtd4UmQpMHWnS+IbQ+mi93NhQX5zrVdC8PkcUm/fl5z8s8 yD0vlmyqD65Kw+auRK5Ewxw6NUI6WHAmY+dXBgyn4yYaQYFmGN2s+K7lTvttX4j4Zot7JJtzMvC 1Lrag70YW4OJdI5Mod6a1miwqmcD9u7auzGVThsO4sxaVvLgdefQDbU+dtV4EEFhT+PFvp44jnO /tkWHcoWZOwDvX3BX6vTdACJE+KG+OJ2Z4Q== X-Google-Smtp-Source: AGHT+IFCIE32gRqXCK2cxP5jJ0umVullIbqtBAeMOiAN/1dBA/vOuBTNpHuGFamrKvDjEfmo1r30gg== X-Received: by 2002:a05:600c:1e87:b0:45b:47e1:f5fe with SMTP id 5b1f17b1804b1-45b855c0d3dmr80790615e9.34.1756819378791; Tue, 02 Sep 2025 06:22:58 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:c207:b600:978:f6fa:583e:b091]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b945332adsm44452155e9.4.2025.09.02.06.22.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Sep 2025 06:22:58 -0700 (PDT) From: Ovidiu Panait To: clabbe.montjoie@gmail.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org Cc: wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Ovidiu Panait Subject: [PATCH v3 3/9] crypto: sun8i-ce - remove unnecessary __maybe_unused annotations Date: Tue, 2 Sep 2025 16:21:28 +0300 Message-ID: <20250902132134.3287515-4-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> References: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Status: O There are 3 instances of '__maybe_unused' annotations that are not needed, as the variables are always used, so remove them. Signed-off-by: Ovidiu Panait --- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c | 2 +- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 2 +- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c index 113a1100f2ae..c57c64a1a388 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -111,7 +111,7 @@ static int sun8i_ce_cipher_fallback(struct skcipher_request *areq) if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG)) { struct skcipher_alg *alg = crypto_skcipher_alg(tfm); - struct sun8i_ce_alg_template *algt __maybe_unused; + struct sun8i_ce_alg_template *algt; algt = container_of(alg, struct sun8i_ce_alg_template, alg.skcipher.base); diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c index 79ec172e5c99..ba30859e749c 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c @@ -1062,7 +1062,7 @@ static int sun8i_ce_probe(struct platform_device *pdev) pm_runtime_put_sync(ce->dev); if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG)) { - struct dentry *dbgfs_dir __maybe_unused; + struct dentry *dbgfs_dir; struct dentry *dbgfs_stats __maybe_unused; /* Ignore error of debugfs */ diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c index 61e8d968fdcc..df2acef9c679 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c @@ -26,7 +26,7 @@ static void sun8i_ce_hash_stat_fb_inc(struct crypto_ahash *tfm) { if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG)) { - struct sun8i_ce_alg_template *algt __maybe_unused; + struct sun8i_ce_alg_template *algt; struct ahash_alg *alg = crypto_ahash_alg(tfm); algt = container_of(alg, struct sun8i_ce_alg_template, From patchwork Tue Sep 2 13:21:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1100 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA9243090C6 for ; Tue, 2 Sep 2025 13:23:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819384; cv=none; b=kMT5vi4o1/2tlCyFxiMGq4QB4B8UplHZ/g1eYMp/dffOVVCHqdtDFD+HB3mzILMzhiCyWEdK+rABd1mopWFOhJFq8/AyIhHmyfxcYgFoU9tQbno+21NmKoRhwGArgnEcaxH5VTcg0K6V3jSN9wq17pB/Sfp7HK25a61/gHmlN20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819384; c=relaxed/simple; bh=NuYFEKMaNu1hQjN2Md5xNm1r7h0CNUWlhKkPh3zc5MU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GSxKG7FXTnlNRDcoSggs5W/52ug1vJpvSpJXidDu6w2NvD2bnzimidROeyAAG46e90lLGA784kGWdUJRn4EXkgSYOUZN63BSWhT06JvMM9WaBxdwwGerICLRTBdLtIy2yj0ICGXRSTjwYWJZ6npaCS9JuXbpEXFMVJkQply3lYE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XGdTUGwj; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XGdTUGwj" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-45b86157e18so16878475e9.0 for ; Tue, 02 Sep 2025 06:23:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756819380; x=1757424180; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Qolo47kLruRZDje5v7puvJiYv8DgcRb8St2Hs5XCLlg=; b=XGdTUGwjcJZN6vXaehhT98XZmZFP8mFN9OzMvme2KxU1gkarf5e5y0dJbi+xBlmgL/ u/Re+MiXGu+5RT0VLzmP+cBxeyLBO2BCF+ZsgY4nHG069JJd/hs/I5bJj6eCafkl0YN+ K0XFTavJX99/b/XmU2QLYQzR7W4vHtLirqiGJhgWlLAmAZZWSqADISHH5ngUkS5jwYxz ytdQ7MHHepTiYP9c6M5IXttNisx2Hz0K8cYpbgySRFxfKg0OnSesZ2JORC3DGmtE90dv bW9BnTmEnrN0ao1thDOS3ArqGJFSEY15aX+ChRNNU2qihBILB1q9p3pAIpfakJMe6iAJ opZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756819380; x=1757424180; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Qolo47kLruRZDje5v7puvJiYv8DgcRb8St2Hs5XCLlg=; b=Y4MjEbJQuMf+O6lJL+pIusb8K6BkWAA7lIzg431xdOQbsukVcDnn+boed03zstzrsR KAFRPoqC4IDbNI3d3DulFUoU/yAJxT6Xb5UgCT2W8MzBEPez5INjk1XPJLnL7XKVGX7v aGYp4cteAuJgG3GNGYW+Ph5LhseN2oQDolzWfjDhRGP1EtJqR1FIylOUJUTP/VFenoFn XNbFtgSRjI7Ynu3qsGxHlOAT56aPQT7h70y6yScf1G5ylr5JwyRCEiNNinemx9jOA/R1 YXkq5pQ9u+Fl/28+MYJOl67ibKjNeUobVp4ltlZtrRmiEHc0R87UAOwdWP6Xo3vqpemG sOXg== X-Forwarded-Encrypted: i=1; AJvYcCXLhSFK59myzzossdnwkpqf1FGe6FpGu+sA/6qDPLOEpn9Q/17iCcrwsCTSdTftXXYVWR8VAgCNZq5GkQ==@lists.linux.dev X-Gm-Message-State: AOJu0YxkaWmbriU+oBGVq5p2PtIqqwAHa5DA1VkMVGLqiHasinNjJwsI kVGlMDBOFre+OYJdP9V9E01H7rrQG5OEIFVSyQm2UvGZKqtojr/z6e51 X-Gm-Gg: ASbGncsxfMfE/n23p/OZFhaZu7zzfwCUJ+lDwugYZE/PBC1qOD3fuzZd38ElGFLAYfN LduYOmpgz8kYkGe8QfT5KZPVpoDUiURW/O9Vzzca/CiCX+aGK9EIyg6mwby4Ox2gxapSurqtedF +hQUZcy7uaLmg/AsU8Z1FvBdZZRquX5SzOS585sePdAyEgoBoopiS+f7RqZiNuj1WSZxRIvVykz 6l39AfXUVaYaK40ZTIQdt+KGm7S5wkz3uTIskfdJcx9vnM2b8F5zVrbzJLza2awfDn3CumR8WiA uxvoKJSYxvB6NuSKEwxZypxXH60Km0YMNLOGl9icFE8SoI9iC6vaNh+3c1xJsnjQkFUYRzc4PAq /Ad2Z+ZNM9OIsyH9uRfjMUQAPInikhHFxXWqS+2U5u0Dx X-Google-Smtp-Source: AGHT+IFVMpRzBsmi4JxaTIrSD5qdn6LF3a/HZb80zXbTgRnBpIOBBAGYwh5jd/sYemoWSplteKfu3A== X-Received: by 2002:a05:600c:3b28:b0:456:201a:99f with SMTP id 5b1f17b1804b1-45b8730d443mr85114285e9.18.1756819380078; Tue, 02 Sep 2025 06:23:00 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:c207:b600:978:f6fa:583e:b091]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b945332adsm44452155e9.4.2025.09.02.06.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Sep 2025 06:22:59 -0700 (PDT) From: Ovidiu Panait To: clabbe.montjoie@gmail.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org Cc: wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Ovidiu Panait Subject: [PATCH v3 4/9] crypto: sun8i-ce - add a new function for dumping task descriptors Date: Tue, 2 Sep 2025 16:21:29 +0300 Message-ID: <20250902132134.3287515-5-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> References: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Status: O In order to remove code duplication, factor out task descriptor dumping to a new function sun8i_ce_dump_task_descriptors(). Signed-off-by: Ovidiu Panait --- .../crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c index ba30859e749c..b7093fbb8e9d 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c @@ -169,6 +169,12 @@ static const struct ce_variant ce_r40_variant = { .trng = CE_ID_NOTSUPP, }; +static void sun8i_ce_dump_task_descriptors(struct sun8i_ce_flow *chan) +{ + print_hex_dump(KERN_INFO, "TASK: ", DUMP_PREFIX_NONE, 16, 4, + chan->tl, sizeof(struct ce_task), false); +} + /* * sun8i_ce_get_engine_number() get the next channel slot * This is a simple round-robin way of getting the next channel @@ -183,7 +189,6 @@ int sun8i_ce_run_task(struct sun8i_ce_dev *ce, int flow, const char *name) { u32 v; int err = 0; - struct ce_task *cet = ce->chanlist[flow].tl; #ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG ce->chanlist[flow].stat_req++; @@ -225,9 +230,8 @@ int sun8i_ce_run_task(struct sun8i_ce_dev *ce, int flow, const char *name) /* Sadly, the error bit is not per flow */ if (v) { dev_err(ce->dev, "CE ERROR: %x for flow %x\n", v, flow); + sun8i_ce_dump_task_descriptors(&ce->chanlist[flow]); err = -EFAULT; - print_hex_dump(KERN_INFO, "TASK: ", DUMP_PREFIX_NONE, 16, 4, - cet, sizeof(struct ce_task), false); } if (v & CE_ERR_ALGO_NOTSUP) dev_err(ce->dev, "CE ERROR: algorithm not supported\n"); @@ -244,9 +248,8 @@ int sun8i_ce_run_task(struct sun8i_ce_dev *ce, int flow, const char *name) v &= 0xF; if (v) { dev_err(ce->dev, "CE ERROR: %x for flow %x\n", v, flow); + sun8i_ce_dump_task_descriptors(&ce->chanlist[flow]); err = -EFAULT; - print_hex_dump(KERN_INFO, "TASK: ", DUMP_PREFIX_NONE, 16, 4, - cet, sizeof(struct ce_task), false); } if (v & CE_ERR_ALGO_NOTSUP) dev_err(ce->dev, "CE ERROR: algorithm not supported\n"); @@ -260,9 +263,8 @@ int sun8i_ce_run_task(struct sun8i_ce_dev *ce, int flow, const char *name) v &= 0xFF; if (v) { dev_err(ce->dev, "CE ERROR: %x for flow %x\n", v, flow); + sun8i_ce_dump_task_descriptors(&ce->chanlist[flow]); err = -EFAULT; - print_hex_dump(KERN_INFO, "TASK: ", DUMP_PREFIX_NONE, 16, 4, - cet, sizeof(struct ce_task), false); } if (v & CE_ERR_ALGO_NOTSUP) dev_err(ce->dev, "CE ERROR: algorithm not supported\n"); From patchwork Tue Sep 2 13:21:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1099 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52D6B307AE9 for ; Tue, 2 Sep 2025 13:23:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819385; cv=none; b=igv7cFFC1j6d/5VWgFAubGDcoRGfaGa1jLrJnrMAHD0UB3EfL9Vw0MHw+5J2fddWL/2Cgmoj5Li00YOlviRA9nOkuJaS2PnFp3OtnMeCS91gaxBux0l9GXaWrnzGxqG5lkaYal0wy+rfk2bHc1C4hPEBtFtKs3fI9rs8Tr+yc0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819385; c=relaxed/simple; bh=Tv+uPkupmNEYL/Dftci6+vTNcsCph7gyS6HdR98JrGQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L+b/qSJCs9N1CDErnQBoafs9O/btOat+80IS71g3hjJ/pmxQWLYHXyFtuzeLt7qdnZpF5Wzq1dgppF6/fMWQF51biLfwNgQkmgKVcOQ0gj8uZ5VmDodyrzRLfXYyIOPIkqwwBVpal2cS15yV7k6Q9ts3bbOhi3YQThnW6PP9SnI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VOnkWtIN; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VOnkWtIN" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-45b7e69570bso27489025e9.0 for ; Tue, 02 Sep 2025 06:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756819382; x=1757424182; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DtsBsRfxsCildLBhMXrk/1mukmK+Bo0TNCGWMCSP/qs=; b=VOnkWtIN50VSuWDyfqDcZY+4HYtHc2pXX2Un+WPvWQzZg0tZ9KHVkW2L9o+Az4cJcY xmTFxGnQWThrN2VSP33XWax2iHVQhEBhZOUCImyzQpYrAwcDH4Dh+jP2NLKrv2187Tio 2JXHW41RXQ4LNyMHJ7uHRlMg0tfscYxGCNZxTBmPk/L90saYLgYZn4/WmNqugLHKz5FY wmENoz+8YIb3mJ3zj+Bt/zWWT7LOSCeJyeNUdbOWb/UaV/v/ThRzzbZZIJDErmHUHU2i TeZxVviwDBJX1a2HPCPs/GxymTJP1XB8eMPpS40FGM31ltlm9/MNafDpfL1+QrJeCnKX IVgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756819382; x=1757424182; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DtsBsRfxsCildLBhMXrk/1mukmK+Bo0TNCGWMCSP/qs=; b=w1RtID9eapZDU3LF7kLceALwANXqBRboI0rMEGp8TCmSqkGccs7HhgdPXXCl+A4+ll IJxn0f6oYd2DmSkIhb2UprZf0IwCbFoif+L79ZP4n7U23EQRLiSzzzHyMFROKclJmfan iw1A4nstZka1TyrshE9OchZlKO/EY0NpnTk8lg0r7YLQ5Bd5XwKR7UoItIIHnSkljlbe Pjs4Th8KZnLt0QirisyfIRl/0tHH96UFtIm/Mv6ZFYfUc8l89ODcMjYsTJWS8p01ZrkE xoOJGX06gSUIU+fPpSk20Ts2lyEzwnuLrvXXNj6bEaomzQaaBr+wQfvjgpJdvit0+RaB 62vw== X-Forwarded-Encrypted: i=1; AJvYcCWOi81aglnNa0vTDWUBEKu7bpHZ6RzMe+xy0u28PLAD7o4fPWBQ7Q1GJrYvY2h/lxAP0auqZh0HmujB7g==@lists.linux.dev X-Gm-Message-State: AOJu0YyXlj3zjrz9PX5TIBtw1BVZCjxtCXC7mwRcoGLeB5bO/uO1VZSq 0nI1SqVAnMf9ZEf9q4DvWwvuB6uowDqwa4ak5ZaSmw7CfgIrnjq9XAji X-Gm-Gg: ASbGnctG3UHZAp/SAA17zJUPeByYr7Nz/HjzsiJE93hk16HZeioBsa9Q6LIHcxJrnrc 1/YC8nRLF4OvlcuOmnr1vTl5hRYcEIUYZdVthdteuSrjYb1mwX3Yjj/Z7Euec1oAE5uYzwUJmf4 L8nzVUHHe+eM1o5TVxugEJU+XcErsW5lKZFy50sGCXvpaM268bkyhSBuj5P2ehpKuDxtbqD0hhb slO5c5qospeZ4Kf807uKPG3PoEJZXWe7ho58uSq6MU97RCKpdry32NFbJeQdUUSpmA7uUrCiQ9n x0S15/cBG2CxHxIyURI6XTjTT7jTbu4ECchu8f3jbcrQYOOrjGx9X+miqT0mB2srViLMCqFl5+z NfGoS1Gqbxo7MBsxeIGmxtd2aqu9OqyWperwWVM0GNgVx X-Google-Smtp-Source: AGHT+IETMOb0Rz6uokv2cCuXIze1UZwZd7stbSLwZ5/eUHfLJCESg1DUz9amO71j1f3f3X5J/fE/FA== X-Received: by 2002:a05:6000:2f87:b0:3d4:d572:b8eb with SMTP id ffacd0b85a97d-3d4d5820387mr7918018f8f.45.1756819381342; Tue, 02 Sep 2025 06:23:01 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:c207:b600:978:f6fa:583e:b091]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b945332adsm44452155e9.4.2025.09.02.06.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Sep 2025 06:23:01 -0700 (PDT) From: Ovidiu Panait To: clabbe.montjoie@gmail.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org Cc: wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Ovidiu Panait Subject: [PATCH v3 5/9] crypto: sun8i-ce - move bounce_iv and backup_iv to request context Date: Tue, 2 Sep 2025 16:21:30 +0300 Message-ID: <20250902132134.3287515-6-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> References: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Status: O Currently, the iv buffers are allocated per flow during driver probe, which means that the buffers are shared by all requests. This works because the driver is not yet truly asynchronous, since it waits inside do_one_request() for the completion irq. However, the iv data is request-specific, so it should be part of the request context. Move iv buffers to request context. The bounce_iv buffer is aligned to sizeof(u32) to match the 'word address' requirement for the task descriptor's iv field. Signed-off-by: Ovidiu Panait --- .../allwinner/sun8i-ce/sun8i-ce-cipher.c | 18 +++++++++--------- .../crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 12 ------------ drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h | 8 ++++---- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c index c57c64a1a388..69ba8236cf2d 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -209,11 +209,11 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req if (areq->iv && ivsize > 0) { if (rctx->op_dir & CE_DECRYPTION) { offset = areq->cryptlen - ivsize; - scatterwalk_map_and_copy(chan->backup_iv, areq->src, + scatterwalk_map_and_copy(rctx->backup_iv, areq->src, offset, ivsize, 0); } - memcpy(chan->bounce_iv, areq->iv, ivsize); - rctx->addr_iv = dma_map_single(ce->dev, chan->bounce_iv, ivsize, + memcpy(rctx->bounce_iv, areq->iv, ivsize); + rctx->addr_iv = dma_map_single(ce->dev, rctx->bounce_iv, ivsize, DMA_TO_DEVICE); if (dma_mapping_error(ce->dev, rctx->addr_iv)) { dev_err(ce->dev, "Cannot DMA MAP IV\n"); @@ -299,13 +299,13 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req offset = areq->cryptlen - ivsize; if (rctx->op_dir & CE_DECRYPTION) { - memcpy(areq->iv, chan->backup_iv, ivsize); - memzero_explicit(chan->backup_iv, ivsize); + memcpy(areq->iv, rctx->backup_iv, ivsize); + memzero_explicit(rctx->backup_iv, ivsize); } else { scatterwalk_map_and_copy(areq->iv, areq->dst, offset, ivsize, 0); } - memzero_explicit(chan->bounce_iv, ivsize); + memzero_explicit(rctx->bounce_iv, ivsize); } dma_unmap_single(ce->dev, rctx->addr_key, op->keylen, DMA_TO_DEVICE); @@ -348,13 +348,13 @@ static void sun8i_ce_cipher_unprepare(struct crypto_engine *engine, DMA_TO_DEVICE); offset = areq->cryptlen - ivsize; if (rctx->op_dir & CE_DECRYPTION) { - memcpy(areq->iv, chan->backup_iv, ivsize); - memzero_explicit(chan->backup_iv, ivsize); + memcpy(areq->iv, rctx->backup_iv, ivsize); + memzero_explicit(rctx->backup_iv, ivsize); } else { scatterwalk_map_and_copy(areq->iv, areq->dst, offset, ivsize, 0); } - memzero_explicit(chan->bounce_iv, ivsize); + memzero_explicit(rctx->bounce_iv, ivsize); } dma_unmap_single(ce->dev, rctx->addr_key, op->keylen, DMA_TO_DEVICE); diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c index b7093fbb8e9d..c16bb6ce6ee3 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c @@ -759,18 +759,6 @@ static int sun8i_ce_allocate_chanlist(struct sun8i_ce_dev *ce) err = -ENOMEM; goto error_engine; } - ce->chanlist[i].bounce_iv = devm_kmalloc(ce->dev, AES_BLOCK_SIZE, - GFP_KERNEL | GFP_DMA); - if (!ce->chanlist[i].bounce_iv) { - err = -ENOMEM; - goto error_engine; - } - ce->chanlist[i].backup_iv = devm_kmalloc(ce->dev, AES_BLOCK_SIZE, - GFP_KERNEL); - if (!ce->chanlist[i].backup_iv) { - err = -ENOMEM; - goto error_engine; - } } return 0; error_engine: diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h index f12c32d1843f..de3a096c476c 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h @@ -188,8 +188,6 @@ struct ce_task { * @status: set to 1 by interrupt if task is done * @t_phy: Physical address of task * @tl: pointer to the current ce_task for this flow - * @backup_iv: buffer which contain the next IV to store - * @bounce_iv: buffer which contain the IV * @stat_req: number of request done by this flow */ struct sun8i_ce_flow { @@ -198,8 +196,6 @@ struct sun8i_ce_flow { int status; dma_addr_t t_phy; struct ce_task *tl; - void *backup_iv; - void *bounce_iv; #ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG unsigned long stat_req; #endif @@ -264,6 +260,8 @@ static inline __le32 desc_addr_val_le32(struct sun8i_ce_dev *dev, * @nr_sgd: The number of destination SG (as given by dma_map_sg()) * @addr_iv: The IV addr returned by dma_map_single, need to unmap later * @addr_key: The key addr returned by dma_map_single, need to unmap later + * @bounce_iv: Current IV buffer + * @backup_iv: Next IV buffer * @fallback_req: request struct for invoking the fallback skcipher TFM */ struct sun8i_cipher_req_ctx { @@ -273,6 +271,8 @@ struct sun8i_cipher_req_ctx { int nr_sgd; dma_addr_t addr_iv; dma_addr_t addr_key; + u8 bounce_iv[AES_BLOCK_SIZE] __aligned(sizeof(u32)); + u8 backup_iv[AES_BLOCK_SIZE]; struct skcipher_request fallback_req; // keep at the end }; From patchwork Tue Sep 2 13:21:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1098 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CB2430AAB4 for ; Tue, 2 Sep 2025 13:23:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819385; cv=none; b=JF0Chv17tINmzLWLOkbVw77FPaSGo4zaWFGeUaheRvkTST4mp1coYPdrX1jY7Z3cc44Y6MYSgOTCmcy0hmpSKB3HDdpOjq/OBtLQ0qcHdxJGUnJ2XuJJDWfEkuEBW7h93xT9s+F3roonbvtNu5XZ3Wmb+mj9oleeu9ot4bUZoV8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819385; c=relaxed/simple; bh=VLxVkCzDUptZN3MLV6XyYZWlwBVycUnPTFTRKmIikGY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k8DOkyL7sWpNuNRCH5NgnaBpVnKpS3NznE4QoT7hwW9bTZXSLpDFgFBVRsNurhruLjwUPAEKWXVwaqpss+T/MVEc9B635gupaxPeDGFIyCprcWVupXtes+AnQLTg20pT/3Z8H8xN9C+myodlyg8P6YLGG1ch1ba2uNbW2ZIHN3k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZRImtAPs; arc=none smtp.client-ip=209.85.221.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZRImtAPs" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-3d1bf79d7acso1868080f8f.0 for ; Tue, 02 Sep 2025 06:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756819383; x=1757424183; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dlcibDkuEhs59MfzxPNpL2Xe4LDD/D/d8iw52Y6RVVM=; b=ZRImtAPsBwzaEP6dKG8GHjsKTDgRjgxkuB/qA/miMoY0q/9V6V6/DStM+q8/05PX62 1gmqGgN3j8735LJRk/6qrOV72nNsZq5OZn3DcdvAo5ls5jHUVYT/PTwyLW3qfwDR4r51 1re5Y9eFdq/KSpKyF9cftvk3YycGCBcOQxVjKvpOhUUp6pGqlwam1gH+4HzHZLqe+zZW jxA8jMYne6SzJrX95Q+xBeTw8v4J/WYRQFMK/OxDXpdluOocwBAs/e7u64KKpY7sRoay trL0Ht9e3EC5KBY/lyvByXy4oHljciki8wukC6huwjgk19W1IDbbemh1w9J12x/Yw5/9 FTBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756819383; x=1757424183; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dlcibDkuEhs59MfzxPNpL2Xe4LDD/D/d8iw52Y6RVVM=; b=BudJIniQ4Kx1pIBDgOMw8g2oZoO8EpDmaQ5PG3PeVR8iSAMLRVaCpPjNrj/bjBdqZ5 +Rtj5XFa+OqTq+USnSSYg+WCk4CiSaVOFoDfNexHd94j2qXo+wWX5mZl2/fZuygs8avz Y9w501USBo4WG42iVzmwxQK/dF2L/UFnb4cwa5lLyh/kKy6rAZwclFioCdi/ydH9P9IK MdJlE51tQLqWpv2CS11pFLXRcxvnGnQyxmZ/fuEFRrM3j7ErJiILLAEjGPO2gucKtYcl vOiUt4nvzfcn6yOIv90Z5K4YhjLfc0oZbp/sXS8didphqHK8eLRXauvV74SWtGw5tzZz gNjg== X-Forwarded-Encrypted: i=1; AJvYcCXB1WiNzRV/eEo2G/i/HrGtRFqyHLI/YjV54JZav1Mej3gECCu6ffEBRI5E3FBf+1573r3fWG1Yhxi42A==@lists.linux.dev X-Gm-Message-State: AOJu0YzkN/sqbA97HxGX4jvliy1M74UEUBA5kIHtt2SvUB43RFF4Dj5r 4qgygS2un/DEB0EhQqGAZRA8nKMYvjTCouCbxhe+wL40cdn7QXIIw5h3 X-Gm-Gg: ASbGncv84KDhsKJH1sOtDDJwkp/irOeKe0ltDy1uhplCuSo5/BG0UGSQnkcsT/+AMlO Ju9F8raMDhJhBv585c1ExOna3rGuGZmNreyHsN4QXFOJaaRxLrYaiidW/fOUiPgDo74tRoj1wRf ehAGH3aQSrssfvUK1rN06KvwdE+mJx15DdHmle8z2dpMnQG1jbRd/8Ck2aAI7K9yp6X29r/PMR+ oTvE7ezC+7O+BjltOeJ6WPw6woZ4bLqBlBrLjCTgVLP6RQ85zssRYdl1JLvZlZGd7aJjN2RkQKL 2z6Pqad+cGrsluA7M2F1fBWcDpe5YqugrnR4+oLRz86PaCbJzEjrEINIlp6lhKIt90LJag0Cow/ 96cwMO4NT5vquwwYv7NOyGHdjAz0HH/sSdA== X-Google-Smtp-Source: AGHT+IHVnaSqlqqL4i33vbnl8DxH3Zomz9ikQnMsjbbKikajW7iV7MsBCgP8xKySewSnOuFEhpUjVQ== X-Received: by 2002:a05:6000:1ace:b0:3cf:3fe7:2203 with SMTP id ffacd0b85a97d-3d1dd81d0a4mr8042987f8f.7.1756819382532; Tue, 02 Sep 2025 06:23:02 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:c207:b600:978:f6fa:583e:b091]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b945332adsm44452155e9.4.2025.09.02.06.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Sep 2025 06:23:02 -0700 (PDT) From: Ovidiu Panait To: clabbe.montjoie@gmail.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org Cc: wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Ovidiu Panait Subject: [PATCH v3 6/9] crypto: sun8i-ce - fold sun8i_ce_cipher_run() into sun8i_ce_cipher_do_one() Date: Tue, 2 Sep 2025 16:21:31 +0300 Message-ID: <20250902132134.3287515-7-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> References: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Status: O Fold sun8i_ce_cipher_run() into it's only caller, sun8i_ce_cipher_do_one(), to eliminate a bit of boilerplate. Signed-off-by: Ovidiu Panait --- .../allwinner/sun8i-ce/sun8i-ce-cipher.c | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c index 69ba8236cf2d..f63d21cd1e52 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -360,31 +360,28 @@ static void sun8i_ce_cipher_unprepare(struct crypto_engine *engine, dma_unmap_single(ce->dev, rctx->addr_key, op->keylen, DMA_TO_DEVICE); } -static void sun8i_ce_cipher_run(struct crypto_engine *engine, void *areq) -{ - struct skcipher_request *breq = container_of(areq, struct skcipher_request, base); - struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(breq); - struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); - struct sun8i_ce_dev *ce = op->ce; - struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(breq); - int flow, err; - - flow = rctx->flow; - err = sun8i_ce_run_task(ce, flow, crypto_tfm_alg_name(breq->base.tfm)); - sun8i_ce_cipher_unprepare(engine, areq); - local_bh_disable(); - crypto_finalize_skcipher_request(engine, breq, err); - local_bh_enable(); -} - int sun8i_ce_cipher_do_one(struct crypto_engine *engine, void *areq) { - int err = sun8i_ce_cipher_prepare(engine, areq); + struct skcipher_request *req = skcipher_request_cast(areq); + struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(req); + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); + struct sun8i_cipher_tfm_ctx *ctx = crypto_skcipher_ctx(tfm); + struct sun8i_ce_dev *ce = ctx->ce; + int err; + err = sun8i_ce_cipher_prepare(engine, areq); if (err) return err; - sun8i_ce_cipher_run(engine, areq); + err = sun8i_ce_run_task(ce, rctx->flow, + crypto_tfm_alg_name(req->base.tfm)); + + sun8i_ce_cipher_unprepare(engine, areq); + + local_bh_disable(); + crypto_finalize_skcipher_request(engine, req, err); + local_bh_enable(); + return 0; } From patchwork Tue Sep 2 13:21:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1097 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B212930BF6B for ; Tue, 2 Sep 2025 13:23:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819387; cv=none; b=N0WXLLOjFvknn5HfFpdreRLiLgxwF6GbNelnYy0bLokVEfeuqW4Ypg5XrouONe7eMmt/II+bNtjiAxTx6DgyzkesfJoV2RnG6AM/0i5qhPgtYsqK3Dox5n57hSgXtsm6W6nZBaLj3oU6T7IwZyIijC+b/bRIPmTNTOK1avUyhME= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819387; c=relaxed/simple; bh=f6FBfJ2O2GQ3lk7rvtQvn1UblRaOsewFE81eXurpKa8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RBgtfOxfRmdEsmAF1T4MjLAdLqelfoMwYmdpH42KjLrsYmKdD7qUxdR5Nq3DsdCpf0vGA7cF60qYaEaOF0mXgDqopJKZ/nrX/cR7PT0PtsE6bPGhrM33RzpgFhaXPmzA4Jis4eQu1E+2heIxmqyxSIsUZfbpngC9L92pjYEaYY0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZnBwJ+OB; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZnBwJ+OB" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-45a1b065d59so37112105e9.1 for ; Tue, 02 Sep 2025 06:23:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756819384; x=1757424184; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XM9OSoT7EEhuPBZA6neX1BQbhTIUd6+o400NZdJKrYY=; b=ZnBwJ+OBCTGr9nF6G4MsmuiiTodf4xGnfgKhgK3QqrrAS7/VH211H8b7IOYAapeynk Hn0q6I7atXd3K5m/aRRBVRtiSoDAn0xYUKH6kngK8V9m75gQ6+7bcFTp6Bvw64da8cnx EJtoTKXBDw7viQbDTw9RS3flaEgN770yuVrToqlrDUZVFkLxk0lkFxPAe9xzwCr77MBi 1XOfg+7RwV/cgFFnPo8vMEjLuGepVFg0jkCrXbEpoRbbMGUMUt1Yl8c8ZvBq/rhaSDfD IGuYNaYPp179tOoyudjubcwU9niW3wE8Gv7K8OjfLkYbrLMO+9+YJQ05Bq4ojGqf6PKh QCfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756819384; x=1757424184; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XM9OSoT7EEhuPBZA6neX1BQbhTIUd6+o400NZdJKrYY=; b=bcUDG2LIZd+6hSndGUXh//w/BVy7dKn21tatpJDxrZAICVqTLXWa4Fz5sD9Yfpd9uB tVXl0L08sHsuRNy7XJ+ri6em80ZBq4bV+TRHoUp0eEhqx+bw6JP5GRe7b8lY/q8SPvmS hVbn9RCwOejaHwiRsmy+mZy6kJln3TRdBjWkP1O02F8QGZPWcaycbTIu3U2vHt/6dJi7 KBxtZ4jhQbxo8rRwYh2lye44Dm/FOewbStHDmlwbHkd/xi3hnqD1JHw/b36vfUaOMDqH QMOKUcHtaseqd91QVtS72t8DXi66vvSnz1z/Mz3zyol40ZucINnNPKYuZOzskeOSNp3k M1Sw== X-Forwarded-Encrypted: i=1; AJvYcCUz0a5sQiwyQzU0vuERuMmU3iMgWbgmIxZOiueEtB/kfNDOiTa2dSi2Qoq1CgPfu0nCaIpctjYUQZJzCQ==@lists.linux.dev X-Gm-Message-State: AOJu0YyJMde2AdcXmxzKQUaBZBMx/UE/nZZz6zMGq9T3nBPVAuBi7Myc eS6ihIPLS1kOuNMwibV9Gyd+Z1F6romba7Qe/ZcYaUhunRKa8cN5EgKe X-Gm-Gg: ASbGnct/1tU8zGWUs7/uYqLsEB959ec1XS+uhCpyCDZPDIDpzPjY7iRjGYxSpQaLjzv zLE+3d/iwrMt5y4OGZ6LDZe3bhPbSFXr+shtkhGLIEh10waVvqddrxq5bpKF5RmAgiXizIsIcNk 5UXD5pE58V4DqhNMAxl3E2hM18/9hJ8jLTLXpDcnk0zIVhmPnHAastqxdhcFHMHiU3GNwPdU6EK awqtqzjzHHmhItkVqx1ymM3buwRX7rndZGC0RAn9FxA2N04BLA0sQONs81wJZvIHayS4QHUmc4t l10LJCNP/MO5PHmzveB4qO/6cMY6r2OkAexzqNgOjoEe0GFQY6ustyNIHwpE3my7Z+hTl6m9XJ7 mBclIm0HEon0GoASDMim/edkBk0KqUDnU+g== X-Google-Smtp-Source: AGHT+IHcOusuOZbxetLEUJAQpcS9Gkujl1YTX1DeE+tYFW/iEjj3AZ0hRgYLZeeDGlNURGNUHbKE/g== X-Received: by 2002:a05:600c:1f1a:b0:456:1560:7c5f with SMTP id 5b1f17b1804b1-45b8554f88fmr83630355e9.14.1756819383829; Tue, 02 Sep 2025 06:23:03 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:c207:b600:978:f6fa:583e:b091]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b945332adsm44452155e9.4.2025.09.02.06.23.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Sep 2025 06:23:03 -0700 (PDT) From: Ovidiu Panait To: clabbe.montjoie@gmail.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org Cc: wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Ovidiu Panait Subject: [PATCH v3 7/9] crypto: sun8i-ce - pass task descriptor to cipher prepare/unprepare Date: Tue, 2 Sep 2025 16:21:32 +0300 Message-ID: <20250902132134.3287515-8-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> References: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Status: O To remove some duplicated code, directly pass 'struct skcipher_request' and 'struct ce_task' pointers to sun8i_ce_cipher_{prepare,unprepare}. Signed-off-by: Ovidiu Panait --- .../allwinner/sun8i-ce/sun8i-ce-cipher.c | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c index f63d21cd1e52..021614b65e39 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -131,21 +131,19 @@ static int sun8i_ce_cipher_fallback(struct skcipher_request *areq) return err; } -static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req) +static int sun8i_ce_cipher_prepare(struct skcipher_request *areq, + struct ce_task *cet) { - struct skcipher_request *areq = container_of(async_req, struct skcipher_request, base); struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); struct sun8i_ce_dev *ce = op->ce; struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq); struct skcipher_alg *alg = crypto_skcipher_alg(tfm); struct sun8i_ce_alg_template *algt; - struct sun8i_ce_flow *chan; - struct ce_task *cet; struct scatterlist *sg; unsigned int todo, len, offset, ivsize; u32 common, sym; - int flow, i; + int i; int nr_sgs = 0; int nr_sgd = 0; int err = 0; @@ -163,14 +161,9 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG)) algt->stat_req++; - flow = rctx->flow; - - chan = &ce->chanlist[flow]; - - cet = chan->tl; memset(cet, 0, sizeof(struct ce_task)); - cet->t_id = cpu_to_le32(flow); + cet->t_id = cpu_to_le32(rctx->flow); common = ce->variant->alg_cipher[algt->ce_algo_id]; common |= rctx->op_dir | CE_COMM_INT; cet->t_common_ctl = cpu_to_le32(common); @@ -314,24 +307,17 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req return err; } -static void sun8i_ce_cipher_unprepare(struct crypto_engine *engine, - void *async_req) +static void sun8i_ce_cipher_unprepare(struct skcipher_request *areq, + struct ce_task *cet) { - struct skcipher_request *areq = container_of(async_req, struct skcipher_request, base); struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); struct sun8i_ce_dev *ce = op->ce; struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq); - struct sun8i_ce_flow *chan; - struct ce_task *cet; unsigned int ivsize, offset; int nr_sgs = rctx->nr_sgs; int nr_sgd = rctx->nr_sgd; - int flow; - flow = rctx->flow; - chan = &ce->chanlist[flow]; - cet = chan->tl; ivsize = crypto_skcipher_ivsize(tfm); if (areq->src == areq->dst) { @@ -367,16 +353,19 @@ int sun8i_ce_cipher_do_one(struct crypto_engine *engine, void *areq) struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); struct sun8i_cipher_tfm_ctx *ctx = crypto_skcipher_ctx(tfm); struct sun8i_ce_dev *ce = ctx->ce; + struct sun8i_ce_flow *chan; int err; - err = sun8i_ce_cipher_prepare(engine, areq); + chan = &ce->chanlist[rctx->flow]; + + err = sun8i_ce_cipher_prepare(req, chan->tl); if (err) return err; err = sun8i_ce_run_task(ce, rctx->flow, crypto_tfm_alg_name(req->base.tfm)); - sun8i_ce_cipher_unprepare(engine, areq); + sun8i_ce_cipher_unprepare(req, chan->tl); local_bh_disable(); crypto_finalize_skcipher_request(engine, req, err); From patchwork Tue Sep 2 13:21:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1096 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08D9430DD1A for ; Tue, 2 Sep 2025 13:23:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819389; cv=none; b=MZwK1Fndqa/BEbky4UMF6YS04cSbo5Z8KPPWvbGU6hCApuaPwsNosTTkCuQycaiylMNovs3WJPQGenCwiorvrX8W6cW8DAo4eFZh4DlT879aqLo/RluheroosSetpv+6VKOj01VqEJHo51horSacW62PSlrLKNkGR474l8UK8KY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819389; c=relaxed/simple; bh=iUJf2ME5JPBKyPRHHiEIhLOkEFHThzgikx7ZYRJssN4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j6OCtxn9+FC0PY/aKYLbxc6d3OopgEkf8ZQIwSzaiQgLaXrffK4NTfM+RAbrkqPZHecb0NRmhhhnYhr50IH7dp39oL9CPi+V0XUaIRJJh17Mjv2D05Nnx1lrba8ubUqHLbwUc5pJZZre+2Pq5p8ncbRywxG4yzf69D8mGm0F3LQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gYQue74p; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gYQue74p" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-45b627ea685so45733465e9.1 for ; Tue, 02 Sep 2025 06:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756819385; x=1757424185; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Brl2BLRMH8dw6ZRRE0AMqdemVZpKH9vXc+oBuQmErPs=; b=gYQue74pciXQg2kms4SRquFfSNyC1KinkKMgGKfQKeTSfYEmFLqbHTghyTrcXkCl4p oBqCsAkhkkW3LIqjiQkFMi20tQD+oxrb+HwNIffL0lYXZywAkout0cctPl8Xgi7goBtL oD/9+bKn8jJ83Zz638HFlfc5gwSDTpOZLvB+465LS7tjwQvDAEGUCSPGUUCGA/OjX5Vr w5dZ3R4iMhchkOG3BqLIfNXINj8nmrdGAitTiegrAHzm+SHpWN+NoQ+LDcUykA/V1qJV TqooGUWMkhubGV5zCCbt4zAnAXsb2/5+uUGnf4eFdUII0izQLKG/LpcmZfw0SWAaq2wS UAPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756819385; x=1757424185; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Brl2BLRMH8dw6ZRRE0AMqdemVZpKH9vXc+oBuQmErPs=; b=T7CPEMIi3hMqW1IEgKg+fUqgI9Wdtrnt9aBFltCEt17FmL5W0qbLnvkgorDoHdTpmC fcVwWgSOjvlTlAYZUbLV+wIFHNj4Rub9N6slKAhe8rfjcMFVVA0whyFOmhWhn0MjPq6k U7psWJlyjqQekJFdW46EZ2triVYtLx55SJOnLFq3fxqwkNlkns9TnJHgjVmns++giVv6 JndfqwBdO4RG5e1OvfonqQ3JCtCx0cEnvRbB8F6y2xe3ze7FpTVWW1iaRcUFNGv8S7GN u82GsI+QiECLOHvdARv4mjWIpA9cOAGhVJqLorCP3eAV/E8fH4MxcGYnxHsMberEg7Rp SnfA== X-Forwarded-Encrypted: i=1; AJvYcCWwJ9z+y9C/X1/aOOQO/69mgu8MLfF2tuYqi99ocd63x28CAo9pFeSZWNauw6nQ45oKaUOtl+A/p2SVzg==@lists.linux.dev X-Gm-Message-State: AOJu0YypQI7rpcjWOpCW+2Zfsz/SfNvlJCYAS4+VPKipoE5N1pPCPBS+ aIS+o383ABydIMc5ZquSEDkc7iK05zZ6/aR1eug3t3LKpH32xj+v+ZXQ X-Gm-Gg: ASbGncuXteX7gINdbrj5shN/vklZM7pP/0gMG5pYOnpJF9fYkviMEizJVZgI167C5X5 YhPi9xtRFgm/Eq0GBFdYUkts2Yp2ElE/q0nwJaqqgbULeu+RBwojfoc+l2DZ9AO2njr2UunQb7C TCgOYg1S40YlAXoxJin/itYYqIIF+Ekd0OSXz/x7qWD+DgSk6UmKB19AOKOtJbx1hBCZDcncex+ XOCOPqnWwZJ1HBahTTITZLxdl9nBMTErgfYrf6FiXWeteH2C59Jex2qBXGVxza5IXBX88/uXgN5 M+FgV02jf9Jz06NWTtjRRrvHD8mc8X6tqJRpl11Zdin8Hc72eI1M40UHmxFCAGFXFV9/Gh4SwLq j8te5RInOJIuu9EKL7WI/OqItYVRPa1A5C859WF669RDswkk78SIMXTY= X-Google-Smtp-Source: AGHT+IHVGvsGBQGQkvMvtDDfpFtA8mIByGRDIA1JCKyDlAWmlLEu0KLDhiMCrW7Q3CDU6nE/Q0y2eQ== X-Received: by 2002:a05:600c:a41:b0:45b:627a:60cf with SMTP id 5b1f17b1804b1-45b8559b8edmr113456095e9.24.1756819385117; Tue, 02 Sep 2025 06:23:05 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:c207:b600:978:f6fa:583e:b091]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b945332adsm44452155e9.4.2025.09.02.06.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Sep 2025 06:23:04 -0700 (PDT) From: Ovidiu Panait To: clabbe.montjoie@gmail.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org Cc: wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Ovidiu Panait Subject: [PATCH v3 8/9] crypto: sun8i-ce - save hash buffers and dma info to request context Date: Tue, 2 Sep 2025 16:21:33 +0300 Message-ID: <20250902132134.3287515-9-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> References: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Status: O Similar to sun8i-ce skcipher code, move all request-specific data to request context. This simplifies sun8i_ce_hash_run() and it eliminates the remaining kmalloc() calls from the digest path. Since the 'result' buffer in the request ctx struct is used for from-device DMA, it needs to be properly aligned to CRYPTO_DMA_ALIGN. Therefore: - increase reqsize by CRYPTO_DMA_PADDING - add __aligned(CRYPTO_DMA_ALIGN) attribute for the 'result' buffer - convert all ahash_request_ctx_dma() calls to ahash_request_ctx_dma() Signed-off-by: Ovidiu Panait --- .../crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 77 ++++++++----------- drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h | 17 ++++ 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c index df2acef9c679..6573c566bd0d 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c @@ -58,7 +58,8 @@ int sun8i_ce_hash_init_tfm(struct crypto_ahash *tfm) crypto_ahash_set_reqsize(tfm, sizeof(struct sun8i_ce_hash_reqctx) + - crypto_ahash_reqsize(op->fallback_tfm)); + crypto_ahash_reqsize(op->fallback_tfm) + + CRYPTO_DMA_PADDING); if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG)) memcpy(algt->fbname, @@ -84,7 +85,7 @@ void sun8i_ce_hash_exit_tfm(struct crypto_ahash *tfm) int sun8i_ce_hash_init(struct ahash_request *areq) { - struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx(areq); + struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx_dma(areq); struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); struct sun8i_ce_hash_tfm_ctx *tfmctx = crypto_ahash_ctx(tfm); @@ -100,7 +101,7 @@ int sun8i_ce_hash_init(struct ahash_request *areq) int sun8i_ce_hash_export(struct ahash_request *areq, void *out) { - struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx(areq); + struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx_dma(areq); struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); struct sun8i_ce_hash_tfm_ctx *tfmctx = crypto_ahash_ctx(tfm); @@ -114,7 +115,7 @@ int sun8i_ce_hash_export(struct ahash_request *areq, void *out) int sun8i_ce_hash_import(struct ahash_request *areq, const void *in) { - struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx(areq); + struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx_dma(areq); struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); struct sun8i_ce_hash_tfm_ctx *tfmctx = crypto_ahash_ctx(tfm); @@ -128,7 +129,7 @@ int sun8i_ce_hash_import(struct ahash_request *areq, const void *in) int sun8i_ce_hash_final(struct ahash_request *areq) { - struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx(areq); + struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx_dma(areq); struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); struct sun8i_ce_hash_tfm_ctx *tfmctx = crypto_ahash_ctx(tfm); @@ -145,7 +146,7 @@ int sun8i_ce_hash_final(struct ahash_request *areq) int sun8i_ce_hash_update(struct ahash_request *areq) { - struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx(areq); + struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx_dma(areq); struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); struct sun8i_ce_hash_tfm_ctx *tfmctx = crypto_ahash_ctx(tfm); @@ -160,7 +161,7 @@ int sun8i_ce_hash_update(struct ahash_request *areq) int sun8i_ce_hash_finup(struct ahash_request *areq) { - struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx(areq); + struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx_dma(areq); struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); struct sun8i_ce_hash_tfm_ctx *tfmctx = crypto_ahash_ctx(tfm); @@ -178,7 +179,7 @@ int sun8i_ce_hash_finup(struct ahash_request *areq) static int sun8i_ce_hash_digest_fb(struct ahash_request *areq) { - struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx(areq); + struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx_dma(areq); struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); struct sun8i_ce_hash_tfm_ctx *tfmctx = crypto_ahash_ctx(tfm); @@ -239,7 +240,7 @@ int sun8i_ce_hash_digest(struct ahash_request *areq) { struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); struct sun8i_ce_hash_tfm_ctx *ctx = crypto_ahash_ctx(tfm); - struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx(areq); + struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx_dma(areq); struct sun8i_ce_dev *ce = ctx->ce; struct crypto_engine *engine; int e; @@ -317,7 +318,7 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) struct ahash_request *areq = container_of(breq, struct ahash_request, base); struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); struct ahash_alg *alg = __crypto_ahash_alg(tfm->base.__crt_alg); - struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx(areq); + struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx_dma(areq); struct sun8i_ce_alg_template *algt; struct sun8i_ce_dev *ce; struct sun8i_ce_flow *chan; @@ -328,12 +329,9 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) u32 common; u64 byte_count; __le32 *bf; - void *buf, *result; int j, i, todo; u64 bs; int digestsize; - dma_addr_t addr_res, addr_pad; - int ns = sg_nents_for_len(areq->src, areq->nbytes); algt = container_of(alg, struct sun8i_ce_alg_template, alg.hash.base); ce = algt->ce; @@ -345,19 +343,7 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) if (digestsize == SHA384_DIGEST_SIZE) digestsize = SHA512_DIGEST_SIZE; - /* the padding could be up to two block. */ - buf = kcalloc(2, bs, GFP_KERNEL | GFP_DMA); - if (!buf) { - err = -ENOMEM; - goto err_out; - } - bf = (__le32 *)buf; - - result = kzalloc(digestsize, GFP_KERNEL | GFP_DMA); - if (!result) { - err = -ENOMEM; - goto err_free_buf; - } + bf = (__le32 *)rctx->pad; flow = rctx->flow; chan = &ce->chanlist[flow]; @@ -378,11 +364,12 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) cet->t_sym_ctl = 0; cet->t_asym_ctl = 0; - nr_sgs = dma_map_sg(ce->dev, areq->src, ns, DMA_TO_DEVICE); + rctx->nr_sgs = sg_nents_for_len(areq->src, areq->nbytes); + nr_sgs = dma_map_sg(ce->dev, areq->src, rctx->nr_sgs, DMA_TO_DEVICE); if (nr_sgs <= 0 || nr_sgs > MAX_SG) { dev_err(ce->dev, "Invalid sg number %d\n", nr_sgs); err = -EINVAL; - goto err_free_result; + goto err_out; } len = areq->nbytes; @@ -397,10 +384,13 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) err = -EINVAL; goto err_unmap_src; } - addr_res = dma_map_single(ce->dev, result, digestsize, DMA_FROM_DEVICE); - cet->t_dst[0].addr = desc_addr_val_le32(ce, addr_res); - cet->t_dst[0].len = cpu_to_le32(digestsize / 4); - if (dma_mapping_error(ce->dev, addr_res)) { + + rctx->result_len = digestsize; + rctx->addr_res = dma_map_single(ce->dev, rctx->result, rctx->result_len, + DMA_FROM_DEVICE); + cet->t_dst[0].addr = desc_addr_val_le32(ce, rctx->addr_res); + cet->t_dst[0].len = cpu_to_le32(rctx->result_len / 4); + if (dma_mapping_error(ce->dev, rctx->addr_res)) { dev_err(ce->dev, "DMA map dest\n"); err = -EINVAL; goto err_unmap_src; @@ -428,10 +418,12 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) goto err_unmap_result; } - addr_pad = dma_map_single(ce->dev, buf, j * 4, DMA_TO_DEVICE); - cet->t_src[i].addr = desc_addr_val_le32(ce, addr_pad); + rctx->pad_len = j * 4; + rctx->addr_pad = dma_map_single(ce->dev, rctx->pad, rctx->pad_len, + DMA_TO_DEVICE); + cet->t_src[i].addr = desc_addr_val_le32(ce, rctx->addr_pad); cet->t_src[i].len = cpu_to_le32(j); - if (dma_mapping_error(ce->dev, addr_pad)) { + if (dma_mapping_error(ce->dev, rctx->addr_pad)) { dev_err(ce->dev, "DMA error on padding SG\n"); err = -EINVAL; goto err_unmap_result; @@ -444,21 +436,16 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) err = sun8i_ce_run_task(ce, flow, crypto_ahash_alg_name(tfm)); - dma_unmap_single(ce->dev, addr_pad, j * 4, DMA_TO_DEVICE); + dma_unmap_single(ce->dev, rctx->addr_pad, rctx->pad_len, DMA_TO_DEVICE); err_unmap_result: - dma_unmap_single(ce->dev, addr_res, digestsize, DMA_FROM_DEVICE); + dma_unmap_single(ce->dev, rctx->addr_res, rctx->result_len, + DMA_FROM_DEVICE); if (!err) - memcpy(areq->result, result, crypto_ahash_digestsize(tfm)); + memcpy(areq->result, rctx->result, crypto_ahash_digestsize(tfm)); err_unmap_src: - dma_unmap_sg(ce->dev, areq->src, ns, DMA_TO_DEVICE); - -err_free_result: - kfree(result); - -err_free_buf: - kfree(buf); + dma_unmap_sg(ce->dev, areq->src, rctx->nr_sgs, DMA_TO_DEVICE); err_out: local_bh_disable(); diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h index de3a096c476c..71f5a0cd3d45 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h @@ -110,6 +110,9 @@ #define MAXFLOW 4 +#define CE_MAX_HASH_DIGEST_SIZE SHA512_DIGEST_SIZE +#define CE_MAX_HASH_BLOCK_SIZE SHA512_BLOCK_SIZE + /* * struct ce_clock - Describe clocks used by sun8i-ce * @name: Name of clock needed by this variant @@ -304,9 +307,23 @@ struct sun8i_ce_hash_tfm_ctx { * struct sun8i_ce_hash_reqctx - context for an ahash request * @fallback_req: pre-allocated fallback request * @flow: the flow to use for this request + * @nr_sgs: number of entries in the source scatterlist + * @result_len: result length in bytes + * @pad_len: padding length in bytes + * @addr_res: DMA address of the result buffer, returned by dma_map_single() + * @addr_pad: DMA address of the padding buffer, returned by dma_map_single() + * @result: per-request result buffer + * @pad: per-request padding buffer (up to 2 blocks) */ struct sun8i_ce_hash_reqctx { int flow; + int nr_sgs; + size_t result_len; + size_t pad_len; + dma_addr_t addr_res; + dma_addr_t addr_pad; + u8 result[CE_MAX_HASH_DIGEST_SIZE] __aligned(CRYPTO_DMA_ALIGN); + u8 pad[2 * CE_MAX_HASH_BLOCK_SIZE]; struct ahash_request fallback_req; // keep at the end }; From patchwork Tue Sep 2 13:21:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1095 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34CC230E0F2 for ; Tue, 2 Sep 2025 13:23:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819390; cv=none; b=FncQAF+5I37LNSkU1rWWz7c72VM5v4eOY7MUnxoEDi+ah9M4yUmjmcvVQ1dkjpDcREGX6wysRQAwa8Rzm0HUKAK7AM5vDoI/X/YLJVM4PTkjJB8STQNX93u7/ZqrKj169YaZ6j64LkNoSaeLV7o+X7Ffxj87NB+QfzeZeb0za8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756819390; c=relaxed/simple; bh=pi1l7opJu00vs6MD7nSWkMq1KZSzvh++I4qQ67bTi2k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X8kB91O/s09dbkxNxRg7rqeSSeHWUqEWqqhDE/+vTYduWi1wDw+T0bAZa4N9UY9EmqaXWIxQozMI5BjOzP9jQn25TS9VjE/OF7TBkm+LIDLkSMofCpeo3zWecmRPnrC6fTQ30xyx6Ds2RzX368k7N4DaIz9V6cP1qNmwlcok8d0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MjifqFq6; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MjifqFq6" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-3d0b6008a8bso2111015f8f.0 for ; Tue, 02 Sep 2025 06:23:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756819386; x=1757424186; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J+zU65F7Gerz/ADwaQ8W/yEAgtxRKhLtaag+pELJ150=; b=MjifqFq6ijINrKQiwRF+LP1CAlvrN3efJND/9w5Qd1VduWekcSbi+94fuXJaZ3zTJE rlQ52VbVch6Hw6dye3l5tsoDiuNPMxBSbNNNWZaUniBTluywMCp2eZRGXPPl0kZSrMCS mkLPsNVJrUKaF4ngrM7/2JT2FYeZfI3jZL2ZFwR0n0FYX61DLS0stUHOv8QcrJCTHVFK z5IpFa4ilFZ2QWXYMtVe6LlnZKugAJ4CU1N22URVeFbSk2yomY8HfTGP4cCNdIkR6ZZv Z94J49sdQFUrTUxIrPqNFbkE1iXT4Btk5x7o7zeqKvtnSRf7h1JAQM8YciqeQ3JBtana F1FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756819386; x=1757424186; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J+zU65F7Gerz/ADwaQ8W/yEAgtxRKhLtaag+pELJ150=; b=lJ8LvZdCX/Rpm59kklkj3t20ZzjiR01eXxVHk1uH7AcULdQRC+yprF0oY/C9DwZbGi otaF2lEbw9YFNOAGi/1uaNicfxIgubjuri57QLDqMzY5/2RbSFDeeWNTz83IPj2Mcvg7 d/EvHn2bgC04e3L/BY8pjOPomDi/crITj+amrr/cTGLmbz/Yid2Ynpsjg90y/++CxILZ jF+MqEAABJ8JZdcr20uxGQFJeFqsEre26G/vI1a9iFttnM2740MhwRDT2JcWq9jfxyjf qunSOvbB/x1YBZjLT4se+LEg/Ef7YxKDQnYG4Pz/XqR+nPDb1QseaAshO9mr6wDMAh/3 ArrA== X-Forwarded-Encrypted: i=1; AJvYcCXYUp1fMU9w2yTezbN2VnjWOWZOgQG2SDtMEAczBSUs3bbVyms639qgPw5k4DA9umzypea1OEi66W/qQA==@lists.linux.dev X-Gm-Message-State: AOJu0YyVZMrzn+aPjGbWKpRUzPD8ALw8x3zQbCWEV4CUKKjl9PR625H+ hPEosOgE2hcHUcB9NnQPkKzy6PS929eu0yESB0hXS6hUzycAENY3qKXY X-Gm-Gg: ASbGncsPl5EDTZlEnt3IT7N+7fuyxxY5O5QODsQ5TPp73+gRahlTgnraeb/0GX5R39r Mvi52pR9u4+ZieUG/buXhEbOvE28NH8WguRVqrLwxYyZS5t3wirWGmDrZi/PCxstiDoLH6SKScK 5E4kYUfMPgI8L71vFsXoVIMcSCifW3X17P6et815CQp/Y0dOVZP8pL5MqRwz3mcpWVDD1M2B8Kz G2uHEHnq6H3vKZAeSLWfdw4UQM7JeHByNnHxktMRt/Tk8sQgGo1AXlWliMp9nAGmcHmpdqdQOzR IBQmgTpZoZgFyUY1R/rxCR5Kuhl+MWE8mCzIEo8StzLva1DLZXRDMh0ofiH3jHmvyJYa9JFIBgI 7xtXVU8pa97LkG9J/E8W9/Yu8CFge4MZpKkMcBNYPD5ni X-Google-Smtp-Source: AGHT+IGEIroq02nSpRHx0vFtxRxr9TNdfsRxwLjDOb7ndAqqFPycS5qCf/jnA7MepquM0G+zsISS8Q== X-Received: by 2002:a05:6000:2281:b0:3ca:83e2:6339 with SMTP id ffacd0b85a97d-3d1e02cb35fmr8305578f8f.49.1756819386400; Tue, 02 Sep 2025 06:23:06 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:c207:b600:978:f6fa:583e:b091]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b945332adsm44452155e9.4.2025.09.02.06.23.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Sep 2025 06:23:06 -0700 (PDT) From: Ovidiu Panait To: clabbe.montjoie@gmail.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org Cc: wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Ovidiu Panait Subject: [PATCH v3 9/9] crytpo: sun8i-ce - factor out prepare/unprepare from sun8i_ce_hash_run() Date: Tue, 2 Sep 2025 16:21:34 +0300 Message-ID: <20250902132134.3287515-10-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> References: <20250902132134.3287515-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Status: O In order to make the ahash code more clear and modular, split the monolithic sun8i_ce_hash_run() callback into two parts, prepare and unprepare (therefore aligning it with the sun8i-ce skcipher code). Signed-off-by: Ovidiu Panait --- .../crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 62 ++++++++++++++----- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c index 6573c566bd0d..d01594353d9a 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c @@ -313,18 +313,15 @@ static u64 hash_pad(__le32 *buf, unsigned int bufsize, u64 padi, u64 byte_count, return j; } -int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) +static int sun8i_ce_hash_prepare(struct ahash_request *areq, struct ce_task *cet) { - struct ahash_request *areq = container_of(breq, struct ahash_request, base); struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); struct ahash_alg *alg = __crypto_ahash_alg(tfm->base.__crt_alg); struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx_dma(areq); struct sun8i_ce_alg_template *algt; struct sun8i_ce_dev *ce; - struct sun8i_ce_flow *chan; - struct ce_task *cet; struct scatterlist *sg; - int nr_sgs, flow, err; + int nr_sgs, err; unsigned int len; u32 common; u64 byte_count; @@ -345,18 +342,14 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) bf = (__le32 *)rctx->pad; - flow = rctx->flow; - chan = &ce->chanlist[flow]; - if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG)) algt->stat_req++; dev_dbg(ce->dev, "%s %s len=%d\n", __func__, crypto_tfm_alg_name(areq->base.tfm), areq->nbytes); - cet = chan->tl; memset(cet, 0, sizeof(struct ce_task)); - cet->t_id = cpu_to_le32(flow); + cet->t_id = cpu_to_le32(rctx->flow); common = ce->variant->alg_hash[algt->ce_algo_id]; common |= CE_COMM_INT; cet->t_common_ctl = cpu_to_le32(common); @@ -434,22 +427,59 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) else cet->t_dlen = cpu_to_le32(areq->nbytes / 4 + j); - err = sun8i_ce_run_task(ce, flow, crypto_ahash_alg_name(tfm)); - - dma_unmap_single(ce->dev, rctx->addr_pad, rctx->pad_len, DMA_TO_DEVICE); + return 0; err_unmap_result: dma_unmap_single(ce->dev, rctx->addr_res, rctx->result_len, DMA_FROM_DEVICE); - if (!err) - memcpy(areq->result, rctx->result, crypto_ahash_digestsize(tfm)); err_unmap_src: dma_unmap_sg(ce->dev, areq->src, rctx->nr_sgs, DMA_TO_DEVICE); err_out: + return err; +} + +static void sun8i_ce_hash_unprepare(struct ahash_request *areq, + struct ce_task *cet) +{ + struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx_dma(areq); + struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); + struct sun8i_ce_hash_tfm_ctx *ctx = crypto_ahash_ctx(tfm); + struct sun8i_ce_dev *ce = ctx->ce; + + dma_unmap_single(ce->dev, rctx->addr_pad, rctx->pad_len, DMA_TO_DEVICE); + dma_unmap_single(ce->dev, rctx->addr_res, rctx->result_len, + DMA_FROM_DEVICE); + dma_unmap_sg(ce->dev, areq->src, rctx->nr_sgs, DMA_TO_DEVICE); +} + +int sun8i_ce_hash_run(struct crypto_engine *engine, void *async_req) +{ + struct ahash_request *areq = ahash_request_cast(async_req); + struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); + struct sun8i_ce_hash_tfm_ctx *ctx = crypto_ahash_ctx(tfm); + struct sun8i_ce_hash_reqctx *rctx = ahash_request_ctx_dma(areq); + struct sun8i_ce_dev *ce = ctx->ce; + struct sun8i_ce_flow *chan; + int err; + + chan = &ce->chanlist[rctx->flow]; + + err = sun8i_ce_hash_prepare(areq, chan->tl); + if (err) + return err; + + err = sun8i_ce_run_task(ce, rctx->flow, crypto_ahash_alg_name(tfm)); + + sun8i_ce_hash_unprepare(areq, chan->tl); + + if (!err) + memcpy(areq->result, rctx->result, + crypto_ahash_digestsize(tfm)); + local_bh_disable(); - crypto_finalize_hash_request(engine, breq, err); + crypto_finalize_hash_request(engine, async_req, err); local_bh_enable(); return 0;