Hello, > In dw_pcie_ep_init() we allocate memory from the EPC address space that we > will later use to raise a MSI/MSI-X IRQ. This memory is only freed in > dw_pcie_ep_deinit(). > > Performing this allocation in dw_pcie_ep_init() is to ensure that we will > not fail to allocate memory from the EPC address space when trying to raise > a MSI/MSI-X IRQ. > > We still map/unmap this memory every time we raise an IRQ, in order to not > constantly occupy an iATU, especially for controllers with few iATUs. > (So we can still fail to raise an MSI/MSI-X IRQ if all iATUs are occupied.) > > When allocating this memory in dw_pcie_ep_init(), we allocate > epc->mem->window.page_size memory, which is the smallest unit that we can > allocate from the EPC address space. > > However, when writing/sending the msg data, which is only 2 bytes for MSI, > 4 bytes for MSI-X, in either case a single writel() is sufficient. Thus, > the size that we need to map is a single PCI DWORD (4 bytes). > > This is the size that we should send in to the pci_epc_ops::align_addr() > API. It is align_addr()'s responsibility to return a size that is aligned > to the EPC page size, for platforms that need a special alignment. > > Modify the align_addr() call to send in the proper size that we need to > map. > > Before this patch on a system with a EPC page size 64k, we would > incorrectly map 128k (which is larger than our allocation) instead of 64k. > > After this patch, we will correctly map 64k (a single page). (We should > never need to map more than a page to write a single DWORD.) [...] > Feel free to squash this with the patch that it fixes, if you so prefer. Squashed with the rest of the pending changes, per: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/commit/?h=endpoint&id=d2d9f84914e147d6ee399e0ed8d938fea7f0c35c Let me know if anything needs to be updated there. Thank you! Krzysztof