Subject: Re: linux-next: build failure after merge of the scsi-mkp tree

From: Stephen Rothwell <[email-masked]>
Date: Wed, 27 Apr 2022 18:28:53 +1000

Hi Sumit,

On Wed, 27 Apr 2022 13:10:57 +0530 Sumit Saxena <[email-masked]> wrote:
>
> Could you please try if the below patch fixes this build failure:
> 
> From: Sumit Saxena <[email-masked]>
> Date: Wed, 27 Apr 2022 03:35:34 -0400
> Subject: [PATCH] uapi: include <linux/types.h> header in scsi_bsg_mpi3mr.h
> 
> Signed-off-by: Sumit Saxena <[email-masked]>
> ---
>  include/uapi/scsi/scsi_bsg_mpi3mr.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/uapi/scsi/scsi_bsg_mpi3mr.h
> b/include/uapi/scsi/scsi_bsg_mpi3mr.h
> index 46c33efcff19..a0ddad7d84f7 100644
> --- a/include/uapi/scsi/scsi_bsg_mpi3mr.h
> +++ b/include/uapi/scsi/scsi_bsg_mpi3mr.h
> @@ -10,6 +10,8 @@
>  #ifndef SCSI_BSG_MPI3MR_H_INCLUDED
>  #define SCSI_BSG_MPI3MR_H_INCLUDED
> 
> +#include <linux/types.h>
> +
>  /* Definitions for BSG commands */
>  #define MPI3MR_IOCTL_VERSION                   0x06

It does not, because the uapi headers should only use the __ prefixed
versions of the kernel data types (u8 etc) and need to include
stdint.h in the not __KERNEL__ case for unint8_t etc.

So ... (this needs white space cleanups - you should probably use TAB
characters before the field names.)

diff --git a/include/uapi/scsi/scsi_bsg_mpi3mr.h b/include/uapi/scsi/scsi_bsg_mpi3mr.h
index 6d866256f924..5167d4da478a 100644
--- a/include/uapi/scsi/scsi_bsg_mpi3mr.h
+++ b/include/uapi/scsi/scsi_bsg_mpi3mr.h
@@ -10,6 +10,11 @@
 #ifndef SCSI_BSG_MPI3MR_H_INCLUDED
 #define SCSI_BSG_MPI3MR_H_INCLUDED
 
+#ifndef __KERNEL__
+#include <stdint.h>
+#endif
+#include <linux/types.h>
+
 /* Definitions for BSG commands */
 #define MPI3MR_IOCTL_VERSION			0x06
 
@@ -94,12 +99,12 @@ enum command {
  */
 struct mpi3_driver_info_layout {
 	__le32             information_length;
-	u8                 driver_signature[12];
-	u8                 os_name[16];
-	u8                 os_version[12];
-	u8                 driver_name[20];
-	u8                 driver_version[32];
-	u8                 driver_release_date[20];
+	__u8                 driver_signature[12];
+	__u8                 os_name[16];
+	__u8                 os_version[12];
+	__u8                 driver_name[20];
+	__u8                 driver_version[32];
+	__u8                 driver_release_date[20];
 	__le32             driver_capabilities;
 };
 
@@ -461,11 +466,11 @@ struct mpi3mr_bsg_packet {
 
 struct mpi3_nvme_encapsulated_request {
 	__le16                     host_tag;
-	u8                         ioc_use_only02;
-	u8                         function;
+	__u8                         ioc_use_only02;
+	__u8                         function;
 	__le16                     ioc_use_only04;
-	u8                         ioc_use_only06;
-	u8                         msg_flags;
+	__u8                         ioc_use_only06;
+	__u8                         msg_flags;
 	__le16                     change_count;
 	__le16                     dev_handle;
 	__le16                     encapsulated_command_length;
@@ -477,11 +482,11 @@ struct mpi3_nvme_encapsulated_request {
 
 struct mpi3_nvme_encapsulated_error_reply {
 	__le16                     host_tag;
-	u8                         ioc_use_only02;
-	u8                         function;
+	__u8                         ioc_use_only02;
+	__u8                         function;
 	__le16                     ioc_use_only04;
-	u8                         ioc_use_only06;
-	u8                         msg_flags;
+	__u8                         ioc_use_only06;
+	__u8                         msg_flags;
 	__le16                     ioc_use_only08;
 	__le16                     ioc_status;
 	__le32                     ioc_log_info;
@@ -499,20 +504,20 @@ struct mpi3_nvme_encapsulated_error_reply {
 /* MPI3: task management related definitions */
 struct mpi3_scsi_task_mgmt_request {
 	__le16                     host_tag;
-	u8                         ioc_use_only02;
-	u8                         function;
+	__u8                         ioc_use_only02;
+	__u8                         function;
 	__le16                     ioc_use_only04;
-	u8                         ioc_use_only06;
-	u8                         msg_flags;
+	__u8                         ioc_use_only06;
+	__u8                         msg_flags;
 	__le16                     change_count;
 	__le16                     dev_handle;
 	__le16                     task_host_tag;
-	u8                         task_type;
-	u8                         reserved0f;
+	__u8                         task_type;
+	__u8                         reserved0f;
 	__le16                     task_request_queue_id;
 	__le16                     reserved12;
 	__le32                     reserved14;
-	u8                         lun[8];
+	__u8                         lun[8];
 };
 
 #define MPI3_SCSITASKMGMT_MSGFLAGS_DO_NOT_SEND_TASK_IU      (0x08)
@@ -528,11 +533,11 @@ struct mpi3_scsi_task_mgmt_request {
 #define MPI3_SCSITASKMGMT_TASKTYPE_I_T_NEXUS_RESET          (0x0b)
 struct mpi3_scsi_task_mgmt_reply {
 	__le16                     host_tag;
-	u8                         ioc_use_only02;
-	u8                         function;
+	__u8                         ioc_use_only02;
+	__u8                         function;
 	__le16                     ioc_use_only04;
-	u8                         ioc_use_only06;
-	u8                         msg_flags;
+	__u8                         ioc_use_only06;
+	__u8                         msg_flags;
 	__le16                     ioc_use_only08;
 	__le16                     ioc_status;
 	__le32                     ioc_log_info;

-- 
Cheers,
Stephen Rothwell