linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] Enable Qualcomm Crypto Engine on sdm845
@ 2020-11-17 13:47 Thara Gopinath
  2020-11-17 13:47 ` [PATCH 1/6] dt-binding:clock: Add entry for crypto engine RPMH clock resource Thara Gopinath
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Thara Gopinath @ 2020-11-17 13:47 UTC (permalink / raw)
  To: agross, bjorn.andersson, herbert, davem, robh+dt, sboyd, mturquette
  Cc: linux-arm-msm, linux-crypto, devicetree, linux-kernel, linux-clk

Qualcomm crypto engine supports hardware accelerated algorithms for
encryption and authentication. Enable support for aes,des,3des encryption
algorithms and sha1,sha256, hmac(sha1),hmac(sha256) authentication
algorithms on sdm845.The patch series has been tested using the kernel
crypto testing module tcrypto.ko.

Thara Gopinath (6):
  dt-binding:clock: Add entry for crypto engine RPMH clock resource
  clk:qcom:rpmh: Add CE clock on sdm845.
  drivers:crypto:qce: Enable support for crypto engine on sdm845.
  drivers:crypto:qce: Fix SHA result buffer corruption issues.
  dts:qcom:sdm845: Add dt entries to support crypto engine.
  devicetree:bindings:crypto: Extend qcom-qce binding to add support for
    crypto engine version 5.4

 .../devicetree/bindings/crypto/qcom-qce.txt   |  4 ++-
 arch/arm64/boot/dts/qcom/sdm845.dtsi          | 30 +++++++++++++++++++
 drivers/clk/qcom/clk-rpmh.c                   |  2 ++
 drivers/crypto/qce/core.c                     | 17 ++++++++++-
 drivers/crypto/qce/sha.c                      |  2 +-
 include/dt-bindings/clock/qcom,rpmh.h         |  1 +
 6 files changed, 53 insertions(+), 3 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/6] dt-binding:clock: Add entry for crypto engine RPMH clock resource
  2020-11-17 13:47 [PATCH 0/6] Enable Qualcomm Crypto Engine on sdm845 Thara Gopinath
@ 2020-11-17 13:47 ` Thara Gopinath
  2020-11-18  3:57   ` Bjorn Andersson
  2020-11-17 13:47 ` [PATCH 2/6] clk:qcom:rpmh: Add CE clock on sdm845 Thara Gopinath
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Thara Gopinath @ 2020-11-17 13:47 UTC (permalink / raw)
  To: agross, bjorn.andersson, herbert, davem, robh+dt, sboyd, mturquette
  Cc: linux-arm-msm, linux-crypto, devicetree, linux-kernel, linux-clk

Add clock id forc CE clock resource which is required to bring up the
crypto engine on sdm845.

Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
---
 include/dt-bindings/clock/qcom,rpmh.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/dt-bindings/clock/qcom,rpmh.h b/include/dt-bindings/clock/qcom,rpmh.h
index 2e6c54e65455..30111c8f7fe9 100644
--- a/include/dt-bindings/clock/qcom,rpmh.h
+++ b/include/dt-bindings/clock/qcom,rpmh.h
@@ -21,5 +21,6 @@
 #define RPMH_IPA_CLK				12
 #define RPMH_LN_BB_CLK1				13
 #define RPMH_LN_BB_CLK1_A			14
+#define RPMH_CE_CLK				15
 
 #endif
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/6] clk:qcom:rpmh: Add CE clock on sdm845.
  2020-11-17 13:47 [PATCH 0/6] Enable Qualcomm Crypto Engine on sdm845 Thara Gopinath
  2020-11-17 13:47 ` [PATCH 1/6] dt-binding:clock: Add entry for crypto engine RPMH clock resource Thara Gopinath
@ 2020-11-17 13:47 ` Thara Gopinath
  2020-11-18  3:59   ` Bjorn Andersson
  2020-11-17 13:47 ` [PATCH 3/6] drivers:crypto:qce: Enable support for crypto engine " Thara Gopinath
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Thara Gopinath @ 2020-11-17 13:47 UTC (permalink / raw)
  To: agross, bjorn.andersson, herbert, davem, robh+dt, sboyd, mturquette
  Cc: linux-arm-msm, linux-crypto, devicetree, linux-kernel, linux-clk

Qualcomm CE clock resource that is managed by BCM is required
by crypto driver to access the core clock.

Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
---
 drivers/clk/qcom/clk-rpmh.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
