26 Oct, 2020

1 commit

  • Use a more generic form for __section that requires quotes to avoid
    complications with clang and gcc differences.

    Remove the quote operator # from compiler_attributes.h __section macro.

    Convert all unquoted __section(foo) uses to quoted __section("foo").
    Also convert __attribute__((section("foo"))) uses to __section("foo")
    even if the __attribute__ has multiple list entry forms.

    Conversion done using the script at:

    https://lore.kernel.org/lkml/75393e5ddc272dc7403de74d645e6c6e0f4e70eb.camel@perches.com/2-convert_section.pl

    Signed-off-by: Joe Perches
    Reviewed-by: Nick Desaulniers
    Reviewed-by: Miguel Ojeda
    Signed-off-by: Linus Torvalds

    Joe Perches
     

05 Oct, 2020

1 commit

  • Add request_partial_firmware_into_buf() to allow for portions of a
    firmware file to be read into a buffer. This is needed when large firmware
    must be loaded in portions from a file on memory constrained systems.

    Signed-off-by: Scott Branden
    Co-developed-by: Kees Cook
    Signed-off-by: Kees Cook
    Link: https://lore.kernel.org/r/20201002173828.2099543-16-keescook@chromium.org
    Signed-off-by: Greg Kroah-Hartman

    Scott Branden
     

17 Apr, 2020

1 commit

  • The struct firmware contains a page table pointer that was used only
    internally in the past. Since the actual page tables are referred
    from struct fw_priv and should be never from struct firmware, we can
    drop this unused field gracefully.

    Signed-off-by: Takashi Iwai
    Acked-by: Luis Chamberlain
    Link: https://lore.kernel.org/r/20200415164500.28749-1-tiwai@suse.de
    Signed-off-by: Greg Kroah-Hartman

    Takashi Iwai
     

20 Mar, 2020

1 commit

  • In some cases the platform's main firmware (e.g. the UEFI fw) may contain
    an embedded copy of device firmware which needs to be (re)loaded into the
    peripheral. Normally such firmware would be part of linux-firmware, but in
    some cases this is not feasible, for 2 reasons:

    1) The firmware is customized for a specific use-case of the chipset / use
    with a specific hardware model, so we cannot have a single firmware file
    for the chipset. E.g. touchscreen controller firmwares are compiled
    specifically for the hardware model they are used with, as they are
    calibrated for a specific model digitizer.

    2) Despite repeated attempts we have failed to get permission to
    redistribute the firmware. This is especially a problem with customized
    firmwares, these get created by the chip vendor for a specific ODM and the
    copyright may partially belong with the ODM, so the chip vendor cannot
    give a blanket permission to distribute these.

    This commit adds a new platform fallback mechanism to the firmware loader
    which will try to lookup a device fw copy embedded in the platform's main
    firmware if direct filesystem lookup fails.

    Drivers which need such embedded fw copies can enable this fallback
    mechanism by using the new firmware_request_platform() function.

    Note that for now this is only supported on EFI platforms and even on
    these platforms firmware_fallback_platform() only works if
    CONFIG_EFI_EMBEDDED_FIRMWARE is enabled (this gets selected by drivers
    which need this), in all other cases firmware_fallback_platform() simply
    always returns -ENOENT.

    Reported-by: Dave Olsthoorn
    Suggested-by: Peter Jones
    Acked-by: Luis Chamberlain
    Signed-off-by: Hans de Goede
    Link: https://lore.kernel.org/r/20200115163554.101315-5-hdegoede@redhat.com
    Signed-off-by: Greg Kroah-Hartman

    Hans de Goede
     

14 May, 2018

1 commit

  • Currently the firmware loader only exposes one silent path for querying
    optional firmware, and that is firmware_request_direct(). This function
    also disables the sysfs fallback mechanism, which might not always be the
    desired behaviour [0].

    This patch introduces a variations of request_firmware() that enable the
    caller to disable the undesired warning messages but enables the sysfs
    fallback mechanism. This is equivalent to adding FW_OPT_NO_WARN to the
    old behaviour.

    [0]: https://git.kernel.org/linus/c0cc00f250e1

    Signed-off-by: Andres Rodriguez
    Reviewed-by: Kees Cook
    Acked-by: Luis R. Rodriguez
    [mcgrof: used the old API calls as the full rename is not done yet, and
    add the caller for when FW_LOADER is disabled, enhance documentation ]
    Signed-off-by: Luis R. Rodriguez
    Signed-off-by: Greg Kroah-Hartman

    Andres Rodriguez
     

23 Mar, 2018

