iommu.c (285eba57db7bd7d7c3c5929fb8621fdcaaea1b00) iommu.c (95f72d1ed41a66f1c1c29c24d479de81a0bea36f)
1/*
2 * IOMMU implementation for Cell Broadband Processor Architecture
3 *
4 * (C) Copyright IBM Corporation 2006-2008
5 *
6 * Author: Jeremy Kerr <jk@ozlabs.org>
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 15 unchanged lines hidden (view full) ---

24
25#include <linux/kernel.h>
26#include <linux/init.h>
27#include <linux/interrupt.h>
28#include <linux/notifier.h>
29#include <linux/of.h>
30#include <linux/of_platform.h>
31#include <linux/slab.h>
1/*
2 * IOMMU implementation for Cell Broadband Processor Architecture
3 *
4 * (C) Copyright IBM Corporation 2006-2008
5 *
6 * Author: Jeremy Kerr <jk@ozlabs.org>
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 15 unchanged lines hidden (view full) ---

24
25#include <linux/kernel.h>
26#include <linux/init.h>
27#include <linux/interrupt.h>
28#include <linux/notifier.h>
29#include <linux/of.h>
30#include <linux/of_platform.h>
31#include <linux/slab.h>
32#include <linux/lmb.h>
32#include <linux/memblock.h>
33
34#include <asm/prom.h>
35#include <asm/iommu.h>
36#include <asm/machdep.h>
37#include <asm/pci-bridge.h>
38#include <asm/udbg.h>
39#include <asm/firmware.h>
40#include <asm/cell-regs.h>

--- 799 unchanged lines hidden (view full) ---

840 break;
841 }
842 }
843 of_node_put(np);
844
845 /* If we found a DMA window, we check if it's big enough to enclose
846 * all of physical memory. If not, we force enable IOMMU
847 */
33
34#include <asm/prom.h>
35#include <asm/iommu.h>
36#include <asm/machdep.h>
37#include <asm/pci-bridge.h>
38#include <asm/udbg.h>
39#include <asm/firmware.h>
40#include <asm/cell-regs.h>

--- 799 unchanged lines hidden (view full) ---

840 break;
841 }
842 }
843 of_node_put(np);
844
845 /* If we found a DMA window, we check if it's big enough to enclose
846 * all of physical memory. If not, we force enable IOMMU
847 */
848 if (np && size < lmb_end_of_DRAM()) {
848 if (np && size < memblock_end_of_DRAM()) {
849 printk(KERN_WARNING "iommu: force-enabled, dma window"
850 " (%ldMB) smaller than total memory (%lldMB)\n",
849 printk(KERN_WARNING "iommu: force-enabled, dma window"
850 " (%ldMB) smaller than total memory (%lldMB)\n",
851 size >> 20, lmb_end_of_DRAM() >> 20);
851 size >> 20, memblock_end_of_DRAM() >> 20);
852 return -ENODEV;
853 }
854
855 cell_dma_direct_offset += base;
856
857 if (cell_dma_direct_offset != 0)
858 ppc_md.pci_dma_dev_setup = cell_pci_dma_dev_setup;
859

--- 199 unchanged lines hidden (view full) ---

1059 */
1060 fbase = 0;
1061 for_each_node_by_name(np, "axon") {
1062 cell_iommu_get_window(np, &dbase, &dsize);
1063 fbase = max(fbase, dbase + dsize);
1064 }
1065
1066 fbase = _ALIGN_UP(fbase, 1 << IO_SEGMENT_SHIFT);
852 return -ENODEV;
853 }
854
855 cell_dma_direct_offset += base;
856
857 if (cell_dma_direct_offset != 0)
858 ppc_md.pci_dma_dev_setup = cell_pci_dma_dev_setup;
859

--- 199 unchanged lines hidden (view full) ---

1059 */
1060 fbase = 0;
1061 for_each_node_by_name(np, "axon") {
1062 cell_iommu_get_window(np, &dbase, &dsize);
1063 fbase = max(fbase, dbase + dsize);
1064 }
1065
1066 fbase = _ALIGN_UP(fbase, 1 << IO_SEGMENT_SHIFT);
1067 fsize = lmb_phys_mem_size();
1067 fsize = memblock_phys_mem_size();
1068
1069 if ((fbase + fsize) <= 0x800000000ul)
1070 hbase = 0; /* use the device tree window */
1071 else {
1072 /* If we're over 32 GB we need to cheat. We can't map all of
1073 * RAM with the fixed mapping, and also fit the dynamic
1074 * region. So try to place the dynamic region where the hash
1075 * table sits, drivers never need to DMA to it, we don't

--- 88 unchanged lines hidden (view full) ---

1164 struct device_node *np;
1165
1166 /* If IOMMU is disabled or we have little enough RAM to not need
1167 * to enable it, we setup a direct mapping.
1168 *
1169 * Note: should we make sure we have the IOMMU actually disabled ?
1170 */
1171 if (iommu_is_off ||
1068
1069 if ((fbase + fsize) <= 0x800000000ul)
1070 hbase = 0; /* use the device tree window */
1071 else {
1072 /* If we're over 32 GB we need to cheat. We can't map all of
1073 * RAM with the fixed mapping, and also fit the dynamic
1074 * region. So try to place the dynamic region where the hash
1075 * table sits, drivers never need to DMA to it, we don't

--- 88 unchanged lines hidden (view full) ---

1164 struct device_node *np;
1165
1166 /* If IOMMU is disabled or we have little enough RAM to not need
1167 * to enable it, we setup a direct mapping.
1168 *
1169 * Note: should we make sure we have the IOMMU actually disabled ?
1170 */
1171 if (iommu_is_off ||
1172 (!iommu_force_on && lmb_end_of_DRAM() <= 0x80000000ull))
1172 (!iommu_force_on && memblock_end_of_DRAM() <= 0x80000000ull))
1173 if (cell_iommu_init_disabled() == 0)
1174 goto bail;
1175
1176 /* Setup various ppc_md. callbacks */
1177 ppc_md.pci_dma_dev_setup = cell_pci_dma_dev_setup;
1178 ppc_md.tce_build = tce_build_cell;
1179 ppc_md.tce_free = tce_free_cell;
1180

--- 33 unchanged lines hidden ---
1173 if (cell_iommu_init_disabled() == 0)
1174 goto bail;
1175
1176 /* Setup various ppc_md. callbacks */
1177 ppc_md.pci_dma_dev_setup = cell_pci_dma_dev_setup;
1178 ppc_md.tce_build = tce_build_cell;
1179 ppc_md.tce_free = tce_free_cell;
1180

--- 33 unchanged lines hidden ---