diff options
author | Christoph Hellwig <hch@lst.de> | 2019-02-13 02:01:20 -0500 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2019-02-18 06:41:03 -0500 |
commit | 74194cdaac41f6dfaacd9433f739dcbd83125d0b (patch) | |
tree | 6e2dc6d362d1c2f55e9678f4de418da50a86e5b5 | |
parent | 391133fd5adaba319795cd96882d1ea405c41cf6 (diff) |
powerpc/dma: remove max_direct_dma_addr
The max_direct_dma_addr duplicates the bus_dma_mask field in struct
device. Use the generic field instead.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r-- | arch/powerpc/include/asm/device.h | 3 | ||||
-rw-r--r-- | arch/powerpc/include/asm/dma-direct.h | 4 | ||||
-rw-r--r-- | arch/powerpc/kernel/dma-swiotlb.c | 21 | ||||
-rw-r--r-- | arch/powerpc/kernel/dma.c | 5 | ||||
-rw-r--r-- | arch/powerpc/sysdev/fsl_pci.c | 4 |
5 files changed, 6 insertions, 31 deletions
diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/include/asm/device.h index 3814e1c2d4bc..a130be13ee83 100644 --- a/arch/powerpc/include/asm/device.h +++ b/arch/powerpc/include/asm/device.h | |||
@@ -38,9 +38,6 @@ struct dev_archdata { | |||
38 | #ifdef CONFIG_IOMMU_API | 38 | #ifdef CONFIG_IOMMU_API |
39 | void *iommu_domain; | 39 | void *iommu_domain; |
40 | #endif | 40 | #endif |
41 | #ifdef CONFIG_SWIOTLB | ||
42 | dma_addr_t max_direct_dma_addr; | ||
43 | #endif | ||
44 | #ifdef CONFIG_PPC64 | 41 | #ifdef CONFIG_PPC64 |
45 | struct pci_dn *pci_data; | 42 | struct pci_dn *pci_data; |
46 | #endif | 43 | #endif |
diff --git a/arch/powerpc/include/asm/dma-direct.h b/arch/powerpc/include/asm/dma-direct.h index 7702875aabb7..e00ab5d0612d 100644 --- a/arch/powerpc/include/asm/dma-direct.h +++ b/arch/powerpc/include/asm/dma-direct.h | |||
@@ -5,9 +5,7 @@ | |||
5 | static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) | 5 | static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) |
6 | { | 6 | { |
7 | #ifdef CONFIG_SWIOTLB | 7 | #ifdef CONFIG_SWIOTLB |
8 | struct dev_archdata *sd = &dev->archdata; | 8 | if (dev->bus_dma_mask && addr + size > dev->bus_dma_mask) |
9 | |||
10 | if (sd->max_direct_dma_addr && addr + size > sd->max_direct_dma_addr) | ||
11 | return false; | 9 | return false; |
12 | #endif | 10 | #endif |
13 | 11 | ||
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c index 42badc4bf536..0e21c318300e 100644 --- a/arch/powerpc/kernel/dma-swiotlb.c +++ b/arch/powerpc/kernel/dma-swiotlb.c | |||
@@ -24,21 +24,6 @@ | |||
24 | 24 | ||
25 | unsigned int ppc_swiotlb_enable; | 25 | unsigned int ppc_swiotlb_enable; |
26 | 26 | ||
27 | static u64 swiotlb_powerpc_get_required(struct device *dev) | ||
28 | { | ||
29 | u64 end, mask, max_direct_dma_addr = dev->archdata.max_direct_dma_addr; | ||
30 | |||
31 | end = memblock_end_of_DRAM(); | ||
32 | if (max_direct_dma_addr && end > max_direct_dma_addr) | ||
33 | end = max_direct_dma_addr; | ||
34 | end += get_dma_offset(dev); | ||
35 | |||
36 | mask = 1ULL << (fls64(end) - 1); | ||
37 | mask += mask - 1; | ||
38 | |||
39 | return mask; | ||
40 | } | ||
41 | |||
42 | /* | 27 | /* |
43 | * At the moment, all platforms that use this code only require | 28 | * At the moment, all platforms that use this code only require |
44 | * swiotlb to be used if we're operating on HIGHMEM. Since | 29 | * swiotlb to be used if we're operating on HIGHMEM. Since |
@@ -59,22 +44,18 @@ const struct dma_map_ops powerpc_swiotlb_dma_ops = { | |||
59 | .sync_single_for_device = dma_direct_sync_single_for_device, | 44 | .sync_single_for_device = dma_direct_sync_single_for_device, |
60 | .sync_sg_for_cpu = dma_direct_sync_sg_for_cpu, | 45 | .sync_sg_for_cpu = dma_direct_sync_sg_for_cpu, |
61 | .sync_sg_for_device = dma_direct_sync_sg_for_device, | 46 | .sync_sg_for_device = dma_direct_sync_sg_for_device, |
62 | .get_required_mask = swiotlb_powerpc_get_required, | 47 | .get_required_mask = dma_direct_get_required_mask, |
63 | }; | 48 | }; |
64 | 49 | ||
65 | static int ppc_swiotlb_bus_notify(struct notifier_block *nb, | 50 | static int ppc_swiotlb_bus_notify(struct notifier_block *nb, |
66 | unsigned long action, void *data) | 51 | unsigned long action, void *data) |
67 | { | 52 | { |
68 | struct device *dev = data; | 53 | struct device *dev = data; |
69 | struct dev_archdata *sd; | ||
70 | 54 | ||
71 | /* We are only intereted in device addition */ | 55 | /* We are only intereted in device addition */ |
72 | if (action != BUS_NOTIFY_ADD_DEVICE) | 56 | if (action != BUS_NOTIFY_ADD_DEVICE) |
73 | return 0; | 57 | return 0; |
74 | 58 | ||
75 | sd = &dev->archdata; | ||
76 | sd->max_direct_dma_addr = 0; | ||
77 | |||
78 | /* May need to bounce if the device can't address all of DRAM */ | 59 | /* May need to bounce if the device can't address all of DRAM */ |
79 | if ((dma_get_mask(dev) + 1) < memblock_end_of_DRAM()) | 60 | if ((dma_get_mask(dev) + 1) < memblock_end_of_DRAM()) |
80 | set_dma_ops(dev, &powerpc_swiotlb_dma_ops); | 61 | set_dma_ops(dev, &powerpc_swiotlb_dma_ops); |
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index 9def69c8f602..1e191eb3f0ec 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c | |||
@@ -30,11 +30,10 @@ | |||
30 | static u64 __maybe_unused get_pfn_limit(struct device *dev) | 30 | static u64 __maybe_unused get_pfn_limit(struct device *dev) |
31 | { | 31 | { |
32 | u64 pfn = (dev->coherent_dma_mask >> PAGE_SHIFT) + 1; | 32 | u64 pfn = (dev->coherent_dma_mask >> PAGE_SHIFT) + 1; |
33 | struct dev_archdata __maybe_unused *sd = &dev->archdata; | ||
34 | 33 | ||
35 | #ifdef CONFIG_SWIOTLB | 34 | #ifdef CONFIG_SWIOTLB |
36 | if (sd->max_direct_dma_addr && dev->dma_ops == &powerpc_swiotlb_dma_ops) | 35 | if (dev->bus_dma_mask && dev->dma_ops == &powerpc_swiotlb_dma_ops) |
37 | pfn = min_t(u64, pfn, sd->max_direct_dma_addr >> PAGE_SHIFT); | 36 | pfn = min_t(u64, pfn, dev->bus_dma_mask >> PAGE_SHIFT); |
38 | #endif | 37 | #endif |
39 | 38 | ||
40 | return pfn; | 39 | return pfn; |
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c index 561f97d698cc..b710cee023a2 100644 --- a/arch/powerpc/sysdev/fsl_pci.c +++ b/arch/powerpc/sysdev/fsl_pci.c | |||
@@ -117,9 +117,8 @@ static u64 pci64_dma_offset; | |||
117 | static void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev) | 117 | static void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev) |
118 | { | 118 | { |
119 | struct pci_controller *hose = pci_bus_to_host(pdev->bus); | 119 | struct pci_controller *hose = pci_bus_to_host(pdev->bus); |
120 | struct dev_archdata *sd = &pdev->dev.archdata; | ||
121 | 120 | ||
122 | sd->max_direct_dma_addr = | 121 | pdev->dev.bus_dma_mask = |
123 | hose->dma_window_base_cur + hose->dma_window_size; | 122 | hose->dma_window_base_cur + hose->dma_window_size; |
124 | } | 123 | } |
125 | 124 | ||
@@ -144,6 +143,7 @@ static int fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask) | |||
144 | * mapping that allows addressing any RAM address from across PCI. | 143 | * mapping that allows addressing any RAM address from across PCI. |
145 | */ | 144 | */ |
146 | if (dev_is_pci(dev) && dma_mask >= pci64_dma_offset * 2 - 1) { | 145 | if (dev_is_pci(dev) && dma_mask >= pci64_dma_offset * 2 - 1) { |
146 | dev->bus_dma_mask = 0; | ||
147 | set_dma_ops(dev, &dma_nommu_ops); | 147 | set_dma_ops(dev, &dma_nommu_ops); |
148 | set_dma_offset(dev, pci64_dma_offset); | 148 | set_dma_offset(dev, pci64_dma_offset); |
149 | } | 149 | } |