All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3] crypto: qat - fix timeout issues
@ 2016-01-07  1:39 Yang Pingchao
  2016-01-15 18:29 ` [V3] " Tadeusz Struk
  0 siblings, 1 reply; 3+ messages in thread
From: Yang Pingchao @ 2016-01-07  1:39 UTC (permalink / raw)
  To: herbert; +Cc: tadeusz.struk, linux-crypto, qat-linux, Yang Pingchao

Change the variable times data type and timeout conditon since the value
of times should be -1 after loop.

Signed-off-by: Yang Pingchao <pingchao.yang@intel.com>
---
 drivers/crypto/qat/qat_common/qat_hal.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/qat_hal.c b/drivers/crypto/qat/qat_common/qat_hal.c
index 0ac0ba8..7786e6e 100644
--- a/drivers/crypto/qat/qat_common/qat_hal.c
+++ b/drivers/crypto/qat/qat_common/qat_hal.c
@@ -389,7 +389,7 @@ static int qat_hal_check_ae_alive(struct icp_qat_fw_loader_handle *handle)
 {
 	unsigned int base_cnt, cur_cnt;
 	unsigned char ae;
-	unsigned int times = MAX_RETRY_TIMES;
+	int times = MAX_RETRY_TIMES;
 
 	for (ae = 0; ae < handle->hal_handle->ae_max_num; ae++) {
 		qat_hal_rd_ae_csr(handle, ae, PROFILE_COUNT,
@@ -402,7 +402,7 @@ static int qat_hal_check_ae_alive(struct icp_qat_fw_loader_handle *handle)
 			cur_cnt &= 0xffff;
 		} while (times-- && (cur_cnt == base_cnt));
 
-		if (!times) {
+		if (times < 0) {
 			pr_err("QAT: AE%d is inactive!!\n", ae);
 			return -EFAULT;
 		}
@@ -453,7 +453,8 @@ static int qat_hal_init_esram(struct icp_qat_fw_loader_handle *handle)
 	void __iomem *csr_addr =
 			(void __iomem *)((uintptr_t)handle->hal_ep_csr_addr_v +
 			ESRAM_AUTO_INIT_CSR_OFFSET);
-	unsigned int csr_val, times = 30;
+	unsigned int csr_val;
+	int times = 30;
 
 	csr_val = ADF_CSR_RD(csr_addr, 0);
 	if ((csr_val & ESRAM_AUTO_TINIT) && (csr_val & ESRAM_AUTO_TINIT_DONE))
@@ -467,7 +468,7 @@ static int qat_hal_init_esram(struct icp_qat_fw_loader_handle *handle)
 		qat_hal_wait_cycles(handle, 0, ESRAM_AUTO_INIT_USED_CYCLES, 0);
 		csr_val = ADF_CSR_RD(csr_addr, 0);
 	} while (!(csr_val & ESRAM_AUTO_TINIT_DONE) && times--);
-	if ((!times)) {
+	if ((times < 0)) {
 		pr_err("QAT: Fail to init eSram!\n");
 		return -EFAULT;
 	}
@@ -658,7 +659,7 @@ static int qat_hal_clear_gpr(struct icp_qat_fw_loader_handle *handle)
 			ret = qat_hal_wait_cycles(handle, ae, 20, 1);
 		} while (ret && times--);
 
-		if (!times) {
+		if (times < 0) {
 			pr_err("QAT: clear GPR of AE %d failed", ae);
 			return -EINVAL;
 		}
-- 
2.6.4

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

* Re: [V3] crypto: qat - fix timeout issues
  2016-01-07  1:39 [PATCH V3] crypto: qat - fix timeout issues Yang Pingchao
@ 2016-01-15 18:29 ` Tadeusz Struk
  2016-01-18 15:22   ` Herbert Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Tadeusz Struk @ 2016-01-15 18:29 UTC (permalink / raw)
  To: herbert; +Cc: Pingchao Yang, linux-crypto, qat-linux

On 01/06/2016 05:39 PM, Pingchao Yang wrote:
> Change the variable times data type and timeout conditon since the value
> of times should be -1 after loop.
> 
> Signed-off-by: Yang Pingchao <pingchao.yang@intel.com>
> 
> ---
> drivers/crypto/qat/qat_common/qat_hal.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/crypto/qat/qat_common/qat_hal.c b/drivers/crypto/qat/qat_common/qat_hal.c
> index 0ac0ba8..7786e6e 100644
> --- a/drivers/crypto/qat/qat_common/qat_hal.c
> +++ b/drivers/crypto/qat/qat_common/qat_hal.c
> @@ -389,7 +389,7 @@ static int qat_hal_check_ae_alive(struct icp_qat_fw_loader_handle *handle)
>  {
>  	unsigned int base_cnt, cur_cnt;
>  	unsigned char ae;
> -	unsigned int times = MAX_RETRY_TIMES;
> +	int times = MAX_RETRY_TIMES;
>  
>  	for (ae = 0; ae < handle->hal_handle->ae_max_num; ae++) {
>  		qat_hal_rd_ae_csr(handle, ae, PROFILE_COUNT,
> @@ -402,7 +402,7 @@ static int qat_hal_check_ae_alive(struct icp_qat_fw_loader_handle *handle)
>  			cur_cnt &= 0xffff;
>  		} while (times-- && (cur_cnt == base_cnt));
>  
> -		if (!times) {
> +		if (times < 0) {
>  			pr_err("QAT: AE%d is inactive!!\n", ae);
>  			return -EFAULT;
>  		}
> @@ -453,7 +453,8 @@ static int qat_hal_init_esram(struct icp_qat_fw_loader_handle *handle)
>  	void __iomem *csr_addr =
>  			(void __iomem *)((uintptr_t)handle->hal_ep_csr_addr_v +
>  			ESRAM_AUTO_INIT_CSR_OFFSET);
> -	unsigned int csr_val, times = 30;
> +	unsigned int csr_val;
> +	int times = 30;
>  
>  	csr_val = ADF_CSR_RD(csr_addr, 0);
>  	if ((csr_val & ESRAM_AUTO_TINIT) && (csr_val & ESRAM_AUTO_TINIT_DONE))
> @@ -467,7 +468,7 @@ static int qat_hal_init_esram(struct icp_qat_fw_loader_handle *handle)
>  		qat_hal_wait_cycles(handle, 0, ESRAM_AUTO_INIT_USED_CYCLES, 0);
>  		csr_val = ADF_CSR_RD(csr_addr, 0);
>  	} while (!(csr_val & ESRAM_AUTO_TINIT_DONE) && times--);
> -	if ((!times)) {
> +	if ((times < 0)) {
>  		pr_err("QAT: Fail to init eSram!\n");
>  		return -EFAULT;
>  	}
> @@ -658,7 +659,7 @@ static int qat_hal_clear_gpr(struct icp_qat_fw_loader_handle *handle)
>  			ret = qat_hal_wait_cycles(handle, ae, 20, 1);
>  		} while (ret && times--);
>  
> -		if (!times) {
> +		if (times < 0) {
>  			pr_err("QAT: clear GPR of AE %d failed", ae);
>  			return -EINVAL;
>  		}
> 
Herbert,
This fixes integer overflow issue around csr initialization.
Please include this fix into 4.5.
Thanks,

-- 
TS

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

* Re: [V3] crypto: qat - fix timeout issues
  2016-01-15 18:29 ` [V3] " Tadeusz Struk
@ 2016-01-18 15:22   ` Herbert Xu
  0 siblings, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2016-01-18 15:22 UTC (permalink / raw)
  To: Tadeusz Struk; +Cc: Pingchao Yang, linux-crypto, qat-linux

On Fri, Jan 15, 2016 at 10:29:01AM -0800, Tadeusz Struk wrote:
> On 01/06/2016 05:39 PM, Pingchao Yang wrote:
> > Change the variable times data type and timeout conditon since the value
> > of times should be -1 after loop.
> > 
> > Signed-off-by: Yang Pingchao <pingchao.yang@intel.com>

Patch applied.  Thanks!
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2016-01-18 15:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-07  1:39 [PATCH V3] crypto: qat - fix timeout issues Yang Pingchao
2016-01-15 18:29 ` [V3] " Tadeusz Struk
2016-01-18 15:22   ` Herbert Xu

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.