13 Oct, 2007

2 commits

  • This changes the uevent buffer functions to use a struct instead of a
    long list of parameters. It does no longer require the caller to do the
    proper buffer termination and size accounting, which is currently wrong
    in some places. It fixes a known bug where parts of the uevent
    environment are overwritten because of wrong index calculations.

    Many thanks to Mathieu Desnoyers for finding bugs and improving the
    error handling.

    Signed-off-by: Kay Sievers
    Cc: Mathieu Desnoyers
    Cc: Cornelia Huck
    Signed-off-by: Greg Kroah-Hartman

    Kay Sievers
     
  • Attributes do not have an owner(module) anymore, so there is no need
    to carry the attributes in every single bus instance.

    Signed-off-by: Kay Sievers
    Acked-by: Tejun Heo
    Signed-off-by: Greg Kroah-Hartman

    Kay Sievers
     

27 Jul, 2007

1 commit

  • Commit bd804eba1c8597cbb7cd5a5f9fe886aae16a079a ("PM: Introduce
    pm_power_off_prepare") caused problems in the poweroff path, as reported by
    YOSHIFUJI Hideaki / 吉藤英明.

    Generally, sysdev_shutdown() should be called after the ACPI preparation for
    powering the system off. To make it happen, we can separate sysdev_shutdown()
    from device_shutdown() and call it directly wherever necessary.

    Signed-off-by: Rafael J. Wysocki
    Tested-by: YOSHIFUJI Hideaki / 吉藤英明
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

19 Jul, 2007

1 commit

  • This defines a dev_vdbg() call, which is enabled with -DVERBOSE_DEBUG.
    When enabled, dev_vdbg() acts just like dev_dbg(). When disabled, it is a
    NOP ... just like dev_dbg() without -DDEBUG. The specific code was moved
    out of a USB patch, but lots of drivers have similar support.

    That is, code can now be written to use an additional level of debug
    output, selected at compile time. Many driver authors have found this
    idiom to be very useful. A typical usage model is for "normal" debug
    messages to focus on fault paths and not be very "chatty", so that those
    messages can be left on during normal operation without much of a
    performance or syslog load. On the other hand "verbose" messages would be
    noisy enough that they wouldn't normally be enabled; they might even affect
    timings enough to change system or driver behavior.

    Signed-off-by: David Brownell
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    David Brownell
     

12 Jul, 2007

1 commit

  • devt_attr and uevent_attr are either allocated dynamically with or
    embedded in device and class_device as they needed their owner field
    set to the module implementing the driver. Now that sysfs implements
    immediate disconnect and owner field removed from struct attribute,
    there is no reason to do this. Remove these attributes from
    [class_]device and use static attribute structures instead.

    Signed-off-by: Tejun Heo
    Signed-off-by: Greg Kroah-Hartman

    Tejun Heo
     

09 May, 2007

1 commit

  • We've had various reports of some legacy "probe the hardware" style
    platform drivers having nasty problems with hotplug support.

    The core issue is that those legacy drivers don't fully conform to the
    driver model. They assume a role that should be the responsibility of
    infrastructure code: creating device nodes.

    The "modprobe" step in hotplugging relies on drivers to have split those
    roles into different modules. The lack of this split causes the problems.
    When a driver creates nodes for devices that don't exist (sending a hotplug
    event), then exits (aborting one modprobe) before the "modprobe $MODALIAS"
    step completes (by failing, since it's in the middle of a modprobe), the
    result can be an endless loop of modprobe invocations ... badness.

    This fix uses the newish per-device flag controlling issuance of "add"
    events. (A previous version of this patch used a per-device "driver can
    hotplug" flag, which only scrubbed $MODALIAS from the environment rather
    than suppressing the entire hotplug event.) It also shrinks that flag to
    one bit, saving a word in "struct device".

    So the net of this patch is removing some nasty failures with legacy
    drivers, while retaining hotplug capability for the majority of platform
    drivers.

    Signed-off-by: David Brownell
    Cc: Greg KH
    Cc: Andres Salomon
    Cc: Dominik Brodowski
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     

05 May, 2007

1 commit


03 May, 2007

2 commits


28 Apr, 2007

9 commits

  • Duplicate what Zach Brown did for pr_debug in commit
    8b2a1fd1b394c60eaa2587716102dd5e9b4e5990

    [akpm@linux-foundation.org: fix a couple of things which broke]
    Signed-off-by: Dan Williams
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    Dan Williams
     
  • This patch (as896b) fixes an oversight in the design of
    device_schedule_callback(). It is necessary to acquire a reference to the
    module owning the callback routine, to prevent the module from being
    unloaded before the callback can run.

    Signed-off-by: Alan Stern
    Cc: Satyam Sharma
    Cc: Neil Brown
    Cc: Cornelia Huck
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • Driver core: add suspend() and resume() to struct device_type

    In cases when there are devices of different types in the same class
    we can't use class's implementation of suspend and resume methods and
    we need to add them to struct device_type instead.

    Also fix error handling in resume code (we should not try to call
    class's resume method iof bus's resume method for the device failed.

    Signed-off-by: Dmitry Torokhov
    Signed-off-by: Greg Kroah-Hartman

    Dmitry Torokhov
     
  • The completion in the driver release path is due to ancient history in
    the _very_ early 2.5 days when we were not tracking the module reference
    count of attributes. It is not needed at all and can be removed.

    Note, we now have an empty release function for the driver structure.
    This is due to the fact that drivers are statically allocated in the
    system at this point in time, something which I want to change in the
    future. But remember, drivers are really code, which is reference
    counted by the module, unlike devices, which are data and _must_ be
    reference counted properly in order to work correctly.

    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • Make multithreaded probing work per subsystem instead of per driver.

    It doesn't make much sense to probe the same device for multiple drivers in
    parallel (after all, only one driver can bind to the device). Instead, create
    a probing thread for each device that probes the drivers one after another.
    Also make the decision to use multi-threaded probe per bus instead of per
    device and adapt the pci code.

    Signed-off-by: Cornelia Huck
    Cc: Benjamin Herrenschmidt
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    Cornelia Huck
     
  • If "name" of a device_type is specified, the uevent will
    contain the device_type name in the DEVTYPE variable.
    This helps userspace to distingiush between different types
    of devices, belonging to the same subsystem.

    Signed-off-by: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Kay Sievers
     
  • Driver core: use attribute groups in struct device_type

    Attribute groups are more flexible than attribute lists
    (an attribute list can be represented by anonymous group)
    so switch struct device_type to use them.

    Also rework attribute creation for devices so that they all
    cleaned up properly in case of errors.

    Signed-off-by: Dmitry Torokhov
    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Dmitry Torokhov
     
  • We get two per-bus sysfs files:
    ls-l /sys/subsystem/usb
    drwxr-xr-x 2 root root 0 2007-02-16 16:42 devices
    drwxr-xr-x 7 root root 0 2007-02-16 14:55 drivers
    -rw-r--r-- 1 root root 4096 2007-02-16 16:42 drivers_autoprobe
    --w------- 1 root root 4096 2007-02-16 16:42 drivers_probe

    The flag "drivers_autoprobe" controls the behavior of the bus to bind
    devices by default, or just initialize the device and leave it alone.

    The command "drivers_probe" accepts a bus_id and the bus tries to bind a
    driver to this device.

    Systems who want to control the driver binding with udev, switch off the
    bus initiated probing:
    echo 0 > /sys/subsystem/usb/drivers_autoprobe
    echo 0 > /sys/subsystem/pcmcia/drivers_autoprobe
    ...

    and initiate the probing with udev rules like:
    ACTION=="add", SUBSYSTEM=="usb", ATTR{subsystem/drivers_probe}="$kernel"
    ACTION=="add", SUBSYSTEM=="pcmcia", ATTR{subsystem/drivers_probe}="$kernel"
    ...

    Custom driver binding can happen in earlier rules by something like:
    ACTION=="add", SUBSYSTEM=="usb", \
    ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678" \
    ATTR{subsystem/drivers//bind}="$kernel"

    This is intended to solve the modprobe.conf mess with "install-rules", custom
    bind/unbind-scripts and all the weird things people invented over the years.
    It should also provide the functionality "libusual" was supposed to do.

    With udev, one can just write a udev rule to drive all USB-disks at the
    third port of USB-hub by the "ub" driver, and everything else by
    usb-storage. One can also instruct udev to bind different wireless
    drivers to identical cards - just selected by the pcmcia slot-number, and
    whatever ...

    To use the mentioned rules, it needs udev version 106, to be able to
    write ATTR{}="$kernel" to sysfs files.

    Signed-off-by: Greg Kroah-Hartman

    Kay Sievers
     
  • - uses a kset in "struct class" to keep track of all directories
    belonging to this class
    - merges with the /sys/devices/virtual logic.
    - removes the namespace-dir if the last member of that class
    leaves the directory.

    There may be locking or refcounting fixes left, I stopped when it seemed
    to work with network and sound modules. :)

    From: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Kay Sievers
     

03 Apr, 2007

1 commit


16 Mar, 2007

1 commit

  • This patch (as868) adds a helper routine for device drivers that need
    to set up a callback to perform some action in a different process's
    context. This is intended for use by attribute methods that want to
    unregister themselves or their parent device. Attribute method calls
    are mutually exclusive with unregistration, so such actions cannot be
    taken directly.

    Two attribute methods are converted to use the new helper routine: one
    for SCSI device deletion and one for System/390 ccwgroup devices.

    Signed-off-by: Alan Stern
    Cc: Hugh Dickins
    Cc: Cornelia Huck
    Cc: Oliver Neukum
    Signed-off-by: Linus Torvalds

    Alan Stern
     

24 Feb, 2007

1 commit


20 Feb, 2007

1 commit

  • * git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial: (25 commits)
    Documentation/kernel-docs.txt update.
    arch/cris: typo in KERN_INFO
    Storage class should be before const qualifier
    kernel/printk.c: comment fix
    update I/O sched Kconfig help texts - CFQ is now default, not AS.
    Remove duplicate listing of Cris arch from README
    kbuild: more doc. cleanups
    doc: make doc. for maxcpus= more visible
    drivers/net/eexpress.c: remove duplicate comment
    add a help text for BLK_DEV_GENERIC
    correct a dead URL in the IP_MULTICAST help text
    fix the BAYCOM_SER_HDX help text
    fix SCSI_SCAN_ASYNC help text
    trivial documentation patch for platform.txt
    Fix typos concerning hierarchy
    Fix comment typo "spin_lock_irqrestore".
    Fix misspellings of "agressive".
    drivers/scsi/a100u2w.c: trivial typo patch
    Correct trivial typo in log2.h.
    Remove useless FIND_FIRST_BIT() macro from cardbus.c.
    ...

    Linus Torvalds
     

18 Feb, 2007

1 commit


17 Feb, 2007

1 commit


10 Feb, 2007

1 commit

  • Implement device resource management, in short, devres. A device
    driver can allocate arbirary size of devres data which is associated
    with a release function. On driver detach, release function is
    invoked on the devres data, then, devres data is freed.

    devreses are typed by associated release functions. Some devreses are
    better represented by single instance of the type while others need
    multiple instances sharing the same release function. Both usages are
    supported.

    devreses can be grouped using devres group such that a device driver
    can easily release acquired resources halfway through initialization
    or selectively release resources (e.g. resources for port 1 out of 4
    ports).

    This patch adds devres core including documentation and the following
    managed interfaces.

    * alloc/free : devm_kzalloc(), devm_kzfree()
    * IO region : devm_request_region(), devm_release_region()
    * IRQ : devm_request_irq(), devm_free_irq()
    * DMA : dmam_alloc_coherent(), dmam_free_coherent(),
    dmam_declare_coherent_memory(), dmam_pool_create(),
    dmam_pool_destroy()
    * PCI : pcim_enable_device(), pcim_pin_device(), pci_is_managed()
    * iomap : devm_ioport_map(), devm_ioport_unmap(), devm_ioremap(),
    devm_ioremap_nocache(), devm_iounmap(), pcim_iomap_table(),
    pcim_iomap(), pcim_iounmap()

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

08 Feb, 2007

3 commits


21 Dec, 2006

1 commit


08 Dec, 2006

1 commit

  • For node-aware skb allocations we need information about the node in struct
    net_device or struct device. Davem suggested to put it into struct device
    which this patch does.

    In particular:

    - struct device gets a new int numa_node member if CONFIG_NUMA is set
    - there are two new helpers, dev_to_node and set_dev_node to
    transparently deal with the non-numa case
    - for pci devices the node-info is set to the value we get from
    pcibus_to_node.

    Note that for some architectures pcibus_to_node doesn't work yet at the time
    we call it currently. This is harmless and will just mean skb allocations
    aren't node-local on this architectures until the implementation of
    pcibus_to_node on these architectures have been updated (There are patches for
    x86 and x86_64 floating around)

    [akpm@osdl.org: cleanup]
    Signed-off-by: Christoph Hellwig
    Cc: Christoph Lameter
    Cc: Greg KH
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Hellwig
     

02 Dec, 2006

6 commits

  • Provide a function device_move() to move a device to a new parent device. Add
    auxilliary functions kobject_move() and sysfs_move_dir().
    kobject_move() generates a new uevent of type KOBJ_MOVE, containing the
    previous path (DEVPATH_OLD) in addition to the usual values. For this, a new
    interface kobject_uevent_env() is created that allows to add further
    environmental data to the uevent at the kobject layer.

    Signed-off-by: Cornelia Huck
    Acked-by: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Cornelia Huck
     
  • Introduce device_find_child() to match device_for_each_child().

    Signed-off-by: Cornelia Huck
    Signed-off-by: Greg Kroah-Hartman

    Cornelia Huck
     
  • Change ACPI to use dev_archdata instead of firmware_data

    This patch changes ACPI to use the new dev_archdata on i386, x86_64
    and ia64 (is there any other arch using ACPI ?) to store it's
    acpi_handle.

    It also removes the firmware_data field from struct device as this
    was the only user.

    Only build-tested on x86

    Signed-off-by: Benjamin Herrenschmidt
    Cc: Len Brown
    Signed-off-by: Greg Kroah-Hartman

    Benjamin Herrenschmidt
     
  • Add arch specific dev_archdata to struct device

    Adds an arch specific struct dev_arch to struct device. This enables
    architecture to add specific fields to every device in the system, like
    DMA operation pointers, NUMA node ID, firmware specific data, etc...

    Signed-off-by: Benjamin Herrenschmidt
    Acked-by: Andi Kleen
    Acked-By: David Howells
    Signed-off-by: Greg Kroah-Hartman

    Benjamin Herrenschmidt
     
  • It doesn't need to be global or in device.h

    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • I finally did as you suggested and added the notifier to the struct
    bus_type itself. There are still problems to be expected is something
    attaches to a bus type where the code can hook in different struct
    device sub-classes (which is imho a big bogosity but I won't even try to
    argue that case now) but it will solve nicely a number of issues I've
    had so far.

    That also means that clients interested in registering for such
    notifications have to do it before devices are added and after bus types
    are registered. Fortunately, most bus types that matter for the various
    usage scenarios I have in mind are registerd at postcore_initcall time,
    which means I have a really nice spot at arch_initcall time to add my
    notifiers.

    There are 4 notifications provided. Device being added (before hooked to
    the bus) and removed (failure of previous case or after being unhooked
    from the bus), along with driver being bound to a device and about to be
    unbound.

    The usage I have for these are:

    - The 2 first ones are used to maintain a struct device_ext that is
    hooked to struct device.firmware_data. This structure contains for now a
    pointer to the Open Firmware node related to the device (if any), the
    NUMA node ID (for quick access to it) and the DMA operations pointers &
    iommu table instance for DMA to/from this device. For bus types I own
    (like IBM VIO or EBUS), I just maintain that structure directly from the
    bus code when creating the devices. But for bus types managed by generic
    code like PCI or platform (actually, of_platform which is a variation of
    platform linked to Open Firmware device-tree), I need this notifier.

    - The other two ones have a completely different usage scenario. I have
    cases where multiple devices and their drivers depend on each other. For
    example, the IBM EMAC network driver needs to attach to a MAL DMA engine
    which is a separate device, and a PHY interface which is also a separate
    device. They are all of_platform_device's (well, about to be with my
    upcoming patches) but there is no say in what precise order the core
    will "probe" them and instanciate the various modules. The solution I
    found for that is to have the drivers for emac to use multithread_probe,
    and wait for a driver to be bound to the target MAL and PHY control
    devices (the device-tree contains reference to the MAL and PHY interface
    nodes, which I can then match to of_platform_devices). Right now, I've
    been polling, but with that notifier, I can more cleanly wait (with a
    timeout of course).

    Signed-off-by: Benjamin Herrenschmidt
    Signed-off-by: Greg Kroah-Hartman

    Benjamin Herrenschmidt
     

