From 01472f19bb7fe25bf932ff286d1298e15d3c7093 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Thu, 25 Mar 2004 06:00:32 -0800 Subject: [PATCH] [PATCH] dmasound close timeout The dmasound driver occasionally hangs a process on exit. Apparently there is a possible case where the sound HW stops draining output samples and the driver waits forever in its release() callback. It should check for signals(), but it seems signal_pending() never returns 1 when the process is beeing killed (implicit release() of files on exit). This patch adds a safety timeout to the release() function to make sure we can at least close the driver. I'll try to find the reason we aren't driving samples later, but it is better to have a safety just incase the sound clock goes berserk for some reason. --- sound/oss/dmasound/dmasound_core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c index add1724bf38e5..758ea0cd5cd21 100644 --- a/sound/oss/dmasound/dmasound_core.c +++ b/sound/oss/dmasound/dmasound_core.c @@ -1004,6 +1004,7 @@ static void sq_reset(void) static int sq_fsync(struct file *filp, struct dentry *dentry) { int rc = 0; + int timeout = 5; write_sq.syncing |= 1; sq_play(); /* there may be an incomplete frame waiting */ @@ -1018,6 +1019,12 @@ static int sq_fsync(struct file *filp, struct dentry *dentry) rc = -EINTR; break; } + if (!--timeout) { + printk(KERN_WARNING "dmasound: Timeout draining output\n"); + sq_reset_output(); + rc = -EIO; + break; + } } /* flag no sync regardless of whether we had a DSP_POST or not */ -- 2.53.0