index e2c669b08aff..7e2a4a9b9bf6 100644
--- a/drivers/clk/qcom/clk-rpmh.c
+++ b/drivers/clk/qcom/clk-rpmh.c
@@ -349,6 +349,7 @@ DEFINE_CLK_RPMH_VRM(sdm845, rf_clk2, rf_clk2_ao, "rfclka2", 1);
 DEFINE_CLK_RPMH_VRM(sdm845, rf_clk3, rf_clk3_ao, "rfclka3", 1);
 DEFINE_CLK_RPMH_VRM(sm8150, rf_clk3, rf_clk3_ao, "rfclka3", 1);
 DEFINE_CLK_RPMH_BCM(sdm845, ipa, "IP0");
+DEFINE_CLK_RPMH_BCM(sdm845, ce, "CE0");
 
 static struct clk_hw *sdm845_rpmh_clocks[] = {
 	[RPMH_CXO_CLK]		= &sdm845_bi_tcxo.hw,
@@ -364,6 +365,7 @@ static struct clk_hw *sdm845_rpmh_clocks[] = {
 	[RPMH_RF_CLK3]		= &sdm845_rf_clk3.hw,
 	[RPMH_RF_CLK3_A]	= &sdm845_rf_clk3_ao.hw,
 	[RPMH_IPA_CLK]		= &sdm845_ipa.hw,
+	[RPMH_CE_CLK]		= &sdm845_ce.hw,
 };
 
 static const struct clk_rpmh_desc clk_rpmh_sdm845 = {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/6] drivers:crypto:qce: Enable support for crypto engine on sdm845.
  2020-11-17 13:47 [PATCH 0/6] Enable Qualcomm Crypto Engine on sdm845 Thara Gopinath
  2020-11-17 13:47 ` [PATCH 1/6] dt-binding:clock: Add entry for crypto engine RPMH clock resource Thara Gopinath
  2020-11-17 13:47 ` [PATCH 2/6] clk:qcom:rpmh: Add CE clock on sdm845 Thara Gopinath
@ 2020-11-17 13:47 ` Thara Gopinath
  2020-11-18  4:02   ` Bjorn Andersson
  2020-11-17 13:47 ` [PATCH 4/6] drivers:crypto:qce: Fix SHA result buffer corruption issues Thara Gopinath
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Thara Gopinath @ 2020-11-17 13:47 UTC (permalink / raw)
  To: agross, bjorn.andersson, herbert, davem, robh+dt, sboyd, mturquette
  Cc: linux-arm-msm, linux-crypto, devicetree, linux-kernel, linux-clk

Add support Qualcomm Crypto Engine accelerated encryption and
authentication algorithms on sdm845.

Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
---
 drivers/crypto/qce/core.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c
index ea616b7259ae..67c3ca13e55b 100644
--- a/drivers/crypto/qce/core.c
+++ b/drivers/crypto/qce/core.c
@@ -160,7 +160,21 @@ static int qce_check_version(struct qce_device *qce)
 		return -ENODEV;
 
 	qce->burst_size = QCE_BAM_BURST_SIZE;
-	qce->pipe_pair_id = 1;
+
+	/*
+	 * Rx and tx pipes are treated as a pair inside CE.
+	 * Pipe pair number depended on the actual BAM dma pipe
+	 * that is used for transfers. The BAM dma pipes are passed
+	 * from the device tree and used to derive the pipe pair
+	 * id in the CE driver as follows.
+	 * 	BAM dma pipes(rx, tx)		CE pipe pair id
+	 *		0,1				0
+	 *		2,3				1
+	 *		4,5				2
+	 *		6,7				3
+	 *		...
+	 */
+	qce->pipe_pair_id = qce->dma.rxchan->chan_id >> 1;
 
 	dev_dbg(qce->dev, "Crypto device found, version %d.%d.%d\n",
 		major, minor, step);
@@ -261,6 +275,7 @@ static int qce_crypto_remove(struct platform_device *pdev)
 
 static const struct of_device_id qce_crypto_of_match[] = {
 	{ .compatible = "qcom,crypto-v5.1", },
+	{ .compatible = "qcom,crypto-v5.4", },
 	{}
 };
 MODULE_DEVICE_TABLE(of, qce_crypto_of_match);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 4/6] drivers:crypto:qce: Fix SHA result buffer corruption issues.
  2020-11-17 13:47 [PATCH 0/6] Enable Qualcomm Crypto Engine on sdm845 Thara Gopinath
                   ` (2 preceding siblings ...)
  2020-11-17 13:47 ` [PATCH 3/6] drivers:crypto:qce: Enable support for crypto engine " Thara Gopinath
@ 2020-11-17 13:47 ` Thara Gopinath
  2020-11-18  4:04   ` Bjorn Andersson
  2020-11-17 13:47 ` [PATCH 5/6] dts:qcom:sdm845: Add dt entries to support crypto engine Thara Gopinath
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Thara Gopinath @ 2020-11-17 13:47 UTC (permalink / raw)
  To: agross, bjorn.andersson, herbert, davem, robh+dt, sboyd, mturquette
  Cc: linux-arm-msm, linux-crypto, devicetree, linux-kernel, linux-clk

Partial hash was being copied into the final result buffer without the
entire message block processed. Depending on how the end user processes
this result buffer, errors vary from result buffer corruption to result
buffer poisoing. Fix this issue by ensuring that only the final hash value
is copied into the result buffer.

Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
---
 drivers/crypto/qce/sha.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c
index 87be96a0b0bb..61c418c12345 100644
--- a/drivers/crypto/qce/sha.c
+++ b/drivers/crypto/qce/sha.c
@@ -48,7 +48,7 @@ static void qce_ahash_done(void *data)
 	dma_unmap_sg(qce->dev, &rctx->result_sg, 1, DMA_FROM_DEVICE);
 
 	memcpy(rctx->digest, result->auth_iv, digestsize);
-	if (req->result)
+	if (req->result && rctx->last_blk)
 		memcpy(req->result, result->auth_iv, digestsize);
 
 	rctx->byte_count[0] = cpu_to_be32(result->auth_byte_count[0]);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 5/6] dts:qcom:sdm845: Add dt entries to support crypto engine.
  2020-11-17 13:47 [PATCH 0/6] Enable Qualcomm Crypto Engine on sdm845 Thara Gopinath
                   ` (3 preceding siblings ...)
  2020-11-17 13:47 ` [PATCH 4/6] drivers:crypto:qce: Fix SHA result buffer corruption issues Thara Gopinath
@ 2020-11-17 13:47 ` Thara Gopinath
  2020-11-18  4:10   ` Bjorn Andersson
  2020-11-17 13:47 ` [PATCH 6/6] devicetree:bindings:crypto: Extend qcom-qce binding to add support for crypto engine version 5.4 Thara Gopinath
  2020-11-17 16:57 ` [PATCH 0/6] Enable Qualcomm Crypto Engine on sdm845 Eric Biggers
  6 siblings, 1 reply; 16+ messages in thread
From: Thara Gopinath @ 2020-11-17 13:47 UTC (permalink / raw)
  To: agross, bjorn.andersson, herbert, davem, robh+dt, sboyd, mturquette
  Cc: linux-arm-msm, linux-crypto, devicetree, linux-kernel, linux-clk

Add crypto engine (CE) and CE BAM related nodes and definitions to
"sdm845.dtsi".

Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
---
 arch/arm64/boot/dts/qcom/sdm845.dtsi | 30 ++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
index 40e8c11f23ab..b5b2ea97681f 100644
--- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
@@ -2138,6 +2138,36 @@ ufs_mem_phy_lanes: lanes@1d87400 {
 			};
 		};
 
+		cryptobam: dma@1dc4000 {
+			compatible = "qcom,bam-v1.7.0";
+			reg = <0 0x01dc4000 0 0x24000>;
+			interrupts = <GIC_SPI 272 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&rpmhcc RPMH_CE_CLK>;
+			clock-names = "bam_clk";
+			#dma-cells = <1>;
+			qcom,ee = <0>;
+			qcom,controlled-remotely = <1>;
+			iommus = <&apps_smmu 0x704 0x1>,
+				 <&apps_smmu 0x706 0x1>,
+				 <&apps_smmu 0x714 0x1>,
+				 <&apps_smmu 0x716 0x1>;
+		};
+
+		crypto: crypto@1dfa000 {
+			compatible = "qcom,crypto-v5.4";
+			reg = <0 0x01dfa000 0 0x6000>;
+			clocks = <&gcc GCC_CE1_AHB_CLK>,
+				 <&gcc GCC_CE1_AHB_CLK>,
+				 <&rpmhcc RPMH_CE_CLK>;
+			clock-names = "iface", "bus", "core";
+			dmas = <&cryptobam 6>, <&cryptobam 7>;
+			dma-names = "rx", "tx";
+			iommus = <&apps_smmu 0x704 0x1>,
+				 <&apps_smmu 0x706 0x1>,
+				 <&apps_smmu 0x714 0x1>,
+				 <&apps_smmu 0x716 0x1>;
+		};
+
 		ipa: ipa@1e40000 {
 			compatible = "qcom,sdm845-ipa";
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 6/6] devicetree:bindings:crypto: Extend qcom-qce binding to add support for crypto engine version 5.4
  2020-11-17 13:47 [PATCH 0/6] Enable Qualcomm Crypto Engine on sdm845 Thara Gopinath
                   ` (4 preceding siblings ...)
  2020-11-17 13:47 ` [PATCH 5/6] dts:qcom:sdm845: Add dt entries to support crypto engine Thara Gopinath
