aboutsummaryrefslogtreecommitdiff
path: root/drivers/base/firmware_class.c
AgeCommit message (Collapse)AuthorFilesLines
2012-08-16firmware loader: simplify pages ownership transferMing Lei1-23/+39
This patch doesn't transfer ownership of pages' buffer to the instance of firmware until the firmware loading is completed, which will simplify firmware_loading_store a lot, so help to introduce the following cache_firmware and uncache_firmware mechanism during system suspend-resume cycle. In fact, this patch fixes one bug: if writing data into firmware loader device is bypassed between writting 1 and 0 to 'loading', OOPS will be triggered without the patch. Also handle the vmap failure case, and add some comments to make code more readable. Signed-off-by: Ming Lei <[email protected]> Cc: Linus Torvalds <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-07-16driver-core: Use kobj_to_dev instead of re-implementing itLars-Peter Clausen1-4/+2
Signed-off-by: Lars-Peter Clausen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2012-03-28firmware_class: Move request_firmware_nowait() to workqueuesStephen Boyd1-20/+7
Oddly enough a work_struct was already part of the firmware_work structure but nobody was using it. Instead of creating a new kthread for each request_firmware_nowait() call just schedule the work on the system workqueue. This should avoid some overhead in forking new threads when they're not strictly necessary. Signed-off-by: Stephen Boyd <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
2012-03-28firmware_class: Reorganize fw_create_instance()Stephen Boyd1-73/+62
Recent patches to split up the three phases of request_firmware() lead to a casting away of const in fw_create_instance(). We can avoid this cast by splitting up fw_create_instance() a bit. Make _request_firmware_setup() return a struct fw_priv and use that struct instead of passing struct firmware to _request_firmware(). Move the uevent and device file creation bits to the loading phase and rename the function to _request_firmware_load() to better reflect its purpose. Signed-off-by: Stephen Boyd <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
2012-03-28firmware_class: Do not warn that system is not ready from async loadsRafael J. Wysocki1-21/+30
If firmware is requested asynchronously, by calling request_firmware_nowait(), there is no reason to fail the request (and warn the user) when the system is (presumably temporarily) unready to handle it (because user space is not available yet or frozen). For this reason, introduce an alternative routine for read-locking umhelper_sem, usermodehelper_read_lock_wait(), that will wait for usermodehelper_disabled to be unset (possibly with a timeout) and make request_firmware_work_func() use it instead of usermodehelper_read_trylock(). Accordingly, modify request_firmware() so that it uses usermodehelper_read_trylock() to acquire umhelper_sem and remove the code related to that lock from _request_firmware(). Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Cc: [email protected]
2012-03-28firmware_class: Split _request_firmware() into three functions, v2Rafael J. Wysocki1-17/+41
Split _request_firmware() into three functions, _request_firmware_prepare() doing preparatory work that need not be done under umhelper_sem, _request_firmware_cleanup() doing the post-error cleanup and _request_firmware() carrying out the remaining operations. This change is requisite for moving the acquisition of umhelper_sem from _request_firmware() to the callers, which is going to be done subsequently. Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Cc: [email protected]
2012-03-28firmware_class: Rework usermodehelper checkRafael J. Wysocki1-6/+5
Instead of two functions, read_lock_usermodehelper() and usermodehelper_is_disabled(), used in combination, introduce usermodehelper_read_trylock() that will only return with umhelper_sem held if usermodehelper_disabled is unset (and will return -EAGAIN otherwise) and make _request_firmware() use it. Rename read_unlock_usermodehelper() to usermodehelper_read_unlock() to follow the naming convention of the new function. Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Cc: [email protected]
2012-01-23PM / Sleep: Fix read_unlock_usermodehelper() call.Tetsuo Handa1-2/+1
Commit b298d289 "PM / Sleep: Fix freezer failures due to racy usermodehelper_is_disabled()" added read_unlock_usermodehelper() but read_unlock_usermodehelper() is called without read_lock_usermodehelper() when kmalloc() failed. Signed-off-by: Tetsuo Handa <[email protected]> Acked-by: Srivatsa S. Bhat <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
2012-01-08Merge branch 'pm-for-linus' of ↵Linus Torvalds1-0/+4
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm * '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
2012-01-04firmware: Fix an oops on reading fw_priv->fw in sysfs loading fileNeil Horman1-7/+7
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 <[email protected]> Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2011-12-09PM / Sleep: Fix freezer failures due to racy usermodehelper_is_disabled()Srivatsa S. Bhat1-0/+4
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 <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
2011-08-24firmware loader: allow builtin firmware load even if usermodehelper is disabledLinus Torvalds1-5/+6
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 <[email protected]> Bisected-by: Elimar Riesebieter <[email protected]> Cc: Michel Dänzer <[email protected]> Cc: Rafael Wysocki <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Valdis Kletnieks <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2011-05-17PM: Print a warning if firmware is requested when tasks are frozenRafael J. Wysocki1-0/+5
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 <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Valdis Kletnieks <[email protected]>
2011-02-03firmware_classs: change val uevent's type to boolBob Liu1-4/+3
Some place in firmware_class.c using "int uevent" define, but others use "bool uevent". This patch replace all int uevent define to bool. Signed-off-by: Bob Liu <[email protected]> Acked-by: Dmitry Torokhov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2010-08-23firmware_class: fix typo in error pathJohannes Berg1-1/+1
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 <[email protected]> Signed-off-by: Johannes Berg <[email protected]> Acked-by: Dmitry Torokhov <[email protected]> Signed-off-by: Pekka Enberg <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2010-08-05firmware loader: embed device into firmware_priv structureDmitry Torokhov1-133/+122
Both these structures have the same lifetime rules so instead of allocating and managing them separately embed struct device into struct firmware_priv. Also make sure to delete sysfs attributes ourselves instead of expecting sysfs to clean up our mess. Signed-off-by: Dmitry Torokhov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2010-08-05firmware loader: use statically initialized data attributeDmitry Torokhov1-6/+3
There is no reason why we are using a template for binary attribute and copying it into per-firmware data before registering. Using the original works as well. Signed-off-by: Dmitry Torokhov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2010-05-21sysfs: add struct file* to bin_attr callbacksChris Wright1-4/+7
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 <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2010-05-21firmware loader: do not allocate firmare id separatelyDmitry Torokhov1-13/+4
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 <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2010-05-21firmware loader: split out builtin firmware handlingDmitry Torokhov1-26/+50
Split builtin firmware handling into separate functions to clean up the main body of code. Signed-off-by: Dmitry Torokhov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2010-05-21firmware loader: rely on driver core to create class attributeDmitry Torokhov1-35/+24
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 <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2010-05-21firmware class: export nowait to userspaceJohannes Berg1-5/+11
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 <[email protected]> Cc: Kay Sievers <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2010-05-21Driver core: Reduce the level of request_firmware() messagesRafael J. Wysocki1-3/+2
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 <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2010-05-21firmware_class: fix memory leak - free allocated pagesDavid Woodhouse1-6/+20
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 <[email protected]> Cc: Ming Lei <[email protected]> Cc: Catalin Marinas <[email protected]> Singed-off-by: Kay Sievers <[email protected]> Signed-off-by: David Woodhouse <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2010-03-30include cleanup: Update gfp.h and slab.h includes to prepare for breaking ↵Tejun Heo1-0/+1
implicit 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 <[email protected]> Guess-its-ok-by: Christoph Lameter <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Lee Schermerhorn <[email protected]>
2010-03-19driver-core: fix missing kernel-doc in firmware_classRandy Dunlap1-0/+1
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 <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2010-03-19sysfs: use sysfs_bin_attr_init in firmware class driverJiri Kosina1-0/+1
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: [<ffffffff8107c1d2>] ? lockdep_init_map+0x562/0x620 [<ffffffff81049fd8>] warn_slowpath_common+0x78/0xd0 [<ffffffff8104a03f>] warn_slowpath_null+0xf/0x20 [<ffffffff8107c1d2>] lockdep_init_map+0x562/0x620 [<ffffffff8117a236>] ? sysfs_new_dirent+0x76/0x120 [<ffffffff8126edb2>] ? put_device+0x12/0x20 [<ffffffff811797cc>] sysfs_add_file_mode+0x6c/0xd0 [<ffffffff8117983c>] sysfs_add_file+0xc/0x10 [<ffffffff8117bf61>] sysfs_create_bin_file+0x21/0x30 [<ffffffff81279c61>] _request_firmware+0x2f1/0x650 [<ffffffff8127a04e>] request_firmware+0xe/0x10 [<ffffffffa01ec19e>] bnx2_init_one+0x8f5/0x177e [bnx2] [<ffffffff81389eab>] ? _raw_spin_unlock_irq+0x2b/0x40 [<ffffffff81040ed9>] ? finish_task_switch+0x69/0x100 [<ffffffff81040e70>] ? finish_task_switch+0x0/0x100 [<ffffffff81064b40>] ? do_work_for_cpu+0x0/0x30 [<ffffffff811e6302>] local_pci_probe+0x12/0x20 [<ffffffff81064b53>] do_work_for_cpu+0x13/0x30 [<ffffffff81064b40>] ? do_work_for_cpu+0x0/0x30 [<ffffffff81068c56>] kthread+0x96/0xa0 [<ffffffff81003e64>] kernel_thread_helper+0x4/0x10 [<ffffffff8138a350>] ? restore_args+0x0/0x30 [<ffffffff81068bc0>] ? kthread+0x0/0xa0 [<ffffffff81003e60>] ? kernel_thread_helper+0x0/0x10 ---[ end trace a2ecee9c9602d195 ]--- Cc: Eric W. Biederman <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2010-03-07Driver core: Fix first line of kernel-doc for a few functionsBen Hutchings1-1/+1
The function name must be followed by a space, hypen, space, and a short description. Signed-off-by: Ben Hutchings <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2010-03-07driver-core: firmware_class: remove base.h header inclusionLuis R. Rodriguez1-1/+0
base.h is used by base drivers for sharing internal structures. Turns out firmware_class does not depend on it at all so remove it. Cc: Johannes Berg <[email protected]> Signed-off-by: Luis R. Rodriguez <[email protected]> Acked-by: Marcel Holtmann <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2010-03-07driver-core: Add attribute argument to class_attribute show/storeAndi Kleen1-2/+6
Passing the attribute to the low level IO functions allows all kinds of cleanups, by sharing low level IO code without requiring an own function for every piece of data. Also drivers can extend the attributes with own data fields and use that in the low level function. This makes the class attributes the same as sysdev_class attributes and plain attributes. This will allow further cleanups in drivers. Full tree sweep converting all users. Signed-off-by: Andi Kleen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2009-12-11firmware_class: make request_firmware_nowait more usefulJohannes Berg1-8/+6
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 <[email protected]> Acked-by: Marcel Holtmann <[email protected]> Cc: Ming Lei <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: David Woodhouse <[email protected]> Cc: Pavel Roskin <[email protected]> Cc: Abhay Salunke <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2009-07-28driver core: firmware_class:fix memory leak of page pointers arrayMing Lei1-1/+0
The page pointers array is allocated in fw_realloc_buffer() called by firmware_data_write(), and should be freed in release function of firmware device. Signed-off-by: Ming Lei <[email protected]> Reported-by: Catalin Marinas <[email protected]> Acked-by: David Woodhouse <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2009-07-12Firmware: firmware_class, fix lock imbalanceJiri Slaby1-2/+4
Add omitted unlock in firmware_data_read. Signed-off-by: Jiri Slaby <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2009-07-08Free struct device in fw_dev_release()Catalin Marinas1-4/+2
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 <[email protected]> Acked-by: Cornelia Huck <[email protected]> Acked-by: Ming Lei <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-06-15driver core: fix gcc 4.3.3 warnings about string literalsGreg Kroah-Hartman1-1/+1
This removes the warning: format not a string literal and no format arguments warnings in the driver core that gcc 4.3.3 complains about. Signed-off-by: Greg Kroah-Hartman <[email protected]>
2009-06-15firmware: allocate firmware id dynamicallySamuel Ortiz1-4/+12
The firmware loader has a statically allocated 30 bytes long string for the firmware id (a.k.a. the firmware file name). There is no reason why we couldnt allocate it dynamically, and avoid having restrictions on the firmware names lengths. Signed-off-by: Samuel Ortiz <[email protected]> Cc: Marcel Holtmann <[email protected]> Cc: Zhu Yi <[email protected]>, Cc: John Linville <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2009-06-15driver core: fix documentation of request_firmware_nowaitMing Lei1-2/+3
request_firmware_nowait declares it can be called in non-sleep contexts, but kthead_run called by request_firmware_nowait may sleep. So fix its documentation and comment to make callers clear about it. Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2009-06-15driver core: firmware_class: replace kfree(dev) with put_device(dev)Ming Lei1-3/+5
against v2.6.30-rc3-next tree. Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2009-05-15firmware: speed up request_firmware(), v3David Woodhouse1-26/+103
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 <[email protected]> Tested-by: Sachin Sant <[email protected]>
2009-03-24Driver core: implement uevent suppress in kobjectMing Lei1-2/+2
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 <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2009-01-06driver core: struct device - replace bus_id with dev_name(), dev_set_name()Kay Sievers1-7/+1
Signed-off-by: Kay Sievers <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2008-10-16firmware: use dev_printk when possibleBjorn Helgaas1-14/+10
Convert printks to use dev_printk(). Signed-off-by: Bjorn Helgaas <[email protected]> Cc: David Woodhouse <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-07-25firmware: use memory_read_from_buffer()Akinobu Mita1-9/+3
Signed-off-by: Akinobu Mita <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Markus Rechberger <[email protected]> Cc: Kay Sievers <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-07-10firmware: allow firmware files to be built into kernel imageDavid Woodhouse1-2/+31
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 <[email protected]>
2008-07-10firmware: make fw->data constDavid Woodhouse1-1/+1
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 <[email protected]>
2008-04-29firmware loader: printk when requesting firmwareCiaran McCreesh1-0/+2
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 <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-04-19driver core: replace remaining __FUNCTION__ occurrencesHarvey Harrison1-9/+9
__FUNCTION__ is gcc-specific, use __func__ Signed-off-by: Harvey Harrison <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2008-02-07Driver core: Revert "Fix Firmware class name collision"Michael E Brown1-1/+2
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 <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2007-10-12Fix Firmware class name collisionMarkus Rechberger1-2/+1
following patch fixes the i2c name collision with i2c-dev. http://mcentral.de/wiki/index.php/Bugtracker#i2c_core_problem This issue has been experienced with em28xx and saa7133 based devices. I discussed that problem with Jean Delvare a while ago and he proposed to add a prefix to the class name. Signed-off-by: Markus Rechberger <[email protected]> Acked-by: Marcel Holtmann <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2007-10-12Driver core: change add_uevent_var to use a structKay Sievers1-8/+3
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 <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Cornelia Huck <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>