compound_group->pgsizes = pe->table_group.pgsizes;
        }
 
+       /*
+       * I'm not sure this is strictly required, but it's probably a good idea
+       * since the table_group for the PE is going to be attached to the
+       * compound table group. If we leave the PE's iommu group active then
+       * we might have the same table_group being modifiable via two sepeate
+       * iommu groups.
+       */
+       iommu_group_put(pe->table_group.group);
+
        pnv_comp_attach_table_group(npucomp, pe);
 
        return compound_group;
 
                }
 
                pnv_pci_ioda2_setup_dma_pe(phb, pe);
-#ifdef CONFIG_IOMMU_API
-               iommu_register_group(&pe->table_group,
-                               pe->phb->hose->global_number, pe->pe_number);
-#endif
        }
 }
 
                                        continue;
 
                                table_group = &pe->table_group;
-                               iommu_register_group(&pe->table_group,
-                                               pe->phb->hose->global_number,
-                                               pe->pe_number);
                        }
                        pnv_ioda_setup_bus_iommu_group(pe, table_group,
                                        pe->pbus);
                        IOMMU_TABLE_GROUP_MAX_TABLES;
        pe->table_group.max_levels = POWERNV_IOMMU_MAX_LEVELS;
        pe->table_group.pgsizes = pnv_ioda_parse_tce_sizes(phb);
-#ifdef CONFIG_IOMMU_API
-       pe->table_group.ops = &pnv_pci_ioda2_ops;
-#endif
 
        rc = pnv_pci_ioda2_setup_default_config(pe);
        if (rc)
                return;
 
+#ifdef CONFIG_IOMMU_API
+       pe->table_group.ops = &pnv_pci_ioda2_ops;
+       iommu_register_group(&pe->table_group, phb->hose->global_number,
+                            pe->pe_number);
+#endif
+
        if (pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL))
                pnv_ioda_setup_bus_dma(pe, pe->pbus);
 }