2024-02-16 15:50:31

by Adam Guerin

[permalink] [raw]
Subject: [PATCH 0/6] crypto: qat - fix warnings reported by clang

This set fixes a list of warnings found by compiling the QAT driver with
"CC=clang W=2" and with the Clang tool scan-build.

These fixes include removing unused macros in both adf_cnv_dbgfs.c and
qat_comp_alg.c, fix initialization of multiple variables, check that
delta_us is not 0, and fixing the comment structures in multiple files.

Adam Guerin (6):
crypto: qat - remove unused macros in qat_comp_alg.c
crypto: qat - removed unused macro in adf_cnv_dbgfs.c
crypto: qat - avoid division by zero
crypto: qat - remove double initialization of value
crypto: qat - remove unnecessary description from comment
crypto: qat - fix comment structure

drivers/crypto/intel/qat/qat_common/adf_clock.c | 3 +++
drivers/crypto/intel/qat/qat_common/adf_cnv_dbgfs.c | 1 -
drivers/crypto/intel/qat/qat_common/adf_dev_mgr.c | 4 ++--
drivers/crypto/intel/qat/qat_common/adf_gen4_ras.c | 6 ++----
drivers/crypto/intel/qat/qat_common/adf_isr.c | 2 --
drivers/crypto/intel/qat/qat_common/adf_vf_isr.c | 2 --
drivers/crypto/intel/qat/qat_common/qat_comp_algs.c | 9 ---------
drivers/crypto/intel/qat/qat_common/qat_crypto.c | 4 ++--
8 files changed, 9 insertions(+), 22 deletions(-)


base-commit: 7a35f3adf4535a9a56ef7b3e75355806632030ca
--
2.40.1



2024-02-16 15:51:22

by Adam Guerin

[permalink] [raw]
Subject: [PATCH 1/6] crypto: qat - remove unused macros in qat_comp_alg.c

As a result of the removal of qat_zlib_deflate, some defines where not
removed. Remove them.

This is to fix the following warning when compiling the QAT driver
using the clang compiler with CC=clang W=2:
drivers/crypto/intel/qat/qat_common/qat_comp_algs.c:21:9: warning: macro is not used [-Wunused-macros]
21 | #define QAT_RFC_1950_CM_OFFSET 4
| ^
drivers/crypto/intel/qat/qat_common/qat_comp_algs.c:16:9: warning: macro is not used [-Wunused-macros]
16 | #define QAT_RFC_1950_HDR_SIZE 2
| ^
drivers/crypto/intel/qat/qat_common/qat_comp_algs.c:17:9: warning: macro is not used [-Wunused-macros]
17 | #define QAT_RFC_1950_FOOTER_SIZE 4
| ^
drivers/crypto/intel/qat/qat_common/qat_comp_algs.c:22:9: warning: macro is not used [-Wunused-macros]
22 | #define QAT_RFC_1950_DICT_MASK 0x20
| ^
drivers/crypto/intel/qat/qat_common/qat_comp_algs.c:18:9: warning: macro is not used [-Wunused-macros]
18 | #define QAT_RFC_1950_CM_DEFLATE 8
| ^
drivers/crypto/intel/qat/qat_common/qat_comp_algs.c:20:9: warning: macro is not used [-Wunused-macros]
20 | #define QAT_RFC_1950_CM_MASK 0x0f
| ^
drivers/crypto/intel/qat/qat_common/qat_comp_algs.c:23:9: warning: macro is not used [-Wunused-macros]
23 | #define QAT_RFC_1950_COMP_HDR 0x785e
| ^
drivers/crypto/intel/qat/qat_common/qat_comp_algs.c:19:9: warning: macro is not used [-Wunused-macros]
19 | #define QAT_RFC_1950_CM_DEFLATE_CINFO_32K 7
| ^

Fixes: e9dd20e0e5f6 ("crypto: qat - Remove zlib-deflate")
Signed-off-by: Adam Guerin <[email protected]>
Reviewed-by: Giovanni Cabiddu <[email protected]>
---
drivers/crypto/intel/qat/qat_common/qat_comp_algs.c | 9 ---------
1 file changed, 9 deletions(-)

diff --git a/drivers/crypto/intel/qat/qat_common/qat_comp_algs.c b/drivers/crypto/intel/qat/qat_common/qat_comp_algs.c
index bf8c0ee62917..2ba4aa22e092 100644
--- a/drivers/crypto/intel/qat/qat_common/qat_comp_algs.c
+++ b/drivers/crypto/intel/qat/qat_common/qat_comp_algs.c
@@ -13,15 +13,6 @@
#include "qat_compression.h"
#include "qat_algs_send.h"

-#define QAT_RFC_1950_HDR_SIZE 2
-#define QAT_RFC_1950_FOOTER_SIZE 4
-#define QAT_RFC_1950_CM_DEFLATE 8
-#define QAT_RFC_1950_CM_DEFLATE_CINFO_32K 7
-#define QAT_RFC_1950_CM_MASK 0x0f
-#define QAT_RFC_1950_CM_OFFSET 4
-#define QAT_RFC_1950_DICT_MASK 0x20
-#define QAT_RFC_1950_COMP_HDR 0x785e
-
static DEFINE_MUTEX(algs_lock);
static unsigned int active_devs;

--
2.40.1


2024-02-16 15:51:28

by Adam Guerin

[permalink] [raw]
Subject: [PATCH 4/6] crypto: qat - remove double initialization of value

Remove double initialization of the reg variable.

