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

PCI: designware-ep: Use aligned ATU window for raising MSI interrupts

Certain platforms like K2G reguires the outbound ATU window to be
aligned. The alignment size is already present in mem->page_size.
Use the alignment size present in mem->page_size to configure an
aligned ATU window. In order to raise an interrupt, CPU has to write
to address offset from the start of the window unlike before where
writes were always to the beginning of the ATU window.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

authored by

Kishon Vijay Abraham I and committed by
Lorenzo Pieralisi
6b733030 fc9a7704

+5 -2
+5 -2
drivers/pci/controller/dwc/pcie-designware-ep.c
··· 397 397 { 398 398 struct dw_pcie *pci = to_dw_pcie_from_ep(ep); 399 399 struct pci_epc *epc = ep->epc; 400 + unsigned int aligned_offset; 400 401 u16 msg_ctrl, msg_data; 401 402 u32 msg_addr_lower, msg_addr_upper, reg; 402 403 u64 msg_addr; ··· 423 422 reg = ep->msi_cap + PCI_MSI_DATA_32; 424 423 msg_data = dw_pcie_readw_dbi(pci, reg); 425 424 } 426 - msg_addr = ((u64) msg_addr_upper) << 32 | msg_addr_lower; 425 + aligned_offset = msg_addr_lower & (epc->mem->page_size - 1); 426 + msg_addr = ((u64)msg_addr_upper) << 32 | 427 + (msg_addr_lower & ~aligned_offset); 427 428 ret = dw_pcie_ep_map_addr(epc, func_no, ep->msi_mem_phys, msg_addr, 428 429 epc->mem->page_size); 429 430 if (ret) 430 431 return ret; 431 432 432 - writel(msg_data | (interrupt_num - 1), ep->msi_mem); 433 + writel(msg_data | (interrupt_num - 1), ep->msi_mem + aligned_offset); 433 434 434 435 dw_pcie_ep_unmap_addr(epc, func_no, ep->msi_mem_phys); 435 436