iommu.c 17 KB

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