diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2009-08-04 15:08:22 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-08-28 00:24:09 -0400 |
commit | 762afb7317b1987fa0851135fe4f2947f68c3c2a (patch) | |
tree | 1cf83145c1bdd55b6a166d428af8ee195b09985b /arch/powerpc/kernel/dma-swiotlb.c | |
parent | 2864697cefb6e7596e39aef933b4131f6c9fa9e1 (diff) |
powerpc: Remove addr_needs_map in struct dma_mapping_ops
This patch adds max_direct_dma_addr to struct dev_archdata to remove
addr_needs_map in struct dma_mapping_ops. It also converts
dma_capable() to use max_direct_dma_addr.
max_direct_dma_addr is initialized in pci_dma_dev_setup_swiotlb(),
called via ppc_md.pci_dma_dev_setup hook.
For further information:
http://marc.info/?t=124719060200001&r=1&w=2
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: Becky Bruce <beckyb@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel/dma-swiotlb.c')
-rw-r--r-- | arch/powerpc/kernel/dma-swiotlb.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c index e8a57de85bcf..c9f6a302e879 100644 --- a/arch/powerpc/kernel/dma-swiotlb.c +++ b/arch/powerpc/kernel/dma-swiotlb.c | |||
@@ -25,26 +25,6 @@ int swiotlb __read_mostly; | |||
25 | unsigned int ppc_swiotlb_enable; | 25 | unsigned 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 | */ | ||
30 | static int | ||
31 | swiotlb_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, |
@@ -73,22 +53,36 @@ struct dma_mapping_ops swiotlb_pci_dma_ops = { | |||
73 | .dma_supported = swiotlb_dma_supported, | 53 | .dma_supported = swiotlb_dma_supported, |
74 | .map_page = swiotlb_map_page, | 54 | .map_page = swiotlb_map_page, |
75 | .unmap_page = swiotlb_unmap_page, | 55 | .unmap_page = swiotlb_unmap_page, |
76 | .addr_needs_map = swiotlb_pci_addr_needs_map, | ||
77 | .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu, | 56 | .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu, |
78 | .sync_single_range_for_device = swiotlb_sync_single_range_for_device, | 57 | .sync_single_range_for_device = swiotlb_sync_single_range_for_device, |
79 | .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, | 58 | .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, |
80 | .sync_sg_for_device = swiotlb_sync_sg_for_device | 59 | .sync_sg_for_device = swiotlb_sync_sg_for_device |
81 | }; | 60 | }; |
82 | 61 | ||
62 | void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev) | ||
63 | { | ||
64 | struct pci_controller *hose; | ||
65 | struct dev_archdata *sd; | ||
66 | |||
67 | hose = pci_bus_to_host(pdev->bus); | ||
68 | sd = &pdev->dev.archdata; | ||
69 | sd->max_direct_dma_addr = | ||
70 | hose->dma_window_base_cur + hose->dma_window_size; | ||
71 | } | ||
72 | |||
83 | static int ppc_swiotlb_bus_notify(struct notifier_block *nb, | 73 | static int ppc_swiotlb_bus_notify(struct notifier_block *nb, |
84 | unsigned long action, void *data) | 74 | unsigned long action, void *data) |
85 | { | 75 | { |
86 | struct device *dev = data; | 76 | struct device *dev = data; |
77 | struct dev_archdata *sd; | ||
87 | 78 | ||
88 | /* We are only intereted in device addition */ | 79 | /* We are only intereted in device addition */ |
89 | if (action != BUS_NOTIFY_ADD_DEVICE) | 80 | if (action != BUS_NOTIFY_ADD_DEVICE) |
90 | return 0; | 81 | return 0; |
91 | 82 | ||
83 | sd = &dev->archdata; | ||
84 | sd->max_direct_dma_addr = 0; | ||
85 | |||
92 | /* May need to bounce if the device can't address all of DRAM */ | 86 | /* May need to bounce if the device can't address all of DRAM */ |
93 | if (dma_get_mask(dev) < lmb_end_of_DRAM()) | 87 | if (dma_get_mask(dev) < lmb_end_of_DRAM()) |
94 | set_dma_ops(dev, &swiotlb_dma_ops); | 88 | set_dma_ops(dev, &swiotlb_dma_ops); |