Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

3w-xxxx: fix mis-aligned struct accesses

Building an allmodconfig ARM kernel, I get multiple such
warnings because of a spinlock contained in packed structure
in the 3w-xxxx driver:

../drivers/scsi/3w-xxxx.c: In function 'tw_chrdev_ioctl':
../drivers/scsi/3w-xxxx.c:1001:68: warning: mis-aligned access used for structure member [-fstrict-volatile-bitfields]
timeout = wait_event_timeout(tw_dev->ioctl_wqueue, tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout);
^
../drivers/scsi/3w-xxxx.c:1001:68: note: when a volatile object spans multiple type-sized locations, the compiler must choose between using a single mis-aligned access to preserve the volatility, or using multiple aligned accesses to avoid runtime faults; this code may fail at runtime if the hardware does not allow this access

The same bug apparently was present in 3w-sas and 3w-9xxx, but has been
fixed in the past. This patch uses the same fix by moving the pragma
in front of the TW_Device_Extension definition, so it only covers
hardware structures.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Adam Radford <aradford@gmail.com>
Cc: Adam Radford <linuxraid@lsi.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>

authored by

Arnd Bergmann and committed by
Christoph Hellwig
4bfaa5c4 6919a366

+2 -2
+2 -2
drivers/scsi/3w-xxxx.h
··· 392 392 unsigned char padding[12]; 393 393 } TW_Passthru; 394 394 395 + #pragma pack() 396 + 395 397 typedef struct TAG_TW_Device_Extension { 396 398 u32 base_addr; 397 399 unsigned long *alignment_virtual_address[TW_Q_LENGTH]; ··· 431 429 volatile int chrdev_request_id; 432 430 wait_queue_head_t ioctl_wqueue; 433 431 } TW_Device_Extension; 434 - 435 - #pragma pack() 436 432 437 433 #endif /* _3W_XXXX_H */