* [REPOST][PATCH 2/2] driver core: platform: allow platform drivers to bind to any device
@ 2013-12-03 12:34 Kim Phillips
2013-12-19 1:03 ` Greg Kroah-Hartman
0 siblings, 1 reply; 5+ 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
Platform drivers such as the vfio-platform "meta-" driver [1]
should be allowed to specify that they can bind to any device,
much like PCI drivers can with PCI_ANY_ID.
Currently, binding platform drivers to devices depends on:
- a string match in the device node's compatible entry (OF)
- a string match in the ACPI id list (ACPI)
- a string match in the id_table (platform data)
- a string match on the driver name (fall-back)
none of which allow for the notion of "match any."
This patch adds the notion by adding a "match any device" boolean to
struct platform_driver, for drivers to be able to set and thus not cause
platform_match() to fail when a bind is requested.
[1] http://www.spinics.net/lists/kvm/msg96701.html
Signed-off-by: Kim Phillips <kim.phillips@linaro.org>
---
rebased onto 3.13-rc2, and reposted from first submission which
received no comments:
https://lkml.org/lkml/2013/10/11/48
drivers/base/platform.c | 4 ++++
include/linux/platform_device.h | 1 +
2 files changed, 5 insertions(+)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 3a94b79..78a5b62 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -736,6 +736,10 @@ static int platform_match(struct device *dev, struct device_driver *drv)
struct platform_device *pdev = to_platform_device(dev);
struct platform_driver *pdrv = to_platform_driver(drv);
+ /* the driver matches any device */
+ if (pdrv->match_any_dev)
+ return 1;
+
/* Attempt an OF style match first */
if (of_driver_match_device(dev, drv))
return 1;
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 16f6654..55e76b1 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -179,6 +179,7 @@ struct platform_driver {
struct device_driver driver;
const struct platform_device_id *id_table;
bool prevent_deferred_probe;
+ bool match_any_dev;
};
#define to_platform_driver(drv) (container_of((drv), struct platform_driver, \
--
1.8.5
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [REPOST][PATCH 2/2] driver core: platform: allow platform drivers to bind to any device
2013-12-03 12:34 [REPOST][PATCH 2/2] driver core: platform: allow platform drivers to bind to any device Kim Phillips
@ 2013-12-19 1:03 ` Greg Kroah-Hartman
2013-12-19 20:29 ` Scott Wood
0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2013-12-19 1:03 UTC (permalink / raw)
To: Kim Phillips
Cc: linux-kernel, kvm, scottwood, R65777, B07421, B08248,
christoffer.dall, alex.williamson, a.motakis, agraf, B16395
On Tue, Dec 03, 2013 at 12:34:54PM +0000, Kim Phillips wrote:
> Platform drivers such as the vfio-platform "meta-" driver [1]
> should be allowed to specify that they can bind to any device,
> much like PCI drivers can with PCI_ANY_ID.
>
> Currently, binding platform drivers to devices depends on:
>
> - a string match in the device node's compatible entry (OF)
> - a string match in the ACPI id list (ACPI)
> - a string match in the id_table (platform data)
> - a string match on the driver name (fall-back)
>
> none of which allow for the notion of "match any."
>
> This patch adds the notion by adding a "match any device" boolean to
> struct platform_driver, for drivers to be able to set and thus not cause
> platform_match() to fail when a bind is requested.
>
> [1] http://www.spinics.net/lists/kvm/msg96701.html
>
> Signed-off-by: Kim Phillips <kim.phillips@linaro.org>
> ---
> rebased onto 3.13-rc2, and reposted from first submission which
> received no comments:
>
> https://lkml.org/lkml/2013/10/11/48
>
> drivers/base/platform.c | 4 ++++
> include/linux/platform_device.h | 1 +
> 2 files changed, 5 insertions(+)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 3a94b79..78a5b62 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -736,6 +736,10 @@ static int platform_match(struct device *dev, struct device_driver *drv)
> struct platform_device *pdev = to_platform_device(dev);
> struct platform_driver *pdrv = to_platform_driver(drv);
>
> + /* the driver matches any device */
> + if (pdrv->match_any_dev)
> + return 1;
This breaks userspace in that it will never know to load the module that
can "bind to anything".
You need a way to encode this in the platform device id that can be a
wildcard type of thing, so that userspace can know about this.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [REPOST][PATCH 2/2] driver core: platform: allow platform drivers to bind to any device
2013-12-19 1:03 ` Greg Kroah-Hartman
@ 2013-12-19 20:29 ` Scott Wood
2013-12-19 20:44 ` Greg Kroah-Hartman
0 siblings, 1 reply; 5+ messages in thread
From: Scott Wood @ 2013-12-19 20:29 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Kim Phillips, linux-kernel, kvm, R65777, B07421, B08248,
christoffer.dall, alex.williamson, a.motakis, agraf, B16395
On Wed, 2013-12-18 at 17:03 -0800, Greg Kroah-Hartman wrote:
> On Tue, Dec 03, 2013 at 12:34:54PM +0000, Kim Phillips wrote:
> > Platform drivers such as the vfio-platform "meta-" driver [1]
> > should be allowed to specify that they can bind to any device,
> > much like PCI drivers can with PCI_ANY_ID.
> >
> > Currently, binding platform drivers to devices depends on:
> >
> > - a string match in the device node's compatible entry (OF)
> > - a string match in the ACPI id list (ACPI)
> > - a string match in the id_table (platform data)
> > - a string match on the driver name (fall-back)
> >
> > none of which allow for the notion of "match any."
> >
> > This patch adds the notion by adding a "match any device" boolean to
> > struct platform_driver, for drivers to be able to set and thus not cause
> > platform_match() to fail when a bind is requested.
> >
> > [1] http://www.spinics.net/lists/kvm/msg96701.html
> >
> > Signed-off-by: Kim Phillips <kim.phillips@linaro.org>
> > ---
> > rebased onto 3.13-rc2, and reposted from first submission which
> > received no comments:
> >
> > https://lkml.org/lkml/2013/10/11/48
> >
> > drivers/base/platform.c | 4 ++++
> > include/linux/platform_device.h | 1 +
> > 2 files changed, 5 insertions(+)
> >
> > diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> > index 3a94b79..78a5b62 100644
> > --- a/drivers/base/platform.c
> > +++ b/drivers/base/platform.c
> > @@ -736,6 +736,10 @@ static int platform_match(struct device *dev, struct device_driver *drv)
> > struct platform_device *pdev = to_platform_device(dev);
> > struct platform_driver *pdrv = to_platform_driver(drv);
> >
> > + /* the driver matches any device */
> > + if (pdrv->match_any_dev)
> > + return 1;
>
> This breaks userspace in that it will never know to load the module that
> can "bind to anything".
>
> You need a way to encode this in the platform device id that can be a
> wildcard type of thing, so that userspace can know about this.
How is userspace broken? vfio platform is a new thing; there's nothing
existing to break. I don't see how automatic module loading makes sense
for it. Whether the module needs to be loaded depends on the user's
intentions, not based on what hardware you have.
-Scott
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [REPOST][PATCH 2/2] driver core: platform: allow platform drivers to bind to any device
2013-12-19 20:29 ` Scott Wood
@ 2013-12-19 20:44 ` Greg Kroah-Hartman
2013-12-19 22:17 ` Scott Wood
0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2013-12-19 20:44 UTC (permalink / raw)
To: Scott Wood
Cc: Kim Phillips, linux-kernel, kvm, R65777, B07421, B08248,
christoffer.dall, alex.williamson, a.motakis, agraf, B16395
On Thu, Dec 19, 2013 at 02:29:21PM -0600, Scott Wood wrote:
> On Wed, 2013-12-18 at 17:03 -0800, Greg Kroah-Hartman wrote:
> > On Tue, Dec 03, 2013 at 12:34:54PM +0000, Kim Phillips wrote:
> > > Platform drivers such as the vfio-platform "meta-" driver [1]
> > > should be allowed to specify that they can bind to any device,
> > > much like PCI drivers can with PCI_ANY_ID.
> > >
> > > Currently, binding platform drivers to devices depends on:
> > >
> > > - a string match in the device node's compatible entry (OF)
> > > - a string match in the ACPI id list (ACPI)
> > > - a string match in the id_table (platform data)
> > > - a string match on the driver name (fall-back)
> > >
> > > none of which allow for the notion of "match any."
> > >
> > > This patch adds the notion by adding a "match any device" boolean to
> > > struct platform_driver, for drivers to be able to set and thus not cause
> > > platform_match() to fail when a bind is requested.
> > >
> > > [1] http://www.spinics.net/lists/kvm/msg96701.html
> > >
> > > Signed-off-by: Kim Phillips <kim.phillips@linaro.org>
> > > ---
> > > rebased onto 3.13-rc2, and reposted from first submission which
> > > received no comments:
> > >
> > > https://lkml.org/lkml/2013/10/11/48
> > >
> > > drivers/base/platform.c | 4 ++++
> > > include/linux/platform_device.h | 1 +
> > > 2 files changed, 5 insertions(+)
> > >
> > > diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> > > index 3a94b79..78a5b62 100644
> > > --- a/drivers/base/platform.c
> > > +++ b/drivers/base/platform.c
> > > @@ -736,6 +736,10 @@ static int platform_match(struct device *dev, struct device_driver *drv)
> > > struct platform_device *pdev = to_platform_device(dev);
> > > struct platform_driver *pdrv = to_platform_driver(drv);
> > >
> > > + /* the driver matches any device */
> > > + if (pdrv->match_any_dev)
> > > + return 1;
> >
> > This breaks userspace in that it will never know to load the module that
> > can "bind to anything".
> >
> > You need a way to encode this in the platform device id that can be a
> > wildcard type of thing, so that userspace can know about this.
>
> How is userspace broken? vfio platform is a new thing; there's nothing
> existing to break. I don't see how automatic module loading makes sense
> for it. Whether the module needs to be loaded depends on the user's
> intentions, not based on what hardware you have.
As your driver is saying it can "match any device", you need to tell
userspace that, which you aren't doing here. That's what the ids that
are exported to userspace do, please add some for platform devices to
allow this to work properly, like almost all other busses have.
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [REPOST][PATCH 2/2] driver core: platform: allow platform drivers to bind to any device
2013-12-19 20:44 ` Greg Kroah-Hartman
@ 2013-12-19 22:17 ` Scott Wood
0 siblings, 0 replies; 5+ messages in thread
From: Scott Wood @ 2013-12-19 22:17 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Kim Phillips, linux-kernel, kvm, R65777, B07421, B08248,
christoffer.dall, alex.williamson, a.motakis, agraf, B16395
On Thu, 2013-12-19 at 12:44 -0800, Greg Kroah-Hartman wrote:
> On Thu, Dec 19, 2013 at 02:29:21PM -0600, Scott Wood wrote:
> > On Wed, 2013-12-18 at 17:03 -0800, Greg Kroah-Hartman wrote:
> > > On Tue, Dec 03, 2013 at 12:34:54PM +0000, Kim Phillips wrote:
> > > > diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> > > > index 3a94b79..78a5b62 100644
> > > > --- a/drivers/base/platform.c
> > > > +++ b/drivers/base/platform.c
> > > > @@ -736,6 +736,10 @@ static int platform_match(struct device *dev, struct device_driver *drv)
> > > > struct platform_device *pdev = to_platform_device(dev);
> > > > struct platform_driver *pdrv = to_platform_driver(drv);
> > > >
> > > > + /* the driver matches any device */
> > > > + if (pdrv->match_any_dev)
> > > > + return 1;
> > >
> > > This breaks userspace in that it will never know to load the module that
> > > can "bind to anything".
> > >
> > > You need a way to encode this in the platform device id that can be a
> > > wildcard type of thing, so that userspace can know about this.
> >
> > How is userspace broken? vfio platform is a new thing; there's nothing
> > existing to break. I don't see how automatic module loading makes sense
> > for it. Whether the module needs to be loaded depends on the user's
> > intentions, not based on what hardware you have.
>
> As your driver is saying it can "match any device", you need to tell
> userspace that, which you aren't doing here.
Userspace either knows how to set up VFIO platform devices, in which
case it knows what to do, or it doesn't, in which case why would we want
the module loaded?
> That's what the ids that are exported to userspace do, please add some for platform devices to
> allow this to work properly, like almost all other busses have.
This isn't about platform devices versus "almost all other buses", it's
about VFIO being fundamentally different from normal drivers.
-Scott
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-12-19 22:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-03 12:34 [REPOST][PATCH 2/2] driver core: platform: allow platform drivers to bind to any device Kim Phillips
2013-12-19 1:03 ` Greg Kroah-Hartman
2013-12-19 20:29 ` Scott Wood
2013-12-19 20:44 ` Greg Kroah-Hartman
2013-12-19 22:17 ` Scott Wood
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox