linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Displaying/modifying PCI device id tables via sysfs
@ 2003-03-03 17:57 Matt Domsch
  2003-03-03 18:25 ` Greg KH
  0 siblings, 1 reply; 15+ messages in thread
From: Matt Domsch @ 2003-03-03 17:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: mochel, greg

A lot of PCI drivers today use the pci_device_id table model to specify 
what IDs the driver supports.  I'd like to be able to do 2 things with 
this information:
1) display it in sysfs
2) Add new IDs at runtime and have the drivers probe for the new IDs.

To this end, I've started thinking about how to properly display the table 
via sysfs.  So far I've got:


/sys
|-- bus
|   |-- pci
|   |   `-- drivers
|   |       |-- 3c59x
|   |       |   `-- id_table
|   |       |-- PIIX IDE
|   |       |   `-- id_table
|   |       |-- RZ1000 IDE
|   |       |   `-- id_table
|   |       |-- aic7xxx
|   |       |   `-- id_table
|   |       |-- e100
|   |       |   `-- id_table
|   |       |-- e1000
|   |       |   `-- id_table
|   |       |-- eepro100
|   |       |   `-- id_table
|   |       `-- serial
|   |           `-- id_table


where id_table is a file that looks like:

  vendor,   device, subvendor, subdevice,    class, class_mask
00009004, ffffffff,  ffffffff,  ffffffff, 00010000,   00ffff00
00009005, ffffffff,  ffffffff,  ffffffff, 00010000,   00ffff00

Now, this isn't ideal.
a) It violates sysfs rule of one value per file
b) for drivers with lots of IDs (like 3c59x), it could be longer than
PAGE_SIZE.

So, I've thought about a directory model:


/sys
`-- bus
    `-- pci
        `-- drivers
            `-- 3c59x
                |-- dynamic_id_table
                |   |-- 0
                |   |   |-- class
                |   |   |-- class_mask
                |   |   |-- device
                |   |   |-- subdevice
                |   |   |-- subvendor
                |   |   `-- vendor
                |   `-- new_id
                `-- static_id_table
                    |-- 0
                    |   |-- class
                    |   |-- class_mask
                    |   |-- device
                    |   |-- subdevice
                    |   |-- subvendor
                    |   `-- vendor


The new_id file in the dynamic_id_table would be writable, used for
adding new IDs.

This solves a and b both, at the expense of adding two additional
directories to the hierarchy.

The current sysfs implementation doesn't cleanly handle this type of
data display however.  sysfs_create_dir() takes a kobject*, but I
don't think we want to instantiate kobjects which are simply 
groupings for attribute entries in a table, do we?

I've started down this road, but before I go too far want validation that 
I'm on the right track instantiating kobjects for these table entries.  
Something doesn't feel quite right about it.

I've so far had to:
a) add a struct kobject and a struct list_head (for the dynamic list) to 
pci_device_id.
b) add 2 struct kobjects and 1 struct list_head to struct pci_driver
c) create them all in drivers/pci/pci-sysfs.c.

I also think I need some type of ATTR_ATTR macro, as I don't have whole 
devices for these, just kobjects.  That's where it starts getting really 
weird.


Feedback requested.

Thanks,
Matt

-- 
Matt Domsch
Sr. Software Engineer, Lead Engineer, Architect
Dell Linux Solutions www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com



^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: Displaying/modifying PCI device id tables via sysfs
@ 2003-05-23  2:27 Matt_Domsch
  0 siblings, 0 replies; 15+ messages in thread
From: Matt_Domsch @ 2003-05-23  2:27 UTC (permalink / raw)
  To: rusty; +Cc: greg, linux-kernel, mochel

> So the question is, how do you add PCI IDs to a module which isn't
> loaded?

I think the key is here, in drivers/pci/pci-driver.c:

/**
 * pci_register_driver - register a new pci driver
 * @drv: the driver structure to register
 * 
 * Adds the driver structure to the list of registered drivers
 * Returns the number of pci devices which were claimed by the driver
 * during registration.  The driver remains registered even if the
 * return value is zero.
 */
int
pci_register_driver(struct pci_driver *drv)


So it's perfectly legal to have a driver loaded, for which no device
instances are present.  Then you can add the new ID, and it gets probed
for automatically.  When I was testing this, I had the e100 driver built
in statically, and though it didn't have the ID for my actual device in
the table, it remained available.  When I used the new_id interface to
add the ID, then it probed for devices again, the new ID matched, and it
attached itself to the hardware instance.

Granted, today not all the drivers do this.  But I think it's part of
the grand hotplug scheme to allow them to do so.

This does also mean that a whole pile of drivers, for which hardware may
*never* be present, could be loaded.  My sysfs tree shows drivers for
several PCI devices, which I left as =y in my .config file, which don't
exist in my system.

I'll be out of touch the next few days, but will join back in any
discussion next week.

Thanks,
Matt

-- 
Matt Domsch
Sr. Software Engineer, Lead Engineer, Architect
Dell Linux Solutions www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com



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

end of thread, other threads:[~2003-05-26  0:04 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-03 17:57 Displaying/modifying PCI device id tables via sysfs Matt Domsch
2003-03-03 18:25 ` Greg KH
2003-03-03 20:02   ` Alan Cox
2003-03-03 20:56   ` Matt Domsch
2003-03-04  0:31     ` Greg KH
2003-03-04  4:56       ` Matt Domsch
2003-03-04 14:10         ` Patrick Mochel
2003-03-04 20:22         ` Kai Germaschewski
2003-03-04 22:39           ` Alan Cox
2003-03-04 22:57           ` Jeff Garzik
2003-03-04  0:34     ` Jeff Garzik
2003-05-23  0:53   ` Rusty Russell
2003-05-24  0:37     ` Greg KH
2003-05-25  4:57       ` Rusty Russell
2003-05-23  2:27 Matt_Domsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).