diff options
author | Sri Krishna chowdary <schowdary@nvidia.com> | 2014-01-30 14:59:49 +0530 |
---|---|---|
committer | Krishna Reddy <vdumpa@nvidia.com> | 2014-01-31 10:32:02 -0800 |
commit | 25e4750235628bc03dca21c0cbf30fe267761a93 (patch) | |
tree | 554d35eed3901ae594225dd7d670f2095e1d6a54 /drivers/iommu | |
parent | 4a59abe6d86a880ef008446ea97034293b54ff2b (diff) |
iommu: tegra: correct device attach/detach
attach/detach a device only if registered to use smmu
Bug 1446597
Change-Id: I99be7eb3ddeff8b9f8ec61dc06b09eeb66bbd1d6
Signed-off-by: Sri Krishna chowdary <schowdary@nvidia.com>
Reviewed-on: http://git-master/r/361928
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Tested-by: Krishna Reddy <vdumpa@nvidia.com>
Diffstat (limited to 'drivers/iommu')
-rw-r--r-- | drivers/iommu/tegra-smmu.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 0e103761ec55..b75b455bcfba 100644 --- a/drivers/iommu/tegra-smmu.c +++ b/drivers/iommu/tegra-smmu.c @@ -1862,6 +1862,10 @@ static int tegra_smmu_device_notifier(struct notifier_block *nb, struct dma_iommu_mapping *map; struct device *dev = _dev; + map = tegra_smmu_get_map(dev, tegra_smmu_of_get_swgids(dev)); + if (!map) + return NOTIFY_DONE; + switch (event) { case BUS_NOTIFY_BIND_DRIVER: if (get_dma_ops(dev) != &arm_dma_ops) @@ -1876,9 +1880,7 @@ static int tegra_smmu_device_notifier(struct notifier_block *nb, break; } - map = tegra_smmu_get_map(dev, tegra_smmu_of_get_swgids(dev)); - if (!map) - break; + WARN_ON(to_dma_iommu_mapping(dev) == map); if (arm_iommu_attach_device(dev, map)) { dev_err(dev, "Failed to attach %s\n", dev_name(dev)); @@ -1892,6 +1894,8 @@ static int tegra_smmu_device_notifier(struct notifier_block *nb, break; /* FALLTHROUGH */ case BUS_NOTIFY_UNBOUND_DRIVER: + WARN_ON(!to_dma_iommu_mapping(dev)); + dev_dbg(dev, "Detaching %s from map %p\n", dev_name(dev), to_dma_iommu_mapping(dev)); arm_iommu_detach_device(dev); |