1 commit

  • Some devices have an optimization in place to enable the firmware to
    be retaineed during a system reboot, so after reboot the device can skip
    requesting and loading the firmware. This can save up to 1s in load
    time. The mt7601u 802.11 device happens to be such a device.

    When these devices retain the firmware on a reboot and then suspend
    they can miss looking for the firmware on resume. To help with this we
    need a way to cache the firmware when such an optimization has taken
    place.

    Signed-off-by: Luis R. Rodriguez
    Signed-off-by: Greg Kroah-Hartman

    Luis R. Rodriguez
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

03 Aug, 2016

1 commit

  • 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&id=0a328c5f6cd999f5c591f172216835636f39bcb5

    Link: http://lkml.kernel.org/r/20160607164741.31849-4-stephen.boyd@linaro.org
    Signed-off-by: Stephen Boyd
    Cc: Mimi Zohar
    Cc: Vikram Mulukutla
    Cc: Mark Brown
    Cc: Ming Lei
    Cc: Greg Kroah-Hartman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Boyd
     

09 Jul, 2014

2 commits

  • Now that the udev firmware loader is optional request_firmware()
    will not provide any information on the kernel ring buffer if
    direct firmware loading failed and udev firmware loading is disabled.
    If no information is needed request_firmware_direct() should be used
    for optional firmware, at which point drivers can take on the onus
    over informing of any failures, if udev firmware loading is disabled
    though we should at the very least provide some sort of information
    as when the udev loader was enabled by default back in the days.

    With this change with a simple firmware load test module [0]:

    Example output without FW_LOADER_USER_HELPER_FALLBACK

    platform fake-dev.0: Direct firmware load for fake.bin failed
    with error -2

    Example with FW_LOADER_USER_HELPER_FALLBACK

    platform fake-dev.0: Direct firmware load for fake.bin failed with error -2
    platform fake-dev.0: Falling back to user helper

    Without this change without FW_LOADER_USER_HELPER_FALLBACK we
    get no output logged upon failure.

    Cc: Tom Gundersen
    Cc: Ming Lei
    Cc: Abhay Salunke
    Cc: Stefan Roese
    Cc: Arnd Bergmann
    Cc: Kay Sievers
    Signed-off-by: Luis R. Rodriguez
    Reviewed-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Luis R. Rodriguez
     
  • [The patch was originally proposed by Tom Gundersen, and rewritten
    afterwards by me; most of changelogs below borrowed from Tom's
    original patch -- tiwai]

    Currently (at least) the dell-rbu driver selects FW_LOADER_USER_HELPER,
    which means that distros can't really stop loading firmware through
    udev without breaking other users (though some have).

    Ideally we would remove/disable the udev firmware helper in both the
    kernel and in udev, but if we were to disable it in udev and not the
    kernel, the result would be (seemingly) hung kernels as no one would
    be around to cancel firmware requests.

    This patch allows udev firmware loading to be disabled while still
    allowing non-udev firmware loading, as done by the dell-rbu driver, to
    continue working. This is achieved by only using the fallback
    mechanism when the uevent is suppressed.

    The patch renames the user-selectable Kconfig from FW_LOADER_USER_HELPER
    to FW_LOADER_USER_HELPER_FALLBACK, and the former is reverse-selected
    by the latter or the drivers that need userhelper like dell-rbu.

    Also, the "default y" is removed together with this change, since it's
    been deprecated in udev upstream, thus rather better to disable it
    nowadays.

    Tested with
    FW_LOADER_USER_HELPER=n
    LATTICE_ECP3_CONFIG=y
    DELL_RBU=y
    and udev without the firmware loading support, but I don't have the
    hardware to test the lattice/dell drivers, so additional testing would
    be appreciated.

    Reviewed-by: Tom Gundersen
    Cc: Ming Lei
    Cc: Abhay Salunke
    Cc: Stefan Roese
    Cc: Arnd Bergmann
    Cc: Kay Sievers
    Tested-by: Balaji Singh
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Takashi Iwai
     

09 Dec, 2013

1 commit

  • When CONFIG_FW_LOADER_USER_HELPER is set, request_firmware() falls
    back to the usermode helper for loading via udev when the direct
    loading fails. But the recent udev takes way too long timeout (60
    seconds) for non-existing firmware. This is unacceptable for the
    drivers like microcode loader where they load firmwares optionally,
    i.e. it's no error even if no requested file exists.

    This patch provides a new helper function, request_firmware_direct().
    It behaves as same as request_firmware() except for that it doesn't
    fall back to usermode helper but returns an error immediately if the
    f/w can't be loaded directly in kernel.

    Without CONFIG_FW_LOADER_USER_HELPER=y, request_firmware_direct() is
    just an alias of request_firmware(), due to obvious reason.

    Tested-by: Prarit Bhargava
    Acked-by: Ming Lei
    Acked-by: Borislav Petkov
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Takashi Iwai
     

