linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: pmcraid: fix 'ioarcb' alignment warning
@ 2021-02-04 16:30 Arnd Bergmann
  2021-02-09  2:23 ` Martin K. Petersen
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2021-02-04 16:30 UTC (permalink / raw)
  To: James E.J. Bottomley, Martin K. Petersen
  Cc: Arnd Bergmann, Lee Jones, Gustavo A. R. Silva, Satish Kharat,
	Lee Duncan, linux-scsi, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

Building with 'make W=1' enables -Wpacked-not-aligned, and this
warns about pmcraid because of incompatible alignment constraints for
pmcraid_passthrough_ioctl_buffer:

drivers/scsi/pmcraid.h:1044:1: warning: alignment 1 of 'struct pmcraid_passthrough_ioctl_buffer' is less than 32 [-Wpacked-not-aligned]
 1044 | } __attribute__ ((packed));
      | ^
drivers/scsi/pmcraid.h:1041:24: warning: 'ioarcb' offset 16 in 'struct pmcraid_passthrough_ioctl_buffer' isn't aligned to 32 [-Wpacked-not-aligned]
 1041 |  struct pmcraid_ioarcb ioarcb;

The inner structure is documented as having 32 byte alignment here,
but is starts at a 16 byte offset in the outer structure, so it's never
actually aligned, as the outer structure is also marked 'packed'.

Lee Jones point this out as one of the last files that need to be changed
before the warning can be enabled by default.

Change the annotations in a way that avoids the warning but leaves the
layout unchanged, by removing the packing on the inner structure and
adding it to the outer one. The one-byte request_buffer[] array should
have been a flexible array member here, which is how I change it to
avoid extra padding from the alignment attribute.

Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/scsi/pmcraid.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
index 15c962108075..6d36debde18e 100644
--- a/drivers/scsi/pmcraid.h
+++ b/drivers/scsi/pmcraid.h
@@ -244,7 +244,7 @@ struct pmcraid_ioarcb {
 	__u8  hrrq_id;
 	__u8  cdb[PMCRAID_MAX_CDB_LEN];
 	struct pmcraid_ioarcb_add_data add_data;
-} __attribute__((packed, aligned(PMCRAID_IOARCB_ALIGNMENT)));
+};
 
 /* well known resource handle values */
 #define PMCRAID_IOA_RES_HANDLE        0xffffffff
@@ -1040,8 +1040,8 @@ struct pmcraid_passthrough_ioctl_buffer {
 	struct pmcraid_ioctl_header ioctl_header;
 	struct pmcraid_ioarcb ioarcb;
 	struct pmcraid_ioasa  ioasa;
-	u8  request_buffer[1];
-} __attribute__ ((packed));
+	u8  request_buffer[];
+} __attribute__ ((packed, aligned(PMCRAID_IOARCB_ALIGNMENT)));
 
 /*
  * keys to differentiate between driver handled IOCTLs and passthrough
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: pmcraid: fix 'ioarcb' alignment warning
  2021-02-04 16:30 [PATCH] scsi: pmcraid: fix 'ioarcb' alignment warning Arnd Bergmann
@ 2021-02-09  2:23 ` Martin K. Petersen
  0 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2021-02-09  2:23 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: James E.J. Bottomley, Martin K. Petersen, Arnd Bergmann,
	Lee Jones, Gustavo A. R. Silva, Satish Kharat, Lee Duncan,
	linux-scsi, linux-kernel


Arnd,

> Building with 'make W=1' enables -Wpacked-not-aligned, and this warns
> about pmcraid because of incompatible alignment constraints for
> pmcraid_passthrough_ioctl_buffer:

Applied to 5.12/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: pmcraid: fix 'ioarcb' alignment warning
  2021-02-01 16:59 Arnd Bergmann
