From patchwork Thu Jun 19 12:23:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 898463 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.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 C1C2D23B609; Thu, 19 Jun 2025 12:24:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335856; cv=none; b=XJKeU/QijC5ZCoLqYVuY3agizLAS+dNDu8daYNZtXcP2TNXNL8bU3bAtjbKXB8/+NK1I3S+vaMqaoxBkdj6JpfIzMl83WmspcQac3vUu4/ecIbUI5g3iIvXCf4WmZTyI6WhNwZ7lzE+Xe0o7eJmJrI9UwpBq/Kd1KzY4DVHfNpI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335856; c=relaxed/simple; bh=V+HFJ3mcjgzB1Gr3bIDT3f6dj+Z5XsFbLbUNii2zGtc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tCEKQ/AoZjVCiaLI//f4b3JntXUtrCOdXJ2DxNOnhscixsVAPAvHsnmLvpGiIvh+DJQYMTdiZAZsJLF4/M5Q1qZh79+xG5MapzQb1BO/L1aNDWo4kZ3YgeSlkNDty9v7kTzUY0sq/1L/W66DE7PPVfC7/bcLGBwvTq3RwWH6hvQ= 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=e64iRcA4; arc=none smtp.client-ip=209.85.208.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="e64iRcA4" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-60867565fb5so1162194a12.3; Thu, 19 Jun 2025 05:24:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750335852; x=1750940652; darn=vger.kernel.org; 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=XbU44eJvfJDBcTZ+xWKQo+1cPwZ/TlkyCXqSjcDCqLQ=; b=e64iRcA49GseZRg/Cm6Ag73zA/ieF1F35I98NrSMSr4juBfQ3ZNGQlQ8olLp3appq2 Gq4Tr140wnbe3piq7gdnH2RI2L0RvjSg7cmXIBedoXWFVbUORQuzZ6JIC6SkyuPW3lrQ L3KEsGSct5CY/vSpX3oUPNekU8WntzQx6KmAf6rSJJPeVH3h4+VEyKjopUKkdeCg5C6w wlraUETxG9B7hURQFe5PmMciiRbF43T1R30QOyXEYDzbCYSnCWiDHhu6Jfx3INOF3P95 WeRUmj+amyWbt73rthqKvG4uFRo12M0cZpUVYX9kRUQEbmLO0pUOD9auSdvsBvEL1und 2xyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750335852; x=1750940652; 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=XbU44eJvfJDBcTZ+xWKQo+1cPwZ/TlkyCXqSjcDCqLQ=; b=nTk3F3F2IrbpguFQb0BOjJVkGx5AkEDXfXT8fhk7p8powDUJTYZkzhLfBTHN9j5Ocu liJPnc0+r0stvVkUD1+BQe+tVtBVKRF9j3pPLM5r5DRQhUiTH4tLxlHz9aYY+Q5X/NBE pJ3fmW5ZJd1il6LkOaeYCP7GYOo8+uanTlbtROgwJuSFaGhjdpmZLCyIwt0ChN1LKawG i56GIEM4pwS+dnxD6jEa5m2hMdDXUOpTGR7BuRTLXUNQr/OxycPYlPjmS4u9LO/cY1LE YrAmFAysCR+pBWH+SetC9L4srrmnX8Cak7HPWIWkh0fqR547PgxueO4ACs5sHGMYl+YV qhCw== X-Forwarded-Encrypted: i=1; AJvYcCVb1R2YSY30rurdb7t4T8ZC2lc0Ao0UIptNpJXUMSF559PNg/u2IwRPEtgR17s3JP5QgKn3l7E3eIHhGzY=@vger.kernel.org, AJvYcCWKz0BqHZtSU6EYwjy0Te9Bzu6B7vo+xC+2xZmFKyhOFJWfyqyVKR7m47xZU8yP/fPZL4vLXb9XrTkXaaeG@vger.kernel.org X-Gm-Message-State: AOJu0YzA2O/jYc0ThEV2cEKVWr0r3nUH1GklT6ONK9WvDeP6o3jz+ThK NVF5YL8YkLTPIoXSaIxcOBwRdTbQHMpUm4t5fNGfR4CfcsuYhgH36Cwf X-Gm-Gg: ASbGncviVRDCjeTnVZfbdSRZPLloAKT8xp3EVy045rcbfCULpe+9ZG4kNVTcTKBJZ9h DlAcmmR1VtaSdvQjZ9omwnYyxQ5x8+P1SgMzbIErhh12p5o0osPvyeOwZrMf86h9M+iC1ZH33kh 2p0406N1g98xLoIjEggUDibQmMYVjcf5yyLjllgYaZbW1e+95Ug/o5icgCNVAlfBPYZuEtk7p5d qiTRQn/mx0F/1sUL8fHQz6v3hcROq92c6dqeXDrazA/a+FGX2Og2EbHRzWTO6eUn95wkwk1lVFg oAVJfPpkZAyirFTV3teXtvL1oz/P8MkAfH/i1b8p+ucKNn1PuDQPtWUIrzZQfy8ldbMr+nXU0gw 6UeVviOHqTo1oqA== X-Google-Smtp-Source: AGHT+IHxZ6KyDVZH+/AWtxZdICZOs1YlDPZ1ZpE6Nu/jpvdE/3Ii2DDUvVsNbEbPVhvCkr3A2LmzwA== X-Received: by 2002:a17:907:d86:b0:ad8:8d89:bbec with SMTP id a640c23a62f3a-adfad4123a2mr2149991966b.28.1750335851736; Thu, 19 Jun 2025 05:24:11 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c51b:8900:a03f:12cb:72f7:9069]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae000b02bd3sm504688066b.3.2025.06.19.05.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jun 2025 05:24:11 -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 01/10] crypto: sun8i-ce - remove channel timeout field Date: Thu, 19 Jun 2025 15:23:07 +0300 Message-ID: <20250619122316.2587236-2-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> References: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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 Thu Jun 19 12:23:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 898075 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.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 D83D5242D96; Thu, 19 Jun 2025 12:24:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335856; cv=none; b=Az2Y9lEkJNi2QROU+O+4IoHrxMrefbT3FlNuicW5OKcFNtmH8g6oVvwy0Q9YLzhGCwpajCxLwr0ki+EYcbI0wExuIxt8g/eG1wQS6kdzWPzB5ATcDAXZCjaPTEx/kRaiUYBt1NJ+Q7/sOUxnllBm/UfGXag2SPcReLCLFIGNe2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335856; c=relaxed/simple; bh=D3Fpyml+Pwh/ot9LUtEAJrW9x78rJDQPnjdfBz8Z7cI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=He/YaDgGg4z9K17mtADPHXwvRnGUwsYPyAdWPtYhRK9xxSJgzjgVcud3/7Pc7XfgQWQbkFaFCDuiIJ54ZXVRQh9X8xuwWQciRl92xOOE3Dlo1pz2anWM+wGfvMULA/XvCa86DzJaVL9IssnkjIRl/91yTqAtZCxsAtwwTjGu1d0= 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=HnifZLg5; arc=none smtp.client-ip=209.85.218.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="HnifZLg5" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-adb2e9fd208so138175466b.3; Thu, 19 Jun 2025 05:24:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750335853; x=1750940653; darn=vger.kernel.org; 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=0HrsFLSEEMdhGLUzZIYXTdJy0VycwWTY4NZmzeB9UZg=; b=HnifZLg5gZRBeUdIQ+zXxe5GXXU8mDQifJJJ8R+N3o81kwDmlYUSPJaZUMQauOf/U0 HFLZlXjMw6ZgWUQIqQ61eg/Hl1QOXb6rqgDr9xvPXp2tUVsF2vIKnh6BYFgXikeTm4pa kR8PutDGwFim8hrOB+62dzxSOPRyqJ3wTKHAqUbkLM4kbKYIQqJJTkPmMwcUCtVUVF+x 26IFg1BiLTRssnyB5DyMm3EZG3dK/Zdl6+2mhYZGTzBHHcCST0wTgdy9MvQou2G7oeEw TA2Ed+WKO1hZ8IflfAzHYBm/rEgVpWJGPOOKNwsyLFolWYsLgI6UJrTjqW5sSwJmfTaJ WQIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750335853; x=1750940653; 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=0HrsFLSEEMdhGLUzZIYXTdJy0VycwWTY4NZmzeB9UZg=; b=hi006VfJWvCvMAA3Acfo3Iv+a3zH8tgsDaawgDbv3GYaVXX1IvDBuO60MvFpOQyI8Z ctO9QOeMLTho8BMAUr+y1Tt9hGLLYK+40j3HJxwOkrFSFQIdz27sxAuGmP7enpfQwqXI zDVRBA8xfias+eRubd6+nb3U6ule/XUtnms249HR/lAuHA0ROEVuiwS8tyr4/lTP0Mto qzEB2reZsjqqMdZE518TiRTh6yjJiFeSMv/tQ8to+FCcttGBzSlsnQLcsunlGavVOKVf uqZbjCvzGi8GqiJbVjGb1Oh8fDKagPMktFUT43BHC0dscixWTx280PQv+Bk//eyIJGtn 958g== X-Forwarded-Encrypted: i=1; AJvYcCVATIFKfx0VC9rw6WxQ1f5vWywGQ1MLxcsieOiJoZyyrAWDmx5s/6FjaHCGpYawqqcUkpFngwHJFrlK7Iw=@vger.kernel.org, AJvYcCWoyLfiq1CRnnyZUFNnBZ/WAJ3BD0mJz7HCl/Ttf5Y/CmCG4QvPq4fSGowmUbm+NF31c2ZNAYosX9wa9ePS@vger.kernel.org X-Gm-Message-State: AOJu0Yw0IMrT4j1Hkk4W7oJbVi15GnvsoHhXDOvXoqmsvj0h9hyEgLk2 hZLYttNTw85+nyzw/ouyPLYUbroD0H9WntPXnCcubm402YqdVNgiJHvi X-Gm-Gg: ASbGnctmcqdEMW4G1sMEoZtX+Rq95O3LSOBpBw+T0pmapTXfIVcOHVax4b+zA5NVlOD TV+bCdTZ9HvjU/zhuPSFoRBexHC2Z2vs+4+nnrB1glP7ffbbCnz9KemQQeX4sVLo8ErkiZsrojC IoInhlQuiYTE3J/ttvyiLWrZS/8bQd9wrJVDqf/OjixhzNR/6P0yp0AlCN41RcSshQ4NFGAdpwW CvayP3VtaE+f1qTYPFxXgtrbJP4tITNw/X2XtblaKs454/ubg/hoSB+aMlFcJb/T87jwUKSjskL kti4L7SjkdhIDFQ2SXxfrERVMtHNYjWINNdIYyxYKb54ZmsBBWpkwVEy1pMASSK/9TC6qw5MmGz Jt44f7/GQa2wmQA== X-Google-Smtp-Source: AGHT+IFHuWqBozXH71wulrFP//Y6OM4S5v5aSjrSOQKgs/LL1p2at57xIwfuaUeDkpt3vFS1Udqh+Q== X-Received: by 2002:a17:907:3f1a:b0:ad8:8e56:3c5c with SMTP id a640c23a62f3a-adfad363d82mr1948037266b.11.1750335852861; Thu, 19 Jun 2025 05:24:12 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c51b:8900:a03f:12cb:72f7:9069]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae000b02bd3sm504688066b.3.2025.06.19.05.24.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jun 2025 05:24:12 -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 02/10] crypto: sun8i-ce - remove boilerplate in sun8i_ce_hash_digest() Date: Thu, 19 Jun 2025 15:23:08 +0300 Message-ID: <20250619122316.2587236-3-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> References: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Retrieve the dev pointer from tfm context to eliminate some boilerplate code in sun8i_ce_hash_digest(). Signed-off-by: Ovidiu Panait --- 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 Thu Jun 19 12:23:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 898074 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (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 0C847248888; Thu, 19 Jun 2025 12:24:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335858; cv=none; b=GzibR34vV0oRqUd9Of68GQKQ1Tm1CEMdG8EpNQE+6McWjcVNaRYz8t1v0kCqDEw2u1eKI/0lgFmcmCawQaj1bMB3OyBp5D6pM0S8M2BZoZ4zuykagXCKVbwzXR+zvrPgFQQFZCjHiWX574mYKozK9vch+X+feyD1Rzq3hh7PNLc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335858; c=relaxed/simple; bh=pRmnLFjBJ2dWkN+uiG3G+4366k2+/zNV3iQ7dsrr+ws=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=roMnd1cj1xONiqxkks8jVkkIjAVco+60Qj1AGEGtl7YUqjakI4QgkNT/JIdASdSsN0PU4ikePqaTMe60yfPepDu9gog1k7MNRVkEiOru9I7CRmVverWGYQ2vMtVs9TBLGr/LebpdcxI5Vzb7fC2ND4gtFGqVpxmnQjmh10dlYuc= 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=ThHQuOYe; arc=none smtp.client-ip=209.85.208.43 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="ThHQuOYe" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-60700a745e5so1478463a12.3; Thu, 19 Jun 2025 05:24:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750335854; x=1750940654; darn=vger.kernel.org; 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=t10wxuAUiB4KyOt9zeZgZ/9RxJrj16+YdQHln4bOH7s=; b=ThHQuOYeqiZG+GJk9D7KhulVi21VVv8RRsKVO+tvEV+uwloMA12pZEwGU7SQesBY1i VPDzQFnaTAsyIvgspU80IuHAUFHCdNF8zFSYaZJiQcAG+WuWunUlGJqHcW9IHz4SiYZX Qn2ujI7JJJdIcMcGbeVx5NINlMfNqwF24j+fDnBtrvDIOaFO1S/VZqZKL+PIr7lYMZP+ pQb5pSK3exNUJeknP1yToyBOoUJ/0hi0/pvpuwwQxDfSF2sX7VCQNiAadcf6TqXRbYvI 06iubcaHeADi2WLpHE+mvTCDTGzOZJRmwJUWEZoSYIESl80caVXQWw+iYeTtiaD4H45r +gIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750335854; x=1750940654; 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=t10wxuAUiB4KyOt9zeZgZ/9RxJrj16+YdQHln4bOH7s=; b=F5PZaUhaTzOOPyPN80UHPzr9WXT8RJqC0dxP0M/QfPujLQHHRVkPW/rPPD4cpiHRgG 84Rt4irxgKmKHRgXu3mDZvW73tGNqg+fHRhDsE5bv1nGRGTj+YM0YVH7laaJHnnnvmqt 134H4u3w2bQovbWe/1BuyKeVMRFgeD5dWt6KVHvX8ugcqStSE5S7nIODxpVIP84XkRk2 5IHim1LY800By3eWu+uwiQC2RMVWF8CH6Zi1yoEtZxr+TCUktvIqQzxPlxst+ODljtJC ygAA9I3YrxSkr0y1hctSvAb1IP+7DbJKTCIgx67mqD+MeuRLxYfpDXwHWHVnNZqiTpzw t5og== X-Forwarded-Encrypted: i=1; AJvYcCVH4k/uWTUv+GK2LTa2mJNXhw8QG5DYePP8JTiygfJc2RDNNYGKUZG+DVR2tffSP2ZMyEzKTQ86KiOHLWw=@vger.kernel.org, AJvYcCXmEtcR9iMNUhjefjpXJsksMbsGu3a9WgwwUol1upSPtsc+D7TNRCJIFnBNQmXuaHwcrNsJ2Ns6/FD2WF9c@vger.kernel.org X-Gm-Message-State: AOJu0Yy1LZ01NoleKanfffu7sCsCGLdjN/VrcZ5YTm+2ZkJUBkjH85fj BFPLxCzxfK3z1HH35hGbJAOlTB0PWPTzaGKH4MhMppjWeVvVzfDMCFhE X-Gm-Gg: ASbGnctH7mRSA8TqCKgsvu3jOnPGnGQXUHCzTPny6o+urILKyUoihfvW5Kg3KCV5rHc h4V0yhbQ//57jDsEmGcig1bhsVuIliMAqfOkfgCs9jglvzeNekuQ7VYQUE47V5wQMDFNkzPcihy +y4/AeD7Z+lCnwe8udkCZ9G3MeTKC4Fs4oe2tzL3EljLVYO3jI174u6kKn+igaht+Qp0/AtjHF+ MfO2DzMvfrmIhC5Qdol/H6lURFpKSAN6kpcnWLT0l/aXWnLyaMtcsbAEmEkYgLsO/G0SnA3H7Tq QP0IuLyXCEI5NsvWKIg01/AoDJz841qsOyOYfHgFWRe8IMpfc73ecFvYDAYcH7XN80r5O1yBpRT id2o90Fm4h7YUPw== X-Google-Smtp-Source: AGHT+IHjXBuVHBHVzGX7KJawSoi/MaD0OIMw0TPwOstgtvFQbFHnqwQM6253a1WMLNA8WmktvzgJrw== X-Received: by 2002:a17:907:7fa6:b0:ae0:3f20:68f8 with SMTP id a640c23a62f3a-ae03f207cdamr188465966b.39.1750335854011; Thu, 19 Jun 2025 05:24:14 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c51b:8900:a03f:12cb:72f7:9069]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae000b02bd3sm504688066b.3.2025.06.19.05.24.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jun 2025 05:24:13 -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 03/10] crypto: sun8i-ce - move bounce_iv and backup_iv to request context Date: Thu, 19 Jun 2025 15:23:09 +0300 Message-ID: <20250619122316.2587236-4-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> References: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently, the iv buffers are allocated once per flow during driver probe. Having a single iv buffer for all requests works with the current setup where requests are processed one by one, but it wouldn't work if multiple requests are chained together and processed in one go. In preparation for introducing request batching, 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 113a1100f2ae..9963e5962551 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 79ec172e5c99..930a6579d853 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c @@ -757,18 +757,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 Thu Jun 19 12:23:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 898073 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.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 1902323ED5E; Thu, 19 Jun 2025 12:24:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335860; cv=none; b=PDkiG+DslzQqllatkmEcQBJBKUQBtaMqyO3GMdEQEqFI+044IJdwGLs9Bj11UtDywQl+jQQT/C/4elNA/SxZo0W7Z9OaHJyg5GG5i9LTnVtDO7TtFZbK+XXT2GkmUFQhlVsUsPHhabSRk3/Jb/JYtagcvEmZ1jrHyeDN8lIR18E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335860; c=relaxed/simple; bh=C/gJk2ObWTENdNN8gXRsiciv6hvj3wk+copliiqlW8I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ljl49Jz2PrKSoL5qBPPHofAdc4VtPdNlpbdEdMZdV/84QJwHr9QiaAygovFXKGTYF1RgE/nsvsdxe8cNcN+amTM+EC0nOOfhMfMFT+FQH7gSRJcBRpHpIMEALYi4ejYx5o9s0eLRH+6e36spO0G8fo+F5DaRBTttpKvnYhozick= 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=hbg6CXLc; arc=none smtp.client-ip=209.85.218.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="hbg6CXLc" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-ade4679fba7so144146266b.2; Thu, 19 Jun 2025 05:24:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750335855; x=1750940655; darn=vger.kernel.org; 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=n4FE/m8CCQWWX6zEjUZSa1AuebcPVAo/kb1WN2hI258=; b=hbg6CXLcW1TtkUUoM+zWRzaSftIp7J1UzgcE9zXpPtT60VDLseauixlu9KB5p/mTUs 2vYGIMrr9hN16BXXWjmju71IQfmbuKV+O+7TXfDB9frjLpqbUuvqoeG26ft+z0MBQoHU 2WhbgzTsw/TMfdyO9dSUq8WYZZXCpA5vIjRQEOqyagS4I0tIjQbx37zvJKdmXkmbLoKk /RsVebu2iuuXEbalMTlpLf9xY0y6FfVJTrfZWmZInDTdMgZ3ogEHJC12ISDBuaqGZzrR gata6hwPMpt3ejFTdTHCKmNj4u9awc0tMmHre69KGvePtrZigsLsQGW9gIfPj6EL+A59 jNnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750335855; x=1750940655; 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=n4FE/m8CCQWWX6zEjUZSa1AuebcPVAo/kb1WN2hI258=; b=WMP5wKAIBuJjvR7OofQkbo1GEujzYpHY8pqoa5iMa7EXeGj6JmyLuLPx02po/lRkWC vdDYBrX5YJeKFMMeryLQp7y1LTrkZAJPOg1tnnJTmp81vtxy1O76txatOpQhBW9vPhyl zJaSlRUF/IjqQrZlIYQ6aWWsWe4iS5qKnLp12z67BCXvEJS5YdoISPle2ptmU/0wJ3mi 5i0ZejzhN7V19+CY3LGE3L9PgF3dzBlKMIcuVOkFQbJGuc1maTb9IK1uakkF/C61+lh5 tMuqQ/YiS0pfJW7PcsPezFpQlrEBBJg/GgXu/emvdM9yomFIo61Rmysp7g2X6sg4ZbxK bFLQ== X-Forwarded-Encrypted: i=1; AJvYcCXSfSQDFOqv3yH5j5WkYAzFz0Sna7K7hSh07NYBwVNT+ir5DZTZMDWjsZNJLX6k8H8utXMReCAqLhfSYXHQ@vger.kernel.org, AJvYcCXyn6vtCfCZmrJU9DdtkmzNA/Lj6Do4Q447Xh4ySizG/bT7W/SwSq5wZ8rr5ylbKLerDUd3rJJKyj4DCAA=@vger.kernel.org X-Gm-Message-State: AOJu0YwlMDhkfki+ud3Kms05LO5XgXl0y3vOL6m+VguvXQEnj1MScGSh rZT86hb3a+uEgm2Buk2Gyvju0xKigfLIKZazmg09KF4fbXfYDxELSwYRvJodaA== X-Gm-Gg: ASbGncsePT16b0y8Sd2IlmY/6F732QQmU/Aq0jrqLfAF1MGSgs17WS26zVCh65bK1Ll u5hoe3bFnsEBxWTXV8Op1YxYbNOJH+RXa+A/dPhaChV/HkDuxtq8RI/X5FMYcZ+am+NMeX/Ax+p BH6Z7kG2fHtPpzdLlcxov2Bxu4Gd7CqxTFg7LmZXqh9kC1FJ8u6XHmLLYwq/oIt08hcyQAWrecv aShLlCsa+7JG5N5CKZifAHhYaalqfh4dY6tJLSUPQqB/z7lX3dj1oA2XIalVIhQvFlyCBzUMgXL hxlmIgoCYnhPI5seyHdO0549r3KkgYkBGWc4re+cGZYi7dVYgtt9XTqvazUlY1kFxhm038P/Rqu vSB4XgSWgvfXXoA== X-Google-Smtp-Source: AGHT+IEqkd21piHtgzZrKyYzEgGCeUARprhDQ5f8PJdOXO/FUR4X0Sb+5gSgjLC8tCZKpkV/N0CMLw== X-Received: by 2002:a17:907:1c9e:b0:ad8:8529:4f86 with SMTP id a640c23a62f3a-adfad5e2b12mr2149539166b.58.1750335855186; Thu, 19 Jun 2025 05:24:15 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c51b:8900:a03f:12cb:72f7:9069]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae000b02bd3sm504688066b.3.2025.06.19.05.24.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jun 2025 05:24:14 -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 04/10] crypto: sun8i-ce - save hash buffers and dma info to request context Date: Thu, 19 Jun 2025 15:23:10 +0300 Message-ID: <20250619122316.2587236-5-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> References: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently, all hash processing (buffer allocation/deallocation, dma mapping/unmapping) is done inside do_one_request() callback. In order to implement request batching, the hash buffers and dma info associated with each request need to be saved inside request context, for later use (during do_batch_requests() callback). 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 61e8d968fdcc..3ee0c65ef600 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 Thu Jun 19 12:23:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 898462 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.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 3A10B24DD04; Thu, 19 Jun 2025 12:24:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335860; cv=none; b=rweFYpfa5gi63Yy7xfrqOAfH0p5R3WBC9A394McomNdJp2QRHKqPJZtX0hVKp6/e+eF4FHadeU5Fh+HndmgDeFyxp9dGWaobRejD1knWYaTZNOcIbA5/jNny/qaTix72eF2/HE8DFNoFK5WWtt7VASWWo+axR0vZ+rQD/0wXLik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335860; c=relaxed/simple; bh=ThK72kzM3/NAb5q4kYO3GzKkml/jXobH2nqcwRen8oE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GUaYcEM1UbHSR3RIHw2yPR409ciZi9vMbYOgDhp1XrkVnwdnF354XMHrlQaO8IFKYJ8ZDHBXcNSNfFbVYO6MP++3Fn9QcvcikUnIL5CbOXajHVJEKVKZXQPiuGIIboWrzjgwkkj5pLl7ra8QkswzKI47kirW9i0SlntW8sSxfPk= 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=S751SmNU; arc=none smtp.client-ip=209.85.208.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="S751SmNU" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-6084dfb4cd5so3699045a12.0; Thu, 19 Jun 2025 05:24:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750335856; x=1750940656; darn=vger.kernel.org; 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=rgIbzVPscBuyqUEBsClRFHHr0kmYa9s+xoX+40DNp18=; b=S751SmNUMz9mtaNKv0nGVeKIl/dVEozINkKS/ulq5v4Wg4mLRRsVaRK4T3paSJ2VAR oJIXa8SILjQW7DE9PhRTigePYlihnM3ndkWbWPBDvvzG0QECntvEYxz2kFmFCYVo+hxV UuoKI68Fqs1Y6Xnq+9qUKW0kmN3zXgF6TgmGwHbDmAMq5dejjL9j7pRS26NPOydrgLPT +GQj273QbdcWWA4D9ZFHO+0fuVwe74IDHNZGODlJ4mdALluMMgR3i5uZIuDg0wh5BO2g 53GzjpRvuq++bxXLhdpbzuC7PxbJ1Dy/43HW8tT5uaiOaUUqjT7Mp4apRoFZ6UwjHQTM sXNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750335856; x=1750940656; 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=rgIbzVPscBuyqUEBsClRFHHr0kmYa9s+xoX+40DNp18=; b=pw1Gu55X0GTDRpiZWeCuYhePKuU+EGK5OaMiZf/Su9KGYXcuPF4GslCNOLV0HBc6zp cHSCql65Vd6jCbTft0gnDEuIZZvXPyxExkoFN4whn1NXG8m9rsrrBy2jJtBjz7kU11ye 7ptDH+GSgT6/GG5Gn7gyQl5T7nBBDKxQEednaq0gBYHNwLyi6AXxmcw1OaEMn04ywm5d sySY8jSovYQiWdpZsf5VttadBk5ROPu6gO9EG/t22TE36rooaxI0K+ZeKF6rjNwcTvU1 OVF3QqwHlHJihGo5tMeFWCK+/B06IXc5buIiFWsqH9HJrdRydezN+vxvhRI/hNcxdF83 YShA== X-Forwarded-Encrypted: i=1; AJvYcCV+irRqaJdsqSg/Vduq0CHbfqwM+RyhjKsr9b4aRrfXFleA4xs4FzpQkTMu29jON8r8jmu3/QTQEe4QEso=@vger.kernel.org, AJvYcCWw7PaQOSUx50f8KQD1xn6RhFBbzyrZbzFvRuiOqUR3aRP+opJorpv1cEMffQ1RfNYcXbHOpLwEA9eDGiDx@vger.kernel.org X-Gm-Message-State: AOJu0YzsvZ+wNgd+12+T47FqJcar4MacAxGbVrXQoaiVqIuLUyQXQyfS /wWiJrOOrdlD8TdGJk4e5wgEed5tW7gx/QrSYmrQ+IcXz7Ik103OAfGx X-Gm-Gg: ASbGncvKisFrq6rGHtACijtYnyszzSK/k0VpjicyymgYOFnUcQCwMgZdvlerwob7WOv RyMycpHEjsXit8o3wSvbzpZ498f+kPjDjJ6u7yliP0Kb26jG+ZNnILsxHJpEL7q3x+2c5WbpWIN B8GuclfaN+FZAgmk5+YoXNi7x+MLhTjhb1mjpgFsUtI9CnAC90WYl56yx67oOZOHnduuFtfJz6M PJGUQvx2NUnLPN6lK2F0+G8JqQQMlu6sCwTM3n7K3K/6UTgaGtvQnmKyPjxwG+LGBllwIjCp12l xvgborKQKsPhtF3ydqJNOpKZX+5IwqmO0DwQAJcM14Ciw5p6wlCpf6kXJhNZekAbFDJlm9oiNIa Ld0INIwl5HbgPfQ== X-Google-Smtp-Source: AGHT+IGp2TBBgU3kBXSIIbngsVXxutaDLHe7ezjC9aFjh5AHU1t7NJo73l09wb2AvdA+UM11p80C2g== X-Received: by 2002:a17:907:e897:b0:ade:31eb:66df with SMTP id a640c23a62f3a-ae035285491mr322808566b.11.1750335856287; Thu, 19 Jun 2025 05:24:16 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c51b:8900:a03f:12cb:72f7:9069]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae000b02bd3sm504688066b.3.2025.06.19.05.24.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jun 2025 05:24:16 -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 05/10] crypto: sun8i-ce - factor out prepare/unprepare code from ahash do_one_request Date: Thu, 19 Jun 2025 15:23:11 +0300 Message-ID: <20250619122316.2587236-6-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> References: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The crypto engine workflow for batching requests requires the driver to chain the requests in do_one_request() and then send the batch for processing in do_batch_requests(). Split the monolithic ahash do_one_request() callback into two parts, prepare and unprepare, so they can be used in batch processing. Signed-off-by: Ovidiu Panait --- .../crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 64 ++++++++++++++----- 1 file changed, 48 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 3ee0c65ef600..7811fa17388c 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,61 @@ 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; + struct ce_task *cet; + int err; + + chan = &ce->chanlist[rctx->flow]; + cet = chan->tl; + + err = sun8i_ce_hash_prepare(areq, cet); + if (err) + return err; + + err = sun8i_ce_run_task(ce, rctx->flow, crypto_ahash_alg_name(tfm)); + + sun8i_ce_hash_unprepare(areq, cet); + + 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; From patchwork Thu Jun 19 12:23:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 898461 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.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 5F80324EA9D; Thu, 19 Jun 2025 12:24:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335861; cv=none; b=u3Nsz5am1N076BhiEZUQXtqxWyUvD++Pf/+N/jyJnLE4d7iZxiixfIXrfMM57NYLtXdTZnrTkoRNJalM/wJY98/2t2XdxtZ85WFafHo0sAMcFrq0TjTgUiFfUiH2yDbfWRplAumDeayJtiVV8A4KKxNGIm6bif6WnjYFslfOf6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335861; c=relaxed/simple; bh=MVmmWlPksmaiBVibi00qDI48RIUv844ifSFHgrjus/c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VSq21hVmYGRc90ikTLSxvGk7bqYRrTyPYI7zNKbl5EcjZFYq0FKIuw6QtVz2AEfXUrpYJUZJmo8B88onqmR9jEsb+7U+J7jjhe8deH2QQhoxyW0pfYbjX3M8HREFGQQlsHmPw3DOuaajEX5UCAj8Komi+vDq5IdL/JWSAg8MtYA= 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=KGnZU3bb; arc=none smtp.client-ip=209.85.208.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="KGnZU3bb" Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-60497d07279so1406120a12.3; Thu, 19 Jun 2025 05:24:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750335858; x=1750940658; darn=vger.kernel.org; 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=nOCWgCxa5TuHqEzs7P/Xd0Uu+UeKSk+lfEEEEay9BLo=; b=KGnZU3bbiDwo3MXIXyFx4KmgC6ZE3Z/cp2mLaMm2iJQlrrnU1oQrUPOE7gAQ6xUpiz p0xwo3n9S5MVyTKd35ijwrEesjM3ZO3U36ZpxZFjYdirTELgWHh3rNoRe1HCshw+WgoI rrIxLXJ0GCWz4pRje2tZWQXZS7cm4Nhr3Zfiu6UrZWZiP3hC5iG4jDYlvynYCUX/ywI9 HV4nUCkViENfD58bHY0msLmrBXuAZWv+U3jRwLOKcEUe1kXpDFSdvOU4giiuSpLCahA/ A5AvjZlQbeEb/nJjFrz5XLGqDjBdnSm2AxmUEJuCDc7x/caXcy9PKCsXDZ+0eIFh8sDP xabQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750335858; x=1750940658; 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=nOCWgCxa5TuHqEzs7P/Xd0Uu+UeKSk+lfEEEEay9BLo=; b=wYmbLc2mMMVbFLqC6vsJCp0SOk3wptD8B+BaPZLY9QMmljtoUiUr6HOZOVlNtTluwf bIzv4ZP4XNSBEn6jwUDw8J7UJ8YxHBMjevrrR8FWMPVd85b+5B96OHgLrmt+gePUUQZ5 MXanQ4q4qqrTrS7KK3+iPsNDiX3MotFTVsWi3tEMwgKFQIUOavLxpWh5oS+sVyW9wyts 1DNaFiJLsfrQTeeEh7NCuRIOS62aaqWVosXvFfGrGhczQMiKQDv1hSLomKAZf7LLhyIm Zilcd/XIzjuNevtHx+UJh58y1IuNndFjKqd7rSR1bZrRRPM0OalWLl6k0WlFf0rtNQ21 0org== X-Forwarded-Encrypted: i=1; AJvYcCXidHTjCrH5TEkIJjf2YPX+SHywH6TWce8RHJffvfgtoqoPqjr3KttBi+0Kr6AfwoAU3vD6EtG8ez8BA6TX@vger.kernel.org, AJvYcCXw022C+gG26FtzMCilnlZRFLeX8whTDyTdFrps68hWpg+oaUDIUS7Pv1UlUooEK8AqcbxifuuWCeU1OSQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yxoo3b7aMv5fT9YuZLZC96/czFqo09/nQrHpvd7l9dQjCuEIa5R vsRVbVo2WebQOHbmKL/BU41y50rm+rZVhRsO7QLx8PgHAaAXhkhVx0KN X-Gm-Gg: ASbGncvoghhGVf5gvPBdaj2zRn8z2pq/WOQp3ZNXD9ixLexr8nPbu9roYXNITWCoNS2 gPlL7mwT+rvW7TrlQDxSOh8PPYk2VSJqZJzJAzhnuqh3ztWpK+n9hjYXAXcOomus6zfqDz/TY7w z1x2Thha98tuq01X0jebh7B5GcxG32QxnXhTVfLRzVor14OUQAAgqNEwJMmApi+iXwRJYPTmL1y BltZrz2PrHLrtWaZvLt+TMKg5tjVmACmGGl95b0FKBWBXIYpe68GUXlQkuH7R49ab9hxiHEmiA6 VDrAUMZxUMvsyPNNQhmeunzZdAK2S9zliR45BwhigNcE445QmJHN8IJqvjEKEGpnSjhIBl6XbxR eDNpyc+xYVpYQpw== X-Google-Smtp-Source: AGHT+IE+a44JiT4pmaQaCPgiF4SiL6W/ZMs6YLvucyMriX+08QeWg5qDOEHlRbDj5alSx6vbOGHqPA== X-Received: by 2002:a17:906:9fcb:b0:ad8:9e5b:9217 with SMTP id a640c23a62f3a-adfad60cb3bmr2167795566b.45.1750335857453; Thu, 19 Jun 2025 05:24:17 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c51b:8900:a03f:12cb:72f7:9069]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae000b02bd3sm504688066b.3.2025.06.19.05.24.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jun 2025 05:24:17 -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 06/10] crypto: sun8i-ce - fold sun8i_ce_cipher_run() into sun8i_ce_cipher_do_one() Date: Thu, 19 Jun 2025 15:23:12 +0300 Message-ID: <20250619122316.2587236-7-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> References: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Fold sun8i_ce_cipher_run() into it's only caller, sun8i_ce_cipher_do_one(), to eliminate a bit of boilerplate. This will also make it a bit more clear that the skcipher do_one_request() callback follows the usual prepare -> run -> unprepare pattern. Signed-off-by: Ovidiu Panait --- .../allwinner/sun8i-ce/sun8i-ce-cipher.c | 34 ++++++++----------- 1 file changed, 15 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 9963e5962551..5fdb6a986b1f 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -360,31 +360,27 @@ 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 sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq); + struct skcipher_request *req = skcipher_request_cast(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; + 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 Thu Jun 19 12:23:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 898072 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.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 8B2D9251782; Thu, 19 Jun 2025 12:24:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335862; cv=none; b=SzEp1/AjGeZ+GARuInfhkX0OdeDIKl+NxQXm5+thYGSAmnZrmgNaHuYfpzDREHl2fs5eOWp1Yrr19P4KyTjnt4mbKUYlfFT8iXi294hTPsGL8ASHwGbw6cmgAvXwrZVc9QdyNH6GySPNIUM7TaLnkYtmW3t2SDGzoxGtT9qvm/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335862; c=relaxed/simple; bh=kINjivbB1+ylLn7tV9af00mOK273H9HJI0nMG3aaa1c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WlPUTnkRued/pK8DmBlPCTPGXdyDje/rSlHX68ePlYV84/Z5aPGcTB8Pxdm1mZ9mX7UqwfYuZGrfg/+PdYyTjByteI73Zq7blJwO0CQFDEBtz7y0MVlgtDWEvI3qAt2d/JDpTvyGVeAJ9PlttMjXe0biWwkv0YCUq+Yq9kfy0H8= 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=lTDfPL0m; arc=none smtp.client-ip=209.85.218.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="lTDfPL0m" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-ad93ff9f714so135257066b.2; Thu, 19 Jun 2025 05:24:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750335859; x=1750940659; darn=vger.kernel.org; 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=SfOFmSReN1wX8YEf6gXPwdHyf/C+wiQacKthqWE/o4Y=; b=lTDfPL0miKfZwuGXmgCxxQOpvY96FPrqvC/hXxPCbdGdeMewst7EkbRV/9jQK7h6Sm pa/u7k5VshIK1GVmhxsvTFKaywScB24F2k7tO5cpIi3f0GEyX0/K0eYh/9VIFu/7wBGX ouALiMIBzu7VembSFeJn+uE9ywskkkVKPVf9NkCAb7jK6rYCNrsnDtvdEmj4PVdHiP32 FMiufD8nCngV3jbyXzI38TJ19kyl2eGgMsIxN9mF7xBNb/MxEDtwfSA6qzAhoxSHK7jF kvYB8cKsEH8drgElp2Kvnzaq9qGviV0czIMz+MRhKJcGRKjun70kJSzFqhIGz5paidgB GMXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750335859; x=1750940659; 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=SfOFmSReN1wX8YEf6gXPwdHyf/C+wiQacKthqWE/o4Y=; b=I8hXAxN3YQq7tnA91EvtzsQR0c3PkwfkBvFL8E9w/EnTAYpgB30G/V+C60U6d9wk6D AHKb3/7UirBPkVj5cVi5+R3BOP8c9/hxyh7GBM1+Tr85uYA+5zczfw50AXvd0vmKkCsd A0JRSFKELmyBNUplXr+5VjvVafANFt97dj65h9ODeyjafmhnQeUXNaZDkeF+JXmAqe7D 1PU0/A8OPLBiCDXsEYjfOvF4AuGkCbm5HE1prs6yL+NxMWT/b9EydlefvJSBNqXwac1B pwTUCxIuN5UM0k/a/U1+JTY5ub0myHIJilTJl2UMWQRhv75/UysqOVHbn8OTbczXnIAA qXFA== X-Forwarded-Encrypted: i=1; AJvYcCURCESjHRd+5eAYFlg4xqgbBgBiSdzZ9gRu14M3gsxGa+gz0uW7dtGUb7ZskWI8P9dFiytTPapF8UOUs/g=@vger.kernel.org, AJvYcCX3dyf9v6Hi4Wh2azYLHU+c4FBIh3UsraGhxAPS6FGHkIl2mUq2Ah7RsG1cvp9RCSGx5XKEbn3GuqPnadDA@vger.kernel.org X-Gm-Message-State: AOJu0Yx3gdpXBO5wuP5CQ5sDkM4iD/vS5xKbNycXFn5waUXMmWQjFEla AwPcPIFjMiIdY0+esPAe8my4JDMmOD8f4DRDSrVgLvtzKEcunR9/7phb X-Gm-Gg: ASbGncuCvfnWac/jHTa9hhatiSG3LV3lgoXy9npwM2pqh0q3j76ygh/Luv/DH54ghG/ sV9vbAwGZHZ9FNbkx2cD0sau9ZQdHT0nSmr6VY+ujMTlOVTLSQW+3I9CWOlwwfu9thCMMwatH3C i5sdtrrr2OlqNuATKJIp29aHt7WPTqC6fFCq6gj13vR9MG0CsMWwkRLhGH9wCJwNWUZpTw4xLwD UOBKwPdjXrJ56+BNmdver0HYwDs/MSYcEpEz8jbJYPqdjcR4IBOiPBffIjEpwZnOM4oHFcckes9 Vnq8+BCfAR9Y7fAceaLRpz9Bdunj0Lpun3Tzksf/4g6A/7Kw4vYykGLQjQocjtGsv5hvImsVX0K BM2pOhnNfkK3SQw== X-Google-Smtp-Source: AGHT+IGEPeo5IOklcxib13+gmY/mAxR132u//d0bSaTarIv0yq4bk3Wfepb86FCqZ57HZAhqV1/TKw== X-Received: by 2002:a17:906:c10f:b0:adb:3345:7594 with SMTP id a640c23a62f3a-adfad31e10cmr1852773366b.9.1750335858569; Thu, 19 Jun 2025 05:24:18 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c51b:8900:a03f:12cb:72f7:9069]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae000b02bd3sm504688066b.3.2025.06.19.05.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jun 2025 05:24:18 -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 07/10] crypto: sun8i-ce - pass task descriptor to cipher prepare/unprepare Date: Thu, 19 Jun 2025 15:23:13 +0300 Message-ID: <20250619122316.2587236-8-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> References: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Rework sun8i_ce_cipher_prepare() and sun8i_ce_cipher_unprepare() to take a task descriptor pointer as a parameter. Move common flow setup code to sun8i_ce_cipher_do_one() and also remove the crypto_engine parameter, as it was not used anyway. Signed-off-by: Ovidiu Panait --- .../allwinner/sun8i-ce/sun8i-ce-cipher.c | 37 +++++++------------ 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c index 5fdb6a986b1f..d206b4fb5084 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) { @@ -362,20 +348,25 @@ static void sun8i_ce_cipher_unprepare(struct crypto_engine *engine, int sun8i_ce_cipher_do_one(struct crypto_engine *engine, void *areq) { - struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(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; + struct sun8i_ce_flow *chan; + struct ce_task *cet; int err; - err = sun8i_ce_cipher_prepare(engine, areq); + chan = &ce->chanlist[rctx->flow]; + cet = chan->tl; + + err = sun8i_ce_cipher_prepare(req, cet); 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, cet); local_bh_disable(); crypto_finalize_skcipher_request(engine, req, err); From patchwork Thu Jun 19 12:23:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 898460 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (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 CFCDE253F12; Thu, 19 Jun 2025 12:24:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335863; cv=none; b=G+CGc5jbz+sBv6jXJ2cfDfoISt60jwf882XJ1pyhclj8m4Ts7mXcg44WpgCDw6lhHMMthYmGTT5PDC5PY286bFnWj7qlnWHyyYPpbDIDkWTOJTQM4WchuliLvRqaeyYFELX3ankoF4PXC93cN2khSrdqQnEdm5tPMQagZYMEjc8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335863; c=relaxed/simple; bh=SV17SgqAFM/CwgJKb43KYYELjIo00ELjwm2XuaeiHoY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RtwUV4gksMMLrR33RwL3jkqk6O2UlQH8j4Ga0uqAyv+TS+RPP+r88B0l/a/O33/nJEXAIMLWvJkKvBG9BSLhMqZ1g8NJ7SvWz2PBI0Ak4jaAxlMRhV5fR4pCYNaUbVPIBLPiHs9tVvJ5Mily6YuObQ7AqnMp0Z9ngwnkEVtMlxc= 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=juk6oTfl; arc=none smtp.client-ip=209.85.208.43 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="juk6oTfl" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-606ddbda275so1441991a12.1; Thu, 19 Jun 2025 05:24:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750335860; x=1750940660; darn=vger.kernel.org; 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=TntJfTNuRfw8H9ywL1n4IQi1UH/CB2DPSoGeEkzsKwc=; b=juk6oTflyeNv1BxcBz7hGeXEYz5s1IFneu9Gsxiy+8ZcL7ES53rfrcgBD6PLAcAGkT 4PSZ2dbqPelZJfu80swBv8gmMN/Y659q6zwLqvFhfxJ1tXxDHx6wt3gUEL6m8luaXmw8 WtiAEY+cv6CPHhqplPeJ0w1WvfXAp1umTC2LjJxwUjfR+H2rAshWu8CseYaZNnR2c5CA 6ZirD3ioiiv9Pj87Pu9MVR+ElZskNn3BiAGrPEFYpcn5k+8ha6DWPix7O3TYKr5hBgNu F9AFg/CSswVahQe+QjfB5dyL2zEzHf5OxJWXSRGr4SnlQjkmSlfrCOAo3grERhVljt6u V5LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750335860; x=1750940660; 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=TntJfTNuRfw8H9ywL1n4IQi1UH/CB2DPSoGeEkzsKwc=; b=vEjtf7N75ZA06T7XQ1oYHYm7+1bVTKCupFWNpoVu2O8WdMlCXlpYREwROqiVQljE2Y Qdabpkjj7RQWpCxKrS1hKaS5WFGi4RH2fmjuFU3Fr7RSuc2sH4po0N4roDtxFDz1hEa1 lY7CoFU1KUJCZalzXUtP37y5oW14i1ITvPWgee7xvtzqTrv9rLR4AuEbkzfoyMIEdoob Zhz+SlNUzqPDrOV8Me0HL7VN9J2bLXIVdxFYzk0r8JHGTIvUj3y20X+Nsiu0dxvMnqZi hJYehM2z7I817BE6RddeLZOGebaAf8m3l/PIdFi3DG+tYNkcSQjODqxusX/KLeDubvdC bF+Q== X-Forwarded-Encrypted: i=1; AJvYcCWMpkM1EpRGshoK3VAMNedMpvh9KxuQl28kSXqQe63YFrngeNC5H8FFHYLS8dCUlmXbDXsk9aVArCS9VTJn@vger.kernel.org, AJvYcCX+njOSRTSbwyD2f/z/wl8YHOBWM571Aiyi5u5kmnOVngHd2aR2yHN/r6jrbKl6DNl+1T2wfVbzmKfzy6A=@vger.kernel.org X-Gm-Message-State: AOJu0Yzs7BrWfPFGMily+4sut+f96t3ej2SQ+6846JGM2OJnq9ALIF7p LmH26uz0wcy2ZsGtYMCSNv/NSpOmymjGVHQdn7Dbpk+qyzvyn38EWw68 X-Gm-Gg: ASbGncvV+HzXjAIZNpdfFrXs2EJ9pfGgkFdxC0AZi3ZxiBQ2ltDWRaLOKvas8fChBqp TnzuUtBZ1C9rnpLfgT1akmInmhkGs/Kjy6EaakItjEFAzKnX3i9CK5aduRhULzzszslfZIqapcz dkuQ3UPVRUY5kzt7NoozkFhHz+jhmLxnrn33Aws0JAPcQbocN0kNPsvqvzdteJ9AJhbq/Su9ZsH F1iJbJUrsj4L+B445Lq5kVsUU/H5dgg2t1RF3EBocSxHQ5hDBw2pISH4eiXmsRmQ2cJt7WMfbYs HxVbNK80mQ1z6QhMxQEYeDuFo2VNUzzmPrd9ymZL0E8PCuuKSj24J/2JlUZo1lHjXkRSPtlwkOr Z2aY8YSslInFp9w== X-Google-Smtp-Source: AGHT+IHwGI3VAdkps/w875TI+PTeKjZsVrfn6fAKJdMQGXVhrfDL7CIBgagxHkyrj9BPDgk2ITeRzw== X-Received: by 2002:a17:907:3fa9:b0:ad8:89f8:3f51 with SMTP id a640c23a62f3a-adfad28d0e8mr2120856066b.6.1750335859832; Thu, 19 Jun 2025 05:24:19 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c51b:8900:a03f:12cb:72f7:9069]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae000b02bd3sm504688066b.3.2025.06.19.05.24.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jun 2025 05:24:19 -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 08/10] crypto: sun8i-ce - factor out public versions of finalize request Date: Thu, 19 Jun 2025 15:23:14 +0300 Message-ID: <20250619122316.2587236-9-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> References: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Factor out hash and cipher finalize routines so that they can be used in the next commits during do_batch_requests() callback. Signed-off-by: Ovidiu Panait --- .../allwinner/sun8i-ce/sun8i-ce-cipher.c | 23 ++++++++++--- .../crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 33 ++++++++++++++----- drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h | 26 +++++++++++++++ 3 files changed, 69 insertions(+), 13 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c index d206b4fb5084..22b1fe72aa71 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -346,6 +346,24 @@ static void sun8i_ce_cipher_unprepare(struct skcipher_request *areq, dma_unmap_single(ce->dev, rctx->addr_key, op->keylen, DMA_TO_DEVICE); } +void sun8i_ce_cipher_finalize_req(struct crypto_async_request *async_req, + struct ce_task *cet, int err) +{ + struct skcipher_request *req = skcipher_request_cast(async_req); + 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_flow *chan; + + chan = &ctx->ce->chanlist[rctx->flow]; + + sun8i_ce_cipher_unprepare(req, cet); + + local_bh_disable(); + crypto_finalize_skcipher_request(chan->engine, req, err); + local_bh_enable(); +} + int sun8i_ce_cipher_do_one(struct crypto_engine *engine, void *areq) { struct skcipher_request *req = skcipher_request_cast(areq); @@ -366,11 +384,8 @@ int sun8i_ce_cipher_do_one(struct crypto_engine *engine, void *areq) err = sun8i_ce_run_task(ce, rctx->flow, crypto_tfm_alg_name(req->base.tfm)); - sun8i_ce_cipher_unprepare(req, cet); - local_bh_disable(); - crypto_finalize_skcipher_request(engine, req, err); - local_bh_enable(); + sun8i_ce_cipher_finalize_req(areq, cet, err); return 0; } diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c index 7811fa17388c..5d8ac1394c0c 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c @@ -453,6 +453,29 @@ static void sun8i_ce_hash_unprepare(struct ahash_request *areq, dma_unmap_sg(ce->dev, areq->src, rctx->nr_sgs, DMA_TO_DEVICE); } +void sun8i_ce_hash_finalize_req(struct crypto_async_request *async_req, + struct ce_task *cet, + int err) +{ + struct ahash_request *areq = ahash_request_cast(async_req); + 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_flow *chan; + + chan = &ctx->ce->chanlist[rctx->flow]; + + sun8i_ce_hash_unprepare(areq, cet); + + if (!err) + memcpy(areq->result, rctx->result, + crypto_ahash_digestsize(tfm)); + + local_bh_disable(); + crypto_finalize_hash_request(chan->engine, areq, err); + local_bh_enable(); +} + int sun8i_ce_hash_run(struct crypto_engine *engine, void *async_req) { struct ahash_request *areq = ahash_request_cast(async_req); @@ -473,15 +496,7 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *async_req) err = sun8i_ce_run_task(ce, rctx->flow, crypto_ahash_alg_name(tfm)); - sun8i_ce_hash_unprepare(areq, cet); - - if (!err) - memcpy(areq->result, rctx->result, - crypto_ahash_digestsize(tfm)); - - local_bh_disable(); - crypto_finalize_hash_request(engine, async_req, err); - local_bh_enable(); + sun8i_ce_hash_finalize_req(async_req, cet, err); return 0; } diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h index 90b955787d37..1022fd590256 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h @@ -383,6 +383,19 @@ int sun8i_ce_cipher_do_one(struct crypto_engine *engine, void *areq); int sun8i_ce_skdecrypt(struct skcipher_request *areq); int sun8i_ce_skencrypt(struct skcipher_request *areq); +/** + * sun8i_ce_cipher_finalize_req - finalize cipher request + * @async_req: request to be finalized + * @cet: task descriptor associated with @async_req + * @err: error code indicating if request was executed successfully + * + * This function does the final cleanups for request @async_req and + * finalizes the request. + */ +void sun8i_ce_cipher_finalize_req(struct crypto_async_request *async_req, + struct ce_task *cet, + int err); + int sun8i_ce_get_engine_number(struct sun8i_ce_dev *ce); int sun8i_ce_run_task(struct sun8i_ce_dev *ce, int flow, const char *name); @@ -398,6 +411,19 @@ int sun8i_ce_hash_finup(struct ahash_request *areq); int sun8i_ce_hash_digest(struct ahash_request *areq); int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq); +/** + * sun8i_ce_hash_finalize_req - finalize hash request + * @async_req: request to be finalized + * @cet: task descriptor associated with @async_req + * @err: error code indicating if request was executed successfully + * + * This function does the final cleanups for request @async_req and + * finalizes the request. + */ +void sun8i_ce_hash_finalize_req(struct crypto_async_request *async_req, + struct ce_task *cet, + int err); + int sun8i_ce_prng_generate(struct crypto_rng *tfm, const u8 *src, unsigned int slen, u8 *dst, unsigned int dlen); int sun8i_ce_prng_seed(struct crypto_rng *tfm, const u8 *seed, unsigned int slen); From patchwork Thu Jun 19 12:23:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 898071 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.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 BA8E5254867; Thu, 19 Jun 2025 12:24:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335864; cv=none; b=FDnnMzMVNqo5F5jkdZLal87Pm/P3G/lZOF524vMF01SkwVcrR78HtCPAM+vBzvBwFm7emLC1Kw9kHaNrnfscwlQsRArTnrewo1ahpGnhknGtU9fnpvTIhefftLUtwApfJMc2iz0EZfcG3QzZFt5Ci4Lm7g+CVkG9NHtJFtuoNBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335864; c=relaxed/simple; bh=dsS+p6UvQk8Xwg+WgyOGAas3d5MTBbJN2FAK8gI6CFU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZPG44GknfSAck2uKo2coyyN9b+ZN5DNHC9LKD0ARYuTX7YjGU95RLys0nSfSAKwaNop4/F6pkjl27QxFzVByPfU1RFRs8GIOcxlZMBCBZIG2G0alCSBW0oheGV2NfAu+BOzjqh+gU+f2PksvYGAvExnAguSXPlssWV6C3J/WDIQ= 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=WyUAnXSZ; arc=none smtp.client-ip=209.85.218.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="WyUAnXSZ" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-addda47ebeaso145465766b.1; Thu, 19 Jun 2025 05:24:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750335861; x=1750940661; darn=vger.kernel.org; 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=579Q1QhHC2sKl8ad1uJdu4XVU+r2uSj185NnGxhlUu0=; b=WyUAnXSZuMRt6wM/um1tG1kIb3Nd1D4JR19GnVZqLxNit722wN+RAymOleqnE0mmTT gk7/uhZyZh8mt1EB4k9ARP3JVg1HX2IQXM1gJANpQCQpmY0zzAk2jg15U7itX1klrX9v kCjiklV3YfFk8Lu9zeONlAw9CuA9+qvlIUU06DJkYxY64WSD4NA3zEK+z2Ot+h/CK2cx aXDvWYWv/KuIvFpHsMEpnJB4ud2aO6gahhtSx6KfzR1wjaJ0n54TU0u68+csQT3ITDxZ D8KPq8fJu3p0/WyMHYDBPsD8Tq1s3MqubG40KuQt5/67d3nTjc1dSQkQC0bwQmA7HQ4d gO2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750335861; x=1750940661; 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=579Q1QhHC2sKl8ad1uJdu4XVU+r2uSj185NnGxhlUu0=; b=FhgfcKY6Q9VH6Qw87I+iTi/C8FIcetPm4nFP7+AFu+1EVXfQD2itWOcR1XKFihmz5Z qq4e23N9UPisio+dGNJeciV5NdNl68gbDpYySHB5Lu/GMxGFprjrT9XC+tZ7F5wRNsXj ig7R2z14cLoQbMmxrN4ryK6zoDCVc/Y9nbnNPznZAI4gZ0FCurxS7U9ufhyFLzgP/0C0 B6CLDYtN5iYqm2lEpUhlbbthPqLgLhsXt0aKJO6KfFE30uxzUJ2fTTbaNKbQr/4HJY+T 2sB9el1TPHdvlfI9PH0RjWmLfXgx34Bd+46HBABZ5zpL8YFptjx+nvyOuP0arHyMzpIq wP/Q== X-Forwarded-Encrypted: i=1; AJvYcCUNZt7wV/PgcJUVvxeS14LM6IUPbhhnI3QPatPxaWY+TvYB+FV3walrjb+j4oCE+pGcx/CulxiZpfmjkDM=@vger.kernel.org, AJvYcCWALTm4RSaMJsGjX4yWshB7PWei/XG3flfJu1ozxTxXvQYIJPRcl3/3R6d5KZvslgbgn+hqMAD50TiU4+xO@vger.kernel.org X-Gm-Message-State: AOJu0YzpcwvJlnkHP15Oj1RVGv5ociyYKLKcBUv0WfmNUD4SK903e+D9 g93Al1QQVWcHUanc+zXh0TrmyTzxVn5AeXxp20sHfTKtEhkUb5w5LWNA X-Gm-Gg: ASbGnctQSlggsD/Ihyz7Fwl6kCy1yQFo5QG/RED2uy/eiCnN58g4dNPa+SUud2eDvci 2jY/j6fyAfkDQiR/4zbuWhGmdJlCos2hd5m6DE06aFn1XKJwWDmbGDc++0QFi68lDneUDPcq5wd vOIvFgLwm60HfM7qv9br/d0jG5HqzOZIcRi2fd3MXaKDCHu7QwgV1+EVV++r+7cizjGzYpKa6B3 ugG2kj8z3w3aDpgT90+98t+GZ/hRz5Hibb+09AqtqRNdYYR0ANCYF6AStXUwbVUhXxMA/WjUmb7 fw28/WneoU0aICWhwU9c2vUvY/sW5o3QRpeMvEpf8y2ioYBjWVu/5cKpdQbBPgni8yxNQrhSqPm zlWmXKV5dVimveg== X-Google-Smtp-Source: AGHT+IHH6DFXlW3XSv30gN9W1MaxFbV4Xi7gLnQBbzesKqNPz0MrTZ8hdE2KCDgVxH4xeRlqT8acsw== X-Received: by 2002:a17:907:9694:b0:ad5:4a43:5ae8 with SMTP id a640c23a62f3a-adfad31cd15mr2245682266b.12.1750335860965; Thu, 19 Jun 2025 05:24:20 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c51b:8900:a03f:12cb:72f7:9069]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae000b02bd3sm504688066b.3.2025.06.19.05.24.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jun 2025 05:24:20 -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 09/10] crypto: sun8i-ce - add a new function for dumping task descriptors Date: Thu, 19 Jun 2025 15:23:15 +0300 Message-ID: <20250619122316.2587236-10-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> References: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 930a6579d853..b6cfc6758a5a 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 Thu Jun 19 12:23:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 898459 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.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 EE8102550DD; Thu, 19 Jun 2025 12:24:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335866; cv=none; b=tSel3SzOTnmnIV+MlCuUyBbb9peSFz2jCoby51qfIzQFgNDSJn4kU42uyvNt9AQP2osxEJvcJ5lVC40FhjXRiahqUI5Pup0Z0OaYo9DKCE3m7c+BW+qc55B1DcFqh+ZNzNYue+DdG1rkvyJlXL/EeldQUcEw/54SyJlKpj2KTg4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750335866; c=relaxed/simple; bh=uvn/CbjR0iHC1Gzqj3IMoegYKQaMERPstoXduBNPa1Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=siVUYT/a8/iJV8/gq8Ozy9L9cHKFzAlaNwmBOGD0tmEKkxhBQenrIAO3nwbWVy+HifTEH7sf/c9XK7szOqIm4fSgmxBoxHRzlp8ArKKPTBausYELiGmyfmbr+zC8xlcYFQFi0E5UCZ0VGQoOrb9+eyNVjlKC9NemGbYVBZGrVg4= 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=LZGU+Ox1; arc=none smtp.client-ip=209.85.208.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="LZGU+Ox1" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-60727e46168so1307779a12.0; Thu, 19 Jun 2025 05:24:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750335862; x=1750940662; darn=vger.kernel.org; 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=g5Gpu+13nPGCVHqZg30hcatcad880Sim9iFcp3f23U4=; b=LZGU+Ox1LZUVf/lvmBZ854x4Ncjj8SgEJlZAcwVKjc1YFdEY+2ci/WOfmABVrcRMny l3120/5SxZJkSPmcQ4a9AGAmRzim4hl7WARgg2+2sZYBytuuURHjIZ+RfgseWSDGnBG0 krqmmcVJNIrbILSrEpMDO34U3HqowW6tI3NCGDCCVZVdaPQJjmWoo0QWuzwWZOQzN8Kg DspKAjuK4pHs1nRFXmWdts2d0nXu9XXG9ZTbEM4ByvQhbxzKJTqT3y+5VsSJZK1l7WJs N6/mWfDd1J1f+Eou9NegOa3uPXS89aGBM567S7KVBraCXKzzt5vbSX6OBX987Dqxuz8U KR/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750335862; x=1750940662; 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=g5Gpu+13nPGCVHqZg30hcatcad880Sim9iFcp3f23U4=; b=g0GVEegMUvD19OD0uz5qD4sKxh5UsKFIZSEFnFbeman+qtJNXNZ/KmGkLov0IC8iYs Whk5rR/J2V+YG9y9751v5ANgbXlWxCrqZgGsgXnXaNJlmj8Rfw0zl+51wiToTVFJQhT9 m/LG7MDGqUOtz9Uo7uTvNVEro89+Um8yNqMCCuccKIsifZQOgo4hLha6UO5pufbbrqOy 55iZBXstjdXVh4Y6VjbD/KI6rNrEX8QeTMvxTe4KwJa1IhM1i8yubm7qcPUQGxRCIUZp FASfqwvHtGDehxMPVPn3qZQQBvZMTnvHlziIMl9+8D93q/cTOmbhUnCrOeVKFkX6JSaH UaBg== X-Forwarded-Encrypted: i=1; AJvYcCW4azqNt4doWZge0CmbkBrID4vFKJlKfEzl6lqYnnFGEHyV+2XhETg3sUyy1ZROrtvNp5dCr4dpmKXP2wjz@vger.kernel.org, AJvYcCWP/AODXc7aivIT52vEhTCCoFLFsKDoQvMznDB+6MC9Ddkg5djB134RhCjGiv5K2nD3WwflTlBJLVXIpks=@vger.kernel.org X-Gm-Message-State: AOJu0YyxFL7Bdslpsu4C8r/OMDQYPKh1EOhaspK9YCDQyYTR1tfW12uf aQFDP6fkChjVNLkO5yv9VIIE8fnwC2dWjXtKKJMcr63PL1uLvSsGg7vy X-Gm-Gg: ASbGncutaWzXeOO6n0avli8LUph2K/kkBe2XPrW9/9folxVbauxTnAh1JpCcdZfUn9I rmmKPsJSl4oTGd25l256bGqpL1TMzqOZS3Lb/59VOc8AbjkW4VvaCx2EgV+gZ0GPPT8gu4F0Ca2 gp6ZR+Kggtysfu94/Po0lB8qIfZXQhPIwiBB2462Y4EYvOO301fPvK806a9SX/QT96dwR2UWmQP Gyof+MhAGVR0IO60jhiZKNhn871XPWSgQM2HN8TokR1p/HL4zLuwtnopX/fL94cvhBWwF0NaAYd v0hpVwaHav63sxwwipihCubGEnxFOTH7OSRIpVMeHMl7UlK3jI/J1eT/i62ZycdzUNhmPaPye0B NB9iLCmQ4l6UH1Q== X-Google-Smtp-Source: AGHT+IF962CYjlLZtvg9eHBjvU8GUucSlYDpx3mPu8LwlDHj4xeOOn/8jtcAmRLBHe5JeNQW4grErg== X-Received: by 2002:a17:907:3c86:b0:ad8:a329:b490 with SMTP id a640c23a62f3a-adfad396ef2mr1987587166b.23.1750335862153; Thu, 19 Jun 2025 05:24:22 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c51b:8900:a03f:12cb:72f7:9069]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae000b02bd3sm504688066b.3.2025.06.19.05.24.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jun 2025 05:24:21 -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 10/10] crypto: sun8i-ce - implement request batching Date: Thu, 19 Jun 2025 15:23:16 +0300 Message-ID: <20250619122316.2587236-11-ovidiu.panait.oss@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> References: <20250619122316.2587236-1-ovidiu.panait.oss@gmail.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The Allwinner crypto engine can process multiple requests at a time, if they are chained together using the task descriptor's 'next' field. Having multiple requests processed in one go can reduce the number of interrupts generated and also improve throughput. This commit introduces batching support in the sun8i-ce driver by enabling the retry mechanism in the crypto_engine and implementing the do_batch_requests() callback. Only requests of the same type (hash, skcipher, etc) are batched together, as the hardware doesn't seem to support processing multiple types of requests in the same batch. The existing do_one_request() handlers are adjusted to only fill a per-flow queue and set up the dma mappings. Once the queue is full or a different kind of request is received, -ENOSPC is returned to signal the crypto engine that the batch is ready to be processed. Next, do_batch_requests() chains the requests, sets the interrupt flag, sends the batch to hardware for processing and performs the cleanup. With request batching, the tcrypt multibuffer benchmark shows an increase in throughput of ~85% for 16 byte AES blocks (when testing with 8 data streams on the OrangePi Zero2 board). Signed-off-by: Ovidiu Panait --- .../allwinner/sun8i-ce/sun8i-ce-cipher.c | 15 +-- .../crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 123 ++++++++++++++++-- .../crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 13 +- drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h | 31 +++++ 4 files changed, 155 insertions(+), 27 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c index 22b1fe72aa71..5a3fd5848fd1 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -165,7 +165,7 @@ static int sun8i_ce_cipher_prepare(struct skcipher_request *areq, cet->t_id = cpu_to_le32(rctx->flow); common = ce->variant->alg_cipher[algt->ce_algo_id]; - common |= rctx->op_dir | CE_COMM_INT; + common |= rctx->op_dir; cet->t_common_ctl = cpu_to_le32(common); /* CTS and recent CE (H6) need length in bytes, in word otherwise */ if (ce->variant->cipher_t_dlen_in_bytes) @@ -376,16 +376,15 @@ int sun8i_ce_cipher_do_one(struct crypto_engine *engine, void *areq) int err; chan = &ce->chanlist[rctx->flow]; - cet = chan->tl; + cet = sun8i_ce_enqueue_one(chan, areq); + if (IS_ERR(cet)) + return PTR_ERR(cet); err = sun8i_ce_cipher_prepare(req, cet); - if (err) + if (err) { + sun8i_ce_dequeue_one(chan); return err; - - err = sun8i_ce_run_task(ce, rctx->flow, - crypto_tfm_alg_name(req->base.tfm)); - - sun8i_ce_cipher_finalize_req(areq, cet, err); + } 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 b6cfc6758a5a..a2addc9f64d9 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c @@ -10,7 +10,7 @@ * You could find a link for the datasheet in Documentation/arch/arm/sunxi.rst */ -#include +#include #include #include #include @@ -171,8 +171,14 @@ static const struct ce_variant ce_r40_variant = { 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); + for (int i = 0; i < chan->reqs_no; ++i) { + struct ce_task *cet = &chan->tl[i]; + char task[CE_MAX_TASK_DESCR_DUMP_MSG_SIZE]; + + snprintf(task, sizeof(task), "TASK %d:", i); + print_hex_dump(KERN_INFO, task, DUMP_PREFIX_NONE, 16, 4, + cet, sizeof(struct ce_task), false); + } } /* @@ -190,10 +196,6 @@ int sun8i_ce_run_task(struct sun8i_ce_dev *ce, int flow, const char *name) u32 v; int err = 0; -#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG - ce->chanlist[flow].stat_req++; -#endif - mutex_lock(&ce->mlock); v = readl(ce->base + CE_ICR); @@ -710,12 +712,107 @@ static int sun8i_ce_debugfs_show(struct seq_file *seq, void *v) DEFINE_SHOW_ATTRIBUTE(sun8i_ce_debugfs); +static int sun8i_ce_get_flow_from_engine(struct sun8i_ce_dev *ce, + struct crypto_engine *engine) +{ + for (int i = 0; i < MAXFLOW; ++i) + if (ce->chanlist[i].engine == engine) + return i; + + return -ENODEV; +} + +static int sun8i_ce_do_batch(struct crypto_engine *engine) +{ + struct sun8i_ce_dev *ce; + struct sun8i_ce_flow *chan; + int err, flow; + + ce = dev_get_drvdata(engine->dev); + flow = sun8i_ce_get_flow_from_engine(ce, engine); + if (flow < 0) + return flow; + + chan = &ce->chanlist[flow]; + + if (!chan->reqs_no) + return 0; + +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG + ce->chanlist[flow].stat_req += chan->reqs_no; +#endif + + for (int i = 0; i < chan->reqs_no - 1; ++i) { + struct ce_task *task = &chan->tl[i]; + dma_addr_t next = chan->t_phy + (i + 1) * sizeof(struct ce_task); + + task->next = desc_addr_val_le32(ce, next); + } + chan->tl[chan->reqs_no - 1].next = 0; + chan->tl[chan->reqs_no - 1].t_common_ctl |= cpu_to_le32(CE_COMM_INT); + + err = sun8i_ce_run_task(ce, flow, "BATCH"); + + for (int i = 0; i < chan->reqs_no; ++i) { + struct crypto_async_request *areq = chan->reqs[i]; + u32 req_type = crypto_tfm_alg_type(areq->tfm); + + if (req_type == CRYPTO_ALG_TYPE_SKCIPHER) + sun8i_ce_cipher_finalize_req(areq, &chan->tl[i], err); + + if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_HASH) && + (req_type == CRYPTO_ALG_TYPE_AHASH)) + sun8i_ce_hash_finalize_req(areq, &chan->tl[i], err); + + chan->reqs[i] = NULL; + } + + chan->reqs_no = 0; + + return err; +} + +struct ce_task *sun8i_ce_enqueue_one(struct sun8i_ce_flow *chan, + struct crypto_async_request *areq) +{ + struct ce_task *cet; + struct crypto_async_request *prev; + u32 alg_type, prev_alg_type; + + if (chan->reqs_no == CE_MAX_REQS_PER_BATCH) + return ERR_PTR(-ENOSPC); + + if (chan->reqs_no) { + prev = chan->reqs[chan->reqs_no - 1]; + prev_alg_type = crypto_tfm_alg_type(prev->tfm); + alg_type = crypto_tfm_alg_type(areq->tfm); + + if (alg_type != prev_alg_type) + return ERR_PTR(-ENOSPC); + } + + cet = chan->tl + chan->reqs_no; + chan->reqs[chan->reqs_no] = areq; + chan->reqs_no++; + + return cet; +} + +void sun8i_ce_dequeue_one(struct sun8i_ce_flow *chan) +{ + if (chan->reqs_no) { + chan->reqs_no--; + chan->reqs[chan->reqs_no] = NULL; + } +} + static void sun8i_ce_free_chanlist(struct sun8i_ce_dev *ce, int i) { while (i >= 0) { crypto_engine_exit(ce->chanlist[i].engine); if (ce->chanlist[i].tl) - dma_free_coherent(ce->dev, sizeof(struct ce_task), + dma_free_coherent(ce->dev, + CE_DMA_TASK_DESCR_ALLOC_SIZE, ce->chanlist[i].tl, ce->chanlist[i].t_phy); i--; @@ -737,7 +834,9 @@ static int sun8i_ce_allocate_chanlist(struct sun8i_ce_dev *ce) for (i = 0; i < MAXFLOW; i++) { init_completion(&ce->chanlist[i].complete); - ce->chanlist[i].engine = crypto_engine_alloc_init(ce->dev, true); + ce->chanlist[i].engine = crypto_engine_alloc_init_and_set( + ce->dev, true, sun8i_ce_do_batch, true, + CE_MAX_REQS_PER_BATCH); if (!ce->chanlist[i].engine) { dev_err(ce->dev, "Cannot allocate engine\n"); i--; @@ -750,9 +849,9 @@ static int sun8i_ce_allocate_chanlist(struct sun8i_ce_dev *ce) goto error_engine; } ce->chanlist[i].tl = dma_alloc_coherent(ce->dev, - sizeof(struct ce_task), - &ce->chanlist[i].t_phy, - GFP_KERNEL); + CE_DMA_TASK_DESCR_ALLOC_SIZE, + &ce->chanlist[i].t_phy, + GFP_KERNEL); if (!ce->chanlist[i].tl) { dev_err(ce->dev, "Cannot get DMA memory for task %d\n", i); diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c index 5d8ac1394c0c..73cfcdb2b951 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c @@ -350,7 +350,6 @@ static int sun8i_ce_hash_prepare(struct ahash_request *areq, struct ce_task *cet 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); cet->t_sym_ctl = 0; @@ -488,15 +487,15 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *async_req) int err; chan = &ce->chanlist[rctx->flow]; - cet = chan->tl; + cet = sun8i_ce_enqueue_one(chan, async_req); + if (IS_ERR(cet)) + return PTR_ERR(cet); err = sun8i_ce_hash_prepare(areq, cet); - if (err) + if (err) { + sun8i_ce_dequeue_one(chan); return err; - - err = sun8i_ce_run_task(ce, rctx->flow, crypto_ahash_alg_name(tfm)); - - sun8i_ce_hash_finalize_req(async_req, cet, err); + } return 0; } diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h index 1022fd590256..424deea18453 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h @@ -104,6 +104,10 @@ #define CE_DIE_ID_MASK 0x07 #define MAX_SG 8 +#define CE_MAX_REQS_PER_BATCH 10 +#define CE_MAX_TASK_DESCR_DUMP_MSG_SIZE 12 +#define CE_DMA_TASK_DESCR_ALLOC_SIZE \ + (CE_MAX_REQS_PER_BATCH * sizeof(struct ce_task)) #define CE_MAX_CLOCKS 4 #define CE_DMA_TIMEOUT_MS 3000 @@ -191,6 +195,8 @@ 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 + * @reqs: array of requests to be processed in batch + * @reqs_no: current number of requests in @reqs * @stat_req: number of request done by this flow */ struct sun8i_ce_flow { @@ -199,6 +205,8 @@ struct sun8i_ce_flow { int status; dma_addr_t t_phy; struct ce_task *tl; + struct crypto_async_request *reqs[CE_MAX_REQS_PER_BATCH]; + int reqs_no; #ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG unsigned long stat_req; #endif @@ -373,6 +381,29 @@ struct sun8i_ce_alg_template { char fbname[CRYPTO_MAX_ALG_NAME]; }; +/** + * sun8i_ce_enqueue_one - add a request to the per-flow batch queue + * @chan: engine flow to enqueue the request + * @areq: request to be added to the batch queue + * + * This function adds request @areq to the batch queue in @chan. Should be + * called during do_one_request() crypto engine handler. + * + * @return - on success, task descriptor associated with the request + * - on failure, ERR_PTR(-ENOSPC) if the queue was full or if the + * request type is different from the requests already queued up + */ +struct ce_task *sun8i_ce_enqueue_one(struct sun8i_ce_flow *chan, + struct crypto_async_request *areq); + +/** + * sun8i_ce_dequeue_one - remove head request from the per-flow batch queue + * @chan: engine flow to remove the request from + * + * This function removes the head request from the batch queue in @chan. + */ +void sun8i_ce_dequeue_one(struct sun8i_ce_flow *chan); + int sun8i_ce_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen); int sun8i_ce_des3_setkey(struct crypto_skcipher *tfm, const u8 *key,