Microsemi / switchtec-kernel

A kernel module for the Microsemi PCIe switch
GNU General Public License v2.0
45 stars 31 forks source link

Fixed misaligned MMIO data member for ARM64 support #85

Closed PaulSelles closed 4 years ago

PaulSelles commented 4 years ago

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 paul.selles@microchip.com

dmeyergio commented 4 years ago

When this gets upstreamed, quirk_switchtec_ntb_dma_alias() will be impacted. Currently, that quirk does break up ep_map into low/high ioread32s.

partition_map = (u64) ioread32((void * __iomem) &mmio_ntb->ep_map);
partition_map |= ((u64) ioread32((void * __iomem) &mmio_ntb->ep_map + 4)) << 32;

But the name change proposed here will obviously mean the quirk'll have to change.

lsgunth commented 4 years ago

Good point, Doug, thanks for pointing that out.