Skip to content

Commit 1fb4444

Browse files
author
Paul Selles
committed
Fixed misaligned MMIO data member for ARM64 support
The switchtec drivers uses packed structs for MMIO addressing to the PCIe switch BARs. Within the packed struct ntb_info_regs the u64 member ep_map was found to be misaligned. The misalignment was discovered on an ARM64 processor through a kernel panic traced to a Load Register operation when addressing the misaligned member. The misaligned member is currently only being used by the ntb_hw_switchtec driver. Dividing the misaligned u64 member into two u32 members resolves the misalignment. Minor bitwise operations in ntb_hw_switchtec driver were added to recover u64 value. Adding this fix will allow the ntb_hw_switchtec driver to support the ARM64 architecture. Signed-off-by: Paul Selles <[email protected]>
1 parent dbd4558 commit 1fb4444

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

linux/switchtec.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ struct ntb_info_regs {
301301
u8 partition_count;
302302
u8 partition_id;
303303
u16 reserved1;
304-
u64 ep_map;
304+
u32 ep_map_low;
305+
u32 ep_map_high;
305306
u16 requester_id;
306307
u16 reserved2;
307308
u32 reserved3[4];

ntb_hw_switchtec.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,9 @@ static int switchtec_ntb_init_sndev(struct switchtec_ntb *sndev)
904904
tpart_vec <<= 32;
905905
tpart_vec |= ioread32(&sndev->mmio_ntb->ntp_info[self].target_part_low);
906906

907-
part_map = ioread64(&sndev->mmio_ntb->ep_map);
907+
part_map = ioread32(&sndev->mmio_ntb->ep_map_high);
908+
part_map <<= 32;
909+
part_map |= ioread32(&sndev->mmio_ntb->ep_map_low);
908910
tpart_vec &= part_map;
909911
part_map &= ~(1 << sndev->self_partition);
910912

0 commit comments

Comments
 (0)