2023-01-08 22:49:38

by Bean Huo

[permalink] [raw]
Subject: [PATCH v2 0/3] Several compilation warnings fixes for UFS Advanced RPMB

Hi Martin,

These patches are to fix several compilation warnings introduced by my commit:
6ff265fc5ef6 ("scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg"),
please consider this patch series for the next your merge window.
Apologies for this!!



Changelog:

V1--V2:
1. Add new patches 2/3 and 3/3.


Bean Huo (3):
scsi: ufs: core: bsg: Fix sometimes-uninitialized warnings
scsi: core: Fix invisible definition compilation warning
scsi: ufs: core: bsg: Fix cast to restricted __be16 warning

drivers/ufs/core/ufs_bsg.c | 4 ++--
include/uapi/scsi/scsi_bsg_ufs.h | 12 ++++++------
include/ufs/ufshcd.h | 1 +
3 files changed, 9 insertions(+), 8 deletions(-)

--
2.25.1


2023-01-08 22:51:18

by Bean Huo

[permalink] [raw]
Subject: [PATCH v2 1/3] scsi: ufs: core: bsg: Fix sometimes-uninitialized warnings

From: Bean Huo <[email protected]>

Compilation complains that two possible variables are used without
initialization:

drivers/ufs/core/ufs_bsg.c:112:6: warning: variable 'sg_cnt' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
drivers/ufs/core/ufs_bsg.c:112:6: warning: variable 'sg_list' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

Fix both warnings by adding initialization with sg_cnt = 0, sg_list = NULL.

