From video4linux-list-admin#redhat.com Wed Jan 8 10:59:21 2003 Received: from listman.redhat.com (listman.redhat.com [66.187.233.211]) by ee.oulu.fi (8.11.6/8.11.6) with ESMTP id h088xI710605; Wed, 8 Jan 2003 10:59:19 +0200 (EET) Received: from listman.redhat.com (localhost.localdomain [127.0.0.1]) by listman.redhat.com (Postfix) with ESMTP id D14163EF91; Wed, 8 Jan 2003 03:59:10 -0500 (EST) Delivered-To: video4linux-list#listman.redhat.com Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.redhat.com (Postfix) with ESMTP id CD1AF3F1BC for ; Wed, 8 Jan 2003 03:57:47 -0500 (EST) Received: (from mail#localhost) by int-mx1.corp.redhat.com (8.11.6/8.11.6) id h088vlS10855 for video4linux-list#listman.redhat.com; Wed, 8 Jan 2003 03:57:47 -0500 Received: from mx1.redhat.com (mx1.redhat.com [172.16.48.31]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with SMTP id h088vla10851 for ; Wed, 8 Jan 2003 03:57:47 -0500 Received: from mtiwmhc12.worldnet.att.net (mtiwmhc12.worldnet.att.net [204.127.131.116]) by mx1.redhat.com (8.11.6/8.11.6) with SMTP id h088U6B07487 for ; Wed, 8 Jan 2003 03:30:06 -0500 Received: from athlon ([12.89.132.39]) by mtiwmhc12.worldnet.att.net (InterMail vM.5.01.05.xx 201-253-122-126-xxx-20020920) with ESMTP id <20030108085740.QCUJ12564.mtiwmhc12.worldnet.att.net#athlon>; Wed, 8 Jan 2003 08:57:40 +0000 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 Message-ID: X-Mailer: XFMail 1.5.3 on Linux X-Priority: 3 (Normal) In-Reply-To: From: Duncan Haldane To: Gerd Knorr , video4linux-list#redhat.com Subject: Re: Are *all* 2.4.x v4l drivers now broken? X-Loop: video4linux-list#redhat.com Sender: video4linux-list-admin#redhat.com Errors-To: video4linux-list-admin#redhat.com X-BeenThere: video4linux-list#redhat.com X-Mailman-Version: 2.0.1 Precedence: bulk Reply-To: video4linux-list#redhat.com List-Help: List-Post: List-Subscribe: , List-Id: Linux and Kernel Video List-Unsubscribe: , List-Archive: Date: Wed, 08 Jan 2003 03:57:33 -0500 (EST) X-Spam-Status: No, hits=-8.3 required=5.0 tests=IN_REP_TO,SUBJ_ENDS_IN_Q_MARK,UNIFIED_PATCH,MAILTO_WITH_SUBJ version=2.11 Status: R X-Status: X-Keywords: Hi I tested Gerd's patch to fix the deadlock when old-v4l-interface drivers get hot unplugged -- It doesn't quite do the job because vfl->owner can't get its module count decreased if vfl=NULL after the cleanup. The solution is to store a pointer to vfl->owner before calling vfl->close, then later do a __MOD_DEC_USE_COUNT with it, rather than with vfl->owner, which may be history. I attach a (I think) corrected patch. (tested). I basically need this patch for RedHat 7.x and 8.0 2.4.18 kernels which already have the new v4l interface that appeared only officially in 2.4.19, but have it in a broken form, so its unusable, and the old interface must be still be used. (This is for an improved version of the cpia driver that users can substitute for their Official Kernel one, and which will only use the new interface in 2.4.19 or later kernels.) (Hopefully the 2.4.21 kernel can get all the improvements in the cpia driver, so this type of maintenance can end ...) This patch is *definitely* needed for all those drivers which are not updated to use the new V4L interface. It's tested against various sequences of hot_unplugging multiple cameras. Duncan. diff -uNr linux-2.4.20/drivers/media/video/videodev.c linux-2.4.20-videodev_fix/drivers/media/video/videodev.c --- linux-2.4.20/drivers/media/video/videodev.c Sun Sep 29 19:31:52 2002 +++ linux-2.4.20-videodev_fix/drivers/media/video/videodev.c Wed Jan 8 03:11:25 2003 ## -186,14 +186,20 ## static int video_release(struct inode *inode, struct file *file) { struct video_device *vfl; + struct module *owner; - down(&videodev_lock); vfl = video_devdata(file); - if(vfl->close) + owner = vfl->owner; + if(vfl->close) vfl->close(vfl); - vfl->users--; - if(vfl->owner) - __MOD_DEC_USE_COUNT(vfl->owner); + + down(&videodev_lock); + /* ->close() might have called video_device_unregister() + in case of a hot unplug, thus we have to get vfl again */ + if (vfl = video_devdata(file)) + vfl->users--; + if (owner) + __MOD_DEC_USE_COUNT(owner); up(&videodev_lock); return 0; } On 10-Dec-2002 Gerd Knorr wrote: > Duncan Haldane wrote: >> Hi, >> >> continuing my investigation of the effects of the lock added to >> video_unregister_device() in 2.4.19, I got reports of yet more >> drivers that are broken in a way that is fatal to the system if the >> camera is disconnected while open. >> > > The patch below hopefully fixes that without creating new holes. > Comments? > > Gerd > > ==============================[ cut here ]============================== > --- videodev.c.lock 2002-12-10 11:06:04.000000000 +0100 > +++ videodev.c 2002-12-10 11:21:44.000000000 +0100 > ## -187,13 +187,19 ## > { > struct video_device *vfl; > > - down(&videodev_lock); > vfl = video_devdata(file); > if(vfl->close) > vfl->close(vfl); > - vfl->users--; > - if(vfl->owner) > - __MOD_DEC_USE_COUNT(vfl->owner); > + > + down(&videodev_lock); > + /* ->close() might have called video_device_unregister() > + in case of a hot unplug, thus we have to get vfl again */ > + vfl = video_devdata(file); > + if (NULL != vfl) { > + vfl->users--; > + if(vfl->owner) > + __MOD_DEC_USE_COUNT(vfl->owner); > + } > up(&videodev_lock); > return 0; > } > > > > -- > video4linux-list mailing list > Unsubscribe mailto:video4linux-list-request#redhat.com?subject=unsubscribe > https://listman.redhat.com/mailman/listinfo/video4linux-list ---------------------------------- E-Mail: Duncan Haldane Date: 08-Jan-2003 Time: 03:21:59 This message was sent by XFMail ---------------------------------- -- video4linux-list mailing list Unsubscribe mailto:video4linux-list-request#redhat.com?subject=unsubscribe https://listman.redhat.com/mailman/listinfo/video4linux-list