From patchwork Wed May 5 18:59:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Castet X-Patchwork-Id: 97171 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o45IxWOr028330 for ; Wed, 5 May 2010 18:59:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753319Ab0EES72 (ORCPT ); Wed, 5 May 2010 14:59:28 -0400 Received: from smtp6-g21.free.fr ([212.27.42.6]:60050 "EHLO smtp6-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751143Ab0EES71 (ORCPT ); Wed, 5 May 2010 14:59:27 -0400 Received: from smtp6-g21.free.fr (localhost [127.0.0.1]) by smtp6-g21.free.fr (Postfix) with ESMTP id 2090EE0808E; Wed, 5 May 2010 20:59:21 +0200 (CEST) Received: from [192.168.1.234] (cac94-1-81-57-151-96.fbx.proxad.net [81.57.151.96]) by smtp6-g21.free.fr (Postfix) with ESMTP; Wed, 5 May 2010 20:59:20 +0200 (CEST) Message-ID: <4BE1C008.7020206@free.fr> Date: Wed, 05 May 2010 20:59:20 +0200 From: matthieu castet User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.8.1.23) Gecko/20090823 SeaMonkey/1.1.18 MIME-Version: 1.0 To: Mauro Carvalho Chehab CC: linux-media@vger.kernel.org Subject: Re: [PATCH] fix dvb frontend lockup References: <4BA603AB.6070809@free.fr> <4BAE810A.6030405@free.fr> <20100503210726.66a41c01@pedra> In-Reply-To: <20100503210726.66a41c01@pedra> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 05 May 2010 18:59:32 +0000 (UTC) diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c index 55ea260..6932def 100644 --- a/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb/dvb-core/dvb_frontend.c @@ -95,6 +95,10 @@ MODULE_PARM_DESC(dvb_mfe_wait_time, "Wait up to seconds on open( * FESTATE_LOSTLOCK. When the lock has been lost, and we're searching it again. */ +#define DVB_FE_NO_EXIT 0 +#define DVB_FE_NORMAL_EXIT 1 +#define DVB_FE_DEVICE_REMOVED 2 + static DEFINE_MUTEX(frontend_mutex); struct dvb_frontend_private { @@ -497,7 +501,7 @@ static int dvb_frontend_is_exiting(struct dvb_frontend *fe) { struct dvb_frontend_private *fepriv = fe->frontend_priv; - if (fepriv->exit) + if (fepriv->exit != DVB_FE_NO_EXIT) return 1; if (fepriv->dvbdev->writers == 1) @@ -559,7 +563,7 @@ restart: if (kthread_should_stop() || dvb_frontend_is_exiting(fe)) { /* got signal or quitting */ - fepriv->exit = 1; + fepriv->exit = DVB_FE_NORMAL_EXIT; break; } @@ -673,7 +677,10 @@ restart: } fepriv->thread = NULL; - fepriv->exit = 0; + if (kthread_should_stop()) + fepriv->exit = DVB_FE_DEVICE_REMOVED; + else + fepriv->exit = DVB_FE_NO_EXIT; mb(); dvb_frontend_wakeup(fe); @@ -686,7 +693,7 @@ static void dvb_frontend_stop(struct dvb_frontend *fe) dprintk ("%s\n", __func__); - fepriv->exit = 1; + fepriv->exit = DVB_FE_NORMAL_EXIT; mb(); if (!fepriv->thread) @@ -755,7 +762,7 @@ static int dvb_frontend_start(struct dvb_frontend *fe) dprintk ("%s\n", __func__); if (fepriv->thread) { - if (!fepriv->exit) + if (fepriv->exit == DVB_FE_NO_EXIT) return 0; else dvb_frontend_stop (fe); @@ -767,7 +774,7 @@ static int dvb_frontend_start(struct dvb_frontend *fe) return -EINTR; fepriv->state = FESTATE_IDLE; - fepriv->exit = 0; + fepriv->exit = DVB_FE_NO_EXIT; fepriv->thread = NULL; mb(); @@ -1490,7 +1497,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file, dprintk("%s (%d)\n", __func__, _IOC_NR(cmd)); - if (fepriv->exit) + if (fepriv->exit != DVB_FE_NO_EXIT) return -ENODEV; if ((file->f_flags & O_ACCMODE) == O_RDONLY && @@ -1916,6 +1923,8 @@ static int dvb_frontend_open(struct inode *inode, struct file *file) int ret; dprintk ("%s\n", __func__); + if (fepriv->exit == DVB_FE_DEVICE_REMOVED) + return -ENODEV; if (adapter->mfe_shared) { mutex_lock (&adapter->mfe_lock); @@ -2008,7 +2017,7 @@ static int dvb_frontend_release(struct inode *inode, struct file *file) ret = dvb_generic_release (inode, file); if (dvbdev->users == -1) { - if (fepriv->exit == 1) { + if (fepriv->exit != DVB_FE_NO_EXIT) { fops_put(file->f_op); file->f_op = NULL; wake_up(&dvbdev->wait_queue);