From b854c94f3dda55a609bc2a6f1e6348b7df4bbdba Mon Sep 17 00:00:00 2001 From: Mitchel Humpherys Date: Thu, 19 Mar 2015 16:13:03 -0700 Subject: [PATCH] iommu/arm-smmu: configure stream IDs for PCI-e devices dynamically PCI-e devices on MSM systems need to have their stream IDs configured at device add time, since they're not known at system design time and therefore can't be placed in the device tree. Add the necessary calls into the MSM PCI-e driver to obtain stream IDs for devices behind PCI-e at device add time. Change-Id: I3645a525c3ab5ef6d89eeaa99894542bd3aa261f Signed-off-by: Mitchel Humpherys --- drivers/iommu/arm-smmu.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index af4c703ca498..507634c413a9 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -48,6 +48,7 @@ #include #include #include +#include #include @@ -2121,12 +2122,6 @@ static bool arm_smmu_capable(enum iommu_cap cap) } } -static int __arm_smmu_get_pci_sid(struct pci_dev *pdev, u16 alias, void *data) -{ - *((u16 *)data) = alias; - return 0; /* Continue walking */ -} - static void __arm_smmu_release_pci_iommudata(void *data) { kfree(data); @@ -2151,7 +2146,8 @@ static int arm_smmu_add_device(struct device *dev) } if (dev_is_pci(dev)) { - struct pci_dev *pdev = to_pci_dev(dev); + u32 sid; + int tmp; cfg = kzalloc(sizeof(*cfg), GFP_KERNEL); if (!cfg) { @@ -2160,12 +2156,15 @@ static int arm_smmu_add_device(struct device *dev) } cfg->num_streamids = 1; - /* - * Assume Stream ID == Requester ID for now. - * We need a way to describe the ID mappings in FDT. - */ - pci_for_each_dma_alias(pdev, __arm_smmu_get_pci_sid, - &cfg->streamids[0]); + ret = msm_pcie_configure_sid(dev, &sid, &tmp); + if (ret) { + dev_err(dev, + "Couldn't configure SID through PCI-e driver: %d\n", + ret); + kfree(cfg); + goto out_put_group; + } + cfg->streamids[0] = sid; releasefn = __arm_smmu_release_pci_iommudata; } else { struct arm_smmu_master *master;