From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 795003D3332 for ; Wed, 8 Jul 2026 17:58:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783533539; cv=none; b=JPGy6sJ+S5IixJfdWFsqEfxIGqASDG7beLrwUayej+511TEuIXS/RMCJha6/E8k9oxBJ7oYfCKJs3ASvzoCWlaSYqxuVY9LABYn+ts1QjiA6yXzlKCJttTfJcY8GU/hB7mjg0nYsa+jnd6N1vCU7rKfpBQBRJxr2P9uKwI5RZrk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783533539; c=relaxed/simple; bh=Dx/U1QTn3apYjRiz0yi9z250wQK129Fy+tAB/HadHMY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=qmC8mUtnNpbBGlJXWcpN89AHh3O/BDP0ZnNKX48O4mrzcgCkJ37s4Dkxd6G+9TRF71k3PmMTn1KaGdHF/qqg55QsYW9Z51Fg0XIJHxq5krqIl06krfdCmKPwRZaRNVf/DcgChX1OpvtbVDpZ6Ee20GHZ/v3DTGAwJOmbdi+BsUY= 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=Zy+f3Yfu; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zy+f3Yfu" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-c1274802697so6833366b.3 for ; Wed, 08 Jul 2026 10:58:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783533536; x=1784138336; 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=mQO7OwEt2ayLBwYgGRVhBYGfbjzxMLDxfhpK0SkwD/o=; b=Zy+f3Yfu/N/8tVVS/2aEcVR1GVrcbS53CCvzgs1q63rWItqT8wU9J7alx81f6xSTGQ GtGMG+0cawyOmWcG8diitYzhCGQYBmTeglh3kt/DyElNScC/S1bw5oXQzjYp59uVEUYq v73b+F2ijHYp9/KHfM+iTXJp8h3APA/O4VCbr5cTUm3bsBAQksH2FDRUycRvSD2V9CJ/ HR633lucUQO8CtFojS48UlEE/Ud4YLF3vGb19tQaUuQ+jjeJIQRYYQk6RcDuLOHujyYr fQ/TxujbhbdWK8whc2VHRFEBd3jLYPsAC/0i8yi0C9Z4pqOwxTlK1lpkUAGSoZ8Fy0mG HJZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783533536; x=1784138336; 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=mQO7OwEt2ayLBwYgGRVhBYGfbjzxMLDxfhpK0SkwD/o=; b=h7h4eJqvTrPTq0v5TCZsExw3mxnJebSBy159WuU0t54c3EQ8+f733IRQPRWhfAsoPO KzKAoZy4+6y7v+pd2ZuYumEQnaP7Iy0RfYFsNENtKgIalTlqIqwWjyVCbxPptSVF88Si S5qpNeRoKpCGs1yl++oqJI1g3Gi4bdRhVZxxnWClToMtCX6ts81DnPGs0B+qfrmDWtfU 114wN58JEydln6lDO0XfVT5KJJ1uMmS6rUqUxJSSaPiUL8jXcHPdc/TDv1+QEZBVOGBW QhbnS093E12zRqjtCnyofNaGRyP8A41z7IgDsy6SO6lGdmxfW47EsFvMDCnrqc8vY2UL pEtA== X-Forwarded-Encrypted: i=1; AHgh+Rrlpi49EZ1+cyZ1Raa6+N8JIQcSdzql8pXcTtS++ApH/0B3pdiUcewlrYefb1ylol5omzfF+TisWsm2zUg=@vger.kernel.org X-Gm-Message-State: AOJu0YwMQHkBRTvwwLLn2xBQxG7kOVmhyEiA2QRNYfbk/gzSC4RFatsE lPdJJowUqcFmND8vQKsInjRA+jh7HnS70kZnX1mUEs73NA5lH1l5pj6fdsGBWXhO X-Gm-Gg: AfdE7ckeqeCfun7KZkIXkOmCjh0yXsm3W/jj5GUErGYem5yTeCPLnm7+vbMCIzxCvmk GOcb6e8EOjNOpTERTR0vHQ/qjRawtVi3ADaPBrvZcgAe2qiaYwP/4KGO7OkPte4R27AlzRDtbhr m33ZtMI2fLvG7pCflL7Zg6GHFhiFiQsUm7dm3T5bIdkccEqN0QxeD0OjVQ686PT8W9RiNZKQNOI vOgGhceCp23lBuuOflorV0wu7FZLUVv08Wq57HauZe8RDxVCSkNeZwuic9obf1AGglYPSAgcOwF EqPezOv0ZUYx08TocDT7DgssfBfgxwJqjxW8P6KLgbUDYvYPHInhmxBXlttE1LPabWUvtQVwiy3 8Xj/r2EATpR/gITZg7s0Om+Br3fWg1p7Nl9Q1t24FGkTtj6iIijLKfv/gNH5r0aqfdm8aUNqJ5I PFXPBeTw== X-Received: by 2002:a17:906:4fce:b0:c12:5e26:da50 with SMTP id a640c23a62f3a-c15ce14c65bmr157380766b.65.1783533535639; Wed, 08 Jul 2026 10:58:55 -0700 (PDT) Received: from olympus.. ([2a0a:ef40:ea3:3f01:2e0:4cff:fe68:285]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c15ad9bcc26sm357653666b.34.2026.07.08.10.58.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 10:58:55 -0700 (PDT) From: Dawid Olesinski To: Herbert Xu , "David S . Miller" , Rob Herring , Krzysztof Kozlowski Cc: Conor Dooley , Heiko Stuebner , Corentin Labbe , linux-crypto@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Dawid Olesinski Subject: [PATCH v2 0/4] crypto: rockchip: Add RK356x/RK3588 cryptographic offloader Date: Wed, 8 Jul 2026 18:58:21 +0100 Message-ID: <20260708175837.1718437-1-dawidro@gmail.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This series adds support for the second-generation (V2) Rockchip cryptographic hardware accelerator found on RK3568 and RK3588 SoCs. The IP block provides AES (ECB, CBC, XTS) and hash (SHA-1, SHA-256, SHA-384, SHA-512, MD5, SM3) offload via an LLI-based DMA engine. The series is ordered as required: binding first, then driver, then the two DTS nodes that reference the binding. A prerequisite patch removing SECURECRU reset definitions from the non-secure CRU driver is sent separately to the clk/reset tree, as it touches a different subsystem. That patch is not a hard dependency for the driver to build or load, but it is needed for correctness on RK3588: those register offsets map into TrustZone-protected MMIO and must not be accessed directly by Linux. This work started from unmerged patches by Corentin Labbe posted at: https://patchew.org/linux/20231107155532.3747113-1-clabbe@baylibre.com/ The implementation has been substantially reworked. Notable changes from Corentin's original series: - DMA descriptor race condition and DMA mapping leak on timeout fixed - Per-device algorithm copy replaces global device list, removing a locking bottleneck and correctly supporting multiple instances - Runtime PM autosuspend added; clocks and reset gated between requests - Multi-SG hash requests routed to software fallback (hardware padding engine requires total message length upfront and cannot maintain state across LLI boundaries) - Hardware interrupt enable register write corrected to use the HIWORD_UPDATE mask that the hardware requires - Software fallback for all registered algorithms; statesize promotion for export/import compatibility with ARM Crypto Extensions drivers - SCMI reset and clock references in DTS corrected for RK3588 Tested on Orange Pi 5 Pro (RK3588S). All nine algorithm selftests pass. AES-CBC throughput measured at ~100 MiB/s with cryptsetup. PM autosuspend/resume verified over 1000 consecutive hash requests with no errors. 20 modprobe/rmmod cycles produce no DMA coherent memory leaks. Patch series for the crypto subsystem: [1/4] dt-bindings: crypto: rockchip: Add RK356x/RK3588 crypto engine binding [2/4] crypto: rockchip: Add RK356x/RK3588 cryptographic offloader driver [3/4] arm64: dts: rockchip: Add crypto node to rk356x-base [4/4] arm64: dts: rockchip: Add crypto node to rk3588-base Separate patch for clk/reset tree: clk: rockchip: rk3588: Remove SECURECRU reset definitions Changes in v2: - dt-bindings: wrap example in a bus node with #address/#size-cells = 2 and add the SCMI clock/reset dt-binding includes so dt_binding_check passes (Rob Herring / Krzysztof Kozlowski review). - crypto: fix Kconfig to select CRYPTO_SM3 instead of the non-existent CRYPTO_SM3_GENERIC. - crypto: drop IRQF_SHARED (the line is dedicated) and request the IRQ only after clocks are enabled and the completion is initialised; reorder probe accordingly. - crypto: set a 32-bit DMA mask before allocating the descriptor table. - crypto: suspend the device explicitly on removal before disabling runtime PM to avoid leaking clocks. - crypto: call synchronize_irq() on the DMA timeout paths to close a race with delayed interrupts. - crypto: convert fallback statistics to atomic_long_t. - crypto: use cpu_to_le32() for all LLI descriptor fields (big-endian correctness). - crypto: read key/IV with get_unaligned_be32() to fix an alignment fault and a big-endian double-swap. - crypto: fix the CBC/XTS IV backup offset to use the processed length instead of the scatterlist capacity. - arm64: dts: rk356x: move the crypto node into unit-address order. v1: https://patchwork.kernel.org/project/devicetree/cover/20260530160704.3453555-1-dawidro@gmail.com/ Build/rebase fixes (not from review): - crypto: use sizeof(struct sm3_ctx) for the SM3 statesize, as struct sm3_state was removed by the lib/crypto SM3 conversion. - crypto: add the missing SHA-224 zero-message case. Dawid Olesinski (4): dt-bindings: crypto: rockchip: Add RK356x/RK3588 crypto engine binding crypto: rockchip: Add RK356x/RK3588 cryptographic offloader driver arm64: dts: rockchip: Add crypto node to rk356x-base arm64: dts: rockchip: Add crypto node to rk3588-base .../crypto/rockchip,rk3588-crypto.yaml | 75 ++ arch/arm64/boot/dts/rockchip/rk356x-base.dtsi | 12 + arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 12 + drivers/crypto/Kconfig | 32 + drivers/crypto/Makefile | 1 + drivers/crypto/rockchip/Makefile | 5 + drivers/crypto/rockchip/rk2_crypto.c | 746 ++++++++++++++++++ drivers/crypto/rockchip/rk2_crypto.h | 249 ++++++ drivers/crypto/rockchip/rk2_crypto_ahash.c | 565 +++++++++++++ drivers/crypto/rockchip/rk2_crypto_skcipher.c | 728 +++++++++++++++++ 10 files changed, 2425 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/rockchip,rk3588-crypto.yaml create mode 100644 drivers/crypto/rockchip/rk2_crypto.c create mode 100644 drivers/crypto/rockchip/rk2_crypto.h create mode 100644 drivers/crypto/rockchip/rk2_crypto_ahash.c create mode 100644 drivers/crypto/rockchip/rk2_crypto_skcipher.c -- 2.47.3