LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] fix loading of firmware with user mode helper
@ 2015-03-09 15:49 Zahari Doychev
  2015-03-09 15:49 ` [PATCH] drivers: base: fw: fix ret value when loading fw Zahari Doychev
  0 siblings, 1 reply; 5+ messages in thread
From: Zahari Doychev @ 2015-03-09 15:49 UTC (permalink / raw)
  To: ming.lei, gregkh, linux-kernel; +Cc: zahari.doychev

This patch fixes loading of firmware when using the user mode helper. I have
seen the problems with the coda driver. Using this patch the coda driver loads
without any problems. Please check if this is the right way to fix the problem.

Zahari Doychev (1):
  drivers: base: fw: fix ret value when loading fw

 drivers/base/firmware_class.c | 4 ++++
 1 file changed, 4 insertions(+)

-- 
2.3.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] drivers: base: fw: fix ret value when loading fw
  2015-03-09 15:49 [PATCH] fix loading of firmware with user mode helper Zahari Doychev
@ 2015-03-09 15:49 ` Zahari Doychev
  2015-03-10  7:32   ` Ming Lei
  0 siblings, 1 reply; 5+ messages in thread
From: Zahari Doychev @ 2015-03-09 15:49 UTC (permalink / raw)
  To: ming.lei, gregkh, linux-kernel; +Cc: zahari.doychev

When using the user mode helper to load firmwares the function _request_firmware
gets a positive return value from fw_load_from_user_helper and because of this
the firmware buffer is not assigned. This happens only when the return value
is zero. This patch fixes this problem in _request_firmware_load. When the
completion is ready the return value is set to zero.

Signed-off-by: Zahari Doychev <zahari.doychev@linux.com>
---
 drivers/base/firmware_class.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 6c5c9ed..9642e5f 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -920,6 +920,10 @@ static int _request_firmware_load(struct firmware_priv *fw_priv,
 	else if (!buf->data)
 		retval = -ENOMEM;
 
+	/* wait for completion was successful so return ok */
+	if (retval > 0)
+		retval = 0;
+
 	device_remove_file(f_dev, &dev_attr_loading);
 err_del_bin_attr:
 	device_remove_bin_file(f_dev, &firmware_attr_data);
-- 
2.3.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drivers: base: fw: fix ret value when loading fw
  2015-03-09 15:49 ` [PATCH] drivers: base: fw: fix ret value when loading fw Zahari Doychev
@ 2015-03-10  7:32   ` Ming Lei
  2015-03-10  9:45     ` [PATCH v2] " Zahari Doychev
  0 siblings, 1 reply; 5+ messages in thread
From: Ming Lei @ 2015-03-10  7:32 UTC (permalink / raw)
  To: Zahari Doychev; +Cc: Greg Kroah-Hartman, Linux Kernel Mailing List

On Mon, Mar 9, 2015 at 11:49 PM, Zahari Doychev
<zahari.doychev@linux.com> wrote:
> When using the user mode helper to load firmwares the function _request_firmware
> gets a positive return value from fw_load_from_user_helper and because of this
> the firmware buffer is not assigned. This happens only when the return value
> is zero. This patch fixes this problem in _request_firmware_load. When the
> completion is ready the return value is set to zero.
>
> Signed-off-by: Zahari Doychev <zahari.doychev@linux.com>

Acked-by: Ming Lei <ming.lei@canonical.com>

> ---
>  drivers/base/firmware_class.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
> index 6c5c9ed..9642e5f 100644
> --- a/drivers/base/firmware_class.c
> +++ b/drivers/base/firmware_class.c
> @@ -920,6 +920,10 @@ static int _request_firmware_load(struct firmware_priv *fw_priv,
>         else if (!buf->data)
>                 retval = -ENOMEM;
>
> +       /* wait for completion was successful so return ok */
> +       if (retval > 0)
> +               retval = 0;

Suggest to move the check backward and handle return value
from wait_for_completion_interruptible_timeout() in one place, like below:

           if (retval == -ERESTARTSYS || !retval) {
               ...
           } else if (retval > 0) {
               retval = 0;
           }

> +
>         device_remove_file(f_dev, &dev_attr_loading);
>  err_del_bin_attr:
>         device_remove_bin_file(f_dev, &firmware_attr_data);
> --
> 2.3.0
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] drivers: base: fw: fix ret value when loading fw
  2015-03-10  7:32   ` Ming Lei
@ 2015-03-10  9:45     ` Zahari Doychev
  2015-03-18  7:41       ` Zahari Doychev
  0 siblings, 1 reply; 5+ messages in thread
From: Zahari Doychev @ 2015-03-10  9:45 UTC (permalink / raw)
  To: ming.lei, gregkh, linux-kernel; +Cc: zahari.doychev

When using the user mode helper to load firmwares the function _request_firmware
gets a positive return value from fw_load_from_user_helper and because of this
the firmware buffer is not assigned. This happens only when the return value
is zero. This patch fixes this problem in _request_firmware_load. When the
completion is ready the return value is set to zero.

Signed-off-by: Zahari Doychev <zahari.doychev@linux.com>
---

Changes from v1:
 - move handling of wait_for_completion_interruptible_timeout() return value

 drivers/base/firmware_class.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 6c5c9ed..4996541 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -913,6 +913,8 @@ static int _request_firmware_load(struct firmware_priv *fw_priv,
 		mutex_lock(&fw_lock);
 		fw_load_abort(fw_priv);
 		mutex_unlock(&fw_lock);
+	} else if (retval > 0) {
+		retval = 0;
 	}
 
 	if (is_fw_load_aborted(buf))
-- 
2.3.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] drivers: base: fw: fix ret value when loading fw
  2015-03-10  9:45     ` [PATCH v2] " Zahari Doychev
@ 2015-03-18  7:41       ` Zahari Doychev
  0 siblings, 0 replies; 5+ messages in thread
From: Zahari Doychev @ 2015-03-18  7:41 UTC (permalink / raw)
  To: ming.lei, gregkh, linux-kernel; +Cc: zahari.doychev

On Tue, Mar 10, 2015 at 10:45:40AM +0100, Zahari Doychev wrote:
> When using the user mode helper to load firmwares the function _request_firmware
> gets a positive return value from fw_load_from_user_helper and because of this
> the firmware buffer is not assigned. This happens only when the return value
> is zero. This patch fixes this problem in _request_firmware_load. When the
> completion is ready the return value is set to zero.
> 
> Signed-off-by: Zahari Doychev <zahari.doychev@linux.com>
> ---
> 
> Changes from v1:
>  - move handling of wait_for_completion_interruptible_timeout() return value
> 

Hi,

what is the status of the patch? Is there something wrong with it?

Regards,
Zahari

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-03-18  7:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-09 15:49 [PATCH] fix loading of firmware with user mode helper Zahari Doychev
2015-03-09 15:49 ` [PATCH] drivers: base: fw: fix ret value when loading fw Zahari Doychev
2015-03-10  7:32   ` Ming Lei
2015-03-10  9:45     ` [PATCH v2] " Zahari Doychev
2015-03-18  7:41       ` Zahari Doychev

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).