<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/base/firmware_class.c, branch v3.8</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v3.8</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v3.8'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2013-01-16T17:09:53Z</updated>
<entry>
<title>firmware: make sure the fw file size is not 0</title>
<updated>2013-01-16T17:09:53Z</updated>
<author>
<name>Luciano Coelho</name>
<email>coelho@ti.com</email>
</author>
<published>2013-01-15T08:43:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4adf07fba3bd64472921a01aae0e116f9f948b77'/>
<id>urn:sha1:4adf07fba3bd64472921a01aae0e116f9f948b77</id>
<content type='text'>
If the requested firmware file size is 0 bytes in the filesytem, we
will try to vmalloc(0), which causes a warning:

  vmalloc: allocation failure: 0 bytes
  kworker/1:1: page allocation failure: order:0, mode:0xd2
    __vmalloc_node_range+0x164/0x208
    __vmalloc_node+0x4c/0x58
    vmalloc+0x38/0x44
    _request_firmware_load+0x220/0x6b0
    request_firmware+0x64/0xc8
    wl18xx_setup+0xb4/0x570 [wl18xx]
    wlcore_nvs_cb+0x64/0x9f8 [wlcore]
    request_firmware_work_func+0x94/0x100
    process_one_work+0x1d0/0x750
    worker_thread+0x184/0x4ac
    kthread+0xb4/0xc0

To fix this, check whether the file size is less than or equal to zero
in fw_read_file_contents().

Cc: stable &lt;stable@vger.kernel.org&gt; [3.7]
Signed-off-by: Luciano Coelho &lt;coelho@ti.com&gt;
Acked-by: Ming Lei &lt;ming.lei@canonical.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>firmware loader: document firmware cache mechanism</title>
<updated>2012-11-14T23:07:18Z</updated>
<author>
<name>Ming Lei</name>
<email>tom.leiming@gmail.com</email>
</author>
<published>2012-11-03T09:48:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=6a927857d890658789e6e54b058ef8527de8200a'/>
<id>urn:sha1:6a927857d890658789e6e54b058ef8527de8200a</id>
<content type='text'>
This patch documents the firmware cache mechanism so that
users of request_firmware() know that it can be called
safely inside device's suspend and resume callback, and
the device's firmware needn't be cached any more by individual
driver itself to deal with firmware loss during system resume.

Signed-off-by: Ming Lei &lt;ming.lei@canonical.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>firmware loader: introduce module parameter to customize(v4) fw search path</title>
<updated>2012-11-14T23:07:18Z</updated>
<author>
<name>Ming Lei</name>
<email>ming.lei@canonical.com</email>
</author>
<published>2012-11-03T09:47:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=27602842060484b564cd725241b402b0bddfb830'/>
<id>urn:sha1:27602842060484b564cd725241b402b0bddfb830</id>
<content type='text'>
This patch introduces one module parameter of 'path' in firmware_class
to support customizing firmware image search path, so that people can
use its own firmware path if the default built-in paths can't meet their
demand[1], and the typical usage is passing the below from kernel command
parameter when 'firmware_class' is built in kernel:

	firmware_class.path=$CUSTOMIZED_PATH

[1], https://lkml.org/lkml/2012/10/11/337

Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Ming Lei &lt;ming.lei@canonical.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>firmware: use noinline_for_stack</title>
<updated>2012-11-14T23:05:05Z</updated>
<author>
<name>Cesar Eduardo Barros</name>
<email>cesarb@cesarb.net</email>
</author>
<published>2012-10-27T22:37:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=60dac5e284fe99751e3beefe1a9cc7a0771ad73c'/>
<id>urn:sha1:60dac5e284fe99751e3beefe1a9cc7a0771ad73c</id>
<content type='text'>
The comment above fw_file_size() suggests it is noinline for stack size
reasons. Use noinline_for_stack to make this more clear.

Signed-off-by: Cesar Eduardo Barros &lt;cesarb@cesarb.net&gt;
Acked-by: Ming Lei &lt;ming.lei@canonical.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>firmware loader: Fix the concurrent request_firmware() race for kref_get/put</title>
<updated>2012-11-14T23:04:23Z</updated>
<author>
<name>Chuansheng Liu</name>
<email>chuansheng.liu@intel.com</email>
</author>
<published>2012-11-09T17:27:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=bd9eb7fbe69111ea0ff1f999ef4a5f26d223d1d5'/>
<id>urn:sha1:bd9eb7fbe69111ea0ff1f999ef4a5f26d223d1d5</id>
<content type='text'>
There is one race that both request_firmware() with the same
firmware name.

The race scenerio is as below:
CPU1                                                  CPU2
request_firmware() --&gt;
_request_firmware_load() return err                   another request_firmware() is coming --&gt;
_request_firmware_cleanup is called --&gt;               _request_firmware_prepare --&gt;
release_firmware ---&gt;                                 fw_lookup_and_allocate_buf --&gt;
                                                      spin_lock(&amp;fwc-&gt;lock)
...                                                   __fw_lookup_buf() return true
fw_free_buf() will be called --&gt;                      ...
kref_put --&gt;
decrease the refcount to 0
                                                      kref_get(&amp;tmp-&gt;ref) ==&gt; it will trigger warning
                                                                              due to refcount == 0
__fw_free_buf() --&gt;
...                                                   spin_unlock(&amp;fwc-&gt;lock)
spin_lock(&amp;fwc-&gt;lock)
list_del(&amp;buf-&gt;list)
spin_unlock(&amp;fwc-&gt;lock)
kfree(buf)
                                                      After that, the freed buf will be used.

