linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BK PATCH] driver model updates
@ 2002-09-24  1:45 Patrick Mochel
  0 siblings, 0 replies; only message in thread
From: Patrick Mochel @ 2002-09-24  1:45 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 7163 bytes --]


Hey there.

Here is the latest round of driver model infrastructure updates. To 
summarize, these changes do:

- Add system bus type, and struct sys_device for system-level devices.
- convert i8259.c and time.c to use this interface. This gives us in 
driverfs: 

[mochel@cherise mochel]$ tree -d /sys/bus/system/
/sys/bus/system/
|-- devices
|   |-- pic0 -> ../../../root/sys/pic0
|   `-- rtc0 -> ../../../root/sys/rtc0
`-- drivers
    |-- cpu
    `-- pic


- add struct cpu, a default CPU driver, and a CPU device class. 
- Register CPU devices on boot, which gives us in driverfs: 

[mochel@cherise mochel]$ tree -d /sys/class/cpu/
/sys/class/cpu/
|-- devices
|   |-- 0 -> ../../../root/sys/cpu0
|   `-- 1 -> ../../../root/sys/cpu1
`-- drivers


- add struct platform_device to represent platform (legacy) devices. 
- convert floppy.c to use this interface.
- This gives us in driverfs:

[mochel@cherise mochel]$ tree -d /sys/bus/platform/
/sys/bus/platform/
|-- devices
|   `-- floppy0 -> ../../../root/legacy/floppy0
`-- drivers

- add support for multi-board systems (e.g. Numa-Q) and mechanism for 
  setting the what board a system device resides on. 


I've attached the entire tree(1) output of my driverfs partition for my 
dual P4 workstation, to give an idea of what the entire picture looks 
like. It's coming together nicely, except..

ACPI is still ugly, and doesn't deserve a top-level directory. The next 
item on my list is to create a common place for firmware drivers to place 
their stuff, and integrate some of the related patches I've received. 

Please apply.

Thanks,

	-pat

Please pull from 

	bk://ldm.bkbits.net/linux-2.5

This will update the following files:

 arch/i386/kernel/cpu/common.c |   35 +++++++++++
 arch/i386/kernel/i8259.c      |   20 ++++--
 arch/i386/kernel/time.c       |   15 ++--
 drivers/base/Makefile         |    7 +-
 drivers/base/core.c           |   54 ++++++++---------
 drivers/base/cpu.c            |   28 ++++++++
 drivers/base/platform.c       |   41 ++++++++++++-
 drivers/base/sys.c            |  131 ++++++++++++++++++++++++++++++++++++------
 drivers/block/floppy.c        |   19 +++---
 drivers/usb/core/usb.c        |   10 ++-
 include/linux/cpu.h           |   28 ++++++++
 include/linux/device.h        |   36 ++++++++++-
 12 files changed, 350 insertions(+), 74 deletions(-)

through these ChangeSets:

<mochel@osdl.org> (02/09/23 1.607)
   driver model: add better platform device support.
   
   Platform devices are devices commonly found on the motherboard of systems. This
   includes legacy devices (serial ports, floppy controllers, parallel ports, etc)
   and host bridges to peripheral buses. 
   
   We already had a platform bus type, which gives a way to group platform devices
   and drivers, and allow each to be bound to each other dynamically. Though before,
   it didn't do anything. It still doesn't do much, but we now have:
   
   - struct platform_device, which generically describes platform deviecs. This only
     includes a name and id in addition to a struct device, but more may be added later.
   
   - implelemnt platform_device_register() and platform_device_unregister() to handle
     adding and removing these devices. 
   
   - Create legacy_bus - a default parent device for legacy devices. 
   
   - Change the floppy driver to define a platform_device (instead of a sys_device). 
     In driverfs, this gives us now:
   
   a# tree -d /sys/bus/platform/
   /sys/bus/platform/
   |-- devices
   |   `-- floppy0 -> ../../../root/legacy/floppy0
   `-- drivers
   
   and
   
   # tree -d /sys/root/legacy/
   /sys/root/legacy/
   `-- floppy0

<mochel@osdl.org> (02/09/23 1.603.1.5)
   driver model: add support for multi-board systems.
   
   - device struct sys_root for describing the individual boards of a multi-board
     system.
   
   - allow for registration of alternate device roots.
   
   - check if struct sys_device::root is set on registration, and add it as a child of
     an alternative root, if it's set. 

