Skip to contentSkip to conversation

changed ioctls to unlocked

PATCH Applied [email protected] 3 participants 5 messages Mar 24, 2009 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 12/13 changed ioctls to unlocked

From: Stoyan Gaydarov <[email protected]>

---
 drivers/media/dvb/bt8xx/dst_ca.c |    7 +++++--
 drivers/media/video/dabusb.c     |   11 ++++++++---
 2 files changed, 13 insertions(+), 5 deletions(-)
drivers/media/dvb/bt8xx/dst_ca.c +5 -2
index 0258451..d3487c5 100644
@@ -552,8 +552,10 @@ free_mem_and_exit:
 	return result;
 }
 
-static int dst_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long ioctl_arg)
+static long dst_ca_ioctl(struct file *file, unsigned int cmd, unsigned long ioctl_arg)
 {
+	lock_kernel();
+
 	struct dvb_device* dvbdev = (struct dvb_device*) file->private_data;
 	struct dst_state* state = (struct dst_state*) dvbdev->priv;
 	struct ca_slot_info *p_ca_slot_info;
@@ -647,6 +649,7 @@ static int dst_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd
 	kfree (p_ca_slot_info);
 	kfree (p_ca_caps);
 
+	unlock_kernel();
 	return result;
 }
 
@@ -684,7 +687,7 @@ static ssize_t dst_ca_write(struct file *file, const char __user *buffer, size_t
 
 static struct file_operations dst_ca_fops = {
 	.owner = THIS_MODULE,
-	.ioctl = dst_ca_ioctl,
+	.unlocked_ioctl = dst_ca_ioctl,
 	.open = dst_ca_open,
 	.release = dst_ca_release,
 	.read = dst_ca_read,
drivers/media/video/dabusb.c +8 -3
index 298810d..c31e76f 100644
@@ -657,22 +657,26 @@ static int dabusb_release (struct inode *inode, struct file *file)
 	return 0;
 }
 
-static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static long dabusb_ioctl (struct file *file, unsigned int cmd, unsigned long arg)
 {
 	pdabusb_t s = (pdabusb_t) file->private_data;
 	pbulk_transfer_t pbulk;
 	int ret = 0;
 	int version = DABUSB_VERSION;
 
+	lock_kernel();
 	dbg("dabusb_ioctl");
 
-	if (s->remove_pending)
+	if (s->remove_pending) {
+		unlock_kernel();
 		return -EIO;
+	}
 
 	mutex_lock(&s->mutex);
 
 	if (!s->usbdev) {
 		mutex_unlock(&s->mutex);
+		unlock_kernel();
 		return -EIO;
 	}
 
@@ -713,6 +717,7 @@ static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cm
 		break;
 	}
 	mutex_unlock(&s->mutex);
+	unlock_kernel();
 	return ret;
 }
 
@@ -721,7 +726,7 @@ static const struct file_operations dabusb_fops =
 	.owner =	THIS_MODULE,
 	.llseek =	no_llseek,
 	.read =		dabusb_read,
-	.ioctl =	dabusb_ioctl,
+	.unlocked_ioctl =	dabusb_ioctl,
 	.open =		dabusb_open,
 	.release =	dabusb_release,
 };
Signature · 1 line
1.6.2.1
#1 lore raw

Hello, Stoyan

Quoted 75 lines · On Tue, 2009-03-24 at 16:38 -0500, [email protected] wrote:

From: Stoyan Gaydarov <[email protected]>

---
 drivers/media/dvb/bt8xx/dst_ca.c |    7 +++++--
 drivers/media/video/dabusb.c     |   11 ++++++++---
 2 files changed, 13 insertions(+), 5 deletions(-)
drivers/media/dvb/bt8xx/dst_ca.c +5 -2
index 0258451..d3487c5 100644
@@ -552,8 +552,10 @@ free_mem_and_exit:
 	return result;
 }
 
-static int dst_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long ioctl_arg)
+static long dst_ca_ioctl(struct file *file, unsigned int cmd, unsigned long ioctl_arg)
 {
+	lock_kernel();
+
 	struct dvb_device* dvbdev = (struct dvb_device*) file->private_data;
 	struct dst_state* state = (struct dst_state*) dvbdev->priv;
 	struct ca_slot_info *p_ca_slot_info;
@@ -647,6 +649,7 @@ static int dst_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd
 	kfree (p_ca_slot_info);
 	kfree (p_ca_caps);
 
+	unlock_kernel();
 	return result;
 }
 
@@ -684,7 +687,7 @@ static ssize_t dst_ca_write(struct file *file, const char __user *buffer, size_t
 
 static struct file_operations dst_ca_fops = {
 	.owner = THIS_MODULE,
-	.ioctl = dst_ca_ioctl,
+	.unlocked_ioctl = dst_ca_ioctl,
 	.open = dst_ca_open,
 	.release = dst_ca_release,
 	.read = dst_ca_read,
drivers/media/video/dabusb.c +6 -2
index 298810d..c31e76f 100644
@@ -657,22 +657,26 @@ static int dabusb_release (struct inode *inode, struct file *file)
 	return 0;
 }
 
-static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static long dabusb_ioctl (struct file *file, unsigned int cmd, unsigned long arg)
 {
 	pdabusb_t s = (pdabusb_t) file->private_data;
 	pbulk_transfer_t pbulk;
 	int ret = 0;
 	int version = DABUSB_VERSION;
 
+	lock_kernel();
 	dbg("dabusb_ioctl");
 
-	if (s->remove_pending)
+	if (s->remove_pending) {
+		unlock_kernel();
 		return -EIO;
+	}
 
 	mutex_lock(&s->mutex);
 
 	if (!s->usbdev) {
 		mutex_unlock(&s->mutex);
+		unlock_kernel();
 		return -EIO;
 	}
 

drivers/media/video/dabusb.c static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cm · line 720

Quoted 4 lines
drivers/media/video/dabusb.c +1 -0
@@ -713,6 +717,7 @@ static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cm
 		break;
 	}
 	mutex_unlock(&s->mutex);
+	unlock_kernel();

May i ask why big kernel lock is used here?
Where is an advantage of BKL here?
Why not to use, for example, one more mutex lock?

Signature · 1 line
Best regards, Klimov Alexey
#2 lore raw
Quoted 77 lines · Alexey Klimov

Hello, Stoyan

Quoted 74 lines · On Tue, 2009-03-24 at 16:38 -0500, [email protected] wrote:

From: Stoyan Gaydarov <[email protected]>

---
 drivers/media/dvb/bt8xx/dst_ca.c |    7 +++++-- drivers/media/video/dabusb.c     |   11 ++++++++---

 2 files changed, 13 insertions(+), 5 deletions(-)
drivers/media/dvb/bt8xx/dst_ca.c +5 -2
index 0258451..d3487c5 100644
@@ -552,8 +552,10 @@ free_mem_and_exit:
       return result;
  }
 
-static int dst_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long ioctl_arg)
+static long dst_ca_ioctl(struct file *file, unsigned int cmd, unsigned long ioctl_arg)
  {
+     lock_kernel();
+
       struct dvb_device* dvbdev = (struct dvb_device*) file->private_data;
       struct dst_state* state = (struct dst_state*) dvbdev->priv;
       struct ca_slot_info *p_ca_slot_info;
@@ -647,6 +649,7 @@ static int dst_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd
       kfree (p_ca_slot_info);
       kfree (p_ca_caps);
 
+     unlock_kernel();
       return result;
  }
 
@@ -684,7 +687,7 @@ static ssize_t dst_ca_write(struct file *file, const char __user *buffer, size_t
 
  static struct file_operations dst_ca_fops = {
       .owner = THIS_MODULE,
-     .ioctl = dst_ca_ioctl,
+     .unlocked_ioctl = dst_ca_ioctl,
       .open = dst_ca_open,
       .release = dst_ca_release,
       .read = dst_ca_read,
drivers/media/video/dabusb.c +6 -2
index 298810d..c31e76f 100644
@@ -657,22 +657,26 @@ static int dabusb_release (struct inode *inode, struct file *file)
       return 0;
  }
 
-static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static long dabusb_ioctl (struct file *file, unsigned int cmd, unsigned long arg)
  {
       pdabusb_t s = (pdabusb_t) file->private_data;
       pbulk_transfer_t pbulk;
       int ret = 0;
       int version = DABUSB_VERSION;
 
+     lock_kernel();
       dbg("dabusb_ioctl");
 
-     if (s->remove_pending)
+     if (s->remove_pending) {
+             unlock_kernel();
               return -EIO;
+     }
 
       mutex_lock(&s->mutex);
 
       if (!s->usbdev) {
               mutex_unlock(&s->mutex);
+             unlock_kernel();
               return -EIO;
       }
 
Quoted 9 lines

drivers/media/video/dabusb.c static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cm · line 720

Quoted 5 lines
drivers/media/video/dabusb.c +1 -0
@@ -713,6 +717,7 @@ static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cm
               break;
       }
       mutex_unlock(&s->mutex);
+     unlock_kernel();

May i ask why big kernel lock is used here?
Where is an advantage of BKL here?
Why not to use, for example, one more mutex lock?

The big kernel lock was already being used here, the call to ioctl is surrounded by lock/unlock kernel, this patch just pushes it down so that the __locked__ ioctl can be removed and also makes the maintainers of the code aware that the lock was there. If the lock is not needed then it can be removed and the function can remain under the unlocked_ioctl.

Quoted 5 lines

--
Best regards, Klimov Alexey

Signature · 1 line
-Stoyan
#3 lore raw
In reply to [email protected]

Hi Stoyan,

Quoted 22 lines

-----Original Message-----
From: [email protected] [mailto:linux-media- [email protected]] On Behalf Of [email protected]
Sent: Tuesday, March 24, 2009 3:39 PM
To: [email protected]
Cc: Stoyan Gaydarov; [email protected]
Subject: [PATCH 12/13][Resubmit][drivers/media] changed ioctls to unlocked

From: Stoyan Gaydarov <[email protected]>

---
 drivers/media/dvb/bt8xx/dst_ca.c |    7 +++++--
 drivers/media/video/dabusb.c     |   11 ++++++++---
 2 files changed, 13 insertions(+), 5 deletions(-)
drivers/media/dvb/bt8xx/dst_ca.c +0 -0
index 0258451..d3487c5 100644

drivers/media/dvb/bt8xx/dst_ca.c free_mem_and_exit: · line 560

Quoted 10 lines
drivers/media/dvb/bt8xx/dst_ca.c +3 -1
@@ -552,8 +552,10 @@ free_mem_and_exit:
 	return result;
 }
 
-static int dst_ca_ioctl(struct inode *inode, struct file *file, unsigned
 int cmd, unsigned long ioctl_arg)
+static long dst_ca_ioctl(struct file *file, unsigned int cmd, unsigned
 long ioctl_arg)
 {
+	lock_kernel();
+

Why moving to unlocked_ioctl if you're acquiring the Big Kernel Lock anyways?

#4 lore raw
Quoted 6 lines

drivers/media/dvb/bt8xx/dst_ca.c free_mem_and_exit: · line 558

Quoted 3 lines

{

drivers/media/dvb/bt8xx/dst_ca.c +2 -0
+	lock_kernel();
+

Why moving to unlocked_ioctl if you're acquiring the Big Kernel Lock anyways?

Ok, forget it, just saw Alexey mail chain...

Understood.

Regards,
Sergio