<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/base/firmware_class.c, branch v4.9</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=v4.9</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.9'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2016-08-02T23:35:10Z</updated>
<entry>
<title>firmware: support loading into a pre-allocated buffer</title>
<updated>2016-08-02T23:35:10Z</updated>
<author>
<name>Stephen Boyd</name>
<email>stephen.boyd@linaro.org</email>
</author>
<published>2016-08-02T21:04:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a098ecd2fa7db8fa4fcc178a43627b29b226edb9'/>
<id>urn:sha1:a098ecd2fa7db8fa4fcc178a43627b29b226edb9</id>
<content type='text'>
Some systems are memory constrained but they need to load very large
firmwares.  The firmware subsystem allows drivers to request this
firmware be loaded from the filesystem, but this requires that the
entire firmware be loaded into kernel memory first before it's provided
to the driver.  This can lead to a situation where we map the firmware
twice, once to load the firmware into kernel memory and once to copy the
firmware into the final resting place.

This creates needless memory pressure and delays loading because we have
to copy from kernel memory to somewhere else.  Let's add a
request_firmware_into_buf() API that allows drivers to request firmware
be loaded directly into a pre-allocated buffer.  This skips the
intermediate step of allocating a buffer in kernel memory to hold the
firmware image while it's read from the filesystem.  It also requires
that drivers know how much memory they'll require before requesting the
firmware and negates any benefits of firmware caching because the
firmware layer doesn't manage the buffer lifetime.

For a 16MB buffer, about half the time is spent performing a memcpy from
the buffer to the final resting place.  I see loading times go from
0.081171 seconds to 0.047696 seconds after applying this patch.  Plus
the vmalloc pressure is reduced.

This is based on a patch from Vikram Mulukutla on codeaurora.org:
  https://www.codeaurora.org/cgit/quic/la/kernel/msm-3.18/commit/drivers/base/firmware_class.c?h=rel/msm-3.18&amp;id=0a328c5f6cd999f5c591f172216835636f39bcb5

Link: http://lkml.kernel.org/r/20160607164741.31849-4-stephen.boyd@linaro.org
Signed-off-by: Stephen Boyd &lt;stephen.boyd@linaro.org&gt;
Cc: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Cc: Vikram Mulukutla &lt;markivx@codeaurora.org&gt;
Cc: Mark Brown &lt;broonie@kernel.org&gt;
Cc: Ming Lei &lt;ming.lei@canonical.com&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>firmware: provide infrastructure to make fw caching optional</title>
<updated>2016-08-02T23:35:09Z</updated>
<author>
<name>Vikram Mulukutla</name>
<email>markivx@codeaurora.org</email>
</author>
<published>2016-08-02T21:04:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0e742e927571946e08e877d3629e6efd4891ed95'/>
<id>urn:sha1:0e742e927571946e08e877d3629e6efd4891ed95</id>
<content type='text'>
Some low memory systems with complex peripherals cannot afford to have
the relatively large firmware images taking up valuable memory during
suspend and resume.  Change the internal implementation of
firmware_class to disallow caching based on a configurable option.  In
the near future, variants of request_firmware will take advantage of
this feature.

Link: http://lkml.kernel.org/r/20160607164741.31849-3-stephen.boyd@linaro.org
[stephen.boyd@linaro.org: Drop firmware_desc design and use flags]
Signed-off-by: Vikram Mulukutla &lt;markivx@codeaurora.org&gt;
Signed-off-by: Stephen Boyd &lt;stephen.boyd@linaro.org&gt;
Cc: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Cc: Mark Brown &lt;broonie@kernel.org&gt;
Cc: Ming Lei &lt;ming.lei@canonical.com&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>firmware: consolidate kmap/read/write logic</title>
<updated>2016-08-02T23:35:09Z</updated>
<author>
<name>Stephen Boyd</name>
<email>stephen.boyd@linaro.org</email>
</author>
<published>2016-08-02T21:04:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9ccf98119821defe66ee2ee21f8a11071f63fa65'/>
<id>urn:sha1:9ccf98119821defe66ee2ee21f8a11071f63fa65</id>
<content type='text'>
Some systems are memory constrained but they need to load very large
firmwares.  The firmware subsystem allows drivers to request this
firmware be loaded from the filesystem, but this requires that the
entire firmware be loaded into kernel memory first before it's provided
to the driver.  This can lead to a situation where we map the firmware
twice, once to load the firmware into kernel memory and once to copy the
firmware into the final resting place.

This design creates needless memory pressure and delays loading because
we have to copy from kernel memory to somewhere else.  This patch sets
adds support to the request firmware API to load the firmware directly
into a pre-allocated buffer, skipping the intermediate copying step and
alleviating memory pressure during firmware loading.  The drawback is
that we can't use the firmware caching feature because the memory for
the firmware cache is not managed by the firmware layer.

This patch (of 3):

We use similar structured code to read and write the kmapped firmware
pages.  The only difference is read copies from the kmap region and
write copies to it.  Consolidate this into one function to reduce
duplication.

