* [RFC] Some thoughts on device drivers and sysfs
@ 2005-03-27 19:24 Adam Belay
[not found] ` <1111951499.3503.87.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
0 siblings, 1 reply; 9+ messages in thread
From: Adam Belay @ 2005-03-27 19:24 UTC (permalink / raw)
To: Greg KH, Patrick Mochel
Cc: linux-pm-qjLDD68F18O7TbgM5vRIOg,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 2097 bytes --]
One of the original design goals of sysfs was to provide a standardized
location to keep driver configuration attributes. Although sysfs
handles this very well for bus devices and class devices, there isn't
currently a method to export attributes for device drivers and their
specific bound device instances to userspace.
I would like to propose that we create a new type of device that would
act as the layer between physical (bus devices) and logical (class
devices). It could be referred to as a "driver device". Driver devices
would bind to a bus devices and create one or more class devices. Their
type would be of "struct device_driver". As an example, this would
allow us to move something like /proc/driver/emu10k1/0000:01:09.0 into
sysfs.
(physical) | (logical)
------------------------------------------------
|bus device --> driver device --> class device |
------------------------------------------------
struct driver_device {
struct list_head node;
unsigned long id;
struct kobject kobj;
struct device_driver *drv;
struct device *dev;
int state;
};
In sysfs, a new directory could be created to represent driver devices.
It might look like the following:
bus
|
\- pci
|
\- devices
|
\- link to device0
\- link to device1
\- drivers
|
\- link to random_drv (in other words random_drv can drive this bus)
device
|
\- device0
[...]
\- device1
[...]
driver (this directory is new)
|
\- random_drv
|
\- 0 (a sequential instance number) <-- this is a driver device
|
\- link to device0
\- link to class0
\- a file to control driver state (start, stop, etc.)
\- driver attributes for this link
\- 1
|
\- link to device1
\- link to class1
\- a file to control driver state
\- driver attributes for this link
class
|
\-some_type
|
\- class0
[...]
\- class1
[...]
This would allow us to represent per-device driver attributes in sysfs.
As an added benefit, driver devices would allow the tracking and control
of driver state, which may be needed for dynamic power management. I
look forward to any comments.
Thanks,
Adam
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread[parent not found: <1111951499.3503.87.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>]
* Re: [RFC] Some thoughts on device drivers and sysfs [not found] ` <1111951499.3503.87.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org> @ 2005-03-27 20:53 ` Arioch 2005-03-27 21:08 ` Dominik Brodowski ` (2 subsequent siblings) 3 siblings, 0 replies; 9+ messages in thread From: Arioch @ 2005-03-27 20:53 UTC (permalink / raw) To: linux-pm-qjLDD68F18O7TbgM5vRIOg; +Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 268 bytes --] Adam Belay пишет: > I would like to propose that we create a new type of device that would > act as the layer between physical (bus devices) and logical (class > devices). why not using D-BUS to allow lowlevel drivers to expose its features to userspace? [-- Attachment #2: Type: text/plain, Size: 0 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC] Some thoughts on device drivers and sysfs [not found] ` <1111951499.3503.87.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org> 2005-03-27 20:53 ` Arioch @ 2005-03-27 21:08 ` Dominik Brodowski [not found] ` <20050327210853.GA18358-JwFqNg2GrOVrgjWwlLH9qw@public.gmane.org> 2005-03-27 21:25 ` Jon Smirl 2005-03-29 5:03 ` Greg KH 3 siblings, 1 reply; 9+ messages in thread From: Dominik Brodowski @ 2005-03-27 21:08 UTC (permalink / raw) To: Adam Belay Cc: linux-pm-qjLDD68F18O7TbgM5vRIOg, linux-kernel-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 866 bytes --] On Sun, Mar 27, 2005 at 02:24:59PM -0500, Adam Belay wrote: > One of the original design goals of sysfs was to provide a standardized > location to keep driver configuration attributes. Although sysfs > handles this very well for bus devices and class devices, there isn't > currently a method to export attributes for device drivers and their > specific bound device instances to userspace. Drivers can add (e.g. in ->probe) attributes for devices using extern int device_create_file(struct device *device, struct device_attribute * entry); and delete them (e.g. in ->remove) using extern void device_remove_file(struct device * dev, struct device_attribute * attr); and there's also extern int driver_create_file(struct device_driver *, struct driver_attribute *); extern void driver_remove_file(struct device_driver *, struct driver_attribute *); Dominik [-- Attachment #2: Type: text/plain, Size: 0 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <20050327210853.GA18358-JwFqNg2GrOVrgjWwlLH9qw@public.gmane.org>]
* Re: [RFC] Some thoughts on device drivers and sysfs [not found] ` <20050327210853.GA18358-JwFqNg2GrOVrgjWwlLH9qw@public.gmane.org> @ 2005-03-27 21:27 ` Adam Belay [not found] ` <1111958844.3503.100.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org> 0 siblings, 1 reply; 9+ messages in thread From: Adam Belay @ 2005-03-27 21:27 UTC (permalink / raw) To: Dominik Brodowski Cc: linux-pm-qjLDD68F18O7TbgM5vRIOg, linux-kernel-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1313 bytes --] On Sun, 2005-03-27 at 23:08 +0200, Dominik Brodowski wrote: > On Sun, Mar 27, 2005 at 02:24:59PM -0500, Adam Belay wrote: > > One of the original design goals of sysfs was to provide a standardized > > location to keep driver configuration attributes. Although sysfs > > handles this very well for bus devices and class devices, there isn't > > currently a method to export attributes for device drivers and their > > specific bound device instances to userspace. You're right, I should have worded this differently. > > Drivers can add (e.g. in ->probe) attributes for devices using > extern int device_create_file(struct device *device, struct device_attribute > * entry); > and delete them (e.g. in ->remove) using > extern void device_remove_file(struct device * dev, struct device_attribute > * attr); > > and there's also > > extern int driver_create_file(struct device_driver *, struct > driver_attribute *); > extern void driver_remove_file(struct device_driver *, struct > driver_attribute *); > > > Dominik Yes, I'm aware of these functions but they pollute the bus level namespace. I'm interested in reactions to this alternative approach. I wanted to explore the possibility of making a device driver instance a separate component with its own individual state and relationships. Adam [-- Attachment #2: Type: text/plain, Size: 0 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <1111958844.3503.100.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>]
* Re: [RFC] Some thoughts on device drivers and sysfs [not found] ` <1111958844.3503.100.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org> @ 2005-03-27 21:43 ` Dominik Brodowski [not found] ` <20050327214309.GA18745-JwFqNg2GrOVrgjWwlLH9qw@public.gmane.org> 0 siblings, 1 reply; 9+ messages in thread From: Dominik Brodowski @ 2005-03-27 21:43 UTC (permalink / raw) To: Adam Belay Cc: linux-pm-qjLDD68F18O7TbgM5vRIOg, linux-kernel-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1127 bytes --] On Sun, Mar 27, 2005 at 04:27:24PM -0500, Adam Belay wrote: > > extern int device_create_file(struct device *device, struct device_attribute > > * entry); > > and delete them (e.g. in ->remove) using > > extern void device_remove_file(struct device * dev, struct device_attribute > > * attr); > > > > and there's also > > > > extern int driver_create_file(struct device_driver *, struct > > driver_attribute *); > > extern void driver_remove_file(struct device_driver *, struct > > driver_attribute *); > > > > > > Dominik > > Yes, I'm aware of these functions but they pollute the bus level > namespace. I'm interested in reactions to this alternative approach. I > wanted to explore the possibility of making a device driver instance a > separate component with its own individual state and relationships. To be honest, I don't consider this to be a pollution of the "bus" namespace, but I fear that having two different places for somewhat similar, or even equal, data adds unneeded complexity to the driver model. In what specific instances has the current design limited or obstructed your intentions? Dominik [-- Attachment #2: Type: text/plain, Size: 0 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <20050327214309.GA18745-JwFqNg2GrOVrgjWwlLH9qw@public.gmane.org>]
* Re: [RFC] Some thoughts on device drivers and sysfs [not found] ` <20050327214309.GA18745-JwFqNg2GrOVrgjWwlLH9qw@public.gmane.org> @ 2005-03-27 22:18 ` Adam Belay 0 siblings, 0 replies; 9+ messages in thread From: Adam Belay @ 2005-03-27 22:18 UTC (permalink / raw) To: Dominik Brodowski Cc: linux-pm-qjLDD68F18O7TbgM5vRIOg, linux-kernel-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1781 bytes --] On Sun, 2005-03-27 at 23:43 +0200, Dominik Brodowski wrote: > On Sun, Mar 27, 2005 at 04:27:24PM -0500, Adam Belay wrote: > > > extern int device_create_file(struct device *device, struct device_attribute > > > * entry); > > > and delete them (e.g. in ->remove) using > > > extern void device_remove_file(struct device * dev, struct device_attribute > > > * attr); > > > > > > and there's also > > > > > > extern int driver_create_file(struct device_driver *, struct > > > driver_attribute *); > > > extern void driver_remove_file(struct device_driver *, struct > > > driver_attribute *); > > > > > > > > > Dominik > > > > Yes, I'm aware of these functions but they pollute the bus level > > namespace. I'm interested in reactions to this alternative approach. I > > wanted to explore the possibility of making a device driver instance a > > separate component with its own individual state and relationships. > > To be honest, I don't consider this to be a pollution of the "bus" > namespace, but I fear that having two different places for somewhat similar, > or even equal, data adds unneeded complexity to the driver model. In what > specific instances has the current design limited or obstructed your > intentions? > Fair enough. I just wanted to float this possibility. I appreciate your comments. The original intention for this design was to begin working on a framework for driver layering. (ex. snd-intel8x0m -> ac97, or the pci express bus abstraction) I was considering the possibility of having driver devices with parent and child relationships that reflect the internal layering of Linux drivers. I haven't really had a chance to fully develop this idea, so at this point, driver layering and my original email are just abstract concepts. Adam [-- Attachment #2: Type: text/plain, Size: 0 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC] Some thoughts on device drivers and sysfs [not found] ` <1111951499.3503.87.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org> 2005-03-27 20:53 ` Arioch 2005-03-27 21:08 ` Dominik Brodowski @ 2005-03-27 21:25 ` Jon Smirl 2005-03-29 5:03 ` Greg KH 3 siblings, 0 replies; 9+ messages in thread From: Jon Smirl @ 2005-03-27 21:25 UTC (permalink / raw) To: Adam Belay Cc: linux-pm-qjLDD68F18O7TbgM5vRIOg, linux-kernel-u79uwXL29TY76Z2rM5mHXA On Sun, 27 Mar 2005 14:24:59 -0500, Adam Belay <abelay-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org> wrote: > This would allow us to represent per-device driver attributes in sysfs. > As an added benefit, driver devices would allow the tracking and control > of driver state, which may be needed for dynamic power management. I > look forward to any comments. Isn't there already a way to do this? I recall some discussion lkml about six months ago about doing it. I tried googling for it but couldn't find it. It may not have been implemented. -- Jon Smirl jonsmirl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC] Some thoughts on device drivers and sysfs [not found] ` <1111951499.3503.87.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org> ` (2 preceding siblings ...) 2005-03-27 21:25 ` Jon Smirl @ 2005-03-29 5:03 ` Greg KH [not found] ` <20050329050345.GB7937-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org> 3 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2005-03-29 5:03 UTC (permalink / raw) To: Adam Belay Cc: linux-pm-qjLDD68F18O7TbgM5vRIOg, linux-kernel-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1021 bytes --] On Sun, Mar 27, 2005 at 02:24:59PM -0500, Adam Belay wrote: > One of the original design goals of sysfs was to provide a standardized > location to keep driver configuration attributes. Although sysfs > handles this very well for bus devices and class devices, there isn't > currently a method to export attributes for device drivers and their > specific bound device instances to userspace. Hm, what's device_create_file(), device_remove_file(), and DEVICE_ATTR() for? A number of drivers use these functions today to add their own driver specific attributes to a device they control. Then, userspace can just do a simple: ls /sys/bus/pci/drivers/my_foo_driver/ to see all devices on the PCI bus that are controlled by that driver. Then it can go into those directories and cat out the specific information if needed. Is there something that is lacking in the current code that you would like to see present? I don't think that adding another layer on top of a device would help out much here. thanks, greg k-h [-- Attachment #2: Type: text/plain, Size: 0 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <20050329050345.GB7937-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>]
* Re: Re: [RFC] Some thoughts on device drivers and sysfs [not found] ` <20050329050345.GB7937-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org> @ 2005-03-29 6:33 ` Dmitry Torokhov 0 siblings, 0 replies; 9+ messages in thread From: Dmitry Torokhov @ 2005-03-29 6:33 UTC (permalink / raw) To: linux-pm-qjLDD68F18O7TbgM5vRIOg Cc: Adam Belay, linux-kernel-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1227 bytes --] On Tuesday 29 March 2005 00:03, Greg KH wrote: > On Sun, Mar 27, 2005 at 02:24:59PM -0500, Adam Belay wrote: > > One of the original design goals of sysfs was to provide a standardized > > location to keep driver configuration attributes. Although sysfs > > handles this very well for bus devices and class devices, there isn't > > currently a method to export attributes for device drivers and their > > specific bound device instances to userspace. > > Hm, what's device_create_file(), device_remove_file(), and DEVICE_ATTR() > for? A number of drivers use these functions today to add their own > driver specific attributes to a device they control. > > Then, userspace can just do a simple: > ls /sys/bus/pci/drivers/my_foo_driver/ > to see all devices on the PCI bus that are controlled by that driver. > Then it can go into those directories and cat out the specific > information if needed. It probably would be nice if all driver-specific device attributes would be grouped under /sys/devices/.../<blah_device>/drvattr/* so their names would not clash with names of driver core attributes. Unfortunately that would mean we are breaking userspace again... -- Dmitry [-- Attachment #2: Type: text/plain, Size: 0 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-03-29 6:33 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-27 19:24 [RFC] Some thoughts on device drivers and sysfs Adam Belay
[not found] ` <1111951499.3503.87.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2005-03-27 20:53 ` Arioch
2005-03-27 21:08 ` Dominik Brodowski
[not found] ` <20050327210853.GA18358-JwFqNg2GrOVrgjWwlLH9qw@public.gmane.org>
2005-03-27 21:27 ` Adam Belay
[not found] ` <1111958844.3503.100.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2005-03-27 21:43 ` Dominik Brodowski
[not found] ` <20050327214309.GA18745-JwFqNg2GrOVrgjWwlLH9qw@public.gmane.org>
2005-03-27 22:18 ` Adam Belay
2005-03-27 21:25 ` Jon Smirl
2005-03-29 5:03 ` Greg KH
[not found] ` <20050329050345.GB7937-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2005-03-29 6:33 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox