Skip to content

firmware: cleanup for v4.16

Luis R. Rodriguez linux-fsdevel lkml 1 version Applied

Status from this message: I've applied the patches up to here in this series.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest23 patches 11 repliesApplied

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/23firmware: rename struct firmware_priv to struct fw_sysfsdrivers/base/firmware_class.c+49 -490 replies
2/23firmware: rename struct firmware_buf to struct fw_privdrivers/base/firmware_class.c+187 -1850 replies
3/23firmware: rename struct fw_priv->fw_id to fw_namedrivers/base/firmware_class.c+13 -130 replies
4/23firmware: move core data structures to the top of filedrivers/base/firmware_class.c+95 -950 replies
5/23firmware: remove duplicate fw_state_aborted()drivers/base/firmware_class.c+0 -20 replies
6/23firmware: remove unused __fw_state_is_done()drivers/base/firmware_class.c+0 -50 replies
7/23firmware: use static inlines for state machine checkingdrivers/base/firmware_class.c+68 -390 replies
8/23firmware: rename sysfs state checks with sysfs prefixdrivers/base/firmware_class.c+10 -100 replies
9/23firmware: use static inline for to_fw_priv()drivers/base/firmware_class.c+4 -11 reply
10/23firmware: add helper to copy built-in data to pre-alloc bufferdrivers/base/firmware_class.c+9 -22 replies
11/23firmware: provide helper for FW_OPT_USERHELPERdrivers/base/firmware_class.c+18 -130 replies
12/23firmware: replace #ifdef over FW_OPT_FALLBACK with function checksdrivers/base/firmware_class.c+29 -110 replies
13/23test_firmware: wrap sysfs timeout test into helpertools/testing/selftests/firmware/fw_fallback.sh+37 -320 replies
14/23test_firmware: wrap basic sysfs fallback tests into helpertools/testing/selftests/firmware/fw_fallback.sh+41 -370 replies
15/23test_firmware: wrap custom sysfs load tests into helpertools/testing/selftests/firmware/fw_fallback.sh+28 -150 replies
16/23test_firmware: enable custom fallback testing on limited kernel configstools/testing/selftests/firmware/config tools/testing/selftests/firmware/fw_fallback.sh+48 -15 replies
17/23test_firmware: replace syfs fallback check with kconfig_has helpertools/testing/selftests/firmware/fw_fallback.sh+1 -40 replies
18/23firmware: enable to split firmware_class into separate target filesdrivers/base/Makefile drivers/base/firmware_loader.c+1 -00 replies
19/23firmware: add debug facility to emulate forcing sysfs fallbackdrivers/base/Kconfig drivers/base/Makefile drivers/base/firmware_debug.c +2 more+97 -13 replies
20/23firmware: add debug facility to emulate disabling sysfs fallbackdrivers/base/firmware_debug.c drivers/base/firmware_debug.h drivers/base/firmware_loader.c+24 -00 replies
21/23test_firmware: add a library for shared helperstools/testing/selftests/firmware/fw_fallback.sh tools/testing/selftests/firmware/fw_filesystem.sh tools/testing/selftests/firmware/fw_lib.sh+137 -1130 replies
22/23test_firmware: test the 3 firmware kernel configs using debugfstools/testing/selftests/firmware/Makefile tools/testing/selftests/firmware/config tools/testing/selftests/firmware/fw_lib.sh +1 more+123 -10 replies
23/23firmware: cleanup - group and document up private firmware parametersdrivers/base/firmware_loader.c+218 -820 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 00/23] firmware: cleanup for v4.16

Here's a series of cleanups for the firmware loader for consideration for v4.16, *after* the traditional yearly American turkey massacre. This depends on the few fixes I just posted for consideration for v4.15 [0].

While discussing the cleanup patch I posted last for the firmware API [1], Greg suggested making the new data structure we use an opaque pointer so we can avoid modifying so many call sites needing the new parameter. This was a good suggestion, but we already have our own private opaque data structure, it was just used for storing a few variables. We also have our own fw_priv data structure, its however a complete misnomer given it actually is only used now for the old sysfs firmware loading facility.

