Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation |
| 3 | * |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 4 | * Rewrite, cleanup: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
Olof Johansson | 91f1448 | 2005-11-21 02:12:32 -0600 | [diff] [blame] | 6 | * Copyright (C) 2004 Olof Johansson <olof@lixom.net>, IBM Corporation |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 7 | * Copyright (C) 2006 Olof Johansson <olof@lixom.net> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * |
| 9 | * Dynamic DMA mapping support, pSeries-specific parts, both SMP and LPAR. |
| 10 | * |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 11 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by |
| 14 | * the Free Software Foundation; either version 2 of the License, or |
| 15 | * (at your option) any later version. |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 16 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 21 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | */ |
| 26 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <linux/init.h> |
| 28 | #include <linux/types.h> |
| 29 | #include <linux/slab.h> |
| 30 | #include <linux/mm.h> |
| 31 | #include <linux/spinlock.h> |
| 32 | #include <linux/string.h> |
| 33 | #include <linux/pci.h> |
| 34 | #include <linux/dma-mapping.h> |
| 35 | #include <asm/io.h> |
| 36 | #include <asm/prom.h> |
| 37 | #include <asm/rtas.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #include <asm/iommu.h> |
| 39 | #include <asm/pci-bridge.h> |
| 40 | #include <asm/machdep.h> |
| 41 | #include <asm/abs_addr.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #include <asm/pSeries_reconfig.h> |
Stephen Rothwell | 1ababe1 | 2005-08-03 14:35:25 +1000 | [diff] [blame] | 43 | #include <asm/firmware.h> |
Olof Johansson | c707ffc | 2005-09-20 13:45:41 +1000 | [diff] [blame] | 44 | #include <asm/tce.h> |
Stephen Rothwell | d387899 | 2005-09-28 02:50:25 +1000 | [diff] [blame] | 45 | #include <asm/ppc-pci.h> |
Paul Mackerras | 2249ca9 | 2005-11-07 13:18:13 +1100 | [diff] [blame] | 46 | #include <asm/udbg.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
Michael Ellerman | a121872 | 2005-11-03 15:33:31 +1100 | [diff] [blame] | 48 | #include "plpar_wrappers.h" |
| 49 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | #define DBG(fmt...) |
| 51 | |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 52 | static void tce_build_pSeries(struct iommu_table *tbl, long index, |
| 53 | long npages, unsigned long uaddr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | enum dma_data_direction direction) |
| 55 | { |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 56 | u64 proto_tce; |
| 57 | u64 *tcep; |
| 58 | u64 rpn; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
Olof Johansson | d0035c62 | 2005-09-20 13:46:44 +1000 | [diff] [blame] | 60 | index <<= TCE_PAGE_FACTOR; |
| 61 | npages <<= TCE_PAGE_FACTOR; |
| 62 | |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 63 | proto_tce = TCE_PCI_READ; // Read allowed |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
| 65 | if (direction != DMA_TO_DEVICE) |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 66 | proto_tce |= TCE_PCI_WRITE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 68 | tcep = ((u64 *)tbl->it_base) + index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
| 70 | while (npages--) { |
| 71 | /* can't move this out since we might cross LMB boundary */ |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 72 | rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT; |
| 73 | *tcep = proto_tce | (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
Olof Johansson | d0035c62 | 2005-09-20 13:46:44 +1000 | [diff] [blame] | 75 | uaddr += TCE_PAGE_SIZE; |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 76 | tcep++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | } |
| 78 | } |
| 79 | |
| 80 | |
| 81 | static void tce_free_pSeries(struct iommu_table *tbl, long index, long npages) |
| 82 | { |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 83 | u64 *tcep; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
Olof Johansson | d0035c62 | 2005-09-20 13:46:44 +1000 | [diff] [blame] | 85 | npages <<= TCE_PAGE_FACTOR; |
| 86 | index <<= TCE_PAGE_FACTOR; |
| 87 | |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 88 | tcep = ((u64 *)tbl->it_base) + index; |
| 89 | |
| 90 | while (npages--) |
| 91 | *(tcep++) = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | } |
| 93 | |
Haren Myneni | 5f50867 | 2006-06-22 23:35:10 -0700 | [diff] [blame] | 94 | static unsigned long tce_get_pseries(struct iommu_table *tbl, long index) |
| 95 | { |
| 96 | u64 *tcep; |
| 97 | |
| 98 | index <<= TCE_PAGE_FACTOR; |
| 99 | tcep = ((u64 *)tbl->it_base) + index; |
| 100 | |
| 101 | return *tcep; |
| 102 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | |
| 104 | static void tce_build_pSeriesLP(struct iommu_table *tbl, long tcenum, |
| 105 | long npages, unsigned long uaddr, |
| 106 | enum dma_data_direction direction) |
| 107 | { |
| 108 | u64 rc; |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 109 | u64 proto_tce, tce; |
| 110 | u64 rpn; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | |
Michal Ostrowski | cc8b5c9 | 2005-12-02 13:09:13 +1100 | [diff] [blame] | 112 | tcenum <<= TCE_PAGE_FACTOR; |
| 113 | npages <<= TCE_PAGE_FACTOR; |
| 114 | |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 115 | rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT; |
| 116 | proto_tce = TCE_PCI_READ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | if (direction != DMA_TO_DEVICE) |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 118 | proto_tce |= TCE_PCI_WRITE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | |
| 120 | while (npages--) { |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 121 | tce = proto_tce | (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT; |
| 122 | rc = plpar_tce_put((u64)tbl->it_index, (u64)tcenum << 12, tce); |
| 123 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | if (rc && printk_ratelimit()) { |
| 125 | printk("tce_build_pSeriesLP: plpar_tce_put failed. rc=%ld\n", rc); |
| 126 | printk("\tindex = 0x%lx\n", (u64)tbl->it_index); |
| 127 | printk("\ttcenum = 0x%lx\n", (u64)tcenum); |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 128 | printk("\ttce val = 0x%lx\n", tce ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | show_stack(current, (unsigned long *)__get_SP()); |
| 130 | } |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 131 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | tcenum++; |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 133 | rpn++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | } |
| 135 | } |
| 136 | |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 137 | static DEFINE_PER_CPU(u64 *, tce_page) = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
| 139 | static void tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum, |
| 140 | long npages, unsigned long uaddr, |
| 141 | enum dma_data_direction direction) |
| 142 | { |
| 143 | u64 rc; |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 144 | u64 proto_tce; |
| 145 | u64 *tcep; |
| 146 | u64 rpn; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | long l, limit; |
| 148 | |
Paul Mackerras | 6fbb618 | 2005-12-05 14:19:10 +1100 | [diff] [blame] | 149 | if (TCE_PAGE_FACTOR == 0 && npages == 1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr, |
| 151 | direction); |
| 152 | |
| 153 | tcep = __get_cpu_var(tce_page); |
| 154 | |
| 155 | /* This is safe to do since interrupts are off when we're called |
| 156 | * from iommu_alloc{,_sg}() |
| 157 | */ |
| 158 | if (!tcep) { |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 159 | tcep = (u64 *)__get_free_page(GFP_ATOMIC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | /* If allocation fails, fall back to the loop implementation */ |
| 161 | if (!tcep) |
| 162 | return tce_build_pSeriesLP(tbl, tcenum, npages, |
| 163 | uaddr, direction); |
| 164 | __get_cpu_var(tce_page) = tcep; |
| 165 | } |
| 166 | |
Michal Ostrowski | cc8b5c9 | 2005-12-02 13:09:13 +1100 | [diff] [blame] | 167 | tcenum <<= TCE_PAGE_FACTOR; |
| 168 | npages <<= TCE_PAGE_FACTOR; |
| 169 | |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 170 | rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT; |
| 171 | proto_tce = TCE_PCI_READ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | if (direction != DMA_TO_DEVICE) |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 173 | proto_tce |= TCE_PCI_WRITE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
| 175 | /* We can map max one pageful of TCEs at a time */ |
| 176 | do { |
| 177 | /* |
| 178 | * Set up the page with TCE data, looping through and setting |
| 179 | * the values. |
| 180 | */ |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 181 | limit = min_t(long, npages, 4096/TCE_ENTRY_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
| 183 | for (l = 0; l < limit; l++) { |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 184 | tcep[l] = proto_tce | (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT; |
| 185 | rpn++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | rc = plpar_tce_put_indirect((u64)tbl->it_index, |
| 189 | (u64)tcenum << 12, |
| 190 | (u64)virt_to_abs(tcep), |
| 191 | limit); |
| 192 | |
| 193 | npages -= limit; |
| 194 | tcenum += limit; |
| 195 | } while (npages > 0 && !rc); |
| 196 | |
| 197 | if (rc && printk_ratelimit()) { |
| 198 | printk("tce_buildmulti_pSeriesLP: plpar_tce_put failed. rc=%ld\n", rc); |
| 199 | printk("\tindex = 0x%lx\n", (u64)tbl->it_index); |
| 200 | printk("\tnpages = 0x%lx\n", (u64)npages); |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 201 | printk("\ttce[0] val = 0x%lx\n", tcep[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | show_stack(current, (unsigned long *)__get_SP()); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | static void tce_free_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages) |
| 207 | { |
| 208 | u64 rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | |
Olof Johansson | d0035c62 | 2005-09-20 13:46:44 +1000 | [diff] [blame] | 210 | tcenum <<= TCE_PAGE_FACTOR; |
| 211 | npages <<= TCE_PAGE_FACTOR; |
| 212 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | while (npages--) { |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 214 | rc = plpar_tce_put((u64)tbl->it_index, (u64)tcenum << 12, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | |
| 216 | if (rc && printk_ratelimit()) { |
| 217 | printk("tce_free_pSeriesLP: plpar_tce_put failed. rc=%ld\n", rc); |
| 218 | printk("\tindex = 0x%lx\n", (u64)tbl->it_index); |
| 219 | printk("\ttcenum = 0x%lx\n", (u64)tcenum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | show_stack(current, (unsigned long *)__get_SP()); |
| 221 | } |
| 222 | |
| 223 | tcenum++; |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | |
| 228 | static void tce_freemulti_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages) |
| 229 | { |
| 230 | u64 rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | |
Olof Johansson | d0035c62 | 2005-09-20 13:46:44 +1000 | [diff] [blame] | 232 | tcenum <<= TCE_PAGE_FACTOR; |
| 233 | npages <<= TCE_PAGE_FACTOR; |
| 234 | |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 235 | rc = plpar_tce_stuff((u64)tbl->it_index, (u64)tcenum << 12, 0, npages); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | |
| 237 | if (rc && printk_ratelimit()) { |
| 238 | printk("tce_freemulti_pSeriesLP: plpar_tce_stuff failed\n"); |
| 239 | printk("\trc = %ld\n", rc); |
| 240 | printk("\tindex = 0x%lx\n", (u64)tbl->it_index); |
| 241 | printk("\tnpages = 0x%lx\n", (u64)npages); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | show_stack(current, (unsigned long *)__get_SP()); |
| 243 | } |
| 244 | } |
| 245 | |
Haren Myneni | 5f50867 | 2006-06-22 23:35:10 -0700 | [diff] [blame] | 246 | static unsigned long tce_get_pSeriesLP(struct iommu_table *tbl, long tcenum) |
| 247 | { |
| 248 | u64 rc; |
| 249 | unsigned long tce_ret; |
| 250 | |
| 251 | tcenum <<= TCE_PAGE_FACTOR; |
| 252 | rc = plpar_tce_get((u64)tbl->it_index, (u64)tcenum << 12, &tce_ret); |
| 253 | |
| 254 | if (rc && printk_ratelimit()) { |
| 255 | printk("tce_get_pSeriesLP: plpar_tce_get failed. rc=%ld\n", |
| 256 | rc); |
| 257 | printk("\tindex = 0x%lx\n", (u64)tbl->it_index); |
| 258 | printk("\ttcenum = 0x%lx\n", (u64)tcenum); |
| 259 | show_stack(current, (unsigned long *)__get_SP()); |
| 260 | } |
| 261 | |
| 262 | return tce_ret; |
| 263 | } |
| 264 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | static void iommu_table_setparms(struct pci_controller *phb, |
| 266 | struct device_node *dn, |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 267 | struct iommu_table *tbl) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | { |
| 269 | struct device_node *node; |
Jeremy Kerr | 954a46e | 2006-07-12 15:39:43 +1000 | [diff] [blame] | 270 | const unsigned long *basep, *sizep; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | |
| 272 | node = (struct device_node *)phb->arch_data; |
| 273 | |
Jeremy Kerr | 954a46e | 2006-07-12 15:39:43 +1000 | [diff] [blame] | 274 | basep = get_property(node, "linux,tce-base", NULL); |
| 275 | sizep = get_property(node, "linux,tce-size", NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | if (basep == NULL || sizep == NULL) { |
| 277 | printk(KERN_ERR "PCI_DMA: iommu_table_setparms: %s has " |
| 278 | "missing tce entries !\n", dn->full_name); |
| 279 | return; |
| 280 | } |
| 281 | |
| 282 | tbl->it_base = (unsigned long)__va(*basep); |
Haren Myneni | 5f50867 | 2006-06-22 23:35:10 -0700 | [diff] [blame] | 283 | |
| 284 | #ifndef CONFIG_CRASH_DUMP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | memset((void *)tbl->it_base, 0, *sizep); |
Haren Myneni | 5f50867 | 2006-06-22 23:35:10 -0700 | [diff] [blame] | 286 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | |
| 288 | tbl->it_busno = phb->bus->number; |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 289 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | /* Units of tce entries */ |
| 291 | tbl->it_offset = phb->dma_window_base_cur >> PAGE_SHIFT; |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 292 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | /* Test if we are going over 2GB of DMA space */ |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 294 | if (phb->dma_window_base_cur + phb->dma_window_size > 0x80000000ul) { |
| 295 | udbg_printf("PCI_DMA: Unexpected number of IOAs under this PHB.\n"); |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 296 | panic("PCI_DMA: Unexpected number of IOAs under this PHB.\n"); |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 297 | } |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 298 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | phb->dma_window_base_cur += phb->dma_window_size; |
| 300 | |
| 301 | /* Set the tce table size - measured in entries */ |
| 302 | tbl->it_size = phb->dma_window_size >> PAGE_SHIFT; |
| 303 | |
| 304 | tbl->it_index = 0; |
| 305 | tbl->it_blocksize = 16; |
| 306 | tbl->it_type = TCE_PCI; |
| 307 | } |
| 308 | |
| 309 | /* |
| 310 | * iommu_table_setparms_lpar |
| 311 | * |
| 312 | * Function: On pSeries LPAR systems, return TCE table info, given a pci bus. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | */ |
| 314 | static void iommu_table_setparms_lpar(struct pci_controller *phb, |
| 315 | struct device_node *dn, |
| 316 | struct iommu_table *tbl, |
Jeremy Kerr | 954a46e | 2006-07-12 15:39:43 +1000 | [diff] [blame] | 317 | const void *dma_window) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | { |
Jeremy Kerr | 4c76e0b | 2006-05-18 18:06:37 +1000 | [diff] [blame] | 319 | unsigned long offset, size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | |
Jeremy Kerr | 4c76e0b | 2006-05-18 18:06:37 +1000 | [diff] [blame] | 321 | tbl->it_busno = PCI_DN(dn)->bussubno; |
| 322 | of_parse_dma_window(dn, dma_window, &tbl->it_index, &offset, &size); |
| 323 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | tbl->it_base = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | tbl->it_blocksize = 16; |
| 326 | tbl->it_type = TCE_PCI; |
Jeremy Kerr | 4c76e0b | 2006-05-18 18:06:37 +1000 | [diff] [blame] | 327 | tbl->it_offset = offset >> PAGE_SHIFT; |
| 328 | tbl->it_size = size >> PAGE_SHIFT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | static void iommu_bus_setup_pSeries(struct pci_bus *bus) |
| 332 | { |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 333 | struct device_node *dn; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | struct iommu_table *tbl; |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 335 | struct device_node *isa_dn, *isa_dn_orig; |
| 336 | struct device_node *tmp; |
| 337 | struct pci_dn *pci; |
| 338 | int children; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | |
| 340 | DBG("iommu_bus_setup_pSeries, bus %p, bus->self %p\n", bus, bus->self); |
| 341 | |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 342 | dn = pci_bus_to_OF_node(bus); |
| 343 | pci = PCI_DN(dn); |
| 344 | |
| 345 | if (bus->self) { |
| 346 | /* This is not a root bus, any setup will be done for the |
| 347 | * device-side of the bridge in iommu_dev_setup_pSeries(). |
| 348 | */ |
| 349 | return; |
| 350 | } |
| 351 | |
| 352 | /* Check if the ISA bus on the system is under |
| 353 | * this PHB. |
| 354 | */ |
| 355 | isa_dn = isa_dn_orig = of_find_node_by_type(NULL, "isa"); |
| 356 | |
| 357 | while (isa_dn && isa_dn != dn) |
| 358 | isa_dn = isa_dn->parent; |
| 359 | |
| 360 | if (isa_dn_orig) |
| 361 | of_node_put(isa_dn_orig); |
| 362 | |
Anton Blanchard | d3c58fb | 2006-06-20 18:00:30 +1000 | [diff] [blame] | 363 | /* Count number of direct PCI children of the PHB. */ |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 364 | for (children = 0, tmp = dn->child; tmp; tmp = tmp->sibling) |
Anton Blanchard | d3c58fb | 2006-06-20 18:00:30 +1000 | [diff] [blame] | 365 | children++; |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 366 | |
| 367 | DBG("Children: %d\n", children); |
| 368 | |
| 369 | /* Calculate amount of DMA window per slot. Each window must be |
| 370 | * a power of two (due to pci_alloc_consistent requirements). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | * |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 372 | * Keep 256MB aside for PHBs with ISA. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | */ |
| 374 | |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 375 | if (!isa_dn) { |
| 376 | /* No ISA/IDE - just set window size and return */ |
| 377 | pci->phb->dma_window_size = 0x80000000ul; /* To be divided */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 379 | while (pci->phb->dma_window_size * children > 0x80000000ul) |
| 380 | pci->phb->dma_window_size >>= 1; |
Anton Blanchard | f951da3 | 2005-09-22 21:44:05 -0700 | [diff] [blame] | 381 | DBG("No ISA/IDE, window size is 0x%lx\n", |
| 382 | pci->phb->dma_window_size); |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 383 | pci->phb->dma_window_base_cur = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 385 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | } |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 387 | |
| 388 | /* If we have ISA, then we probably have an IDE |
| 389 | * controller too. Allocate a 128MB table but |
| 390 | * skip the first 128MB to avoid stepping on ISA |
| 391 | * space. |
| 392 | */ |
| 393 | pci->phb->dma_window_size = 0x8000000ul; |
| 394 | pci->phb->dma_window_base_cur = 0x8000000ul; |
| 395 | |
Anton Blanchard | ca1588e | 2006-06-10 20:58:08 +1000 | [diff] [blame] | 396 | tbl = kmalloc_node(sizeof(struct iommu_table), GFP_KERNEL, |
| 397 | pci->phb->node); |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 398 | |
| 399 | iommu_table_setparms(pci->phb, dn, tbl); |
Anton Blanchard | ca1588e | 2006-06-10 20:58:08 +1000 | [diff] [blame] | 400 | pci->iommu_table = iommu_init_table(tbl, pci->phb->node); |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 401 | |
| 402 | /* Divide the rest (1.75GB) among the children */ |
| 403 | pci->phb->dma_window_size = 0x80000000ul; |
| 404 | while (pci->phb->dma_window_size * children > 0x70000000ul) |
| 405 | pci->phb->dma_window_size >>= 1; |
| 406 | |
Anton Blanchard | f951da3 | 2005-09-22 21:44:05 -0700 | [diff] [blame] | 407 | DBG("ISA/IDE, window size is 0x%lx\n", pci->phb->dma_window_size); |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 408 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | } |
| 410 | |
| 411 | |
| 412 | static void iommu_bus_setup_pSeriesLP(struct pci_bus *bus) |
| 413 | { |
| 414 | struct iommu_table *tbl; |
| 415 | struct device_node *dn, *pdn; |
Paul Mackerras | 1635317 | 2005-09-06 13:17:54 +1000 | [diff] [blame] | 416 | struct pci_dn *ppci; |
Jeremy Kerr | 954a46e | 2006-07-12 15:39:43 +1000 | [diff] [blame] | 417 | const void *dma_window = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | |
| 419 | DBG("iommu_bus_setup_pSeriesLP, bus %p, bus->self %p\n", bus, bus->self); |
| 420 | |
| 421 | dn = pci_bus_to_OF_node(bus); |
| 422 | |
| 423 | /* Find nearest ibm,dma-window, walking up the device tree */ |
| 424 | for (pdn = dn; pdn != NULL; pdn = pdn->parent) { |
Jeremy Kerr | 4c76e0b | 2006-05-18 18:06:37 +1000 | [diff] [blame] | 425 | dma_window = get_property(pdn, "ibm,dma-window", NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | if (dma_window != NULL) |
| 427 | break; |
| 428 | } |
| 429 | |
| 430 | if (dma_window == NULL) { |
| 431 | DBG("iommu_bus_setup_pSeriesLP: bus %s seems to have no ibm,dma-window property\n", dn->full_name); |
| 432 | return; |
| 433 | } |
| 434 | |
linas | e07102d | 2005-12-05 19:37:35 -0600 | [diff] [blame] | 435 | ppci = PCI_DN(pdn); |
Paul Mackerras | 1635317 | 2005-09-06 13:17:54 +1000 | [diff] [blame] | 436 | if (!ppci->iommu_table) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | /* Bussubno hasn't been copied yet. |
| 438 | * Do it now because iommu_table_setparms_lpar needs it. |
| 439 | */ |
Paul Mackerras | 1635317 | 2005-09-06 13:17:54 +1000 | [diff] [blame] | 440 | |
| 441 | ppci->bussubno = bus->number; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | |
Anton Blanchard | ca1588e | 2006-06-10 20:58:08 +1000 | [diff] [blame] | 443 | tbl = kmalloc_node(sizeof(struct iommu_table), GFP_KERNEL, |
| 444 | ppci->phb->node); |
Olof Johansson | bc97ce9 | 2006-04-28 22:51:59 -0500 | [diff] [blame] | 445 | |
Paul Mackerras | 1635317 | 2005-09-06 13:17:54 +1000 | [diff] [blame] | 446 | iommu_table_setparms_lpar(ppci->phb, pdn, tbl, dma_window); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | |
Anton Blanchard | ca1588e | 2006-06-10 20:58:08 +1000 | [diff] [blame] | 448 | ppci->iommu_table = iommu_init_table(tbl, ppci->phb->node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | if (pdn != dn) |
Paul Mackerras | 1635317 | 2005-09-06 13:17:54 +1000 | [diff] [blame] | 452 | PCI_DN(dn)->iommu_table = ppci->iommu_table; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | |
| 456 | static void iommu_dev_setup_pSeries(struct pci_dev *dev) |
| 457 | { |
| 458 | struct device_node *dn, *mydn; |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 459 | struct iommu_table *tbl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | |
Anton Blanchard | f951da3 | 2005-09-22 21:44:05 -0700 | [diff] [blame] | 461 | DBG("iommu_dev_setup_pSeries, dev %p (%s)\n", dev, pci_name(dev)); |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 462 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | mydn = dn = pci_device_to_OF_node(dev); |
| 464 | |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 465 | /* If we're the direct child of a root bus, then we need to allocate |
| 466 | * an iommu table ourselves. The bus setup code should have setup |
| 467 | * the window sizes already. |
| 468 | */ |
| 469 | if (!dev->bus->self) { |
| 470 | DBG(" --> first child, no bridge. Allocating iommu table.\n"); |
Anton Blanchard | ca1588e | 2006-06-10 20:58:08 +1000 | [diff] [blame] | 471 | tbl = kmalloc_node(sizeof(struct iommu_table), GFP_KERNEL, |
| 472 | PCI_DN(dn)->phb->node); |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 473 | iommu_table_setparms(PCI_DN(dn)->phb, dn, tbl); |
Anton Blanchard | ca1588e | 2006-06-10 20:58:08 +1000 | [diff] [blame] | 474 | PCI_DN(dn)->iommu_table = iommu_init_table(tbl, |
| 475 | PCI_DN(dn)->phb->node); |
Olof Johansson | 3c2822c | 2005-09-21 09:55:31 -0700 | [diff] [blame] | 476 | |
| 477 | return; |
| 478 | } |
| 479 | |
| 480 | /* If this device is further down the bus tree, search upwards until |
| 481 | * an already allocated iommu table is found and use that. |
| 482 | */ |
| 483 | |
linas | e07102d | 2005-12-05 19:37:35 -0600 | [diff] [blame] | 484 | while (dn && PCI_DN(dn) && PCI_DN(dn)->iommu_table == NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | dn = dn->parent; |
| 486 | |
linas | e07102d | 2005-12-05 19:37:35 -0600 | [diff] [blame] | 487 | if (dn && PCI_DN(dn)) { |
Paul Mackerras | 1635317 | 2005-09-06 13:17:54 +1000 | [diff] [blame] | 488 | PCI_DN(mydn)->iommu_table = PCI_DN(dn)->iommu_table; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | } else { |
Anton Blanchard | f951da3 | 2005-09-22 21:44:05 -0700 | [diff] [blame] | 490 | DBG("iommu_dev_setup_pSeries, dev %p (%s) has no iommu table\n", dev, pci_name(dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | } |
| 492 | } |
| 493 | |
| 494 | static int iommu_reconfig_notifier(struct notifier_block *nb, unsigned long action, void *node) |
| 495 | { |
| 496 | int err = NOTIFY_OK; |
| 497 | struct device_node *np = node; |
linas | e07102d | 2005-12-05 19:37:35 -0600 | [diff] [blame] | 498 | struct pci_dn *pci = PCI_DN(np); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | |
| 500 | switch (action) { |
| 501 | case PSERIES_RECONFIG_REMOVE: |
John Rose | 8902e87 | 2005-11-02 10:29:55 -0600 | [diff] [blame] | 502 | if (pci && pci->iommu_table && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | get_property(np, "ibm,dma-window", NULL)) |
| 504 | iommu_free_table(np); |
| 505 | break; |
| 506 | default: |
| 507 | err = NOTIFY_DONE; |
| 508 | break; |
| 509 | } |
| 510 | return err; |
| 511 | } |
| 512 | |
| 513 | static struct notifier_block iommu_reconfig_nb = { |
| 514 | .notifier_call = iommu_reconfig_notifier, |
| 515 | }; |
| 516 | |
| 517 | static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev) |
| 518 | { |
| 519 | struct device_node *pdn, *dn; |
| 520 | struct iommu_table *tbl; |
Jeremy Kerr | 954a46e | 2006-07-12 15:39:43 +1000 | [diff] [blame] | 521 | const void *dma_window = NULL; |
Paul Mackerras | 1635317 | 2005-09-06 13:17:54 +1000 | [diff] [blame] | 522 | struct pci_dn *pci; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | |
Anton Blanchard | f951da3 | 2005-09-22 21:44:05 -0700 | [diff] [blame] | 524 | DBG("iommu_dev_setup_pSeriesLP, dev %p (%s)\n", dev, pci_name(dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | |
| 526 | /* dev setup for LPAR is a little tricky, since the device tree might |
| 527 | * contain the dma-window properties per-device and not neccesarily |
| 528 | * for the bus. So we need to search upwards in the tree until we |
| 529 | * either hit a dma-window property, OR find a parent with a table |
| 530 | * already allocated. |
| 531 | */ |
| 532 | dn = pci_device_to_OF_node(dev); |
| 533 | |
linas | e07102d | 2005-12-05 19:37:35 -0600 | [diff] [blame] | 534 | for (pdn = dn; pdn && PCI_DN(pdn) && !PCI_DN(pdn)->iommu_table; |
Paul Mackerras | 1635317 | 2005-09-06 13:17:54 +1000 | [diff] [blame] | 535 | pdn = pdn->parent) { |
Jeremy Kerr | 4c76e0b | 2006-05-18 18:06:37 +1000 | [diff] [blame] | 536 | dma_window = get_property(pdn, "ibm,dma-window", NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | if (dma_window) |
| 538 | break; |
| 539 | } |
| 540 | |
| 541 | /* Check for parent == NULL so we don't try to setup the empty EADS |
| 542 | * slots on POWER4 machines. |
| 543 | */ |
| 544 | if (dma_window == NULL || pdn->parent == NULL) { |
Anton Blanchard | 586a90e | 2005-09-22 21:44:04 -0700 | [diff] [blame] | 545 | DBG("No dma window for device, linking to parent\n"); |
| 546 | PCI_DN(dn)->iommu_table = PCI_DN(pdn)->iommu_table; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | return; |
| 548 | } else { |
| 549 | DBG("Found DMA window, allocating table\n"); |
| 550 | } |
| 551 | |
linas | e07102d | 2005-12-05 19:37:35 -0600 | [diff] [blame] | 552 | pci = PCI_DN(pdn); |
Paul Mackerras | 1635317 | 2005-09-06 13:17:54 +1000 | [diff] [blame] | 553 | if (!pci->iommu_table) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | /* iommu_table_setparms_lpar needs bussubno. */ |
Paul Mackerras | 1635317 | 2005-09-06 13:17:54 +1000 | [diff] [blame] | 555 | pci->bussubno = pci->phb->bus->number; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | |
Anton Blanchard | ca1588e | 2006-06-10 20:58:08 +1000 | [diff] [blame] | 557 | tbl = kmalloc_node(sizeof(struct iommu_table), GFP_KERNEL, |
| 558 | pci->phb->node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | |
Paul Mackerras | 1635317 | 2005-09-06 13:17:54 +1000 | [diff] [blame] | 560 | iommu_table_setparms_lpar(pci->phb, pdn, tbl, dma_window); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | |
Anton Blanchard | ca1588e | 2006-06-10 20:58:08 +1000 | [diff] [blame] | 562 | pci->iommu_table = iommu_init_table(tbl, pci->phb->node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | if (pdn != dn) |
Paul Mackerras | 1635317 | 2005-09-06 13:17:54 +1000 | [diff] [blame] | 566 | PCI_DN(dn)->iommu_table = pci->iommu_table; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | static void iommu_bus_setup_null(struct pci_bus *b) { } |
| 570 | static void iommu_dev_setup_null(struct pci_dev *d) { } |
| 571 | |
| 572 | /* These are called very early. */ |
| 573 | void iommu_init_early_pSeries(void) |
| 574 | { |
| 575 | if (of_chosen && get_property(of_chosen, "linux,iommu-off", NULL)) { |
| 576 | /* Direct I/O, IOMMU off */ |
| 577 | ppc_md.iommu_dev_setup = iommu_dev_setup_null; |
| 578 | ppc_md.iommu_bus_setup = iommu_bus_setup_null; |
| 579 | pci_direct_iommu_init(); |
| 580 | |
| 581 | return; |
| 582 | } |
| 583 | |
Michael Ellerman | 57cfb81 | 2006-03-21 20:45:59 +1100 | [diff] [blame] | 584 | if (firmware_has_feature(FW_FEATURE_LPAR)) { |
Stephen Rothwell | 1ababe1 | 2005-08-03 14:35:25 +1000 | [diff] [blame] | 585 | if (firmware_has_feature(FW_FEATURE_MULTITCE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | ppc_md.tce_build = tce_buildmulti_pSeriesLP; |
| 587 | ppc_md.tce_free = tce_freemulti_pSeriesLP; |
| 588 | } else { |
| 589 | ppc_md.tce_build = tce_build_pSeriesLP; |
| 590 | ppc_md.tce_free = tce_free_pSeriesLP; |
| 591 | } |
Haren Myneni | 5f50867 | 2006-06-22 23:35:10 -0700 | [diff] [blame] | 592 | ppc_md.tce_get = tce_get_pSeriesLP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | ppc_md.iommu_bus_setup = iommu_bus_setup_pSeriesLP; |
| 594 | ppc_md.iommu_dev_setup = iommu_dev_setup_pSeriesLP; |
| 595 | } else { |
| 596 | ppc_md.tce_build = tce_build_pSeries; |
| 597 | ppc_md.tce_free = tce_free_pSeries; |
Haren Myneni | 5f50867 | 2006-06-22 23:35:10 -0700 | [diff] [blame] | 598 | ppc_md.tce_get = tce_get_pseries; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | ppc_md.iommu_bus_setup = iommu_bus_setup_pSeries; |
| 600 | ppc_md.iommu_dev_setup = iommu_dev_setup_pSeries; |
| 601 | } |
| 602 | |
| 603 | |
| 604 | pSeries_reconfig_notifier_register(&iommu_reconfig_nb); |
| 605 | |
| 606 | pci_iommu_init(); |
| 607 | } |
| 608 | |