PCI: dwc: Don't warn when the 32-bit MSI address allocation fails
PATCH 1/1 PCI: dwc: Don't warn when the 32-bit MSI address allocation fails
Since commit f3a296405b6e ("PCI: dwc: Strengthen the MSI address allocation logic"), dw_pcie_msi_host_init() first tries to allocate the iMSI-RX target address below 4 GiB, and falls back to a 64-bit address if that fails. The fallback exists for platforms that have no 32-bit DMA addresses, so on those platforms the first allocation is expected to fail. The cfg0_base shortcut taken before it does not apply when the "config" window itself is above 4 GiB, as it is on the K3.
The page allocator cannot know that, and reports the failure with a full warn_alloc() splat on every boot. On a SpacemiT K3, whose RAM starts at 4 GiB, with gigabytes free:
page allocation failure: order:0, mode:0xcc4(GFP_KERNEL|GFP_DMA32), [...]
Call Trace: [...] warn_alloc+0xea/0x100 __alloc_pages_slowpath.constprop.0+0x8bc/0xf4a [...] dmam_alloc_attrs+0x50/0x98 dw_pcie_msi_host_init+0xe0/0x26a dw_pcie_host_init+0x2fa/0x45e [...] Mem-Info: [...] free:1442450 free_pcp:0 free_cma:0 [...] Failed to allocate 32-bit MSI address
Pass __GFP_NOWARN to the 32-bit attempt; dmam_alloc_coherent() turns it into DMA_ATTR_NO_WARN for the DMA layer as well. The driver's own dev_warn() still reports that the 32-bit allocation failed, which is what matters: endpoints that only support 32-bit MSI addresses will not get MSIs. A failure of the 64-bit attempt is still reported as before.
The K3's PCIe controller is not supported in mainline yet; this was seen with an out-of-tree glue driver that calls dw_pcie_host_init(). The path is generic, though: any DWC host whose "config" window is above 4 GiB and which has no memory below 4 GiB takes it.
The problem was diagnosed, and this change and changelog drafted, with an AI coding assistant (Claude, Anthropic). Tested on a SpacemiT K3
Pico-ITX: the warn_alloc() splat is gone, the dev_warn() remains, and the port's devices get their MSIs from the 64-bit target address.
--- drivers/pci/controller/dwc/pcie-designware-host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-designware-host.c +1 -1
@@ -375,7 +375,7 @@ int dw_pcie_msi_host_init(struct dw_pcie_rp *pp) ret =dma_set_coherent_mask (dev,DMA_BIT_MASK (32 ));if (!ret) msi_vaddr =dmam_alloc_coherent (dev,sizeof (u64), &pp->msi_data, -GFP_KERNEL ); +GFP_KERNEL | __GFP_NOWARN);if (!msi_vaddr) {dev_warn (dev,"Failed to allocate 32-bit MSI address\n" );
Signature · 1 line
2.55.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 13 lines
Since commit
f3a296405b6e("PCI: dwc: Strengthen the MSI address allocation logic"),dw_pcie_msi_host_init()first tries to allocate the iMSI-RX target address below 4 GiB, and falls back to a 64-bit address if that fails. The fallback exists for platforms that have no 32-bit DMA addresses, so on those platforms the first allocation is expected to fail. Thecfg0_baseshortcut taken before it does not apply when the "config" window itself is above 4 GiB, as it is on the K3.The page allocator cannot know that, and reports the failure with a full
warn_alloc()splat on every boot. On a SpacemiT K3, whose RAM starts at 4 GiB, with gigabytes free:page allocation failure: order:0, mode:0xcc4(GFP_KERNEL|GFP_DMA32), [...]
Quoted 8 lines
Call Trace: [...][ ... ]
Pico-ITX: thewarn_alloc()splat is gone, thedev_warn()remains, and the port's devices get their MSIs from the 64-bit target address.Fixes f3a296405b6e ("PCI: dwc: Strengthen the MSI address allocation logic")Signed-off-by Yuri Zaporozhets <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1