The key race is decreasing refcount to 0 and list_del is not protected together by
fwc-&gt;lock, and it is possible another thread try to get it between refcount==0
and list_del.

Fix it here to protect it together.

Acked-by: Ming Lei &lt;ming.lei@canonical.com&gt;
Signed-off-by: liu chuansheng &lt;chuansheng.liu@intel.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>firmware loader: Fix the race FW_STATUS_DONE is followed by class_timeout</title>
<updated>2012-11-14T23:04:23Z</updated>
<author>
<name>Chuansheng Liu</name>
<email>chuansheng.liu@intel.com</email>
</author>
<published>2012-11-08T11:14:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ce2fcbd99cef580623116bb33531dbc3e6f690b0'/>
<id>urn:sha1:ce2fcbd99cef580623116bb33531dbc3e6f690b0</id>
<content type='text'>
There is a race as below when calling request_firmware():
CPU1                                   CPU2
write 0 &gt; loading
mutex_lock(&amp;fw_lock)
...
set_bit FW_STATUS_DONE                 class_timeout is coming
                                       set_bit FW_STATUS_ABORT
complete_all &amp;completion
...
mutex_unlock(&amp;fw_lock)

In this time, the bit FW_STATUS_DONE and FW_STATUS_ABORT are set,
and request_firmware() will return failure due to condition in
_request_firmware_load():
	if (!buf-&gt;size || test_bit(FW_STATUS_ABORT, &amp;buf-&gt;status))
		retval = -ENOENT;

But from the above scenerio, it should be a successful requesting.
So we need judge if the bit FW_STATUS_DONE is already set before
calling fw_load_abort() in timeout function.

As Ming's proposal, we need change the timer into sched_work to
benefit from using &amp;fw_lock mutex also.

Signed-off-by: liu chuansheng &lt;chuansheng.liu@intel.com&gt;
Acked-by: Ming Lei &lt;ming.lei@canonical.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>firmware loader: sync firmware cache by async_synchronize_full_domain</title>
<updated>2012-10-22T15:37:18Z</updated>
<author>
<name>Ming Lei</name>
<email>ming.lei@canonical.com</email>
</author>
<published>2012-10-09T04:01:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d28d3882bd1fdb88ae4e02f11b091a92b0e5068b'/>
<id>urn:sha1:d28d3882bd1fdb88ae4e02f11b091a92b0e5068b</id>
<content type='text'>
async.c has provided synchronization mechanism on async_schedule_*,
so use async_synchronize_full_domain to sync caching firmware instead
of reinventing the wheel.

Signed-off-by: Ming Lei &lt;ming.lei@canonical.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>firmware loader: let direct loading back on 'firmware_buf'</title>
<updated>2012-10-22T15:37:17Z</updated>
<author>
<name>Ming Lei</name>
<email>ming.lei@canonical.com</email>
</author>
<published>2012-10-09T04:01:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=746058f4304343507e48d39f80d7a3b0d8550e3a'/>
<id>urn:sha1:746058f4304343507e48d39f80d7a3b0d8550e3a</id>
<content type='text'>
Firstly 'firmware_buf' is introduced to make all loading requests
to share one firmware kernel buffer, so firmware_buf should
be used in direct loading for saving memory and speedup firmware
loading.

Secondly, the commit below

	abb139e75c2cdbb955e840d6331cb5863e409d0e(firmware:teach
	the kernel to load firmware files directly from the filesystem)

introduces direct loading for fixing udev regression, but it
bypasses the firmware cache meachnism, so this patch enables
caching firmware for direct loading case since it is still needed
to solve drivers' dependency during system resume.

Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Ming Lei &lt;ming.lei@canonical.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>firmware loader: fix one reqeust_firmware race</title>
<updated>2012-10-22T15:37:17Z</updated>
<author>
<name>Ming Lei</name>
<email>ming.lei@canonical.com</email>
</author>
<published>2012-10-09T04:01:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=253c9240ee09fd2a05d315ea44ac037a893d8981'/>
<id>urn:sha1:253c9240ee09fd2a05d315ea44ac037a893d8981</id>
<content type='text'>
Several loading requests may be pending on one same
firmware buf, and this patch moves fw_map_pages_buf()
before complete_all(&amp;fw_buf-&gt;completion) and let all
requests see the mapped 'buf-&gt;data' once the loading
is completed.

Signed-off-by: Ming Lei &lt;ming.lei@canonical.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>firmware loader: cancel uncache work before caching firmware</title>
<updated>2012-10-22T15:37:16Z</updated>
<author>
<name>Ming Lei</name>
<email>ming.lei@canonical.com</email>
</author>
<published>2012-10-09T04:01:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=373304fe10fc46e68815c7116709ad292695dfd1'/>
<id>urn:sha1:373304fe10fc46e68815c7116709ad292695dfd1</id>
<content type='text'>
Under 'Opportunistic sleep' situation, system sleep might be
triggered very frequently, so the uncahce work may not be completed
before caching firmware during next suspend.

This patch cancels the uncache work before caching firmware to
fix the problem above.

Also this patch optimizes the cacheing firmware mechanism a bit by
only storing one firmware cache entry for one firmware image.

So if the firmware is still cached during suspend, it doesn't need
to be loaded from user space any more.

Signed-off-by: Ming Lei &lt;ming.lei@canonical.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
