aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Trofimovich <[email protected]>2021-03-30 08:19:58 +0100
committerMartin K. Petersen <[email protected]>2021-04-01 22:52:40 -0400
commite01a00ff62adca8ec464f3c8d82cfa0e8d8728dd (patch)
tree0e6cbb0edec5450098f8b7b84a6b2c736dc9ed01
parent02ec144292bc424a5800d45d4cb472c66e97c520 (diff)
scsi: hpsa: Add an assert to prevent __packed reintroduction
Link: https://lore.kernel.org/r/[email protected] Fixes: f749d8b7a989 ("scsi: hpsa: Correct dev cmds outstanding for retried cmds") CC: [email protected] CC: [email protected] CC: [email protected] CC: Joe Szczypek <[email protected]> CC: Scott Benesh <[email protected]> CC: Scott Teel <[email protected]> CC: Tomas Henzl <[email protected]> CC: "Martin K. Petersen" <[email protected]> CC: Don Brace <[email protected]> Reported-by: John Paul Adrian Glaubitz <[email protected]> Suggested-by: Don Brace <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Signed-off-by: Sergei Trofimovich <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
-rw-r--r--drivers/scsi/hpsa_cmd.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
index 885b1f1fb20a..ba6a3aa8d954 100644
--- a/drivers/scsi/hpsa_cmd.h
+++ b/drivers/scsi/hpsa_cmd.h
@@ -22,6 +22,9 @@
#include <linux/compiler.h>
+#include <linux/build_bug.h> /* static_assert */
+#include <linux/stddef.h> /* offsetof */
+
/* general boundary defintions */
#define SENSEINFOBYTES 32 /* may vary between hbas */
#define SG_ENTRIES_IN_CMD 32 /* Max SG entries excluding chain blocks */
@@ -454,6 +457,15 @@ struct CommandList {
atomic_t refcount; /* Must be last to avoid memset in hpsa_cmd_init() */
} __aligned(COMMANDLIST_ALIGNMENT);
+/*
+ * Make sure our embedded atomic variable is aligned. Otherwise we break atomic
+ * operations on architectures that don't support unaligned atomics like IA64.
+ *
+ * The assert guards against reintroductin against unwanted __packed to
+ * the struct CommandList.
+ */
+static_assert(offsetof(struct CommandList, refcount) % __alignof__(atomic_t) == 0);
+
/* Max S/G elements in I/O accelerator command */
#define IOACCEL1_MAXSGENTRIES 24
#define IOACCEL2_MAXSGENTRIES 28