mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiang Liu <liuj97@gmail.com>
To: Alex Williamson <alex.williamson@redhat.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiang Liu <jiang.liu@huawei.com>,
	Joerg Roedel <joerg.roedel@amd.com>,
	Yinghai Lu <yinghai@kernel.org>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Hanjun Guo <guohanjun@huawei.com>
Subject: [RFC PATCH 2/6] iommu: pass on BUS_NOTIFY_QUERY_BINDING to iommu group notifier clients
Date: Sat, 10 Nov 2012 21:57:15 +0800	[thread overview]
Message-ID: <1352555839-18961-2-git-send-email-jiang.liu@huawei.com> (raw)
In-Reply-To: <1352555839-18961-1-git-send-email-jiang.liu@huawei.com>

 From: Jiang Liu <jiang.liu@huawei.com>

Pass on BUS_NOTIFY_QUERY_BINDING event to iommu group notifier clients,
so notifier clients have a chance to reject device driver binding.

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
---
 drivers/iommu/iommu.c |   14 +++++++++-----
 include/linux/iommu.h |    1 +
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index ddbdaca..7fbe055 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -497,6 +497,7 @@ static int add_iommu_group(struct device *dev, void *data)
 static int iommu_bus_notifier(struct notifier_block *nb,
 			      unsigned long action, void *data)
 {
+	int ret = NOTIFY_DONE;
 	struct device *dev = data;
 	struct iommu_ops *ops = dev->bus->iommu_ops;
 	struct iommu_group *group;
@@ -512,7 +513,7 @@ static int iommu_bus_notifier(struct notifier_block *nb,
 	} else if (action == BUS_NOTIFY_DEL_DEVICE) {
 		if (ops->remove_device && dev->iommu_group) {
 			ops->remove_device(dev);
-			return 0;
+			return NOTIFY_DONE;
 		}
 	}
 
@@ -522,9 +523,12 @@ static int iommu_bus_notifier(struct notifier_block *nb,
 	 */
 	group = iommu_group_get(dev);
 	if (!group)
-		return 0;
+		return NOTIFY_DONE;
 
 	switch (action) {
+	case BUS_NOTIFY_SOLICIT_BINDING:
+		group_action = IOMMU_GROUP_NOTIFY_SOLICIT_BINDING;
+		break;
 	case BUS_NOTIFY_BIND_DRIVER:
 		group_action = IOMMU_GROUP_NOTIFY_BIND_DRIVER;
 		break;
@@ -540,11 +544,11 @@ static int iommu_bus_notifier(struct notifier_block *nb,
 	}
 
 	if (group_action)
-		blocking_notifier_call_chain(&group->notifier,
-					     group_action, dev);
+		ret = blocking_notifier_call_chain(&group->notifier,
+						   group_action, dev);
 
 	iommu_group_put(group);
-	return 0;
+	return ret;
 }
 
 static struct notifier_block iommu_bus_nb = {
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 7e83370..366435b 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -109,6 +109,7 @@ struct iommu_ops {
 #define IOMMU_GROUP_NOTIFY_BOUND_DRIVER		4 /* Post Driver bind */
 #define IOMMU_GROUP_NOTIFY_UNBIND_DRIVER	5 /* Pre Driver unbind */
 #define IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER	6 /* Post Driver unbind */
+#define IOMMU_GROUP_NOTIFY_SOLICIT_BINDING	7 /* Check for objections */
 
 extern int bus_set_iommu(struct bus_type *bus, struct iommu_ops *ops);
 extern bool iommu_present(struct bus_type *bus);
-- 
1.7.9.5


  reply	other threads:[~2012-11-10 13:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-10 13:57 [RFC PATCH 1/6] driver core: add a bus notification to temporarily reject driver binding Jiang Liu
2012-11-10 13:57 ` Jiang Liu [this message]
2012-11-10 13:57 ` [RFC PATCH 3/6] VFIO: unregister IOMMU notifier on error recovery path Jiang Liu
2012-11-13 18:15   ` Alex Williamson
2012-11-10 13:57 ` [RFC PATCH 4/6] VFIO: reject binding driver to devices belonging to active VFIO groups Jiang Liu
2012-11-10 13:57 ` [RFC PATCH 5/6] VFIO: simplify IOMMU group notification handler Jiang Liu
2012-11-10 13:57 ` [RFC PATCH 6/6] VFIO: use ACCESS_ONCE() to guard access to dev->driver Jiang Liu
2012-11-11  5:21 ` [RFC PATCH 1/6] driver core: add a bus notification to temporarily reject driver binding Greg Kroah-Hartman
2012-11-13 16:02   ` Jiang Liu

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=1352555839-18961-2-git-send-email-jiang.liu@huawei.com \
    --to=liuj97@gmail.com \
    --cc=alex.williamson@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=guohanjun@huawei.com \
    --cc=jiang.liu@huawei.com \
    --cc=joerg.roedel@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yinghai@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

all inboxes | Powered by JetHome®