All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] staging: ccree: Fixes and cleanups
@ 2017-10-31 11:56 ` Gilad Ben-Yossef
  0 siblings, 0 replies; 18+ messages in thread
From: Gilad Ben-Yossef @ 2017-10-31 11:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Ofir Drang, linux-crypto, driverdev-devel, devel, linux-kernel

Fixes and cleanups for 4.15

Gilad Ben-Yossef (3):
  staging: ccree: copy IV to DMAable memory
  staging: ccree: handle limiting of DMA masks
  staging: ccree: remove dead code

 drivers/staging/ccree/ssi_cipher.c | 20 ++++++++++++++------
 drivers/staging/ccree/ssi_cipher.h |  1 +
 drivers/staging/ccree/ssi_driver.c | 22 ++++++++++++++++++----
 drivers/staging/ccree/ssi_driver.h |  1 -
 4 files changed, 33 insertions(+), 11 deletions(-)

-- 
2.7.4

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

* [PATCH 0/3] staging: ccree: Fixes and cleanups
@ 2017-10-31 11:56 ` Gilad Ben-Yossef
  0 siblings, 0 replies; 18+ messages in thread
From: Gilad Ben-Yossef @ 2017-10-31 11:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: devel, linux-kernel, driverdev-devel, linux-crypto, Ofir Drang

Fixes and cleanups for 4.15

Gilad Ben-Yossef (3):
  staging: ccree: copy IV to DMAable memory
  staging: ccree: handle limiting of DMA masks
  staging: ccree: remove dead code

 drivers/staging/ccree/ssi_cipher.c | 20 ++++++++++++++------
 drivers/staging/ccree/ssi_cipher.h |  1 +
 drivers/staging/ccree/ssi_driver.c | 22 ++++++++++++++++++----
 drivers/staging/ccree/ssi_driver.h |  1 -
 4 files changed, 33 insertions(+), 11 deletions(-)

-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 1/3] staging: ccree: copy IV to DMAable memory
  2017-10-31 11:56 ` Gilad Ben-Yossef
@ 2017-10-31 11:56   ` Gilad Ben-Yossef
  -1 siblings, 0 replies; 18+ messages in thread
From: Gilad Ben-Yossef @ 2017-10-31 11:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Ofir Drang, linux-crypto, driverdev-devel, devel, linux-kernel

We are being passed an IV buffer from unknown origin, which may be
stack allocated and thus not safe for DMA. Allocate a DMA safe
buffer for the IV and use that instead.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
 drivers/staging/ccree/ssi_cipher.c | 16 ++++++++++++++--
 drivers/staging/ccree/ssi_cipher.h |  1 +
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c
index 78706f5..0784c86 100644
--- a/drivers/staging/ccree/ssi_cipher.c
+++ b/drivers/staging/ccree/ssi_cipher.c
@@ -695,6 +695,7 @@ static int ssi_blkcipher_complete(struct device *dev,
 	struct ablkcipher_request *req = (struct ablkcipher_request *)areq;
 
 	ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst);
+	kfree(req_ctx->iv);
 
 	/*Decrease the inflight counter*/
 	if (ctx_p->flow_mode == BYPASS && ctx_p->drvdata->inflight_counter > 0)
@@ -757,6 +758,13 @@ static int ssi_blkcipher_process(
 		rc = 0;
 		goto exit_process;
 	}
+
+	/* The IV we are handed may be allocted from the stack so
+	 * we must copy it to a DMAable buffer before use.
+	 */
+	req_ctx->iv = kmalloc(ivsize, GFP_KERNEL);
+	memcpy(req_ctx->iv, info, ivsize);
+
 	/*For CTS in case of data size aligned to 16 use CBC mode*/
 	if (((nbytes % AES_BLOCK_SIZE) == 0) && (ctx_p->cipher_mode == DRV_CIPHER_CBC_CTS)) {
 		ctx_p->cipher_mode = DRV_CIPHER_CBC;
@@ -778,7 +786,9 @@ static int ssi_blkcipher_process(
 
 	/* STAT_PHASE_1: Map buffers */
 
-	rc = ssi_buffer_mgr_map_blkcipher_request(ctx_p->drvdata, req_ctx, ivsize, nbytes, info, src, dst);
+	rc = ssi_buffer_mgr_map_blkcipher_request(ctx_p->drvdata, req_ctx,
+						  ivsize, nbytes, req_ctx->iv,
+						  src, dst);
 	if (unlikely(rc != 0)) {
 		dev_err(dev, "map_request() failed\n");
 		goto exit_process;
@@ -830,8 +840,10 @@ static int ssi_blkcipher_process(
 	if (cts_restore_flag != 0)
 		ctx_p->cipher_mode = DRV_CIPHER_CBC_CTS;
 
-	if (rc != -EINPROGRESS)
+	if (rc != -EINPROGRESS) {
 		kfree(req_ctx->backup_info);
+		kfree(req_ctx->iv);
+	}
 
 	return rc;
 }
diff --git a/drivers/staging/ccree/ssi_cipher.h b/drivers/staging/ccree/ssi_cipher.h
index f499962..25e6335 100644
--- a/drivers/staging/ccree/ssi_cipher.h
+++ b/drivers/staging/ccree/ssi_cipher.h
@@ -43,6 +43,7 @@ struct blkcipher_req_ctx {
 	u32 out_nents;
 	u32 out_mlli_nents;
 	u8 *backup_info; /*store iv for generated IV flow*/
+	u8 *iv;
 	bool is_giv;
 	struct mlli_params mlli_params;
 };
-- 
2.7.4

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

* [PATCH 1/3] staging: ccree: copy IV to DMAable memory
@ 2017-10-31 11:56   ` Gilad Ben-Yossef
  0 siblings, 0 replies; 18+ messages in thread
From: Gilad Ben-Yossef @ 2017-10-31 11:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: devel, linux-kernel, driverdev-devel, linux-crypto, Ofir Drang

We are being passed an IV buffer from unknown origin, which may be
stack allocated and thus not safe for DMA. Allocate a DMA safe
buffer for the IV and use that instead.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
 drivers/staging/ccree/ssi_cipher.c | 16 ++++++++++++++--
 drivers/staging/ccree/ssi_cipher.h |  1 +
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c
index 78706f5..0784c86 100644
--- a/drivers/staging/ccree/ssi_cipher.c
+++ b/drivers/staging/ccree/ssi_cipher.c
@@ -695,6 +695,7 @@ static int ssi_blkcipher_complete(struct device *dev,
 	struct ablkcipher_request *req = (struct ablkcipher_request *)areq;
 
 	ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst);
+	kfree(req_ctx->iv);
 
 	/*Decrease the inflight counter*/
 	if (ctx_p->flow_mode == BYPASS && ctx_p->drvdata->inflight_counter > 0)
@@ -757,6 +758,13 @@ static int ssi_blkcipher_process(
 		rc = 0;
 		goto exit_process;
 	}
+
+	/* The IV we are handed may be allocted from the stack so
+	 * we must copy it to a DMAable buffer before use.
+	 */
+	req_ctx->iv = kmalloc(ivsize, GFP_KERNEL);
+	memcpy(req_ctx->iv, info, ivsize);
+
 	/*For CTS in case of data size aligned to 16 use CBC mode*/
 	if (((nbytes % AES_BLOCK_SIZE) == 0) && (ctx_p->cipher_mode == DRV_CIPHER_CBC_CTS)) {
 		ctx_p->cipher_mode = DRV_CIPHER_CBC;
@@ -778,7 +786,9 @@ static int ssi_blkcipher_process(
 
 	/* STAT_PHASE_1: Map buffers */
 
-	rc = ssi_buffer_mgr_map_blkcipher_request(ctx_p->drvdata, req_ctx, ivsize, nbytes, info, src, dst);
+	rc = ssi_buffer_mgr_map_blkcipher_request(ctx_p->drvdata, req_ctx,
+						  ivsize, nbytes, req_ctx->iv,
+						  src, dst);
 	if (unlikely(rc != 0)) {
 		dev_err(dev, "map_request() failed\n");
 		goto exit_process;
@@ -830,8 +840,10 @@ static int ssi_blkcipher_process(
 	if (cts_restore_flag != 0)
 		ctx_p->cipher_mode = DRV_CIPHER_CBC_CTS;
 
-	if (rc != -EINPROGRESS)
+	if (rc != -EINPROGRESS) {
 		kfree(req_ctx->backup_info);
+		kfree(req_ctx->iv);
+	}
 
 	return rc;
 }
diff --git a/drivers/staging/ccree/ssi_cipher.h b/drivers/staging/ccree/ssi_cipher.h
index f499962..25e6335 100644
--- a/drivers/staging/ccree/ssi_cipher.h
+++ b/drivers/staging/ccree/ssi_cipher.h
@@ -43,6 +43,7 @@ struct blkcipher_req_ctx {
 	u32 out_nents;
 	u32 out_mlli_nents;
 	u8 *backup_info; /*store iv for generated IV flow*/
+	u8 *iv;
 	bool is_giv;
 	struct mlli_params mlli_params;
 };
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 2/3] staging: ccree: handle limiting of DMA masks
  2017-10-31 11:56 ` Gilad Ben-Yossef
  (?)
@ 2017-10-31 11:56   ` Gilad Ben-Yossef
  -1 siblings, 0 replies; 18+ messages in thread
From: Gilad Ben-Yossef @ 2017-10-31 11:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: devel, linux-kernel, driverdev-devel, linux-crypto, Ofir Drang

Properly handle limiting of DMA masks based on device and bus
capabilities.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
 drivers/staging/ccree/ssi_driver.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index 5f03c25..6d4269f 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -208,6 +208,7 @@ static int init_cc_resources(struct platform_device *plat_dev)
 	struct device *dev = &plat_dev->dev;
 	struct device_node *np = dev->of_node;
 	u32 signature_val;
+	dma_addr_t dma_mask;
 	int rc = 0;
 
 	new_drvdata = devm_kzalloc(dev, sizeof(*new_drvdata), GFP_KERNEL);
@@ -260,11 +261,24 @@ static int init_cc_resources(struct platform_device *plat_dev)
 	if (rc)
 		goto post_drvdata_err;
 
-	if (!dev->dma_mask)
-		dev->dma_mask = &dev->coherent_dma_mask;
+	if (!plat_dev->dev.dma_mask)
+		plat_dev->dev.dma_mask = &plat_dev->dev.coherent_dma_mask;
+
+	dma_mask = (dma_addr_t)(DMA_BIT_MASK(DMA_BIT_MASK_LEN));
+	while (dma_mask > 0x7fffffffUL) {
+		if (dma_supported(&plat_dev->dev, dma_mask)) {
+			rc = dma_set_coherent_mask(&plat_dev->dev, dma_mask);
+				if (!rc)
+					break;
+		}
+		dma_mask >>= 1;
+	}
 
-	if (!dev->coherent_dma_mask)
-		dev->coherent_dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN);
+	if (rc) {
+		dev_err(dev, "Error: failed in dma_set_mask, mask=%par\n",
+			&dma_mask);
+		goto post_drvdata_err;
+	}
 
 	/* Verify correct mapping */
 	signature_val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_SIGNATURE));
-- 
2.7.4

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

* [PATCH 2/3] staging: ccree: handle limiting of DMA masks
@ 2017-10-31 11:56   ` Gilad Ben-Yossef
  0 siblings, 0 replies; 18+ messages in thread
From: Gilad Ben-Yossef @ 2017-10-31 11:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Ofir Drang, linux-crypto, driverdev-devel, devel, linux-kernel

Properly handle limiting of DMA masks based on device and bus
capabilities.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
 drivers/staging/ccree/ssi_driver.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index 5f03c25..6d4269f 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -208,6 +208,7 @@ static int init_cc_resources(struct platform_device *plat_dev)
 	struct device *dev = &plat_dev->dev;
 	struct device_node *np = dev->of_node;
 	u32 signature_val;
+	dma_addr_t dma_mask;
 	int rc = 0;
 
 	new_drvdata = devm_kzalloc(dev, sizeof(*new_drvdata), GFP_KERNEL);
@@ -260,11 +261,24 @@ static int init_cc_resources(struct platform_device *plat_dev)
 	if (rc)
 		goto post_drvdata_err;
 
-	if (!dev->dma_mask)
-		dev->dma_mask = &dev->coherent_dma_mask;
+	if (!plat_dev->dev.dma_mask)
+		plat_dev->dev.dma_mask = &plat_dev->dev.coherent_dma_mask;
+
+	dma_mask = (dma_addr_t)(DMA_BIT_MASK(DMA_BIT_MASK_LEN));
+	while (dma_mask > 0x7fffffffUL) {
+		if (dma_supported(&plat_dev->dev, dma_mask)) {
+			rc = dma_set_coherent_mask(&plat_dev->dev, dma_mask);
+				if (!rc)
+					break;
+		}
+		dma_mask >>= 1;
+	}
 
-	if (!dev->coherent_dma_mask)
-		dev->coherent_dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN);
+	if (rc) {
+		dev_err(dev, "Error: failed in dma_set_mask, mask=%par\n",
+			&dma_mask);
+		goto post_drvdata_err;
+	}
 
 	/* Verify correct mapping */
 	signature_val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_SIGNATURE));
