public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [REPOST][PATCH 1/2] driver core: Add new device_driver flag to allow binding via sysfs only
@ 2013-12-03 12:34 Kim Phillips
  2013-12-03 15:34 ` Jan Kiszka
  2013-12-19  1:07 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 17+ messages in thread
From: Kim Phillips @ 2013-12-03 12:34 UTC (permalink / raw)
  To: linux-kernel, Greg Kroah-Hartman
  Cc: kvm, scottwood, R65777, B07421, B08248, christoffer.dall,
	alex.williamson, a.motakis, agraf, B16395

VFIO supports pass-through of devices to user space - for sake
of illustration, say a PCI e1000 device:

- the e1000 is first unbound from the PCI e1000 driver via sysfs
- the vfio-pci driver is told via new_id that it now handles e1000 devices
- the e1000 is explicitly bound to vfio-pci through sysfs

However, now we have two drivers in the system that both handle e1000
devices.  A hotplug event could then occur and it is ambiguous as to which
driver will claim the device.  The desired semantics is that vfio-pci is
only bound to devices by explicit request in sysfs.  This patch makes this
possible by introducing a sysfs_bind_only flag in struct device_driver.

Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
Signed-off-by: Kim Phillips <kim.phillips@linaro.org>
---
rebased onto 3.13-rc2, and reposted from first submission which
recieved no comments:

https://lkml.org/lkml/2013/10/11/53

 drivers/base/dd.c      | 5 ++++-
 include/linux/device.h | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 0605176..b83b16d 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -389,7 +389,7 @@ static int __device_attach(struct device_driver *drv, void *data)
 {
 	struct device *dev = data;
 
-	if (!driver_match_device(drv, dev))
+	if (drv->sysfs_bind_only || !driver_match_device(drv, dev))
 		return 0;
 
 	return driver_probe_device(drv, dev);
@@ -476,6 +476,9 @@ static int __driver_attach(struct device *dev, void *data)
  */
 int driver_attach(struct device_driver *drv)
 {
+	if (drv->sysfs_bind_only)
+		return 0;
+
 	return bus_for_each_dev(drv->bus, NULL, drv, __driver_attach);
 }
 EXPORT_SYMBOL_GPL(driver_attach);
diff --git a/include/linux/device.h b/include/linux/device.h
index 952b010..ed441d1 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -200,6 +200,7 @@ extern struct klist *bus_get_device_klist(struct bus_type *bus);
  * @owner:	The module owner.
  * @mod_name:	Used for built-in modules.
  * @suppress_bind_attrs: Disables bind/unbind via sysfs.
+ * @sysfs_bind_only: Only allow bind/unbind via sysfs.
  * @of_match_table: The open firmware table.
  * @acpi_match_table: The ACPI match table.
  * @probe:	Called to query the existence of a specific device,
@@ -233,6 +234,7 @@ struct device_driver {
 	const char		*mod_name;	/* used for built-in modules */
 
 	bool suppress_bind_attrs;	/* disables bind/unbind via sysfs */
+	bool sysfs_bind_only;		/* only allow bind/unbind via sysfs */
 
 	const struct of_device_id	*of_match_table;
 	const struct acpi_device_id	*acpi_match_table;
-- 
1.8.5


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2013-12-20  0:00 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-03 12:34 [REPOST][PATCH 1/2] driver core: Add new device_driver flag to allow binding via sysfs only Kim Phillips
2013-12-03 15:34 ` Jan Kiszka
2013-12-05 17:45   ` Kim Phillips
2013-12-05 22:38     ` Scott Wood
2013-12-09 18:58       ` Kim Phillips
2013-12-09 19:12         ` Jan Kiszka
2013-12-09 21:33           ` Scott Wood
2013-12-19  1:04   ` Greg Kroah-Hartman
2013-12-19  1:07 ` Greg Kroah-Hartman
2013-12-19 20:22   ` Scott Wood
2013-12-19 20:34     ` Greg Kroah-Hartman
2013-12-19 21:06       ` Stuart Yoder
2013-12-19 21:43         ` Greg Kroah-Hartman
2013-12-19 22:15           ` Scott Wood
2013-12-19 22:32             ` Greg Kroah-Hartman
2013-12-19 23:08               ` Stuart Yoder
2013-12-20  0:00                 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox