From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796206045; b=V/rEgXedtthnb4+TNZmUh3DVezHIk2x7ENQPGHW6p/xTOX2ho/SkY0hczitnDHUhjEkp m9IcwxdPHNpovR+iWOW5PIQX3H1BQZ6qrJB22+9cel0y0hA75QW+QR5Zu+O4TP/WJ8Qfa 9q/HG972cX0BLE6NFuE3Zb3tmaaIoI7OefqpD9z8Kxi2XchCm2H3SUgmnmgLL6DMVp+0J OsSCjBVH2H2UQm8lqPCba6kpWVvbLwIaXOErVhvyqA0geq8JEag2iezUn600dlFh773oO 4t+EgVijKTFSXka2YslF1KGQRUwwL53dvXcnxEiv/TZ395cbmO02GspIWIojAcKwmig== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796206045; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=YSCqpNzKs3+wLNUSpT4FdOion3SVHtMtD5pmOvWpdqw=; b=TNR6Fo/vjx20oP4/nnshEIDarGHt08UKYL1I0IDRba7yp4Rk3cljvgUEMr5NVvLebEvx DJI2POqUCI7ENSQpauHyFKNzDRA8Wy2c+3D53GMPVyimEpXnFgUYgD4qb3vgvnm+qAjBO d+l6yaEI0Um+J2pujtVL4E7g3UCM8/TzLLM/r1a30ic19d2UJ/RG7WV3HtvB/g4RuHGsl gAceKhvwK+ykH+QmA48Fqlsav/9EIF2iXbm6zJ/DRQgZ/hP+Ddjj5wImlQ9m3uB7QbZvT q79AidEw7odQbLJoxpAkwjHxiGReE5+nrgKm9GmeZlQAnMTHbWN8Ouni6VHS8GiXcHg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=P1rKMoXC; arc=none smtp.remote-ip=209.85.221.51 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 291E3606A31A for ; Wed, 2 Dec 2026 10:07:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 291E3606A31A 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.a=rsa-sha256 header.s=20260707 header.b=P1rKMoXC Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-4c4b8e58c9aso2379125f8f.0 for ; Wed, 02 Dec 2026 02:07:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796206043; x=1796810843; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=YSCqpNzKs3+wLNUSpT4FdOion3SVHtMtD5pmOvWpdqw=; b=P1rKMoXCiv+fR2dzdtypEAVIgEWTc4cpV0LeiJIEFli4TqAqRl+dG4VKbBChtu8gPg vYAXvrRxGfLGmt6YwdTNth2B4fP+SiXjnNiDi0VWUjiz0BBa0beD+JWmBaDVrBOTBBhK SjN3gAe5Aig3s92qwyPjZoPobO17pU+q+FTZluDxLlz6PdpEHsfMUk4p31HUz77uHbbJ dbrkboMxsnIx8qBnTY6nyQ0V8GHN717MeCEy6CS379oL7P9Lhp8dElR1IUn+TAdUfGBu gKyzlOjCyHNOkKkyfwebvGjej+zPPoGgrsqjv6q9XYV4RFIhAIFjeOlN9CrHXt474yEu PFZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796206043; x=1796810843; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YSCqpNzKs3+wLNUSpT4FdOion3SVHtMtD5pmOvWpdqw=; b=mlfXrXF9iYnUGjSSqSPgDJZkNSJlx5wZLTGcPfPunEBeylJAmmKqjammUng6ZGe1EZ g2jgY5LbIcuIsRuyAx/MAHwuoiCHh2nTWVd5AxIcCa/kPSNzoxNnqNVlktUZYxqFqx/2 6TaECi6NWxQiEWVma88euB1JyS84Ia87Ax28DvObmV8BYe4+FSR0JEM1IgW3CgMWzMtB 60rvCHkaU0pSssG+ZZ5DZyP6WeCnGyRB+c+P8oJTQLnToIiDLaDx0gro2UyuDoJ+TCov qTiVe37y4xnlzK4IFiQLlidxp8yaILSQfAefcDZpIBIPc+zz2oxUhFQf6T82epWR2ze2 +nhQ== X-Forwarded-Encrypted: i=1; AL+hErFog18Uwwfp6JRA04yHepHWlNEXTUh7fTF0xW45+YGKWb6rk9MFmqlEg+scqXmbeHOxUBrbaVRtejgUsig=@vger.kernel.org X-Gm-Message-State: APuU4Z/QS4M/Prup67Gcl4sgHgjADz+oDoiZeVpcr/AYngoxmHhM1Xoe ywiK3zmGvH0VIP4VdFGjgfUhBCuhtfvddghcXFLaPwRjiHrre5de0rvF X-Gm-Gg: AZFdTZdg090xeHimu5HNeoI/tbRAfWG4Y3VuhUeTq9kSUtQWwmJbQh5QGPVtajV/522 Lr4zz9RVgkmLRVAyBYfBsG9k9vd/ir/DE9mLfN1U7UpMilBLPdYkRWs6WVK8T4LBpxISzCMhEoE IHQ2JBnTyuOUYECbsNtDwmO2Pu2xzevDimaLI+h8x7o2wZfs9umtDxuvE/QPHYlBdKrATWQMuwb oON3OzUm7dCrooOPkM9b5NVmA1nZNT/Cbnt/4adACgTPb3E4rjLnhOe7H9WlhRhYIml4KuzKQCW DQhmuumrew3EnUL+vOxqD5NwI5WmrUXYBGN2U7/8Q6lAqfo60rEECE+FlWRRNvQliUd0swU56z5 220QWNdYswYj867Q5qm0Z2Yrf5K2GVHyrkX5iYM+aOPElEgPjTX6HsFw5IiminVhEECePJjb8zb G+tOXWbTleX+yvlNjd3SgRD/3CbOwEwIP1UIvaV2eAWo2D4N/x4ztlUPXm9qtDzMZmgUvpuH78G 1MkJ6vY5YRirFXoW1uujYuPIl09qY4qMSVNXcssbQYZAkkb4ZJOistUvZeO1Oo39PcPM0oyb2fZ vP88uK6BzYnrImWGszUrLPaCNny6P67/SjRNh7KwvWUnqDRZsIPJepc6XUi+veMQGG0= X-Received: by 2002:a05:6000:4008:b0:4b6:8c1:bc3d with SMTP id ffacd0b85a97d-4b608c1bc69mr52667220f8f.57.1796206043409; Wed, 02 Dec 2026 02:07:23 -0800 (PST) Received: from localhost.localdomain ([79.117.198.103]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6a67fe75sm87617495f8f.24.2026.12.02.02.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 02:07:22 -0800 (PST) From: Jose Nieto To: Corentin Labbe , Herbert Xu , "David S . Miller" Cc: linux-crypto@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jose Nieto Subject: [PATCH v15 00/35] crypto: amlogic: add support for G12/AXG/A1/S4 and misc fixes Date: Wed, 2 Dec 2026 11:06:39 +0100 Message-ID: <20261202100714.115460-1-jnieto.alaber@gmail.com> X-Mailer: git-send-email 2.47.3 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This is v15 of the Amlogic crypto driver series originally posted by Alexey Romanov. It rebases the series onto linux-next (next-20261123) and adds, on top of the original patches, the fixes required for the current tree and the corrections raised during review. This version is sent as its own thread, as requested. The original 22 patches by Alexey Romanov are kept untouched (authorship is preserved); I only appended my own Signed-off-by trailer, so the DCO is complete now. On top of them: - the fixes that landed in the driver since v12 are preserved (IRQ handler return value and fallthrough, devm clock management, DMA SG unmap on the cipher error path, probe cleanup, devm_kmalloc_obj conversion); - three patches add what is needed for the current code (drop CRYPTO_ALG_ALLOCATES_MEMORY so dm-crypt can select the hardware engine, the ahash ->digest one-shot path, and a small cleanup); - the review fixes: probe/registration error paths, key/IV descriptor sizing and CBC IV reload, the redundant A1 platform data, the A1/S4 crypto clock, hasher request completion and DMA context, algorithm pointer cleanup on unregister, per-flow completion init before the IRQ, a per-request key/IV buffer, and keeping the bus clock enabled. Changes in v15: - add my Signed-off-by to every patch carried from Alexey (DCO); - drop the "keep standard property order" binding patch: clocks may stay after interrupts; - sent as a new thread (not attached to v13/v14); - hasher: return 0 after finalizing the request (the crypto engine also completes it on a negative return, causing a double completion), use ahash_request_ctx_dma(), always unmap the partial buffer, and guard a NULL request scatterlist; - core: clear algs[i].mc on unregister, initialize the per-flow completion before requesting its IRQ, and get/enable the device tree bus clock; - cipher: size the key/IV setup descriptors from the actual key/IV length (fixing an out-of-bounds DMA read in ECB mode on GXL/AXG), reload the CBC IV on every hardware kick (fixing multi-batch CBC), keep the DMA-mapped key/IV buffer per request (removing a race between concurrent requests on the same transform), zero the unused tail of the per-tfm key buffer on re-key and make meson_handle_cipher_request() static. Tested on Khadas VIM3 (A311D / G12B), booted with a linux-next kernel built from this series: - the crypto self-tests (known-answer tests) pass for ecb/cbc(aes) and sha1/224/256; - dm-crypt with aes-cbc-plain runs on top of cbc-aes-gxl and the driver's request counter accounts for the I/O; - the hardware hasher matches a software SHA-256 for both the one-shot and the streaming (init/update/final) paths, including a >8 MiB multi-batch CBC request. A note on the automated review reports against v13/v14 (Sashiko): - the claim that ctx.keyiv.len does not cover the CBC IV is not correct for this series: for CBC, ctx.keyiv.len is extended to AES_MAX_KEY_SIZE + ivsize before the buffer is mapped; - the sg_virt()/sg_dma_len() coalescing concern does not apply on these SoCs: there is no IOMMU, dma_map_sg() keeps the scatterlist entries and the DMA segments 1:1, and the key/IV buffer is separate request memory. Thanks, Jose Alexey Romanov (22): dt-bindings: crypto: amlogic,gxl-crypto: correct clk and interrupt lines dt-bindings: crypto: amlogic,gxl-crypto: support new SoC's crypto: amlogic - Don't hardcode IRQ count crypto: amlogic - Add platform data crypto: amlogic - Remove clock input crypto: amlogic - Add MMIO helpers crypto: amlogic - Move get_engine_number() crypto: amlogic - Drop status field from meson_flow crypto: amlogic - Move algs definition and cipher API to cipher.c crypto: amlogic - Cleanup defines crypto: amlogic - Process more than MAXDESCS descriptors crypto: amlogic - Avoid kzalloc in engine thread crypto: amlogic - Introduce hasher crypto: amlogic - Use fallback for 192-bit keys crypto: amlogic - Add support for G12-series crypto: amlogic - Add support for AXG-series crypto: amlogic - Add support for A1-series arm64: dts: amlogic: gxl: correct crypto node definition arm64: dts: amlogic: a1: add crypto node arm64: dts: amlogic: s4: add crypto node arm64: dts: amlogic: g12: add crypto node arm64: dts: amlogic: axg: add crypto node Jose Nieto (13): crypto: amlogic: g12: drop CRYPTO_ALG_ALLOCATES_MEMORY crypto: amlogic: hasher: add one-shot digest path crypto: amlogic: drop unused field and stale includes crypto: amlogic: fix probe and algorithm registration error paths crypto: amlogic: fix setup descriptor lengths and CBC IV reload crypto: amlogic: drop redundant A1 platform data arm64: dts: amlogic: use the system clock for A1/S4 crypto crypto: amlogic: fix hasher request completion and DMA context crypto: amlogic: clear algorithm pointers on unregister crypto: amlogic: minor cipher cleanups crypto: amlogic: initialize flow completion before requesting IRQ crypto: amlogic: keep the cipher key/IV buffer per request crypto: amlogic: keep the bus clock enabled .../bindings/crypto/amlogic,gxl-crypto.yaml | 32 +- arch/arm64/boot/dts/amlogic/meson-a1.dtsi | 8 + arch/arm64/boot/dts/amlogic/meson-axg.dtsi | 7 + .../boot/dts/amlogic/meson-g12-common.dtsi | 7 + arch/arm64/boot/dts/amlogic/meson-gxl.dtsi | 6 +- arch/arm64/boot/dts/amlogic/meson-s4.dtsi | 7 + drivers/crypto/amlogic/Makefile | 2 +- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 621 ++++++++++++------ drivers/crypto/amlogic/amlogic-gxl-core.c | 274 ++++---- drivers/crypto/amlogic/amlogic-gxl-hasher.c | 512 +++++++++++++++ drivers/crypto/amlogic/amlogic-gxl.h | 121 +++- 11 files changed, 1224 insertions(+), 373 deletions(-) create mode 100644 drivers/crypto/amlogic/amlogic-gxl-hasher.c base-commit: 3191063649dbf7c0d0b768e1f3655e4c5fc6edb5 -- 2.47.3