09 Jan, 2012

1 commit

  • * 'pm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (76 commits)
    PM / Hibernate: Implement compat_ioctl for /dev/snapshot
    PM / Freezer: fix return value of freezable_schedule_timeout_killable()
    PM / shmobile: Allow the A4R domain to be turned off at run time
    PM / input / touchscreen: Make st1232 use device PM QoS constraints
    PM / QoS: Introduce dev_pm_qos_add_ancestor_request()
    PM / shmobile: Remove the stay_on flag from SH7372's PM domains
    PM / shmobile: Don't include SH7372's INTCS in syscore suspend/resume
    PM / shmobile: Add support for the sh7372 A4S power domain / sleep mode
    PM: Drop generic_subsys_pm_ops
    PM / Sleep: Remove forward-only callbacks from AMBA bus type
    PM / Sleep: Remove forward-only callbacks from platform bus type
    PM: Run the driver callback directly if the subsystem one is not there
    PM / Sleep: Make pm_op() and pm_noirq_op() return callback pointers
    PM/Devfreq: Add Exynos4-bus device DVFS driver for Exynos4210/4212/4412.
    PM / Sleep: Merge internal functions in generic_ops.c
    PM / Sleep: Simplify generic system suspend callbacks
    PM / Hibernate: Remove deprecated hibernation snapshot ioctls
    PM / Sleep: Fix freezer failures due to racy usermodehelper_is_disabled()
    ARM: S3C64XX: Implement basic power domain support
    PM / shmobile: Use common always on power domain governor
    ...

    Fix up trivial conflict in fs/xfs/xfs_buf.c due to removal of unused
    XBT_FORCE_SLEEP bit

    Linus Torvalds
     

05 Jan, 2012

1 commit

  • This oops was reported recently:
    firmware_loading_store+0xf9/0x17b
    dev_attr_store+0x20/0x22
    sysfs_write_file+0x101/0x134
    vfs_write+0xac/0xf3
    sys_write+0x4a/0x6e
    system_call_fastpath+0x16/0x1b

    The complete backtrace was unfortunately not captured, but details can be found
    here:
    https://bugzilla.redhat.com/show_bug.cgi?id=769920

    The cause is fairly clear.

    Its caused by the fact that firmware_loading_store has a case 0 in its
    switch statement that reads and writes the fw_priv->fw poniter without the
    protection of the fw_lock mutex. since there is a window between the time that
    _request_firmware sets fw_priv->fw to NULL and the time the corresponding sysfs
    file is unregistered, its possible for a user space application to race in, and
    write a zero to the loading file, causing a NULL dereference in
    firmware_loading_store. Fix it by extending the protection of the fw_lock mutex
    to cover all of the firware_loading_store function.

    Signed-off-by: Neil Horman
    Cc: stable
    Signed-off-by: Greg Kroah-Hartman

    Neil Horman
     

10 Dec, 2011

1 commit

  • Commit a144c6a (PM: Print a warning if firmware is requested when tasks
    are frozen) introduced usermodehelper_is_disabled() to warn and exit
    immediately if firmware is requested when usermodehelpers are disabled.

    However, it is racy. Consider the following scenario, currently used in
    drivers/base/firmware_class.c:

    ...
    if (usermodehelper_is_disabled())
    goto out;

    /* Do actual work */
    ...

    out:
    return err;

    Nothing prevents someone from disabling usermodehelpers just after the check
    in the 'if' condition, which means that it is quite possible to try doing the
    "actual work" with usermodehelpers disabled, leading to undesirable
    consequences.

    In particular, this race condition in _request_firmware() causes task freezing
    failures whenever suspend/hibernation is in progress because, it wrongly waits
    to get the firmware/microcode image from userspace when actually the
    usermodehelpers are disabled or userspace has been frozen.
    Some of the example scenarios that cause freezing failures due to this race
    are those that depend on userspace via request_firmware(), such as x86
    microcode module initialization and microcode image reload.

    Previous discussions about this issue can be found at:
    http://thread.gmane.org/gmane.linux.kernel/1198291/focus=1200591

    This patch adds proper synchronization to fix this issue.

    It is to be noted that this patchset fixes the freezing failures but doesn't
    remove the warnings. IOW, it does not attempt to add explicit synchronization
    to x86 microcode driver to avoid requesting microcode image at inopportune
    moments. Because, the warnings were introduced to highlight such cases, in the
    first place. And we need not silence the warnings, since we take care of the
    *real* problem (freezing failure) and hence, after that, the warnings are
    pretty harmless anyway.

    Signed-off-by: Srivatsa S. Bhat
    Signed-off-by: Rafael J. Wysocki

    Srivatsa S. Bhat
     

