firmware loader: inform direct failure when udev loader is disabled
Subsystems (2)
PATCH v2 1/1 firmware loader: inform direct failure when udev loader is disabled
From: "Luis R. Rodriguez" <[email protected]>
Now that the udev firmware loader is optional request_firmware() will not provide any information on the kernel ring buffer if direct firmware loading failed and udev firmware loading is disabled. If no information is needed request_firmware_direct() should be used for optional firmware, at which point drivers can take on the onus over informing of any failures, if udev firmware loading is disabled though we should at the very least provide some sort of information as when the udev loader was enabled by default back in the days.
With this change with a simple firmware load test module [0]:
Example output without FW_LOADER_USER_HELPER_FALLBACK
platform fake-dev.0: Direct firmware load for fake.bin failed with error -2
Example with FW_LOADER_USER_HELPER_FALLBACK
platform fake-dev.0: Direct firmware load for fake.bin failed with error -2 platform fake-dev.0: Falling back to user helper
Without this change without FW_LOADER_USER_HELPER_FALLBACK we get no output logged upon failure.
---
This v2 modifies the error to always be called and only in the request_firmware_direct case do we not send smoke signals.
drivers/base/firmware_class.c | 13 +++++++------ include/linux/firmware.h | 15 ++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-)
drivers/base/firmware_class.c +7 -6
@@ -109,6 +109,7 @@ static inline long firmware_loading_timeout(void)#else #define FW_OPT_FALLBACK 0#endif +#define FW_OPT_DIRECT_ONLY (1U << 3)struct firmware_cache {/* firmware_buf instance will be added into the below list */
@@ -1116,10 +1117,11 @@ _request_firmware(const struct firmware **firmware_p, const char *name, ret =fw_get_filesystem_firmware (device, fw->priv);if (ret) { -if (opt_flags &FW_OPT_USERHELPER ) { +if (!(opt_flags &FW_OPT_DIRECT_ONLY ))dev_warn (device, -"Direct firmware load failed with error %d\n" , - ret); +"Direct firmware load for %s failed with error %d\n" , + name, ret); +if (opt_flags &FW_OPT_USERHELPER ) {dev_warn (device,"Falling back to user helper\n" ); ret =fw_load_from_user_helper (fw, name, device, opt_flags, timeout);
@@ -1176,7 +1178,6 @@ request_firmware(const struct firmware **firmware_p, const char *name, }EXPORT_SYMBOL (request_firmware); -#ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK /** * request_firmware: - load firmware directly without usermode helper * @firmware_p: pointer to firmware image
@@ -1193,12 +1194,12 @@ int request_firmware_direct(const struct firmware **firmware_p, {int ret;__module_get (THIS_MODULE ); - ret =_request_firmware (firmware_p, name, device,FW_OPT_UEVENT ); + ret =_request_firmware (firmware_p, name, device, +FW_OPT_UEVENT |FW_OPT_DIRECT_ONLY );module_put (THIS_MODULE );return ret; }EXPORT_SYMBOL_GPL (request_firmware_direct); -#endif /** * release_firmware: - release the resource associated with a firmware image
include/linux/firmware.h +8 -7
@@ -45,6 +45,8 @@ int request_firmware_nowait( struct module *module, bool uevent, const char *name, struct device *device, gfp_t gfp, void *context, void (*cont)(const struct firmware *fw, void *context)); +int request_firmware_direct (const struct firmware **fw,const char *name, +struct device *device);void release_firmware (const struct firmware *fw);#else
@@ -66,13 +68,12 @@ static inline void release_firmware(const struct firmware *fw) { } -#endif +static inline int request_firmware_direct (const struct firmware **fw, +const char *name, +struct device *device) +{ +return -EINVAL ; +} -#ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK -int request_firmware_direct (const struct firmware **fw,const char *name, -struct device *device); -#else -#define request_firmware_direct request_firmware#endif -#endif
Signature · 1 line
2.0.0
Quoted 26 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
Now that the udev firmware loader is optional
request_firmware()will not provide any information on the kernel ring buffer if direct firmware loading failed and udev firmware loading is disabled. If no information is neededrequest_firmware_direct()should be used for optional firmware, at which point drivers can take on the onus over informing of any failures, if udev firmware loading is disabled though we should at the very least provide some sort of information as when the udev loader was enabled by default back in the days.With this change with a simple firmware load test module [0]:
Example output without
FW_LOADER_USER_HELPER_FALLBACKplatform fake-dev.0: Direct firmware load for fake.bin failed with error -2
Example with
FW_LOADER_USER_HELPER_FALLBACKplatform fake-dev.0: Direct firmware load for fake.bin failed with error -2 platform fake-dev.0: Falling back to user helper
Without this change without
FW_LOADER_USER_HELPER_FALLBACKwe get no output logged upon failure.
Quoted 9 lines
Cc Tom Gundersen <[email protected]>Cc Ming Lei <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Abhay Salunke <[email protected]>Cc Stefan Roese <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Kay Sievers <[email protected]>Cc Takashi Iwai <[email protected]>Signed-off-by Luis R. Rodriguez <[email protected]>
Looks fine, also it is a cleanup.
Thanks,
--
Ming Lei
At Tue, 1 Jul 2014 20:07:53 -0700,
Quoted 50 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
Now that the udev firmware loader is optional
request_firmware()will not provide any information on the kernel ring buffer if direct firmware loading failed and udev firmware loading is disabled. If no information is neededrequest_firmware_direct()should be used for optional firmware, at which point drivers can take on the onus over informing of any failures, if udev firmware loading is disabled though we should at the very least provide some sort of information as when the udev loader was enabled by default back in the days.With this change with a simple firmware load test module [0]:
Example output without
FW_LOADER_USER_HELPER_FALLBACKplatform fake-dev.0: Direct firmware load for fake.bin failed with error -2
Example with
FW_LOADER_USER_HELPER_FALLBACKplatform fake-dev.0: Direct firmware load for fake.bin failed with error -2 platform fake-dev.0: Falling back to user helper
Without this change without
FW_LOADER_USER_HELPER_FALLBACKwe get no output logged upon failure.Cc Tom Gundersen <[email protected]>Cc Ming Lei <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Abhay Salunke <[email protected]>Cc Stefan Roese <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Kay Sievers <[email protected]>Cc Takashi Iwai <[email protected]>Signed-off-by Luis R. Rodriguez <[email protected]>---
This v2 modifies the error to always be called and only in the
request_firmware_directcase do we not send smoke signals.drivers/base/firmware_class.c | 13 +++++++------ include/linux/firmware.h | 15 ++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-)drivers/base/firmware_class.c +0
-0
drivers/base/firmware_class.c static inline long firmware_loading_timeout(void) · line 112
Quoted 4 lines
drivers/base/firmware_class.c +1
-0@@ -109,6 +109,7 @@ static inline long firmware_loading_timeout(void)#else #define FW_OPT_FALLBACK 0#endif +#define FW_OPT_DIRECT_ONLY (1U << 3)
I'd name it like FW_OPT_NO_WARN or such.
Other than that, looks good to me.
thanks,
Takashi
Quoted 77 lines
drivers/base/firmware_class.c +6
-6struct firmware_cache {/* firmware_buf instance will be added into the below list */ @@ -1116,10 +1117,11 @@ _request_firmware(const struct firmware **firmware_p, const char *name, ret =fw_get_filesystem_firmware (device, fw->priv);if (ret) { -if (opt_flags &FW_OPT_USERHELPER ) { +if (!(opt_flags &FW_OPT_DIRECT_ONLY ))dev_warn (device, -"Direct firmware load failed with error %d\n" , - ret); +"Direct firmware load for %s failed with error %d\n" , + name, ret); +if (opt_flags &FW_OPT_USERHELPER ) {dev_warn (device,"Falling back to user helper\n" ); ret =fw_load_from_user_helper (fw, name, device, opt_flags, timeout);@@ -1176,7 +1178,6 @@ request_firmware(const struct firmware **firmware_p, const char *name, }EXPORT_SYMBOL (request_firmware); -#ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK /** * request_firmware: - load firmware directly without usermode helper * @firmware_p: pointer to firmware image @@ -1193,12 +1194,12 @@ int request_firmware_direct(const struct firmware **firmware_p, {int ret;__module_get (THIS_MODULE ); - ret =_request_firmware (firmware_p, name, device,FW_OPT_UEVENT ); + ret =_request_firmware (firmware_p, name, device, +FW_OPT_UEVENT |FW_OPT_DIRECT_ONLY );module_put (THIS_MODULE );return ret; }EXPORT_SYMBOL_GPL (request_firmware_direct); -#endif /** * release_firmware: - release the resource associated with a firmware image include/linux/firmware.h +8
-7@@ -45,6 +45,8 @@ int request_firmware_nowait( struct module *module, bool uevent, const char *name, struct device *device, gfp_t gfp, void *context, void (*cont)(const struct firmware *fw, void *context)); +int request_firmware_direct (const struct firmware **fw,const char *name, +struct device *device);void release_firmware (const struct firmware *fw);#else @@ -66,13 +68,12 @@ static inline void release_firmware(const struct firmware *fw) { } -#endif +static inline int request_firmware_direct (const struct firmware **fw, +const char *name, +struct device *device) +{ +return -EINVAL ; +} -#ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK -int request_firmware_direct (const struct firmware **fw,const char *name, -struct device *device); -#else -#define request_firmware_direct request_firmware#endif -#endif Signature · 1 line
2.0.0
Quoted 47 lines · Takashi Iwai
At Tue, 1 Jul 2014 20:07:53 -0700,
Quoted 45 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
Now that the udev firmware loader is optional
request_firmware()will not provide any information on the kernel ring buffer if direct firmware loading failed and udev firmware loading is disabled. If no information is neededrequest_firmware_direct()should be used for optional firmware, at which point drivers can take on the onus over informing of any failures, if udev firmware loading is disabled though we should at the very least provide some sort of information as when the udev loader was enabled by default back in the days.With this change with a simple firmware load test module [0]:
Example output without
FW_LOADER_USER_HELPER_FALLBACKplatform fake-dev.0: Direct firmware load for fake.bin failed with error -2
Example with
FW_LOADER_USER_HELPER_FALLBACKplatform fake-dev.0: Direct firmware load for fake.bin failed with error -2 platform fake-dev.0: Falling back to user helper
Without this change without
FW_LOADER_USER_HELPER_FALLBACKwe get no output logged upon failure.Cc Tom Gundersen <[email protected]>Cc Ming Lei <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Abhay Salunke <[email protected]>Cc Stefan Roese <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Kay Sievers <[email protected]>Cc Takashi Iwai <[email protected]>Signed-off-by Luis R. Rodriguez <[email protected]>---
This v2 modifies the error to always be called and only in the
request_firmware_directcase do we not send smoke signals.drivers/base/firmware_class.c | 13 +++++++------ include/linux/firmware.h | 15 ++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-)
Quoted 12 lines
drivers/base/firmware_class.c static inline long firmware_loading_timeout(void) · line 112
Quoted 9 lines
drivers/base/firmware_class.c +1
-0@@ -109,6 +109,7 @@ static inline long firmware_loading_timeout(void)#else #define FW_OPT_FALLBACK 0#endif +#define FW_OPT_DIRECT_ONLY (1U << 3)I'd name it like
FW_OPT_NO_WARNor such.
Other than that, looks good to me.
IMO, DIRECT_ONLY is better because it can be
extend to other usages in future.
Thanks,
--
Ming Lei
At Wed, 2 Jul 2014 19:21:07 +0800,
Quoted 62 lines · Ming Lei
Quoted 47 lines · Takashi Iwai
At Tue, 1 Jul 2014 20:07:53 -0700,
Quoted 45 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
Now that the udev firmware loader is optional
request_firmware()will not provide any information on the kernel ring buffer if direct firmware loading failed and udev firmware loading is disabled. If no information is neededrequest_firmware_direct()should be used for optional firmware, at which point drivers can take on the onus over informing of any failures, if udev firmware loading is disabled though we should at the very least provide some sort of information as when the udev loader was enabled by default back in the days.With this change with a simple firmware load test module [0]:
Example output without
FW_LOADER_USER_HELPER_FALLBACKplatform fake-dev.0: Direct firmware load for fake.bin failed with error -2
Example with
FW_LOADER_USER_HELPER_FALLBACKplatform fake-dev.0: Direct firmware load for fake.bin failed with error -2 platform fake-dev.0: Falling back to user helper
Without this change without
FW_LOADER_USER_HELPER_FALLBACKwe get no output logged upon failure.Cc Tom Gundersen <[email protected]>Cc Ming Lei <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Abhay Salunke <[email protected]>Cc Stefan Roese <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Kay Sievers <[email protected]>Cc Takashi Iwai <[email protected]>Signed-off-by Luis R. Rodriguez <[email protected]>---
This v2 modifies the error to always be called and only in the
request_firmware_directcase do we not send smoke signals.drivers/base/firmware_class.c | 13 +++++++------ include/linux/firmware.h | 15 ++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-)Quoted 12 lines
drivers/base/firmware_class.c static inline long firmware_loading_timeout(void) · line 112
Quoted 9 lines
drivers/base/firmware_class.c +1
-0@@ -109,6 +109,7 @@ static inline long firmware_loading_timeout(void)#else #define FW_OPT_FALLBACK 0#endif +#define FW_OPT_DIRECT_ONLY (1U << 3)I'd name it like
FW_OPT_NO_WARNor such.
Other than that, looks good to me.
Quoted 2 lines
IMO,
DIRECT_ONLYis better because it can be
extend to other usages in future.
Well, do we need any more extension to this function? I thought we're going rather to remove *_direct().
If we need any more extension, a better way would be to expose the bit flag directly as __request_firmware() instead of hacking more on *_direct() or introduce more variants. Then the existing request_firmware() and request_firmware_direct() can be static inline.
In anyway, the flag should indicate each functionality, and if the current purpose is to suppress warning, it should be named so.
Takashi