-- 
2.7.4

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

* [PATCH 2/3] staging: ccree: handle limiting of DMA masks
@ 2017-10-31 11:56   ` Gilad Ben-Yossef
  0 siblings, 0 replies; 18+ messages in thread
From: Gilad Ben-Yossef @ 2017-10-31 11:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: devel, linux-kernel, driverdev-devel, linux-crypto, Ofir Drang

Properly handle limiting of DMA masks based on device and bus
capabilities.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
 drivers/staging/ccree/ssi_driver.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index 5f03c25..6d4269f 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -208,6 +208,7 @@ static int init_cc_resources(struct platform_device *plat_dev)
 	struct device *dev = &plat_dev->dev;
 	struct device_node *np = dev->of_node;
 	u32 signature_val;
+	dma_addr_t dma_mask;
 	int rc = 0;
 
 	new_drvdata = devm_kzalloc(dev, sizeof(*new_drvdata), GFP_KERNEL);
@@ -260,11 +261,24 @@ static int init_cc_resources(struct platform_device *plat_dev)
 	if (rc)
 		goto post_drvdata_err;
 
-	if (!dev->dma_mask)
-		dev->dma_mask = &dev->coherent_dma_mask;
+	if (!plat_dev->dev.dma_mask)
+		plat_dev->dev.dma_mask = &plat_dev->dev.coherent_dma_mask;
+
+	dma_mask = (dma_addr_t)(DMA_BIT_MASK(DMA_BIT_MASK_LEN));
+	while (dma_mask > 0x7fffffffUL) {
+		if (dma_supported(&plat_dev->dev, dma_mask)) {
+			rc = dma_set_coherent_mask(&plat_dev->dev, dma_mask);
+				if (!rc)
+					break;
+		}
+		dma_mask >>= 1;
+	}
 
-	if (!dev->coherent_dma_mask)
-		dev->coherent_dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN);
+	if (rc) {
+		dev_err(dev, "Error: failed in dma_set_mask, mask=%par\n",
+			&dma_mask);
+		goto post_drvdata_err;
+	}
 
 	/* Verify correct mapping */
 	signature_val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_SIGNATURE));
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 3/3] staging: ccree: remove dead code
  2017-10-31 11:56 ` Gilad Ben-Yossef
  (?)
