Skip to content

Commit 6d560f6

Browse files
author
Fox Snowpatch
committed
1 parent 35d5936 commit 6d560f6

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

arch/powerpc/include/asm/ppc-pci.h

+10
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ void *pci_traverse_device_nodes(struct device_node *start,
3030
void *data);
3131
extern void pci_devs_phb_init_dynamic(struct pci_controller *phb);
3232

33+
#if defined(CONFIG_IOMMU_API) && (defined(CONFIG_PPC_PSERIES) || \
34+
defined(CONFIG_PPC_POWERNV))
35+
extern void ppc_iommu_register_device(struct pci_controller *phb);
36+
extern void ppc_iommu_unregister_device(struct pci_controller *phb);
37+
#else
38+
static inline void ppc_iommu_register_device(struct pci_controller *phb) { }
39+
static inline void ppc_iommu_unregister_device(struct pci_controller *phb) { }
40+
#endif
41+
42+
3343
/* From rtas_pci.h */
3444
extern void init_pci_config_tokens (void);
3545
extern unsigned long get_phb_buid (struct device_node *);

arch/powerpc/kernel/iommu.c

+17-6
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ static struct iommu_device *spapr_tce_iommu_probe_device(struct device *dev)
13601360
struct pci_controller *hose;
13611361

13621362
if (!dev_is_pci(dev))
1363-
return ERR_PTR(-EPERM);
1363+
return ERR_PTR(-ENODEV);
13641364

13651365
pdev = to_pci_dev(dev);
13661366
hose = pdev->bus->sysdata;
@@ -1409,6 +1409,21 @@ static const struct attribute_group *spapr_tce_iommu_groups[] = {
14091409
NULL,
14101410
};
14111411

1412+
void ppc_iommu_register_device(struct pci_controller *phb)
1413+
{
1414+
iommu_device_sysfs_add(&phb->iommu, phb->parent,
1415+
spapr_tce_iommu_groups, "iommu-phb%04x",
1416+
phb->global_number);
1417+
iommu_device_register(&phb->iommu, &spapr_tce_iommu_ops,
1418+
phb->parent);
1419+
}
1420+
1421+
void ppc_iommu_unregister_device(struct pci_controller *phb)
1422+
{
1423+
iommu_device_unregister(&phb->iommu);
1424+
iommu_device_sysfs_remove(&phb->iommu);
1425+
}
1426+
14121427
/*
14131428
* This registers IOMMU devices of PHBs. This needs to happen
14141429
* after core_initcall(iommu_init) + postcore_initcall(pci_driver_init) and
@@ -1419,11 +1434,7 @@ static int __init spapr_tce_setup_phb_iommus_initcall(void)
14191434
struct pci_controller *hose;
14201435

14211436
list_for_each_entry(hose, &hose_list, list_node) {
1422-
iommu_device_sysfs_add(&hose->iommu, hose->parent,
1423-
spapr_tce_iommu_groups, "iommu-phb%04x",
1424-
hose->global_number);
1425-
iommu_device_register(&hose->iommu, &spapr_tce_iommu_ops,
1426-
hose->parent);
1437+
ppc_iommu_register_device(hose);
14271438
}
14281439
return 0;
14291440
}

arch/powerpc/platforms/pseries/pci_dlpar.c

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ struct pci_controller *init_phb_dynamic(struct device_node *dn)
3535

3636
pseries_msi_allocate_domains(phb);
3737

38+
ppc_iommu_register_device(phb);
39+
3840
/* Create EEH devices for the PHB */
3941
eeh_phb_pe_create(phb);
4042

@@ -76,6 +78,8 @@ int remove_phb_dynamic(struct pci_controller *phb)
7678
}
7779
}
7880

81+
ppc_iommu_unregister_device(phb);
82+
7983
pseries_msi_free_domains(phb);
8084

8185
/* Keep a reference so phb isn't freed yet */

0 commit comments

Comments
 (0)