@@ -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)