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

Configure Feed

Select the types of activity you want to include in your feed.

scsi: 3w-9xxx: Reduce scope of structure packing

Currently, all command packet structs used by this driver are packed.
However, only one (TW_SG_Entry) actually needs to be packed, because it
uses 64-bit addresses at 32-bit alignment. To improve the quality of
generated code, stop packing all of the other command packet structs. This
requires adjusting the type of one misaligned "reserved" member.

After this change, pahole reports that only one type had its layout change:
the tw_compat_info member of TW_Device_Extension is now naturally aligned.

Link: https://lore.kernel.org/r/20210427235915.39211-3-samuel@sholland.org
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Samuel Holland and committed by
Martin K. Petersen
d133b441 44c5027b

+10 -8
+10 -8
drivers/scsi/3w-9xxx.h
··· 485 485 #define TW_PADDING_LENGTH (sizeof(dma_addr_t) > 4 ? 8 : 0) 486 486 #define TW_CPU_TO_SGL(x) (sizeof(dma_addr_t) > 4 ? cpu_to_le64(x) : cpu_to_le32(x)) 487 487 488 - #pragma pack(1) 488 + #if IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) 489 + typedef u64 twa_addr_t; 490 + #else 491 + typedef u32 twa_addr_t; 492 + #endif 489 493 490 494 /* Scatter Gather List Entry */ 491 495 typedef struct TAG_TW_SG_Entry { 492 - dma_addr_t address; 496 + twa_addr_t address; 493 497 u32 length; 494 - } TW_SG_Entry; 498 + } __packed TW_SG_Entry; 495 499 496 500 /* Command Packet */ 497 501 typedef struct TW_Command { ··· 514 510 struct { 515 511 u32 lba; 516 512 TW_SG_Entry sgl[TW_ESCALADE_MAX_SGL_LENGTH]; 517 - dma_addr_t padding; 513 + twa_addr_t padding; 518 514 } io; 519 515 struct { 520 516 TW_SG_Entry sgl[TW_ESCALADE_MAX_SGL_LENGTH]; 521 517 u32 padding; 522 - dma_addr_t padding2; 518 + twa_addr_t padding2; 523 519 } param; 524 520 } byte8_offset; 525 521 } TW_Command; ··· 549 545 unsigned char err_specific_desc[98]; 550 546 struct { 551 547 unsigned char size_header; 552 - unsigned short reserved; 548 + unsigned char reserved[2]; 553 549 unsigned char size_sense; 554 550 } header_desc; 555 551 } TW_Command_Apache_Header; ··· 648 644 unsigned short fw_on_ctlr_branch; 649 645 unsigned short fw_on_ctlr_build; 650 646 } TW_Compatibility_Info; 651 - 652 - #pragma pack() 653 647 654 648 typedef struct TAG_TW_Device_Extension { 655 649 u32 __iomem *base_addr;