Skip to contentSkip to conversation

firmware loader: inform direct failure when udev loader is disabled

PATCH Superseded Luis R. Rodriguez 5 participants 7 messages Jun 30, 2014 – Jul 2, 2014

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 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 without 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.

[0] https://github.com/mcgrof/fake-firmware-test.git

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]>

---

 drivers/base/firmware_class.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/base/firmware_class.c +8 -4
index 46ea5f4..23274d8 100644
@@ -101,8 +101,10 @@ static inline long firmware_loading_timeout(void)
 #define FW_OPT_NOWAIT	(1U << 1)
 #ifdef CONFIG_FW_LOADER_USER_HELPER
 #define FW_OPT_USERHELPER	(1U << 2)
+#define FW_OPT_FAIL_WARN	0
 #else
 #define FW_OPT_USERHELPER	0
+#define FW_OPT_FAIL_WARN	(1U << 3)
 #endif
 #ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
 #define FW_OPT_FALLBACK		FW_OPT_USERHELPER
@@ -1116,10 +1118,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_FAIL_WARN | FW_OPT_USERHELPER))
 			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);
@@ -1170,7 +1173,8 @@ request_firmware(const struct firmware **firmware_p, const char *name,
 	/* Need to pin this module until return */
 	__module_get(THIS_MODULE);
 	ret = _request_firmware(firmware_p, name, device,
-				FW_OPT_UEVENT | FW_OPT_FALLBACK);
+				FW_OPT_UEVENT | FW_OPT_FALLBACK |
+				FW_OPT_FAIL_WARN);
 	module_put(THIS_MODULE);
 	return ret;
 }
Signature · 1 line
2.0.0
#1 lore raw
Quoted 57 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 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 without 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.

[0] https://github.com/mcgrof/fake-firmware-test.git

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]>

---

 drivers/base/firmware_class.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/base/firmware_class.c +2 -0
index 46ea5f4..23274d8 100644
@@ -101,8 +101,10 @@ static inline long firmware_loading_timeout(void)
 #define FW_OPT_NOWAIT  (1U << 1)
 #ifdef CONFIG_FW_LOADER_USER_HELPER
 #define FW_OPT_USERHELPER      (1U << 2)
+#define FW_OPT_FAIL_WARN       0
 #else
 #define FW_OPT_USERHELPER      0
+#define FW_OPT_FAIL_WARN       (1U << 3)
 #endif
 #ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
 #define FW_OPT_FALLBACK                FW_OPT_USERHELPER

drivers/base/firmware_class.c _request_firmware(const struct firmware **firmware_p, const char *name, · line 1124

Quoted 10 lines
drivers/base/firmware_class.c +3 -3
@@ -1116,10 +1118,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_FAIL_WARN | FW_OPT_USERHELPER))
                        dev_warn(device,
-                                "Direct firmware load failed with error %d\n",
-                                ret);
+                                "Direct firmware load for %s failed with error %d\n",
+                                name, ret);

Maybe the warning can be always printed out since
(FW_OPT_FAIL_WARN | FW_OPT_USERHELPER) should be
always true.

Thanks,
--
Ming Lei

#2 lore raw

At Tue, 1 Jul 2014 11:54:24 +0800,

Quoted 61 lines · Ming Lei
Quoted 58 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 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 without 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.

[0] https://github.com/mcgrof/fake-firmware-test.git

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]>

---

 drivers/base/firmware_class.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/base/firmware_class.c +2 -0
index 46ea5f4..23274d8 100644
@@ -101,8 +101,10 @@ static inline long firmware_loading_timeout(void)
 #define FW_OPT_NOWAIT  (1U << 1)
 #ifdef CONFIG_FW_LOADER_USER_HELPER
 #define FW_OPT_USERHELPER      (1U << 2)
+#define FW_OPT_FAIL_WARN       0
 #else
 #define FW_OPT_USERHELPER      0
+#define FW_OPT_FAIL_WARN       (1U << 3)
 #endif
 #ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
 #define FW_OPT_FALLBACK                FW_OPT_USERHELPER
@@ -1116,10 +1118,11 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
 
Quoted 13 lines

drivers/base/firmware_class.c _request_firmware(const struct firmware **firmware_p, const char *name, · line 1124

Quoted 9 lines
drivers/base/firmware_class.c +3 -3
        ret = fw_get_filesystem_firmware(device, fw->priv);
        if (ret) {
-               if (opt_flags & FW_OPT_USERHELPER) {
+               if (opt_flags & (FW_OPT_FAIL_WARN | FW_OPT_USERHELPER))
                        dev_warn(device,
-                                "Direct firmware load failed with error %d\n",
-                                ret);
+                                "Direct firmware load for %s failed with error %d\n",
+                                name, ret);

Maybe the warning can be always printed out since
(FW_OPT_FAIL_WARN | FW_OPT_USERHELPER) should be
always true.

Yes, it'd be simpler. Let's reduce lines! :)

Takashi

#3 lore raw
Quoted 77 lines · Takashi Iwai

At Tue, 1 Jul 2014 11:54:24 +0800,

Quoted 61 lines · Ming Lei
Quoted 58 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 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 without 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.

[0] https://github.com/mcgrof/fake-firmware-test.git

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]>

---

 drivers/base/firmware_class.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/base/firmware_class.c +2 -0
index 46ea5f4..23274d8 100644
@@ -101,8 +101,10 @@ static inline long firmware_loading_timeout(void)
 #define FW_OPT_NOWAIT  (1U << 1)
 #ifdef CONFIG_FW_LOADER_USER_HELPER
 #define FW_OPT_USERHELPER      (1U << 2)
+#define FW_OPT_FAIL_WARN       0
 #else
 #define FW_OPT_USERHELPER      0
+#define FW_OPT_FAIL_WARN       (1U << 3)
 #endif
 #ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
 #define FW_OPT_FALLBACK                FW_OPT_USERHELPER
@@ -1116,10 +1118,11 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
 
Quoted 13 lines

drivers/base/firmware_class.c _request_firmware(const struct firmware **firmware_p, const char *name, · line 1124

Quoted 9 lines
drivers/base/firmware_class.c +3 -3
        ret = fw_get_filesystem_firmware(device, fw->priv);
        if (ret) {
-               if (opt_flags & FW_OPT_USERHELPER) {
+               if (opt_flags & (FW_OPT_FAIL_WARN | FW_OPT_USERHELPER))
                        dev_warn(device,
-                                "Direct firmware load failed with error %d\n",
-                                ret);
+                                "Direct firmware load for %s failed with error %d\n",
+                                name, ret);

Maybe the warning can be always printed out since
(FW_OPT_FAIL_WARN | FW_OPT_USERHELPER) should be
always true.

Quoted 1 line

Yes, it'd be simpler. Let's reduce lines! :)

Actually we don't want to warn when request_firmware_direct() is used right? That's really what I meant to upkeep while adding a warning when _direct() is not used. So how about this as an ammendment:

drivers/base/firmware_class.c +0 -2
index 23274d8..4f6adf3 100644
@@ -1180,7 +1180,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
@@ -1202,7 +1201,6 @@ int request_firmware_direct(const struct firmware **firmware_p,
 	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
index 67e5b80..5c41c5e 100644
@@ -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
#4 lore raw
Quoted 78 lines · Luis R. Rodriguez
Quoted 77 lines · Takashi Iwai

At Tue, 1 Jul 2014 11:54:24 +0800,

Quoted 74 lines · Ming Lei
Quoted 57 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 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 without 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.

[0] https://github.com/mcgrof/fake-firmware-test.git

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]>

---

 drivers/base/firmware_class.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/base/firmware_class.c +2 -0
index 46ea5f4..23274d8 100644
@@ -101,8 +101,10 @@ static inline long firmware_loading_timeout(void)
 #define FW_OPT_NOWAIT  (1U << 1)
 #ifdef CONFIG_FW_LOADER_USER_HELPER
 #define FW_OPT_USERHELPER      (1U << 2)
+#define FW_OPT_FAIL_WARN       0
 #else
 #define FW_OPT_USERHELPER      0
+#define FW_OPT_FAIL_WARN       (1U << 3)
 #endif
 #ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
 #define FW_OPT_FALLBACK                FW_OPT_USERHELPER

drivers/base/firmware_class.c _request_firmware(const struct firmware **firmware_p, const char *name, · line 1124

Quoted 10 lines
drivers/base/firmware_class.c +3 -3
@@ -1116,10 +1118,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_FAIL_WARN | FW_OPT_USERHELPER))
                        dev_warn(device,
-                                "Direct firmware load failed with error %d\n",
-                                ret);
+                                "Direct firmware load for %s failed with error %d\n",
+                                name, ret);

Maybe the warning can be always printed out since
(FW_OPT_FAIL_WARN | FW_OPT_USERHELPER) should be
always true.

Quoted 3 lines
Quoted 1 line

Yes, it'd be simpler. Let's reduce lines! :)

Actually we don't want to warn when request_firmware_direct() is used right? That's really what

Yes, that is for the CPU microcode update in which it is common to fail in direct loading, and x86 guys hate the warning.

Quoted 2 lines

I meant to upkeep while adding a warning when _direct() is not used. So how about this as an ammendment:

Yes, the idea is right, and it is good to make request_firmware_direct() not depend on CONFIG_FW_LOADER_USER_HELPER, and with
one FW_OPT_DIRECT_ONLY flag together it should work.

Quoted 35 lines
drivers/base/firmware_class.c +0 -2
index 23274d8..4f6adf3 100644
@@ -1180,7 +1180,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
@@ -1202,7 +1201,6 @@ int request_firmware_direct(const struct firmware **firmware_p,
        return ret;
 }
 EXPORT_SYMBOL_GPL(request_firmware_direct);
-#endif
 
 /**
  * release_firmware: - release the resource associated with a firmware image
include/linux/firmware.h +2 -0
index 67e5b80..5c41c5e 100644
@@ -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

include/linux/firmware.h static inline void release_firmware(const struct firmware *fw) · line 76

Quoted 10 lines
include/linux/firmware.h +6 -1
@@ -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;
+}

You define two request_firmware_direct?

Quoted 9 lines
include/linux/firmware.h +0 -6
-#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
#5 lore raw
Quoted 79 lines · Ming Lei
Quoted 78 lines · Luis R. Rodriguez
Quoted 77 lines · Takashi Iwai

At Tue, 1 Jul 2014 11:54:24 +0800,

Quoted 74 lines · Ming Lei
Quoted 57 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 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 without 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.

[0] https://github.com/mcgrof/fake-firmware-test.git

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]>

---

 drivers/base/firmware_class.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/base/firmware_class.c +2 -0
index 46ea5f4..23274d8 100644
@@ -101,8 +101,10 @@ static inline long firmware_loading_timeout(void)
 #define FW_OPT_NOWAIT  (1U << 1)
 #ifdef CONFIG_FW_LOADER_USER_HELPER
 #define FW_OPT_USERHELPER      (1U << 2)
+#define FW_OPT_FAIL_WARN       0
 #else
 #define FW_OPT_USERHELPER      0
+#define FW_OPT_FAIL_WARN       (1U << 3)
 #endif
 #ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
 #define FW_OPT_FALLBACK                FW_OPT_USERHELPER

drivers/base/firmware_class.c _request_firmware(const struct firmware **firmware_p, const char *name, · line 1124

Quoted 10 lines
drivers/base/firmware_class.c +3 -3
@@ -1116,10 +1118,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_FAIL_WARN | FW_OPT_USERHELPER))
                        dev_warn(device,
-                                "Direct firmware load failed with error %d\n",
-                                ret);
+                                "Direct firmware load for %s failed with error %d\n",
+                                name, ret);

Maybe the warning can be always printed out since
(FW_OPT_FAIL_WARN | FW_OPT_USERHELPER) should be
always true.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Yes, it'd be simpler. Let's reduce lines! :)

Actually we don't want to warn when request_firmware_direct() is used right? That's really what

Yes, that is for the CPU microcode update in which it is common to fail in direct loading, and x86 guys hate the warning.

I've extended use of request_firmware_direct() to drivers that also load non-firmware but optional config files, EEPROM override, etc.

Quoted 6 lines
Quoted 2 lines

I meant to upkeep while adding a warning when _direct() is not used. So how about this as an ammendment:

Yes, the idea is right, and it is good to make request_firmware_direct() not depend on CONFIG_FW_LOADER_USER_HELPER, and with
one FW_OPT_DIRECT_ONLY flag together it should work.

OK.

Quoted 8 lines
Quoted 8 lines
drivers/base/firmware_class.c +0 -0
index 23274d8..4f6adf3 100644
@@ -66,13 +68,12 @@ static inline void release_firmware(const struct firmware *fw)
 {
 }
 
Quoted 9 lines

drivers/base/firmware_class.c static inline void release_firmware(const struct firmware *fw) · line 76

Quoted 7 lines
drivers/base/firmware_class.c +6 -1
-#endif
+static inline int request_firmware_direct(const struct firmware **fw,
+                                         const char *name,
+                                         struct device *device)
+{
+       return -EINVAL;
+}

You define two request_firmware_direct?

This is the negative of

#if defined(CONFIG_FW_LOADER) || (defined(CONFIG_FW_LOADER_MODULE) && defined(MODULE))

We have two also for request_firmware().

Will send out a v2.

Luis

Reviewed-by on v1 1/1
#6 lore raw
In reply to Luis R. Rodriguez
Quoted 11 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 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.

Quoted 7 lines

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 without FW_LOADER_USER_HELPER_FALLBACK

This ^^ should be "Example output with [...]" ?

Otherwise looks good, so:

Quoted 65 lines

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.

[0] https://github.com/mcgrof/fake-firmware-test.git

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]>

---

 drivers/base/firmware_class.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/base/firmware_class.c +8 -5
index 46ea5f4..23274d8 100644
@@ -101,8 +101,10 @@ static inline long firmware_loading_timeout(void)
 #define FW_OPT_NOWAIT  (1U << 1)
 #ifdef CONFIG_FW_LOADER_USER_HELPER
 #define FW_OPT_USERHELPER      (1U << 2)
+#define FW_OPT_FAIL_WARN       0
 #else
 #define FW_OPT_USERHELPER      0
+#define FW_OPT_FAIL_WARN       (1U << 3)
 #endif
 #ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
 #define FW_OPT_FALLBACK                FW_OPT_USERHELPER
@@ -1116,10 +1118,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_FAIL_WARN | FW_OPT_USERHELPER))
                        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);
@@ -1170,7 +1173,8 @@ request_firmware(const struct firmware **firmware_p, const char *name,
        /* Need to pin this module until return */
        __module_get(THIS_MODULE);
        ret = _request_firmware(firmware_p, name, device,
-                               FW_OPT_UEVENT | FW_OPT_FALLBACK);
+                               FW_OPT_UEVENT | FW_OPT_FALLBACK |
+                               FW_OPT_FAIL_WARN);
        module_put(THIS_MODULE);
        return ret;
 }
--

2.0.0