This is to fix the following warning when compiling the QAT driver
using clang scan-build:
drivers/crypto/intel/qat/qat_common/adf_gen4_ras.c:1010:6: warning: Value stored to 'reg' during its initialization is never read [deadcode.DeadStores]
1010 | u32 reg = ADF_CSR_RD(csr, ADF_GEN4_SSMCPPERR);
| ^~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/crypto/intel/qat/qat_common/adf_gen4_ras.c:1109:6: warning: Value stored to 'reg' during its initialization is never read [deadcode.DeadStores]
1109 | u32 reg = ADF_CSR_RD(csr, ADF_GEN4_SER_ERR_SSMSH);
| ^~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fixes: 99b1c9826e48 ("crypto: qat - count QAT GEN4 errors")
Signed-off-by: Adam Guerin <[email protected]>
Reviewed-by: Giovanni Cabiddu <[email protected]>
---
drivers/crypto/intel/qat/qat_common/adf_gen4_ras.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/intel/qat/qat_common/adf_gen4_ras.c b/drivers/crypto/intel/qat/qat_common/adf_gen4_ras.c
index 048c24607939..2dd3772bf58a 100644
--- a/drivers/crypto/intel/qat/qat_common/adf_gen4_ras.c
+++ b/drivers/crypto/intel/qat/qat_common/adf_gen4_ras.c
@@ -1007,8 +1007,7 @@ static bool adf_handle_spppar_err(struct adf_accel_dev *accel_dev,
static bool adf_handle_ssmcpppar_err(struct adf_accel_dev *accel_dev,
void __iomem *csr, u32 iastatssm)
{
- u32 reg = ADF_CSR_RD(csr, ADF_GEN4_SSMCPPERR);
- u32 bits_num = BITS_PER_REG(reg);
+ u32 reg, bits_num = BITS_PER_REG(reg);
bool reset_required = false;
unsigned long errs_bits;
u32 bit_iterator;
@@ -1106,8 +1105,7 @@ static bool adf_handle_rf_parr_err(struct adf_accel_dev *accel_dev,
static bool adf_handle_ser_err_ssmsh(struct adf_accel_dev *accel_dev,
void __iomem *csr, u32 iastatssm)
{
- u32 reg = ADF_CSR_RD(csr, ADF_GEN4_SER_ERR_SSMSH);
- u32 bits_num = BITS_PER_REG(reg);
+ u32 reg, bits_num = BITS_PER_REG(reg);
bool reset_required = false;
unsigned long errs_bits;
u32 bit_iterator;
--
2.40.1


2024-02-16 15:57:42

by Adam Guerin

[permalink] [raw]
Subject: [PATCH 3/6] crypto: qat - avoid division by zero

Check if delta_us is not zero and return -EINVAL if it is.
delta_us is unlikely to be zero as there is a sleep between the reads of
the two timestamps.

This is to fix the following warning when compiling the QAT driver
using clang scan-build:
drivers/crypto/intel/qat/qat_common/adf_clock.c:87:9: warning: Division by zero [core.DivideZero]
87 | temp = DIV_ROUND_CLOSEST_ULL(temp, delta_us);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fixes: e2980ba57e79 ("crypto: qat - add measure clock frequency")
Signed-off-by: Adam Guerin <[email protected]>
Reviewed-by: Giovanni Cabiddu <[email protected]>
---
drivers/crypto/intel/qat/qat_common/adf_clock.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/crypto/intel/qat/qat_common/adf_clock.c b/drivers/crypto/intel/qat/qat_common/adf_clock.c
index 01e0a389e462..cf89f57de2a7 100644
--- a/drivers/crypto/intel/qat/qat_common/adf_clock.c
+++ b/drivers/crypto/intel/qat/qat_common/adf_clock.c
@@ -83,6 +83,9 @@ static int measure_clock(struct adf_accel_dev *accel_dev, u32 *frequency)
}

delta_us = timespec_to_us(&ts3) - timespec_to_us(&ts1);
+ if (!delta_us)
+ return -EINVAL;
+
temp = (timestamp2 - timestamp1) * ME_CLK_DIVIDER * 10;
temp = DIV_ROUND_CLOSEST_ULL(temp, delta_us);
/*
--
2.40.1


2024-02-24 00:51:21

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH 0/6] crypto: qat - fix warnings reported by clang

On Fri, Feb 16, 2024 at 03:19:54PM +0000, Adam Guerin wrote:
> This set fixes a list of warnings found by compiling the QAT driver with
> "CC=clang W=2" and with the Clang tool scan-build.
>
> These fixes include removing unused macros in both adf_cnv_dbgfs.c and
> qat_comp_alg.c, fix initialization of multiple variables, check that
> delta_us is not 0, and fixing the comment structures in multiple files.
>
> Adam Guerin (6):
> crypto: qat - remove unused macros in qat_comp_alg.c
> crypto: qat - removed unused macro in adf_cnv_dbgfs.c
> crypto: qat - avoid division by zero
> crypto: qat - remove double initialization of value
> crypto: qat - remove unnecessary description from comment
> crypto: qat - fix comment structure
>
> drivers/crypto/intel/qat/qat_common/adf_clock.c | 3 +++
> drivers/crypto/intel/qat/qat_common/adf_cnv_dbgfs.c | 1 -
> drivers/crypto/intel/qat/qat_common/adf_dev_mgr.c | 4 ++--
> drivers/crypto/intel/qat/qat_common/adf_gen4_ras.c | 6 ++----
> drivers/crypto/intel/qat/qat_common/adf_isr.c | 2 --
> drivers/crypto/intel/qat/qat_common/adf_vf_isr.c | 2 --
> drivers/crypto/intel/qat/qat_common/qat_comp_algs.c | 9 ---------
> drivers/crypto/intel/qat/qat_common/qat_crypto.c | 4 ++--
> 8 files changed, 9 insertions(+), 22 deletions(-)
>
>
> base-commit: 7a35f3adf4535a9a56ef7b3e75355806632030ca
> --
> 2.40.1

All applied. Thanks.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt