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

ARM: footbridge: remove custom DMA address handling

Footbridge is the last Arm platform that has its own
__virt_to_bus()/__bus_to_virt()/phys_to_dma()/dma_to_phys() abstraction,
but this is just a simple offset now.

For PCI devices, the offset that is programmed into the PCI bridge must
also be set in each device using dma_direct_set_offset(). As Arm does
not have a pcibios_bus_add_device() helper yet, just use a bus notifier
for this.

For the ISA DMA, drivers now pass a non-translated physical address into
set_dma_addr(), so they have to be converted back with the corresponding
isa_bus_to_virt() function and then into the correct bus address with
the offset using the isa_dma_dev.

Tested-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+32 -42
-1
arch/arm/include/asm/dma-direct.h
··· 1 - #include <mach/dma-direct.h>
+1 -1
arch/arm/include/asm/dma.h
··· 106 106 */ 107 107 extern void __set_dma_addr(unsigned int chan, void *addr); 108 108 #define set_dma_addr(chan, addr) \ 109 - __set_dma_addr(chan, (void *)__bus_to_virt(addr)) 109 + __set_dma_addr(chan, (void *)isa_bus_to_virt(addr)) 110 110 111 111 /* Set the DMA byte count for this channel 112 112 *
+7
arch/arm/include/asm/hardware/dec21285.h
··· 22 22 #define DC21285_IO(x) (x) 23 23 #endif 24 24 25 + /* 26 + * The footbridge is programmed to expose the system RAM at 0xe0000000. 27 + * The requirement is that the RAM isn't placed at bus address 0, which 28 + * would clash with VGA cards. 29 + */ 30 + #define BUS_OFFSET 0xe0000000 31 + 25 32 #define CSR_PCICMD DC21285_IO(0x0004) 26 33 #define CSR_CLASSREV DC21285_IO(0x0008) 27 34 #define CSR_PCICACHELINESIZE DC21285_IO(0x000c)
-11
arch/arm/include/asm/memory.h
··· 370 370 #define virt_to_idmap(x) __virt_to_idmap((unsigned long)(x)) 371 371 372 372 /* 373 - * Virtual <-> DMA view memory address translations 374 - * Again, these are *only* valid on the kernel direct mapped RAM 375 - * memory. Use of these is *deprecated* (and that doesn't mean 376 - * use the __ prefixed forms instead.) See dma-mapping.h. 377 - */ 378 - #ifndef __virt_to_bus 379 - #define __virt_to_bus __virt_to_phys 380 - #define __bus_to_virt __phys_to_virt 381 - #endif 382 - 383 - /* 384 373 * Conversion between a struct page and a physical address. 385 374 * 386 375 * page_to_pfn(page) convert a struct page * to a PFN number
-1
arch/arm/mach-footbridge/Kconfig
··· 46 46 # Footbridge support 47 47 config FOOTBRIDGE 48 48 def_bool y 49 - select ARCH_HAS_PHYS_TO_DMA 50 49 select ARCH_MIGHT_HAVE_PC_SERIO 51 50 select ISA_DMA_API 52 51
-10
arch/arm/mach-footbridge/common.c
··· 281 281 *CSR_SA110_CNTL |= (1 << 13); 282 282 } 283 283 } 284 - 285 - dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) 286 - { 287 - return paddr + (BUS_OFFSET - PHYS_OFFSET); 288 - } 289 - 290 - phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr) 291 - { 292 - return dev_addr - (BUS_OFFSET - PHYS_OFFSET); 293 - }
+20 -1
arch/arm/mach-footbridge/dc21285.c
··· 5 5 * Copyright (C) 1998-2001 Russell King 6 6 * Copyright (C) 1998-2000 Phil Blundell 7 7 */ 8 + #include <linux/dma-map-ops.h> 8 9 #include <linux/kernel.h> 9 10 #include <linux/pci.h> 10 11 #include <linux/interrupt.h> ··· 242 241 return IRQ_HANDLED; 243 242 } 244 243 244 + static int dc21285_pci_bus_notifier(struct notifier_block *nb, 245 + unsigned long action, 246 + void *data) 247 + { 248 + if (action != BUS_NOTIFY_ADD_DEVICE) 249 + return NOTIFY_DONE; 250 + 251 + dma_direct_set_offset(data, PHYS_OFFSET, BUS_OFFSET, SZ_256M); 252 + 253 + return NOTIFY_OK; 254 + } 255 + 256 + static struct notifier_block dc21285_pci_bus_nb = { 257 + .notifier_call = dc21285_pci_bus_notifier, 258 + }; 259 + 245 260 int __init dc21285_setup(int nr, struct pci_sys_data *sys) 246 261 { 247 262 struct resource *res; ··· 282 265 283 266 pci_add_resource_offset(&sys->resources, &res[0], sys->mem_offset); 284 267 pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset); 268 + 269 + bus_register_notifier(&pci_bus_type, &dc21285_pci_bus_nb); 285 270 286 271 return 1; 287 272 } ··· 348 329 */ 349 330 *CSR_PCICSRBASE = 0xf4000000; 350 331 *CSR_PCICSRIOBASE = 0; 351 - *CSR_PCISDRAMBASE = __virt_to_bus(PAGE_OFFSET); 332 + *CSR_PCISDRAMBASE = BUS_OFFSET; 352 333 *CSR_PCIROMBASE = 0; 353 334 *CSR_PCICMD = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | 354 335 PCI_COMMAND_INVALIDATE | PCICMD_ERROR_BITS;
+4
arch/arm/mach-footbridge/dma-isa.c
··· 11 11 * arch/arm/kernel/dma-ebsa285.c 12 12 * Copyright (C) 1998 Phil Blundell 13 13 */ 14 + #include <linux/dma-map-ops.h> 14 15 #include <linux/ioport.h> 15 16 #include <linux/init.h> 16 17 #include <linux/dma-mapping.h> ··· 19 18 20 19 #include <asm/dma.h> 21 20 #include <asm/mach/dma.h> 21 + #include <asm/hardware/dec21285.h> 22 22 23 23 #define ISA_DMA_MASK 0 24 24 #define ISA_DMA_MODE 1 ··· 222 220 223 221 request_dma(DMA_ISA_CASCADE, "cascade"); 224 222 } 223 + 224 + dma_direct_set_offset(&isa_dma_dev, PHYS_OFFSET, BUS_OFFSET, SZ_256M); 225 225 226 226 return 0; 227 227 }
-8
arch/arm/mach-footbridge/include/mach/dma-direct.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef MACH_FOOTBRIDGE_DMA_DIRECT_H 3 - #define MACH_FOOTBRIDGE_DMA_DIRECT_H 1 4 - 5 - dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr); 6 - phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr); 7 - 8 - #endif /* MACH_FOOTBRIDGE_DMA_DIRECT_H */
-9
arch/arm/mach-footbridge/include/mach/memory.h
··· 17 17 #define __ASM_ARCH_MEMORY_H 18 18 19 19 /* 20 - * The footbridge is programmed to expose the system RAM at 0xe0000000. 21 - * The requirement is that the RAM isn't placed at bus address 0, which 22 - * would clash with VGA cards. 23 - */ 24 - #define BUS_OFFSET 0xe0000000 25 - #define __virt_to_bus(x) ((x) + (BUS_OFFSET - PAGE_OFFSET)) 26 - #define __bus_to_virt(x) ((x) - (BUS_OFFSET - PAGE_OFFSET)) 27 - 28 - /* 29 20 * Cache flushing area. 30 21 */ 31 22 #define FLUSH_BASE 0xf9000000