From patchwork Mon Jul 28 06:06:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1362 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 391D521CFFD for ; Mon, 28 Jul 2025 06:07:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753682879; cv=none; b=R92ElWQpo1V1Gnnb5dsIHPQt8yuyfGdxWN+SK9EoBhX/7UD6uRAFfal6fHYR6LBDKLyK/dPAWag0+xg4maDkc+wyUImhGVLKv8LPbCpnXMbmzYfoiOD5hy6yKf3tIhTgd6gfzudbX3rBXaAxMfA7eK2ZS+mfNAuRAqEzn/863bU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753682879; c=relaxed/simple; bh=JhryCQPIHZMBHN4Dh3iGOODDbabwR0S+i4gukSM6ud0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rPUGZ8vbP1iuZRnBlMFr6BrNjSMS+k0seUeRiYD6D8GZBt0u7LtdyrojIG244po5M2K/vex+rmFnHR7i/MGXDoFaLrr57xfOa3wtoHfBHtSf4rkotmCxWCSJxMj/uqa9ltI1FMghAPgq/v0A3etHfj4pliyIrYj3b9ShAAJj5hg= 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=OMTzDbJN; arc=none smtp.client-ip=209.85.128.49 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="OMTzDbJN" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-451d3f72391so37784865e9.3 for ; Sun, 27 Jul 2025 23:07:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753682875; x=1754287675; 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=OMTzDbJNucLTz7lvUNOvmEPMAwoa6l1ofu0TT9KlEBUOG6e3BBZsgv/EMGNhZy2/+C x8m3MHdNxCJeEFoALUmr2FkFRzCu8uL7hruwHGRZR72RH+HC/xjhRHtvPIK2ktclLK/2 V6zeZKPJAfMd1VfGDdevG+mEGDim82E7N6M8M/gANY1MoPZpQSY0nn1uEdHbAJOdni7w 05g0uoxiOna8NFLWXL2jpFPQJfGAloH3IdmI3uUE/DkMZ3gSyZyf8EwN35BLqS+SCg7u x4EEcKKUeAeqpcdxRuNOiQMOCl3yfZlB3NMfpJOLYWxOsx5ANyorPofsuc3tZPNQZ/JB MSYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753682875; x=1754287675; 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=j0Yq6dnjn9x0saiisarixVtkGiL+xu2X1DgEce/RoICv0HQpFF6/E1oKeYlvgjimhE GsR4R+anPN8GzkAtzhzAM3+FbD6ctP6iEbZeb7yju2IfSJxLS1wxG5lTsuaZAtFLI9CI 5rw2E2ekGeMGkOTc1Y54Xl3G7RhR3F3uSfY95f1Tqudhu9IMyCj1eLsktkpZn1cTSQw9 bR0f4mD91lozGU9w8NZpMjAUhb8Gk0wKeRsnU9Bx39vCi6cVjqHRrSWFXj6qpbzE3NaY YbpFlAM06V59F0srRBEPYSpIUZm6Us+J+vK2a5qTRTqRCo10YlgVciQrFbrEEJgGfy20 N1CQ== X-Forwarded-Encrypted: i=1; AJvYcCXeo0+AfnnuDoafwlkpM/JvARp8eimQgQ9b5US490J7DYsTEiN2jrIsB47BucZGbzk/eijcBD9x8VNEpQ==@lists.linux.dev X-Gm-Message-State: AOJu0YwLORtBktPYIgoZgIrczzK60fOeWZ46PHSq0V/3lfow/YBbCfMI OQdPrJ9CFj+MSagOeIU1xjEMuxoEf40em2mXnSwKOCo5YeuwTNbqHjoT X-Gm-Gg: ASbGncshrEcBX5eYGzxJ7wUdCa0x//+5qNo0DSIXXpw7I/EH1tg5UZ/pN7xrGh4/m0K AEffG9mGRvOvoDBOl7cb9XuogTv5ZMSrwPHECOBBfInj5WbzajXIw29/VtzmmY3Kk1vXlXbSW1L rzHzyYPuoVYfemPSygOQyqJOCICDUbj6RN5lP2rRBxC6SeVyDgErCwFQ2MX572aAsaRcJwLdE/5 i7w5yR2sG4iqcF7MGake40wnr2Vfljw/D59ilK8eDV7uZD1RWDjchCf6hEj9iSBkSS2tw8nB9UP GXpBIjv1VVzYDCpHnoGIlcs1GpL7wlY8IGwsSauFJgMEVjzjuxfCFGBw828CbiKtjiTEComg0Ol bKt5XamTL12MhOS/FSySERbDY1A9UATRD4g== X-Google-Smtp-Source: AGHT+IHqPCaG3R/59IYXjBcGJJCe3DhN/AsfRtBjv+Iqv+7bPs2nkDA/DLavuu+09pT2v/lTOUM3GA== X-Received: by 2002:a05:600c:8b11:b0:456:1d34:97a with SMTP id 5b1f17b1804b1-4587631561fmr92141855e9.9.1753682875203; Sun, 27 Jul 2025 23:07:55 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:ca0d:f700:1210:b727:adc8:716]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587abe6ba0sm86195215e9.9.2025.07.27.23.07.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 23:07:54 -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 1/9] crypto: sun8i-ce - remove channel timeout field Date: Mon, 28 Jul 2025 09:06:53 +0300 Message-ID: <20250728060701.1787607-2-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250728060701.1787607-1-ovidiu.panait.oss@gmail.com> References: <20250728060701.1787607-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 Mon Jul 28 06:06:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1361 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 4F72E22126A for ; Mon, 28 Jul 2025 06:07: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=1753682879; cv=none; b=gTzlymWWtoogVxTWtNiGw63yZBGTIGLHKrX/DtmJVp2SqUYNV2uu55VIv47ije97NWhgHTGB84Oy1u48gGNFVQxV1zXydNbskwDuT9M2h5c0q2CraazUbLcZ3inYUa2kk0cGEnYhy40lIP4DvfopDCzOWeHRXtEwioOFQoSqJ74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753682879; c=relaxed/simple; bh=kyASvvV0C6502P156s4uvhgiJ2anCkqmkQU+DPnmJLM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QTpHj/qZXCqbs7PVIBXQzTMY1a6JMNB3VvVP0JrHqVH6LOc6ktXYg1zDUa1yCLuY5Plkh2z7Xgxp4fFsjRokNmTifFpi+eNn1vHhSdIeQVuy+4WdRtiLFtltijiWy9NFa6pUof4PMDaXjjVR5OHnJa4EbJMLmys7OEmYs+R3AJw= 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=gtL9AXFF; 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="gtL9AXFF" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-454f428038eso35349605e9.2 for ; Sun, 27 Jul 2025 23:07:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753682877; x=1754287677; 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=gtL9AXFFj+ZVvoIBXQ9FHSQELfXYdby47PsFJ3Q/wzEAz5u5VzDInUduO6NoAPb9+2 c8AgZZ7RfCOlenJSB7fUWKQgHhlmRnQVMXL5dywRFmQerHSMMaYwndEuUcqAP1IwUQaf 9ydCB8vUwuS2QDBffLH1QgU/n8c/yzeRodbvzBVv7XtFt0ieKLgIC0J1nho+6AHMnJgf LpmAwDB9nlwsLDNgKHtEs5o74iRDkU7jvg6jkSh+QlV51t/XNoq7Lh1LeTb833NY9K7P gVI8uZiNhqyqbEXhTT9GKqgUQS/Czm/ivf7vrRA6BKNX6rY1TXht/kTwD2rQK0G4pv8Z az5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753682877; x=1754287677; 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=DM1BjNyQBh2W//BAo0lcL51Qh7X6+nsxnRjSzTKT4Q2cbi+bYlFLRNqiDXYz63+MXV QS/MkYVthN7P4smwOUG8p+XoCd+GAg07oo1T3F79P5FFR26d9A64dkpzs9rGlBq4D5DB 8tl7flzY4o5gdZKeUDfWii+Jpm42KxZr5ypm3K/r87X2LDhLuanxzz6pqxwx910cO2p5 pvpqN5C04YZGMVyXzcDLSUb48uHmjHsoLxn/bId5qIVAJmRNx/6BiPfZRXm7AnYiv/k3 497bk4L2BeiN3MpeNqqCZQLp25cJNAaMYNJM/zxvVxqK2aOflFuVQKJvGvxHauXB4gj0 hKYw== X-Forwarded-Encrypted: i=1; AJvYcCXkdb27ZpHVlQQMyjcckFEMP8jG2M6rvXkYjUfuB1Hp7xMdHViK1JiYkvSxMNyWgZk+alpGLtikbS2QNA==@lists.linux.dev X-Gm-Message-State: AOJu0YxbeLHqDeoATJC+0WEEFuh8pO/BNo8TenfFLj3xgA85ONvUPgSk lcHvj/nEY7aAuyE62Nu/7G+7g1YEwF4qvXOVfaUANzvHRjXISYRLLm7n X-Gm-Gg: ASbGncvOWQT4qvkHvjGu8J4Isx+GBOaviBwQWVv4sfK7FMelQ6aSKu5oGll3z/9YL2b EhlFKebkSZwoU9f9yXKxDhJ1TGPk3KVwtgDMqibXqR+Z2J+Wh8RT29AxssvHnjKW7XRuOS+Bp6L WMWtgP3Vu6lpwZc9oeQN63Pr5KuxpT+7v7j7onNv0xGyqSOPFSrzJp8CFtGavQ67Tj/ZLmqspwz PeJ7lbSZYfNrTHSgD5eMWApLlBMU1i5LVnK/APPq03gsD1CloR3IQ2QvZbh5iEGfQkLyOwqlccb u8sOPkT/BGKJft0tmaYkeLt6UTv7C9gk+lOt3BFssuHZWaeJQuCOVvT1VqmqetRNfEFfiIm2CL+ qrH5c3FhhOrxQWVIhcRh2dVC3ATACW1dIiA== X-Google-Smtp-Source: AGHT+IFJw3EbsUDLtQA1ecwg56WxcbMEO+eyP+FEUWh83ffWtoZBkFf3rr8tJhzBHJdAJ6osjr0sWQ== X-Received: by 2002:a05:600c:1e1d:b0:450:d4a6:799d with SMTP id 5b1f17b1804b1-45877445e1bmr70270965e9.7.1753682876514; Sun, 27 Jul 2025 23:07:56 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:ca0d:f700:1210:b727:adc8:716]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587abe6ba0sm86195215e9.9.2025.07.27.23.07.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 23:07:56 -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 2/9] crypto: sun8i-ce - remove boilerplate in sun8i_ce_hash_digest() Date: Mon, 28 Jul 2025 09:06:54 +0300 Message-ID: <20250728060701.1787607-3-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250728060701.1787607-1-ovidiu.panait.oss@gmail.com> References: <20250728060701.1787607-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 Mon Jul 28 06:06:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1360 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 C139C221FD8 for ; Mon, 28 Jul 2025 06:07:59 +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=1753682881; cv=none; b=c6uroRRJW8UdKrp0pSpqmuJ2SNuipV9we6eTQpLcWFeoESU+zMUIH8OEQfcIWgE8rsUtFp6msPAKyyGiNZQhi7jDBquRS3tDANwrrhLD1mUp5T/ptOCKdjrHy+EPsxaFJpruB7HQRsyuhwAEf33S/hD+G915BKp66LACWmo2WCo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753682881; c=relaxed/simple; bh=4zJMhQ+VcPBQ76ASBvFai/gasWQveJW54RMGe/zEYD0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CW9S8SIGF+xVgzgs2qsHg315m06tEqcplIWR+zIvcKzculXSky4LiAd5DQQM2FtGK2lRFuYHfBRRJ8cqPnvBHjbqOJO8h4C9ME1e6RWpNw1gp57L20njLHubr1AAIDO0EHwydj1560Se6PHc3BONvvzt/YsNc7EfT3j5JqlJow4= 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=R2Ocz7io; 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="R2Ocz7io" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-45555e3317aso19790325e9.3 for ; Sun, 27 Jul 2025 23:07:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753682878; x=1754287678; 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=j2K/bAbM7b4hD+UZ1sY7e2X2nlDeVKcJvl2Epy7suEc=; b=R2Ocz7io1ZKHaJIqtP9g9Ivkajz2JbH33/HgmYP5MY5Rm9YepitboO1tE3r1enV+ii 6RplyVn8P5GhGHNkKgoGipWhIqyNlXuxaJnW2BCugk41+avskFEhZhMxnFmRm5MtONX/ 7EHEkgMsEqXwoICRQfOSqkv/a8d4DQGqrdkqquOi+29cch844SC2q2Uv19FuK40dmAwU KB7iY7f73MZ4oZh8jN9LbuKwxKbpdS2i/2s0l0aIM8xur9i/F4Lxs9846dTBmVJqLBKP kGosp0qlQ+leF1RgR+qcsBHSQ5pLDbtfLrYRkFx5XqYLj9f2TeBW3z0p9XPHHqWD6gaT E3Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753682878; x=1754287678; 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=j2K/bAbM7b4hD+UZ1sY7e2X2nlDeVKcJvl2Epy7suEc=; b=PKlMYtts8YUYWtYbmoBLMqs83jw3eMgGAMnNx/oMX2Nuz+E1avhwA9DMC8xpcIX+S2 2ZCmNcxxWtlyum0qf9aJStjOa2KytQZ0qtVgDSWQ0Q5OZrPe2diLaPD2GsCSREjnaAso zKOJ8ufFvTjgNKOT8m1HEFinMAaNaZvJqHmB+767F1wsMfU0dAKuVL3Da8QjwEqQsuHM G6GrQ9+dcif2r5XYGcHT7jmcLc3SLYztQUF0aA7bsGbN8KkYuv+F4XTvNhgKWmLbf/PP nMwE6YhaDSjJXUltFjZ6ok7JJkQI0DAI+XSWS1eBPKMyYi7z0zZtYVqrH4U5ZRNNMcyn EbuA== X-Forwarded-Encrypted: i=1; AJvYcCXUlzyOoEVYgspBwtt6HJWtooSJTX+RwYFUsW4WwvKMU5HTeYMM8Ek1yFL+DzUillHwvxk7IYrIqt7x4Q==@lists.linux.dev X-Gm-Message-State: AOJu0YzexZDELh+f6IL2AKqenOeyB4s24Z50uqVaH/u6o2LvX8RfIm9C uL5KlFSleAUdJOi65xiS7VwGVsdX7ilaWGztQWZvzkk7EB2BoHqzIe3M X-Gm-Gg: ASbGncs1prnXY8/luKnTvnDo1oJTk37XwtOI0Yv0PCtRBuGbO0Ks6P5/DTWDn801G/3 LxdSaSLyZaIU6IV9D5mFD38Xgo4i61pl28izKnjVF56lGcXC4L0kyalBPCICz9fDleqG1FCaxlZ 8O0kHwZ5L7rCaQ8brvGLpVohUIeBmIeu6ucnLtZrJC0hDLCr/PQsn6QeIAYJjNaoOqnIjsH1p0e W6Ol2j1stLsLgEevSYMHBwVjd1xpyGWGmccAjA0R6RD+adidIT1LEI4O7Ek7xCP+j2W54FEBgQb NOj2Ah8sCDW9bThKx7Vfj2LD+TZK4VtELvczPOKBNh7Aw+2XQHfYVYQdgAL50mb9iPA/XYHpBU5 8rKF9lPZTDFkEAqn7ND7HoWWNMhzmrE8A0A== X-Google-Smtp-Source: AGHT+IES0WVeYiOQzgvF9uZ/F/ZuRvB9DCBVa5KoIGMgW6lVQFOUgMPsAT/Es0z6LGY/i4jb9SI8lQ== X-Received: by 2002:a05:600c:1d1e:b0:456:3b21:ad1e with SMTP id 5b1f17b1804b1-45876442799mr90886165e9.17.1753682877810; Sun, 27 Jul 2025 23:07:57 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:ca0d:f700:1210:b727:adc8:716]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587abe6ba0sm86195215e9.9.2025.07.27.23.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 23:07: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 3/9] crypto: sun8i-ce - remove unnecessary __maybe_unused annotations Date: Mon, 28 Jul 2025 09:06:55 +0300 Message-ID: <20250728060701.1787607-4-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250728060701.1787607-1-ovidiu.panait.oss@gmail.com> References: <20250728060701.1787607-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 4 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 | 4 ++-- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 2 +- 3 files changed, 4 insertions(+), 4 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..326d9c988bb1 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c @@ -1062,8 +1062,8 @@ 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_stats __maybe_unused; + struct dentry *dbgfs_dir; + struct dentry *dbgfs_stats; /* Ignore error of debugfs */ dbgfs_dir = debugfs_create_dir("sun8i-ce", NULL); 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 Mon Jul 28 06:06:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1359 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 048672248BF for ; Mon, 28 Jul 2025 06:08:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753682884; cv=none; b=LLjLYX4TwwdDw4HUiE/emskmN6ORLYenJmpADhsoJKXAgsJSq0eeoLhWEAhxRRkcMg0PJq8Cfxuw3rPW+REikqI1yxe5hHD8nq6xBp8gKA4fwQdrHl1UKuCMIBF9jZNe3oMNjIgbWTz+ILwEuvjxAjAM5uLUi0sCTf+A11P+aoc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753682884; c=relaxed/simple; bh=b3yfadSxlQTuuUjecZzGWQXT1ppEt7Mr1bmdx41N2Jk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=slzvNyfapd+XpZG5HiLIOeU1FZPWMRgknPYx6Wd2V3oQh7FkLcsjC2sCctIFZfptm8mX0vAZzPI9YDLJwmY+rQXWB9IKcmXFNA8OL9bo+f7xeLhkXOsgOZ3EgaNR7N7kt4gLVbwUKIJkjIVG78YTD+EVAnsso1MGNMMaSUGfgQc= 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=a+fsV4U9; arc=none smtp.client-ip=209.85.128.46 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="a+fsV4U9" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4561514c7f0so39360605e9.0 for ; Sun, 27 Jul 2025 23:08:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753682879; x=1754287679; 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=eJtO1nuKB/731gs+IWxyxQBo+tSaie/TO/30jHleAGw=; b=a+fsV4U94b0BF3FWYU6KBaBK9+wfXqAvQ8WrYyvuhI1mcQ3OVhoo/aMZt+1o9tcgxX iozHWNbLZQAhsnbKGwSRA5Yyn/t2Yo9SpKEAn5JZqUzC49Dr9C+qgTpwt+P9XEIy+3eo QirdCMI4IhzMeNkFXyHvLKshE1Xl0K8vSeqn3F3rIkMXCFSgI5btCV8ZDVE8iSE2NanA 9/R40EloP/wO4EcsmqU3MmU9WC0/J/Cz25l6T9CwcmhYbLo0WGYGxzWQIaMxPTX9ppiD qsuog2KU3RslHDk+s60oBNYagF6Ze/Mig/HAn1m3+ChRHlCaYfMslIRhqAGo6h3mMDnM yW/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753682879; x=1754287679; 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=eJtO1nuKB/731gs+IWxyxQBo+tSaie/TO/30jHleAGw=; b=AnX+r2LMTo1DTkOWXeaD1rlxtT5g2V5B3BbNZ1t8vFmAMq2n7cQJmHq3WaA4lqxMQS //PlCgc1PsDv/xGuMZ3VxIv+T3WtmZe7OPAxDijdSr2vdL9B8PrfTX+UMlrEVZVQ+13K eLpQf/ciGIIoZWN87byny9b+eCXgYhIk1FeskjKsoXwaoaOEd9dlEMorNCip229ggBDk 68hOhxigZfSd9lyeC/qZi9Ve6QxRKwWP8rRp9E+NgtwL7mWHnMxXZ+TASC2ut++Md4OC UtW5tnSgyPm7R10oytbCdVJjh0RwA1pPK8lk+EfQ1r/HVeBXLTvfEEzC6a2FK5BNSAZv RtcQ== X-Forwarded-Encrypted: i=1; AJvYcCXNocIJYmbQPP3BKL+31GTEYROOX67XusfRV3hBlU45jqWwLacM42iTJvtGy+IPk2bUaChyB2+Qtj3xvA==@lists.linux.dev X-Gm-Message-State: AOJu0YxbB4d1XoNOaUQjoRhqKdxcgwNPp2aWS3SUH3xEwMnkfDt4C+cW Di9GX+4+CRVQFNWFj6nf6dm0VEbqZfwFmfQqOSz8J1cJTwHhgjxD4WCR X-Gm-Gg: ASbGncsudBs/SDrh07q05y9FuydkvwHNrH5Pa/lSsT66PGVjpvkg1bcpYkD1ez4qT3m mr+4gIWfHFS2XxFPWI4o2EvNiF1t6FPyBMsPsXhZ472cnBoxTf2CAEZQzJWwOMTcfBXtxbW0xUn ATXqQhaa2NNGqzL83xxjgYDCYokwzWX2Pb6U3/6mMpYLIRefZ5Mucz8oIfWpqA8mJF5GYxQ4rdu OgHnOLe0s+wTqxGRdcGVm0M9E92VIymFoVjZExEGL/1KZBnPdYThviMU1Po8Qj7ijQNq5t1ocBx gbvabFlC55CKvCIaQbqgp+Cmo7fHm9keyNJOhF5H4PsmqYAR9/PrDw8BpsgBKdjI7ULapH6knf6 GozIJo7ax/vi4lBRyUuV/NTQBI5KzYy27zU3tU+M19ynn X-Google-Smtp-Source: AGHT+IHcuqZDSycBlmjS65wGUlNSERplHlPi6V2vucApJV8xzGnmPFaJnpc/De5ZHaB9MzmHrkvGag== X-Received: by 2002:a05:600c:4590:b0:43c:f8fe:dd82 with SMTP id 5b1f17b1804b1-4587643ec92mr86897145e9.18.1753682879129; Sun, 27 Jul 2025 23:07:59 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:ca0d:f700:1210:b727:adc8:716]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587abe6ba0sm86195215e9.9.2025.07.27.23.07.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 23:07: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 4/9] crypto: sun8i-ce - add a new function for dumping task descriptors Date: Mon, 28 Jul 2025 09:06:56 +0300 Message-ID: <20250728060701.1787607-5-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250728060701.1787607-1-ovidiu.panait.oss@gmail.com> References: <20250728060701.1787607-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 326d9c988bb1..d94304a439d3 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 Mon Jul 28 06:06:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1358 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 6E78F22A1D5 for ; Mon, 28 Jul 2025 06:08:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753682884; cv=none; b=J6Qm2eqDQOcybsHXPv9bQf0Hp/tTdmJHIF9VDwlNdJQp12fJDiQ5DcTYoMvPAri+XuQOewu3k9sefaHOgFJERp2fY1u9ArGyJrddbekuccSxamJTx9gwF0zDdJUIGJfeFb8yTLxJAmD/0LTKCCrgJgGIbeGcUjRj0X9gJ94+hik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753682884; c=relaxed/simple; bh=xmk9NUUKau69JXd8j/FyZNIhFMPQAiXB84NiNB/WsI4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZaN46XSnI1/rPa5g1hXIGaUcHL11qv1zRqoAWNe7a7eZeyEj4P57mcZmsUN+g3i++maplrWhHbmFB2SmGrnhxV/FLgyYwj43eK2akt3gGP3vyh9CWAMXu4rDgLaUkxW4YlM/i7N18GQ81CTNzSJ76m2o8wbHXCBwJwhBGFpktYQ= 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=QN4yAMXk; arc=none smtp.client-ip=209.85.128.54 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="QN4yAMXk" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4560d176f97so43194725e9.0 for ; Sun, 27 Jul 2025 23:08:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753682881; x=1754287681; 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=sdqdaaScOBYi48Kijra/+QGBgmA2GIY7lfOSgwcV1kY=; b=QN4yAMXkYjIgbXxvsbQUKp7+kWxacOmyvyYpCwn5/YOd0WAdsCOcdmUGRwDz7VYJ04 038kfjndpNcDF6P1Zf3R3L5LxrSZvv1S7r10A+VZwc6Hs1LexxUj2W3FlgG3ewyrZfE4 F1iMYQayDtCdpLtDd1YfOFc1iSmYa0Y6dz8zKkMa5mLnAB40+3mHmvoyVhmMVHsDyAjF EbiGOXSPe4571qi7SA8OiQoK/uC4tM5eKdkQ7QrE3X//DLgZiQ+jW72w0T1KS4NUxn6d 1yEnqGTvT9+FMsqeOI17EXjN8yfThNOhOQ7XMALfae8PQ5oGENDayCKcDti/tR+EwynW G9Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753682881; x=1754287681; 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=sdqdaaScOBYi48Kijra/+QGBgmA2GIY7lfOSgwcV1kY=; b=MWJfql4A7RbQidxit2QIZ2nESjWfGyO8Fh7K3OxVS8Z01Q9hQR7KEWY4mjnNcqvwmc Ues+ijfW7XFEBRKHqSveG6lX4RG1E3OpPG6FTCYSvzM07FLSIl/IanA5PyAHZqpTYTVP 0syLeCKYhNebQXYCZPTU5t/aEiHdVY1wkspBK9gKgjp5wskZy5RPNO291hHK5s/AMCfN K2PQudSKnvHTKWBU0YxIENT2Y8Jkp/VQ2Sr2bfeKLl8RrcR0rWZUxIkxy1Jmqap7a7KZ NNjJ9RfJ8v+ipLDpuyAOsGhPXAVPESEw9+xdRQALllrjnhMKfOD6Jt+V1LJKkruOWGUS GTPw== X-Forwarded-Encrypted: i=1; AJvYcCWyzkgV6xV1vfBxUKLUlRgpFefK5S8Nzl3HQbjkw+NFnfs07tmmT/F6aFdoNKTEp11ryqTXEtx3ahotIg==@lists.linux.dev X-Gm-Message-State: AOJu0Yx86eS0AkB24OnlsNic1P15rlMYwigzEmbE4mVbrJKZHLvP7SHS Yu/lvwHEf+YfiOsYXIVleQXeWRIWEgP3lEqPYByAfNbnKyUooOQMUnCikPfskg== X-Gm-Gg: ASbGncvRqqLlOKvuQeqz8cGG/BWeEo88k20q4LbSEgUtdRlKlnKlkTyh0oUOH5vT3D+ PN0+/1h1mp5DxxtYklA6hUWeJ7fQiYMquFZfCvwvt7xacadxz5kv28W4BMsG5rYkzztMNn32BEu Vf5QCOrgmttrole+ajGK88KHmcPY2OhTvbD7OMPSWiH1DQjNQcRBoGdJOAh5+UqhFx7Uw5ECiZ/ taGVCq5vjAcn3q71nx9j5KmnLHWXaIO21Tkk7VaqGSvrgzo1yFRV9ihR6ozik18OUFGGTK0/j1r h170C09YnRWo+6vdOuujLoPLcJtOq9QfHQmsnkvCHPyrZeV0FORCZ5cKFBhzaiRKLHDZckfknyL 2VEU6Lp/9DknCs2kQFb6vWVrN/+rzZYJjzw== X-Google-Smtp-Source: AGHT+IHZ+61CYtmRgVeRSYGGn06dcWJ7qkkpNHOxwMUzzATXNR8lg1Va00usgycivkfePU3GB9B7Ig== X-Received: by 2002:a05:600c:5027:b0:456:1a87:a6ba with SMTP id 5b1f17b1804b1-4587666af1amr70261495e9.33.1753682880486; Sun, 27 Jul 2025 23:08:00 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:ca0d:f700:1210:b727:adc8:716]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587abe6ba0sm86195215e9.9.2025.07.27.23.07.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 23:08:00 -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 5/9] crypto: sun8i-ce - move bounce_iv and backup_iv to request context Date: Mon, 28 Jul 2025 09:06:57 +0300 Message-ID: <20250728060701.1787607-6-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250728060701.1787607-1-ovidiu.panait.oss@gmail.com> References: <20250728060701.1787607-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 once per flow during driver probe. However, the iv buffers hold request-specific data, so they should be part of the request context. Therefore, allocate iv buffers per request, rather than per flow. 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 d94304a439d3..ac29e3f4e099 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..0d46531c475c 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] ____cacheline_aligned; + u8 backup_iv[AES_BLOCK_SIZE] ____cacheline_aligned; struct skcipher_request fallback_req; // keep at the end }; From patchwork Mon Jul 28 06:06:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1357 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 A31B822F77E for ; Mon, 28 Jul 2025 06:08:03 +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=1753682885; cv=none; b=D9ZUZZuBfDdxVcmhpfa6CTrP92I7TxapzsBgQypspAZyEjtr92XWRXxmzenXBSc6Ty2pXrIaRK0MtO2y7TKTjUKi6xvjk3iK6B3omRhlxYW5R3rESYUCisiKayrRwxYUqn3UJUJQyvAZ2aArfKgkybBHaRgJm774/w9Is+1SoUE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753682885; c=relaxed/simple; bh=VLxVkCzDUptZN3MLV6XyYZWlwBVycUnPTFTRKmIikGY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jCdnzRH3IzXQ6RTNmOy4Gf5hTpv07WvLoafHOg0N2DNT/xdSVdOcmrr0Ri8dTk4AM+ijXnLo4pU2Bxomp58jE3sOkClXcTzIgB+AB/uvGQfnmB881VVfyqb/QRV/HJ6LfoK1OUT6ubzr0p876k27BAm+/yveAI+UHS0fQuKgezk= 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=mG6yFfJH; 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="mG6yFfJH" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4560add6cd2so29485325e9.0 for ; Sun, 27 Jul 2025 23:08:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753682882; x=1754287682; 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=mG6yFfJHV+Z69hXYKOj+YrjFDRsmvl08iCcqsgKcZDvgqFjE37vv6i8kuZ65uJSdSh qIgKuJ8Nvr2wR8HUhww2I2b3QsnRJm7gDKQNAErnT+37GA2ocdSCR+hUKDiTk9Acp4EI F21Dj9l96VOKqj4lAlPWEhnk/jPBtrOlboyWTwVenJKSGWlp0tmwFbu/sUvElU1qMIF0 aYeT5GnYYOdwnXFgUFpbiZZhKKcv5d7YdjAJg+zt5/5qEcKjqGVLyIf+Vxa2QKuWyvV1 D75mBl2dkQydtuBOA1WYPO+6W/wNcKnkoe/Ki5w+szArrmj4EFuYH+CX/HdvJk6P3WCA /qXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753682882; x=1754287682; 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=wCfgT7abTPQ//jGlXMxnKGfZ5/J4ouIPl0wrgWED0V7L3r+vQUPnWoIzxI345eUB1B xVSCUQRGBJl+9l5Mneex4zhrobQHQBQSOiqlFZsjsnVKkdarm6e9JYsUNKDzmWYsQ1Eu BEon6bpcqvDs+pMHiO8AoBI4JBLCV1uxvt7ik7sAXGfd0OM6RPuS9ZSsygZEwsmi/ZE9 dNSRnpl50kHy1yv/P+evDpVtCSY9HJyFaWtAHS0MIdhSmVCGo/fcpCTO6bEJTZiabX4F g7CcQsqpLVqqC9F18tHiPE+zyew2+lNfKo3mLIpbRwHrNsXJ6lHjztNnkNfE22ZG5gta zT1A== X-Forwarded-Encrypted: i=1; AJvYcCV0TgEbeCw7JK52/zmUygvoTC8Cw5sLOlk4L1E93ho6OgQFQIpX9G7ppy9JeV3vt39dUOsTVPXzg/IVUw==@lists.linux.dev X-Gm-Message-State: AOJu0YyjxdLrW7qoT0f1WTYN91dI5UsRAm3HSbssWm+oqcNFEy4SdSFV w3lTkqhPRlGDEZePDaKeIYYE3GEQHcCWdEzSXtgoDni2IGkbL/+3UAGa X-Gm-Gg: ASbGncs5QuL5mSO9CDjzHZteGkfm867ylyEMrxPQ/aiaAJB2LCoM7rV932jQiQ3S50V ivGUCrFNWwQYHOMvbTGOX5vfQmV9WihicfUZf9+Lh0tNHpLAmA1s/okB3Hp6+cNzLsVHcs6GBVS kGPvq5N8jcjwDhokC6Assp1iZQd/5WMe0Vafob+hv0SAiOG2VtYNPQ3iyq1Nq5T92fNzwxt8S1T Zg0XiooAsv0UwApg1GL/J6Jjo3XM2BpGqPPcES23tu2mAvva21eSoKB2z2AZ01msQ2NxXmTwvUF aGQ/ckFQqWm3pIskLR+AI9yXELsTbgbttmye18aVgbZzjAJQjA5coNF34rXeCv58mN+9kqneKvW SOma5M0fG+KBRYiB+IIa1rYrk62YRqJyqGg== X-Google-Smtp-Source: AGHT+IGpFevRNhf2Vrq4L9a0rQ+pWGEn25CUoR7Gcz+cBTBQUtLy+n5N/VX74UxKawJZYUhaHpYi5w== X-Received: by 2002:a05:600c:1ca9:b0:450:c9e3:91fe with SMTP id 5b1f17b1804b1-458754bbe03mr80560255e9.0.1753682881878; Sun, 27 Jul 2025 23:08:01 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:ca0d:f700:1210:b727:adc8:716]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587abe6ba0sm86195215e9.9.2025.07.27.23.08.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 23:08: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 6/9] crypto: sun8i-ce - fold sun8i_ce_cipher_run() into sun8i_ce_cipher_do_one() Date: Mon, 28 Jul 2025 09:06:58 +0300 Message-ID: <20250728060701.1787607-7-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250728060701.1787607-1-ovidiu.panait.oss@gmail.com> References: <20250728060701.1787607-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 Mon Jul 28 06:06:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1356 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 E724D231A4D for ; Mon, 28 Jul 2025 06:08:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753682886; cv=none; b=DLgQFTdWqXAKjxf0R8a9dSFAN8QXpQHKNzlycTmsjTedmS6pF5mQvZoI5nPfnFihTlyYz9wf/uKY7NvrG2Um1o/oPApfeV/dX+psHar/MVUmYyA/x8iMRz3wJ03IFcDaL1BPMEXjUWlR8JoE+ax5nMKLX52kPzWUVOIGIjiDW1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753682886; c=relaxed/simple; bh=f6FBfJ2O2GQ3lk7rvtQvn1UblRaOsewFE81eXurpKa8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SFtFkkSwvvivhFhXlqHjKMbwJuOUodCyFTy8jUIdOV+VXEOvcyPC2zbwlvgh8MLPMJOF8wJgMddoCC9cH2HCRqAE37SSTpDWX69juRUIqIHIBlMG+RSXHQVVw2fCH5f5NhxZAvWWMJAU0jKv9c7PE11tj8XRs33x79xpjzdpSDA= 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=aKDUOxZC; arc=none smtp.client-ip=209.85.128.46 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="aKDUOxZC" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4550709f2c1so32242845e9.3 for ; Sun, 27 Jul 2025 23:08:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753682883; x=1754287683; 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=aKDUOxZC9pZy0BS9LDNJGGfiGxCyrvwjrBrgEVNAL+YI+5q2gouehswIuMsUak3Y5F c7RuREi7SawWmBYD1q04mG0N6VcH+eJobXcMVvbxN+AeQHtnDaZUqbJUjmXZ/PezlJSE c7Dw+oP7TChKBudhNPGhvwgVM70wlCIxVhl4zOYSYKykg1wECfH/bhWBjouYaz/7QqmQ 7qKQ5obCrjT47nTzEDLXy56nVWr8n672uf/Tgx3mXdOu5zc0RJX9lzMvODzMcwtp3WR0 uwP2MnVFiNUnly8dVTISvnyUxkNKSXX3JsVlaPDO55pCLDDOb4bIXuuOD81IQr/530HJ fiIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753682883; x=1754287683; 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=Es6CUPpqM5wzq3GxllVLv/zBlwHgOwS3uy0a8IzGZEly2CnkOWQrPDZecj4bongBeX 8RJiK0WKq8NA2eUT5mCnTpLoEFBZs7IG822sh8QqtaRfD5ZrXOuDMdyLMNSln4MWJMQp I+GeNdFrksy0oBiTuZsx+l4c5Ra485T4DiGFuZzRpl5ZpB0rgwwCG7WT7Xxuu6gp/60g ZkaeYIfekmXWjcUmgF9HIMgmUFm7z0wCeYpx27ASbxMaZEycO9/4vxQLOFRQVyCX0ozX 3P1oAwBFahqyWb4F1Z/ZkBkImBPix4cSLIoATxu3wLs5wbjnDqno2VFpH0AR6dnxe/Lz jI1g== X-Forwarded-Encrypted: i=1; AJvYcCX3HMtnlKgTN4LKV6sT7+efXwHdgk79kgr5757DypIpI3n4IwxyrAGO9Y7wiyIIN4zRgHTXSgJjC8GMvQ==@lists.linux.dev X-Gm-Message-State: AOJu0Yx1y3yzt9SPVuxQcAb8cQYr5uSLI9+e7cf64AQC9NpHv97zzLnm D9lMFnzCHvpJIHSukZ+IcsVtE2zhHvskatg6acM5LOHHVQMB4PsC5A2p X-Gm-Gg: ASbGncvyj+Oirr3f4Ix6F1qu1MmY71UWiiOjpMfH08lWt2lHY4ot2DRbXr8Td/KeNaH HrtLUoBRtHyWRgXLetdmkiGOnslz1aThXPgADtvwleL8qsbTeDL2gH/UdGysvZDSLN3kbwKQASZ 7YF5RKx0n8AS+dF+KglraalYb0MqHBLX7C2v31ht54xLhFO38L1+94Zr50fVAt/lAS0DC7eZE0b 2dFeMjsfRJ4s3eOcp9y7lDTCWYVj0u3N2DUKXH/m1r6p0DN/RId5arh3GnQnne7jFORn3Rd0NnP b/yO4UEnRB75IuHo/aMOV++GDcrtKOKP/jk6rZYnzWeHAWq/UlkdP5WGTSWe3J+dvkAjc2tkFkI MKUAwuu4UFJ1/mLJDENYEu46Ivu9WJa5/DQ== X-Google-Smtp-Source: AGHT+IF4uUDpr1nH7CAsFxI85U0J21VbGx+Pa4bqECbTdmTZSrvcjVZKnUakIVKf5iSA2kR6TptSZw== X-Received: by 2002:a05:600c:6309:b0:456:207e:fd86 with SMTP id 5b1f17b1804b1-4588459921cmr31627685e9.2.1753682883194; Sun, 27 Jul 2025 23:08:03 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:ca0d:f700:1210:b727:adc8:716]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587abe6ba0sm86195215e9.9.2025.07.27.23.08.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 23:08: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 7/9] crypto: sun8i-ce - pass task descriptor to cipher prepare/unprepare Date: Mon, 28 Jul 2025 09:06:59 +0300 Message-ID: <20250728060701.1787607-8-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250728060701.1787607-1-ovidiu.panait.oss@gmail.com> References: <20250728060701.1787607-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 Mon Jul 28 06:07:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1355 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 56DE8224896 for ; Mon, 28 Jul 2025 06:08:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753682888; cv=none; b=sn/60Jd86dxr7UP5RI20E/i4vRYpPtf6l+gHJEmo9wyWua1IH4WQKG6KaGACJMTDXqJw9l3kPhXQokoF3SC7R+kfEKTKqKmWJAM7cumZ/hczuR0TZFafd8HqolmcNMGjZAjo48wMrl7rxjdk/Z3+byHzoEtp+IQGNfXOjlejBvc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753682888; c=relaxed/simple; bh=B65GIV3its2xp1R6jcBGC4dXubBGAt9T//wtW+mLfK0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DfsyZRCzlgGCKehMx2G1V43j17WcqEBZl2FyBbRgfboHpmWV27KJufIHxBEt1TVsUTkXyd4VXj+QrNwlPUoYHaiosQmt0fd4TRq2SXCFy9qgIkdFfyjug2QEuqqFH4UTKQsDyAf5DXTrQ7JwQTp34pJR5neH7ZBcyQYbS0qLyBk= 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=IhtRLG7d; arc=none smtp.client-ip=209.85.128.47 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="IhtRLG7d" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4560cdf235cso19478225e9.1 for ; Sun, 27 Jul 2025 23:08:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753682885; x=1754287685; 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=yPkkvVwxFYU+2Mr615PFvFXGtNmnnnpM8am4NYDPd7Y=; b=IhtRLG7dUpyhPtBNgMR5pa3H182QwMb71q8ibV3WfqRd9wRFuKTiTddLx0KeYjJ5IS a+xRQjDYGBBa4/l39vu3Wq0dszg7UgP12OhSjAbweQX2CyO8+aH6UP+sLLoUPFeiC5JK nfIt254e1EQnauGqSnovv3MxiiKEsvDwom4a1O8nKJoARmCJoqPgwwHqdm+qONZinDPY WTjs44Z6zu7shsw6TgKhXGrKN9cExnJaZefJSPxxwmFvfh1xeYw34XYl3VgYpEp5CsDr 4nk7I3bUQXwfWQhMtaH2AY9Xi8f05/WqkDO6gWZH88JQSIz9TRQzyy9otRUyFp6L2nhc sXog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753682885; x=1754287685; 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=yPkkvVwxFYU+2Mr615PFvFXGtNmnnnpM8am4NYDPd7Y=; b=ZLQyPXM2jo0irDYXnUl7NEuCVFlAsow543caE36IzkeHHf4/UUraJLRmxdsIUx05s7 IuGYhZUhRpy9nP/bfT+Fw42AEaS0KghsFiRJsICZAWMuqEzvTWSoaX9uvymnP49MdWCe 6Enlap4/RYKC1wLNxugrGJd29+VBkxQ8oCHSGtdJwaIw2nsWaadhDPcdZpIcJcN1igPH wIHd7rVETkc7Bug5rhSgXw4q1Lau14D3Iwr6714iDipLX6ndpkkoM3uy+R9yB3Mw7UHK 5Q47ZqxJdsmf/ewHOWDPijM/SMy1k6GP1OJ7v5CX9orAqDpMOcAkm/ls+yL6eGoFWeCf UD5A== X-Forwarded-Encrypted: i=1; AJvYcCVDokgBVJSMnkDbtpZXgd80Ece1WZ3u6KZOKaKANaoLt58TDHme9lWZ/Defbr3zrs9ygNAcPlw+ilyaDQ==@lists.linux.dev X-Gm-Message-State: AOJu0YwREz/ULVrchdrRTbtuGtJcGvP7sjJREPObPMkOonp75VkkpDlZ ZCbXzp9iLtfE+8OblNNQcJCt1aMcQYbnB4A7iGfPdMUJnob/EKz/avmi X-Gm-Gg: ASbGncshkQKeR8G6SOdD6wLCAqMM4w+ct8YSPVy2hFCo+2Xo7yIbadWjsIrYVq0Kzi9 rLzjKlxNwq70uJkz0euv2/KGGP6dkzDJBGangSOvV/9wRfSuM4sfQUvp8TfyaixjQImDQwkKx+N G39iBmwlCp7HNzIYgVMbn++8GeovKAjMx3AcgzvfY261SOG1HUt+AWRqlYwFdeJPxex0RWy/Dya 6nlTOVMp08A4c6ejI0WyfTb9oxvlXDTa81UGbodI9Ix6+9gPwcg3/7NirveRCxKf8mEBeUIdiqi n2PzDdgAD6kzQA1j+gcCMz8ZK/aW6vUYerJDWoytnPuRkpg3IB3ELgsyS3fVwt9jnVno5XxoJ5R WsKFNlMhbIlYgE4HhkzGAdLAmHn2xpDpybQ== X-Google-Smtp-Source: AGHT+IGNHmqJIpVWF51P/BJHTnOzhLLnt+a4s0Kx90Y6aX/0rcrlD4mW+DwtiXOJokQk4AhF1Jdd9Q== X-Received: by 2002:a05:600c:674f:b0:455:ed48:144f with SMTP id 5b1f17b1804b1-4587630921cmr85129635e9.14.1753682884424; Sun, 27 Jul 2025 23:08:04 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:ca0d:f700:1210:b727:adc8:716]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587abe6ba0sm86195215e9.9.2025.07.27.23.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 23:08: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 8/9] crypto: sun8i-ce - save hash buffers and dma info to request context Date: Mon, 28 Jul 2025 09:07:00 +0300 Message-ID: <20250728060701.1787607-9-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250728060701.1787607-1-ovidiu.panait.oss@gmail.com> References: <20250728060701.1787607-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. It also makes it easier to split the monolithic sun8i_ce_hash_run() function in the next commit. Signed-off-by: Ovidiu Panait --- .../crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 56 +++++++------------ drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h | 17 ++++++ 2 files changed, 38 insertions(+), 35 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..e28100c07b86 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c @@ -328,12 +328,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 +342,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 +363,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 +383,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 +417,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 +435,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 0d46531c475c..90b955787d37 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] ____cacheline_aligned; + u8 pad[2 * CE_MAX_HASH_BLOCK_SIZE] ____cacheline_aligned; struct ahash_request fallback_req; // keep at the end }; From patchwork Mon Jul 28 06:07:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1354 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 977A2237163 for ; Mon, 28 Jul 2025 06:08:07 +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=1753682889; cv=none; b=YpWN+T5umgnogtZnT1ZtTxYqBFylDOihVBnD0R9EjbOz3LXO5NIYKlS5lI6+X1hbopiwx/upqu1AHoBCg8aME1qTkcWaZMY3ZKEFTfOXICOpHvZsYs4J8wnUsqQJOGJr9knuDSc2yPk9nemX9/q4w25dFOvaFklVI+EcAzDp/KY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753682889; c=relaxed/simple; bh=J9ebtys+gOadsS+t9/vBdipuMTDeR7aQZjcVU3lSpuI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=skxjnnguncRxbHusmA8Iev9rirY0+SOovoPu5N3hw0WU17y2lmrFdyPzdQ4EoW21WPiImqvBMO/4MLbJeb5TKuWAtZm/bPcVpBcnC2uIBQ4NQxXeStM8/uVif/SNyRbAr5ktFPNXdujVtJWgiHSr7BCjQ7y5ZnK7XvUzAEu2T+w= 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=bksU0j7G; 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="bksU0j7G" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-3b780bdda21so1607278f8f.3 for ; Sun, 27 Jul 2025 23:08:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753682886; x=1754287686; 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=5OquH3bzsfHd+3HPbbgh3jCNSZfVC5bnpDs/2otunY4=; b=bksU0j7GU6tWA8eUa51sJHYPkin0Yq8/Iyg7xFThkH6pzAzXwNdXA7f0HBcnbhNHpo +OLgTH5QyNU63PXwgsQPtY3nfXwrvRbFu7Fh8XgNc1QjeQhYTiSgbZGQ5dQljdAC1NHY Egi+eR0gJgGvFZ0ughJvNFNdJjY1Phktr6WuEFGThFwAFV9rQ1z1/vZvP+ixt2PIJfiI 77cGR3dDmcv63mpa/OaAnInstgUcLljLJm6UhMIvjcwyYslrhrcVNOreZd2IFvqHXBO8 Tr3MVY6u1ZxKRtc1Gy0hbkZugeM1E6wA2krvT1UWpkEBnWaHsOsQ+SOILAuUv9KnOoJn IHAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753682886; x=1754287686; 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=5OquH3bzsfHd+3HPbbgh3jCNSZfVC5bnpDs/2otunY4=; b=ZjZH/4mITzMqvJ4tSw0N5KdaIy3WW6FBXHcRdBgMxtOMxBtdVBdeig4b61WK2GIsMu hiFdk0+5b6pc4jSRZ95zMBhBRDk1Qq7bim9B9wnPXNMHtGVtZWWcJhDRSbrXODRjBqe1 HZ0yHUF7qXoTK8pZkSokVqTfp8qEy8o0m6X9dCG0NSF6cKUDqFFT6e4KaF7HfO7F48bl hZY7+CiKHiitLDkdRi+a2iwvJ9ShLkq/78Yw0BMO4rwsptpSC/ezwSEGnY+h4TO7iI3a MRQFuKJdNSdnQzKnH+aMo1OSd0AI7OcnhjeDd82eNwxpfK8jVkD18A2/ZshrEhGpHEp8 Wp4g== X-Forwarded-Encrypted: i=1; AJvYcCURnvsZzjVsQoc2lz/Dpd9VI3iyjpdV7MiIZhllaRAAseCptxdoRp7pjyXq8oDBagA1HCp/zFhtVXvCYg==@lists.linux.dev X-Gm-Message-State: AOJu0Yyu8Wx9mOkO4RxZhXMMT9NSxMUjg67bSOOp9p5F/ayZWi6Fo3tP zicVxwS0iKkFwCkmn4uEapoF588unu4gCFt1l9vUYnjDQ8bJTNbbMLoo X-Gm-Gg: ASbGncsrBXhpSScCAIr1CD1B1qJgkREiUdiBTZoOePYNQSeWAOY4pqyWQOr4TvzokqF Sehe1zovWW/t8LNerfdtXVryDHNMkrrEbZnjKHKmi/u4a3fiprTjp1R7qF5DBwtemTg4k2jsySP 4STuBcbM4nHnI+AesiGMkT63dO8wF94GjCg7nBp+rJwDFaUhqIZINQc61xP8/WQQCTehhtQ2VoS unVzWToGgeY+1FbQ4JOc+37E0KJFAMh6CpNLJh7vp1YvjZ8donNlB3qmhweJjN7UllDTdq032qF P4xcU5XSvsMT8J5cA+//LyRjd2jn0phSBIJt9w01c8/9GtdFmdJG1IblRMWSj/ai4A3sR3874bX E5ImddubBqvLlRbzH2Od+SXp7pccByf/jEQ== X-Google-Smtp-Source: AGHT+IGmdqX9IZttVYna5BJ5xmHOnuGw9/sYW7r7das3xWFHBQfvmW7jivr0ZkUOFKLeiH33vIEMqw== X-Received: by 2002:a05:6000:2011:b0:3b7:88a1:19f4 with SMTP id ffacd0b85a97d-3b788a11e12mr1371642f8f.27.1753682885748; Sun, 27 Jul 2025 23:08:05 -0700 (PDT) Received: from ws-linux01 ([2a02:2f0e:ca0d:f700:1210:b727:adc8:716]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587abe6ba0sm86195215e9.9.2025.07.27.23.08.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 23:08:05 -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 9/9] crytpo: sun8i-ce - factor out prepare/unprepare from sun8i_ce_hash_run() Date: Mon, 28 Jul 2025 09:07:01 +0300 Message-ID: <20250728060701.1787607-10-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250728060701.1787607-1-ovidiu.panait.oss@gmail.com> References: <20250728060701.1787607-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 e28100c07b86..70c761baf847 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c @@ -312,18 +312,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(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; @@ -344,18 +341,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); @@ -433,22 +426,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(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(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;