From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rob Clark Subject: [PATCH v2 1/2] iommu: add support for drivers that manage iommu explicitly Date: Fri, 6 Sep 2019 14:44:01 -0700 Message-ID: <20190906214409.26677-2-robdclark@gmail.com> References: <20190906214409.26677-1-robdclark@gmail.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <20190906214409.26677-1-robdclark@gmail.com> Sender: linux-kernel-owner@vger.kernel.org To: iommu@lists.linux-foundation.org Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Robin Murphy , Joerg Roedel , Will Deacon , Rob Clark , Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Morton , Suzuki K Poulose , Rasmus Villemoes , Heikki Krogerus , Bartosz Golaszewski , Sudeep Holla , Joe Perches , Arnd Bergmann , open list List-Id: dri-devel@lists.freedesktop.org From: Rob Clark Avoid attaching any non-driver managed domain if the driver indicates that it manages the iommu directly. Signed-off-by: Rob Clark --- drivers/iommu/iommu.c | 2 +- drivers/iommu/of_iommu.c | 3 +++ include/linux/device.h | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 0c674d80c37f..2ac5e8d48cae 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -674,7 +674,7 @@ int iommu_group_add_device(struct iommu_group *group, struct device *dev) mutex_lock(&group->mutex); list_add_tail(&device->list, &group->devices); - if (group->domain) + if (group->domain && !(dev->driver && dev->driver->driver_manages_iommu)) ret = __iommu_attach_device(group->domain, dev); mutex_unlock(&group->mutex); if (ret) diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index 614a93aa5305..62b47e384a77 100644 --- a/drivers/iommu/of_iommu.c +++ b/drivers/iommu/of_iommu.c @@ -221,6 +221,9 @@ const struct iommu_ops *of_iommu_configure(struct device *dev, } else if (err < 0) { dev_dbg(dev, "Adding to IOMMU failed: %d\n", err); ops = NULL; + } else if (dev->driver && dev->driver->driver_manages_iommu) { + dev_dbg(dev, "Driver manages IOMMU\n"); + ops = NULL; } return ops; diff --git a/include/linux/device.h b/include/linux/device.h index 1aa341b2a0db..b77a11b8d9bb 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -284,7 +284,8 @@ struct device_driver { struct module *owner; const char *mod_name; /* used for built-in modules */ - bool suppress_bind_attrs; /* disables bind/unbind via sysfs */ + bool suppress_bind_attrs:1; /* disables bind/unbind via sysfs */ + bool driver_manages_iommu:1; /* driver manages IOMMU explicitly */ enum probe_type probe_type; const struct of_device_id *of_match_table; -- 2.21.0