diff mbox

[PATCH/RFC] media: soc_camera: rcar_vin: Fix wait_for_completion

Message ID 1426430373-3443-1-git-send-email-ykaneko0929@gmail.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Yoshihiro Kaneko March 15, 2015, 2:39 p.m. UTC
From: Koji Matsuoka <koji.matsuoka.xm@renesas.com>

When stopping abnormally, a driver can't return from wait_for_completion.
This patch resolved this problem by changing wait_for_completion_timeout
from wait_for_completion.

Signed-off-by: Koji Matsuoka <koji.matsuoka.xm@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
---

This patch is against master branch of linuxtv.org/media_tree.git.

 drivers/media/platform/soc_camera/rcar_vin.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Guennadi Liakhovetski March 15, 2015, 2:46 p.m. UTC | #1
Hi,

Thanks for the patch.

On Sun, 15 Mar 2015, Yoshihiro Kaneko wrote:

> From: Koji Matsuoka <koji.matsuoka.xm@renesas.com>
> 
> When stopping abnormally, a driver can't return from wait_for_completion.
> This patch resolved this problem by changing wait_for_completion_timeout
> from wait_for_completion.
> 
> Signed-off-by: Koji Matsuoka <koji.matsuoka.xm@renesas.com>
> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
> ---
> 
> This patch is against master branch of linuxtv.org/media_tree.git.
> 
>  drivers/media/platform/soc_camera/rcar_vin.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
> index 279ab9f..ff0359b 100644
> --- a/drivers/media/platform/soc_camera/rcar_vin.c
> +++ b/drivers/media/platform/soc_camera/rcar_vin.c
> @@ -135,6 +135,8 @@
>  #define VIN_MAX_WIDTH		2048
>  #define VIN_MAX_HEIGHT		2048
>  
> +#define TIMEOUT_MS		100
> +
>  enum chip_id {
>  	RCAR_GEN2,
>  	RCAR_H1,
> @@ -821,6 +823,10 @@ static void rcar_vin_wait_stop_streaming(struct rcar_vin_priv *priv)
>  			priv->request_to_stop = true;
>  			spin_unlock_irq(&priv->lock);
>  			wait_for_completion(&priv->capture_stop);
> +			if (!wait_for_completion_timeout(
> +				&priv->capture_stop,
> +				msecs_to_jiffies(TIMEOUT_MS)))
> +				priv->state = STOPPED;

You forgot to remove the original wait_for_completion().

Thanks
Guennadi

>  			spin_lock_irq(&priv->lock);
>  		}
>  	}
> -- 
> 1.9.1
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sergei Shtylyov March 15, 2015, 9:37 p.m. UTC | #2
Hello.

On 03/15/2015 05:39 PM, Yoshihiro Kaneko wrote:

> From: Koji Matsuoka <koji.matsuoka.xm@renesas.com>

> When stopping abnormally, a driver can't return from wait_for_completion.
> This patch resolved this problem by changing wait_for_completion_timeout
> from wait_for_completion.

> Signed-off-by: Koji Matsuoka <koji.matsuoka.xm@renesas.com>
> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
> ---

[...]

> diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
> index 279ab9f..ff0359b 100644
> --- a/drivers/media/platform/soc_camera/rcar_vin.c
> +++ b/drivers/media/platform/soc_camera/rcar_vin.c
[...]
> @@ -821,6 +823,10 @@ static void rcar_vin_wait_stop_streaming(struct rcar_vin_priv *priv)
>   			priv->request_to_stop = true;
>   			spin_unlock_irq(&priv->lock);
>   			wait_for_completion(&priv->capture_stop);

    You forgot to remove this line, as already noted.

> +			if (!wait_for_completion_timeout(
> +				&priv->capture_stop,
> +				msecs_to_jiffies(TIMEOUT_MS)))

    Please indent the above 2 lines more to the right, so that they're easier 
on the eyes with the following line.

> +				priv->state = STOPPED;
>   			spin_lock_irq(&priv->lock);
>   		}
>   	}

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yoshihiro Kaneko March 16, 2015, 1:44 p.m. UTC | #3
Hi,

2015-03-15 23:46 GMT+09:00 Guennadi Liakhovetski <g.liakhovetski@gmx.de>:
> Hi,
>
> Thanks for the patch.
>
> On Sun, 15 Mar 2015, Yoshihiro Kaneko wrote:
>
>> From: Koji Matsuoka <koji.matsuoka.xm@renesas.com>
>>
>> When stopping abnormally, a driver can't return from wait_for_completion.
>> This patch resolved this problem by changing wait_for_completion_timeout
>> from wait_for_completion.
>>
>> Signed-off-by: Koji Matsuoka <koji.matsuoka.xm@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
>> ---
>>
>> This patch is against master branch of linuxtv.org/media_tree.git.
>>
>>  drivers/media/platform/soc_camera/rcar_vin.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
>> index 279ab9f..ff0359b 100644
>> --- a/drivers/media/platform/soc_camera/rcar_vin.c
>> +++ b/drivers/media/platform/soc_camera/rcar_vin.c
>> @@ -135,6 +135,8 @@
>>  #define VIN_MAX_WIDTH                2048
>>  #define VIN_MAX_HEIGHT               2048
>>
>> +#define TIMEOUT_MS           100
>> +
>>  enum chip_id {
>>       RCAR_GEN2,
>>       RCAR_H1,
>> @@ -821,6 +823,10 @@ static void rcar_vin_wait_stop_streaming(struct rcar_vin_priv *priv)
>>                       priv->request_to_stop = true;
>>                       spin_unlock_irq(&priv->lock);
>>                       wait_for_completion(&priv->capture_stop);
>> +                     if (!wait_for_completion_timeout(
>> +                             &priv->capture_stop,
>> +                             msecs_to_jiffies(TIMEOUT_MS)))
>> +                             priv->state = STOPPED;
>
> You forgot to remove the original wait_for_completion().

Oops, my bad.

Thanks,
Kaneko

>
> Thanks
> Guennadi
>
>>                       spin_lock_irq(&priv->lock);
>>               }
>>       }
>> --
>> 1.9.1
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index 279ab9f..ff0359b 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -135,6 +135,8 @@ 
 #define VIN_MAX_WIDTH		2048
 #define VIN_MAX_HEIGHT		2048
 
+#define TIMEOUT_MS		100
+
 enum chip_id {
 	RCAR_GEN2,
 	RCAR_H1,
@@ -821,6 +823,10 @@  static void rcar_vin_wait_stop_streaming(struct rcar_vin_priv *priv)
 			priv->request_to_stop = true;
 			spin_unlock_irq(&priv->lock);
 			wait_for_completion(&priv->capture_stop);
+			if (!wait_for_completion_timeout(
+				&priv->capture_stop,
+				msecs_to_jiffies(TIMEOUT_MS)))
+				priv->state = STOPPED;
 			spin_lock_irq(&priv->lock);
 		}
 	}