24 Oct, 2006

1 commit

  • Eliminate more __must_check madness.

    The return code from device_for_each_child() depends on the values
    which the helper function returns. If the helper function always
    returns zero, it's utterly pointless to check the return code from
    device_for_each_child().

    The only code which knows if the return value should be checked is
    the caller itself, so forcing the return code to always be checked
    is silly. Hence, remove the __must_check annotation.

    Signed-off-by: Russell King
    Signed-off-by: Linus Torvalds

    Russell King
     

26 Sep, 2006

3 commits

  • There is a potential deadlock in the driver core. It boils down to
    the fact that bus_remove_device() calls klist_remove() instead of
    klist_del(), thereby waiting until the reference count of the
    klist_node in the bus's klist of devices drops to 0. The refcount
    can't reach 0 so long as a modprobe process is trying to bind a new
    driver to the device being removed, by calling __driver_attach(). The
    problem is that __driver_attach() tries to acquire the device's
    parent's semaphore, but the caller of bus_remove_device() is quite
    likely to own that semaphore already.

    It isn't sufficient just to replace klist_remove() with klist_del().
    Doing so runs the risk that the device would remain on the bus's klist
    of devices for some time, and so could be bound to another driver even
    after it was unregistered. What's needed is a new way to distinguish
    whether or not a device is registered, based on a criterion other than
    whether its klist_node is linked into the bus's klist of devices. That
    way driver binding can fail when the device is unregistered, even if
    it is still linked into the klist.

    This patch (as782) implements the solution, by adding a new bitflag to
    indiate when a struct device is registered, by testing the flag before
    allowing a driver to bind a device, and by changing the definition of
    the device_is_registered() inline.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • This adds the infrastructure for drivers to do a threaded probe, and
    waits at init time for all currently outstanding probes to complete.

    A new kernel thread will be created when the probe() function for the
    driver is called, if the multithread_probe bit is set in the driver
    saying it can support this kind of operation.

    I have tested this with USB and PCI, and it works, and shaves off a lot
    of time in the boot process, but there are issues with finding root boot
    disks, and some USB drivers assume that this can never happen, so it is
    currently not enabled for any bus type. Individual drivers can enable
    this right now if they wish, and bus authors can selectivly turn it on
    as well, once they determine that their subsystem will work properly
    with it.

    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • Add lots of return-value checking.

    : fix bus_rescan_devices()]
    Cc: "Randy.Dunlap"
    Signed-off-by: Cornelia Huck
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    Andrew Morton