From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74D54C433F5 for ; Wed, 23 Mar 2022 13:22:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244266AbiCWNYR (ORCPT ); Wed, 23 Mar 2022 09:24:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244263AbiCWNYQ (ORCPT ); Wed, 23 Mar 2022 09:24:16 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A705E7CDFF for ; Wed, 23 Mar 2022 06:22:45 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id v22so2125761wra.2 for ; Wed, 23 Mar 2022 06:22:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=nFhPQ/2TAffPjbDjiI/2I0v37r+CcQs5C7D/sWxAMI8=; b=quPIS4rlbqNNwzlG7UsIcANuXUutqUX2+fS2vwwVrkSb8FadLyZ9PZuzt3n4FECs6b JD3NheA8m53Arv3IJp2+FRXgb8apclZMBwVLZzL1u949YS0k93kjWRoPRC7j6cfksk60 qxWnya1GQ0o6FnD0kdxsnW3YSZ6iUb00BQ9WyMilezQ5n3ltGCDn+C8jl6rMTHz5Oakz /607HtEh8xP6zzvxbUd5PSpNYWuV9/bc8PQYBMTN/o3/amywjFJkjwFPiEjWUSPZsUf+ UUicmWGMkDbN/NfGnIkjbJTQNk7WhHnpkDNNvhtM2OQ7+b+7vY0duYDYvrj3Vwl6M31g 2puA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=nFhPQ/2TAffPjbDjiI/2I0v37r+CcQs5C7D/sWxAMI8=; b=FRmM6y1dYwNfm32S3F5RDclJ64+GkJC6574OoPOl/C6mIfPzXSSfq2qGdLo0cgHWfb jEmqECGDwQAOjsrDDmpQk4wG1F7vHeZ4kfrXp+phQ1bCYO0GfLKF3ZnN0JUubriKG2J5 WPFjS3dcV3HpwT5ypBzwDbghHM9TQCD+UzQKNbdz73jgv0uULvnrGcln6vRid6LegIyH wfeGU2U5Da4jE1SjXGoTY+68EcZdff8SyqntBcXO8AI2NDVOiENaQEx6fWWww/YKx3HT gdQleaM+22z9k6z0OXBRJotMcwDjVVNEwHkwtGU2qglYGxHcJUC95CYzjOT/C4XhUy2r idLA== X-Gm-Message-State: AOAM531rLhcw2q5HahMXZ4o709LFsWnA6Wb5z1YyPXnlYIrFws3Cr2WA Pc5Ujnvaw/ui5NrgCu7EBDdSmQ== X-Google-Smtp-Source: ABdhPJzktCyQ+4ZXtq4E5zEr/KHSW2QBwhlwN+M/BloZ0THBfCmhcKR2IkHX5we1S2uX5VNg/THYAA== X-Received: by 2002:a05:6000:1b86:b0:1f0:d6f:1424 with SMTP id r6-20020a0560001b8600b001f00d6f1424mr26954876wru.174.1648041764214; Wed, 23 Mar 2022 06:22:44 -0700 (PDT) Received: from Red ([2a01:cb1d:3d5:a100:264b:feff:fe03:2806]) by smtp.googlemail.com with ESMTPSA id l15-20020a05600c4f0f00b0038cbdf5221dsm2806353wmq.41.2022.03.23.06.22.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 06:22:43 -0700 (PDT) Date: Wed, 23 Mar 2022 14:22:41 +0100 From: LABBE Corentin To: Robin Murphy Cc: heiko@sntech.de, herbert@gondor.apana.org.au, krzk+dt@kernel.org, mturquette@baylibre.com, robh+dt@kernel.org, sboyd@kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org Subject: Re: [PATCH v3 18/26] arm64: dts: rockchip: rk3399: add crypto node Message-ID: References: <20220321200739.3572792-1-clabbe@baylibre.com> <20220321200739.3572792-19-clabbe@baylibre.com> <70422777-a3f9-b2f1-5faa-94d24fe200ac@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <70422777-a3f9-b2f1-5faa-94d24fe200ac@arm.com> Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Le Tue, Mar 22, 2022 at 12:00:06PM +0000, Robin Murphy a écrit : > On 2022-03-21 20:07, Corentin Labbe wrote: > > The rk3399 has a crypto IP handled by the rk3288 crypto driver so adds a > > node for it. > > > > Signed-off-by: Corentin Labbe > > --- > > arch/arm64/boot/dts/rockchip/rk3399.dtsi | 12 ++++++++++++ > > 1 file changed, 12 insertions(+) > > > > diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi b/arch/arm64/boot/dts/rockchip/rk3399.dtsi > > index 88f26d89eea1..ca2c658371a5 100644 > > --- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi > > +++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi > > @@ -573,6 +573,18 @@ saradc: saradc@ff100000 { > > status = "disabled"; > > }; > > > > + crypto0: crypto@ff8b0000 { > > + compatible = "rockchip,rk3399-crypto"; > > + reg = <0x0 0xff8b0000 0x0 0x4000>, > > + <0x0 0xff8b8000 0x0 0x4000>; > > + interrupts = , > > + ; > > + clocks = <&cru SCLK_CRYPTO0>, <&cru HCLK_M_CRYPTO0>, <&cru HCLK_S_CRYPTO0>, > > + <&cru SCLK_CRYPTO1>, <&cru HCLK_M_CRYPTO1>, <&cru HCLK_S_CRYPTO1>; > > + resets = <&cru SRST_CRYPTO0>, <&cru SRST_CRYPTO0_S>, <&cru SRST_CRYPTO0_M>, > > + <&cru SRST_CRYPTO1>, <&cru SRST_CRYPTO1_S>, <&cru SRST_CRYPTO1_M>; > > + }; > > What's going on here? If these are simply two instances of the same IP > block as the evidence suggests, why are they crammed into a single DT > node rather than simply being described as two separate instances? I was > rather wondering what all the confusing mess in patch #16 was about, > until I got here. > > If there's something in the crypto API that means the driver can't > simply naively register itself multiple times, there should be any > number of ways for the probe routine to keep track of whether it's > already registered something and associate any subsequent devices with > the first one internally if need be. Linux implementation details should > not leak out as non-standard DT weirdness. > > I know the Rockchip IOMMU driver does this, but in that case the two > IOMMU instances are closely coupled and sharing work such that they > effectively need to be programmed identically at all times, so it was a > bit more justifiable. I don't know the full story here, but it certainly > looks like rk_get_engine_number() is just a means to schedule work on > any available unit independently, so looks like it wouldn't take much to > select between distinct devices at that point, and actually end up a lot > simpler and cleaner overall. Yes rk3399 has 2 instances of the same IP (Exception: crypto1 does not have RSA). The problem is that only one drivername (like rk-md5) could exists. If crypto0 and crypto1 register with different drivername (rk-md5-0/rk-md5-1), only one will be used anyway. So I merged them into only one instance. I think this way will be easier, but you are right, this is not pretty. I found another way with 2 nodes: You could preview it at https://github.com/montjoie/linux/tree/cryptorockchipv4 Basicly the crypto0 is a normal instance, and crypto1 "registers" itself against crypto0. So if crypto0 know another instance exists it will load balance requests. Regards