From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752392AbdKTSYh (ORCPT ); Mon, 20 Nov 2017 13:24:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:57766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752342AbdKTSYe (ORCPT ); Mon, 20 Nov 2017 13:24:34 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 63B65219AA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mcgrof@kernel.org From: "Luis R. Rodriguez" To: gregkh@linuxfoundation.org Cc: akpm@linux-foundation.org, keescook@chromium.org, mfuzzey@parkeon.com, zohar@linux.vnet.ibm.com, dhowells@redhat.com, pali.rohar@gmail.com, tiwai@suse.de, arend.vanspriel@broadcom.com, zajec5@gmail.com, nbroeking@me.com, markivx@codeaurora.org, stephen.boyd@linaro.org, broonie@kernel.org, dmitry.torokhov@gmail.com, dwmw2@infradead.org, torvalds@linux-foundation.org, Abhay_Salunke@dell.com, bjorn.andersson@linaro.org, jewalt@lgsinnovations.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, "Luis R. Rodriguez" Subject: [PATCH v2 20/23] firmware: add debug facility to emulate disabling sysfs fallback Date: Mon, 20 Nov 2017 10:24:06 -0800 Message-Id: <20171120182409.27348-21-mcgrof@kernel.org> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20171120182409.27348-1-mcgrof@kernel.org> References: <20171120182409.27348-1-mcgrof@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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