Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sh/PCI: Pass GAPSPCI_DMA_BASE CPU & bus address to dma_declare_coherent_memory()

dma_declare_coherent_memory() needs both the CPU physical address and the
bus address of the device memory. They are the same on this platform, but
in general we should use pcibios_resource_to_bus() to account for any
address translation done by the PCI host bridge.

This makes no difference on Dreamcast, but is safer if the usage is copied
to future drivers.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
CC: Magnus Damm <damm@opensource.se>
CC: linux-sh@vger.kernel.org

+15 -3
+15 -3
arch/sh/drivers/pci/fixups-dreamcast.c
··· 31 31 static void gapspci_fixup_resources(struct pci_dev *dev) 32 32 { 33 33 struct pci_channel *p = dev->sysdata; 34 + struct resource res; 35 + struct pci_bus_region region; 34 36 35 37 printk(KERN_NOTICE "PCI: Fixing up device %s\n", pci_name(dev)); 36 38 ··· 52 50 53 51 /* 54 52 * Redirect dma memory allocations to special memory window. 53 + * 54 + * If this GAPSPCI region were mapped by a BAR, the CPU 55 + * phys_addr_t would be pci_resource_start(), and the bus 56 + * address would be pci_bus_address(pci_resource_start()). 57 + * But apparently there's no BAR mapping it, so we just 58 + * "know" its CPU address is GAPSPCI_DMA_BASE. 55 59 */ 60 + res.start = GAPSPCI_DMA_BASE; 61 + res.end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1; 62 + res.flags = IORESOURCE_MEM; 63 + pcibios_resource_to_bus(dev->bus, &region, &res); 56 64 BUG_ON(!dma_declare_coherent_memory(&dev->dev, 57 - GAPSPCI_DMA_BASE, 58 - GAPSPCI_DMA_BASE, 59 - GAPSPCI_DMA_SIZE, 65 + res.start, 66 + region.start, 67 + resource_size(&res), 60 68 DMA_MEMORY_MAP | 61 69 DMA_MEMORY_EXCLUSIVE)); 62 70 break;