From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) (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 7CC9D10A07 for ; Fri, 29 Dec 2023 09:00:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fairphone.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fairphone.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fairphone.com header.i=@fairphone.com header.b="bfUwC1If" Received: by mail-ej1-f67.google.com with SMTP id a640c23a62f3a-a22f59c6ae6so802347366b.1 for ; Fri, 29 Dec 2023 01:00:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fairphone.com; s=fair; t=1703840456; x=1704445256; darn=vger.kernel.org; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=4YFW2Iq8e4IPK1klqEUPGasZZ4lNFL4o1U6qQyaGioA=; b=bfUwC1IfPl9BrSIPCEdLyPwGiW5Jasbb+GV7gUIqeJUIqNUIqHrX/BJOAuTO8ys/g3 YHaqN9v38oHo0s0y6lGZIZSNi5BJCdngr44CiCeWCuACEtX1MaQ2bgNS3xEJMBS5V8in ixCUO652TGVBr63mMpUX6UOn+aZUTlzH6hU7FPa9HJPGhh3mLjmANw//rGDDaYEpAy00 Eq2j2iQRIsq8yqSbsTxBZGxwxVD/qYHC0v9e+kmrq++xRSNayDM05IGZWBebdbfPkSwk tQagy/tRExtug1R1Jzt4QlPE4H4bPNYdLkb/LV0PH6683LmAyC83/63RQYT1teShK7+l Sxug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703840456; x=1704445256; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=4YFW2Iq8e4IPK1klqEUPGasZZ4lNFL4o1U6qQyaGioA=; b=T9fW/FuiNsBl+x0cPwz/2YztWJTIO3582stwZNw/CAo6IRtQzsajdb83MfRIliyWnc 0nFOqMtLj6AHpQlrPmaeheQl0mVeegazVARB1S/UOklfmjUB6onpi1jrYVIp+l+axLcy Be1rBF6v6dZi4CS7HfyEAvCNAdHJwobS5eTcoWV635/sjK/53McACMZ3MXbBGz/tLc8g U6XgnSGaW+uYdUUQuX3lpE4u/Qa5I/929iZ6C7JtwW+hXbQPUGmzW4LLZ15Qv+7vMQJq OIURvWljECkS8MosHgxesQPPdDykOtGih8IRilluuD1SnlnTFCZvM7ZtvEHZUEc8dX// fOlg== X-Gm-Message-State: AOJu0Yx+YROmaCz0iIxO1GSHwRpgTOtr/h9aoL7LfT1BDBFPUa0XrO0I Ry4cSQGGDcJHwVIH2EGqXfggRhp7uKU1Lg== X-Google-Smtp-Source: AGHT+IFsgyvxY2FIbSeZ4Rhwj26H1SnL4iCSe5/raWPACAtLD2F4iWeQeP0GVD7tgQnJsAiTpkU2iA== X-Received: by 2002:a17:906:6016:b0:a26:a0d9:10a7 with SMTP id o22-20020a170906601600b00a26a0d910a7mr2218391ejj.76.1703840455776; Fri, 29 Dec 2023 01:00:55 -0800 (PST) Received: from localhost (144-178-202-138.static.ef-service.nl. [144.178.202.138]) by smtp.gmail.com with ESMTPSA id bz8-20020a1709070aa800b00a234b686f93sm8161508ejc.187.2023.12.29.01.00.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Dec 2023 01:00:55 -0800 (PST) Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 29 Dec 2023 10:00:54 +0100 Message-Id: To: "Luca Weiss" , "Om Prakash Singh" Cc: , , , , , , , , , , , , , , , Subject: Re: [PATCH V3 2/2] arm64: dts: qcom: sc7280: add QCrypto nodes From: "Luca Weiss" X-Mailer: aerc 0.15.2 References: <20231214103600.2613988-1-quic_omprsing@quicinc.com> <20231214103600.2613988-3-quic_omprsing@quicinc.com> In-Reply-To: On Thu Dec 28, 2023 at 3:29 PM CET, Luca Weiss wrote: > On Thu Dec 14, 2023 at 11:36 AM CET, Om Prakash Singh wrote: > > Add the QCE and Crypto BAM DMA nodes. > > > > Signed-off-by: Om Prakash Singh > > --- > > > > Changes in V3: > > - V2 patch was sent without actual modification. Resending the patch = with modified file. > > > > Changes in V2: > > - Update DT node sequence as per register ascending order. > > - Fix DT node properties as per convention. > > > > arch/arm64/boot/dts/qcom/sc7280.dtsi | 22 ++++++++++++++++++++++ > > 1 file changed, 22 insertions(+) > > > > diff --git a/arch/arm64/boot/dts/qcom/sc7280.dtsi b/arch/arm64/boot/dts= /qcom/sc7280.dtsi > > index 66f1eb83cca7..b819724c1255 100644 > > --- a/arch/arm64/boot/dts/qcom/sc7280.dtsi > > +++ b/arch/arm64/boot/dts/qcom/sc7280.dtsi > > @@ -2233,6 +2233,28 @@ pcie1_phy: phy@1c0e000 { > > status =3D "disabled"; > > }; > > =20 > > + cryptobam: dma-controller@1dc4000 { > > + compatible =3D "qcom,bam-v1.7.4", "qcom,bam-v1.7.0"; > > + reg =3D <0x0 0x01dc4000 0x0 0x28000>; > > + interrupts =3D ; > > + #dma-cells =3D <1>; > > + iommus =3D <&apps_smmu 0x4e4 0x0011>, > > + <&apps_smmu 0x4e6 0x0011>; > > + qcom,ee =3D <0>; > > + qcom,controlled-remotely; > > + }; > > Hi, > > Unfortunately I seem to have boot failure / device crash with cryptobam > enabled on my qcm6490-fairphone-fp5. Are you aware of any firmware > differences that could cause this with QCM6490 LA firmware? > > Looking at downstream msm-5.4 dmesg I do see this BAM being used so it > should generally be accessible from Linux. > > [ 5.217214] qce 1de0000.qcedev: Adding to iommu group 18 > [ 5.223741] QCE50: __qce_get_device_tree_data: CE operating frequency = is not defined, setting to default 100MHZ > [ 5.234986] qce 1de0000.qcedev: QTI Crypto 5.6.0 device found @0x1de00= 00 > [ 5.242981] sps_register_bam_device: sps:BAM 0x0000000001dc4000 is reg= istered > [ 5.251124] sps_bam_enable: sps:BAM 0x0000000001dc4000 (va:0x000000001= db63156) enabled: ver:0x27, number of pipes:16 > [ 5.262783] QCE50: qce_sps_init: QTI MSM CE-BAM at 0x0000000001dc4000= irq 9 > [ 5.271820] qce 1de0000.qcedev:qcom_cedev_ns_cb: Adding to iommu group= 19 > [ 5.281083] qce 1de0000.qcedev:qcom_cedev_s_cb: Adding to iommu group = 20 > [ 5.289376] qcrypto 1de0000.qcrypto: Adding to iommu group 21 > [ 5.296326] QCE50: __qce_get_device_tree_data: CE operating frequency = is not defined, setting to default 100MHZ > [ 5.307675] qcrypto 1de0000.qcrypto: QTI Crypto 5.6.0 device found @0x= 1de0000 > [ 5.315867] QCE50: qce_sps_init: QTI MSM CE-BAM at 0x0000000001dc4000= irq 9 After some hints from Stephan Gerhold, it looks like when the bam driver tries to read the registers for getting num-ees and num-channels we need to have the interconnect up, otherwise the register read fails and resets the device into EDL mode. After applying the patch I've attached below the registers can be read successfully. The patch I've actually sent now[0] adds the values read from these registers as static properties so that during cryptobam probe we don't need to have the interconnect up because we don't read any registers. Stephan Gerhold mentioned off-list that this is an adequate solution because all the other times the cryptobam is used by the &crypto node the interconnect will be up. [0] https://lore.kernel.org/linux-arm-msm/20231229-sc7280-cryptobam-fixup-v= 1-1-bd8f68589b80@fairphone.com/T/#u I imagine the cause why cryptobam & crypto are disabled in sm8350.dtsi is the same, so the solution there probably also is just hardcoding those properties and then using &crypto should work as expected. Regards Luca diff --git a/arch/arm64/boot/dts/qcom/sc7280.dtsi b/arch/arm64/boot/dts/qco= m/sc7280.dtsi index 83b5b76ba179..b2517631e884 100644 --- a/arch/arm64/boot/dts/qcom/sc7280.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7280.dtsi @@ -2345,6 +2345,9 @@ cryptobam: dma-controller@1dc4000 { <&apps_smmu 0x4e6 0x0011>; qcom,ee =3D <0>; qcom,controlled-remotely; + interconnects =3D <&aggre2_noc MASTER_CRYPTO QCOM_ICC_TAG_ALWAYS + &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>; + interconnect-names =3D "memory"; }; =20 crypto: crypto@1dfa000 { diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c index 5e7d332731e0..b2f85c6bcbea 100644 --- a/drivers/dma/qcom/bam_dma.c +++ b/drivers/dma/qcom/bam_dma.c @@ -40,6 +40,7 @@ #include #include #include +#include #include =20 #include "../dmaengine.h" @@ -394,6 +395,7 @@ struct bam_device { const struct reg_offset_data *layout; =20 struct clk *bamclk; + struct icc_path *mem_path; int irq; =20 /* dma start transaction tasklet */ @@ -1298,6 +1300,14 @@ static int bam_dma_probe(struct platform_device *pde= v) return ret; } =20 + bdev->mem_path =3D devm_of_icc_get(bdev->dev, "memory"); + if (IS_ERR(bdev->mem_path)) + return PTR_ERR(bdev->mem_path); + + ret =3D icc_set_bw(bdev->mem_path, 1, 1); + if (ret) + return ret; + ret =3D bam_init(bdev); if (ret) goto err_disable_clk;