[PATCH v2 20/23] firmware: add debug facility to emulate disabling sysfs fallback
From: Luis R. Rodriguez
Date: Mon Nov 20 2017 - 13:24:41 EST
One can build a kernel without CONFIG_FW_LOADER_USER_HELPER being
enabled, but testing it requires a unique kernel configuration most
folks do not enable. This makes it hard to test.
Provide a debugfs facility to enable us to emulate such kernels.
Signed-off-by: Luis R. Rodriguez <mcgrof@xxxxxxxxxx>
---
drivers/base/firmware_debug.c | 5 +++++
drivers/base/firmware_debug.h | 14 ++++++++++++++
drivers/base/firmware_loader.c | 5 +++++
3 files changed, 24 insertions(+)
diff --git a/drivers/base/firmware_debug.c b/drivers/base/firmware_debug.c
index f2817eb6f480..9332f0acfa8f 100644
--- a/drivers/base/firmware_debug.c
+++ b/drivers/base/firmware_debug.c
@@ -20,6 +20,11 @@ int __init register_fw_debugfs(void)
&fw_debug.force_sysfs_fallback))
goto err_out;
+ if (!debugfs_create_bool("ignore_sysfs_fallback", S_IRUSR | S_IWUSR,
+ debugfs_firmware,
+ &fw_debug.ignore_sysfs_fallback))
+ goto err_out;
+
return 0;
err_out:
debugfs_remove_recursive(debugfs_firmware);
diff --git a/drivers/base/firmware_debug.h b/drivers/base/firmware_debug.h
index bc41bbca9a54..5f551d8b9003 100644
--- a/drivers/base/firmware_debug.h
+++ b/drivers/base/firmware_debug.h
@@ -12,9 +12,13 @@
* as if one had enabled CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y.
* Useful to help debug a CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
* functionality on a kernel where that config entry has been disabled.
+ * @ignore_sysfs_fallback: force to disable the sysfs fallback mechanism.
+ * This emulates the behaviour as if we had set the kernel
+ * config CONFIG_FW_LOADER_USER_HELPER=n.
*/
struct firmware_debug {
bool force_sysfs_fallback;
+ bool ignore_sysfs_fallback;
};
extern struct firmware_debug fw_debug;
@@ -26,6 +30,11 @@ static inline bool fw_debug_force_sysfs_fallback(void)
{
return fw_debug.force_sysfs_fallback;
}
+
+static inline bool fw_debug_ignore_sysfs_fallback(void)
+{
+ return fw_debug.ignore_sysfs_fallback;
+}
#else
static inline int register_fw_debugfs(void)
{
@@ -39,6 +48,11 @@ static inline bool fw_debug_force_sysfs_fallback(void)
{
return false;
}
+
+static inline bool fw_debug_ignore_sysfs_fallback(void)
+{
+ return false;
+}
#endif /* CONFIG_FW_LOADER_DEBUG */
#endif /* __FIRMWARE_DEBUG_H */
diff --git a/drivers/base/firmware_loader.c b/drivers/base/firmware_loader.c
index b2b52ba9f245..6c44ede98be0 100644
--- a/drivers/base/firmware_loader.c
+++ b/drivers/base/firmware_loader.c
@@ -1170,6 +1170,11 @@ static bool fw_force_sysfs_fallback(unsigned int opt_flags)
static bool fw_run_sysfs_fallback(unsigned int opt_flags)
{
+ if (fw_debug_ignore_sysfs_fallback()) {
+ pr_info("Ignoring firmware sysfs fallback due to debugfs knob\n");
+ return false;
+ }
+
if ((opt_flags & FW_OPT_NOFALLBACK))
return false;
--
2.15.0