tm6000: don't use BKL at the driver
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/4 tm6000: don't use BKL at the driver
Instead, use core lock handling.
Signed-off-by Mauro Carvalho Chehab <[email protected]>
drivers/staging/tm6000/tm6000-cards.c +0 -3
@@ -909,8 +909,6 @@ static void tm6000_usb_disconnect(struct usb_interface *interface)printk (KERN_INFO "tm6000: disconnecting %s\n" , dev->name); -mutex_lock (&dev->lock); -tm6000_ir_fini (dev);if (dev->gpio.power_led) {
@@ -945,7 +943,6 @@ static void tm6000_usb_disconnect(struct usb_interface *interface)tm6000_close_extension (dev);tm6000_remove_from_devlist (dev); -mutex_unlock (&dev->lock);kfree (dev); }
drivers/staging/tm6000/tm6000-core.c +0 -2
@@ -326,10 +326,8 @@ int tm6000_init_analog_mode(struct tm6000_core *dev)/*FIXME: Hack!!! */ struct v4l2_frequency f; -mutex_lock (&dev->lock); f.frequency = dev->freq;v4l2_device_call_all (&dev->v4l2_dev,0 , tuner, s_frequency, &f); -mutex_unlock (&dev->lock);msleep (100 );tm6000_set_standard (dev, &dev->norm);
drivers/staging/tm6000/tm6000-video.c +7 -14
@@ -791,16 +791,11 @@ static struct videobuf_queue_ops tm6000_video_qops = {static int res_get (struct tm6000_core *dev,struct tm6000_fh *fh) {/* is it free? */ -mutex_lock (&dev->lock); -if (dev->resources) { -/* no, someone else uses it */ -mutex_unlock (&dev->lock); +if (dev->resources)return 0 ; - }/* it's free, grab it */ dev->resources =1 ;dprintk (dev,V4L2_DEBUG_RES_LOCK ,"res: get\n" ); -mutex_unlock (&dev->lock);return 1 ; }
@@ -811,10 +806,8 @@ static int res_locked(struct tm6000_core *dev)static void res_free (struct tm6000_core *dev,struct tm6000_fh *fh) { -mutex_lock (&dev->lock); dev->resources =0 ;dprintk (dev,V4L2_DEBUG_RES_LOCK ,"res: put\n" ); -mutex_unlock (&dev->lock); }/* ------------------------------------------------------------------
@@ -1229,10 +1222,8 @@ static int vidioc_s_frequency (struct file *file, void *priv,if (unlikely (f->tuner !=0 ))return -EINVAL ; -// mutex_lock(&dev->lock); dev->freq = f->frequency;v4l2_device_call_all (&dev->v4l2_dev,0 , tuner, s_frequency, f); -// mutex_unlock(&dev->lock); return 0 ; }
@@ -1308,7 +1299,7 @@ static int tm6000_open(struct file *file)NULL , &dev->slock, fh->type,V4L2_FIELD_INTERLACED , - sizeof(struct tm6000_buffer), fh, NULL); + sizeof(struct tm6000_buffer), fh, &dev->lock);return 0 ; }
@@ -1389,7 +1380,7 @@ static struct v4l2_file_operations tm6000_fops = { .owner = THIS_MODULE, .open = tm6000_open, .release = tm6000_release, - .ioctl = video_ioctl2, /* V4L2 ioctl handler */ + .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */ .read = tm6000_read, .poll = tm6000_poll, .mmap = tm6000_mmap,
@@ -1451,8 +1442,10 @@ int tm6000_v4l2_register(struct tm6000_core *dev)INIT_LIST_HEAD (&dev->vidq.active);INIT_LIST_HEAD (&dev->vidq.queued); -memcpy (dev->vfd, &tm6000_template,sizeof (*(dev->vfd))); - dev->vfd->debug=tm6000_debug; +memcpy (dev->vfd, &tm6000_template,sizeof (*(dev->vfd))); + dev->vfd->debug = tm6000_debug; + dev->vfd->lock = &dev->lock; + vfd->v4l2_dev = &dev->v4l2_dev;video_set_drvdata (vfd, dev);
Signature · 1 line
1.7.1
PATCH 2/4 V4L/DVB: tm6000-alsa: fix some locking issues
In reply to a message not in the archiveThose locking issues affect tvtime, causing a kernel oops/panic, due to a race condition.
Signed-off-by Mauro Carvalho Chehab <[email protected]>
drivers/media/video/cx231xx/cx231xx-cards.c +2 -0
@@ -462,6 +462,8 @@ struct usb_device_id cx231xx_id_table[] = { .driver_info = CX231XX_BOARD_HAUPPAUGE_USBLIVE2}, {USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x4000, 0x4001), .driver_info = CX231XX_BOARD_PV_PLAYTV_USB_HYBRID}, + {USB_DEVICE(0x1b80, 0xe424), + .driver_info = CX231XX_BOARD_PV_PLAYTV_USB_HYBRID}, {}, };
drivers/staging/tm6000/tm6000-alsa.c +37 -9
93 lines not on this page · raw message
drivers/staging/tm6000/tm6000.h +3 -0
@@ -205,6 +205,9 @@ struct tm6000_core {/* audio support */ struct snd_tm6000_card *adev; +struct work_struct wq_trigger;/* Trigger to start/stop audio for alsa module */ +atomic_t stream_started;/* stream should be running if true */ +struct tm6000_IR *ir;
Signature · 1 line
1.7.1
PATCH 3/4 V4L/DVB: Use just one lock for devlist
In reply to a message not in the archiveThis avoids a race condition
Signed-off-by Mauro Carvalho Chehab <[email protected]>
drivers/staging/tm6000/tm6000-core.c +4 -9
@@ -657,7 +657,6 @@ void tm6000_add_into_devlist(struct tm6000_core *dev)*/ static LIST_HEAD (tm6000_extension_devlist); -static DEFINE_MUTEX (tm6000_extension_devlist_lock);int tm6000_call_fillbuf (struct tm6000_core *dev,enum tm6000_ops_type type,char *buf,int size)
@@ -681,14 +680,12 @@ int tm6000_register_extension(struct tm6000_ops *ops)struct tm6000_core *dev =NULL ;mutex_lock (&tm6000_devlist_mutex); -mutex_lock (&tm6000_extension_devlist_lock);list_add_tail (&ops->next, &tm6000_extension_devlist);list_for_each_entry (dev, &tm6000_devlist, devlist) { ops->init (dev);printk (KERN_INFO "%s: Initialized (%s) extension\n" , dev->name, ops->name); } -mutex_unlock (&tm6000_extension_devlist_lock);mutex_unlock (&tm6000_devlist_mutex);return 0 ; }
@@ -704,10 +701,8 @@ void tm6000_unregister_extension(struct tm6000_ops *ops) ops->fini (dev); } -mutex_lock (&tm6000_extension_devlist_lock);printk (KERN_INFO "tm6000: Remove (%s) extension\n" , ops->name);list_del (&ops->next); -mutex_unlock (&tm6000_extension_devlist_lock);mutex_unlock (&tm6000_devlist_mutex); }EXPORT_SYMBOL (tm6000_unregister_extension);
@@ -716,26 +711,26 @@ void tm6000_init_extension(struct tm6000_core *dev) {struct tm6000_ops *ops =NULL ; -mutex_lock (&tm6000_extension_devlist_lock); +mutex_lock (&tm6000_devlist_mutex);if (!list_empty (&tm6000_extension_devlist)) {list_for_each_entry (ops, &tm6000_extension_devlist, next) {if (ops->init) ops->init (dev); } } -mutex_unlock (&tm6000_extension_devlist_lock); +mutex_unlock (&tm6000_devlist_mutex); }void tm6000_close_extension (struct tm6000_core *dev) {struct tm6000_ops *ops =NULL ; -mutex_lock (&tm6000_extension_devlist_lock); +mutex_lock (&tm6000_devlist_mutex);if (!list_empty (&tm6000_extension_devlist)) {list_for_each_entry (ops, &tm6000_extension_devlist, next) {if (ops->fini) ops->fini (dev); } } -mutex_unlock (&tm6000_extension_devlist_lock); +mutex_lock (&tm6000_devlist_mutex); }
Signature · 1 line
1.7.1
PATCH 4/4 V4L/DVB: tm6000: fix resource locking
In reply to a message not in the archiveSigned-off-by Mauro Carvalho Chehab <[email protected]>
drivers/staging/tm6000/tm6000-video.c +42 -14
@@ -788,25 +788,49 @@ static struct videobuf_queue_ops tm6000_video_qops = {IOCTL handling ------------------------------------------------------------------*/ -static int res_get (struct tm6000_core *dev,struct tm6000_fh *fh) +static bool is_res_read (struct tm6000_core *dev,struct tm6000_fh *fh) { +/* Is the current fh handling it? if so, that's OK */ +if (dev->resources == fh && dev->is_res_read) +return true; + +return false; +} + +static bool is_res_streaming (struct tm6000_core *dev,struct tm6000_fh *fh) +{ +/* Is the current fh handling it? if so, that's OK */ +if (dev->resources == fh) +return true; + +return false; +} + +static bool res_get (struct tm6000_core *dev,struct tm6000_fh *fh, +bool is_res_read) +{ +/* Is the current fh handling it? if so, that's OK */ +if (dev->resources == fh && dev->is_res_read == is_res_read) +return true; +/* is it free? */ if (dev->resources) -return 0 ; -/* it's free, grab it */ - dev->resources =1 ; +return false; + +/* grab it */ + dev->resources = fh; + dev->is_res_read = is_res_read;dprintk (dev,V4L2_DEBUG_RES_LOCK ,"res: get\n" ); -return 1 ; -} - -static int res_locked (struct tm6000_core *dev) -{ -return (dev->resources); +return true; }static void res_free (struct tm6000_core *dev,struct tm6000_fh *fh) { - dev->resources =0 ; +/* Is the current fh handling it? if so, that's OK */ +if (dev->resources != fh) +return ; + + dev->resources =NULL ;dprintk (dev,V4L2_DEBUG_RES_LOCK ,"res: put\n" ); }
@@ -981,7 +1005,7 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)if (i != fh->type)return -EINVAL ; -if (!res_get (dev,fh)) +if (!res_get (dev, fh, false))return -EBUSY ;return (videobuf_streamon (&fh->vb_vidq)); }
@@ -1310,7 +1334,7 @@ tm6000_read(struct file *file, char __user *data, size_t count, loff_t *pos)struct tm6000_fh *fh = file->private_data;if (fh->type==V4L2_BUF_TYPE_VIDEO_CAPTURE ) { -if (res_locked (fh->dev)) +if (!res_get (fh->dev, fh, true))return -EBUSY ; return videobuf_read_stream(&fh->vb_vidq, data, count, pos, 0,
@@ -1328,7 +1352,10 @@ tm6000_poll(struct file *file, struct poll_table_struct *wait)if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type)return POLLERR ; -if (res_get (fh->dev,fh)) { +if (!!is_res_streaming (fh->dev, fh)) +return POLLERR ; + +if (!is_res_read (fh->dev, fh)) {/* streaming capture */ if (list_empty (&fh->vb_vidq.stream))return POLLERR ;
@@ -1356,6 +1383,7 @@ static int tm6000_release(struct file *file) dev->users--; +res_free (dev, fh);if (!dev->users) {tm6000_uninit_isoc (dev);videobuf_mmap_free (&fh->vb_vidq);
drivers/staging/tm6000/tm6000.h +3 -1
@@ -189,7 +189,9 @@ struct tm6000_core {int users;/* various device info */ -unsigned int resources; +struct tm6000_fh *resources;/* Points to fh that is streaming */ +bool is_res_read; +struct video_device *vfd;struct tm6000_dmaqueue vidq;struct v4l2_device v4l2_dev;
Signature · 1 line
1.7.1