@ 2020-11-17 13:47 ` Thara Gopinath
  2020-11-18  4:08   ` Bjorn Andersson
  2020-11-17 16:57 ` [PATCH 0/6] Enable Qualcomm Crypto Engine on sdm845 Eric Biggers
  6 siblings, 1 reply; 16+ messages in thread
From: Thara Gopinath @ 2020-11-17 13:47 UTC (permalink / raw)
  To: agross, bjorn.andersson, herbert, davem, robh+dt, sboyd, mturquette
  Cc: linux-arm-msm, linux-crypto, devicetree, linux-kernel, linux-clk

Add compatible string to support v5.4 crypto engine.

Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
---
 Documentation/devicetree/bindings/crypto/qcom-qce.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/crypto/qcom-qce.txt b/Documentation/devicetree/bindings/crypto/qcom-qce.txt
index fdd53b184ba8..ed1ede9c0acc 100644
--- a/Documentation/devicetree/bindings/crypto/qcom-qce.txt
+++ b/Documentation/devicetree/bindings/crypto/qcom-qce.txt
@@ -2,7 +2,9 @@ Qualcomm crypto engine driver
 
 Required properties:
 
-- compatible  : should be "qcom,crypto-v5.1"
+- compatible  : should be
+		"qcom,crypto-v5.1" for ipq6018
+		"qcom,crypto-v5.4" for sdm845
 - reg         : specifies base physical address and size of the registers map
 - clocks      : phandle to clock-controller plus clock-specifier pair
 - clock-names : "iface" clocks register interface
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/6] Enable Qualcomm Crypto Engine on sdm845
  2020-11-17 13:47 [PATCH 0/6] Enable Qualcomm Crypto Engine on sdm845 Thara Gopinath
                   ` (5 preceding siblings ...)
  2020-11-17 13:47 ` [PATCH 6/6] devicetree:bindings:crypto: Extend qcom-qce binding to add support for crypto engine version 5.4 Thara Gopinath
@ 2020-11-17 16:57 ` Eric Biggers
  2020-11-17 18:07   ` Thara Gopinath
  6 siblings, 1 reply; 16+ messages in thread
From: Eric Biggers @ 2020-11-17 16:57 UTC (permalink / raw)
  To: Thara Gopinath
  Cc: agross, bjorn.andersson, herbert, davem, robh+dt, sboyd,
	mturquette, linux-arm-msm, linux-crypto, devicetree,
	linux-kernel, linux-clk

On Tue, Nov 17, 2020 at 08:47:08AM -0500, Thara Gopinath wrote:
> Qualcomm crypto engine supports hardware accelerated algorithms for
> encryption and authentication. Enable support for aes,des,3des encryption
> algorithms and sha1,sha256, hmac(sha1),hmac(sha256) authentication
> algorithms on sdm845.The patch series has been tested using the kernel
> crypto testing module tcrypto.ko.

Did you do this testing with CONFIG_CRYPTO_MANAGER_EXTRA_TESTS enabled?
Do all tests pass with it enabled?

- Eric

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/6] Enable Qualcomm Crypto Engine on sdm845
  2020-11-17 16:57 ` [PATCH 0/6] Enable Qualcomm Crypto Engine on sdm845 Eric Biggers
@ 2020-11-17 18:07   ` Thara Gopinath
  0 siblings, 0 replies; 16+ messages in thread
From: Thara Gopinath @ 2020-11-17 18:07 UTC (permalink / raw)
  To: Eric Biggers
  Cc: agross, bjorn.andersson, herbert, davem, robh+dt, sboyd,
	mturquette, linux-arm-msm, linux-crypto, devicetree,
	linux-kernel, linux-clk



On 11/17/20 11:57 AM, Eric Biggers wrote:
> On Tue, Nov 17, 2020 at 08:47:08AM -0500, Thara Gopinath wrote:
>> Qualcomm crypto engine supports hardware accelerated algorithms for
>> encryption and authentication. Enable support for aes,des,3des encryption
>> algorithms and sha1,sha256, hmac(sha1),hmac(sha256) authentication
>> algorithms on sdm845.The patch series has been tested using the kernel
>> crypto testing module tcrypto.ko.
> 
> Did you do this testing with CONFIG_CRYPTO_MANAGER_EXTRA_TESTS enabled?
> Do all tests pass with it enabled?

No I have not. This is in my todo list though. I am trying to enable 
AEAD algorithms on the crypto engine right now. I will try to test it 
out with that set.

> 
> - Eric
> 

-- 
Warm Regards
Thara

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/6] dt-binding:clock: Add entry for crypto engine RPMH clock resource
  2020-11-17 13:47 ` [PATCH 1/6] dt-binding:clock: Add entry for crypto engine RPMH clock resource Thara Gopinath
