diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/ppc64/kernel/pci_direct_iommu.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/ppc64/kernel/pci_direct_iommu.c')
-rw-r--r-- | arch/ppc64/kernel/pci_direct_iommu.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/arch/ppc64/kernel/pci_direct_iommu.c b/arch/ppc64/kernel/pci_direct_iommu.c new file mode 100644 index 000000000000..b8f7f58824f4 --- /dev/null +++ b/arch/ppc64/kernel/pci_direct_iommu.c | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | * Support for DMA from PCI devices to main memory on | ||
3 | * machines without an iommu or with directly addressable | ||
4 | * RAM (typically a pmac with 2Gb of RAM or less) | ||
5 | * | ||
6 | * Copyright (C) 2003 Benjamin Herrenschmidt (benh@kernel.crashing.org) | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * as published by the Free Software Foundation; either version | ||
11 | * 2 of the License, or (at your option) any later version. | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/pci.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/string.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/bootmem.h> | ||
20 | #include <linux/mm.h> | ||
21 | #include <linux/dma-mapping.h> | ||
22 | |||
23 | #include <asm/sections.h> | ||
24 | #include <asm/io.h> | ||
25 | #include <asm/prom.h> | ||
26 | #include <asm/pci-bridge.h> | ||
27 | #include <asm/machdep.h> | ||
28 | #include <asm/pmac_feature.h> | ||
29 | #include <asm/abs_addr.h> | ||
30 | |||
31 | #include "pci.h" | ||
32 | |||
33 | static void *pci_direct_alloc_coherent(struct device *hwdev, size_t size, | ||
34 | dma_addr_t *dma_handle, unsigned int __nocast flag) | ||
35 | { | ||
36 | void *ret; | ||
37 | |||
38 | ret = (void *)__get_free_pages(flag, get_order(size)); | ||
39 | if (ret != NULL) { | ||
40 | memset(ret, 0, size); | ||
41 | *dma_handle = virt_to_abs(ret); | ||
42 | } | ||
43 | return ret; | ||
44 | } | ||
45 | |||
46 | static void pci_direct_free_coherent(struct device *hwdev, size_t size, | ||
47 | void *vaddr, dma_addr_t dma_handle) | ||
48 | { | ||
49 | free_pages((unsigned long)vaddr, get_order(size)); | ||
50 | } | ||
51 | |||
52 | static dma_addr_t pci_direct_map_single(struct device *hwdev, void *ptr, | ||
53 | size_t size, enum dma_data_direction direction) | ||
54 | { | ||
55 | return virt_to_abs(ptr); | ||
56 | } | ||
57 | |||
58 | static void pci_direct_unmap_single(struct device *hwdev, dma_addr_t dma_addr, | ||
59 | size_t size, enum dma_data_direction direction) | ||
60 | { | ||
61 | } | ||
62 | |||
63 | static int pci_direct_map_sg(struct device *hwdev, struct scatterlist *sg, | ||
64 | int nents, enum dma_data_direction direction) | ||
65 | { | ||
66 | int i; | ||
67 | |||
68 | for (i = 0; i < nents; i++, sg++) { | ||
69 | sg->dma_address = page_to_phys(sg->page) + sg->offset; | ||
70 | sg->dma_length = sg->length; | ||
71 | } | ||
72 | |||
73 | return nents; | ||
74 | } | ||
75 | |||
76 | static void pci_direct_unmap_sg(struct device *hwdev, struct scatterlist *sg, | ||
77 | int nents, enum dma_data_direction direction) | ||
78 | { | ||
79 | } | ||
80 | |||
81 | static int pci_direct_dma_supported(struct device *dev, u64 mask) | ||
82 | { | ||
83 | return mask < 0x100000000ull; | ||
84 | } | ||
85 | |||
86 | void __init pci_direct_iommu_init(void) | ||
87 | { | ||
88 | pci_dma_ops.alloc_coherent = pci_direct_alloc_coherent; | ||
89 | pci_dma_ops.free_coherent = pci_direct_free_coherent; | ||
90 | pci_dma_ops.map_single = pci_direct_map_single; | ||
91 | pci_dma_ops.unmap_single = pci_direct_unmap_single; | ||
92 | pci_dma_ops.map_sg = pci_direct_map_sg; | ||
93 | pci_dma_ops.unmap_sg = pci_direct_unmap_sg; | ||
94 | pci_dma_ops.dma_supported = pci_direct_dma_supported; | ||
95 | } | ||