• Matt Domsch's avatar
    Device Driver Dynamic PCI Device IDs · a1c03667
    Matt Domsch authored
    Provides a mechanism to pass new PCI device IDs to device drivers
    at runtime, rather than relying only on a static compiled-in list
    of supported IDs.
    
    For each driver which has a pci_driver->probe routine, two things
    are added: a probe_it file, and a dynamic_id directory.  In the
    dynamic_id directory is a new file, new_id.
    
    /sys/bus/pci/drivers/e100
    |-- dynamic_id
    |   `-- new_id
    `-- probe_it
    
    One may read the new_id file, which by default returns:
    $ cat new_id
    echo vendor device subvendor subdevice class classmask
    where each field is a 32-bit value in ABCD (hex) format (no leading 0x).
    Pass only as many fields as you need to override the defaults below.
    Default vendor, device, subvendor, and subdevice fields
    are set to FFFFFFFF (PCI_ANY_ID).
    Default class and classmask fields are set to 0.
    
    One may write new PCI device IDs into the new_id file:
    echo "8086 1229" > new_id
    
    which will cause a new device ID (sysfs name 0) to be added to the driver.
    
    /sys/bus/pci/drivers/e100
    |-- dynamic_id
    |   |-- 0
    |   `-- new_id
    `-- probe_it
    
    $ cat 0
    00008086 00001229 ffffffff ffffffff 00000000 00000000
    
    One can then cause the driver to probe for devices again.
    echo 1 > probe_it
    
    Individual device drivers may override the behavior of the new_id
    file, for instance, if they need to also pass driver-specific
    information.  Likewise, reading the individual dynamic ID files
    can be overridden by the driver.
    
    This also adds an existance test field to struct driver_attribute,
    necessary because we only want the probe_it file to appear iff
    struct pci_driver->probe is non-NULL.
    
    The device probing routines in pci-driver.c are enhanced to scan
    first the static list of IDs, then the dynamic list (if any).
    a1c03667
pci-driver.c 10.7 KB