* [PATCHv2 0/2] Avoid firmware warning in imx-sdma
@ 2018-07-04 16:04 Sebastian Reichel
2018-07-04 16:04 ` [PATCHv2 1/2] firmware: add request_firmware_nowait_nowarn function Sebastian Reichel
2018-07-04 16:05 ` [PATCHv2 2/2] dmaengine: imx-sdma: request firmware with FW_OPT_NO_WARN Sebastian Reichel
0 siblings, 2 replies; 3+ messages in thread
From: Sebastian Reichel @ 2018-07-04 16:04 UTC (permalink / raw)
To: Greg Kroah-Hartman, Kees Cook, Hans de Goede
Cc: andresx7, torvalds, Luis R. Rodriguez, Dan Williams, Vinod Koul,
dmaengine, linux-kernel, Rafał Miłecki, kernel,
Sebastian Reichel
Hi,
I grabbed the first patch from patchwork from an 2017 patch series. As far as I
could see, their usecase vanished due to switching to sync FW API (that already
supports NOWARN). This series fixes a kernel warning in imx-sdma driver, which
works fine with ROM firmware (and already prints an info message about ROM
firmware being used due to missing firmware file). This has been tested on
arch/arm/boot/dts/imx53-ppd.dts.
Changes since PATCHv2:
* Provide request_firmware_nowait_nowarn instead of generic function with
flags as suggested by Luis [0]
[0] https://lore.kernel.org/lkml/20180628031332.GE21242@wotan.suse.de/
-- Sebastian
Sebastian Reichel (2):
firmware: add request_firmware_nowait_nowarn function
dmaengine: imx-sdma: request firmware with FW_OPT_NO_WARN
drivers/base/firmware_loader/main.c | 40 ++++++++++++++++++++++++-----
drivers/dma/imx-sdma.c | 10 +++-----
include/linux/firmware.h | 12 +++++++++
3 files changed, 48 insertions(+), 14 deletions(-)
--
2.18.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCHv2 1/2] firmware: add request_firmware_nowait_nowarn function
2018-07-04 16:04 [PATCHv2 0/2] Avoid firmware warning in imx-sdma Sebastian Reichel
@ 2018-07-04 16:04 ` Sebastian Reichel
2018-07-04 16:05 ` [PATCHv2 2/2] dmaengine: imx-sdma: request firmware with FW_OPT_NO_WARN Sebastian Reichel
1 sibling, 0 replies; 3+ messages in thread
From: Sebastian Reichel @ 2018-07-04 16:04 UTC (permalink / raw)
To: Greg Kroah-Hartman, Kees Cook, Hans de Goede
Cc: andresx7, torvalds, Luis R. Rodriguez, Dan Williams, Vinod Koul,
dmaengine, linux-kernel, Rafał Miłecki, kernel,
Sebastian Reichel
So far we got only one function for loading firmware asynchronously:
request_firmware_nowait. This adds another method for loading async
firmware without generating a warning when the firmware file is missing.
This is useful for devices, which also work without a firmware (i.e.
by using ROM firmware).
This is based on previous work from Rafał Miłecki <rafal@milecki.pl>.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
---
drivers/base/firmware_loader/main.c | 40 ++++++++++++++++++++++++-----
include/linux/firmware.h | 12 +++++++++
2 files changed, 45 insertions(+), 7 deletions(-)
diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
index 0943e7065e0e..ede1a90e075e 100644
--- a/drivers/base/firmware_loader/main.c
+++ b/drivers/base/firmware_loader/main.c
@@ -774,7 +774,7 @@ static void request_firmware_work_func(struct work_struct *work)
_request_firmware(&fw, fw_work->name, fw_work->device, NULL, 0,
fw_work->opt_flags);
fw_work->cont(fw, fw_work->context);
- put_device(fw_work->device); /* taken in request_firmware_nowait() */
+ put_device(fw_work->device); /* taken in __request_firmware_nowait() */
module_put(fw_work->module);
kfree_const(fw_work->name);
@@ -782,8 +782,9 @@ static void request_firmware_work_func(struct work_struct *work)
}
/**
- * request_firmware_nowait() - asynchronous version of request_firmware
+ * __request_firmware_nowait() - asynchronous version of request_firmware
* @module: module requesting the firmware
+ * @opt_flags: flags that control firmware loading process, see FW_OPT_*
* @uevent: sends uevent to copy the firmware image if this flag
* is non-zero else the firmware copy must be done manually.
* @name: name of firmware file
@@ -804,13 +805,14 @@ static void request_firmware_work_func(struct work_struct *work)
*
* - can't sleep at all if @gfp is GFP_ATOMIC.
**/
-int
-request_firmware_nowait(
- struct module *module, bool uevent,
+static int
+__request_firmware_nowait(
+ struct module *module, unsigned int opt_flags,
const char *name, struct device *device, gfp_t gfp, void *context,
void (*cont)(const struct firmware *fw, void *context))
{
struct firmware_work *fw_work;
+ bool uevent = !!(opt_flags & FW_OPT_UEVENT);
fw_work = kzalloc(sizeof(struct firmware_work), gfp);
if (!fw_work)
@@ -825,8 +827,7 @@ request_firmware_nowait(
fw_work->device = device;
fw_work->context = context;
fw_work->cont = cont;
- fw_work->opt_flags = FW_OPT_NOWAIT |
- (uevent ? FW_OPT_UEVENT : FW_OPT_USERHELPER);
+ fw_work->opt_flags = FW_OPT_NOWAIT | opt_flags;
if (!uevent && fw_cache_is_setup(device, name)) {
kfree_const(fw_work->name);
@@ -845,8 +846,33 @@ request_firmware_nowait(
schedule_work(&fw_work->work);
return 0;
}
+
+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))
+{
+ unsigned int opt_flags = (uevent ? FW_OPT_UEVENT : FW_OPT_USERHELPER);
+
+ return __request_firmware_nowait(module, opt_flags, name, device, gfp,
+ context, cont);
+}
EXPORT_SYMBOL(request_firmware_nowait);
+int request_firmware_nowait_nowarn(struct module *module, bool uevent,
+ const char *name, struct device *dev,
+ gfp_t gfp, void *context,
+ void (*cont)(const struct firmware *fw,
+ void *context))
+{
+ unsigned int opt_flags = (uevent ? FW_OPT_UEVENT : FW_OPT_USERHELPER);
+ opt_flags |= FW_OPT_NO_WARN;
+
+ return __request_firmware_nowait(module, opt_flags, name, dev, gfp,
+ context, cont);
+}
+EXPORT_SYMBOL(request_firmware_nowait_nowarn);
+
#ifdef CONFIG_PM_SLEEP
static ASYNC_DOMAIN_EXCLUSIVE(fw_cache_domain);
diff --git a/include/linux/firmware.h b/include/linux/firmware.h
index 2dd566c91d44..a6d0bc8273a4 100644
--- a/include/linux/firmware.h
+++ b/include/linux/firmware.h
@@ -48,6 +48,10 @@ 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_nowait_nowarn(
+ 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);
int request_firmware_into_buf(const struct firmware **firmware_p,
@@ -77,6 +81,14 @@ static inline int request_firmware_nowait(
return -EINVAL;
}
+static inline int request_firmware_nowait_nowarn(
+ struct module *module, bool uevent,
+ const char *name, struct device *device, gfp_t gfp, void *context,
+ void (*cont)(const struct firmware *fw, void *context))
+{
+ return -EINVAL;
+}
+
static inline void release_firmware(const struct firmware *fw)
{
}
--
2.18.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCHv2 2/2] dmaengine: imx-sdma: request firmware with FW_OPT_NO_WARN
2018-07-04 16:04 [PATCHv2 0/2] Avoid firmware warning in imx-sdma Sebastian Reichel
2018-07-04 16:04 ` [PATCHv2 1/2] firmware: add request_firmware_nowait_nowarn function Sebastian Reichel
@ 2018-07-04 16:05 ` Sebastian Reichel
1 sibling, 0 replies; 3+ messages in thread
From: Sebastian Reichel @ 2018-07-04 16:05 UTC (permalink / raw)
To: Greg Kroah-Hartman, Kees Cook, Hans de Goede
Cc: andresx7, torvalds, Luis R. Rodriguez, Dan Williams, Vinod Koul,
dmaengine, linux-kernel, Rafał Miłecki, kernel,
Sebastian Reichel
Request firmware with FW_OPT_NO_WARN. The driver works without the
firmware by using the one supplied in ROM. There is already an info
message, that informs about this.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
---
drivers/dma/imx-sdma.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index f077992635c2..68f7e5a2092f 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -1599,13 +1599,9 @@ static int sdma_event_remap(struct sdma_engine *sdma)
static int sdma_get_firmware(struct sdma_engine *sdma,
const char *fw_name)
{
- int ret;
-
- ret = request_firmware_nowait(THIS_MODULE,
- FW_ACTION_HOTPLUG, fw_name, sdma->dev,
- GFP_KERNEL, sdma, sdma_load_firmware);
-
- return ret;
+ return request_firmware_nowait_nowarn(THIS_MODULE, FW_ACTION_HOTPLUG,
+ fw_name, sdma->dev, GFP_KERNEL,
+ sdma, sdma_load_firmware);
}
static int sdma_init(struct sdma_engine *sdma)
--
2.18.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-04 16:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-04 16:04 [PATCHv2 0/2] Avoid firmware warning in imx-sdma Sebastian Reichel
2018-07-04 16:04 ` [PATCHv2 1/2] firmware: add request_firmware_nowait_nowarn function Sebastian Reichel
2018-07-04 16:05 ` [PATCHv2 2/2] dmaengine: imx-sdma: request firmware with FW_OPT_NO_WARN Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).