@ 2017-10-31 11:56   ` Gilad Ben-Yossef
  -1 siblings, 0 replies; 18+ messages in thread
From: Gilad Ben-Yossef @ 2017-10-31 11:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: devel, linux-kernel, driverdev-devel, linux-crypto, Ofir Drang

The inflight_counter field is updated in a single location and
never used. Remove it.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
 drivers/staging/ccree/ssi_cipher.c | 4 ----
 drivers/staging/ccree/ssi_driver.h | 1 -
 2 files changed, 5 deletions(-)

diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c
index 0784c86..42844ae 100644
--- a/drivers/staging/ccree/ssi_cipher.c
+++ b/drivers/staging/ccree/ssi_cipher.c
@@ -697,10 +697,6 @@ static int ssi_blkcipher_complete(struct device *dev,
 	ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst);
 	kfree(req_ctx->iv);
 
-	/*Decrease the inflight counter*/
-	if (ctx_p->flow_mode == BYPASS && ctx_p->drvdata->inflight_counter > 0)
-		ctx_p->drvdata->inflight_counter--;
-
 	if (areq) {
 		/*
 		 * The crypto API expects us to set the req->info to the last
diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h
index 488f665..e01c880 100644
--- a/drivers/staging/ccree/ssi_driver.h
+++ b/drivers/staging/ccree/ssi_driver.h
@@ -134,7 +134,6 @@ struct ssi_drvdata {
 	void *fips_handle;
 	void *ivgen_handle;
 	void *sram_mgr_handle;
-	u32 inflight_counter;
 	struct clk *clk;
 	bool coherent;
 };
-- 
2.7.4

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

* [PATCH 3/3] staging: ccree: remove dead code
@ 2017-10-31 11:56   ` Gilad Ben-Yossef
  0 siblings, 0 replies; 18+ messages in thread
