BACKPORT: FROMLIST: PCI: dwc: Drop dependency on ZONE_DMA32
Re-work the msi_msg DMA allocation logic to use dmam_alloc_coherent() which uses the coherent DMA mask to try to return an allocation within the DMA mask limits. With that, we now can drop the msi_page parameter in struct dw_pcie_rp. This allows kernel configurations that disable ZONE_DMA32 to continue supporting a 32-bit DMA mask. Without this patch, the PCIe host device will fail to probe when ZONE_DMA32 is disabled. Link: https://lore.kernel.org/all/20220812000327.3154251-2-willmcvicker@google.com/ Bug: 241473543 Fixes: 35797e672ff0 ("PCI: dwc: Fix MSI msi_msg DMA mapping") Reported-by: Isaac J. Manjarres <isaacmanjarres@google.com> Signed-off-by: Will McVicker <willmcvicker@google.com> Reviewed-by: Rob Herring <robh@kernel.org> Acked-by: Jingoo Han <jingoohan1@gmail.com> Change-Id: Ibed6585fea5a20a95b197d8077b7273c485586a0
This commit is contained in:
committed by
Treehugger Robot
parent
cfaccedb79
commit
6c9828727f
@@ -263,15 +263,6 @@ static void dw_pcie_free_msi(struct pcie_port *pp)
|
||||
|
||||
irq_domain_remove(pp->msi_domain);
|
||||
irq_domain_remove(pp->irq_domain);
|
||||
|
||||
if (pp->msi_data) {
|
||||
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
|
||||
struct device *dev = pci->dev;
|
||||
|
||||
dma_unmap_page(dev, pp->msi_data, PAGE_SIZE, DMA_FROM_DEVICE);
|
||||
if (pp->msi_page)
|
||||
__free_page(pp->msi_page);
|
||||
}
|
||||
}
|
||||
|
||||
static void dw_pcie_msi_init(struct pcie_port *pp)
|
||||
@@ -296,6 +287,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
|
||||
struct resource_entry *win;
|
||||
struct pci_host_bridge *bridge;
|
||||
struct resource *cfg_res;
|
||||
u64 *msi_vaddr;
|
||||
int ret;
|
||||
|
||||
raw_spin_lock_init(&pci->pp.lock);
|
||||
@@ -374,18 +366,15 @@ int dw_pcie_host_init(struct pcie_port *pp)
|
||||
dw_chained_msi_isr,
|
||||
pp);
|
||||
|
||||
ret = dma_set_mask(pci->dev, DMA_BIT_MASK(32));
|
||||
ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
|
||||
if (ret)
|
||||
dev_warn(pci->dev, "Failed to set DMA mask to 32-bit. Devices with only 32-bit MSI support may not work properly\n");
|
||||
|
||||
pp->msi_page = alloc_page(GFP_DMA32);
|
||||
pp->msi_data = dma_map_page(pci->dev, pp->msi_page, 0, PAGE_SIZE,
|
||||
DMA_FROM_DEVICE);
|
||||
if (dma_mapping_error(pci->dev, pp->msi_data)) {
|
||||
dev_err(pci->dev, "Failed to map MSI data\n");
|
||||
__free_page(pp->msi_page);
|
||||
pp->msi_page = NULL;
|
||||
pp->msi_data = 0;
|
||||
msi_vaddr = dmam_alloc_coherent(dev, sizeof(u64), &pp->msi_data,
|
||||
GFP_KERNEL);
|
||||
if (!msi_vaddr) {
|
||||
dev_err(dev, "Failed to alloc and map MSI data\n");
|
||||
ret = -ENOMEM;
|
||||
goto err_free_msi;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,6 +191,7 @@ struct pcie_port {
|
||||
struct irq_domain *irq_domain;
|
||||
struct irq_domain *msi_domain;
|
||||
dma_addr_t msi_data;
|
||||
/* msi_page is deprecated. Keeping for ABI compatibility */
|
||||
struct page *msi_page;
|
||||
struct irq_chip *msi_irq_chip;
|
||||
u32 num_vectors;
|
||||
|
||||
Reference in New Issue
Block a user