07 Jun, 2013

1 commit


17 Aug, 2012

2 commits

  • This patches introduce two kernel APIs of cache_firmware and
    uncache_firmware, both of which take the firmware file name
    as the only parameter.

    So any drivers can call cache_firmware to cache the specified
    firmware file into kernel memory, and can use the cached firmware
    in situations which can't request firmware from user space.

    Signed-off-by: Ming Lei
    Cc: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Ming Lei
     
  • This patch always let firmware_buf own the pages buffer allocated
    inside firmware_data_write, and add all instances of firmware_buf
    into the firmware cache global list. Also introduce one private field
    in 'struct firmware', so release_firmware will see the instance of
    firmware_buf associated with the current firmware instance, then just
    'free' the instance of firmware_buf.

    The firmware_buf instance represents one pages buffer for one
    firmware image, so lots of firmware loading requests can share
    the same firmware_buf instance if they request the same firmware
    image file.

    This patch will make implementation of the following cache_firmware/
    uncache_firmware very easy and simple.

    In fact, the patch improves request_formware/release_firmware:

    - only request userspace to write firmware image once if
    several devices share one same firmware image and its drivers
    call request_firmware concurrently.

    Signed-off-by: Ming Lei
    Cc: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Ming Lei
     

01 Nov, 2011

1 commit

  • The pretty much brings in the kitchen sink along
    with it, so it should be avoided wherever reasonably possible in
    terms of being included from other commonly used
    files, as it results in a measureable increase on compile times.

    The worst culprit was probably device.h since it is used everywhere.
    This file also had an implicit dependency/usage of mutex.h which was
    masked by module.h, and is also fixed here at the same time.

    There are over a dozen other headers that simply declare the
    struct instead of pulling in the whole file, so follow their lead
    and simply make it a few more.

    Most of the implicit dependencies on module.h being present by
    these headers pulling it in have been now weeded out, so we can
    finally make this change with hopefully minimal breakage.

    Signed-off-by: Paul Gortmaker

    Paul Gortmaker
     

04 Feb, 2011

1 commit


22 May, 2010

1 commit

  • 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
     

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
     

16 Jun, 2009

1 commit

  • As we're allocating the firmware name dynamically, we no longer need this
    definition.
    This patch must be applied only after the 5 previous patches from this pacth
    set have been applied.

    Signed-off-by: Samuel Ortiz
    Signed-off-by: Greg Kroah-Hartman

    Samuel Ortiz
     

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
     

05 Jul, 2008

1 commit

  • > the build (.config attached) failed, make ends with :
    > ...
    > UPD include/linux/compile.h
    > CC init/version.o
    > LD init/built-in.o
    > LD vmlinux
    > drivers/built-in.o: In function `sas_request_addr':
    > (.text+0x33bab): undefined reference to `request_firmware'
    > drivers/built-in.o: In function `sas_request_addr':
    > (.text+0x33c3f): undefined reference to `release_firmware'
    > make: *** [vmlinux] Error 1

    There's a slight fault in the stub logic. It fails for FW_LOADER=m and
    the user =y.

    This should fix it.

    This patch fixes the following 2.6.26-rc regression:
    http://bugzilla.kernel.org/show_bug.cgi?id=10730

    Reviewed-by: Toralf Foerster
    Signed-off-by: Adrian Bunk
    Cc: "Rafael J. Wysocki"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    James Bottomley
     

11 Mar, 2008

1 commit

  • libsas has a case where it uses the firmware loader to provide services,
    but doesn't want to select it all the time. This currently causes a
    compile failure in libsas if FW_LOADER=n. Fix this by providing error
    stubs for the firmware loader API in the FW_LOADER=n case.

    Signed-off-by: James Bottomley
    Cc: Randy Dunlap
    Signed-off-by: Greg Kroah-Hartman

    James Bottomley
     

22 May, 2006

1 commit

  • - remove the following global function that is both unused and
    unimplemented:
    - register_firmware()

    - make the following needlessly global function static:
    - firmware_class_uevent()

    Signed-off-by: Adrian Bunk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Adrian Bunk
     

05 Jan, 2006

1 commit


08 Sep, 2005

1 commit


17 Apr, 2005

1 commit

  • Initial git repository build. I'm not bothering with the full history,
    even though we have it. We can create a separate "historical" git
    archive of that later if we want to, and in the meantime it's about
    3.2GB when imported into git - space that would just make the early
    git days unnecessarily complicated, when we don't have a lot of good
    infrastructure for it.

    Let it rip!

    Linus Torvalds