From: Gilad Ben-Yossef @ 2017-10-31 11:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Ofir Drang, linux-crypto, driverdev-devel, devel, linux-kernel

The inflight_counter field is updated in a single location and
never used. Remove it.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
 drivers/staging/ccree/ssi_cipher.c | 4 ----
 drivers/staging/ccree/ssi_driver.h | 1 -
 2 files changed, 5 deletions(-)

diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c
index 0784c86..42844ae 100644
--- a/drivers/staging/ccree/ssi_cipher.c
+++ b/drivers/staging/ccree/ssi_cipher.c
@@ -697,10 +697,6 @@ static int ssi_blkcipher_complete(struct device *dev,
 	ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst);
 	kfree(req_ctx->iv);
 
-	/*Decrease the inflight counter*/
-	if (ctx_p->flow_mode == BYPASS && ctx_p->drvdata->inflight_counter > 0)
-		ctx_p->drvdata->inflight_counter--;
-
 	if (areq) {
 		/*
 		 * The crypto API expects us to set the req->info to the last
diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h
index 488f665..e01c880 100644
--- a/drivers/staging/ccree/ssi_driver.h
+++ b/drivers/staging/ccree/ssi_driver.h
@@ -134,7 +134,6 @@ struct ssi_drvdata {
 	void *fips_handle;
 	void *ivgen_handle;
 	void *sram_mgr_handle;
-	u32 inflight_counter;
 	struct clk *clk;
 	bool coherent;
 };
-- 
2.7.4

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

* [PATCH 3/3] staging: ccree: remove dead code
@ 2017-10-31 11:56   ` Gilad Ben-Yossef
  0 siblings, 0 replies; 18+ messages in thread
From: Gilad Ben-Yossef @ 2017-10-31 11:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: devel, linux-kernel, driverdev-devel, linux-crypto, Ofir Drang

The inflight_counter field is updated in a single location and
never used. Remove it.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
 drivers/staging/ccree/ssi_cipher.c | 4 ----
 drivers/staging/ccree/ssi_driver.h | 1 -
 2 files changed, 5 deletions(-)

diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c
index 0784c86..42844ae 100644
--- a/drivers/staging/ccree/ssi_cipher.c
+++ b/drivers/staging/ccree/ssi_cipher.c
@@ -697,10 +697,6 @@ static int ssi_blkcipher_complete(struct device *dev,
 	ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst);
 	kfree(req_ctx->iv);
 
-	/*Decrease the inflight counter*/
-	if (ctx_p->flow_mode == BYPASS && ctx_p->drvdata->inflight_counter > 0)
-		ctx_p->drvdata->inflight_counter--;
-
 	if (areq) {
 		/*
 		 * The crypto API expects us to set the req->info to the last
diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h
index 488f665..e01c880 100644
--- a/drivers/staging/ccree/ssi_driver.h
+++ b/drivers/staging/ccree/ssi_driver.h
@@ -134,7 +134,6 @@ struct ssi_drvdata {
 	void *fips_handle;
 	void *ivgen_handle;
 	void *sram_mgr_handle;
-	u32 inflight_counter;
 	struct clk *clk;
 	bool coherent;
 };
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 1/3] staging: ccree: copy IV to DMAable memory
  2017-10-31 11:56   ` Gilad Ben-Yossef
@ 2017-11-01 10:58     ` Dan Carpenter
  -1 siblings, 0 replies; 18+ messages in thread
From: Dan Carpenter @ 2017-11-01 10:58 UTC (permalink / raw)
  To: Gilad Ben-Yossef
  Cc: Greg Kroah-Hartman, devel, linux-kernel, driverdev-devel,
	linux-crypto, Ofir Drang

On Tue, Oct 31, 2017 at 11:56:15AM +0000, Gilad Ben-Yossef wrote:
> +
> +	/* The IV we are handed may be allocted from the stack so
> +	 * we must copy it to a DMAable buffer before use.
> +	 */
> +	req_ctx->iv = kmalloc(ivsize, GFP_KERNEL);
> +	memcpy(req_ctx->iv, info, ivsize);

We need to check if kmalloc() fails.

regards,
dan carpenter

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

* Re: [PATCH 1/3] staging: ccree: copy IV to DMAable memory
@ 2017-11-01 10:58     ` Dan Carpenter
  0 siblings, 0 replies; 18+ messages in thread
From: Dan Carpenter @ 2017-11-01 10:58 UTC (permalink / raw)
  To: Gilad Ben-Yossef
  Cc: devel, Greg Kroah-Hartman, driverdev-devel, linux-kernel,
	linux-crypto, Ofir Drang

On Tue, Oct 31, 2017 at 11:56:15AM +0000, Gilad Ben-Yossef wrote:
> +
> +	/* The IV we are handed may be allocted from the stack so
> +	 * we must copy it to a DMAable buffer before use.
> +	 */
> +	req_ctx->iv = kmalloc(ivsize, GFP_KERNEL);
> +	memcpy(req_ctx->iv, info, ivsize);

We need to check if kmalloc() fails.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 2/3] staging: ccree: handle limiting of DMA masks
  2017-10-31 11:56   ` Gilad Ben-Yossef
@ 2017-11-01 10:59     ` Dan Carpenter
  -1 siblings, 0 replies; 18+ messages in thread
From: Dan Carpenter @ 2017-11-01 10:59 UTC (permalink / raw)
  To: Gilad Ben-Yossef
  Cc: Greg Kroah-Hartman, devel, linux-kernel, driverdev-devel,
	linux-crypto, Ofir Drang

On Tue, Oct 31, 2017 at 11:56:16AM +0000, Gilad Ben-Yossef wrote:
> +	dma_mask = (dma_addr_t)(DMA_BIT_MASK(DMA_BIT_MASK_LEN));
> +	while (dma_mask > 0x7fffffffUL) {
> +		if (dma_supported(&plat_dev->dev, dma_mask)) {
> +			rc = dma_set_coherent_mask(&plat_dev->dev, dma_mask);
> +				if (!rc)
> +					break;

The indenting is messed up.

> +		}
> +		dma_mask >>= 1;
> +	}

regards,
dan carpenter

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

* Re: [PATCH 2/3] staging: ccree: handle limiting of DMA masks
@ 2017-11-01 10:59     ` Dan Carpenter
  0 siblings, 0 replies; 18+ messages in thread
From: Dan Carpenter @ 2017-11-01 10:59 UTC (permalink / raw)
  To: Gilad Ben-Yossef
  Cc: devel, Greg Kroah-Hartman, driverdev-devel, linux-kernel,
	linux-crypto, Ofir Drang

On Tue, Oct 31, 2017 at 11:56:16AM +0000, Gilad Ben-Yossef wrote:
> +	dma_mask = (dma_addr_t)(DMA_BIT_MASK(DMA_BIT_MASK_LEN));
> +	while (dma_mask > 0x7fffffffUL) {
> +		if (dma_supported(&plat_dev->dev, dma_mask)) {
> +			rc = dma_set_coherent_mask(&plat_dev->dev, dma_mask);
> +				if (!rc)
> +					break;

The indenting is messed up.

> +		}
> +		dma_mask >>= 1;
> +	}

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 2/3] staging: ccree: handle limiting of DMA masks
  2017-10-31 11:56   ` Gilad Ben-Yossef
                     ` (2 preceding siblings ...)
  (?)
@ 2017-11-01 11:09   ` Dan Carpenter
  2017-11-02  7:28       ` Gilad Ben-Yossef
  -1 siblings, 1 reply; 18+ messages in thread
From: Dan Carpenter @ 2017-11-01 11:09 UTC (permalink / raw)
  To: Gilad Ben-Yossef
  Cc: Greg Kroah-Hartman, devel, linux-kernel, driverdev-devel,
	linux-crypto, Ofir Drang

On Tue, Oct 31, 2017 at 11:56:16AM +0000, Gilad Ben-Yossef wrote:
>  
> -	if (!dev->coherent_dma_mask)
> -		dev->coherent_dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN);
> +	if (rc) {
> +		dev_err(dev, "Error: failed in dma_set_mask, mask=%par\n",
> +			&dma_mask);
> +		goto post_drvdata_err;


Also this is not the right goto.  We should be turning the clk off.

I don't really care for the naming scheme, and I know you renamed it for
me already once and I feel bad for not liking it more.  It's still
really a come-from label name and doesn't say what the goto does...
Instead of post_clk_err, I wish it had names like "err_clk_off:".

And in this case what it does is print a duplicative error message and
return.  :/  The goto post_drvdata_err: lines should just print their
own error messages if needed and return directly.  If there is no
cleanup then there is no need for a goto.

Anyway, that's not related to this patch.  Just resend it with
goto post_clk_err: in the v2.

regards,
dan carpenter

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

* Re: [PATCH 2/3] staging: ccree: handle limiting of DMA masks
  2017-11-01 11:09   ` Dan Carpenter
  2017-11-02  7:28       ` Gilad Ben-Yossef
@ 2017-11-02  7:28       ` Gilad Ben-Yossef
  0 siblings, 0 replies; 18+ messages in thread
From: Gilad Ben-Yossef @ 2017-11-02  7:28 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: devel, Greg Kroah-Hartman, driverdev-devel,
	Linux kernel mailing list, Linux Crypto Mailing List, Ofir Drang

Hi,

Thank you for the review.

On Wed, Nov 1, 2017 at 1:09 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Tue, Oct 31, 2017 at 11:56:16AM +0000, Gilad Ben-Yossef wrote:
>>
>> -     if (!dev->coherent_dma_mask)
>> -             dev->coherent_dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN);
>> +     if (rc) {
>> +             dev_err(dev, "Error: failed in dma_set_mask, mask=%par\n",
>> +                     &dma_mask);
>> +             goto post_drvdata_err;
>
>
> Also this is not the right goto.  We should be turning the clk off.

Yes, it's wrong. I think a better thing to do though is to check the
DMA mask before turning the clock on, so the goto label
is right, but the code location is wrong...

>
> I don't really care for the naming scheme, and I know you renamed it for
> me already once and I feel bad for not liking it more.  It's still
> really a come-from label name and doesn't say what the goto does...
> Instead of post_clk_err, I wish it had names like "err_clk_off:".
>

> And in this case what it does is print a duplicative error message and
> return.  :/  The goto post_drvdata_err: lines should just print their
> own error messages if needed and return directly.  If there is no
> cleanup then there is no need for a goto.
>

Both good points. I will address them in a later patch.


> Anyway, that's not related to this patch.  Just resend it with
> goto post_clk_err: in the v2.

Will do.

Thanks!

Gilad


-- 
Gilad Ben-Yossef
Chief Coffee Drinker

"If you take a class in large-scale robotics, can you end up in a
situation where the homework eats your dog?"
 -- Jean-Baptiste Queru

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

* Re: [PATCH 2/3] staging: ccree: handle limiting of DMA masks
@ 2017-11-02  7:28       ` Gilad Ben-Yossef
  0 siblings, 0 replies; 18+ messages in thread
From: Gilad Ben-Yossef @ 2017-11-02  7:28 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Greg Kroah-Hartman, devel, Linux kernel mailing list,
	driverdev-devel, Linux Crypto Mailing List, Ofir Drang

Hi,

Thank you for the review.

On Wed, Nov 1, 2017 at 1:09 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Tue, Oct 31, 2017 at 11:56:16AM +0000, Gilad Ben-Yossef wrote:
>>
>> -     if (!dev->coherent_dma_mask)
>> -             dev->coherent_dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN);
>> +     if (rc) {
>> +             dev_err(dev, "Error: failed in dma_set_mask, mask=%par\n",
>> +                     &dma_mask);
>> +             goto post_drvdata_err;
>
>
> Also this is not the right goto.  We should be turning the clk off.

Yes, it's wrong. I think a better thing to do though is to check the
DMA mask before turning the clock on, so the goto label
is right, but the code location is wrong...

>
> I don't really care for the naming scheme, and I know you renamed it for
> me already once and I feel bad for not liking it more.  It's still
> really a come-from label name and doesn't say what the goto does...
> Instead of post_clk_err, I wish it had names like "err_clk_off:".
>

> And in this case what it does is print a duplicative error message and
> return.  :/  The goto post_drvdata_err: lines should just print their
> own error messages if needed and return directly.  If there is no
> cleanup then there is no need for a goto.
>

Both good points. I will address them in a later patch.


> Anyway, that's not related to this patch.  Just resend it with
> goto post_clk_err: in the v2.

Will do.

Thanks!

Gilad


-- 
Gilad Ben-Yossef
Chief Coffee Drinker

"If you take a class in large-scale robotics, can you end up in a
situation where the homework eats your dog?"
 -- Jean-Baptiste Queru

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

* Re: [PATCH 2/3] staging: ccree: handle limiting of DMA masks
@ 2017-11-02  7:28       ` Gilad Ben-Yossef
  0 siblings, 0 replies; 18+ messages in thread
From: Gilad Ben-Yossef @ 2017-11-02  7:28 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: devel, Greg Kroah-Hartman, driverdev-devel,
	Linux kernel mailing list, Linux Crypto Mailing List, Ofir Drang

Hi,

Thank you for the review.

On Wed, Nov 1, 2017 at 1:09 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Tue, Oct 31, 2017 at 11:56:16AM +0000, Gilad Ben-Yossef wrote:
>>
>> -     if (!dev->coherent_dma_mask)
>> -             dev->coherent_dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN);
>> +     if (rc) {
>> +             dev_err(dev, "Error: failed in dma_set_mask, mask=%par\n",
>> +                     &dma_mask);
>> +             goto post_drvdata_err;
>
>
> Also this is not the right goto.  We should be turning the clk off.

Yes, it's wrong. I think a better thing to do though is to check the
DMA mask before turning the clock on, so the goto label
is right, but the code location is wrong...

>
> I don't really care for the naming scheme, and I know you renamed it for
> me already once and I feel bad for not liking it more.  It's still
> really a come-from label name and doesn't say what the goto does...
> Instead of post_clk_err, I wish it had names like "err_clk_off:".
>

> And in this case what it does is print a duplicative error message and
> return.  :/  The goto post_drvdata_err: lines should just print their
> own error messages if needed and return directly.  If there is no
> cleanup then there is no need for a goto.
>

Both good points. I will address them in a later patch.


> Anyway, that's not related to this patch.  Just resend it with
> goto post_clk_err: in the v2.

Will do.

Thanks!

Gilad


-- 
Gilad Ben-Yossef
Chief Coffee Drinker

"If you take a class in large-scale robotics, can you end up in a
situation where the homework eats your dog?"
 -- Jean-Baptiste Queru
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

end of thread, other threads:[~2017-11-02  7:28 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-31 11:56 [PATCH 0/3] staging: ccree: Fixes and cleanups Gilad Ben-Yossef
2017-10-31 11:56 ` Gilad Ben-Yossef
2017-10-31 11:56 ` [PATCH 1/3] staging: ccree: copy IV to DMAable memory Gilad Ben-Yossef
2017-10-31 11:56   ` Gilad Ben-Yossef
2017-11-01 10:58   ` Dan Carpenter
2017-11-01 10:58     ` Dan Carpenter
2017-10-31 11:56 ` [PATCH 2/3] staging: ccree: handle limiting of DMA masks Gilad Ben-Yossef
2017-10-31 11:56   ` Gilad Ben-Yossef
2017-10-31 11:56   ` Gilad Ben-Yossef
2017-11-01 10:59   ` Dan Carpenter
2017-11-01 10:59     ` Dan Carpenter
2017-11-01 11:09   ` Dan Carpenter
2017-11-02  7:28     ` Gilad Ben-Yossef
2017-11-02  7:28       ` Gilad Ben-Yossef
2017-11-02  7:28       ` Gilad Ben-Yossef
2017-10-31 11:56 ` [PATCH 3/3] staging: ccree: remove dead code Gilad Ben-Yossef
2017-10-31 11:56   ` Gilad Ben-Yossef
2017-10-31 11:56   ` Gilad Ben-Yossef

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.