Message ID | 20140522230845.2856.95844.stgit@bling.home (mailing list archive) |
---|---|
State | New, archived |
Delegated to: | Bjorn Helgaas |
Headers | show |
DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogQWxleCBXaWxsaWFtc29u IFttYWlsdG86YWxleC53aWxsaWFtc29uQHJlZGhhdC5jb21dDQo+IFNlbnQ6IEZyaWRheSwgTWF5 IDIzLCAyMDE0IDQ6MzkgQU0NCj4gVG86IGxpbnV4LXBjaUB2Z2VyLmtlcm5lbC5vcmc7IGlvbW11 QGxpc3RzLmxpbnV4LWZvdW5kYXRpb24ub3JnDQo+IENjOiBsaW51eC1rZXJuZWxAdmdlci5rZXJu ZWwub3JnOyBhY29va3NAZ21haWwuY29tOyBsaW51eEBob3Jpem9uLmNvbTsNCj4gYmhlbGdhYXNA Z29vZ2xlLmNvbTsgU2V0aGkgVmFydW4tQjE2Mzk1OyBlZGR5MDU5NkBnbWFpbC5jb20NCj4gU3Vi amVjdDogW1BBVENIIHY0IDEzLzE2XSBpb21tdS9mc2w6IFVzZSBpb21tdV9ncm91cF9nZXRfZm9y X2RldigpIGZvcg0KPiBJT01NVSBncm91cHMNCj4gDQo+IERyb3AgY3VzdG9tIGNvZGUgYW5kIHVz ZSBJT01NVSBwcm92aWRlZCBncm91cGluZyBzdXBwb3J0IGZvciBQQ0kuDQo+IA0KPiBTaWduZWQt b2ZmLWJ5OiBBbGV4IFdpbGxpYW1zb24gPGFsZXgud2lsbGlhbXNvbkByZWRoYXQuY29tPg0KPiBD YzogVmFydW4gU2V0aGkgPHZhcnVuLnNldGhpQGZyZWVzY2FsZS5jb20+DQo+IC0tLQ0KPiAgZHJp dmVycy9pb21tdS9mc2xfcGFtdV9kb21haW4uYyB8ICAgNjYgKy0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tDQo+IC0tLS0tLQ0KPiAgMSBmaWxlIGNoYW5nZWQsIDEgaW5zZXJ0aW9uKCsp L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kJICogUENJZSBjb250cm9sbGVyIGlzIG5vdCBhIHBhcml0aW9uYWJsZSBlbnRpdHkN Cj4gIAkJICogZnJlZSB0aGUgY29udHJvbGxlciBkZXZpY2UgaW9tbXVfZ3JvdXAuDQpBY2tub3ds ZWRnZWQtYnk6IFZhcnVuIFNldGhpIDx2YXJ1bi5zZXRoaUBmcmVlc2NhbGUuY29tPg0K -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c index 93072ba..d02d668 100644 --- a/drivers/iommu/fsl_pamu_domain.c +++ b/drivers/iommu/fsl_pamu_domain.c @@ -38,7 +38,6 @@ #include <sysdev/fsl_pci.h> #include "fsl_pamu_domain.h" -#include "pci.h" /* * Global spinlock that needs to be held while @@ -892,8 +891,6 @@ static int fsl_pamu_get_domain_attr(struct iommu_domain *domain, return ret; } -#define REQ_ACS_FLAGS (PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF) - static struct iommu_group *get_device_iommu_group(struct device *dev) { struct iommu_group *group; @@ -950,74 +947,13 @@ static struct iommu_group *get_pci_device_group(struct pci_dev *pdev) struct pci_controller *pci_ctl; bool pci_endpt_partioning; struct iommu_group *group = NULL; - struct pci_dev *bridge, *dma_pdev = NULL; pci_ctl = pci_bus_to_host(pdev->bus); pci_endpt_partioning = check_pci_ctl_endpt_part(pci_ctl); /* We can partition PCIe devices so assign device group to the device */ if (pci_endpt_partioning) { - bridge = pci_find_upstream_pcie_bridge(pdev); - if (bridge) { - if (pci_is_pcie(bridge)) - dma_pdev = pci_get_domain_bus_and_slot( - pci_domain_nr(pdev->bus), - bridge->subordinate->number, 0); - if (!dma_pdev) - dma_pdev = pci_dev_get(bridge); - } else - dma_pdev = pci_dev_get(pdev); - - /* Account for quirked devices */ - swap_pci_ref(&dma_pdev, pci_get_dma_source(dma_pdev)); - - /* - * If it's a multifunction device that does not support our - * required ACS flags, add to the same group as lowest numbered - * function that also does not suport the required ACS flags. - */ - if (dma_pdev->multifunction && - !pci_acs_enabled(dma_pdev, REQ_ACS_FLAGS)) { - u8 i, slot = PCI_SLOT(dma_pdev->devfn); - - for (i = 0; i < 8; i++) { - struct pci_dev *tmp; - - tmp = pci_get_slot(dma_pdev->bus, PCI_DEVFN(slot, i)); - if (!tmp) - continue; - - if (!pci_acs_enabled(tmp, REQ_ACS_FLAGS)) { - swap_pci_ref(&dma_pdev, tmp); - break; - } - pci_dev_put(tmp); - } - } - - /* - * Devices on the root bus go through the iommu. If that's not us, - * find the next upstream device and test ACS up to the root bus. - * Finding the next device may require skipping virtual buses. - */ - while (!pci_is_root_bus(dma_pdev->bus)) { - struct pci_bus *bus = dma_pdev->bus; - - while (!bus->self) { - if (!pci_is_root_bus(bus)) - bus = bus->parent; - else - goto root_bus; - } - - if (pci_acs_path_enabled(bus->self, NULL, REQ_ACS_FLAGS)) - break; - - swap_pci_ref(&dma_pdev, pci_dev_get(bus->self)); - } + group = iommu_group_get_for_dev(&pdev->dev); -root_bus: - group = get_device_iommu_group(&dma_pdev->dev); - pci_dev_put(dma_pdev); /* * PCIe controller is not a paritionable entity * free the controller device iommu_group.
Drop custom code and use IOMMU provided grouping support for PCI. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Cc: Varun Sethi <varun.sethi@freescale.com> --- drivers/iommu/fsl_pamu_domain.c | 66 +-------------------------------------- 1 file changed, 1 insertion(+), 65 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html