* [patch] crypto: qat - fix some timeout tests
@ 2015-12-15 10:05 Dan Carpenter
2015-12-15 20:27 ` Tadeusz Struk
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2015-12-15 10:05 UTC (permalink / raw)
To: Tadeusz Struk
Cc: Herbert Xu, David S. Miller, Bruce Allan, Pingchao Yang,
qat-linux, linux-crypto, kernel-janitors
We do an "if (!times)" test later to see if we ran the loop too many
times, but because it is a postop negate that means times is -1 when we
exit that way. I have fixed this by changing it from a post op to a
preop.
Fixes: b3416fb8a2f5 ('crypto: qat - Intel(R) QAT accelengine part of fw loader')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This means we only loop 9999 times instead of 10000 like before but I
figure it probably doesn't matter.
diff --git a/drivers/crypto/qat/qat_common/qat_hal.c b/drivers/crypto/qat/qat_common/qat_hal.c
index 45c1739..2b078a6 100644
--- a/drivers/crypto/qat/qat_common/qat_hal.c
+++ b/drivers/crypto/qat/qat_common/qat_hal.c
@@ -171,7 +171,7 @@ static int qat_hal_wait_cycles(struct icp_qat_fw_loader_handle *handle,
qat_hal_rd_ae_csr(handle, ae, PROFILE_COUNT, &base_cnt);
base_cnt &= 0xffff;
- while ((int)cycles > elapsed_cycles && times--) {
+ while ((int)cycles > elapsed_cycles && --times) {
if (chk_inactive)
qat_hal_rd_ae_csr(handle, ae, ACTIVE_CTX_STATUS, &csr);
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [patch] crypto: qat - fix some timeout tests
2015-12-15 10:05 [patch] crypto: qat - fix some timeout tests Dan Carpenter
@ 2015-12-15 20:27 ` Tadeusz Struk
2015-12-15 23:50 ` Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Tadeusz Struk @ 2015-12-15 20:27 UTC (permalink / raw)
To: Dan Carpenter
Cc: Herbert Xu, David S. Miller, Bruce Allan, Pingchao Yang,
qat-linux, linux-crypto, kernel-janitors
On 12/15/2015 02:05 AM, Dan Carpenter wrote:
> We do an "if (!times)" test later to see if we ran the loop too many
> times, but because it is a postop negate that means times is -1 when we
> exit that way. I have fixed this by changing it from a post op to a
> preop.
>
> Fixes: b3416fb8a2f5 ('crypto: qat - Intel(R) QAT accelengine part of fw loader')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> This means we only loop 9999 times instead of 10000 like before but I
> figure it probably doesn't matter.
>
> diff --git a/drivers/crypto/qat/qat_common/qat_hal.c b/drivers/crypto/qat/qat_common/qat_hal.c
> index 45c1739..2b078a6 100644
> --- a/drivers/crypto/qat/qat_common/qat_hal.c
> +++ b/drivers/crypto/qat/qat_common/qat_hal.c
> @@ -171,7 +171,7 @@ static int qat_hal_wait_cycles(struct icp_qat_fw_loader_handle *handle,
>
> qat_hal_rd_ae_csr(handle, ae, PROFILE_COUNT, &base_cnt);
> base_cnt &= 0xffff;
> - while ((int)cycles > elapsed_cycles && times--) {
> + while ((int)cycles > elapsed_cycles && --times) {
> if (chk_inactive)
> qat_hal_rd_ae_csr(handle, ae, ACTIVE_CTX_STATUS, &csr);
>
>
Since the times var is an signed int I think we should rather change the condition:
diff --git a/drivers/crypto/qat/qat_common/qat_hal.c b/drivers/crypto/qat/qat_common/qat_hal.c
index 45c1739..864a5ea 100644
--- a/drivers/crypto/qat/qat_common/qat_hal.c
+++ b/drivers/crypto/qat/qat_common/qat_hal.c
@@ -186,7 +186,7 @@ static int qat_hal_wait_cycles(struct icp_qat_fw_loader_handle *handle,
if (elapsed_cycles >= 8 && !(csr & (1 << ACS_ABO_BITPOS)))
return 0;
}
- if (!times) {
+ if (!(0 < times)) {
pr_err("QAT: wait_num_cycles time out\n");
return -EFAULT;
}
Pingchao could you test and send a patch please.
Thanks
--
TS
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [patch] crypto: qat - fix some timeout tests
2015-12-15 20:27 ` Tadeusz Struk
@ 2015-12-15 23:50 ` Dan Carpenter
0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2015-12-15 23:50 UTC (permalink / raw)
To: Tadeusz Struk
Cc: Herbert Xu, David S. Miller, Bruce Allan, Pingchao Yang,
qat-linux, linux-crypto, kernel-janitors
On Tue, Dec 15, 2015 at 12:27:23PM -0800, Tadeusz Struk wrote:
> Since the times var is an signed int I think we should rather change the condition:
I don't see what signed int has to do with anything.
>
> diff --git a/drivers/crypto/qat/qat_common/qat_hal.c b/drivers/crypto/qat/qat_common/qat_hal.c
> index 45c1739..864a5ea 100644
> --- a/drivers/crypto/qat/qat_common/qat_hal.c
> +++ b/drivers/crypto/qat/qat_common/qat_hal.c
> @@ -186,7 +186,7 @@ static int qat_hal_wait_cycles(struct icp_qat_fw_loader_handle *handle,
> if (elapsed_cycles >= 8 && !(csr & (1 << ACS_ABO_BITPOS)))
> return 0;
> }
> - if (!times) {
> + if (!(0 < times)) {
Oh, wow that's nasty! Why would you write it in such an obfuscated way?
Plus it's buggy and wrong... What on earth.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] crypto: qat - fix some timeout tests
@ 2015-12-16 6:09 Yang Pingchao
2015-12-22 13:23 ` Herbert Xu
0 siblings, 1 reply; 5+ messages in thread
From: Yang Pingchao @ 2015-12-16 6:09 UTC (permalink / raw)
To: herbert, dan.carpenter
Cc: tadeusz.struk, linux-crypto, qat-linux, kernel-janitors,
Yang Pingchao
Change the timeout condition since the times value would be -1 after
running MAX_RETRY_TIMES.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Yang Pingchao <pingchao.yang@intel.com>
---
drivers/crypto/qat/qat_common/qat_hal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/qat/qat_common/qat_hal.c b/drivers/crypto/qat/qat_common/qat_hal.c
index 81bd1fe..0ac0ba8 100644
--- a/drivers/crypto/qat/qat_common/qat_hal.c
+++ b/drivers/crypto/qat/qat_common/qat_hal.c
@@ -186,7 +186,7 @@ static int qat_hal_wait_cycles(struct icp_qat_fw_loader_handle *handle,
if (elapsed_cycles >= 8 && !(csr & (1 << ACS_ABO_BITPOS)))
return 0;
}
- if (!times) {
+ if (times < 0) {
pr_err("QAT: wait_num_cycles time out\n");
return -EFAULT;
}
--
2.6.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] crypto: qat - fix some timeout tests
2015-12-16 6:09 [PATCH] " Yang Pingchao
@ 2015-12-22 13:23 ` Herbert Xu
0 siblings, 0 replies; 5+ messages in thread
From: Herbert Xu @ 2015-12-22 13:23 UTC (permalink / raw)
To: Yang Pingchao
Cc: dan.carpenter, tadeusz.struk, linux-crypto, qat-linux,
kernel-janitors
On Wed, Dec 16, 2015 at 02:09:50PM +0800, Yang Pingchao wrote:
> Change the timeout condition since the times value would be -1 after
> running MAX_RETRY_TIMES.
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> 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] 5+ messages in thread
end of thread, other threads:[~2015-12-22 13:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-15 10:05 [patch] crypto: qat - fix some timeout tests Dan Carpenter
2015-12-15 20:27 ` Tadeusz Struk
2015-12-15 23:50 ` Dan Carpenter
-- strict thread matches above, loose matches on Subject: below --
2015-12-16 6:09 [PATCH] " Yang Pingchao
2015-12-22 13:23 ` Herbert Xu
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).