Skip to content

Commit 92a1d9b

Browse files
committed
Merge branch 'pci/controller/dwc'
- Fall back to allocating 64-bit MSI DMA address if unable to allocate a 32-bit address (Ajay Agarwal) * pci/controller/dwc: PCI: dwc: endpoint: Fix advertised resizable BAR size PCI: dwc: Strengthen the MSI address allocation logic
2 parents 538ca00 + 72e34b8 commit 92a1d9b

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

drivers/pci/controller/dwc/pcie-designware-ep.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,13 @@ int dw_pcie_ep_init_complete(struct dw_pcie_ep *ep)
627627
nbars = (reg & PCI_REBAR_CTRL_NBAR_MASK) >>
628628
PCI_REBAR_CTRL_NBAR_SHIFT;
629629

630+
/*
631+
* PCIe r6.0, sec 7.8.6.2 require us to support at least one
632+
* size in the range from 1 MB to 512 GB. Advertise support
633+
* for 1 MB BAR size only.
634+
*/
630635
for (i = 0; i < nbars; i++, offset += PCI_REBAR_CTRL)
631-
dw_pcie_writel_dbi(pci, offset + PCI_REBAR_CAP, 0x0);
636+
dw_pcie_writel_dbi(pci, offset + PCI_REBAR_CAP, BIT(4));
632637
}
633638

634639
/*

drivers/pci/controller/dwc/pcie-designware-host.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ static int dw_pcie_msi_host_init(struct dw_pcie_rp *pp)
328328
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
329329
struct device *dev = pci->dev;
330330
struct platform_device *pdev = to_platform_device(dev);
331-
u64 *msi_vaddr;
331+
u64 *msi_vaddr = NULL;
332332
int ret;
333333
u32 ctrl, num_ctrls;
334334

@@ -379,15 +379,20 @@ static int dw_pcie_msi_host_init(struct dw_pcie_rp *pp)
379379
* memory.
380380
*/
381381
ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
382-
if (ret)
383-
dev_warn(dev, "Failed to set DMA mask to 32-bit. Devices with only 32-bit MSI support may not work properly\n");
382+
if (!ret)
383+
msi_vaddr = dmam_alloc_coherent(dev, sizeof(u64), &pp->msi_data,
384+
GFP_KERNEL);
384385

385-
msi_vaddr = dmam_alloc_coherent(dev, sizeof(u64), &pp->msi_data,
386-
GFP_KERNEL);
387386
if (!msi_vaddr) {
388-
dev_err(dev, "Failed to alloc and map MSI data\n");
389-
dw_pcie_free_msi(pp);
390-
return -ENOMEM;
387+
dev_warn(dev, "Failed to allocate 32-bit MSI address\n");
388+
dma_set_coherent_mask(dev, DMA_BIT_MASK(64));
389+
msi_vaddr = dmam_alloc_coherent(dev, sizeof(u64), &pp->msi_data,
390+
GFP_KERNEL);
391+
if (!msi_vaddr) {
392+
dev_err(dev, "Failed to allocate MSI address\n");
393+
dw_pcie_free_msi(pp);
394+
return -ENOMEM;
395+
}
391396
}
392397

393398
return 0;

0 commit comments

Comments
 (0)