Link: http://lkml.kernel.org/r/20160607164741.31849-2-stephen.boyd@linaro.org
Signed-off-by: Stephen Boyd &lt;stephen.boyd@linaro.org&gt;
Cc: Vikram Mulukutla &lt;markivx@codeaurora.org&gt;
Cc: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Cc: Mark Brown &lt;broonie@kernel.org&gt;
Cc: Ming Lei &lt;ming.lei@canonical.com&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>Merge tag 'char-misc-4.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc</title>
<updated>2016-03-17T20:47:50Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2016-03-17T20:47:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8eee93e2576c303b6071368456dcd6c9a5a021c9'/>
<id>urn:sha1:8eee93e2576c303b6071368456dcd6c9a5a021c9</id>
<content type='text'>
Pull char/misc updates from Greg KH:
 "Here is the big char/misc driver update for 4.6-rc1.

  The majority of the patches here is hwtracing and some new mic
  drivers, but there's a lot of other driver updates as well.  Full
  details in the shortlog.

  All have been in linux-next for a while with no reported issues"

* tag 'char-misc-4.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (238 commits)
  goldfish: Fix build error of missing ioremap on UM
  nvmem: mediatek: Fix later provider initialization
  nvmem: imx-ocotp: Fix return value of imx_ocotp_read
  nvmem: Fix dependencies for !HAS_IOMEM archs
  char: genrtc: replace blacklist with whitelist
  drivers/hwtracing: make coresight-etm-perf.c explicitly non-modular
  drivers: char: mem: fix IS_ERROR_VALUE usage
  char: xillybus: Fix internal data structure initialization
  pch_phub: return -ENODATA if ROM can't be mapped
  Drivers: hv: vmbus: Support kexec on ws2012 r2 and above
  Drivers: hv: vmbus: Support handling messages on multiple CPUs
  Drivers: hv: utils: Remove util transport handler from list if registration fails
  Drivers: hv: util: Pass the channel information during the init call
  Drivers: hv: vmbus: avoid unneeded compiler optimizations in vmbus_wait_for_unload()
  Drivers: hv: vmbus: remove code duplication in message handling
  Drivers: hv: vmbus: avoid wait_for_completion() on crash
  Drivers: hv: vmbus: don't loose HVMSG_TIMER_EXPIRED messages
  misc: at24: replace memory_accessor with nvmem_device_read
  eeprom: 93xx46: extend driver to plug into the NVMEM framework
  eeprom: at25: extend driver to plug into the NVMEM framework
  ...
</content>
</entry>
<entry>
<title>firmware: change kernel read fail to dev_dbg()</title>
<updated>2016-02-29T08:08:06Z</updated>
<author>
<name>Luis R. Rodriguez</name>
<email>mcgrof@suse.com</email>
</author>
<published>2016-02-28T20:57:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8e516aa52cea98b23e14c5d67fe74147e73d25f7'/>
<id>urn:sha1:8e516aa52cea98b23e14c5d67fe74147e73d25f7</id>
<content type='text'>
When we now use the new kernel_read_file_from_path() we
are reporting a failure when we iterate over all the paths
possible for firmware. Before using kernel_read_file_from_path()
we only reported a failure once we confirmed a file existed
with filp_open() but failed with fw_read_file_contents().

With kernel_read_file_from_path() both are done for us and
we obviously are now reporting too much information given that
some optional paths will always fail and clutter the logs.

fw_get_filesystem_firmware() already has a check for failure
and uses an internal flag, FW_OPT_NO_WARN, but this does not
let us capture other unxpected errors. This enables that
as changed by Neil via commit:

"firmware: Be a bit more verbose about direct firmware loading failure"

Reported-by: Heiner Kallweit &lt;hkallweit1@gmail.com&gt;
Cc: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Cc: Heiner Kallweit &lt;hkallweit1@gmail.com&gt;
Cc: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Cc: Kees Cook &lt;keescook@chromium.org&gt;
Signed-off-by: Luis R. Rodriguez &lt;mcgrof@kernel.org&gt;
Acked-by: Kees Cook &lt;keescook@chromium.org&gt;
Acked-by: Ming Lei &lt;ming.lei@canonical.com&gt;
Signed-off-by: James Morris &lt;james.l.morris@oracle.com&gt;
</content>
</entry>
<entry>
<title>firmware: replace call to fw_read_file_contents() with kernel version</title>
<updated>2016-02-21T14:03:44Z</updated>
<author>
<name>Mimi Zohar</name>
<email>zohar@linux.vnet.ibm.com</email>
</author>
<published>2015-11-19T17:39:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e40ba6d56b41754b37b995dbc8035b2b3a6afd8a'/>
<id>urn:sha1:e40ba6d56b41754b37b995dbc8035b2b3a6afd8a</id>
<content type='text'>
Replace the fw_read_file_contents with kernel_file_read_from_path().

Although none of the upstreamed LSMs define a kernel_fw_from_file hook,
IMA is called by the security function to prevent unsigned firmware from
being loaded and to measure/appraise signed firmware, based on policy.

