iommu/rockchip: add more judgement for virtual device who using iommu
authorSimon <xxm@rock-chips.com>
Fri, 25 Mar 2016 08:31:37 +0000 (16:31 +0800)
committerGerrit Code Review <gerrit@rock-chips.com>
Mon, 28 Mar 2016 02:42:59 +0000 (10:42 +0800)
A virtual device like "drm" call iommu_attach_device may fail.
Current only judge if a device has "group", this is not enough,
"group->iommu_data" is needed

Change-Id: I1a66d6016dfef867d83aa4cccaf223ced4e07161
Signed-off-by: Simon <xxm@rock-chips.com>
drivers/iommu/rockchip-iommu.c

index 044c5685b11533ff17ad97f9316a54e34ba55d59..e9db6badd5cb3cf8b36fc6e20519213da9ad0d4c 100644 (file)
@@ -772,6 +772,11 @@ static struct rk_iommu *rk_iommu_from_dev(struct device *dev)
        if (!group)
                return NULL;
        iommu_dev = iommu_group_get_iommudata(group);
+       if (!iommu_dev) {
+               dev_info(dev, "Possibly a virtual device\n");
+               return NULL;
+       }
+
        rk_iommu = dev_get_drvdata(iommu_dev);
        iommu_group_put(group);