Commit 5a1379e8 authored by Takashi Iwai's avatar Takashi Iwai Committed by Greg Kroah-Hartman

firmware loader: allow disabling of udev as firmware loader

[The patch was originally proposed by Tom Gundersen, and rewritten
 afterwards by me; most of changelogs below borrowed from Tom's
 original patch -- tiwai]

Currently (at least) the dell-rbu driver selects FW_LOADER_USER_HELPER,
which means that distros can't really stop loading firmware through
udev without breaking other users (though some have).

Ideally we would remove/disable the udev firmware helper in both the
kernel and in udev, but if we were to disable it in udev and not the
kernel, the result would be (seemingly) hung kernels as no one would
be around to cancel firmware requests.

This patch allows udev firmware loading to be disabled while still
allowing non-udev firmware loading, as done by the dell-rbu driver, to
continue working. This is achieved by only using the fallback
mechanism when the uevent is suppressed.

The patch renames the user-selectable Kconfig from FW_LOADER_USER_HELPER
to FW_LOADER_USER_HELPER_FALLBACK, and the former is reverse-selected
by the latter or the drivers that need userhelper like dell-rbu.

Also, the "default y" is removed together with this change, since it's
been deprecated in udev upstream, thus rather better to disable it
nowadays.

Tested with
    FW_LOADER_USER_HELPER=n
    LATTICE_ECP3_CONFIG=y
    DELL_RBU=y
and udev without the firmware loading support, but I don't have the
hardware to test the lattice/dell drivers, so additional testing would
be appreciated.
Reviewed-by: default avatarTom Gundersen <teg@jklm.no>
Cc: Ming Lei <ming.lei@canonical.com>
Cc: Abhay Salunke <Abhay_Salunke@dell.com>
Cc: Stefan Roese <sr@denx.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Kay Sievers <kay@vrfy.org>
Tested-by: default avatarBalaji Singh <B_B_Singh@DELL.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3c3b177a
...@@ -149,15 +149,21 @@ config EXTRA_FIRMWARE_DIR ...@@ -149,15 +149,21 @@ config EXTRA_FIRMWARE_DIR
some other directory containing the firmware files. some other directory containing the firmware files.
config FW_LOADER_USER_HELPER config FW_LOADER_USER_HELPER
bool
config FW_LOADER_USER_HELPER_FALLBACK
bool "Fallback user-helper invocation for firmware loading" bool "Fallback user-helper invocation for firmware loading"
depends on FW_LOADER depends on FW_LOADER
default y select FW_LOADER_USER_HELPER
help help
This option enables / disables the invocation of user-helper This option enables / disables the invocation of user-helper
(e.g. udev) for loading firmware files as a fallback after the (e.g. udev) for loading firmware files as a fallback after the
direct file loading in kernel fails. The user-mode helper is direct file loading in kernel fails. The user-mode helper is
no longer required unless you have a special firmware file that no longer required unless you have a special firmware file that
resides in a non-standard path. resides in a non-standard path. Moreover, the udev support has
been deprecated upstream.
If you are unsure about this, say N here.
config DEBUG_DRIVER config DEBUG_DRIVER
bool "Driver Core verbose debug messages" bool "Driver Core verbose debug messages"
......
...@@ -100,9 +100,14 @@ static inline long firmware_loading_timeout(void) ...@@ -100,9 +100,14 @@ static inline long firmware_loading_timeout(void)
#define FW_OPT_UEVENT (1U << 0) #define FW_OPT_UEVENT (1U << 0)
#define FW_OPT_NOWAIT (1U << 1) #define FW_OPT_NOWAIT (1U << 1)
#ifdef CONFIG_FW_LOADER_USER_HELPER #ifdef CONFIG_FW_LOADER_USER_HELPER
#define FW_OPT_FALLBACK (1U << 2) #define FW_OPT_USERHELPER (1U << 2)
#else #else
#define FW_OPT_FALLBACK 0 #define FW_OPT_USERHELPER 0
#endif
#ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
#define FW_OPT_FALLBACK FW_OPT_USERHELPER
#else
#define FW_OPT_FALLBACK 0
#endif #endif
struct firmware_cache { struct firmware_cache {
...@@ -1111,7 +1116,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name, ...@@ -1111,7 +1116,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
ret = fw_get_filesystem_firmware(device, fw->priv); ret = fw_get_filesystem_firmware(device, fw->priv);
if (ret) { if (ret) {
if (opt_flags & FW_OPT_FALLBACK) { if (opt_flags & FW_OPT_USERHELPER) {
dev_warn(device, dev_warn(device,
"Direct firmware load failed with error %d\n", "Direct firmware load failed with error %d\n",
ret); ret);
...@@ -1171,7 +1176,7 @@ request_firmware(const struct firmware **firmware_p, const char *name, ...@@ -1171,7 +1176,7 @@ request_firmware(const struct firmware **firmware_p, const char *name,
} }
EXPORT_SYMBOL(request_firmware); EXPORT_SYMBOL(request_firmware);
#ifdef CONFIG_FW_LOADER_USER_HELPER #ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
/** /**
* request_firmware: - load firmware directly without usermode helper * request_firmware: - load firmware directly without usermode helper
* @firmware_p: pointer to firmware image * @firmware_p: pointer to firmware image
...@@ -1277,7 +1282,7 @@ request_firmware_nowait( ...@@ -1277,7 +1282,7 @@ request_firmware_nowait(
fw_work->context = context; fw_work->context = context;
fw_work->cont = cont; fw_work->cont = cont;
fw_work->opt_flags = FW_OPT_NOWAIT | FW_OPT_FALLBACK | fw_work->opt_flags = FW_OPT_NOWAIT | FW_OPT_FALLBACK |
(uevent ? FW_OPT_UEVENT : 0); (uevent ? FW_OPT_UEVENT : FW_OPT_USERHELPER);
if (!try_module_get(module)) { if (!try_module_get(module)) {
kfree(fw_work); kfree(fw_work);
......
...@@ -68,7 +68,7 @@ static inline void release_firmware(const struct firmware *fw) ...@@ -68,7 +68,7 @@ static inline void release_firmware(const struct firmware *fw)
#endif #endif
#ifdef CONFIG_FW_LOADER_USER_HELPER #ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
int request_firmware_direct(const struct firmware **fw, const char *name, int request_firmware_direct(const struct firmware **fw, const char *name,
struct device *device); struct device *device);
#else #else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment