lkml.org 
[lkml]   [2012]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 2/6] iommu: pass on BUS_NOTIFY_QUERY_BINDING to iommu group notifier clients
Date

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


\
 
 \ /
  Last update: 2012-11-10 15:21    [from the cache]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog