All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFCv3 PATCH 1/1] hdpvr: fix interrupted recording
@ 2017-01-26 12:17 Jonathan Sims
  2017-02-08 11:42 ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Sims @ 2017-01-26 12:17 UTC (permalink / raw)
  To: linux-media; +Cc: hverkuil, mchehab, kpyle, ryleyjangus

This is a reworking of a patch originally submitted by Ryley Angus, modified by Hans Verkuil and then seemingly forgotten before changes suggested by Keith Pyle here:

http://www.mail-archive.com/linux-media@vger.kernel.org/msg75163.html

were made and tested.

I have implemented the suggested changes and have been testing for several months. I am no longer experiencing lockups while recording (with blue light on, requiring power cycling) which had been a long standing problem with the HD-PVR. I have not noticed any other problems since applying the patch.

Signed-off-by: Jonathan Sims <jonathan.625266@earthlink.net>
---

Changes in v3:
- Actually sleep for 4 seconds after the hdpvr_stop_streaming call.

 drivers/media/usb/hdpvr/hdpvr-video.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index 2a3a8b4..dec8496 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -454,6 +454,7 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count,
 
 		if (buf->status != BUFSTAT_READY &&
 		    dev->status != STATUS_DISCONNECTED) {
+			int err;
 			/* return nonblocking */
 			if (file->f_flags & O_NONBLOCK) {
 				if (!ret)
@@ -461,9 +462,27 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count,
 				goto err;
 			}
 
-			if (wait_event_interruptible(dev->wait_data,
-					      buf->status == BUFSTAT_READY))
-				return -ERESTARTSYS;
+			err = wait_event_interruptible_timeout(dev->wait_data,
+				buf->status == BUFSTAT_READY,
+				msecs_to_jiffies(1000));
+			if (err < 0) {
+				ret = err;
+				goto err;
+			}
+			if (!err) {
+				int delay;
+
+				v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev,
+					"timeout: restart streaming\n");
+				hdpvr_stop_streaming(dev);
+				delay = msecs_to_jiffies(4000);
+				schedule_timeout(delay);
+				err = hdpvr_start_streaming(dev);
+				if (err) {
+					ret = err;
+					goto err;
+				}
+			}
 		}
 
 		if (buf->status != BUFSTAT_READY)
-- 
2.10.1

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

* Re: [RFCv3 PATCH 1/1] hdpvr: fix interrupted recording
  2017-01-26 12:17 [RFCv3 PATCH 1/1] hdpvr: fix interrupted recording Jonathan Sims
@ 2017-02-08 11:42 ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 2+ messages in thread
From: Mauro Carvalho Chehab @ 2017-02-08 11:42 UTC (permalink / raw)
  To: Jonathan Sims; +Cc: linux-media, hverkuil, mchehab, kpyle, ryleyjangus

Em Thu, 26 Jan 2017 07:17:22 -0500
Jonathan Sims <jonathan.625266@earthlink.net> escreveu:

> This is a reworking of a patch originally submitted by Ryley Angus, modified by Hans Verkuil and then seemingly forgotten before changes suggested by Keith Pyle here:
> 
> http://www.mail-archive.com/linux-media@vger.kernel.org/msg75163.html
> 
> were made and tested.
> 
> I have implemented the suggested changes and have been testing for several months. I am no longer experiencing lockups while recording (with blue light on, requiring power cycling) which had been a long standing problem with the HD-PVR. I have not noticed any other problems since applying the patch.
> 
> Signed-off-by: Jonathan Sims <jonathan.625266@earthlink.net>
> ---
> 
> Changes in v3:
> - Actually sleep for 4 seconds after the hdpvr_stop_streaming call.
> 
>  drivers/media/usb/hdpvr/hdpvr-video.c | 25 ++++++++++++++++++++++---
>  1 file changed, 22 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
> index 2a3a8b4..dec8496 100644
> --- a/drivers/media/usb/hdpvr/hdpvr-video.c
> +++ b/drivers/media/usb/hdpvr/hdpvr-video.c
> @@ -454,6 +454,7 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count,
>  
>  		if (buf->status != BUFSTAT_READY &&
>  		    dev->status != STATUS_DISCONNECTED) {
> +			int err;

Are there any reason why not using "ret" var, instead of creating
another return variable here?

>  			/* return nonblocking */
>  			if (file->f_flags & O_NONBLOCK) {
>  				if (!ret)
> @@ -461,9 +462,27 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count,
>  				goto err;
>  			}
>  
> -			if (wait_event_interruptible(dev->wait_data,
> -					      buf->status == BUFSTAT_READY))
> -				return -ERESTARTSYS;
> +			err = wait_event_interruptible_timeout(dev->wait_data,
> +				buf->status == BUFSTAT_READY,
> +				msecs_to_jiffies(1000));
> +			if (err < 0) {
> +				ret = err;
> +				goto err;
> +			}
> +			if (!err) {
> +				int delay;
> +
> +				v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev,
> +					"timeout: restart streaming\n");
> +				hdpvr_stop_streaming(dev);
> +				delay = msecs_to_jiffies(4000);
> +				schedule_timeout(delay);

Why don't you just call:
	msleep(4000);

> +				err = hdpvr_start_streaming(dev);
> +				if (err) {
> +					ret = err;
> +					goto err;
> +				}
> +			}
>  		}
>  
>  		if (buf->status != BUFSTAT_READY)



Thanks,
Mauro

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

end of thread, other threads:[~2017-02-08 11:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-26 12:17 [RFCv3 PATCH 1/1] hdpvr: fix interrupted recording Jonathan Sims
2017-02-08 11:42 ` Mauro Carvalho Chehab

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.