Fixes: 6ff265fc5ef6 ("scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg")
Signed-off-by: Bean Huo <[email protected]>
Reported-by: kernel test robot <[email protected]>
Reported-by: Xiaosen He <[email protected]>
Reviewed-by: Alim Akhtar <[email protected]>
---
drivers/ufs/core/ufs_bsg.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ufs/core/ufs_bsg.c b/drivers/ufs/core/ufs_bsg.c
index 0044029bcf7b..0d38e7fa34cc 100644
--- a/drivers/ufs/core/ufs_bsg.c
+++ b/drivers/ufs/core/ufs_bsg.c
@@ -70,9 +70,9 @@ static int ufs_bsg_exec_advanced_rpmb_req(struct ufs_hba *hba, struct bsg_job *j
struct ufs_rpmb_reply *rpmb_reply = job->reply;
struct bsg_buffer *payload = NULL;
enum dma_data_direction dir;
- struct scatterlist *sg_list;
+ struct scatterlist *sg_list = NULL;
int rpmb_req_type;
- int sg_cnt;
+ int sg_cnt = 0;
int ret;
int data_len;

--
2.25.1

2023-01-08 22:52:39

by Bean Huo

[permalink] [raw]
Subject: [PATCH v2 3/3] scsi: ufs: core: bsg: Fix cast to restricted __be16 warning

From: Bean Huo <[email protected]>

Fix the following sparse endianness warning:

"sparse warnings: drivers/ufs/core/ufs_bsg.c:91:25: sparse: sparse: cast to
restricted __be16."

For consistency with endianness annotations of other UFS data structures,
change __u16/32 to __be16/32 in UFS ARPMB data structures.

Fixes: 6ff265fc5ef6 ("scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg")
Reported-by: kernel test robot <[email protected]>
Signed-off-by: Bean Huo <[email protected]>
---
include/uapi/scsi/scsi_bsg_ufs.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/uapi/scsi/scsi_bsg_ufs.h b/include/uapi/scsi/scsi_bsg_ufs.h
index 276e2772328f..2801b65299aa 100644
--- a/include/uapi/scsi/scsi_bsg_ufs.h
+++ b/include/uapi/scsi/scsi_bsg_ufs.h
@@ -97,18 +97,18 @@ struct utp_upiu_req {
};

struct ufs_arpmb_meta {
- __u16 req_resp_type;
+ __be16 req_resp_type;
__u8 nonce[16];
- __u32 write_counter;
- __u16 addr_lun;
- __u16 block_count;
- __u16 result;
+ __be32 write_counter;
+ __be16 addr_lun;
+ __be16 block_count;
+ __be16 result;
} __attribute__((__packed__));

struct ufs_ehs {
__u8 length;
__u8 ehs_type;
- __u16 ehssub_type;
+ __be16 ehssub_type;
struct ufs_arpmb_meta meta;
__u8 mac_key[32];
} __attribute__((__packed__));
--
2.25.1

2023-01-08 23:18:51

by Bean Huo

[permalink] [raw]
Subject: [PATCH v2 2/3] scsi: core: Fix invisible definition compilation warning

From: Bean Huo <[email protected]>

In 'include/ufs/ufshcd.h' file, 'enum dma_data_direction' will be used,
which is defined in linux/dma-direction.h, however, this header file is
not included in ufshcd.h, thus causing the following compilation warning:

"warning: ‘enum dma_data_direction’ declared inside parameter list will
not be visible outside of this definition or declaration"

Fix this warning by including 'linux/dma-direction.h'.

Fixes: 6ff265fc5ef6 ("scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg")
Reported-by: Xiaosen He <[email protected]>
Reported-by: Bart Van Assche <[email protected]>
Signed-off-by: Bean Huo <[email protected]>
---
include/ufs/ufshcd.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index dd5912b4db77..e44a41abcc05 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -17,6 +17,7 @@
#include <linux/blk-mq.h>
#include <linux/devfreq.h>
#include <linux/pm_runtime.h>
+#include <linux/dma-direction.h>
#include <scsi/scsi_device.h>
#include <ufs/unipro.h>
#include <ufs/ufs.h>
--
2.25.1

2023-01-09 00:11:47

by Bart Van Assche

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Several compilation warnings fixes for UFS Advanced RPMB

On 1/8/23 14:40, Bean Huo wrote:
> These patches are to fix several compilation warnings introduced by my commit:
> 6ff265fc5ef6 ("scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg"),
> please consider this patch series for the next your merge window.

For the entire series:

Reviewed-by: Bart Van Assche <[email protected]>

2023-01-11 17:39:35

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [PATCH v2 1/3] scsi: ufs: core: bsg: Fix sometimes-uninitialized warnings

On Sun, Jan 08, 2023 at 11:40:55PM +0100, Bean Huo wrote:
> From: Bean Huo <[email protected]>
>
> Compilation complains that two possible variables are used without
> initialization:
>
> drivers/ufs/core/ufs_bsg.c:112:6: warning: variable 'sg_cnt' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
> drivers/ufs/core/ufs_bsg.c:112:6: warning: variable 'sg_list' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
>
> Fix both warnings by adding initialization with sg_cnt = 0, sg_list = NULL.
>
> Fixes: 6ff265fc5ef6 ("scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg")
> Signed-off-by: Bean Huo <[email protected]>
> Reported-by: kernel test robot <[email protected]>
> Reported-by: Xiaosen He <[email protected]>
> Reviewed-by: Alim Akhtar <[email protected]>

Thanks for the patch!
Reviewed-by: Nick Desaulniers <[email protected]>

We also got a report from KernelCI:

Link: https://lore.kernel.org/llvm/[email protected]/
Reported-by: kernelci.org bot <[email protected]>

> ---
> drivers/ufs/core/ufs_bsg.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ufs/core/ufs_bsg.c b/drivers/ufs/core/ufs_bsg.c
> index 0044029bcf7b..0d38e7fa34cc 100644
> --- a/drivers/ufs/core/ufs_bsg.c
> +++ b/drivers/ufs/core/ufs_bsg.c
> @@ -70,9 +70,9 @@ static int ufs_bsg_exec_advanced_rpmb_req(struct ufs_hba *hba, struct bsg_job *j
> struct ufs_rpmb_reply *rpmb_reply = job->reply;
> struct bsg_buffer *payload = NULL;
> enum dma_data_direction dir;
> - struct scatterlist *sg_list;
> + struct scatterlist *sg_list = NULL;
> int rpmb_req_type;
> - int sg_cnt;
> + int sg_cnt = 0;
> int ret;
> int data_len;
>
> --
> 2.25.1
>
>

2023-01-12 05:05:45

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Several compilation warnings fixes for UFS Advanced RPMB


Bean,

> These patches are to fix several compilation warnings introduced by my
> commit: 6ff265fc5ef6 ("scsi: ufs: core: bsg: Add advanced RPMB support
> in ufs_bsg"), please consider this patch series for the next your
> merge window. Apologies for this!!

Applied to 6.3/scsi-staging, thanks!

--
Martin K. Petersen Oracle Linux Engineering

2023-01-14 03:44:23

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Several compilation warnings fixes for UFS Advanced RPMB

On Sun, 08 Jan 2023 23:40:54 +0100, Bean Huo wrote:

> These patches are to fix several compilation warnings introduced by my commit:
> 6ff265fc5ef6 ("scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg"),
> please consider this patch series for the next your merge window.
> Apologies for this!!
>
>
>
> [...]

Applied to 6.3/scsi-queue, thanks!

[1/3] scsi: ufs: core: bsg: Fix sometimes-uninitialized warnings
https://git.kernel.org/mkp/scsi/c/5e87c51f186e
[2/3] scsi: core: Fix invisible definition compilation warning
https://git.kernel.org/mkp/scsi/c/f3e57da52812
[3/3] scsi: ufs: core: bsg: Fix cast to restricted __be16 warning
https://git.kernel.org/mkp/scsi/c/e2cb6e8db69e

--
Martin K. Petersen Oracle Linux Engineering