Skip to contentSkip to conversation

powernv: fix VFIO support with PHB3

PATCH In review Thadeu Lima de Souza Cascardo 2 participants 3 messages Dec 6, 2013 – Dec 7, 2013 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powernv: fix VFIO support with PHB3

I have recently found out that no iommu_groups could be found under /sys/ on a P8. That prevents PCI passthrough from working.

During my investigation, I found out there seems to be a missing iommu_register_group for PHB3. The following patch seems to fix the problem. After applying it, I see iommu_groups under /sys/kernel/iommu_groups/, and can also bind vfio-pci to an adapter, which gives me a device at /dev/vfio/.

---
 arch/powerpc/platforms/powernv/pci-ioda.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/powerpc/platforms/powernv/pci-ioda.c +1 -0
index 084cdfa..2c6d173 100644
@@ -720,6 +720,7 @@ static void pnv_pci_ioda2_setup_dma_pe(struct pnv_phb *phb,
 		tbl->it_type = TCE_PCI_SWINV_CREATE | TCE_PCI_SWINV_FREE;
 	}
 	iommu_init_table(tbl, phb->hose->node);
+	iommu_register_group(tbl, pci_domain_nr(pe->pbus), pe->pe_number);
 
 	if (pe->pdev)
 		set_iommu_table_base(&pe->pdev->dev, tbl);
Signature · 1 line
1.7.1
#1 lore raw
Quoted 19 lines · Thadeu Lima de Souza Cascardo

I have recently found out that no iommu_groups could be found under /sys/ on a P8. That prevents PCI passthrough from working.

During my investigation, I found out there seems to be a missing iommu_register_group for PHB3. The following patch seems to fix the problem. After applying it, I see iommu_groups under /sys/kernel/iommu_groups/, and can also bind vfio-pci to an adapter, which gives me a device at /dev/vfio/.

---
 arch/powerpc/platforms/powernv/pci-ioda.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/powerpc/platforms/powernv/pci-ioda.c +0 -0
index 084cdfa..2c6d173 100644

arch/powerpc/platforms/powernv/pci-ioda.c static void pnv_pci_ioda2_setup_dma_pe(struct pnv_phb *phb, · line 726

Quoted 7 lines
arch/powerpc/platforms/powernv/pci-ioda.c +1 -0
@@ -720,6 +720,7 @@ static void pnv_pci_ioda2_setup_dma_pe(struct pnv_phb *phb,
 		tbl->it_type = TCE_PCI_SWINV_CREATE | TCE_PCI_SWINV_FREE;
 	}
 	iommu_init_table(tbl, phb->hose->node);
+	iommu_register_group(tbl, pci_domain_nr(pe->pbus), pe->pe_number);
 
 	if (pe->pdev)
 		set_iommu_table_base(&pe->pdev->dev, tbl);

This does not seem absolutely right - normally set_iommu_table_base() is replaced with set_iommu_table_base_and_group() or you will not see some devices in a group and this may make VFIO unhappy.

But - if every single device gets assigned to some group, then we can push this to Frobisher and let people test in on power8.

Signature · 1 line
Alexey
#2 lore raw
Quoted 25 lines · Alexey Kardashevskiy
Quoted 24 lines · Thadeu Lima de Souza Cascardo

I have recently found out that no iommu_groups could be found under /sys/ on a P8. That prevents PCI passthrough from working.

During my investigation, I found out there seems to be a missing iommu_register_group for PHB3. The following patch seems to fix the problem. After applying it, I see iommu_groups under /sys/kernel/iommu_groups/, and can also bind vfio-pci to an adapter, which gives me a device at /dev/vfio/.

---
 arch/powerpc/platforms/powernv/pci-ioda.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/powerpc/platforms/powernv/pci-ioda.c +1 -0
index 084cdfa..2c6d173 100644
@@ -720,6 +720,7 @@ static void pnv_pci_ioda2_setup_dma_pe(struct pnv_phb *phb,
 		tbl->it_type = TCE_PCI_SWINV_CREATE | TCE_PCI_SWINV_FREE;
 	}
 	iommu_init_table(tbl, phb->hose->node);
+	iommu_register_group(tbl, pci_domain_nr(pe->pbus), pe->pe_number);
 
Quoted 7 lines

arch/powerpc/platforms/powernv/pci-ioda.c static void pnv_pci_ioda2_setup_dma_pe(struct pnv_phb *phb, · line 726

Quoted 2 lines
arch/powerpc/platforms/powernv/pci-ioda.c +0 -0
 	if (pe->pdev)
 		set_iommu_table_base(&pe->pdev->dev, tbl);

This does not seem absolutely right - normally set_iommu_table_base() is replaced with set_iommu_table_base_and_group() or you will not see some devices in a group and this may make VFIO unhappy.

Alexey,

Your patch "[PATCH v9] PPC: POWERNV: move iommu_add_device earlier" is not upstream yet. It calls set_iommu_table_base_and_group properly. However, without calling iommu_register_group, there is no group to add the device to.

Compare to pnv_pci_ioda_setup_dma_pe which calls iommu_register_group too. My patch fixes this discrepancy between IODA and IODA2.

Regards.
Cascardo.

Quoted 8 lines

But - if every single device gets assigned to some group, then we can push this to Frobisher and let people test in on power8.

Signature · 1 line
Alexey