iommu.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. /*
  2. * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation
  3. *
  4. * Rewrite, cleanup:
  5. *
  6. * Copyright (C) 2004 Olof Johansson <olof@lixom.net>, IBM Corporation
  7. * Copyright (C) 2006 Olof Johansson <olof@lixom.net>
  8. *
  9. * Dynamic DMA mapping support, pSeries-specific parts, both SMP and LPAR.
  10. *
  11. *
  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.
  16. *
  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.
  21. *
  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. #include <linux/init.h>
  27. #include <linux/types.h>
  28. #include <linux/slab.h>
  29. #include <linux/mm.h>
  30. #include <linux/spinlock.h>
  31. #include <linux/string.h>
  32. #include <linux/pci.h>
  33. #include <linux/dma-mapping.h>
  34. #include <asm/io.h>
  35. #include <asm/prom.h>
  36. #include <asm/rtas.h>
  37. #include <asm/iommu.h>
  38. #include <asm/pci-bridge.h>
  39. #include <asm/machdep.h>
  40. #include <asm/abs_addr.h>
  41. #include <asm/pSeries_reconfig.h>
  42. #include <asm/firmware.h>
  43. #include <asm/tce.h>
  44. #include <asm/ppc-pci.h>
  45. #include <asm/udbg.h>
  46. #include "plpar_wrappers.h"
  47. static int tce_build_pSeries(struct iommu_table *tbl, long index,
  48. long npages, unsigned long uaddr,
  49. enum dma_data_direction direction,
  50. struct dma_attrs *attrs)
  51. {
  52. u64 proto_tce;
  53. u64 *tcep;
  54. u64 rpn;
  55. proto_tce = TCE_PCI_READ; // Read allowed
  56. if (direction != DMA_TO_DEVICE)
  57. proto_tce |= TCE_PCI_WRITE;
  58. tcep = ((u64 *)tbl->it_base) + index;
  59. while (npages--) {
  60. /* can't move this out since we might cross LMB boundary */
  61. rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT;
  62. *tcep = proto_tce | (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT;
  63. uaddr += TCE_PAGE_SIZE;
  64. tcep++;
  65. }
  66. return 0;
  67. }
  68. static void tce_free_pSeries(struct iommu_table *tbl, long index, long npages)
  69. {
  70. u64 *tcep;
  71. tcep = ((u64 *)tbl->it_base) + index;
  72. while (npages--)
  73. *(tcep++) = 0;
  74. }
  75. static unsigned long tce_get_pseries(struct iommu_table *tbl, long index)
  76. {
  77. u64 *tcep;
  78. tcep = ((u64 *)tbl->it_base) + index;
  79. return *tcep;
  80. }
  81. static void tce_free_pSeriesLP(struct iommu_table*, long, long);
  82. static void tce_freemulti_pSeriesLP(struct iommu_table*, long, long);
  83. static int tce_build_pSeriesLP(struct iommu_table *tbl, long tcenum,
  84. long npages, unsigned long uaddr,
  85. enum dma_data_direction direction,
  86. struct dma_attrs *attrs)
  87. {
  88. u64 rc = 0;
  89. u64 proto_tce, tce;
  90. u64 rpn;
  91. int ret = 0;
  92. long tcenum_start = tcenum, npages_start = npages;
  93. rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT;
  94. proto_tce = TCE_PCI_READ;
  95. if (direction != DMA_TO_DEVICE)
  96. proto_tce |= TCE_PCI_WRITE;
  97. while (npages--) {
  98. tce = proto_tce | (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT;
  99. rc = plpar_tce_put((u64)tbl->it_index, (u64)tcenum << 12, tce);
  100. if (unlikely(rc == H_NOT_ENOUGH_RESOURCES)) {
  101. ret = (int)rc;
  102. tce_free_pSeriesLP(tbl, tcenum_start,
  103. (npages_start - (npages + 1)));
  104. break;
  105. }
  106. if (rc && printk_ratelimit()) {
  107. printk("tce_build_pSeriesLP: plpar_tce_put failed. rc=%ld\n", rc);
  108. printk("\tindex = 0x%lx\n", (u64)tbl->it_index);
  109. printk("\ttcenum = 0x%lx\n", (u64)tcenum);
  110. printk("\ttce val = 0x%lx\n", tce );
  111. show_stack(current, (unsigned long *)__get_SP());
  112. }
  113. tcenum++;
  114. rpn++;
  115. }
  116. return ret;
  117. }
  118. static DEFINE_PER_CPU(u64 *, tce_page) = NULL;
  119. static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
  120. long npages, unsigned long uaddr,
  121. enum dma_data_direction direction,
  122. struct dma_attrs *attrs)
  123. {
  124. u64 rc = 0;
  125. u64 proto_tce;
  126. u64 *tcep;
  127. u64 rpn;
  128. long l, limit;
  129. long tcenum_start = tcenum, npages_start = npages;
  130. int ret = 0;
  131. if (npages == 1) {
  132. return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr,
  133. direction, attrs);
  134. }
  135. tcep = __get_cpu_var(tce_page);
  136. /* This is safe to do since interrupts are off when we're called
  137. * from iommu_alloc{,_sg}()
  138. */
  139. if (!tcep) {
  140. tcep = (u64 *)__get_free_page(GFP_ATOMIC);
  141. /* If allocation fails, fall back to the loop implementation */
  142. if (!tcep) {
  143. return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr,
  144. direction, attrs);
  145. }
  146. __get_cpu_var(tce_page) = tcep;
  147. }
  148. rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT;
  149. proto_tce = TCE_PCI_READ;
  150. if (direction != DMA_TO_DEVICE)
  151. proto_tce |= TCE_PCI_WRITE;
  152. /* We can map max one pageful of TCEs at a time */
  153. do {
  154. /*
  155. * Set up the page with TCE data, looping through and setting
  156. * the values.
  157. */
  158. limit = min_t(long, npages, 4096/TCE_ENTRY_SIZE);
  159. for (l = 0; l < limit; l++) {
  160. tcep[l] = proto_tce | (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT;
  161. rpn++;
  162. }
  163. rc = plpar_tce_put_indirect((u64)tbl->it_index,
  164. (u64)tcenum << 12,
  165. (u64)virt_to_abs(tcep),
  166. limit);
  167. npages -= limit;
  168. tcenum += limit;
  169. } while (npages > 0 && !rc);
  170. if (unlikely(rc == H_NOT_ENOUGH_RESOURCES)) {
  171. ret = (int)rc;
  172. tce_freemulti_pSeriesLP(tbl, tcenum_start,
  173. (npages_start - (npages + limit)));
  174. return ret;
  175. }
  176. if (rc && printk_ratelimit()) {
  177. printk("tce_buildmulti_pSeriesLP: plpar_tce_put failed. rc=%ld\n", rc);
  178. printk("\tindex = 0x%lx\n", (u64)tbl->it_index);
  179. printk("\tnpages = 0x%lx\n", (u64)npages);
  180. printk("\ttce[0] val = 0x%lx\n", tcep[0]);
  181. show_stack(current, (unsigned long *)__get_SP());
  182. }
  183. return ret;
  184. }
  185. static void tce_free_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages)
  186. {
  187. u64 rc;
  188. while (npages--) {
  189. rc = plpar_tce_put((u64)tbl->it_index, (u64)tcenum << 12, 0);
  190. if (rc && printk_ratelimit()) {
  191. printk("tce_free_pSeriesLP: plpar_tce_put failed. rc=%ld\n", rc);
  192. printk("\tindex = 0x%lx\n", (u64)tbl->it_index);
  193. printk("\ttcenum = 0x%lx\n", (u64)tcenum);
  194. show_stack(current, (unsigned long *)__get_SP());
  195. }
  196. tcenum++;
  197. }
  198. }
  199. static void tce_freemulti_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages)
  200. {
  201. u64 rc;
  202. rc = plpar_tce_stuff((u64)tbl->it_index, (u64)tcenum << 12, 0, npages);
  203. if (rc && printk_ratelimit()) {
  204. printk("tce_freemulti_pSeriesLP: plpar_tce_stuff failed\n");
  205. printk("\trc = %ld\n", rc);
  206. printk("\tindex = 0x%lx\n", (u64)tbl->it_index);
  207. printk("\tnpages = 0x%lx\n", (u64)npages);
  208. show_stack(current, (unsigned long *)__get_SP());
  209. }
  210. }
  211. static unsigned long tce_get_pSeriesLP(struct iommu_table *tbl, long tcenum)
  212. {
  213. u64 rc;
  214. unsigned long tce_ret;
  215. rc = plpar_tce_get((u64)tbl->it_index, (u64)tcenum << 12, &tce_ret);
  216. if (rc && printk_ratelimit()) {
  217. printk("tce_get_pSeriesLP: plpar_tce_get failed. rc=%ld\n",
  218. rc);
  219. printk("\tindex = 0x%lx\n", (u64)tbl->it_index);
  220. printk("\ttcenum = 0x%lx\n", (u64)tcenum);
  221. show_stack(current, (unsigned long *)__get_SP());
  222. }
  223. return tce_ret;
  224. }
  225. #ifdef CONFIG_PCI
  226. static void iommu_table_setparms(struct pci_controller *phb,
  227. struct device_node *dn,
  228. struct iommu_table *tbl)
  229. {
  230. struct device_node *node;
  231. const unsigned long *basep;
  232. const u32 *sizep;
  233. node = phb->dn;
  234. basep = of_get_property(node, "linux,tce-base", NULL);
  235. sizep = of_get_property(node, "linux,tce-size", NULL);
  236. if (basep == NULL || sizep == NULL) {
  237. printk(KERN_ERR "PCI_DMA: iommu_table_setparms: %s has "
  238. "missing tce entries !\n", dn->full_name);
  239. return;
  240. }
  241. tbl->it_base = (unsigned long)__va(*basep);
  242. #ifndef CONFIG_CRASH_DUMP
  243. memset((void *)tbl->it_base, 0, *sizep);
  244. #endif
  245. tbl->it_busno = phb->bus->number;
  246. /* Units of tce entries */
  247. tbl->it_offset = phb->dma_window_base_cur >> IOMMU_PAGE_SHIFT;
  248. /* Test if we are going over 2GB of DMA space */
  249. if (phb->dma_window_base_cur + phb->dma_window_size > 0x80000000ul) {
  250. udbg_printf("PCI_DMA: Unexpected number of IOAs under this PHB.\n");
  251. panic("PCI_DMA: Unexpected number of IOAs under this PHB.\n");
  252. }
  253. phb->dma_window_base_cur += phb->dma_window_size;
  254. /* Set the tce table size - measured in entries */
  255. tbl->it_size = phb->dma_window_size >> IOMMU_PAGE_SHIFT;
  256. tbl->it_index = 0;
  257. tbl->it_blocksize = 16;
  258. tbl->it_type = TCE_PCI;
  259. }
  260. /*
  261. * iommu_table_setparms_lpar
  262. *
  263. * Function: On pSeries LPAR systems, return TCE table info, given a pci bus.
  264. */
  265. static void iommu_table_setparms_lpar(struct pci_controller *phb,
  266. struct device_node *dn,
  267. struct iommu_table *tbl,
  268. const void *dma_window,
  269. int bussubno)
  270. {
  271. unsigned long offset, size;
  272. tbl->it_busno = bussubno;
  273. of_parse_dma_window(dn, dma_window, &tbl->it_index, &offset, &size);
  274. tbl->it_base = 0;
  275. tbl->it_blocksize = 16;
  276. tbl->it_type = TCE_PCI;
  277. tbl->it_offset = offset >> IOMMU_PAGE_SHIFT;
  278. tbl->it_size = size >> IOMMU_PAGE_SHIFT;
  279. }
  280. static void pci_dma_bus_setup_pSeries(struct pci_bus *bus)
  281. {
  282. struct device_node *dn;
  283. struct iommu_table *tbl;
  284. struct device_node *isa_dn, *isa_dn_orig;
  285. struct device_node *tmp;
  286. struct pci_dn *pci;
  287. int children;
  288. dn = pci_bus_to_OF_node(bus);
  289. pr_debug("pci_dma_bus_setup_pSeries: setting up bus %s\n", dn->full_name);
  290. if (bus->self) {
  291. /* This is not a root bus, any setup will be done for the
  292. * device-side of the bridge in iommu_dev_setup_pSeries().
  293. */
  294. return;
  295. }
  296. pci = PCI_DN(dn);
  297. /* Check if the ISA bus on the system is under
  298. * this PHB.
  299. */
  300. isa_dn = isa_dn_orig = of_find_node_by_type(NULL, "isa");
  301. while (isa_dn && isa_dn != dn)
  302. isa_dn = isa_dn->parent;
  303. if (isa_dn_orig)
  304. of_node_put(isa_dn_orig);
  305. /* Count number of direct PCI children of the PHB. */
  306. for (children = 0, tmp = dn->child; tmp; tmp = tmp->sibling)
  307. children++;
  308. pr_debug("Children: %d\n", children);
  309. /* Calculate amount of DMA window per slot. Each window must be
  310. * a power of two (due to pci_alloc_consistent requirements).
  311. *
  312. * Keep 256MB aside for PHBs with ISA.
  313. */
  314. if (!isa_dn) {
  315. /* No ISA/IDE - just set window size and return */
  316. pci->phb->dma_window_size = 0x80000000ul; /* To be divided */
  317. while (pci->phb->dma_window_size * children > 0x80000000ul)
  318. pci->phb->dma_window_size >>= 1;
  319. pr_debug("No ISA/IDE, window size is 0x%lx\n",
  320. pci->phb->dma_window_size);
  321. pci->phb->dma_window_base_cur = 0;
  322. return;
  323. }
  324. /* If we have ISA, then we probably have an IDE
  325. * controller too. Allocate a 128MB table but
  326. * skip the first 128MB to avoid stepping on ISA
  327. * space.
  328. */
  329. pci->phb->dma_window_size = 0x8000000ul;
  330. pci->phb->dma_window_base_cur = 0x8000000ul;
  331. tbl = kmalloc_node(sizeof(struct iommu_table), GFP_KERNEL,
  332. pci->phb->node);
  333. iommu_table_setparms(pci->phb, dn, tbl);
  334. pci->iommu_table = iommu_init_table(tbl, pci->phb->node);
  335. /* Divide the rest (1.75GB) among the children */
  336. pci->phb->dma_window_size = 0x80000000ul;
  337. while (pci->phb->dma_window_size * children > 0x70000000ul)
  338. pci->phb->dma_window_size >>= 1;
  339. pr_debug("ISA/IDE, window size is 0x%lx\n", pci->phb->dma_window_size);
  340. }
  341. static void pci_dma_bus_setup_pSeriesLP(struct pci_bus *bus)
  342. {
  343. struct iommu_table *tbl;
  344. struct device_node *dn, *pdn;
  345. struct pci_dn *ppci;
  346. const void *dma_window = NULL;
  347. dn = pci_bus_to_OF_node(bus);
  348. pr_debug("pci_dma_bus_setup_pSeriesLP: setting up bus %s\n",
  349. dn->full_name);
  350. /* Find nearest ibm,dma-window, walking up the device tree */
  351. for (pdn = dn; pdn != NULL; pdn = pdn->parent) {
  352. dma_window = of_get_property(pdn, "ibm,dma-window", NULL);
  353. if (dma_window != NULL)
  354. break;
  355. }
  356. if (dma_window == NULL) {
  357. pr_debug(" no ibm,dma-window property !\n");
  358. return;
  359. }
  360. ppci = PCI_DN(pdn);
  361. pr_debug(" parent is %s, iommu_table: 0x%p\n",
  362. pdn->full_name, ppci->iommu_table);
  363. if (!ppci->iommu_table) {
  364. tbl = kmalloc_node(sizeof(struct iommu_table), GFP_KERNEL,
  365. ppci->phb->node);
  366. iommu_table_setparms_lpar(ppci->phb, pdn, tbl, dma_window,
  367. bus->number);
  368. ppci->iommu_table = iommu_init_table(tbl, ppci->phb->node);
  369. pr_debug(" created table: %p\n", ppci->iommu_table);
  370. }
  371. if (pdn != dn)
  372. PCI_DN(dn)->iommu_table = ppci->iommu_table;
  373. }
  374. static void pci_dma_dev_setup_pSeries(struct pci_dev *dev)
  375. {
  376. struct device_node *dn;
  377. struct iommu_table *tbl;
  378. pr_debug("pci_dma_dev_setup_pSeries: %s\n", pci_name(dev));
  379. dn = dev->dev.archdata.of_node;
  380. /* If we're the direct child of a root bus, then we need to allocate
  381. * an iommu table ourselves. The bus setup code should have setup
  382. * the window sizes already.
  383. */
  384. if (!dev->bus->self) {
  385. struct pci_controller *phb = PCI_DN(dn)->phb;
  386. pr_debug(" --> first child, no bridge. Allocating iommu table.\n");
  387. tbl = kmalloc_node(sizeof(struct iommu_table), GFP_KERNEL,
  388. phb->node);
  389. iommu_table_setparms(phb, dn, tbl);
  390. PCI_DN(dn)->iommu_table = iommu_init_table(tbl, phb->node);
  391. dev->dev.archdata.dma_data = PCI_DN(dn)->iommu_table;
  392. return;
  393. }
  394. /* If this device is further down the bus tree, search upwards until
  395. * an already allocated iommu table is found and use that.
  396. */
  397. while (dn && PCI_DN(dn) && PCI_DN(dn)->iommu_table == NULL)
  398. dn = dn->parent;
  399. if (dn && PCI_DN(dn))
  400. dev->dev.archdata.dma_data = PCI_DN(dn)->iommu_table;
  401. else
  402. printk(KERN_WARNING "iommu: Device %s has no iommu table\n",
  403. pci_name(dev));
  404. }
  405. static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
  406. {
  407. struct device_node *pdn, *dn;
  408. struct iommu_table *tbl;
  409. const void *dma_window = NULL;
  410. struct pci_dn *pci;
  411. pr_debug("pci_dma_dev_setup_pSeriesLP: %s\n", pci_name(dev));
  412. /* dev setup for LPAR is a little tricky, since the device tree might
  413. * contain the dma-window properties per-device and not neccesarily
  414. * for the bus. So we need to search upwards in the tree until we
  415. * either hit a dma-window property, OR find a parent with a table
  416. * already allocated.
  417. */
  418. dn = pci_device_to_OF_node(dev);
  419. pr_debug(" node is %s\n", dn->full_name);
  420. for (pdn = dn; pdn && PCI_DN(pdn) && !PCI_DN(pdn)->iommu_table;
  421. pdn = pdn->parent) {
  422. dma_window = of_get_property(pdn, "ibm,dma-window", NULL);
  423. if (dma_window)
  424. break;
  425. }
  426. if (!pdn || !PCI_DN(pdn)) {
  427. printk(KERN_WARNING "pci_dma_dev_setup_pSeriesLP: "
  428. "no DMA window found for pci dev=%s dn=%s\n",
  429. pci_name(dev), dn? dn->full_name : "<null>");
  430. return;
  431. }
  432. pr_debug(" parent is %s\n", pdn->full_name);
  433. /* Check for parent == NULL so we don't try to setup the empty EADS
  434. * slots on POWER4 machines.
  435. */
  436. if (dma_window == NULL || pdn->parent == NULL) {
  437. pr_debug(" no dma window for device, linking to parent\n");
  438. dev->dev.archdata.dma_data = PCI_DN(pdn)->iommu_table;
  439. return;
  440. }
  441. pci = PCI_DN(pdn);
  442. if (!pci->iommu_table) {
  443. tbl = kmalloc_node(sizeof(struct iommu_table), GFP_KERNEL,
  444. pci->phb->node);
  445. iommu_table_setparms_lpar(pci->phb, pdn, tbl, dma_window,
  446. pci->phb->bus->number);
  447. pci->iommu_table = iommu_init_table(tbl, pci->phb->node);
  448. pr_debug(" created table: %p\n", pci->iommu_table);
  449. } else {
  450. pr_debug(" found DMA window, table: %p\n", pci->iommu_table);
  451. }
  452. dev->dev.archdata.dma_data = pci->iommu_table;
  453. }
  454. #else /* CONFIG_PCI */
  455. #define pci_dma_bus_setup_pSeries NULL
  456. #define pci_dma_dev_setup_pSeries NULL
  457. #define pci_dma_bus_setup_pSeriesLP NULL
  458. #define pci_dma_dev_setup_pSeriesLP NULL
  459. #endif /* !CONFIG_PCI */
  460. static int iommu_reconfig_notifier(struct notifier_block *nb, unsigned long action, void *node)
  461. {
  462. int err = NOTIFY_OK;
  463. struct device_node *np = node;
  464. struct pci_dn *pci = PCI_DN(np);
  465. switch (action) {
  466. case PSERIES_RECONFIG_REMOVE:
  467. if (pci && pci->iommu_table &&
  468. of_get_property(np, "ibm,dma-window", NULL))
  469. iommu_free_table(pci->iommu_table, np->full_name);
  470. break;
  471. default:
  472. err = NOTIFY_DONE;
  473. break;
  474. }
  475. return err;
  476. }
  477. static struct notifier_block iommu_reconfig_nb = {
  478. .notifier_call = iommu_reconfig_notifier,
  479. };
  480. /* These are called very early. */
  481. void iommu_init_early_pSeries(void)
  482. {
  483. if (of_chosen && of_get_property(of_chosen, "linux,iommu-off", NULL)) {
  484. /* Direct I/O, IOMMU off */
  485. ppc_md.pci_dma_dev_setup = NULL;
  486. ppc_md.pci_dma_bus_setup = NULL;
  487. set_pci_dma_ops(&dma_direct_ops);
  488. return;
  489. }
  490. if (firmware_has_feature(FW_FEATURE_LPAR)) {
  491. if (firmware_has_feature(FW_FEATURE_MULTITCE)) {
  492. ppc_md.tce_build = tce_buildmulti_pSeriesLP;
  493. ppc_md.tce_free = tce_freemulti_pSeriesLP;
  494. } else {
  495. ppc_md.tce_build = tce_build_pSeriesLP;
  496. ppc_md.tce_free = tce_free_pSeriesLP;
  497. }
  498. ppc_md.tce_get = tce_get_pSeriesLP;
  499. ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_pSeriesLP;
  500. ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_pSeriesLP;
  501. } else {
  502. ppc_md.tce_build = tce_build_pSeries;
  503. ppc_md.tce_free = tce_free_pSeries;
  504. ppc_md.tce_get = tce_get_pseries;
  505. ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_pSeries;
  506. ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_pSeries;
  507. }
  508. pSeries_reconfig_notifier_register(&iommu_reconfig_nb);
  509. set_pci_dma_ops(&dma_iommu_ops);
  510. }