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 the last 2 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.
Unified · Split
| @@ -449,6 +449,7 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count, · 448 unmodified lines | ||
| 449 | 449 | |
| 450 | 450 | if (buf->status != BUFSTAT_READY && |
| 451 | 451 | dev->status != STATUS_DISCONNECTED) { |
| 452 | + int err; | |
| 452 | 453 | /* return nonblocking */ |
| 453 | 454 | if (file->f_flags & O_NONBLOCK) { |
| 454 | 455 | if (!ret) |
| @@ -456,9 +457,24 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count, · 1 unmodified line | ||
| 456 | 457 | goto err; |
| 457 | 458 | } |
| 458 | 459 | |
| 459 | − if (wait_event_interruptible(dev->wait_data, | |
| 460 | − buf->status == BUFSTAT_READY)) | |
| 461 | − return -ERESTARTSYS; | |
| 460 | + err = wait_event_interruptible_timeout(dev->wait_data, | |
| 461 | + buf->status == BUFSTAT_READY, | |
| 462 | + msecs_to_jiffies(1000)); | |
| 463 | + if (err < 0) { | |
| 464 | + ret = err; | |
| 465 | + goto err; | |
| 466 | + } | |
| 467 | + if (!err) { | |
| 468 | + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, | |
| 469 | + "timeout: restart streaming\n"); | |
| 470 | + hdpvr_stop_streaming(dev); | |
| 471 | + msecs_to_jiffies(4000); | |
| 472 | + err = hdpvr_start_streaming(dev); | |
| 473 | + if (err) { | |
| 474 | + ret = err; | |
| 475 | + goto err; | |
| 476 | + } | |
| 477 | + } | |
| 462 | 478 | } |
| 463 | 479 | |
| 464 | 480 | if (buf->status != BUFSTAT_READY) |