firmware: doc revamp
Subsystems (5)
Luis R. Rodriguez
maintainercover firmware: doc revamp
Greg,
here's a few simple changes for documentation revamp and a few simple fixes for the firmware test script. I'm pretty sure this is too late for the next release so I am happy with this getting queued in until the merge window closes, posting now to iron out kinks once the merge window closes.
I'll soon also post the extensible firmware API as per feedback, much of which was just name change preferences and also a huge clarification on roadmap on fallback mechanisms. The documentation should help iron out tons of kinks I think folks have on this front, but more on all this later once those patches get posted.
You may notice I've dropped the SmPL patches which complain on use of the API on init and probe -- although valid the context was off given the only valid use case was if you don't use initramfs, and that's a corner case. Fortunatley Daniel Wagner and Tom Gundersen have come up with some ideas that should help correct these issues, so I've dropped that grammar patch.
Luis R. Rodriguez (5):
selftests: firmware: only modprobe if driver is missing
selftests: firmware: send expected errors to /dev/null
firmware: revamp firmware documentation
firmware: add SmPL report for custom fallback mechanism
firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Documentation/driver-api/firmware/built-in-fw.rst | 36 ++++ Documentation/driver-api/firmware/core.rst | 16 ++ .../driver-api/firmware/direct-fs-lookup.rst | 30 +++ .../driver-api/firmware/fallback-mechanisms.rst | 215 +++++++++++++++++++++ .../driver-api/firmware/firmware_cache.rst | 51 +++++ .../driver-api/firmware/fw_search_path.rst | 26 +++ Documentation/driver-api/firmware/index.rst | 16 ++ Documentation/driver-api/firmware/introduction.rst | 27 +++ Documentation/driver-api/firmware/lookup-order.rst | 18 ++ .../driver-api/firmware/request_firmware.rst | 56 ++++++ Documentation/driver-api/index.rst | 1 + Documentation/firmware_class/README | 128 ------------ drivers/firmware/dell_rbu.c | 1 + drivers/leds/leds-lp55xx-common.c | 1 + include/linux/firmware.h | 7 + .../api/request_firmware-custom-fallback.cocci | 44 +++++ tools/testing/selftests/firmware/fw_filesystem.sh | 25 ++- 17 files changed, 565 insertions(+), 133 deletions(-) create mode 100644 Documentation/driver-api/firmware/built-in-fw.rst create mode 100644 Documentation/driver-api/firmware/core.rst create mode 100644 Documentation/driver-api/firmware/direct-fs-lookup.rst create mode 100644 Documentation/driver-api/firmware/fallback-mechanisms.rst create mode 100644 Documentation/driver-api/firmware/firmware_cache.rst create mode 100644 Documentation/driver-api/firmware/fw_search_path.rst create mode 100644 Documentation/driver-api/firmware/index.rst create mode 100644 Documentation/driver-api/firmware/introduction.rst create mode 100644 Documentation/driver-api/firmware/lookup-order.rst create mode 100644 Documentation/driver-api/firmware/request_firmware.rst delete mode 100644 Documentation/firmware_class/README create mode 100644 scripts/coccinelle/api/request_firmware-custom-fallback.cocci
Signature · 1 line
2.10.1
Luis R. Rodriguez
maintainerPATCH 1/5 selftests: firmware: only modprobe if driver is missing
No need to load test_firmware if its already there. Also use a more generic form to recommend what is required to be built.
--- tools/testing/selftests/firmware/fw_filesystem.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
tools/testing/selftests/firmware/fw_filesystem.sh +17 -2
@@ -5,9 +5,24 @@ # know so we can be sure we're not accidentally testing the user helper. set -e -modprobe test_firmware - DIR=/sys/devices/virtual/misc/test_firmware +TEST_DIR=$(dirname $0) + +test_modprobe() +{ + if [ ! -d $DIR ]; then + echo "$0: $DIR not present" + echo "You must have the following enabled in your kernel:" + cat $TEST_DIR/config + exit 1 + fi +} + +trap "test_modprobe" EXIT + +if [ ! -d $DIR ]; then + modprobe test_firmware +fi # CONFIG_FW_LOADER_USER_HELPER has a sysfs class under /sys/class/firmware/ # These days no one enables CONFIG_FW_LOADER_USER_HELPER so check for that
Signature · 1 line
2.10.1
Luis R. Rodriguez
maintainerPATCH 2/5 selftests: firmware: send expected errors to /dev/null
In reply to Luis R. RodriguezError that we expect should not be spilled to stdout.
Without this we get:
./fw_filesystem.sh: line 58: printf: write error: Invalid argument ./fw_filesystem.sh: line 63: printf: write error: No such device ./fw_filesystem.sh: line 69: echo: write error: No such file or directory ./fw_filesystem.sh: filesystem loading works ./fw_filesystem.sh: async filesystem loading works
With it:
./fw_filesystem.sh: filesystem loading works ./fw_filesystem.sh: async filesystem loading works
--- tools/testing/selftests/firmware/fw_filesystem.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/firmware/fw_filesystem.sh +3 -3
@@ -63,18 +63,18 @@ echo "ABCD0123" >"$FW" NAME=$(basename "$FW") -if printf '\000' >"$DIR"/trigger_request; then +if printf '\000' >"$DIR"/trigger_request 2> /dev/null; then echo "$0: empty filename should not succeed" >&2 exit 1 fi -if printf '\000' >"$DIR"/trigger_async_request; then +if printf '\000' >"$DIR"/trigger_async_request 2> /dev/null; then echo "$0: empty filename should not succeed (async)" >&2 exit 1 fi # Request a firmware that doesn't exist, it should fail. -if echo -n "nope-$NAME" >"$DIR"/trigger_request; then +if echo -n "nope-$NAME" >"$DIR"/trigger_request 2> /dev/null; then echo "$0: firmware shouldn't have loaded" >&2 exit 1 fi
Signature · 1 line
2.10.1
Luis R. Rodriguez
maintainerPATCH 3/5 firmware: revamp firmware documentation
In reply to Luis R. RodriguezUnderstanding this code is getting out of control without any notes. Give the firmware_class driver a much needed documentation love, and while at it convert it to the new sphinx documentation format.
--- Documentation/driver-api/firmware/built-in-fw.rst | 36 ++++ Documentation/driver-api/firmware/core.rst | 16 ++ .../driver-api/firmware/direct-fs-lookup.rst | 30 ++++ .../driver-api/firmware/fallback-mechanisms.rst | 195 +++++++++++++++++++++ .../driver-api/firmware/firmware_cache.rst | 51 ++++++ .../driver-api/firmware/fw_search_path.rst | 26 +++ Documentation/driver-api/firmware/index.rst | 16 ++ Documentation/driver-api/firmware/introduction.rst | 27 +++ Documentation/driver-api/firmware/lookup-order.rst | 18 ++ .../driver-api/firmware/request_firmware.rst | 56 ++++++ Documentation/driver-api/index.rst | 1 + Documentation/firmware_class/README | 128 -------------- 12 files changed, 472 insertions(+), 128 deletions(-) create mode 100644 Documentation/driver-api/firmware/built-in-fw.rst create mode 100644 Documentation/driver-api/firmware/core.rst create mode 100644 Documentation/driver-api/firmware/direct-fs-lookup.rst create mode 100644 Documentation/driver-api/firmware/fallback-mechanisms.rst create mode 100644 Documentation/driver-api/firmware/firmware_cache.rst create mode 100644 Documentation/driver-api/firmware/fw_search_path.rst create mode 100644 Documentation/driver-api/firmware/index.rst create mode 100644 Documentation/driver-api/firmware/introduction.rst create mode 100644 Documentation/driver-api/firmware/lookup-order.rst create mode 100644 Documentation/driver-api/firmware/request_firmware.rst delete mode 100644 Documentation/firmware_class/README
Documentation/driver-api/firmware/built-in-fw.rst new file +36 -0
@@ -0,0 +1,36 @@ +================= +Built-in firmware +================= + +Firmware can be built-in to the kernel, that is built-in to vmlinux, +to enable firmware lookups to avoid having to look for firmware from +the filesystem. You can enable built-in firmware using the kernel +configuration options: + + * CONFIG_EXTRA_FIRMWARE + * CONFIG_EXTRA_FIRMWARE_DIR + +The should not be confused with CONFIG_FIRMWARE_IN_KERNEL, this is for drivers +which enable firmware to be built as part of the kernel build process. This +option, CONFIG_FIRMWARE_IN_KERNEL, will build all firmware for all drivers +enabled which ship its firmware inside the Linux kernel source tree. + +There are a few reasons why you might want to consider building your firmware +into the kernel with CONFIG_EXTRA_FIRMWARE though: + +* Speed +* Firmware is needed for accessing the boot device, and the user doesn't + want to stuff the firmware into the boot initramfs. + +Even if you have these needs there are a few reasons why you may not be +able to make use of built-in firmware: + +* Legalese - firmware is non-GPL compatible +* Some firmware may be optional +* Firmware upgrades are possible, therefore a new firmware would implicate + a complete firmware rebuild. +* Some firmware files may be really large in size. The remote-proc subsystem + is an example subsystem which deals with these sorts of firmware +* The firmware may need to be scraped out from some device specific location + dynamically, an example is calibration data for for some WiFi chipsets. +
Documentation/driver-api/firmware/core.rst new file +16 -0
@@ -0,0 +1,16 @@ +========================== +Firmware API core features +========================== + +The firmware API has a rich set of core features available. This section +documents these features. + +.. toctree:: + + fw_search_path + built-in-fw + firmware_cache + direct-fs-lookup + fallback-mechanisms + lookup-order +
Documentation/driver-api/firmware/direct-fs-lookup.rst new file +30 -0
@@ -0,0 +1,30 @@ +======================== +Direct filesystem lookup +======================== + +Direct filesystem lookup is the most common form of firmware lookup performed +by the kernel. The kernel looks for the firmware directly on the root +filesystem in the paths documented in the section 'Firmware search paths'. +The filesystem lookup is implemented in fw_get_filesystem_firmware(), it +uses common core kernel file loader facility kernel_read_file_from_path(). +The max path allowed is PATH_MAX -- currently this is 4096 characters. + +It is recommended you keep /lib/firmware paths on your root filesystem, +avoid having a separate partition for them in order to avoid possible +races with lookups and avoid uses of the custom fallback mechanisms +documented below. + +Firmware and initramfs +---------------------- + +Drivers which are built-in to the kernel should have the firmware integrated +also as part of the initramfs used to boot the kernel given that otherwise +a race is possible with loading the driver and the real rootfs not yet being +available. Stuffing the firmware into initramfs resolves this race issue, +however note that using initrd does not suffice to address the same race. + +There are circumstances that justify not wanting to include firmware into +initramfs, such as dealing with large firmware firmware files for the +remote-proc subsystem. For such cases using a userspace fallback mechanism +is currently the only viable solution as only userspace can know for sure +when the real rootfs is ready and mounted.
Documentation/driver-api/firmware/fallback-mechanisms.rst new file +195 -0
195 lines not on this page · raw message
Documentation/driver-api/firmware/firmware_cache.rst new file +51 -0
51 lines not on this page · raw message
Documentation/driver-api/firmware/fw_search_path.rst new file +26 -0
@@ -0,0 +1,26 @@ +===================== +Firmware search paths +===================== + +The following search paths are used to look for firmware on your +root filesystem. + +* fw_path_para - module parameter - default is empty so this is ignored +* /lib/firmware/updates/UTS_RELEASE/ +* /lib/firmware/updates/ +* /lib/firmware/UTS_RELEASE/ +* /lib/firmware/ + +The module parameter ''path'' can be passed to the firmware_class module +to activate the first optional custom fw_path_para. The custom path can +only be up to 256 characters long. The kernel parameter passed would be: + +* 'firmware_class.path=$CUSTOMIZED_PATH' + +There is an alternative to customize the path at run time after bootup, you +can use the file: + +* /sys/module/firmware_class/parameters/path + +You would echo into it your custom path and firmware requested will be +searched for there first.
Documentation/driver-api/firmware/index.rst new file +16 -0
@@ -0,0 +1,16 @@ +================== +Linux Firmware API +================== + +.. toctree:: + + introduction + core + request_firmware + +.. only:: subproject and html + + Indices + ======= + + * :ref:`genindex`
Documentation/driver-api/firmware/introduction.rst new file +27 -0
@@ -0,0 +1,27 @@ +============ +Introduction +============ + +The firmware API enables kernel code to request files required +for functionality from userspace, the uses vary: + +* Microcode for CPU errata +* Device driver firmware, required to be loaded onto device + microcontrollers +* Device driver information data (calibration data, EEPROM overrides), + some of which can be completely optional. + +Types of firmware requests +========================== + +There are two types of calls: + +* Synchronous +* Asynchronous + +Which one you use vary depending on your requirements, the rule of thumb +however is you should strive to use the asynchronous APIs unless you also +are already using asynchronous initialization mechanisms which will not +stall or delay boot. Even if loading firmware does not take a lot of time +processing firmware might, and this can still delay boot or initialization, +as such mechanisms such as asynchronous probe can help supplement drivers.
Documentation/driver-api/firmware/lookup-order.rst new file +18 -0
@@ -0,0 +1,18 @@ +===================== +Firmware lookup order +===================== + +Different functionality is available to enable firmware to be found. +Below is chronological order of how firmware will be looked for once +a driver issues a firmware API call. + +* The ''Built-in firmware'' is checked first, if the firmware is present we + return it immediately +* The ''Firmware cache'' is looked at next. If the firmware is found we + return it immediately +* The ''Direct filesystem lookup'' is performed next, if found we + return it immediately +* If no firmware has been found and the fallback mechanism was enabled + the sysfs interface is created. After this either a kobject uevent + is issued or the custom firmware loading is relied upon for firmware + loading up to the timeout value.
Documentation/driver-api/firmware/request_firmware.rst new file +56 -0
56 lines not on this page · raw message
Documentation/driver-api/index.rst +1 -0
@@ -30,6 +30,7 @@ available subsections can be seen below. miscellaneous vme 80211/index + firmware/index .. only:: subproject and html
Documentation/firmware_class/README deleted +0 -128
128 lines not on this page · raw message
Signature · 1 line
2.10.1
Re: [PATCH 3/5] firmware: revamp firmware documentation
Quoted 3 lines · Luis R. Rodriguez
Understanding this code is getting out of control without any notes. Give the
firmware_classdriver a much needed documentation love, and while at it convert it to the new sphinx documentation format.
It does help to understand the class/API, thank you!
Documentation/driver-api/firmware/built-in-fw.rst line 31
Quoted 7 lines
Documentation/driver-api/firmware/built-in-fw.rst new file +7
-0+Even if you have these needs there are a few reasons why you may not be +able to make use of built-in firmware: + +* Legalese - firmware is non-GPL compatible +* Some firmware may be optional +* Firmware upgrades are possible, therefore a new firmware would implicate + a complete firmware rebuild.
Could it be you meant "kernel rebuild" or "vmlinux rebuild" here?
Quoted 17 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst new file +11
-0@@ -0,0 +1,195 @@ +=================== +Fallback mechanisms +=================== + +A fallback mechanism is supported to allow to overcome failures to do a direct +filesystem lookup on the root filesystem or when the firmware simply cannot be +installed for practical reasons on the root filesystem. The kernel +configuration options related to supporting the firmware fallback mechanism are: + + * CONFIG_FW_LOADER_USER_HELPER: enables building the firmware fallback + mechanism. Most distributions enable this option today. If enabled but
Documentation/driver-api/firmware/fallback-mechanisms.rst line 21
Quoted 10 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst new file +10
-0+ CONFIG_FW_LOADER_USER_HELPER_FALLBACK is disabled, only the custom fallback + mechanism is available and for the request_firmware_nowait() call. + * CONFIG_FW_LOADER_USER_HELPER_FALLBACK: force enables each request to + enable the kobject uevent fallback mechanism on all firmare API calls + except request_firmware_direct(). Most distributions disable this option + today. The call request_firmware_nowait() allows for one alternative + fallback mechanism: if this kconfig option is enabled and your second + argument to request_firmware_nowait(), uevent, is set to false you are + informing the kernel that you have a custom fallback mechanism and it will + manually load the firmware. Read below for more details.
Yeah, it really asks for API simplification ;)
Luis R. Rodriguez
maintainerRe: [PATCH 3/5] firmware: revamp firmware documentation
Quoted 6 lines · Rafał Miłecki
Quoted 3 lines · Luis R. Rodriguez
Understanding this code is getting out of control without any notes. Give the
firmware_classdriver a much needed documentation love, and while at it convert it to the new sphinx documentation format.It does help to understand the class/API, thank you!
Glad it is helping!
Quoted 9 lines
Documentation/driver-api/firmware/built-in-fw.rst line 31
Quoted 7 lines
Documentation/driver-api/firmware/built-in-fw.rst new file +7
-0+Even if you have these needs there are a few reasons why you may not be +able to make use of built-in firmware: + +* Legalese - firmware is non-GPL compatible +* Some firmware may be optional +* Firmware upgrades are possible, therefore a new firmware would implicate + a complete firmware rebuild.Could it be you meant "kernel rebuild" or "vmlinux rebuild" here?
Heh, yes... thanks, fixed!
Quoted 21 lines
Quoted 21 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst new file +15
-0@@ -0,0 +1,195 @@ +=================== +Fallback mechanisms +=================== + +A fallback mechanism is supported to allow to overcome failures to do a direct +filesystem lookup on the root filesystem or when the firmware simply cannot be +installed for practical reasons on the root filesystem. The kernel +configuration options related to supporting the firmware fallback mechanism are: + + * CONFIG_FW_LOADER_USER_HELPER: enables building the firmware fallback + mechanism. Most distributions enable this option today. If enabled but + CONFIG_FW_LOADER_USER_HELPER_FALLBACK is disabled, only the custom fallback + mechanism is available and for the request_firmware_nowait() call. + * CONFIG_FW_LOADER_USER_HELPER_FALLBACK: force enables each request to + enable the kobject uevent fallback mechanism on all firmare API calls
Quoted 8 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst line 21
Quoted 6 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst new file +6
-0+ except request_firmware_direct(). Most distributions disable this option + today. The call request_firmware_nowait() allows for one alternative + fallback mechanism: if this kconfig option is enabled and your second + argument to request_firmware_nowait(), uevent, is set to false you are + informing the kernel that you have a custom fallback mechanism and it will + manually load the firmware. Read below for more details.Yeah, it really asks for API simplification ;)
So up next once this is done is the new revamp with an extensible firmware API.
Luis
Re: [PATCH 3/5] firmware: revamp firmware documentation
In reply to Luis R. RodriguezDocumentation/driver-api/firmware/built-in-fw.rst line 7
Quoted 9 lines
+++
b/Documentation/driver-api/firmware/built-in-fw.rstDocumentation/driver-api/firmware/built-in-fw.rst new file +7
-0@@ -0,0 +1,36 @@ +================= +Built-in firmware +================= + +Firmware can be built-in to the kernel, that is built-in to vmlinux, +to enable firmware lookups to avoid having to look for firmware from +the filesystem.
I find the second part of the sentence a bit confusing in the wording.
Documentation/driver-api/firmware/built-in-fw.rst line 13
Quoted 7 lines
You can enable built-in firmware using the kernel
Documentation/driver-api/firmware/built-in-fw.rst new file +6
-0+configuration options: + + * CONFIG_EXTRA_FIRMWARE + * CONFIG_EXTRA_FIRMWARE_DIR + +The should not be confused with CONFIG_FIRMWARE_IN_KERNEL, this is for drivers
s/The/This/ ?
Quoted 1 line
+which enable firmware to be built as part of the kernel build process. This
enables?
Quoted 7 lines
Documentation/driver-api/firmware/built-in-fw.rst new file +7
-0+option, CONFIG_FIRMWARE_IN_KERNEL, will build all firmware for all drivers +enabled which ship its firmware inside the Linux kernel source tree. + +There are a few reasons why you might want to consider building your firmware +into the kernel with CONFIG_EXTRA_FIRMWARE though: + +* Speed
Documentation/driver-api/firmware/built-in-fw.rst line 31
Quoted 10 lines
Documentation/driver-api/firmware/built-in-fw.rst new file +10
-0+* Firmware is needed for accessing the boot device, and the user doesn't + want to stuff the firmware into the boot initramfs. + +Even if you have these needs there are a few reasons why you may not be +able to make use of built-in firmware: + +* Legalese - firmware is non-GPL compatible +* Some firmware may be optional +* Firmware upgrades are possible, therefore a new firmware would implicate + a complete firmware rebuild.
kernel rebuild?
Documentation/driver-api/firmware/built-in-fw.rst line 35
Quoted 4 lines
Documentation/driver-api/firmware/built-in-fw.rst new file +4
-0+* Some firmware files may be really large in size. The remote-proc subsystem + is an example subsystem which deals with these sorts of firmware +* The firmware may need to be scraped out from some device specific location + dynamically, an example is calibration data for for some WiFi chipsets.
Maybe it is worth to mention, that the calibration data is unique to a given chip, so it is individual. That is you would need to built for each device you sell its own kernel.
[...]
Quoted 7 lines
+++
b/Documentation/driver-api/firmware/fallback-mechanisms.rstDocumentation/driver-api/firmware/fallback-mechanisms.rst new file +5
-0@@ -0,0 +1,195 @@ +=================== +Fallback mechanisms +=================== + +A fallback mechanism is supported to allow to overcome failures to do a direct
Documentation/driver-api/firmware/fallback-mechanisms.rst line 15
Quoted 10 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst new file +10
-0+filesystem lookup on the root filesystem or when the firmware simply cannot be +installed for practical reasons on the root filesystem. The kernel +configuration options related to supporting the firmware fallback mechanism are: + + * CONFIG_FW_LOADER_USER_HELPER: enables building the firmware fallback + mechanism. Most distributions enable this option today. If enabled but + CONFIG_FW_LOADER_USER_HELPER_FALLBACK is disabled, only the custom fallback + mechanism is available and for the request_firmware_nowait() call. + * CONFIG_FW_LOADER_USER_HELPER_FALLBACK: force enables each request to + enable the kobject uevent fallback mechanism on all firmare API calls
s/firmare/firmware/
Quoted 26 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst new file +26
-0+ except request_firmware_direct(). Most distributions disable this option + today. The call request_firmware_nowait() allows for one alternative + fallback mechanism: if this kconfig option is enabled and your second + argument to request_firmware_nowait(), uevent, is set to false you are + informing the kernel that you have a custom fallback mechanism and it will + manually load the firmware. Read below for more details. + +Note that this means when having this configuration: + +CONFIG_FW_LOADER_USER_HELPER=y +CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n + +the kobject uevent fallback mechanism will never take effect even +for request_firmware_nowait() when uevent is set to true. + +Justifying the firmware fallback mechanism +========================================== + +Direct filesystem lookups may fail for a variety of reasons. Known reasons for +this are worth itemizing and documenting as it justifies the need for the +fallback mechanism: + +* Race against access with the root filesystem upon bootup. + +* Races upon resume from suspend. This is resolved by the firmware cache, but + the firmware cache is only supported if you use uevents, and its not
Documentation/driver-api/firmware/fallback-mechanisms.rst line 51
Quoted 10 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst new file +10
-0+ supported for request_firmware_into_buf(). + +* Firmware is not accessible through typical means: + * It cannot be installed into the root filesystem + * The firmware provides very unique device specific data tailored for + the unit gathered with local information. An example is calibration + data for WiFi chipsets for mobile devices. This calibration data is + not common to all units, but tailored per unit. Such information may + be installed on a separate flash partition other than where the root + filesystem is provided.
Ah, her is the bit about the calibration information.
cheers,
daniel
Re: [PATCH 3/5] firmware: revamp firmware documentation
Quoted 11 lines · Daniel Wagner
Quoted 6 lines
+* Some firmware files may be really large in size. The remote-proc subsystem
(quoted diff) +2
-0+ is an example subsystem which deals with these sorts of firmware +* The firmware may need to be scraped out from some device specificlocation
+ dynamically, an example is calibration data for for some WiFi chipsets.Maybe it is worth to mention, that the calibration data is unique to a given chip, so it is individual. That is you would need to built for each device you sell its own kernel.
It's commonly unique to the device model, not a chip. The same chip can be used with different power amplifiers or different antennas. That's why you need model (board) specific calibration data.
Luis R. Rodriguez
maintainerRe: [PATCH 3/5] firmware: revamp firmware documentation
Quoted 13 lines · Rafał Miłecki
Quoted 11 lines · Daniel Wagner
Quoted 6 lines
+* Some firmware files may be really large in size. The remote-proc subsystem
(quoted diff) +2
-0+ is an example subsystem which deals with these sorts of firmware +* The firmware may need to be scraped out from some device specificlocation
+ dynamically, an example is calibration data for for some WiFi chipsets.Maybe it is worth to mention, that the calibration data is unique to a given chip, so it is individual. That is you would need to built for each device you sell its own kernel.
Quoted 5 lines
It's commonly unique to the device model, not a chip. The same chip can be used with different power amplifiers or different antennas. That's why you need model (board) specific calibration data.
From what I recall in my 802.11 days this can be often very specific
per *batch* of cards not just chip/device model, so this depends on the manufacturing process and date.
Luis
Re: [PATCH 3/5] firmware: revamp firmware documentation
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines
Maybe it is worth to mention, that the calibration data is unique to a given chip, so it is individual. That is you would need to built for each device you sell its own kernel.
It's commonly unique to the device model, not a chip. The same chip can be used with different power amplifiers or different antennas. That's why you need model (board) specific calibration data.
From what I recall in my 802.11 days this can be often very specific per *batch* of cards not just chip/device model, so this depends on the manufacturing process and date.
Yes, it can be a per-device calibration done in the factory, and then the data is programmed into the device after that calibration - but if the device is something like a router (not a standalone NIC) then the data might still go through request_firmware() or similar in the end.
johannes
Luis R. Rodriguez
maintainerRe: [PATCH 3/5] firmware: revamp firmware documentation
In reply to Daniel WagnerQuoted 11 lines · Daniel Wagner
Documentation/driver-api/firmware/built-in-fw.rst line 7
Quoted 9 lines
+++
b/Documentation/driver-api/firmware/built-in-fw.rstDocumentation/driver-api/firmware/built-in-fw.rst new file +7
-0@@ -0,0 +1,36 @@ +================= +Built-in firmware +================= + +Firmware can be built-in to the kernel, that is built-in to vmlinux, +to enable firmware lookups to avoid having to look for firmware from +the filesystem.I find the second part of the sentence a bit confusing in the wording.
OK how about:
Firmware can be built-in to the kernel, this means building the firmware into vmlinux directly, to enable avoiding having to look for firmware from the filesystem. Instead, firmware can be looked for inside the kernel directly. You can enable built-in firmware using the kernel configuration options:
* CONFIG_EXTRA_FIRMWARE
* CONFIG_EXTRA_FIRMWARE_DIR
Quoted 9 lines
Documentation/driver-api/firmware/built-in-fw.rst line 13
Quoted 7 lines
You can enable built-in firmware using the kernel
Documentation/driver-api/firmware/built-in-fw.rst new file +6
-0+configuration options: + + * CONFIG_EXTRA_FIRMWARE + * CONFIG_EXTRA_FIRMWARE_DIR + +The should not be confused with CONFIG_FIRMWARE_IN_KERNEL, this is for driverss/The/This/ ?
Fixed.
Quoted 3 lines
Quoted 1 line
+which enable firmware to be built as part of the kernel build process. This
enables?
Fixed.
Quoted 11 lines
Quoted 11 lines
Documentation/driver-api/firmware/built-in-fw.rst new file +11
-0+option, CONFIG_FIRMWARE_IN_KERNEL, will build all firmware for all drivers +enabled which ship its firmware inside the Linux kernel source tree. + +There are a few reasons why you might want to consider building your firmware +into the kernel with CONFIG_EXTRA_FIRMWARE though: + +* Speed +* Firmware is needed for accessing the boot device, and the user doesn't + want to stuff the firmware into the boot initramfs. + +Even if you have these needs there are a few reasons why you may not be
Quoted 8 lines
Documentation/driver-api/firmware/built-in-fw.rst line 31
Quoted 6 lines
Documentation/driver-api/firmware/built-in-fw.rst new file +6
-0+able to make use of built-in firmware: + +* Legalese - firmware is non-GPL compatible +* Some firmware may be optional +* Firmware upgrades are possible, therefore a new firmware would implicate + a complete firmware rebuild.kernel rebuild?
Fixed.
Quoted 8 lines
Documentation/driver-api/firmware/built-in-fw.rst line 35
Quoted 4 lines
Documentation/driver-api/firmware/built-in-fw.rst new file +4
-0+* Some firmware files may be really large in size. The remote-proc subsystem + is an example subsystem which deals with these sorts of firmware +* The firmware may need to be scraped out from some device specific location + dynamically, an example is calibration data for for some WiFi chipsets.Maybe it is worth to mention, that the calibration data is unique to a given chip, so it is individual. That is you would need to built for each device you sell its own kernel.
Adjusted. It now says:
* The firmware may need to be scraped out from some device specific location dynamically, an example is calibration data for for some WiFi chipsets. This calibration data can be unique per sold device.
Quoted 13 lines
[...]
Quoted 11 lines
+++
b/Documentation/driver-api/firmware/fallback-mechanisms.rstDocumentation/driver-api/firmware/fallback-mechanisms.rst new file +9
-0@@ -0,0 +1,195 @@ +=================== +Fallback mechanisms +=================== + +A fallback mechanism is supported to allow to overcome failures to do a direct +filesystem lookup on the root filesystem or when the firmware simply cannot be +installed for practical reasons on the root filesystem. The kernel +configuration options related to supporting the firmware fallback mechanism are: +
Quoted 8 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst line 15
Quoted 6 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst new file +6
-0+ * CONFIG_FW_LOADER_USER_HELPER: enables building the firmware fallback + mechanism. Most distributions enable this option today. If enabled but + CONFIG_FW_LOADER_USER_HELPER_FALLBACK is disabled, only the custom fallback + mechanism is available and for the request_firmware_nowait() call. + * CONFIG_FW_LOADER_USER_HELPER_FALLBACK: force enables each request to + enable the kobject uevent fallback mechanism on all firmare API callss/firmare/firmware/
Fixed.
Luis
Luis R. Rodriguez
maintainerv4 cover firmware: fw doc revamp follow up
In reply to Luis R. RodriguezThis v4 addresses the last 2 remaining patches from the last doc revamp series, which relate only to the firmware custom fallback mechanism. One of the patches just needed minor adjustments to account for a conjunction on SmPL grammar. We also keep the leds-lp55xx-common white-list annotation of DECLARE_FW_CUSTOM_FALLBACK() given despite the fact that it is acknowledged that we could do better, old userspace already exists and relies on using request firmware instead of using sysfs to enable custom control of LEDs.
As clarified in the last series, most users of the custom fallback mechanism have been typo issues on part of the driver developer. The custom fallback mechanism is needed today to help with custom fetching of firmware outside of the typical standard firmware path, and for out of tree drivers for remote-proc firmware for really large firmware files for which initramfs is not suitable. A proper upstream solution for this need has been discussed and we can address this using the *standard fallback mechanism* using *kobject uevents*, what we need is a proper design paired with corresponding userspace component. That is underway. Given this, there is no longer any need *upstream* for these uses. To avoid further issues and to help understand the reason and logic behind old custom uses this adds a white-list upstream to help report if further faulty uses are added upstream.
Luis R. Rodriguez (2):
firmware: add SmPL report for custom fallback mechanism
firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
.../driver-api/firmware/fallback-mechanisms.rst | 20 +++++++++++ drivers/firmware/dell_rbu.c | 1 + drivers/leds/leds-lp55xx-common.c | 1 + include/linux/firmware.h | 7 ++++ .../api/request_firmware-custom-fallback.cocci | 42 ++++++++++++++++++++++ 5 files changed, 71 insertions(+) create mode 100644 scripts/coccinelle/api/request_firmware-custom-fallback.cocci
Signature · 1 line
2.11.0
Luis R. Rodriguez
maintainerPATCH v4 1/2 firmware: add SmPL report for custom fallback mechanism
Even though most distributions today disable the fallback mechanism by default we've determined that we cannot remove them from the kernel. This is not well understood so document the reason and logic behind that.
Recent discussions suggest some future userspace development prospects which may enable fallback mechanisms to become more useful while avoiding some historical issues. These discussions have made it clear though that there is less value to the custom fallback mechanism and an alternative can be provided in the future. Its also clear that some old users of the custom fallback mechanism were using it as a copy and paste error. Because of all this add a Coccinelle SmPL patch to help maintainers police for new incorrect users of the custom fallback mechanism.
Best we can do for now then is police for new users of the custom fallback mechanism and and fix incorrect users when they are spotted. Drivers can only be transitioned out of the custom fallback mechanism once we know old userspace cannot be not be broken by a kernel change.
The current SmPL patch reports:
$ export COCCI=scripts/coccinelle/api/request_firmware-custom-fallback.cocci $ make coccicheck MODE=report
drivers/leds/leds-lp55xx-common.c:227:8-31: WARNING: please check if driver really needs a custom fallback mechanism drivers/firmware/dell_rbu.c:622:17-40: WARNING: please check if driver really needs a custom fallback mechanism
--- .../driver-api/firmware/fallback-mechanisms.rst | 17 +++++++++++ .../api/request_firmware-custom-fallback.cocci | 35 ++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 scripts/coccinelle/api/request_firmware-custom-fallback.cocci
Documentation/driver-api/firmware/fallback-mechanisms.rst +17 -0
@@ -28,6 +28,12 @@ CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n the kobject uevent fallback mechanism will never take effect even for request_firmware_nowait() when uevent is set to true. +Although the fallback mechanisms are not used widely today they cannot be +removed from the kernel since some old userspace may exist which could +entirely depend on the fallback mechanism enabled with the kernel config option +CONFIG_FW_LOADER_USER_HELPER_FALLBACK. In the future though drivers may opt +to embrace a different API which provides alternative fallback mechanisms. + Justifying the firmware fallback mechanism ==========================================
@@ -176,6 +182,17 @@ but you want to suppress kobject uevents, as you have a custom solution which will monitor for your device addition into the device hierarchy somehow and load firmware for you through a custom path. +The custom fallback mechanism can often be enabled by mistake. We currently +have only 2 users of it, and little justification to enable it for other users. +Since it is a common driver developer mistake to enable it, help police for +new users of the custom fallback mechanism with:: + + $ export COCCI=scripts/coccinelle/api/request_firmware-avoid-init-probe-init.cocci + $ make coccicheck MODE=report + +Drivers can only be transitioned out of the custom fallback mechanism +once we know old userspace cannot be not be broken by a kernel change. + Firmware fallback timeout =========================
scripts/coccinelle/api/request_firmware-custom-fallback.cocci new file +35 -0
@@ -0,0 +1,35 @@ +// Avoid the firmware custom fallback mechanism at all costs +// +// request_firmware_nowait() API enables explicit request for use of the custom +// fallback mechanism if firmware is not found. Chances are high its use is +// just a copy and paste bug. Before you fix the driver be sure to *verify* no +// custom firmware loading tool exists that would otherwise break if we replace +// the driver to use the uevent fallback mechanism. +// +// Confidence: High +// +// Copyright: (C) 2017 Luis R. Rodriguez <[email protected]> GPLv2. +// +// Options: --include-headers + +virtual report +virtual context + +@ r1 depends on report || context @ +expression mod, name, dev, gfp, drv, cb; +position p; +@@ + +( +*request_firmware_nowait@p(mod, false, name, dev, gfp, drv, cb) +| +*request_firmware_nowait@p(mod, 0, name, dev, gfp, drv, cb) +| +*request_firmware_nowait@p(mod, FW_ACTION_NOHOTPLUG, name, dev, gfp, drv, cb) +) + +@script:python depends on report@ +p << r1.p; +@@ + +coccilib.report.print_report(p[0], "WARNING: please check if driver really needs a custom fallback mechanism")
Signature · 1 line
2.11.0
Luis R. Rodriguez
maintainerPATCH v4 2/2 firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
In reply to Luis R. RodriguezWe need to ensure that when driver developers use the custom firmware fallback mechanism it was not a copy and paste bug. These use cases on upstream drivers are rare, we only have 2 upstream users and its for really old drivers. Since valid uses are rare but possible enable a white-list for its use, and use this same white-list annotation to refer to the documentation covering the custom use case.
New faulty users can be reported via 0-day now.
v2: change dependencies on rules make more sense, and fixed
context mode
--- Documentation/driver-api/firmware/fallback-mechanisms.rst | 7 +++++-- drivers/firmware/dell_rbu.c | 1 + drivers/leds/leds-lp55xx-common.c | 1 + include/linux/firmware.h | 7 +++++++ scripts/coccinelle/api/request_firmware-custom-fallback.cocci | 9 ++++++++- 5 files changed, 22 insertions(+), 3 deletions(-)
Documentation/driver-api/firmware/fallback-mechanisms.rst +5 -2
@@ -184,8 +184,11 @@ load firmware for you through a custom path. The custom fallback mechanism can often be enabled by mistake. We currently have only 2 users of it, and little justification to enable it for other users. -Since it is a common driver developer mistake to enable it, help police for -new users of the custom fallback mechanism with:: +Since it is a common driver developer mistake to enable it, driver developers +should use DECLARE_FW_CUSTOM_FALLBACK() to both white-list and validate their +use and also refer to the documentation for the custom loading solution. + +Invalid users of the custom fallback mechanism can be policed using:: $ export COCCI=scripts/coccinelle/api/request_firmware-avoid-init-probe-init.cocci $ make coccicheck MODE=report
drivers/firmware/dell_rbu.c +1 -0
@@ -586,6 +586,7 @@ static ssize_t read_rbu_image_type(struct file *filp, struct kobject *kobj,return size; } +DECLARE_FW_CUSTOM_FALLBACK ("Documentation/dell_rbu.txt" );static ssize_t write_rbu_image_type (struct file *filp,struct kobject *kobj,struct bin_attribute *bin_attr,char *buffer,loff_t pos,size_t count)
drivers/leds/leds-lp55xx-common.c +1 -0
@@ -219,6 +219,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)release_firmware (chip->fw); } +DECLARE_FW_CUSTOM_FALLBACK ("Documentation/leds/leds-lp55xx.txt" );static int lp55xx_request_firmware (struct lp55xx_chip *chip) {const char *name = chip->cl->name;
include/linux/firmware.h +7 -0
@@ -8,6 +8,13 @@#define FW_ACTION_NOHOTPLUG 0#define FW_ACTION_HOTPLUG 1 +/* +* Helper for scripts/coccinelle/api/request_firmware-custom-fallback.cocci +* and so users can also easily search for the documentation for the +* respectively needed custom fallback mechanism. +*/ +#define DECLARE_FW_CUSTOM_FALLBACK (__usermode_helper) +struct firmware {size_t size;const u8 *data;
scripts/coccinelle/api/request_firmware-custom-fallback.cocci +8 -1
@@ -15,7 +15,14 @@ virtual report virtual context -@ r1 depends on report || context @ +@ r0 depends on report || context @ +declarer name DECLARE_FW_CUSTOM_FALLBACK; +expression E; +@@ + +DECLARE_FW_CUSTOM_FALLBACK(E); + +@ r1 depends on !r0 && (report || context) @ expression mod, name, dev, gfp, drv, cb; position p; @@
Signature · 1 line
2.11.0
Re: [PATCH v4 2/2] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Quoted 32 lines · Luis R. Rodriguez
We need to ensure that when driver developers use the custom firmware fallback mechanism it was not a copy and paste bug. These use cases on upstream drivers are rare, we only have 2 upstream users and its for really old drivers. Since valid uses are rare but possible enable a white-list for its use, and use this same white-list annotation to refer to the documentation covering the custom use case.
New faulty users can be reported via 0-day now.
v2: change dependencies on rules make more sense, and fixed
context modeCc Fengguang Wu <[email protected]>Cc Richard Purdie <[email protected]>Cc Jacek Anaszewski <[email protected]>Cc Abhay Salunke <[email protected]>Acked-by Jacek Anaszewski <[email protected]>Signed-off-by Luis R. Rodriguez <[email protected]>--- Documentation/driver-api/firmware/fallback-mechanisms.rst | 7 +++++-- drivers/firmware/dell_rbu.c | 1 + drivers/leds/leds-lp55xx-common.c | 1 + include/linux/firmware.h | 7 +++++++ scripts/coccinelle/api/request_firmware-custom-fallback.cocci | 9 ++++++++- 5 files changed, 22 insertions(+), 3 deletions(-)Documentation/driver-api/firmware/fallback-mechanisms.rst +0
-0
Documentation/driver-api/firmware/fallback-mechanisms.rst load firmware for you through a custom path. · line 191
Quoted 10 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst +5
-2@@ -184,8 +184,11 @@ load firmware for you through a custom path. The custom fallback mechanism can often be enabled by mistake. We currently have only 2 users of it, and little justification to enable it for other users. -Since it is a common driver developer mistake to enable it, help police for -new users of the custom fallback mechanism with:: +Since it is a common driver developer mistake to enable it, driver developers +should use DECLARE_FW_CUSTOM_FALLBACK() to both white-list and validate their +use and also refer to the documentation for the custom loading solution. + +Invalid users of the custom fallback mechanism can be policed using::
Ick, no, why? Why not just add a checkpatch rule instead?
drivers/firmware/dell_rbu.c static ssize_t read_rbu_image_type(struct file *filp, struct kobject *kobj, · line 589
Quoted 12 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst +0
-0$ export COCCI=scripts/coccinelle/api/request_firmware-avoid-init-probe-init.cocci $ make coccicheck MODE=reportdrivers/firmware/dell_rbu.c +1
-0@@ -586,6 +586,7 @@ static ssize_t read_rbu_image_type(struct file *filp, struct kobject *kobj,return size; } +DECLARE_FW_CUSTOM_FALLBACK ("Documentation/dell_rbu.txt" );
That's a pain.
drivers/leds/leds-lp55xx-common.c static void lp55xx_firmware_loaded(const struct firmware *fw, void *context) · line 222
Quoted 12 lines
drivers/firmware/dell_rbu.c +0
-0static ssize_t write_rbu_image_type (struct file *filp,struct kobject *kobj,struct bin_attribute *bin_attr,char *buffer,loff_t pos,size_t count)drivers/leds/leds-lp55xx-common.c +1
-0@@ -219,6 +219,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)release_firmware (chip->fw); } +DECLARE_FW_CUSTOM_FALLBACK ("Documentation/leds/leds-lp55xx.txt" );
Same here.
Quoted 8 lines
drivers/leds/leds-lp55xx-common.c +0
-0static int lp55xx_request_firmware (struct lp55xx_chip *chip) {const char *name = chip->cl->name;include/linux/firmware.h +0
-0
include/linux/firmware.h line 16
Quoted 9 lines
include/linux/firmware.h +6
-0@@ -8,6 +8,13 @@#define FW_ACTION_NOHOTPLUG 0#define FW_ACTION_HOTPLUG 1 +/* +* Helper for scripts/coccinelle/api/request_firmware-custom-fallback.cocci +* and so users can also easily search for the documentation for the +* respectively needed custom fallback mechanism. +*/ +#define DECLARE_FW_CUSTOM_FALLBACK (__usermode_helper)
So you really don't need to put anything "valid" in the define argument? This feels like such a horrid hack, I really don't like it, especially as we don't do it anywhere else in the kernel, right? Why start now?
thanks,
greg k-h
Luis R. Rodriguez
maintainerRe: [PATCH v4 2/2] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Quoted 4 lines · Greg KH
Quoted 1 line · Luis R. Rodriguez
+Invalid users of the custom fallback mechanism can be policed using::
Ick, no, why? Why not just add a checkpatch rule instead?
If its easy to do, how would we do that?
Quoted 11 lines
Quoted 11 lines
$ export COCCI=scripts/coccinelle/api/request_firmware-avoid-init-probe-init.cocci $ make coccicheck MODE=reportdrivers/firmware/dell_rbu.c +0
-0@@ -586,6 +586,7 @@ static ssize_t read_rbu_image_type(struct file *filp, struct kobject *kobj,return size; }
Quoted 3 lines
drivers/firmware/dell_rbu.c static ssize_t read_rbu_image_type(struct file *filp, struct kobject *kobj, · line 589
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+DECLARE_FW_CUSTOM_FALLBACK ("Documentation/dell_rbu.txt" );That's a pain.
It is easier with checkpatch?
Quoted 8 lines
Quoted 8 lines
include/linux/firmware.h +0
-0@@ -8,6 +8,13 @@#define FW_ACTION_NOHOTPLUG 0#define FW_ACTION_HOTPLUG 1
Quoted 10 lines
include/linux/firmware.h line 16
Quoted 6 lines
include/linux/firmware.h +6
-0+/* +* Helper for scripts/coccinelle/api/request_firmware-custom-fallback.cocci +* and so users can also easily search for the documentation for the +* respectively needed custom fallback mechanism. +*/ +#define DECLARE_FW_CUSTOM_FALLBACK (__usermode_helper)So you really don't need to put anything "valid" in the define argument? This feels like such a horrid hack, I really don't like it, especially as we don't do it anywhere else in the kernel, right? Why start now?
Correct me if I'm wrong but AFAICT we may not have had previous grammatical policing done before so I think this is a question of how we would want to handle such type of strategies. Indeed this is just one approach. Using checkpatch is certainly possible as well, I however think using checkpatch is a bit more hacky.
I could also just drop this completely but figured its worth discussion.
Luis
Re: [PATCH v4 2/2] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Quoted 7 lines · Luis R. Rodriguez
Quoted 4 lines · Greg KH
Quoted 1 line · Luis R. Rodriguez
+Invalid users of the custom fallback mechanism can be policed using::
Ick, no, why? Why not just add a checkpatch rule instead?
If its easy to do, how would we do that?
You just patch checkpatch.pl to test for the apis you don't want used anymore.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
$ export COCCI=scripts/coccinelle/api/request_firmware-avoid-init-probe-init.cocci $ make coccicheck MODE=reportdrivers/firmware/dell_rbu.c +0
-0@@ -586,6 +586,7 @@ static ssize_t read_rbu_image_type(struct file *filp, struct kobject *kobj,return size; }
Quoted 5 lines
Quoted 3 lines
drivers/firmware/dell_rbu.c static ssize_t read_rbu_image_type(struct file *filp, struct kobject *kobj, · line 589
Quoted 1 line
drivers/firmware/dell_rbu.c +1
-0+DECLARE_FW_CUSTOM_FALLBACK ("Documentation/dell_rbu.txt" );That's a pain.
It is easier with checkpatch?
Yes. You are modifying the .c code just to "whitelist" an api you want to check for. What's the odds that someone who wants to use that api just cargo-cult-copies this line as well, to prevent the strange warning they are getting from the build system? :)
In short, don't worry about this, it's not a big deal nor really worth the effort.
thanks,
greg k-h
Luis R. Rodriguez
maintainerRe: [PATCH v4 2/2] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Quoted 2 lines · Greg KH
In short, don't worry about this, it's not a big deal nor really worth the effort.
Fine by me, I'll drop these two patches.
Luis
Luis R. Rodriguez
maintainerPATCH 4/5 firmware: add SmPL report for custom fallback mechanism
In reply to Luis R. RodriguezEven though most distributions today disable the fallback mechanism by default we've determined that we cannot remove them from the kernel. This is not well understood so document the reason and logic behind that.
Recent discussions suggest some future userspace development prospects which may enable fallback mechanisms to become more useful while avoiding some historical issues. These discussions have made it clear though that there is less value to the custom fallback mechanism and an alternative can be provided in the future. Its also clear that some old users of the custom fallback mechanism were using it as a copy and paste error. Because of all this add a Coccinelle SmPL patch to help maintainers police for new incorrect users of the custom fallback mechanism.
Best we can do for now then is police for new users of the custom fallback mechanism and and fix incorrect users when they are spotted. Drivers can only be transitioned out of the custom fallback mechanism once we know old userspace cannot be not be broken by a kernel change.
The current SmPL patch reports:
$ export COCCI=scripts/coccinelle/api/request_firmware-custom-fallback.cocci $ make coccicheck MODE=report
drivers/leds/leds-lp55xx-common.c:227:8-31: WARNING: please check if driver really needs a custom fallback mechanism drivers/firmware/dell_rbu.c:622:17-40: WARNING: please check if driver really needs a custom fallback mechanism
--- .../driver-api/firmware/fallback-mechanisms.rst | 17 ++++++++++ .../api/request_firmware-custom-fallback.cocci | 37 ++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 scripts/coccinelle/api/request_firmware-custom-fallback.cocci
Documentation/driver-api/firmware/fallback-mechanisms.rst +17 -0
@@ -28,6 +28,12 @@ CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n the kobject uevent fallback mechanism will never take effect even for request_firmware_nowait() when uevent is set to true. +Although the fallback mechanisms are not used widely today they cannot be +removed from the kernel since some old userspace may exist which could +entirely depend on the fallback mechanism enabled with the kernel config option +CONFIG_FW_LOADER_USER_HELPER_FALLBACK. In the future though drivers may opt +to embrace a different API which provides alternative fallback mechanisms. + Justifying the firmware fallback mechanism ==========================================
@@ -176,6 +182,17 @@ but you want to suppress kobject uevents, as you have a custom solution which will monitor for your device addition into the device hierarchy somehow and load firmware for you through a custom path. +The custom fallback mechanism can often be enabled by mistake. We currently +have only 2 users of it, and little justification to enable it for other users. +Since it is a common driver developer mistake to enable it, help police for +new users of the custom fallback mechanism with:: + + $ export COCCI=scripts/coccinelle/api/request_firmware-avoid-init-probe-init.cocci + $ make coccicheck MODE=report + +Drivers can only be transitioned out of the custom fallback mechanism +once we know old userspace cannot be not be broken by a kernel change. + Firmware fallback timeout =========================
scripts/coccinelle/api/request_firmware-custom-fallback.cocci new file +37 -0
@@ -0,0 +1,37 @@ +// Avoid the firmware custom fallback mechanism at all costs +// +// request_firmware_nowait() API enables explicit request for use of the custom +// fallback mechanism if firmware is not found. Chances are high its use is +// just a copy and paste bug. Before you fix the driver be sure to *verify* no +// custom firmware loading tool exists that would otherwise break if we replace +// the driver to use the uevent fallback mechanism. +// +// Confidence: High +// +// Reason for low confidence: +// +// Copyright: (C) 2016 Luis R. Rodriguez <[email protected]> GPLv2. +// +// Options: --include-headers + +virtual report +virtual context + +@ r1 depends on report || context @ +expression mod, name, dev, gfp, drv, cb; +position p; +@@ + +( +*request_firmware_nowait@p(mod, false, name, dev, gfp, drv, cb) +| +*request_firmware_nowait@p(mod, 0, name, dev, gfp, drv, cb) +| +*request_firmware_nowait@p(mod, FW_ACTION_NOHOTPLUG, name, dev, gfp, drv, cb) +) + +@script:python depends on report@ +p << r1.p; +@@ + +coccilib.report.print_report(p[0], "WARNING: please check if driver really needs a custom fallback mechanism")
Signature · 1 line
2.10.1
Re: [PATCH 4/5] firmware: add SmPL report for custom fallback mechanism
Quoted 23 lines · Luis R. Rodriguez
Even though most distributions today disable the fallback mechanism by default we've determined that we cannot remove them from the kernel. This is not well understood so document the reason and logic behind that.
Recent discussions suggest some future userspace development prospects which may enable fallback mechanisms to become more useful while avoiding some historical issues. These discussions have made it clear though that there is less value to the custom fallback mechanism and an alternative can be provided in the future. Its also clear that some old users of the custom fallback mechanism were using it as a copy and paste error. Because of all this add a Coccinelle SmPL patch to help maintainers police for new incorrect users of the custom fallback mechanism.
Best we can do for now then is police for new users of the custom fallback mechanism and and fix incorrect users when they are spotted. Drivers can only be transitioned out of the custom fallback mechanism once we know old userspace cannot be not be broken by a kernel change.
The current SmPL patch reports:
$ export COCCI=scripts/coccinelle/api/request_firmware-custom-fallback.cocci $ make coccicheck MODE=report
Quoted 8 lines
drivers/leds/leds-lp55xx-common.c:227:8-31: WARNING: please check if driver really needs a custom fallback mechanism drivers/firmware/dell_rbu.c:622:17-40: WARNING: please check if driver really needs a custom fallback mechanism
Cc Richard Purdie <[email protected]>Cc Jacek Anaszewski <[email protected]>Cc Abhay Salunke <[email protected]>Signed-off-by Luis R. Rodriguez <[email protected]>
Quoted 88 lines
--- .../driver-api/firmware/fallback-mechanisms.rst | 17 ++++++++++ .../api/request_firmware-custom-fallback.cocci | 37 ++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 scripts/coccinelle/api/request_firmware-custom-fallback.cocciDocumentation/driver-api/firmware/fallback-mechanisms.rst +17
-0@@ -28,6 +28,12 @@ CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n the kobject uevent fallback mechanism will never take effect even for request_firmware_nowait() when uevent is set to true. +Although the fallback mechanisms are not used widely today they cannot be +removed from the kernel since some old userspace may exist which could +entirely depend on the fallback mechanism enabled with the kernel config option +CONFIG_FW_LOADER_USER_HELPER_FALLBACK. In the future though drivers may opt +to embrace a different API which provides alternative fallback mechanisms. + Justifying the firmware fallback mechanism ==========================================@@ -176,6 +182,17 @@ but you want to suppress kobject uevents, as you have a custom solution which will monitor for your device addition into the device hierarchy somehow and load firmware for you through a custom path. +The custom fallback mechanism can often be enabled by mistake. We currently +have only 2 users of it, and little justification to enable it for other users. +Since it is a common driver developer mistake to enable it, help police for +new users of the custom fallback mechanism with:: + + $ export COCCI=scripts/coccinelle/api/request_firmware-avoid-init-probe-init.cocci + $ make coccicheck MODE=report + +Drivers can only be transitioned out of the custom fallback mechanism +once we know old userspace cannot be not be broken by a kernel change. + Firmware fallback timeout =========================scripts/coccinelle/api/request_firmware-custom-fallback.cocci new file +37
-1@@ -0,0 +1,37 @@ +// Avoid the firmware custom fallback mechanism at all costs +// +// request_firmware_nowait() API enables explicit request for use of the custom +// fallback mechanism if firmware is not found. Chances are high its use is +// just a copy and paste bug. Before you fix the driver be sure to *verify* no +// custom firmware loading tool exists that would otherwise break if we replace +// the driver to use the uevent fallback mechanism. +// +// Confidence: High +// +// Reason for low confidence: +// +// Copyright: (C) 2016 Luis R. Rodriguez <[email protected]> GPLv2. +// +// Options: --include-headers + +virtual report +virtual context + +@ r1 depends on report || context @ +expression mod, name, dev, gfp, drv, cb; +position p; +@@ + +( +*request_firmware_nowait@p(mod, false, name, dev, gfp, drv, cb) +| +*request_firmware_nowait@p(mod, 0, name, dev, gfp, drv, cb) +| +*request_firmware_nowait@p(mod, FW_ACTION_NOHOTPLUG, name, dev, gfp, drv, cb) +) + +@script:python depends on report@ +p << r1.p; +@@ + +coccilib.report.print_report(p[0], "WARNING: please check if driver really needs a custom fallback mechanism") --2.10.1
Re: [PATCH 4/5] firmware: add SmPL report for custom fallback mechanism
In reply to Luis R. RodriguezHi Milo,
Could you please verify if leds-lp55xx-common.c driver really needs a custom firmware loading fallback mechanism? See [0] to gain some background knowledge, especially patch 3/5 seems to provide a big amount of information.
[0] https://lkml.org/lkml/2016/12/12/717
Thanks,
Jacek Anaszewski
Quoted 116 lines · Luis R. Rodriguez
Even though most distributions today disable the fallback mechanism by default we've determined that we cannot remove them from the kernel. This is not well understood so document the reason and logic behind that.
Recent discussions suggest some future userspace development prospects which may enable fallback mechanisms to become more useful while avoiding some historical issues. These discussions have made it clear though that there is less value to the custom fallback mechanism and an alternative can be provided in the future. Its also clear that some old users of the custom fallback mechanism were using it as a copy and paste error. Because of all this add a Coccinelle SmPL patch to help maintainers police for new incorrect users of the custom fallback mechanism.
Best we can do for now then is police for new users of the custom fallback mechanism and and fix incorrect users when they are spotted. Drivers can only be transitioned out of the custom fallback mechanism once we know old userspace cannot be not be broken by a kernel change.
The current SmPL patch reports:
$ export COCCI=scripts/coccinelle/api/request_firmware-custom-fallback.cocci $ make coccicheck MODE=reportdrivers/leds/leds-lp55xx-common.c:227:8-31: WARNING: please check if driver really needs a custom fallback mechanism drivers/firmware/dell_rbu.c:622:17-40: WARNING: please check if driver really needs a custom fallback mechanism
Cc Richard Purdie <[email protected]>Cc Jacek Anaszewski <[email protected]>Cc Abhay Salunke <[email protected]>Signed-off-by Luis R. Rodriguez <[email protected]>--- .../driver-api/firmware/fallback-mechanisms.rst | 17 ++++++++++ .../api/request_firmware-custom-fallback.cocci | 37 ++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 scripts/coccinelle/api/request_firmware-custom-fallback.cocciDocumentation/driver-api/firmware/fallback-mechanisms.rst +17
-0@@ -28,6 +28,12 @@ CONFIG_FW_LOADER_USER_HELPER_FALLBACK=n the kobject uevent fallback mechanism will never take effect even for request_firmware_nowait() when uevent is set to true. +Although the fallback mechanisms are not used widely today they cannot be +removed from the kernel since some old userspace may exist which could +entirely depend on the fallback mechanism enabled with the kernel config option +CONFIG_FW_LOADER_USER_HELPER_FALLBACK. In the future though drivers may opt +to embrace a different API which provides alternative fallback mechanisms. + Justifying the firmware fallback mechanism ==========================================@@ -176,6 +182,17 @@ but you want to suppress kobject uevents, as you have a custom solution which will monitor for your device addition into the device hierarchy somehow and load firmware for you through a custom path. +The custom fallback mechanism can often be enabled by mistake. We currently +have only 2 users of it, and little justification to enable it for other users. +Since it is a common driver developer mistake to enable it, help police for +new users of the custom fallback mechanism with:: + + $ export COCCI=scripts/coccinelle/api/request_firmware-avoid-init-probe-init.cocci + $ make coccicheck MODE=report + +Drivers can only be transitioned out of the custom fallback mechanism +once we know old userspace cannot be not be broken by a kernel change. + Firmware fallback timeout =========================scripts/coccinelle/api/request_firmware-custom-fallback.cocci new file +37
-0@@ -0,0 +1,37 @@ +// Avoid the firmware custom fallback mechanism at all costs +// +// request_firmware_nowait() API enables explicit request for use of the custom +// fallback mechanism if firmware is not found. Chances are high its use is +// just a copy and paste bug. Before you fix the driver be sure to *verify* no +// custom firmware loading tool exists that would otherwise break if we replace +// the driver to use the uevent fallback mechanism. +// +// Confidence: High +// +// Reason for low confidence: +// +// Copyright: (C) 2016 Luis R. Rodriguez <[email protected]> GPLv2. +// +// Options: --include-headers + +virtual report +virtual context + +@ r1 depends on report || context @ +expression mod, name, dev, gfp, drv, cb; +position p; +@@ + +( +*request_firmware_nowait@p(mod, false, name, dev, gfp, drv, cb) +| +*request_firmware_nowait@p(mod, 0, name, dev, gfp, drv, cb) +| +*request_firmware_nowait@p(mod, FW_ACTION_NOHOTPLUG, name, dev, gfp, drv, cb) +) + +@script:python depends on report@ +p << r1.p; +@@ + +coccilib.report.print_report(p[0], "WARNING: please check if driver really needs a custom fallback mechanism")
Re: [PATCH 4/5] firmware: add SmPL report for custom fallback mechanism
Hi Jacek,
Quoted 3 lines · Jacek Anaszewski
Could you please verify if
leds-lp55xx-common.cdriver really needs a custom firmware loading fallback mechanism?
Thanks for sharing this. The lp55xx-common uses this mechanism to load and run LED effect manually, so this could be a misuse case. I think the right solution is providing device attributes.
At this moment, four drivers use lp55xx-common code.
- lp5521, lp5523: OK if we do not support FW loading fallback mechanism
- lp5562, lp8501: need to create additional sysfs alternatively.
However, we should be careful because I'm not sure this modification will generate the regression (breaking the user-space) or not.
Best regards,
Milo
Luis R. Rodriguez
maintainerRe: [PATCH 4/5] firmware: add SmPL report for custom fallback mechanism
Quoted 10 lines · Milo Kim
Hi Jacek,
Quoted 3 lines · Jacek Anaszewski
Could you please verify if
leds-lp55xx-common.cdriver really needs a custom firmware loading fallback mechanism?Thanks for sharing this. The lp55xx-common uses this mechanism to load and run LED effect manually, so this could be a misuse case.
I think the right solution is providing device attributes.
Run LED manually using request_firmware()? What the.. yes this sounds odd.
Quoted 4 lines
At this moment, four drivers use lp55xx-common code.
- lp5521, lp5523: OK if we do not support FW loading fallback mechanism
- lp5562, lp8501: need to create additional sysfs alternatively.
Phew!
Quoted 2 lines
However, we should be careful because I'm not sure this modification will generate the regression (breaking the user-space) or not.
Right so not breaking old userspace is critical.
Luis
Luis R. Rodriguez
maintainerRe: [PATCH 4/5] firmware: add SmPL report for custom fallback mechanism
Quoted 19 lines · Luis R. Rodriguez
Quoted 10 lines · Milo Kim
Hi Jacek,
Quoted 3 lines · Jacek Anaszewski
Could you please verify if
leds-lp55xx-common.cdriver really needs a custom firmware loading fallback mechanism?Thanks for sharing this. The lp55xx-common uses this mechanism to load and run LED effect manually, so this could be a misuse case.
I think the right solution is providing device attributes.Run LED manually using
request_firmware()? What the.. yes this sounds odd.Quoted 4 lines
At this moment, four drivers use lp55xx-common code.
- lp5521, lp5523: OK if we do not support FW loading fallback mechanism
- lp5562, lp8501: need to create additional sysfs alternatively.
Quoted 6 lines
Phew!
Quoted 2 lines
However, we should be careful because I'm not sure this modification will generate the regression (breaking the user-space) or not.
Right so not breaking old userspace is critical.
So to recap:
What you can do is add support for the new interface and recommend folks to use it. We just cannot break old userspace relying on the same module.
So the currently proposed DECLARE_FW_CUSTOM_FALLBACK() is still justified for this driver. As stupid as the original implementation may have been its there.. and we just have to deal with it. I would seriously appreciate a revamp update on the Documentation/leds/leds-lp55xx.txt documentation though with everything that we have discussed.
Luis
Luis R. Rodriguez
maintainerPATCH 5/5 firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
In reply to Luis R. RodriguezWe need to ensure that when driver developers use the custom firmware fallback mechanism it was not a copy and paste bug. These use cases on upstream drivers are rare, we only have 2 upstream users and its for really old drivers. Since valid uses are rare but possible enable a white-list for its use, and use this same white-list annotation to refer to the documentation covering the custom use case.
New faulty users can be reported via 0-day now.
--- Documentation/driver-api/firmware/fallback-mechanisms.rst | 7 +++++-- drivers/firmware/dell_rbu.c | 1 + drivers/leds/leds-lp55xx-common.c | 1 + include/linux/firmware.h | 7 +++++++ scripts/coccinelle/api/request_firmware-custom-fallback.cocci | 9 ++++++++- 5 files changed, 22 insertions(+), 3 deletions(-)
Documentation/driver-api/firmware/fallback-mechanisms.rst +5 -2
@@ -184,8 +184,11 @@ load firmware for you through a custom path. The custom fallback mechanism can often be enabled by mistake. We currently have only 2 users of it, and little justification to enable it for other users. -Since it is a common driver developer mistake to enable it, help police for -new users of the custom fallback mechanism with:: +Since it is a common driver developer mistake to enable it, driver developers +should use DECLARE_FW_CUSTOM_FALLBACK() to both white-list and validate their +use and also refer to the documentation for the custom loading solution. + +Invalid users of the custom fallback mechanism can be policed using:: $ export COCCI=scripts/coccinelle/api/request_firmware-avoid-init-probe-init.cocci $ make coccicheck MODE=report
drivers/firmware/dell_rbu.c +1 -0
@@ -586,6 +586,7 @@ static ssize_t read_rbu_image_type(struct file *filp, struct kobject *kobj,return size; } +DECLARE_FW_CUSTOM_FALLBACK ("Documentation/dell_rbu.txt" );static ssize_t write_rbu_image_type (struct file *filp,struct kobject *kobj,struct bin_attribute *bin_attr,char *buffer,loff_t pos,size_t count)
drivers/leds/leds-lp55xx-common.c +1 -0
@@ -219,6 +219,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)release_firmware (chip->fw); } +DECLARE_FW_CUSTOM_FALLBACK ("Documentation/leds/leds-lp55xx.txt" );static int lp55xx_request_firmware (struct lp55xx_chip *chip) {const char *name = chip->cl->name;
include/linux/firmware.h +7 -0
@@ -8,6 +8,13 @@#define FW_ACTION_NOHOTPLUG 0#define FW_ACTION_HOTPLUG 1 +/* +* Helper for scripts/coccinelle/api/request_firmware-custom-fallback.cocci +* and so users can also easily search for the documentation for the +* respectively needed custom fallback mechanism. +*/ +#define DECLARE_FW_CUSTOM_FALLBACK (__usermode_helper) +struct firmware {size_t size;const u8 *data;
scripts/coccinelle/api/request_firmware-custom-fallback.cocci +8 -1
@@ -17,6 +17,13 @@ virtual report virtual context +@ r0 depends on report || context @ +declarer name DECLARE_FW_CUSTOM_FALLBACK; +expression E; +@@ + +DECLARE_FW_CUSTOM_FALLBACK(E); + @ r1 depends on report || context @ expression mod, name, dev, gfp, drv, cb; position p;
@@ -30,7 +37,7 @@ position p; *request_firmware_nowait@p(mod, FW_ACTION_NOHOTPLUG, name, dev, gfp, drv, cb) ) -@script:python depends on report@ +@script:python depends on report && !r0 @ p << r1.p; @@
Signature · 1 line
2.10.1
Re: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Hi!
Quoted 10 lines
We need to ensure that when driver developers use the custom firmware fallback mechanism it was not a copy and paste bug. These use cases on upstream drivers are rare, we only have 2 upstream users and its for really old drivers. Since valid uses are rare but possible enable a white-list for its use, and use this same white-list annotation to refer to the documentation covering the custom use case.
drivers/leds/leds-lp55xx-common.c static void lp55xx_firmware_loaded(const struct firmware *fw, void *context) · line 225
Quoted 7 lines
drivers/leds/leds-lp55xx-common.c +1
-0@@ -219,6 +219,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)release_firmware (chip->fw); } +DECLARE_FW_CUSTOM_FALLBACK ("Documentation/leds/leds-lp55xx.txt" );static int lp55xx_request_firmware (struct lp55xx_chip *chip) {const char *name = chip->cl->name;
The driver does:
static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)
{
struct lp55xx_chip *chip = context;
struct device *dev = &chip->cl->dev;
enum lp55xx_engine_index idx =
chip->engine_idx;
if (!fw) {
dev_err(dev, "firmware request failed\n");
goto out;
}
...
out:
/* firmware should be released for other channel use */
release_firmware(chip->fw);
}Does that match the "custom fallback" definition?
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Luis R. Rodriguez
maintainerRe: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Quoted 41 lines · Pavel Machek
Hi!
Quoted 10 lines
We need to ensure that when driver developers use the custom firmware fallback mechanism it was not a copy and paste bug. These use cases on upstream drivers are rare, we only have 2 upstream users and its for really old drivers. Since valid uses are rare but possible enable a white-list for its use, and use this same white-list annotation to refer to the documentation covering the custom use case.
drivers/leds/leds-lp55xx-common.c static void lp55xx_firmware_loaded(const struct firmware *fw, void *context) · line 225
Quoted 7 lines
drivers/leds/leds-lp55xx-common.c +1
-0@@ -219,6 +219,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)release_firmware (chip->fw); } +DECLARE_FW_CUSTOM_FALLBACK ("Documentation/leds/leds-lp55xx.txt" );static int lp55xx_request_firmware (struct lp55xx_chip *chip) {const char *name = chip->cl->name;The driver does:
static void
lp55xx_firmware_loaded(const struct firmware *fw, void *context){ struct lp55xx_chip *chip = context; struct device *dev = &chip->cl->dev; enum lp55xx_engine_index idx = chip->engine_idx; if (!fw) { dev_err(dev, "firmware request failed\n"); goto out; } ... out: /* firmware should be released for other channel use */ release_firmware(chip->fw); }
Quoted 1 line
Does that match the "custom fallback" definition?
Refer to the documentation I supplied, and also to the grammar rule, in particular the patch "firmware: add SmPL report for custom fallback mechanism", it captures the SmPL form for the custom fallback mechanism as:
@ r1 depends on report || context @
expression mod, name, dev, gfp, drv, cb;
position p;
@@
(
*request_firmware_nowait@p(mod, false, name, dev, gfp, drv, cb)
|
*request_firmware_nowait@p(mod, 0, name, dev, gfp, drv, cb)
|
*request_firmware_nowait@p(mod, FW_ACTION_NOHOTPLUG, name, dev, gfp, drv, cb) )
Re: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Quoted 42 lines · Luis R. Rodriguez
Quoted 41 lines · Pavel Machek
Hi!
Quoted 10 lines
We need to ensure that when driver developers use the custom firmware fallback mechanism it was not a copy and paste bug. These use cases on upstream drivers are rare, we only have 2 upstream users and its for really old drivers. Since valid uses are rare but possible enable a white-list for its use, and use this same white-list annotation to refer to the documentation covering the custom use case.
drivers/leds/leds-lp55xx-common.c static void lp55xx_firmware_loaded(const struct firmware *fw, void *context) · line 225
Quoted 7 lines
drivers/leds/leds-lp55xx-common.c +1
-0@@ -219,6 +219,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)release_firmware (chip->fw); } +DECLARE_FW_CUSTOM_FALLBACK ("Documentation/leds/leds-lp55xx.txt" );static int lp55xx_request_firmware (struct lp55xx_chip *chip) {const char *name = chip->cl->name;The driver does:
static void
lp55xx_firmware_loaded(const struct firmware *fw, void *context){ struct lp55xx_chip *chip = context; struct device *dev = &chip->cl->dev; enum lp55xx_engine_index idx = chip->engine_idx; if (!fw) { dev_err(dev, "firmware request failed\n"); goto out; } ... out: /* firmware should be released for other channel use */ release_firmware(chip->fw); }
Quoted 5 lines
Quoted 1 line
Does that match the "custom fallback" definition?
Refer to the documentation I supplied, and also to the grammar rule, in particular the patch "firmware: add SmPL report for custom fallback mechanism", it captures the SmPL form for the custom fallback mechanism as:
I don't much care what the rule says. If you believe the code is buggy, submit a patch.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Luis R. Rodriguez
maintainerRe: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Quoted 43 lines · Pavel Machek
Quoted 42 lines · Luis R. Rodriguez
Quoted 41 lines · Pavel Machek
Hi!
Quoted 10 lines
We need to ensure that when driver developers use the custom firmware fallback mechanism it was not a copy and paste bug. These use cases on upstream drivers are rare, we only have 2 upstream users and its for really old drivers. Since valid uses are rare but possible enable a white-list for its use, and use this same white-list annotation to refer to the documentation covering the custom use case.
drivers/leds/leds-lp55xx-common.c static void lp55xx_firmware_loaded(const struct firmware *fw, void *context) · line 225
Quoted 7 lines
drivers/leds/leds-lp55xx-common.c +1
-0@@ -219,6 +219,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)release_firmware (chip->fw); } +DECLARE_FW_CUSTOM_FALLBACK ("Documentation/leds/leds-lp55xx.txt" );static int lp55xx_request_firmware (struct lp55xx_chip *chip) {const char *name = chip->cl->name;The driver does:
static void
lp55xx_firmware_loaded(const struct firmware *fw, void *context){ struct lp55xx_chip *chip = context; struct device *dev = &chip->cl->dev; enum lp55xx_engine_index idx = chip->engine_idx; if (!fw) { dev_err(dev, "firmware request failed\n"); goto out; } ... out: /* firmware should be released for other channel use */ release_firmware(chip->fw); }
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Does that match the "custom fallback" definition?
Refer to the documentation I supplied, and also to the grammar rule, in particular the patch "firmware: add SmPL report for custom fallback mechanism", it captures the SmPL form for the custom fallback mechanism as:
I don't much care what the rule says. If you believe the code is buggy, submit a patch.
Huh? No, its an old API and valid uses are scarce. The point is to avoid folks adding yet other users by mistake by using grammar to help white-list actual valid users.
Luis
Re: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Quoted 50 lines · Luis R. Rodriguez
Quoted 49 lines · Pavel Machek
Quoted 47 lines · Luis R. Rodriguez
Quoted 41 lines · Pavel Machek
Hi!
Quoted 10 lines
We need to ensure that when driver developers use the custom firmware fallback mechanism it was not a copy and paste bug. These use cases on upstream drivers are rare, we only have 2 upstream users and its for really old drivers. Since valid uses are rare but possible enable a white-list for its use, and use this same white-list annotation to refer to the documentation covering the custom use case.
drivers/leds/leds-lp55xx-common.c static void lp55xx_firmware_loaded(const struct firmware *fw, void *context) · line 225
Quoted 7 lines
drivers/leds/leds-lp55xx-common.c +1
-0@@ -219,6 +219,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)release_firmware (chip->fw); } +DECLARE_FW_CUSTOM_FALLBACK ("Documentation/leds/leds-lp55xx.txt" );static int lp55xx_request_firmware (struct lp55xx_chip *chip) {const char *name = chip->cl->name;The driver does:
static void
lp55xx_firmware_loaded(const struct firmware *fw, void *context){ struct lp55xx_chip *chip = context; struct device *dev = &chip->cl->dev; enum lp55xx_engine_index idx = chip->engine_idx; if (!fw) { dev_err(dev, "firmware request failed\n"); goto out; } ... out: /* firmware should be released for other channel use */ release_firmware(chip->fw); }Quoted 1 line
Does that match the "custom fallback" definition?
Refer to the documentation I supplied, and also to the grammar rule, in particular the patch "firmware: add SmPL report for custom fallback mechanism", it captures the SmPL form for the custom fallback mechanism as:
Quoted 6 lines
Quoted 2 lines
I don't much care what the rule says. If you believe the code is buggy, submit a patch.
Huh? No, its an old API and valid uses are scarce. The point is to avoid folks adding yet other users by mistake by using grammar to help white-list actual valid users.
Well, I was asking if the above snipped looks like valid use. Because AFAICT, the "custom fallback" is just dev_err(), see above. Coccinelle rules don't help me...
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Luis R. Rodriguez
maintainerRe: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Quoted 4 lines · Pavel Machek
Well, I was asking if the above snipped looks like valid use. Because AFAICT, the "custom fallback" is just
dev_err(), see above. Coccinelle rules don't help me...
Its not. Its when you ask for no uevent. Only 2 drivers do this.
Luis
Re: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Quoted 7 lines · Luis R. Rodriguez
Quoted 4 lines · Pavel Machek
Well, I was asking if the above snipped looks like valid use. Because AFAICT, the "custom fallback" is just
dev_err(), see above. Coccinelle rules don't help me...Its not. Its when you ask for no uevent. Only 2 drivers do this.
That was one of two you listed. If that is not valid use, perhaps it should be removed, not annotated?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Luis R. Rodriguez
maintainerRe: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Quoted 11 lines · Pavel Machek
Quoted 7 lines · Luis R. Rodriguez
Quoted 4 lines · Pavel Machek
Well, I was asking if the above snipped looks like valid use. Because AFAICT, the "custom fallback" is just
dev_err(), see above. Coccinelle rules don't help me...Its not. Its when you ask for no uevent. Only 2 drivers do this.
That was one of two you listed. If that is not valid use, perhaps it should be removed, not annotated?
Pavel, the annotation was added on top of:
static int lp55xx_request_firmware(struct lp55xx_chip *chip)
{
const char *name = chip->cl->name;
struct device *dev = &chip->cl->dev;
return request_firmware_nowait(THIS_MODULE, false, name, dev,
GFP_KERNEL, chip, lp55xx_firmware_loaded);
}Note the second argument is false. This matches the grammar and the definition for a custom fallback mechanism since uevents are not used. What am I missing?
Luis
Luis R. Rodriguez
maintainerRe: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
In reply to Pavel MachekQuoted 11 lines · Pavel Machek
Quoted 7 lines · Luis R. Rodriguez
Quoted 4 lines · Pavel Machek
Well, I was asking if the above snipped looks like valid use. Because AFAICT, the "custom fallback" is just
dev_err(), see above. Coccinelle rules don't help me...Its not. Its when you ask for no uevent. Only 2 drivers do this.
That was one of two you listed. If that is not valid use, perhaps it should be removed, not annotated?
Ah, well Milo Kim replied and described that the custom fallback is used as to help load LED effect manually, and suggested a sysfs interface is more ideal [0]. I agree however its also may be too late, and it depends how wide spread this "userspace" that relies on this is, we just can't break it. Granted the custom fallback mechanism was broken since v4.0 (see the fix "firmware: fix usermode helper fallback loading") so one may argue no one seems to care...
So this is a judgement call, and the declaration is to point to documentation to white list uses, as terrible as this one is userspace exists for it. but more importantly to also help the SmPL grammar report to avoid reporting already vetted cases. The alarm / cases for the 2 drivers has been issueed, moving forward the lack of declaration with the custom fallback should trigger a rant through 0-day so we don't run into the same stupid situation.
[0] https://marc.info/?l=linux-kernel&m=148168024112445
Luis
Luis R. Rodriguez
maintainerRe: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Quoted 7 lines · Luis R. Rodriguez
Ah, well Milo Kim replied and described that the custom fallback is used as to help load LED effect manually, and suggested a sysfs interface is more ideal [0]. I agree however its also may be too late, and it depends how wide spread this "userspace" that relies on this is, we just can't break it. Granted the custom fallback mechanism was broken since v4.0 (see the fix "firmware: fix usermode helper fallback loading") so one may argue no one seems to care...
Quoted 8 lines
So this is a judgement call, and the declaration is to point to documentation to white list uses, as terrible as this one is userspace exists for it. but more importantly to also help the SmPL grammar report to avoid reporting already vetted cases. The alarm / cases for the 2 drivers has been issueed, moving forward the lack of declaration with the custom fallback should trigger a rant through 0-day so we don't run into the same stupid situation.
Milo if sysfs is used can't the old userspace be mapped to use the new sysfs interface through a wrapper of some sort ? What exactly would be needed to ensure old userspace will not break? Why has no one cried after the v4.0 custom fallback mechanism breaking ? How wide spread is this custom userspace ?
Luis
Re: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Hi Luis,
Quoted 3 lines · Luis R. Rodriguez
Milo if sysfs is used can't the old userspace be mapped to use the new sysfs interface through a wrapper of some sort ? What exactly would be needed to ensure old userspace will not break?
LP5521 and LP5523 have two ways to load hex code from the userspace - the sysfs and firmware I/F. So user program supports both interfaces. Even if the firmware I/F is not available, user can still run LED effect through the sysfs.
However, LP5562 and LP8501 support only single way which is the firmware I/F. So user-space program for LP5562/8501 should be modified if lp55xx removes the interface. My idea is
Phase 1)
- create sysfs in LP5562 and LP8501
- use new sysfs inside the firmware I/F loading callback
- mark the firmware callback as a deprecated interface
Phase 2)
- remove the firmware I/F after all user program fixes the interface (but the problem is how can we get to know when this is done?)
Quoted 2 lines
Why has no one cried
after the v4.0 custom fallback mechanism breaking ?
Well, I don't know the reason exactly but my guess is they maybe still using old kernel.
Quoted 1 line
How wide spread is this custom userspace ?
Device manufactures in Asia & North America requested lp55xx drivers, but I don't know how many vendors uses the firmware I/F. Some vendors embeds the binary code inside the driver instead of using user-program.
I understood it's a kind of troublesome work in terms of the maintenance. Sorry for that. I hope we have a consensus to resolve it. Thanks!
Best regards,
Milo
Re: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Hi!
Quoted 5 lines · Luis R. Rodriguez
Quoted 3 lines
Milo if sysfs is used can't the old userspace be mapped to use the new sysfs interface through a wrapper of some sort ? What exactly would be needed to ensure old userspace will not break?
Quoted 8 lines
LP5521 and LP5523 have two ways to load hex code from the userspace - the sysfs and firmware I/F. So user program supports both interfaces. Even if the firmware I/F is not available, user can still run LED effect through the sysfs.
However, LP5562 and LP8501 support only single way which is the firmware I/F. So user-space program for LP5562/8501 should be modified if lp55xx removes the interface. My idea is
Actually... it would be good to have some reasonable interface for RGB LEDs. This way, we need separate "firmware" for each LED controller. It would be good to have common format for LED effects.
Quoted 4 lines
Phase 1)
- create sysfs in LP5562 and LP8501
- use new sysfs inside the firmware I/F loading callback
- mark the firmware callback as a deprecated interface
Phase 1a)
stick WARN_ON() in the firmware callback.
Quoted 7 lines
Phase 2)
- remove the firmware I/F after all user program fixes the interface (but the problem is how can we get to know when this is done?)Quoted 2 lines
Why has no one cried
after the v4.0 custom fallback mechanism breaking ?
Quoted 8 lines
Well, I don't know the reason exactly but my guess is they maybe still using old kernel.
Quoted 1 line
How wide spread is this custom userspace ?
Device manufactures in Asia & North America requested lp55xx drivers, but I don't know how many vendors uses the firmware I/F. Some vendors embeds the binary code inside the driver instead of using user-program.
Nokia N900 uses lp55xx, and I have custom scripts interfacing sysfs.
Maemo uses the LEDs, too, but maemo is not open source.
So no, I don't think there's anything important that could be broken.
Best regards,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Quoted 12 lines · Pavel Machek
Hi!
Quoted 10 lines · Luis R. Rodriguez
Quoted 3 lines
Milo if sysfs is used can't the old userspace be mapped to use the new sysfs interface through a wrapper of some sort ? What exactly would be needed to ensure old userspace will not break?
LP5521 and LP5523 have two ways to load hex code from the userspace - the sysfs and firmware I/F. So user program supports both interfaces. Even if the firmware I/F is not available, user can still run LED effect through the sysfs.
Quoted 7 lines
Quoted 3 lines
However, LP5562 and LP8501 support only single way which is the firmware I/F. So user-space program for LP5562/8501 should be modified if lp55xx removes the interface. My idea is
Actually... it would be good to have some reasonable interface for RGB LEDs. This way, we need separate "firmware" for each LED controller. It would be good to have common format for LED effects.
We still haven't tried trigger approach discussed over half a year ago. If we used firmware approach we would still have to overcome the problem of defining the LED class drivers affected by the firmware program.
Quoted 25 lines
Quoted 4 lines
Phase 1)
- create sysfs in LP5562 and LP8501
- use new sysfs inside the firmware I/F loading callback
- mark the firmware callback as a deprecated interfacePhase 1a)
stick
WARN_ON()in the firmware callback.Quoted 7 lines
Phase 2)
- remove the firmware I/F after all user program fixes the interface (but the problem is how can we get to know when this is done?)Quoted 2 lines
Why has no one cried
after the v4.0 custom fallback mechanism breaking ?Quoted 8 lines
Well, I don't know the reason exactly but my guess is they maybe still using old kernel.
Quoted 1 line
How wide spread is this custom userspace ?
Device manufactures in Asia & North America requested lp55xx drivers, but I don't know how many vendors uses the firmware I/F. Some vendors embeds the binary code inside the driver instead of using user-program.
Quoted 5 lines
Nokia N900 uses lp55xx, and I have custom scripts interfacing sysfs.
Maemo uses the LEDs, too, but maemo is not open source.
So no, I don't think there's anything important that could be broken.
We can't guarantee that. Is there any problem in just using the currently introduced DECLARE_FW_CUSTOM_FALLBACK() in drivers/leds/leds-lp55xx-common.c?
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Hi!
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 3 lines
Milo if sysfs is used can't the old userspace be mapped to use the new sysfs interface through a wrapper of some sort ? What exactly would be needed to ensure old userspace will not break?
LP5521 and LP5523 have two ways to load hex code from the userspace - the sysfs and firmware I/F. So user program supports both interfaces. Even if the firmware I/F is not available, user can still run LED effect through the sysfs.
However, LP5562 and LP8501 support only single way which is the firmware I/F. So user-space program for LP5562/8501 should be modified if lp55xx removes the interface. My idea is
Quoted 7 lines
Quoted 3 lines
Actually... it would be good to have some reasonable interface for RGB LEDs. This way, we need separate "firmware" for each LED controller. It would be good to have common format for LED effects.
We still haven't tried trigger approach discussed over half a year ago. If we used firmware approach we would still have to overcome the problem of defining the LED class drivers affected by the firmware program.
The firmware approach is in the tree today :-(.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Device manufactures in Asia & North America requested lp55xx drivers, but I don't know how many vendors uses the firmware I/F. Some vendors embeds the binary code inside the driver instead of using user-program.
Nokia N900 uses lp55xx, and I have custom scripts interfacing sysfs.
Quoted 7 lines
Quoted 3 lines
Maemo uses the LEDs, too, but maemo is not open source.
So no, I don't think there's anything important that could be broken.
We can't guarantee that. Is there any problem in just using the currently introduced
DECLARE_FW_CUSTOM_FALLBACK()indrivers/leds/leds-lp55xx-common.c?
Well, it would be good to get rid of the custom fallback functionality. And no, we don't need to "guarantee" that. Removing obscure functionality noone uses is far game... providing noone complains ;-).
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Hi,
Quoted 19 lines · Pavel Machek
Hi!
Quoted 17 lines
Quoted 16 lines
Quoted 4 lines
Quoted 3 lines
Milo if sysfs is used can't the old userspace be mapped to use the new sysfs interface through a wrapper of some sort ? What exactly would be needed to ensure old userspace will not break?
Quoted 8 lines
LP5521 and LP5523 have two ways to load hex code from the userspace - the sysfs and firmware I/F. So user program supports both interfaces. Even if the firmware I/F is not available, user can still run LED effect through the sysfs.
However, LP5562 and LP8501 support only single way which is the firmware I/F. So user-space program for LP5562/8501 should be modified if lp55xx removes the interface. My idea is
Actually... it would be good to have some reasonable interface for RGB LEDs. This way, we need separate "firmware" for each LED controller. It would be good to have common format for LED effects.
Quoted 5 lines
Quoted 3 lines
We still haven't tried trigger approach discussed over half a year ago. If we used firmware approach we would still have to overcome the problem of defining the LED class drivers affected by the firmware program.
The firmware approach is in the tree today :-(.
to RGB LEDs? What exactly do you have on mind?
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 4 lines
Device manufactures in Asia & North America requested lp55xx drivers, but I don't know how many vendors uses the firmware I/F. Some vendors embeds the binary code inside the driver instead of using user-program.
Nokia N900 uses lp55xx, and I have custom scripts interfacing sysfs.
Maemo uses the LEDs, too, but maemo is not open source.
So no, I don't think there's anything important that could be broken.
Quoted 8 lines
Quoted 3 lines
We can't guarantee that. Is there any problem in just using the currently introduced
DECLARE_FW_CUSTOM_FALLBACK()indrivers/leds/leds-lp55xx-common.c?Well, it would be good to get rid of the custom fallback functionality. And no, we don't need to "guarantee" that. Removing obscure functionality noone uses is far game... providing noone complains ;-).
As Milo explained:
Quoted 2 lines
Why has no one cried
after the v4.0 custom fallback mechanism breaking ?
"Well, I don't know the reason exactly but my guess is they maybe still using old kernel."
and after that:
"Device manufactures in Asia & North America requested lp55xx drivers"
These should be sufficient arguments for us for keeping the API unchanged. If the users decided to upgrade their kernel then they would be surprised by the API change.
DECLARE_FW_CUSTOM_FALLBACK macro seems to have been designed for handling exactly this type of cases.
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
In reply to Luis R. RodriguezHi Luis,
Thanks for the patch.
Quoted 28 lines · Luis R. Rodriguez
We need to ensure that when driver developers use the custom firmware fallback mechanism it was not a copy and paste bug. These use cases on upstream drivers are rare, we only have 2 upstream users and its for really old drivers. Since valid uses are rare but possible enable a white-list for its use, and use this same white-list annotation to refer to the documentation covering the custom use case.
New faulty users can be reported via 0-day now.
Cc Fengguang Wu <[email protected]>Cc Richard Purdie <[email protected]>Cc Jacek Anaszewski <[email protected]>Cc Abhay Salunke <[email protected]>Signed-off-by Luis R. Rodriguez <[email protected]>--- Documentation/driver-api/firmware/fallback-mechanisms.rst | 7 +++++-- drivers/firmware/dell_rbu.c | 1 + drivers/leds/leds-lp55xx-common.c | 1 + include/linux/firmware.h | 7 +++++++ scripts/coccinelle/api/request_firmware-custom-fallback.cocci | 9 ++++++++- 5 files changed, 22 insertions(+), 3 deletions(-)Documentation/driver-api/firmware/fallback-mechanisms.rst +0
-0
Documentation/driver-api/firmware/fallback-mechanisms.rst load firmware for you through a custom path. · line 191
Quoted 10 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst +5
-2@@ -184,8 +184,11 @@ load firmware for you through a custom path. The custom fallback mechanism can often be enabled by mistake. We currently have only 2 users of it, and little justification to enable it for other users. -Since it is a common driver developer mistake to enable it, help police for -new users of the custom fallback mechanism with:: +Since it is a common driver developer mistake to enable it, driver developers +should use DECLARE_FW_CUSTOM_FALLBACK() to both white-list and validate their +use and also refer to the documentation for the custom loading solution. + +Invalid users of the custom fallback mechanism can be policed using::
double colon at the end of line
Quoted 20 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst +0
-0$ export COCCI=scripts/coccinelle/api/request_firmware-avoid-init-probe-init.cocci $ make coccicheck MODE=reportdrivers/firmware/dell_rbu.c +1
-0@@ -586,6 +586,7 @@ static ssize_t read_rbu_image_type(struct file *filp, struct kobject *kobj,return size; } +DECLARE_FW_CUSTOM_FALLBACK ("Documentation/dell_rbu.txt" );static ssize_t write_rbu_image_type (struct file *filp,struct kobject *kobj,struct bin_attribute *bin_attr,char *buffer,loff_t pos,size_t count)drivers/leds/leds-lp55xx-common.c +0
-0
drivers/leds/leds-lp55xx-common.c static void lp55xx_firmware_loaded(const struct firmware *fw, void *context) · line 224
Quoted 6 lines
drivers/leds/leds-lp55xx-common.c +1
-0@@ -219,6 +219,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)release_firmware (chip->fw); } +DECLARE_FW_CUSTOM_FALLBACK ("Documentation/leds/leds-lp55xx.txt" );static int lp55xx_request_firmware (struct lp55xx_chip *chip) {
For this LED class driver:
Quoted 47 lines
drivers/leds/leds-lp55xx-common.c +0
-0const char *name = chip->cl->name;include/linux/firmware.h +7
-0@@ -8,6 +8,13 @@#define FW_ACTION_NOHOTPLUG 0#define FW_ACTION_HOTPLUG 1 +/* +* Helper for scripts/coccinelle/api/request_firmware-custom-fallback.cocci +* and so users can also easily search for the documentation for the +* respectively needed custom fallback mechanism. +*/ +#define DECLARE_FW_CUSTOM_FALLBACK (__usermode_helper) +struct firmware {size_t size;const u8 *data;scripts/coccinelle/api/request_firmware-custom-fallback.cocci +8
-1@@ -17,6 +17,13 @@ virtual report virtual context +@ r0 depends on report || context @ +declarer name DECLARE_FW_CUSTOM_FALLBACK; +expression E; +@@ + +DECLARE_FW_CUSTOM_FALLBACK(E); + @ r1 depends on report || context @ expression mod, name, dev, gfp, drv, cb; position p;@@ -30,7 +37,7 @@ position p; *request_firmware_nowait@p(mod, FW_ACTION_NOHOTPLUG, name, dev, gfp, drv, cb) ) -@script:python depends on report@ +@script:python depends on report && !r0 @ p << r1.p; @@
Signature · 2 lines
Best regards, Jacek Anaszewski
Luis R. Rodriguez
maintainerRe: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation
Quoted 6 lines · Jacek Anaszewski
Quoted 6 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst +0
-0@@ -184,8 +184,11 @@ load firmware for you through a custom path.
Quoted 11 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst load firmware for you through a custom path. · line 191
Quoted 9 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst +5
-2The custom fallback mechanism can often be enabled by mistake. We currently have only 2 users of it, and little justification to enable it for other users. -Since it is a common driver developer mistake to enable it, help police for -new users of the custom fallback mechanism with:: +Since it is a common driver developer mistake to enable it, driver developers +should use DECLARE_FW_CUSTOM_FALLBACK() to both white-list and validate their +use and also refer to the documentation for the custom loading solution. + +Invalid users of the custom fallback mechanism can be policed using::double colon at the end of line
That is on purpose for rst files, for use with the new trendy hipster Sphinx documentation format.
Quoted 3 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst load firmware for you through a custom path. · line 194
Quoted 3 lines
Documentation/driver-api/firmware/fallback-mechanisms.rst +0
-0$ export COCCI=scripts/coccinelle/api/request_firmware-avoid-init-probe-init.cocci $ make coccicheck MODE=report
It will kind of blockquote the above.
Quoted 8 lines
Quoted 8 lines
drivers/leds/leds-lp55xx-common.c +0
-0@@ -219,6 +219,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)release_firmware (chip->fw); }
Quoted 7 lines
drivers/leds/leds-lp55xx-common.c static void lp55xx_firmware_loaded(const struct firmware *fw, void *context) · line 224
Quoted 3 lines
drivers/leds/leds-lp55xx-common.c +1
-0+DECLARE_FW_CUSTOM_FALLBACK ("Documentation/leds/leds-lp55xx.txt" );static int lp55xx_request_firmware (struct lp55xx_chip *chip) {For this LED class driver:
Acked-by Jacek Anaszewski <[email protected]>
Thanks, amended!
Luis
Hi Luis,
Quoted 5 lines · Luis R. Rodriguez
You may notice I've dropped the SmPL patches which complain on use of the API on init and probe -- although valid the context was off given the only valid use case was if you don't use initramfs, and that's a corner case. Fortunatley Daniel Wagner and Tom Gundersen have come up with some ideas that should help correct these issues, so I've dropped that grammar patch.
My BMW email address will soon be shutdown. I guess best to use my private instead: [email protected]
cheers,
daniel