Skip to content

Commit 93cd1bb

Browse files
Marc ZyngierLorenzo Pieralisi
authored andcommitted
PCI: rcar: Don't allocate extra memory for the MSI capture address
A long cargo-culted behaviour of PCI drivers is to allocate memory to obtain an address that is fed to the controller as the MSI capture address (i.e. the MSI doorbell). But there is no actual requirement for this address to be RAM. All it needs to be is a suitable aligned address that will *not* be DMA'd to. Since the rcar platform already has a requirement that this address should be in the first 4GB of the physical address space, use the controller's own base address as the capture address. Link: https://lore.kernel.org/r/20210330151145.997953-3-maz@kernel.org Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
1 parent 2c99e55 commit 93cd1bb

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

drivers/pci/controller/pcie-rcar-host.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ struct rcar_msi {
3636
DECLARE_BITMAP(used, INT_PCI_MSI_NR);
3737
struct irq_domain *domain;
3838
struct msi_controller chip;
39-
unsigned long pages;
4039
struct mutex lock;
4140
int irq1;
4241
int irq2;
@@ -680,14 +679,15 @@ static void rcar_pcie_unmap_msi(struct rcar_pcie_host *host)
680679
static void rcar_pcie_hw_enable_msi(struct rcar_pcie_host *host)
681680
{
682681
struct rcar_pcie *pcie = &host->pcie;
683-
struct rcar_msi *msi = &host->msi;
684-
unsigned long base;
682+
struct device *dev = pcie->dev;
683+
struct resource res;
685684

686-
/* setup MSI data target */
687-
base = virt_to_phys((void *)msi->pages);
685+
if (WARN_ON(of_address_to_resource(dev->of_node, 0, &res)))
686+
return;
688687

689-
rcar_pci_write_reg(pcie, lower_32_bits(base) | MSIFE, PCIEMSIALR);
690-
rcar_pci_write_reg(pcie, upper_32_bits(base), PCIEMSIAUR);
688+
/* setup MSI data target */
689+
rcar_pci_write_reg(pcie, lower_32_bits(res.start) | MSIFE, PCIEMSIALR);
690+
rcar_pci_write_reg(pcie, upper_32_bits(res.start), PCIEMSIAUR);
691691

692692
/* enable all MSI interrupts */
693693
rcar_pci_write_reg(pcie, 0xffffffff, PCIEMSIIER);
@@ -735,7 +735,6 @@ static int rcar_pcie_enable_msi(struct rcar_pcie_host *host)
735735
}
736736

737737
/* setup MSI data target */
738-
msi->pages = __get_free_pages(GFP_KERNEL | GFP_DMA32, 0);
739738
rcar_pcie_hw_enable_msi(host);
740739

741740
return 0;
@@ -748,16 +747,13 @@ static int rcar_pcie_enable_msi(struct rcar_pcie_host *host)
748747
static void rcar_pcie_teardown_msi(struct rcar_pcie_host *host)
749748
{
750749
struct rcar_pcie *pcie = &host->pcie;
751-
struct rcar_msi *msi = &host->msi;
752750

753751
/* Disable all MSI interrupts */
754752
rcar_pci_write_reg(pcie, 0, PCIEMSIIER);
755753

756754
/* Disable address decoding of the MSI interrupt, MSIFE */
757755
rcar_pci_write_reg(pcie, 0, PCIEMSIALR);
758756

759-
free_pages(msi->pages, 0);
760-
761757
rcar_pcie_unmap_msi(host);
762758
}
763759

0 commit comments

Comments
 (0)