Message ID | 20220224101129.371905-2-damien.lemoal@opensource.wdc.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Fix mpt3sas driver sparse warnings | expand |
On 2/24/22 02:11, Damien Le Moal wrote: > diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_init.h b/drivers/scsi/mpt3sas/mpi/mpi2_init.h > index 8f1b903fe0a9..80bcf7d83184 100644 > --- a/drivers/scsi/mpt3sas/mpi/mpi2_init.h > +++ b/drivers/scsi/mpt3sas/mpi/mpi2_init.h > @@ -428,7 +428,7 @@ typedef struct _MPI2_SCSI_TASK_MANAGE_REQUEST { > U16 Reserved3; /*0x0A */ > U8 LUN[8]; /*0x0C */ > U32 Reserved4[7]; /*0x14 */ > - U16 TaskMID; /*0x30 */ > + __le16 TaskMID; /*0x30 */ > U16 Reserved5; /*0x32 */ > } MPI2_SCSI_TASK_MANAGE_REQUEST, > *PTR_MPI2_SCSI_TASK_MANAGE_REQUEST, Is this change necessary? From drivers/scsi/mpt3sas/mpi/mpi2_type.h: typedef __le16 U16; BTW, I think the U16 etc. typedefs should disappear. Thanks, Bart.
On 2/25/22 04:49, Bart Van Assche wrote: > On 2/24/22 02:11, Damien Le Moal wrote: >> diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_init.h b/drivers/scsi/mpt3sas/mpi/mpi2_init.h >> index 8f1b903fe0a9..80bcf7d83184 100644 >> --- a/drivers/scsi/mpt3sas/mpi/mpi2_init.h >> +++ b/drivers/scsi/mpt3sas/mpi/mpi2_init.h >> @@ -428,7 +428,7 @@ typedef struct _MPI2_SCSI_TASK_MANAGE_REQUEST { >> U16 Reserved3; /*0x0A */ >> U8 LUN[8]; /*0x0C */ >> U32 Reserved4[7]; /*0x14 */ >> - U16 TaskMID; /*0x30 */ >> + __le16 TaskMID; /*0x30 */ >> U16 Reserved5; /*0x32 */ >> } MPI2_SCSI_TASK_MANAGE_REQUEST, >> *PTR_MPI2_SCSI_TASK_MANAGE_REQUEST, > > Is this change necessary? From drivers/scsi/mpt3sas/mpi/mpi2_type.h: > > typedef __le16 U16; Well, sparse seems to not catch that. Without the change, I get warnings. Will check again. > > BTW, I think the U16 etc. typedefs should disappear. I agree on that :) > > Thanks, > > Bart.
On 2/25/22 04:49, Bart Van Assche wrote: > On 2/24/22 02:11, Damien Le Moal wrote: >> diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_init.h b/drivers/scsi/mpt3sas/mpi/mpi2_init.h >> index 8f1b903fe0a9..80bcf7d83184 100644 >> --- a/drivers/scsi/mpt3sas/mpi/mpi2_init.h >> +++ b/drivers/scsi/mpt3sas/mpi/mpi2_init.h >> @@ -428,7 +428,7 @@ typedef struct _MPI2_SCSI_TASK_MANAGE_REQUEST { >> U16 Reserved3; /*0x0A */ >> U8 LUN[8]; /*0x0C */ >> U32 Reserved4[7]; /*0x14 */ >> - U16 TaskMID; /*0x30 */ >> + __le16 TaskMID; /*0x30 */ >> U16 Reserved5; /*0x32 */ >> } MPI2_SCSI_TASK_MANAGE_REQUEST, >> *PTR_MPI2_SCSI_TASK_MANAGE_REQUEST, > > Is this change necessary? From drivers/scsi/mpt3sas/mpi/mpi2_type.h: > > typedef __le16 U16; Bart, You are correct. The type change is not needed. Sending v2 with the update. Thanks for checking. > > BTW, I think the U16 etc. typedefs should disappear. > > Thanks, > > Bart.
diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_init.h b/drivers/scsi/mpt3sas/mpi/mpi2_init.h index 8f1b903fe0a9..80bcf7d83184 100644 --- a/drivers/scsi/mpt3sas/mpi/mpi2_init.h +++ b/drivers/scsi/mpt3sas/mpi/mpi2_init.h @@ -428,7 +428,7 @@ typedef struct _MPI2_SCSI_TASK_MANAGE_REQUEST { U16 Reserved3; /*0x0A */ U8 LUN[8]; /*0x0C */ U32 Reserved4[7]; /*0x14 */ - U16 TaskMID; /*0x30 */ + __le16 TaskMID; /*0x30 */ U16 Reserved5; /*0x32 */ } MPI2_SCSI_TASK_MANAGE_REQUEST, *PTR_MPI2_SCSI_TASK_MANAGE_REQUEST, diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index d92ca140d298..eac253fce2da 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -618,7 +618,8 @@ _ctl_set_task_mid(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command *karg, * first outstanding smid will be picked up. Otherwise, * targeted smid will be the one. */ - if (!tm_request->TaskMID || tm_request->TaskMID == st->smid) { + if (!tm_request->TaskMID || + tm_request->TaskMID == cpu_to_le16(st->smid)) { tm_request->TaskMID = cpu_to_le16(st->smid); found = 1; }
The TaskMID field of sturtc Mpi2SCSITaskManagementRequest_t seems to be a 16-bits little endian value but is not declared as such, causing sparse to generate warnings. Change this field declaration to __le16 and fix a test in _ctl_set_task_mid() to avoid sparse warnings. Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> --- drivers/scsi/mpt3sas/mpi/mpi2_init.h | 2 +- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)