[PATCH 3/5] iommu/rockchip: add sanity check for virtual device
Shunqian Zheng
zhengsq at rock-chips.com
Sun May 22 18:37:17 PDT 2016
From: Simon <xxm at rock-chips.com>
We mark DRM as "virtual" device by checking it's group,
which may no longer true with the new rockchip drm drv in
https://patchwork.kernel.org/patch/8876331/.
Checking the group->iommu_data for virtual device.
Signed-off-by: Simon <xxm at rock-chips.com>
---
drivers/iommu/rockchip-iommu.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
index 3c16ec3..043d18c 100644
--- a/drivers/iommu/rockchip-iommu.c
+++ b/drivers/iommu/rockchip-iommu.c
@@ -764,6 +764,7 @@ static size_t rk_iommu_unmap(struct iommu_domain *domain, unsigned long _iova,
return unmap_size;
}
+/* Return NULL for a virtual device like DRM */
static struct rk_iommu *rk_iommu_from_dev(struct device *dev)
{
struct iommu_group *group;
@@ -774,6 +775,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);
@@ -791,7 +797,6 @@ static int rk_iommu_attach_device(struct iommu_domain *domain,
/*
* Allow 'virtual devices' (e.g., drm) to attach to domain.
- * Such a device does not belong to an iommu group.
*/
iommu = rk_iommu_from_dev(dev);
if (!iommu)
--
1.9.1
More information about the Linux-rockchip
mailing list