Skip to content

Commit 2cd7a1c

Browse files
mcgrofgregkh
authored andcommitted
firmware: enable to force disable the fallback mechanism at run time
You currently need four different kernel builds to test the firmware API fully. By adding a proc knob to force disable the fallback mechanism completely we are able to reduce the amount of kernels you need built to test the firmware API down to two. Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ceb1813 commit 2cd7a1c

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎drivers/base/firmware_loader/fallback.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,11 @@ static bool fw_force_sysfs_fallback(unsigned int opt_flags)
643643

644644
static bool fw_run_sysfs_fallback(unsigned int opt_flags)
645645
{
646+
if (fw_fallback_config.ignore_sysfs_fallback) {
647+
pr_info_once("Ignoring firmware sysfs fallback due to debugfs knob\n");
648+
return false;
649+
}
650+
646651
if ((opt_flags & FW_OPT_NOFALLBACK))
647652
return false;
648653

‎drivers/base/firmware_loader/fallback.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@
1414
* as if one had enabled CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y.
1515
* Useful to help debug a CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
1616
* functionality on a kernel where that config entry has been disabled.
17+
* @ignore_sysfs_fallback: force to disable the sysfs fallback mechanism.
18+
* This emulates the behaviour as if we had set the kernel
19+
* config CONFIG_FW_LOADER_USER_HELPER=n.
1720
* @old_timeout: for internal use
1821
* @loading_timeout: the timeout to wait for the fallback mechanism before
1922
* giving up, in seconds.
2023
*/
2124
struct firmware_fallback_config {
2225
unsigned int force_sysfs_fallback;
26+
unsigned int ignore_sysfs_fallback;
2327
int old_timeout;
2428
int loading_timeout;
2529
};

‎drivers/base/firmware_loader/fallback_table.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ struct ctl_table firmware_config_table[] = {
3939
.extra1 = &zero,
4040
.extra2 = &one,
4141
},
42+
{
43+
.procname = "ignore_sysfs_fallback",
44+
.data = &fw_fallback_config.ignore_sysfs_fallback,
45+
.maxlen = sizeof(unsigned int),
46+
.mode = 0644,
47+
.proc_handler = proc_douintvec_minmax,
48+
.extra1 = &zero,
49+
.extra2 = &one,
50+
},
4251
{ }
4352
};
4453
EXPORT_SYMBOL_GPL(firmware_config_table);

0 commit comments

Comments
 (0)