From: Rob Clark <robdclark@gmail.com>
To: iommu@lists.linux-foundation.org
Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org,
Robin Murphy <robin.murphy@arm.com>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Rob Clark <robdclark@chromium.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Sudeep Holla <sudeep.holla@arm.com>,
Joe Perches <joe@perches.com>, Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v2 1/2] iommu: add support for drivers that manage iommu explicitly
Date: Fri, 6 Sep 2019 14:44:01 -0700 [thread overview]
Message-ID: <20190906214409.26677-2-robdclark@gmail.com> (raw)
In-Reply-To: <20190906214409.26677-1-robdclark@gmail.com>
From: Rob Clark <robdclark@chromium.org>
Avoid attaching any non-driver managed domain if the driver indicates
that it manages the iommu directly.
Signed-off-by: Rob Clark <robdclark@chromium.org>
---
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
next prev parent reply other threads:[~2019-09-06 21:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-06 21:44 [PATCH v3 0/2] iommu: handle drivers that manage iommu directly Rob Clark
2019-09-06 21:44 ` Rob Clark [this message]
2019-09-10 8:14 ` [PATCH v2 1/2] iommu: add support for drivers that manage iommu explicitly Joerg Roedel
2019-09-10 15:34 ` Rob Clark
2019-09-10 16:51 ` Robin Murphy
2019-09-06 21:44 ` [PATCH v2 2/2] drm/msm: mark devices where iommu is managed by driver Rob Clark
2019-09-10 16:34 ` [PATCH v3 0/2] iommu: handle drivers that manage iommu directly Robin Murphy
2019-09-10 17:10 ` Rob Clark
2019-09-17 13:36 ` Will Deacon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190906214409.26677-2-robdclark@gmail.com \
--to=robdclark@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=brgl@bgdev.pl \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=iommu@lists.linux-foundation.org \
--cc=joe@perches.com \
--cc=joro@8bytes.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=rafael.j.wysocki@intel.com \
--cc=robdclark@chromium.org \
--cc=robin.murphy@arm.com \
--cc=sudeep.holla@arm.com \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).