@ 2020-11-18  3:57   ` Bjorn Andersson
  0 siblings, 0 replies; 16+ messages in thread
From: Bjorn Andersson @ 2020-11-18  3:57 UTC (permalink / raw)
  To: Thara Gopinath
  Cc: agross, herbert, davem, robh+dt, sboyd, mturquette,
	linux-arm-msm, linux-crypto, devicetree, linux-kernel, linux-clk

On Tue 17 Nov 07:47 CST 2020, Thara Gopinath wrote:

> Add clock id forc CE clock resource which is required to bring up the
> crypto engine on sdm845.
> 
> Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>

$subject should have bindings in plural to match other changes and a
space after the ':'

Apart from that, things looks good.

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Regards,
Bjorn

> ---
>  include/dt-bindings/clock/qcom,rpmh.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/dt-bindings/clock/qcom,rpmh.h b/include/dt-bindings/clock/qcom,rpmh.h
> index 2e6c54e65455..30111c8f7fe9 100644
> --- a/include/dt-bindings/clock/qcom,rpmh.h
> +++ b/include/dt-bindings/clock/qcom,rpmh.h
> @@ -21,5 +21,6 @@
>  #define RPMH_IPA_CLK				12
>  #define RPMH_LN_BB_CLK1				13
>  #define RPMH_LN_BB_CLK1_A			14
> +#define RPMH_CE_CLK				15
>  
>  #endif
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/6] clk:qcom:rpmh: Add CE clock on sdm845.
  2020-11-17 13:47 ` [PATCH 2/6] clk:qcom:rpmh: Add CE clock on sdm845 Thara Gopinath
@ 2020-11-18  3:59   ` Bjorn Andersson
  0 siblings, 0 replies; 16+ messages in thread
From: Bjorn Andersson @ 2020-11-18  3:59 UTC (permalink / raw)
  To: Thara Gopinath
  Cc: agross, herbert, davem, robh+dt, sboyd, mturquette,
	linux-arm-msm, linux-crypto, devicetree, linux-kernel, linux-clk

On Tue 17 Nov 07:47 CST 2020, Thara Gopinath wrote:

> Qualcomm CE clock resource that is managed by BCM is required
> by crypto driver to access the core clock.
> 

' ' after ':' in $subject

With that
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Regards,
bjorn

> Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
> ---
>  drivers/clk/qcom/clk-rpmh.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
> index e2c669b08aff..7e2a4a9b9bf6 100644
> --- a/drivers/clk/qcom/clk-rpmh.c
> +++ b/drivers/clk/qcom/clk-rpmh.c
> @@ -349,6 +349,7 @@ DEFINE_CLK_RPMH_VRM(sdm845, rf_clk2, rf_clk2_ao, "rfclka2", 1);
>  DEFINE_CLK_RPMH_VRM(sdm845, rf_clk3, rf_clk3_ao, "rfclka3", 1);
>  DEFINE_CLK_RPMH_VRM(sm8150, rf_clk3, rf_clk3_ao, "rfclka3", 1);
>  DEFINE_CLK_RPMH_BCM(sdm845, ipa, "IP0");
> +DEFINE_CLK_RPMH_BCM(sdm845, ce, "CE0");
>  
>  static struct clk_hw *sdm845_rpmh_clocks[] = {
>  	[RPMH_CXO_CLK]		= &sdm845_bi_tcxo.hw,
> @@ -364,6 +365,7 @@ static struct clk_hw *sdm845_rpmh_clocks[] = {
>  	[RPMH_RF_CLK3]		= &sdm845_rf_clk3.hw,
>  	[RPMH_RF_CLK3_A]	= &sdm845_rf_clk3_ao.hw,
>  	[RPMH_IPA_CLK]		= &sdm845_ipa.hw,
> +	[RPMH_CE_CLK]		= &sdm845_ce.hw,
>  };
>  
>  static const struct clk_rpmh_desc clk_rpmh_sdm845 = {
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 3/6] drivers:crypto:qce: Enable support for crypto engine on sdm845.
  2020-11-17 13:47 ` [PATCH 3/6] drivers:crypto:qce: Enable support for crypto engine " Thara Gopinath
