[PATCH 4/4] dma-mapping: clear dev->dma_ops in arch_teardown_dma_ops
From: mpe@ellerman.id.au (Michael Ellerman)
Date: 2018-09-25 05:32:39
Also in:
linux-iommu, linux-pci, linuxppc-dev, lkml
Guenter Roeck [off-list ref] writes:
Hi, On Mon, Aug 27, 2018 at 10:47:11AM +0200, Christoph Hellwig wrote:quoted
There is no reason to leave the per-device dma_ops around when deconfiguring a device, so move this code from arm64 into the common code. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Robin Murphy <robin.murphy@arm.com>This patch causes various ppc images to crash in -next due to NULL DMA ops in dma_alloc_attrs().
I finally remembered where you autobuilder is :) https://kerneltests.org/builders/qemu-ppc-next/builds/970/steps/qemubuildcommand_1/logs/stdio Looks like mac99 at least is failing. Just reproduced it on my setup.
Looking into the code, the macio driver tries to instantiate on the 0000:f0:0d.0 PCI address (the driver maps to all Apple PCI IDs) and fails. This results in a call to arch_teardown_dma_ops(). Later, the same device pointer is used to instantiate ohci-pci, which crashes in probe because the dma_ops pointer has been cleared. I don't claim to fully understand the code, but to me it looks like the pci device is allocated and waiting for a driver to attach to. See arch/powerpc/kernel/pci_of_scan.c:of_create_pci_dev(). If attaching a driver (here: macio) fails, the same device pointer is then reused for the next matching driver until a match is found and the device is successfully instantiated. Of course this fails quite badly if the device pointer has been scrubbed after the first failure. I don't know if this is generic PCI behavior or ppc specific. I am copying pci and ppc maintainers for additional input.
I would guess this is some PPC special sauce O_o Will have a look. cheers