]> err.no Git - linux-2.6/blobdiff - arch/powerpc/platforms/pseries/iommu.c
[PATCH] powerpc: Replace platform_is_lpar() with a firmware feature
[linux-2.6] / arch / powerpc / platforms / pseries / iommu.c
index c78f2b290a73a52b90356f32f54af51569227796..2643078433f0123f8997c7f98823934e7b1feadb 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * arch/ppc64/kernel/pSeries_iommu.c
- *
  * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation
  *
  * Rewrite, cleanup: 
@@ -51,8 +49,6 @@
 
 #define DBG(fmt...)
 
-extern int is_python(struct device_node *);
-
 static void tce_build_pSeries(struct iommu_table *tbl, long index, 
                              long npages, unsigned long uaddr, 
                              enum dma_data_direction direction)
@@ -109,6 +105,9 @@ static void tce_build_pSeriesLP(struct iommu_table *tbl, long tcenum,
        u64 rc;
        union tce_entry tce;
 
+       tcenum <<= TCE_PAGE_FACTOR;
+       npages <<= TCE_PAGE_FACTOR;
+
        tce.te_word = 0;
        tce.te_rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT;
        tce.te_rdwr = 1;
@@ -143,10 +142,7 @@ static void tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
        union tce_entry tce, *tcep;
        long l, limit;
 
-       tcenum <<= TCE_PAGE_FACTOR;
-       npages <<= TCE_PAGE_FACTOR;
-
-       if (npages == 1)
+       if (TCE_PAGE_FACTOR == 0 && npages == 1)
                return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr,
                                           direction);
 
@@ -164,6 +160,9 @@ static void tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
                __get_cpu_var(tce_page) = tcep;
        }
 
+       tcenum <<= TCE_PAGE_FACTOR;
+       npages <<= TCE_PAGE_FACTOR;
+
        tce.te_word = 0;
        tce.te_rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT;
        tce.te_rdwr = 1;
@@ -433,7 +432,7 @@ static void iommu_bus_setup_pSeriesLP(struct pci_bus *bus)
                return;
        }
 
-       ppci = pdn->data;
+       ppci = PCI_DN(pdn);
        if (!ppci->iommu_table) {
                /* Bussubno hasn't been copied yet.
                 * Do it now because iommu_table_setparms_lpar needs it.
@@ -480,10 +479,10 @@ static void iommu_dev_setup_pSeries(struct pci_dev *dev)
         * an already allocated iommu table is found and use that.
         */
 
-       while (dn && dn->data && PCI_DN(dn)->iommu_table == NULL)
+       while (dn && PCI_DN(dn) && PCI_DN(dn)->iommu_table == NULL)
                dn = dn->parent;
 
-       if (dn && dn->data) {
+       if (dn && PCI_DN(dn)) {
                PCI_DN(mydn)->iommu_table = PCI_DN(dn)->iommu_table;
        } else {
                DBG("iommu_dev_setup_pSeries, dev %p (%s) has no iommu table\n", dev, pci_name(dev));
@@ -494,7 +493,7 @@ static int iommu_reconfig_notifier(struct notifier_block *nb, unsigned long acti
 {
        int err = NOTIFY_OK;
        struct device_node *np = node;
-       struct pci_dn *pci = np->data;
+       struct pci_dn *pci = PCI_DN(np);
 
        switch (action) {
        case PSERIES_RECONFIG_REMOVE:
@@ -530,7 +529,7 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev)
         */
        dn = pci_device_to_OF_node(dev);
 
-       for (pdn = dn; pdn && pdn->data && !PCI_DN(pdn)->iommu_table;
+       for (pdn = dn; pdn && PCI_DN(pdn) && !PCI_DN(pdn)->iommu_table;
             pdn = pdn->parent) {
                dma_window = (unsigned int *)
                        get_property(pdn, "ibm,dma-window", NULL);
@@ -549,7 +548,7 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev)
                DBG("Found DMA window, allocating table\n");
        }
 
-       pci = pdn->data;
+       pci = PCI_DN(pdn);
        if (!pci->iommu_table) {
                /* iommu_table_setparms_lpar needs bussubno. */
                pci->bussubno = pci->phb->bus->number;
@@ -581,7 +580,7 @@ void iommu_init_early_pSeries(void)
                return;
        }
 
-       if (platform_is_lpar()) {
+       if (firmware_has_feature(FW_FEATURE_LPAR)) {
                if (firmware_has_feature(FW_FEATURE_MULTITCE)) {
                        ppc_md.tce_build = tce_buildmulti_pSeriesLP;
                        ppc_md.tce_free  = tce_freemulti_pSeriesLP;