The naming mishap happened given the sysfs loader was the default loader back in the hay day. This is no longer the case, we always directly load firmware from the filesystem first, and only rely on the sysfs loader mechanism as a fallback, if its enabled.

So we rename the old fw_priv to reflect its for sysfs only, and re-use the name now for our existing opaque private data structure, which we'll extend for the original proposed cleanup.

IMHO this ends up tidying up the code even more and makes the code *much* easier to read.

While doing this work I also realized how with a small amount of work we could end up testing the 3 different functional kernel builds possible for the firmware loader with *one* kernel build with a few debugfs knobs. This adds this as well and also paves the way to enable us to later split the sysfs firmware loader onto its own file.

Worth discussing is how the debugfs knobs also reveal how two kernel build configs could potentially just later end up as module params, if we're happy to to live with implicating the fallback mechanism always when the firmware loader is enabled. This would simplfy the kernel build considerably. I'm not aware of anyone disabling the syfs fallback mechanism completely, given its only a fallback mechanism now and we have a way to avoid it completely as well for sync calls, so this very well may be worth a direction worth evaluating forward

0-day has been happy with this. I've also hammered testing the API on the 3 different kernel builds possible, no regressions were found, and also addressed ensuring that the selftests still works on older kernels as expected. On older kernels we run the typical test of two scripts as usual, using whatever whatever defaults your kernel provides and doing our best with that.

Comments and questions are, as always, welcome.

[0] https://lkml.kernel.org/r/[email protected]
[1] https://lkml.kernel.org/r/[email protected]

Luis R. Rodriguez (23):
firmware: rename struct firmware_priv to struct fw_sysfs
firmware: rename struct firmware_buf to struct fw_priv
firmware: rename struct fw_priv->fw_id to fw_name
firmware: move core data structures to the top of file
firmware: remove duplicate fw_state_aborted()
firmware: remove unused __fw_state_is_done()
firmware: use static inlines for state machine checking
firmware: rename sysfs state checks with sysfs prefix
firmware: use static inline for to_fw_priv()
firmware: add helper to copy built-in data to pre-alloc buffer
firmware: provide helper for FW_OPT_USERHELPER
firmware: replace #ifdef over FW_OPT_FALLBACK with function checks
test_firmware: wrap sysfs timeout test into helper
test_firmware: wrap basic sysfs fallback tests into helper
test_firmware: wrap custom sysfs load tests into helper
test_firmware: enable custom fallback testing on limited kernel
configs
test_firmware: replace syfs fallback check with kconfig_has helper
firmware: enable to split firmware_class into separate target files
firmware: add debug facility to emulate forcing sysfs fallback
firmware: add debug facility to emulate disabling sysfs fallback
test_firmware: add a library for shared helpers
test_firmware: test the 3 firmware kernel configs using debugfs
firmware: cleanup - group and document up private firmware parameters

 drivers/base/Kconfig                               |   6 +
 drivers/base/Makefile                              |   2 +
 drivers/base/firmware_debug.c                      |  39 +
 drivers/base/firmware_debug.h                      |  58 ++
 .../base/{firmware_class.c => firmware_loader.c}   | 981 +++++++++++++--------
 tools/testing/selftests/firmware/Makefile          |   2 +-
 tools/testing/selftests/firmware/config            |   5 +
 tools/testing/selftests/firmware/fw_fallback.sh    | 207 +++--
 tools/testing/selftests/firmware/fw_filesystem.sh  |  61 +-
 tools/testing/selftests/firmware/fw_lib.sh         | 174 ++++
 tools/testing/selftests/firmware/fw_run_tests.sh   |  67 ++
 11 files changed, 1064 insertions(+), 538 deletions(-)
 create mode 100644 drivers/base/firmware_debug.c
 create mode 100644 drivers/base/firmware_debug.h
 rename drivers/base/{firmware_class.c => firmware_loader.c} (64%)
 create mode 100755 tools/testing/selftests/firmware/fw_lib.sh
 create mode 100755 tools/testing/selftests/firmware/fw_run_tests.sh
Signature · 1 line
2.15.0