@ 2021-02-02  8:17 ` Lee Jones
  0 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2021-02-02  8:17 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: James E.J. Bottomley, Martin K. Petersen, Arnd Bergmann,
	Gustavo A. R. Silva, Satish Kharat, Lee Duncan, linux-scsi,
	linux-kernel

On Mon, 01 Feb 2021, Arnd Bergmann wrote:

> From: Arnd Bergmann <arnd@arndb.de>
> 
> Building with 'make W=1' enables -Wpacked-not-aligned, and this
> warns about pmcraid because of incompatible alignment constraints for
> pmcraid_passthrough_ioctl_buffer:
> 
> drivers/scsi/pmcraid.h:1044:1: warning: alignment 1 of 'struct pmcraid_passthrough_ioctl_buffer' is less than 32 [-Wpacked-not-aligned]
>  1044 | } __attribute__ ((packed));
>       | ^
> drivers/scsi/pmcraid.h:1041:24: warning: 'ioarcb' offset 16 in 'struct pmcraid_passthrough_ioctl_buffer' isn't aligned to 32 [-Wpacked-not-aligned]
>  1041 |  struct pmcraid_ioarcb ioarcb;
> 
> The inner structure is documented as having 32 byte alignment here,
> but is starts at a 16 byte offset in the outer structure, so it's never
> actually aligned, as the outer structure is also marked 'packed'.
> 
> Lee Jones point this out as one of the last files that need to be changed
> before the warning can be enabled by default.
> 
> Change the annotations in a way that avoids the warning but leaves the
> layout unchanged, by removing the packing on the inner structure and
> adding it to the outer one. The one-byte request_buffer[] array should
> have been a flexible array member here, which is how I change it to
> avoid extra padding from the alignment attribute.

Looks good to me.

Reviewed-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] scsi: pmcraid: fix 'ioarcb' alignment warning
@ 2021-02-01 16:59 Arnd Bergmann
  2021-02-02  8:17 ` Lee Jones
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2021-02-01 16:59 UTC (permalink / raw)
  To: James E.J. Bottomley, Martin K. Petersen
  Cc: Arnd Bergmann, Lee Jones, Gustavo A. R. Silva, Satish Kharat,
	Lee Duncan, linux-scsi, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

Building with 'make W=1' enables -Wpacked-not-aligned, and this
warns about pmcraid because of incompatible alignment constraints for
pmcraid_passthrough_ioctl_buffer:

drivers/scsi/pmcraid.h:1044:1: warning: alignment 1 of 'struct pmcraid_passthrough_ioctl_buffer' is less than 32 [-Wpacked-not-aligned]
 1044 | } __attribute__ ((packed));
      | ^
drivers/scsi/pmcraid.h:1041:24: warning: 'ioarcb' offset 16 in 'struct pmcraid_passthrough_ioctl_buffer' isn't aligned to 32 [-Wpacked-not-aligned]
 1041 |  struct pmcraid_ioarcb ioarcb;

The inner structure is documented as having 32 byte alignment here,
but is starts at a 16 byte offset in the outer structure, so it's never
actually aligned, as the outer structure is also marked 'packed'.

Lee Jones point this out as one of the last files that need to be changed
before the warning can be enabled by default.

Change the annotations in a way that avoids the warning but leaves the
layout unchanged, by removing the packing on the inner structure and
adding it to the outer one. The one-byte request_buffer[] array should
have been a flexible array member here, which is how I change it to
avoid extra padding from the alignment attribute.

Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/scsi/pmcraid.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
index 15c962108075..6d36debde18e 100644
--- a/drivers/scsi/pmcraid.h
+++ b/drivers/scsi/pmcraid.h
@@ -244,7 +244,7 @@ struct pmcraid_ioarcb {
 	__u8  hrrq_id;
 	__u8  cdb[PMCRAID_MAX_CDB_LEN];
 	struct pmcraid_ioarcb_add_data add_data;
-} __attribute__((packed, aligned(PMCRAID_IOARCB_ALIGNMENT)));
+};
 
 /* well known resource handle values */
 #define PMCRAID_IOA_RES_HANDLE        0xffffffff
@@ -1040,8 +1040,8 @@ struct pmcraid_passthrough_ioctl_buffer {
 	struct pmcraid_ioctl_header ioctl_header;
 	struct pmcraid_ioarcb ioarcb;
 	struct pmcraid_ioasa  ioasa;
-	u8  request_buffer[1];
-} __attribute__ ((packed));
+	u8  request_buffer[];
+} __attribute__ ((packed, aligned(PMCRAID_IOARCB_ALIGNMENT)));
 
 /*
  * keys to differentiate between driver handled IOCTLs and passthrough
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-02-09  2:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-04 16:30 [PATCH] scsi: pmcraid: fix 'ioarcb' alignment warning Arnd Bergmann
2021-02-09  2:23 ` Martin K. Petersen
  -- strict thread matches above, loose matches on Subject: below --
2021-02-01 16:59 Arnd Bergmann
2021-02-02  8:17 ` Lee Jones

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).