Instead of reading the firmware twice, once for measuring/appraising the
firmware and again for reading the firmware contents into memory, the
kernel_post_read_file() security hook calculates the file hash based on
the in memory file buffer.  The firmware is read once.

This patch removes the LSM kernel_fw_from_file() hook and security call.

Changelog v4+:
- revert dropped buf-&gt;size assignment - reported by Sergey Senozhatsky
v3:
- remove kernel_fw_from_file hook
- use kernel_file_read_from_path() - requested by Luis
v2:
- reordered and squashed firmware patches
- fix MAX firmware size (Kees Cook)

Signed-off-by: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Acked-by: Kees Cook &lt;keescook@chromium.org&gt;
Acked-by: Luis R. Rodriguez &lt;mcgrof@kernel.org&gt;
</content>
</entry>
<entry>
<title>firmware: clean up filesystem load exit path</title>
<updated>2016-02-18T22:14:01Z</updated>
<author>
<name>Kees Cook</name>
<email>keescook@chromium.org</email>
</author>
<published>2016-02-04T21:15:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4b2530d819e179ae3352c38a1ceff929a922d070'/>
<id>urn:sha1:4b2530d819e179ae3352c38a1ceff929a922d070</id>
<content type='text'>
This makes the error and success paths more readable while trying to
load firmware from the filesystem.

Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
Cc: Josh Boyer &lt;jwboyer@fedoraproject.org&gt;
Cc: David Howells &lt;dhowells@redhat.com&gt;
Acked-by: Luis R. Rodriguez &lt;mcgrof@kernel.org&gt;
Signed-off-by: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>firmware: move completing fw into a helper</title>
<updated>2016-02-18T22:14:00Z</updated>
<author>
<name>Luis R. Rodriguez</name>
<email>mcgrof@kernel.org</email>
</author>
<published>2015-07-30T22:48:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5275d194e0e56db2bdc43e58f5e54b8e36d6fb03'/>
<id>urn:sha1:5275d194e0e56db2bdc43e58f5e54b8e36d6fb03</id>
<content type='text'>
This will be re-used later through a new extensible interface.

Reviewed-by: Josh Boyer &lt;jwboyer@fedoraproject.org&gt;
Signed-off-by: Luis R. Rodriguez &lt;mcgrof@kernel.org&gt;
Signed-off-by: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Acked-by: Kees Cook &lt;keescook@chromium.org&gt;
</content>
</entry>
<entry>
<title>firmware: simplify dev_*() print messages for generic helpers</title>
<updated>2016-02-18T22:13:59Z</updated>
<author>
<name>Luis R. Rodriguez</name>
<email>mcgrof@kernel.org</email>
</author>
<published>2015-04-29T23:30:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ed04630b34c117347423a49af35125f5affff6b9'/>
<id>urn:sha1:ed04630b34c117347423a49af35125f5affff6b9</id>
<content type='text'>
Simplify a few of the *generic* shared dev_warn() and dev_dbg()
print messages for three reasons:

0) Historically firmware_class code was added to help
   get device driver firmware binaries but these days
   request_firmware*() helpers are being repurposed for
   general *system data* needed by the kernel.

1) This will also help generalize shared code as much as possible
   later in the future in consideration for a new extensible firmware
   API which will enable to separate usermode helper code out as much
   as possible.

2) Kees Cook pointed out the the prints already have the device
   associated as dev_*() helpers are used, that should help identify
   the user and case in which the helpers are used. That should provide
   enough context and simplifies the messages further.

v4: generalize debug/warn messages even further as suggested by
    Kees Cook.

Cc: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: David Howells &lt;dhowells@redhat.com&gt;
Cc: Kees Cook &lt;keescook@chromium.org&gt;
Cc: Casey Schaufler &lt;casey@schaufler-ca.com&gt;
Cc: Ming Lei &lt;ming.lei@canonical.com&gt;
Cc: Takashi Iwai &lt;tiwai@suse.de&gt;
Cc: Vojtěch Pavlík &lt;vojtech@suse.cz&gt;
Cc: Kyle McMartin &lt;kyle@kernel.org&gt;
Cc: Matthew Garrett &lt;mjg59@srcf.ucam.org&gt;
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez &lt;mcgrof@kernel.org&gt;
Signed-off-by: Mimi Zohar &lt;zohar@linux.vnet.ibm.com&gt;
Acked-by: Kees Cook &lt;keescook@chromium.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>firmware: Change the page arrary alloc to vmalloc</title>
<updated>2016-02-08T23:01:31Z</updated>
<author>
<name>Chen Feng</name>
<email>puck.chen@hisilicon.com</email>
</author>
<published>2015-12-16T09:03:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=10a3fbf18d99caeeecd2b28445d9104deab11ed7'/>
<id>urn:sha1:10a3fbf18d99caeeecd2b28445d9104deab11ed7</id>
<content type='text'>
No need to use use continuous memory, it may be fail
when memory deeply fragmented.

Signed-off-by: Chen Feng &lt;puck.chen@hisilicon.com&gt;
Signed-off-by: Xia Qing &lt;saberlily.xia@hisilicon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
