Potential fix for "[BUG] process stuck when closing saa7146 [dvb_ttpci]"

Message ID 20160916100028.8856-1-andrey_utkin@fastmail.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Andrey Utkin Sept. 16, 2016, 10 a.m. UTC
  Hi Philipp,
Please try this patch. It is purely speculative as I don't have the hardware,
but I hope my approach is right.

---
 drivers/media/common/saa7146/saa7146_video.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Philipp Hahn Sept. 19, 2016, 5:08 a.m. UTC | #1
Hello Andrey,

Am 16.09.2016 um 12:00 schrieb Andrey Utkin:
> Please try this patch. It is purely speculative as I don't have the hardware,
> but I hope my approach is right.

Thanks you for the patch; I've built a new kernel but didn't have the
time to test it yet; I'll mail you again as soon as I have tested it.

Thanks you for looking into that issues.

Philipp
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  
Philipp Hahn Oct. 16, 2016, 9:52 p.m. UTC | #2
Hello Andrey,

On Mon, Sep 19, 2016 at 07:08:52AM +0200, Philipp Hahn wrote:
> Am 16.09.2016 um 12:00 schrieb Andrey Utkin:
> > Please try this patch. It is purely speculative as I don't have the hardware,
> > but I hope my approach is right.
> 
> Thanks you for the patch; I've built a new kernel but didn't have the
> time to test it yet; I'll mail you again as soon as I have tested it.

I tested your patch and during my limites testing I wan't able to
reproduce the previous problem. Seems you fixed it.

Tested-by: Philipp Matthias Hahn <pmhahn@pmhahn.de>

Thanks you again for looking into that issues.

Philipp
  
Philipp Hahn Feb. 10, 2018, 12:28 p.m. UTC | #3
Hello Andrey,

On Sun, Oct 16, 2016 at 11:52:19PM +0200, Philipp Matthias Hahn wrote:
> On Mon, Sep 19, 2016 at 07:08:52AM +0200, Philipp Hahn wrote:
> > Am 16.09.2016 um 12:00 schrieb Andrey Utkin:
> > > Please try this patch. It is purely speculative as I don't have the hardware,
> > > but I hope my approach is right.
> > 
> > Thanks you for the patch; I've built a new kernel but didn't have the
> > time to test it yet; I'll mail you again as soon as I have tested it.
> 
> I tested your patch and during my limites testing I wan't able to
> reproduce the previous problem. Seems you fixed it.
> 
> Tested-by: Philipp Matthias Hahn <pmhahn@pmhahn.de>
> 
> Thanks you again for looking into that issues.

Bad news: I'm running linux-4.15.2 by now and again got a stuck ffmpeg
process after accessing /dev/video0:

| INFO: task read_thread:20579 blocked for more than 120 seconds.
|       Tainted: P           O     4.15.2 #1
| "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
| read_thread     D    0 20579   2949 0x80000000
| Call Trace:
|  ? __schedule+0x646/0x697
|  schedule+0x79/0x94
|  videobuf_waiton+0x11c/0x148 [videobuf_core]
|  ? wait_woken+0x68/0x68
|  saa7146_dma_free+0x34/0x55 [saa7146_vv]
|  buffer_release+0x25/0x33 [saa7146_vv]
|  videobuf_vm_close+0xd6/0x103 [videobuf_dma_sg]
|  remove_vma+0x23/0x49
|  exit_mmap+0xea/0x114
|  mmput+0x45/0xdb
|  do_exit+0x3a0/0x8c1
|  do_group_exit+0x95/0x95
|  get_signal+0x41c/0x447
|  do_signal+0x1e/0x4c2
|  ? __schedule+0x646/0x697
|  ? do_task_dead+0x38/0x3a
|  ? SyS_futex+0x127/0x137
|  exit_to_usermode_loop+0x1f/0x69
|  do_syscall_64+0xe3/0xea
|  entry_SYSCALL_64_after_hwframe+0x21/0x86
| RIP: 0033:0x7f56429927fd
| RSP: 002b:00007f56217b3550 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
| RAX: fffffffffffffe00 RBX: 00007f5608002320 RCX: 00007f56429927fd
| RDX: 0000000000000000 RSI: 0000000000000080 RDI: 00007f560800234c
| RBP: 0000000000000000 R08: 0000000000000000 R09: 00007f5608002320
| R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000003
| R13: 00007f56080022f8 R14: 0000000000000000 R15: 00007f560800234c

Your previous patch is applied since v4.10-rc1~71^2^2~34 , so the issue seems
to be not fixed.
The tainting is from the NVidia driver.

Philipp
  

Patch

diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c
index ea2f3bf..93c64f0 100644
--- a/drivers/media/common/saa7146/saa7146_video.c
+++ b/drivers/media/common/saa7146/saa7146_video.c
@@ -390,6 +390,7 @@  static int video_end(struct saa7146_fh *fh, struct file *file)
 {
 	struct saa7146_dev *dev = fh->dev;
 	struct saa7146_vv *vv = dev->vv_data;
+	struct saa7146_dmaqueue *q = &vv->video_dmaq;
 	struct saa7146_format *fmt = NULL;
 	unsigned long flags;
 	unsigned int resource;
@@ -428,6 +429,9 @@  static int video_end(struct saa7146_fh *fh, struct file *file)
 	/* shut down all used video dma transfers */
 	saa7146_write(dev, MC1, dmas);
 
+	if(q->curr)
+		saa7146_buffer_finish(dev, q, VIDEOBUF_DONE);
+
 	spin_unlock_irqrestore(&dev->slock, flags);
 
 	vv->video_fh = NULL;