25 Aug, 2011

1 commit

  • In commit a144c6a6c924 ("PM: Print a warning if firmware is requested
    when tasks are frozen") we not only printed a warning if somebody tried
    to load the firmware when tasks are frozen - we also failed the load.

    But that check was done before the check for built-in firmware, and then
    when we disallowed usermode helpers during bootup (commit 288d5abec831:
    "Boot up with usermodehelper disabled"), that actually means that
    built-in modules can no longer load their firmware even if the firmware
    is built in too. Which used to work, and some people depended on it for
    the R100 driver.

    So move the test for usermodehelper_is_disabled() down, to after
    checking the built-in firmware.

    This should fix:

    https://bugzilla.kernel.org/show_bug.cgi?id=40952

    Reported-by: James Cloos
    Bisected-by: Elimar Riesebieter
    Cc: Michel Dänzer
    Cc: Rafael Wysocki
    Cc: Greg Kroah-Hartman
    Cc: Valdis Kletnieks
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

18 May, 2011

1 commit

  • Some drivers erroneously use request_firmware() from their ->resume()
    (or ->thaw(), or ->restore()) callbacks, which is not going to work
    unless the firmware has been built in. This causes system resume to
    stall until the firmware-loading timeout expires, which makes users
    think that the resume has failed and reboot their machines
    unnecessarily. For this reason, make _request_firmware() print a
    warning and return immediately with error code if it has been called
    when tasks are frozen and it's impossible to start any new usermode
    helpers.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Greg Kroah-Hartman
    Reviewed-by: Valdis Kletnieks

    Rafael J. Wysocki
     

04 Feb, 2011

1 commit


24 Aug, 2010

1 commit

  • In the error path, _request_firmware sets
    firmware_p to NULL rather than *firmware_p,
    which leads to passing a freed firmware
    struct to drivers when the firmware file
    cannot be found. Fix this.

    Broken by commit f8a4bd3456b988fc73b2c.

    Reported-by: Wey-Yi Guy
    Signed-off-by: Johannes Berg
    Acked-by: Dmitry Torokhov
    Signed-off-by: Pekka Enberg
    Signed-off-by: Greg Kroah-Hartman

    Johannes Berg
     

06 Aug, 2010

2 commits


22 May, 2010

7 commits

  • This allows bin_attr->read,write,mmap callbacks to check file specific data
    (such as inode owner) as part of any privilege validation.

    Signed-off-by: Chris Wright
    Signed-off-by: Greg Kroah-Hartman

    Chris Wright
     
  • fw_id has the same life time as firmware_priv so it makes sense to move
    it into firmware_priv structure instead of allocating separately.

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

    Dmitry Torokhov
     
  • Split builtin firmware handling into separate functions to clean up the
    main body of code.

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

    Dmitry Torokhov
     
  • Do not create 'timeout' attribute manually, let driver core do it for us.
    This also ensures that attribute is cleaned up properly.

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

    Dmitry Torokhov
     
  • When we use request_firmware_nowait(), userspace may
    not want to answer negatively right away when for
    example it is answering from an initrd only, but
    with request_firmware() it has to in order to not
    delay the kernel boot until the request times out.

    This allows userspace to differentiate between the
    two in order to be able to reply negatively to async
    requests only when all filesystems have been mounted
    and have been checked for the requested firmware file.

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

    Johannes Berg
     
  • The messages from _request_firmware() informing that firmware is
    being requested or built-in firmware is going to be used are printed
    at KERN_INFO, which produces lots of noise on systems with huge
    numbers of AMD CPUs. Reduce the level of these messages to
    KERN_DEBUG to get rid of that noise.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     
  • fix memory leak introduced by the patch 6e03a201bbe:
    firmware: speed up request_firmware()

    1. vfree won't release pages there were allocated explicitly and mapped
    using vmap. The memory has to be vunmap-ed and the pages needs
    to be freed explicitly

    2. page array is moved into the 'struct
    firmware' so that we can free it from release_firmware()
    and not only in fw_dev_release()

    The fix doesn't break the firmware load speed.

    Cc: Johannes Berg
    Cc: Ming Lei
    Cc: Catalin Marinas
    Singed-off-by: Kay Sievers
    Signed-off-by: David Woodhouse
    Signed-off-by: Tomas Winkler
    Signed-off-by: Greg Kroah-Hartman

    David Woodhouse
     

30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

19 Mar, 2010

2 commits

  • Fix kernel-doc warning in firmware_class.c:

    Warning(drivers/base/firmware_class.c:94): No description found for parameter 'attr'

    Signed-off-by: Randy Dunlap
    Signed-off-by: Greg Kroah-Hartman

    Randy Dunlap
     
  • Annotate dynamic sysfs attribute in fw_setup_device(). This gets
    rid of the following lockdep warning:

    bnx2 0000:08:00.0: firmware: requesting bnx2/bnx2-mips-06-5.0.0.j6.fw
    BUG: key ffff880008293470 not in .data!
    ------------[ cut here ]------------
    WARNING: at kernel/lockdep.c:2706 lockdep_init_map+0x562/0x620()
    Modules linked in: bnx2(+) sg tpm_bios floppy rtc_lib usb_storage i2c_piix4 joydev button container shpchp i2c_core sr_mod cdrom pci_hotplug usbhid hid ohci_hcd ehci_hcd sd_mod usbcore edd ext3 mbcache jbd fan ata_generic sata_svw pata_serverworks libata scsi_mod thermal processor
    Pid: 1915, comm: work_for_cpu Not tainted 2.6.34-rc1-default #81
    Call Trace:
    [] ? lockdep_init_map+0x562/0x620
    [] warn_slowpath_common+0x78/0xd0
    [] warn_slowpath_null+0xf/0x20
    [] lockdep_init_map+0x562/0x620
    [] ? sysfs_new_dirent+0x76/0x120
    [] ? put_device+0x12/0x20
    [] sysfs_add_file_mode+0x6c/0xd0
    [] sysfs_add_file+0xc/0x10
    [] sysfs_create_bin_file+0x21/0x30
    [] _request_firmware+0x2f1/0x650
    [] request_firmware+0xe/0x10
    [] bnx2_init_one+0x8f5/0x177e [bnx2]
    [] ? _raw_spin_unlock_irq+0x2b/0x40
    [] ? finish_task_switch+0x69/0x100
    [] ? finish_task_switch+0x0/0x100
    [] ? do_work_for_cpu+0x0/0x30
    [] local_pci_probe+0x12/0x20
    [] do_work_for_cpu+0x13/0x30
    [] ? do_work_for_cpu+0x0/0x30
    [] kthread+0x96/0xa0
    [] kernel_thread_helper+0x4/0x10
    [] ? restore_args+0x0/0x30
    [] ? kthread+0x0/0xa0
    [] ? kernel_thread_helper+0x0/0x10
    ---[ end trace a2ecee9c9602d195 ]---

    Cc: Eric W. Biederman
    Cc: Greg Kroah-Hartman
    Signed-off-by: Jiri Kosina
    Signed-off-by: Greg Kroah-Hartman

    Jiri Kosina
     

08 Mar, 2010

3 commits


12 Dec, 2009

1 commit

  • Unfortunately, one cannot hold on to the struct firmware
    that request_firmware_nowait() hands off, which is needed
    in some cases. Allow this by requiring the callback to
    free it (via release_firmware).

    Additionally, give it a gfp_t parameter -- all the current
    users call it from a GFP_KERNEL context so the GFP_ATOMIC
    isn't necessary. This also marks an API break which is
    useful in a sense, although that is obviously not the
    primary purpose of this change.

    Signed-off-by: Johannes Berg
    Acked-by: Marcel Holtmann
    Cc: Ming Lei
    Cc: Catalin Marinas
    Cc: David Woodhouse
    Cc: Pavel Roskin
    Cc: Abhay Salunke
    Signed-off-by: Greg Kroah-Hartman

    Johannes Berg
     

29 Jul, 2009

1 commit


13 Jul, 2009

1 commit


09 Jul, 2009

1 commit

  • The f_dev in _request_firmware() is allocated via the fw_setup_device()
    and fw_register_device() calls and its class set to firmware_class (the
    class release function is fw_dev_release).

    Commit 6acf70f078ca replaced the kfree(dev) in fw_dev_release() with a
    put_device() call but my understanding is that the release function is
    called via put_device -> kobject_put -> kref_put -> koject_release etc.
    and it should call kfree since it's the last to see this device
    structure alive.

    Because of that, the _request_firmware() function on its -ENOENT error
    path only calls device_unregister(f_dev) which would eventually call
    fw_dev_release() but there is no kfree (the subsequent put_device call
    would just make the kref negative).

    Signed-off-by: Catalin Marinas
    Acked-by: Cornelia Huck
    Acked-by: Ming Lei
    Signed-off-by: Linus Torvalds

    Catalin Marinas
     

16 Jun, 2009

4 commits


15 May, 2009

1 commit

  • Rather than calling vmalloc() repeatedly to grow the firmware image as
    we receive data from userspace, just allocate and fill individual pages.
    Then vmap() the whole lot in one go when we're done.

    A quick test with a 337KiB iwlagn firmware shows the time taken for
    request_firmware() going from ~32ms to ~5ms after I apply this patch.

    [v2: define PAGE_KERNEL_RO as PAGE_KERNEL where necessary, use min_t()]
    [v3: kunmap() takes the struct page *, not the virtual address]

    Signed-off-by: David Woodhouse
    Tested-by: Sachin Sant

    David Woodhouse
     

25 Mar, 2009

1 commit

  • This patch implements uevent suppress in kobject and removes it
    from struct device, based on the following ideas:

    1,Uevent sending should be one attribute of kobject, so suppressing it
    in kobject layer is more natural than in device layer. By this way,
    we can do it for other objects embedded with kobject.

    2,It may save several bytes for each instance of struct device.(On my
    omap3(32bit ARM) based box, can save 8bytes per device object)

    This patch also introduces dev_set|get_uevent_suppress() helpers to
    set and query uevent_suppress attribute in case to help kobject
    as private part of struct device in future.

    [This version is against the latest driver-core patch set of Greg,please
    ignore the last version.]

    Signed-off-by: Ming Lei
    Signed-off-by: Greg Kroah-Hartman

    Ming Lei
     

07 Jan, 2009

1 commit


17 Oct, 2008

1 commit


26 Jul, 2008

1 commit


10 Jul, 2008

2 commits

  • Some drivers have their own hacks to bypass the kernel's firmware loader
    and build their firmware into the kernel; this renders those unnecessary.

    Other drivers don't use the firmware loader at all, because they always
    want the firmware to be available. This allows them to start using the
    firmware loader.

    A third set of drivers already use the firmware loader, but can't be
    used without help from userspace, which sometimes requires an initrd.
    This allows them to work in a static kernel.

    Signed-off-by: David Woodhouse

    David Woodhouse
     
  • In preparation for supporting firmware files linked into the static
    kernel, make fw->data const to ensure that users aren't modifying it (so
    that we can pass a pointer to the original in-kernel copy, rather than
    having to copy it).

    Signed-off-by: David Woodhouse

    David Woodhouse
     

29 Apr, 2008

1 commit

  • Before requesting firmware, printk a message saying what we're requesting. This
    makes it easier to see what's going on, and provides an explanation for the
    huge silent delay that one would otherwise get after accidentally building
    ipw2200 as a non-module.

    Cc: Greg KH
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ciaran McCreesh
     

20 Apr, 2008

1 commit


08 Feb, 2008

1 commit

  • This reverts commit 109f0e93b6b728f03c1eb4af02bc25d71b646c59.

    The original patch breaks BIOS updates on all Dell machines. The path to
    the firmware file for the dell_rbu driver changes, which breaks all of
    the userspace tools which rely on it.

    Note that this patch re-introduces a problem with i2c name collision
    that was previously fixed by this patch.

    Signed-off-by: Michael E Brown
    Signed-off-by: Greg Kroah-Hartman

    Michael E Brown