<mochel@osdl.org> (02/09/23 1.603.1.4)
   driver model: add support for CPUs.
   
   - Create struct cpu to generically describe cpus (it simply contains
     a struct sys_device in it).
   
   - Define an array of size NR_CPUS in arch/i386/kernel/cpu/common.c 
     and register each on bootup. This gives us something like:
   
   # tree -d /sys/root/sys/
   /sys/root/sys/
   |-- cpu0
   |-- pic0
   `-- rtc0
   
   and:
   
   # tree -d /sys/bus/system/devices/
   /sys/bus/system/devices/
   |-- cpu0 -> ../../../root/sys/cpu0
   
   - Define arch-specific CPU driver that's also registered on boot.
     That gives us: 
   
   # tree -d /sys/bus/system/drivers/
   /sys/bus/system/drivers/
   |-- cpu
   
   - Create a CPU device class that's registered very early. That 
     gives us all the CPUs in the system in one place:
   
   # tree -d /sys/class/cpu/
   /sys/class/cpu/
   |-- devices
   |   `-- 0 -> ../../../root/sys/cpu0
   `-- drivers
   
   Other archs are encouraged to do the same.

<mochel@osdl.org> (02/09/23 1.603.1.3)
   USB: fixup handling of generic USB driver.
   
   The generic driver is used by the virtual USB bridge device. This makes sure that
   the driver is registered before we try to use it (and it gets the bus type right).
   
   We also check for equality when matching devices to drivers, because we don't 
   want to match any device to it. 

<mochel@osdl.org> (02/09/23 1.603.1.2)
   Driver model: handle devices registered with ->driver set.
   
   In some cases, especially when dealing with system and platform devices, a 
   device's driver is known when the device is registered. We still want to add
   the device to the driver's list and add it to the class.
   
   This makes splits driver binding into probe() and attach(). If the device already
   has a driver, we simply call attach(). Otherwise, we try to match it on the bus
   and still call found_match().
   
   This requires that all drivers that are referenced are registered beforehand.

<mochel@osdl.org> (02/09/23 1.603.1.1)
   Driver model: improve support for system devices.
     
   - Create struct sys_device to describe system-level devices (CPUs, PICs, etc.). This 
     structure includes a 'name' and 'id' field for drivers to fill in with a simple
     canonical name (like 'pic' or 'floppy') and the id of the device relative to its 
     discovery in the system (it's enumerated value).
   
     The core then constructs the bus_id for the device from these, giving them meaningful
     names when exporting them to userspace:
   
   # tree -d /sys/root/sys/
   /sys/root/sys/
   |-- pic0
   `-- rtc0
   
   - Replace 
   	int register_sys_device(struct device * dev);
   	with 
   	int sys_device_register(struct sys_device * sysdev);
   
   - Fixup the users of the API.
   
   - Add a system_bus_type for devices to associate themselves with. This provides a 
     bus/system/ directory in driverfs that looks like:
   
   # tree -d /sys/bus/system/
   /sys/bus/system/
   |-- devices
   |   |-- pic0 -> ../../../root/sys/pic0
   |   `-- rtc0 -> ../../../root/sys/rtc0
   `-- drivers
       `-- pic


[-- Attachment #2: Type: TEXT/PLAIN, Size: 3842 bytes --]

/sys/
|-- acpi
|   `-- ACPI
|       |-- CPU0
|       |-- CPU1
|       |-- FAN
|       |-- PWRF
|       |-- THRM
|       `-- _SB
|           |-- FWH
|           |-- MEM
|           |-- PCI0
|           |   |-- COPR
|           |   |-- DMA1
|           |   |-- ECP1
|           |   |-- FDC0
|           |   |-- HUB0
|           |   |-- HUBA
|           |   |   `-- HUBB
|           |   |-- HUBC
|           |   |-- ICHX
|           |   |   |-- PRIM
|           |   |   |   |-- MAST
|           |   |   |   `-- SLAV
|           |   |   `-- SECN
|           |   |       |-- MAST
|           |   |       `-- SLAV
|           |   |-- IRDA
|           |   |-- LNK0
|           |   |-- LNK1
|           |   |-- LNKA
|           |   |-- LNKB
|           |   |-- LNKC
|           |   |-- LNKD
|           |   |-- LNKE
|           |   |-- LNKF
|           |   |-- LPT1
|           |   |-- PIC
|           |   |-- PS2K
|           |   |-- PS2M
|           |   |-- PX40
|           |   |-- PX43
|           |   |-- RTC
|           |   |-- SPKR
|           |   |-- SYSR
|           |   |-- TMR
|           |   |-- UAR1
|           |   |-- UAR2
|           |   `-- USB0
|           `-- PWRB
|-- bus
|   |-- ide
|   |   |-- devices
|   |   |   |-- 0.0 -> ../../../root/pci0/00:1f.1/ide0/0.0
|   |   |   |-- 0.1 -> ../../../root/pci0/00:1f.1/ide0/0.1
|   |   |   |-- 1.0 -> ../../../root/pci0/00:1f.1/ide1/1.0
|   |   |   `-- 1.1 -> ../../../root/pci0/00:1f.1/ide1/1.1
|   |   `-- drivers
|   |-- pci
|   |   |-- devices
|   |   |   |-- 00:00.0 -> ../../../root/pci0/00:00.0
|   |   |   |-- 00:01.0 -> ../../../root/pci0/00:01.0
|   |   |   |-- 00:02.0 -> ../../../root/pci0/00:02.0
|   |   |   |-- 00:1e.0 -> ../../../root/pci0/00:1e.0
|   |   |   |-- 00:1f.0 -> ../../../root/pci0/00:1f.0
|   |   |   |-- 00:1f.1 -> ../../../root/pci0/00:1f.1
|   |   |   |-- 00:1f.2 -> ../../../root/pci0/00:1f.2
|   |   |   |-- 00:1f.3 -> ../../../root/pci0/00:1f.3
|   |   |   |-- 00:1f.5 -> ../../../root/pci0/00:1f.5
|   |   |   |-- 01:00.0 -> ../../../root/pci0/00:01.0/01:00.0
|   |   |   |-- 02:1f.0 -> ../../../root/pci0/00:02.0/02:1f.0
|   |   |   |-- 03:00.0 -> ../../../root/pci0/00:02.0/02:1f.0/03:00.0
|   |   |   `-- 04:04.0 -> ../../../root/pci0/00:1e.0/04:04.0
|   |   `-- drivers
|   |       |-- Intel ICH
|   |       |-- Intel ICH Joystick
|   |       |-- PIIX IDE
|   |       |-- agpgart
|   |       |-- e100
|   |       `-- serial
|   |-- platform
|   |   |-- devices
|   |   |   `-- floppy0 -> ../../../root/legacy/floppy0
|   |   `-- drivers
|   |-- system
|   |   |-- devices
|   |   |   |-- cpu0 -> ../../../root/sys/cpu0
|   |   |   |-- cpu1 -> ../../../root/sys/cpu1
|   |   |   |-- pic0 -> ../../../root/sys/pic0
|   |   |   `-- rtc0 -> ../../../root/sys/rtc0
|   |   `-- drivers
|   |       |-- cpu
|   |       `-- pic
|   `-- usb
|       |-- devices
|       `-- drivers
|           |-- hub
|           `-- usbfs
|-- class
|   |-- cpu
|   |   |-- devices
|   |   |   |-- 0 -> ../../../root/sys/cpu0
|   |   |   `-- 1 -> ../../../root/sys/cpu1
|   |   `-- drivers
|   `-- input
|       |-- devices
|       |-- drivers
|       `-- mouse
`-- root
    |-- legacy
    |   `-- floppy0
    |-- pci0
    |   |-- 00:00.0
    |   |-- 00:01.0
    |   |   `-- 01:00.0
    |   |-- 00:02.0
    |   |   `-- 02:1f.0
    |   |       `-- 03:00.0
    |   |-- 00:1e.0
    |   |   `-- 04:04.0
    |   |-- 00:1f.0
    |   |-- 00:1f.1
    |   |   |-- ide0
    |   |   |   |-- 0.0
    |   |   |   `-- 0.1
    |   |   `-- ide1
    |   |       |-- 1.0
    |   |       `-- 1.1
    |   |-- 00:1f.2
    |   |-- 00:1f.3
    |   `-- 00:1f.5
    `-- sys
        |-- cpu0
        |-- cpu1
        |-- pic0
        `-- rtc0

135 directories

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-09-24  1:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-24  1:45 [BK PATCH] driver model updates Patrick Mochel

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).