@ 2020-11-18  4:02   ` Bjorn Andersson
  0 siblings, 0 replies; 16+ messages in thread
From: Bjorn Andersson @ 2020-11-18  4:02 UTC (permalink / raw)
  To: Thara Gopinath
  Cc: agross, herbert, davem, robh+dt, sboyd, mturquette,
	linux-arm-msm, linux-crypto, devicetree, linux-kernel, linux-clk

On Tue 17 Nov 07:47 CST 2020, Thara Gopinath wrote:

> Add support Qualcomm Crypto Engine accelerated encryption and
> authentication algorithms on sdm845.
> 

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Regards,
Bjorn

> Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
> ---
>  drivers/crypto/qce/core.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c
> index ea616b7259ae..67c3ca13e55b 100644
> --- a/drivers/crypto/qce/core.c
> +++ b/drivers/crypto/qce/core.c
> @@ -160,7 +160,21 @@ static int qce_check_version(struct qce_device *qce)
>  		return -ENODEV;
>  
>  	qce->burst_size = QCE_BAM_BURST_SIZE;
> -	qce->pipe_pair_id = 1;
> +
> +	/*
> +	 * Rx and tx pipes are treated as a pair inside CE.
> +	 * Pipe pair number depended on the actual BAM dma pipe
> +	 * that is used for transfers. The BAM dma pipes are passed
> +	 * from the device tree and used to derive the pipe pair
> +	 * id in the CE driver as follows.
> +	 * 	BAM dma pipes(rx, tx)		CE pipe pair id
> +	 *		0,1				0
> +	 *		2,3				1
> +	 *		4,5				2
> +	 *		6,7				3
> +	 *		...
> +	 */
> +	qce->pipe_pair_id = qce->dma.rxchan->chan_id >> 1;
>  
>  	dev_dbg(qce->dev, "Crypto device found, version %d.%d.%d\n",
>  		major, minor, step);
> @@ -261,6 +275,7 @@ static int qce_crypto_remove(struct platform_device *pdev)
>  
>  static const struct of_device_id qce_crypto_of_match[] = {
>  	{ .compatible = "qcom,crypto-v5.1", },
> +	{ .compatible = "qcom,crypto-v5.4", },
>  	{}
>  };
>  MODULE_DEVICE_TABLE(of, qce_crypto_of_match);
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 4/6] drivers:crypto:qce: Fix SHA result buffer corruption issues.
  2020-11-17 13:47 ` [PATCH 4/6] drivers:crypto:qce: Fix SHA result buffer corruption issues Thara Gopinath
@ 2020-11-18  4:04   ` Bjorn Andersson
  0 siblings, 0 replies; 16+ messages in thread
From: Bjorn Andersson @ 2020-11-18  4:04 UTC (permalink / raw)
  To: Thara Gopinath
  Cc: agross, herbert, davem, robh+dt, sboyd, mturquette,
	linux-arm-msm, linux-crypto, devicetree, linux-kernel, linux-clk

On Tue 17 Nov 07:47 CST 2020, Thara Gopinath wrote:

> Partial hash was being copied into the final result buffer without the
> entire message block processed. Depending on how the end user processes
> this result buffer, errors vary from result buffer corruption to result
> buffer poisoing. Fix this issue by ensuring that only the final hash value
> is copied into the result buffer.
> 

Looks reasonable to me

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Regards,
Bjorn

> Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
> ---
>  drivers/crypto/qce/sha.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c
> index 87be96a0b0bb..61c418c12345 100644
> --- a/drivers/crypto/qce/sha.c
> +++ b/drivers/crypto/qce/sha.c
> @@ -48,7 +48,7 @@ static void qce_ahash_done(void *data)
>  	dma_unmap_sg(qce->dev, &rctx->result_sg, 1, DMA_FROM_DEVICE);
>  
>  	memcpy(rctx->digest, result->auth_iv, digestsize);
> -	if (req->result)
> +	if (req->result && rctx->last_blk)
>  		memcpy(req->result, result->auth_iv, digestsize);
>  
>  	rctx->byte_count[0] = cpu_to_be32(result->auth_byte_count[0]);
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 6/6] devicetree:bindings:crypto: Extend qcom-qce binding to add support for crypto engine version 5.4
  2020-11-17 13:47 ` [PATCH 6/6] devicetree:bindings:crypto: Extend qcom-qce binding to add support for crypto engine version 5.4 Thara Gopinath
@ 2020-11-18  4:08   ` Bjorn Andersson
  0 siblings, 0 replies; 16+ messages in thread
From: Bjorn Andersson @ 2020-11-18  4:08 UTC (permalink / raw)
  To: Thara Gopinath
  Cc: agross, herbert, davem, robh+dt, sboyd, mturquette,
	linux-arm-msm, linux-crypto, devicetree, linux-kernel, linux-clk

On Tue 17 Nov 07:47 CST 2020, Thara Gopinath wrote:

> Add compatible string to support v5.4 crypto engine.
> 
> Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>

$subject should be "dt-bindings: crypto: ..." and you should try to stay
within 50 chars for the subject. So how about something like:

"dt-bindings: crypto: qcom-qce: Add v5.4 to binding"

With something like that:
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Regards,
Bjorn

> ---
>  Documentation/devicetree/bindings/crypto/qcom-qce.txt | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/crypto/qcom-qce.txt b/Documentation/devicetree/bindings/crypto/qcom-qce.txt
> index fdd53b184ba8..ed1ede9c0acc 100644
> --- a/Documentation/devicetree/bindings/crypto/qcom-qce.txt
> +++ b/Documentation/devicetree/bindings/crypto/qcom-qce.txt
> @@ -2,7 +2,9 @@ Qualcomm crypto engine driver
>  
>  Required properties:
>  
> -- compatible  : should be "qcom,crypto-v5.1"
> +- compatible  : should be
> +		"qcom,crypto-v5.1" for ipq6018
> +		"qcom,crypto-v5.4" for sdm845
>  - reg         : specifies base physical address and size of the registers map
>  - clocks      : phandle to clock-controller plus clock-specifier pair
>  - clock-names : "iface" clocks register interface
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 5/6] dts:qcom:sdm845: Add dt entries to support crypto engine.
  2020-11-17 13:47 ` [PATCH 5/6] dts:qcom:sdm845: Add dt entries to support crypto engine Thara Gopinath
@ 2020-11-18  4:10   ` Bjorn Andersson
  2020-11-18 19:58     ` Thara Gopinath
  0 siblings, 1 reply; 16+ messages in thread
From: Bjorn Andersson @ 2020-11-18  4:10 UTC (permalink / raw)
  To: Thara Gopinath
  Cc: agross, herbert, davem, robh+dt, sboyd, mturquette,
	linux-arm-msm, linux-crypto, devicetree, linux-kernel, linux-clk

On Tue 17 Nov 07:47 CST 2020, Thara Gopinath wrote:

> Add crypto engine (CE) and CE BAM related nodes and definitions to
> "sdm845.dtsi".
> 
> Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
> ---
>  arch/arm64/boot/dts/qcom/sdm845.dtsi | 30 ++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
> index 40e8c11f23ab..b5b2ea97681f 100644
> --- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
> @@ -2138,6 +2138,36 @@ ufs_mem_phy_lanes: lanes@1d87400 {
>  			};
>  		};
>  
> +		cryptobam: dma@1dc4000 {
> +			compatible = "qcom,bam-v1.7.0";
> +			reg = <0 0x01dc4000 0 0x24000>;
> +			interrupts = <GIC_SPI 272 IRQ_TYPE_LEVEL_HIGH>;
> +			clocks = <&rpmhcc RPMH_CE_CLK>;
> +			clock-names = "bam_clk";
> +			#dma-cells = <1>;
> +			qcom,ee = <0>;
> +			qcom,controlled-remotely = <1>;
> +			iommus = <&apps_smmu 0x704 0x1>,
> +				 <&apps_smmu 0x706 0x1>,
> +				 <&apps_smmu 0x714 0x1>,
> +				 <&apps_smmu 0x716 0x1>;

Can you confirm that this can't be written as:

iommus = <&apps_smmu 0x704 0x3>,
	 <&apps_smmu 0x714 0x3>;

(and same below).

Regards,
Bjorn
> +		};
> +
> +		crypto: crypto@1dfa000 {
> +			compatible = "qcom,crypto-v5.4";
> +			reg = <0 0x01dfa000 0 0x6000>;
> +			clocks = <&gcc GCC_CE1_AHB_CLK>,
> +				 <&gcc GCC_CE1_AHB_CLK>,
> +				 <&rpmhcc RPMH_CE_CLK>;
> +			clock-names = "iface", "bus", "core";
> +			dmas = <&cryptobam 6>, <&cryptobam 7>;
> +			dma-names = "rx", "tx";
> +			iommus = <&apps_smmu 0x704 0x1>,
> +				 <&apps_smmu 0x706 0x1>,
> +				 <&apps_smmu 0x714 0x1>,
> +				 <&apps_smmu 0x716 0x1>;
> +		};
> +
>  		ipa: ipa@1e40000 {
>  			compatible = "qcom,sdm845-ipa";
>  
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 5/6] dts:qcom:sdm845: Add dt entries to support crypto engine.
  2020-11-18  4:10   ` Bjorn Andersson
@ 2020-11-18 19:58     ` Thara Gopinath
  0 siblings, 0 replies; 16+ messages in thread
From: Thara Gopinath @ 2020-11-18 19:58 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: agross, herbert, davem, robh+dt, sboyd, mturquette,
	linux-arm-msm, linux-crypto, devicetree, linux-kernel, linux-clk



On 11/17/20 11:10 PM, Bjorn Andersson wrote:
> On Tue 17 Nov 07:47 CST 2020, Thara Gopinath wrote:
> 
>> Add crypto engine (CE) and CE BAM related nodes and definitions to
>> "sdm845.dtsi".
>>
>> Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
>> ---
>>   arch/arm64/boot/dts/qcom/sdm845.dtsi | 30 ++++++++++++++++++++++++++++
>>   1 file changed, 30 insertions(+)
>>
>> diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
>> index 40e8c11f23ab..b5b2ea97681f 100644
>> --- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
>> +++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
>> @@ -2138,6 +2138,36 @@ ufs_mem_phy_lanes: lanes@1d87400 {
>>   			};
>>   		};
>>   
>> +		cryptobam: dma@1dc4000 {
>> +			compatible = "qcom,bam-v1.7.0";
>> +			reg = <0 0x01dc4000 0 0x24000>;
>> +			interrupts = <GIC_SPI 272 IRQ_TYPE_LEVEL_HIGH>;
>> +			clocks = <&rpmhcc RPMH_CE_CLK>;
>> +			clock-names = "bam_clk";
>> +			#dma-cells = <1>;
>> +			qcom,ee = <0>;
>> +			qcom,controlled-remotely = <1>;
>> +			iommus = <&apps_smmu 0x704 0x1>,
>> +				 <&apps_smmu 0x706 0x1>,
>> +				 <&apps_smmu 0x714 0x1>,
>> +				 <&apps_smmu 0x716 0x1>;
> 
> Can you confirm that this can't be written as:
> 
> iommus = <&apps_smmu 0x704 0x3>,
> 	 <&apps_smmu 0x714 0x3>;
> 
> (and same below).

Hi Bjorn,

Thanks for the reviews. Yes, I can confirm that the above does not work.
The tests hang. I will fix rest of your comments and post v2.

-- 
Warm Regards
Thara

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2020-11-18 19:58 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-17 13:47 [PATCH 0/6] Enable Qualcomm Crypto Engine on sdm845 Thara Gopinath
2020-11-17 13:47 ` [PATCH 1/6] dt-binding:clock: Add entry for crypto engine RPMH clock resource Thara Gopinath
2020-11-18  3:57   ` Bjorn Andersson
2020-11-17 13:47 ` [PATCH 2/6] clk:qcom:rpmh: Add CE clock on sdm845 Thara Gopinath
2020-11-18  3:59   ` Bjorn Andersson
2020-11-17 13:47 ` [PATCH 3/6] drivers:crypto:qce: Enable support for crypto engine " Thara Gopinath
2020-11-18  4:02   ` Bjorn Andersson
2020-11-17 13:47 ` [PATCH 4/6] drivers:crypto:qce: Fix SHA result buffer corruption issues Thara Gopinath
2020-11-18  4:04   ` Bjorn Andersson
2020-11-17 13:47 ` [PATCH 5/6] dts:qcom:sdm845: Add dt entries to support crypto engine Thara Gopinath
2020-11-18  4:10   ` Bjorn Andersson
2020-11-18 19:58     ` Thara Gopinath
2020-11-17 13:47 ` [PATCH 6/6] devicetree:bindings:crypto: Extend qcom-qce binding to add support for crypto engine version 5.4 Thara Gopinath
2020-11-18  4:08   ` Bjorn Andersson
2020-11-17 16:57 ` [PATCH 0/6] Enable Qualcomm Crypto Engine on sdm845 Eric Biggers
2020-11-17 18:07   ` Thara Gopinath

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).