From patchwork Mon Nov 20 18:24:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 10066895 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D61F86038F for ; Mon, 20 Nov 2017 18:25:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD65D2913A for ; Mon, 20 Nov 2017 18:25:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C21112937A; Mon, 20 Nov 2017 18:25:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 729452913A for ; Mon, 20 Nov 2017 18:25:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752366AbdKTSYg (ORCPT ); Mon, 20 Nov 2017 13:24:36 -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 Received: from garbanzo.do-not-panic.com (c-73-15-241-2.hsd1.ca.comcast.net [73.15.241.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 63B65219AA; Mon, 20 Nov 2017 18:24:33 +0000 (UTC) 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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;