aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/dma-swiotlb.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-09-15 12:51:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-15 12:51:09 -0400
commit723e9db7a46e328527cc3da2b478b831184fe828 (patch)
treecdeda255633057dcb4c84097bed27b2bbf76970f /arch/powerpc/kernel/dma-swiotlb.c
parentada3fa15057205b7d3f727bba5cd26b5912e350f (diff)
parentd331d8305cba713605854aab63a000fb892353a7 (diff)
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc: (134 commits) powerpc/nvram: Enable use Generic NVRAM driver for different size chips powerpc/iseries: Fix oops reading from /proc/iSeries/mf/*/cmdline powerpc/ps3: Workaround for flash memory I/O error powerpc/booke: Don't set DABR on 64-bit BookE, use DAC1 instead powerpc/perf_counters: Reduce stack usage of power_check_constraints powerpc: Fix bug where perf_counters breaks oprofile powerpc/85xx: Fix SMP compile error and allow NULL for smp_ops powerpc/irq: Improve nanodoc powerpc: Fix some late PowerMac G5 with PCIe ATI graphics powerpc/fsl-booke: Use HW PTE format if CONFIG_PTE_64BIT powerpc/book3e: Add missing page sizes powerpc/pseries: Fix to handle slb resize across migration powerpc/powermac: Thermal control turns system off too eagerly powerpc/pci: Merge ppc32 and ppc64 versions of phb_scan() powerpc/405ex: support cuImage via included dtb powerpc/405ex: provide necessary fixup function to support cuImage powerpc/40x: Add support for the ESTeem 195E (PPC405EP) SBC powerpc/44x: Add Eiger AMCC (AppliedMicro) PPC460SX evaluation board support. powerpc/44x: Update Arches defconfig powerpc/44x: Update Arches dts ... Fix up conflicts in drivers/char/agp/uninorth-agp.c
Diffstat (limited to 'arch/powerpc/kernel/dma-swiotlb.c')
-rw-r--r--arch/powerpc/kernel/dma-swiotlb.c53
1 files changed, 17 insertions, 36 deletions
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index e8a57de85bcf..e96cbbd9b449 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -25,33 +25,13 @@ int swiotlb __read_mostly;
25unsigned int ppc_swiotlb_enable; 25unsigned int ppc_swiotlb_enable;
26 26
27/* 27/*
28 * Determine if an address is reachable by a pci device, or if we must bounce.
29 */
30static int
31swiotlb_pci_addr_needs_map(struct device *hwdev, dma_addr_t addr, size_t size)
32{
33 dma_addr_t max;
34 struct pci_controller *hose;
35 struct pci_dev *pdev = to_pci_dev(hwdev);
36
37 hose = pci_bus_to_host(pdev->bus);
38 max = hose->dma_window_base_cur + hose->dma_window_size;
39
40 /* check that we're within mapped pci window space */
41 if ((addr + size > max) | (addr < hose->dma_window_base_cur))
42 return 1;
43
44 return 0;
45}
46
47/*
48 * At the moment, all platforms that use this code only require 28 * At the moment, all platforms that use this code only require
49 * swiotlb to be used if we're operating on HIGHMEM. Since 29 * swiotlb to be used if we're operating on HIGHMEM. Since
50 * we don't ever call anything other than map_sg, unmap_sg, 30 * we don't ever call anything other than map_sg, unmap_sg,
51 * map_page, and unmap_page on highmem, use normal dma_ops 31 * map_page, and unmap_page on highmem, use normal dma_ops
52 * for everything else. 32 * for everything else.
53 */ 33 */
54struct dma_mapping_ops swiotlb_dma_ops = { 34struct dma_map_ops swiotlb_dma_ops = {
55 .alloc_coherent = dma_direct_alloc_coherent, 35 .alloc_coherent = dma_direct_alloc_coherent,
56 .free_coherent = dma_direct_free_coherent, 36 .free_coherent = dma_direct_free_coherent,
57 .map_sg = swiotlb_map_sg_attrs, 37 .map_sg = swiotlb_map_sg_attrs,
@@ -62,33 +42,34 @@ struct dma_mapping_ops swiotlb_dma_ops = {
62 .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu, 42 .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
63 .sync_single_range_for_device = swiotlb_sync_single_range_for_device, 43 .sync_single_range_for_device = swiotlb_sync_single_range_for_device,
64 .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, 44 .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
65 .sync_sg_for_device = swiotlb_sync_sg_for_device 45 .sync_sg_for_device = swiotlb_sync_sg_for_device,
46 .mapping_error = swiotlb_dma_mapping_error,
66}; 47};
67 48
68struct dma_mapping_ops swiotlb_pci_dma_ops = { 49void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev)
69 .alloc_coherent = dma_direct_alloc_coherent, 50{
70 .free_coherent = dma_direct_free_coherent, 51 struct pci_controller *hose;
71 .map_sg = swiotlb_map_sg_attrs, 52 struct dev_archdata *sd;
72 .unmap_sg = swiotlb_unmap_sg_attrs, 53
73 .dma_supported = swiotlb_dma_supported, 54 hose = pci_bus_to_host(pdev->bus);
74 .map_page = swiotlb_map_page, 55 sd = &pdev->dev.archdata;
75 .unmap_page = swiotlb_unmap_page, 56 sd->max_direct_dma_addr =
76 .addr_needs_map = swiotlb_pci_addr_needs_map, 57 hose->dma_window_base_cur + hose->dma_window_size;
77 .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu, 58}
78 .sync_single_range_for_device = swiotlb_sync_single_range_for_device,
79 .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
80 .sync_sg_for_device = swiotlb_sync_sg_for_device
81};
82 59
83static int ppc_swiotlb_bus_notify(struct notifier_block *nb, 60static int ppc_swiotlb_bus_notify(struct notifier_block *nb,
84 unsigned long action, void *data) 61 unsigned long action, void *data)
85{ 62{
86 struct device *dev = data; 63 struct device *dev = data;
64 struct dev_archdata *sd;
87 65
88 /* We are only intereted in device addition */ 66 /* We are only intereted in device addition */
89 if (action != BUS_NOTIFY_ADD_DEVICE) 67 if (action != BUS_NOTIFY_ADD_DEVICE)
90 return 0; 68 return 0;
91 69
70 sd = &dev->archdata;
71 sd->max_direct_dma_addr = 0;
72
92 /* May need to bounce if the device can't address all of DRAM */ 73 /* May need to bounce if the device can't address all of DRAM */
93 if (dma_get_mask(dev) < lmb_end_of_DRAM()) 74 if (dma_get_mask(dev) < lmb_end_of_DRAM())
94 set_dma_ops(dev, &swiotlb_dma_ops); 75 set_dma_ops(dev, &swiotlb_dma_ops);