Skip to contentSkip to conversation

linux-2.6.15-rc7/drivers/pci/syscall.c

KJ carlos neira 4 participants 7 messages Jan 9, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Greetings :

patch :linux-2.6.15-rc7/drivers/pci/syscall.c

replaced a lock_kernel with spinlocks , compile tested ok

Signature · 3 lines
"Employ your time in improving yourself by other men's writings, so that you 
shall gain easily what others have labored hard for."
Socrates
home/cneira/Linuxjanitoring/linux-janitorpatching/drivers/pci/syscall.c renamed from usr/src/linux-2.6.15-rc7/drivers/pci/syscall.c +7 -5
diff -urN /usr/src/linux-2.6.15-rc7/drivers/pci/syscall.c /home/cneira/Linuxjanitoring/linux-janitorpatching/drivers/pci/syscall.c
@@ -11,6 +11,7 @@
 #include <linux/errno.h>
 #include <linux/pci.h>
 #include <linux/smp_lock.h>
+#include <linux/spinlock.h>
 #include <linux/syscalls.h>
 #include <asm/uaccess.h>
 #include "pci.h"
@@ -21,6 +22,7 @@
 		   void __user *buf)
 {
 	struct pci_dev *dev;
+
 	u8 byte;
 	u16 word;
 	u32 dword;
@@ -35,7 +37,7 @@
 	if (!dev)
 		goto error;
 
-	lock_kernel();
+	spin_lock(&pciconfig_read_lock)
 	switch (len) {
 	case 1:
 		cfg_ret = pci_user_read_config_byte(dev, off, &byte);
@@ -48,10 +50,10 @@
 		break;
 	default:
 		err = -EINVAL;
-		unlock_kernel();
+		spin_unlock(&pciconfig_read_lock);
 		goto error;
 	};
-	unlock_kernel();
+	spin_unlock(&pciconfig_read_lock);
 
 	err = -EIO;
 	if (cfg_ret != PCIBIOS_SUCCESSFUL)
@@ -106,7 +108,7 @@
 	if (!dev)
 		return -ENODEV;
 
-	lock_kernel();
+	spin_lock(&pciconfig_write_lock)
 	switch(len) {
 	case 1:
 		err = get_user(byte, (u8 __user *)buf);
@@ -139,7 +141,7 @@
 		err = -EINVAL;
 		break;
 	};
-	unlock_kernel();
+	spin_unlock(&pciconfig_write_lock)
 
 	return err;
 }

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#3 lore raw
In reply to carlos neira
Quoted 11 lines · Greg KH
Quoted 5 lines · carlos neira

Greetings :

patch :linux-2.6.15-rc7/drivers/pci/syscall.c

replaced a lock_kernel with spinlocks , compile tested ok

What arch did you compile this for?

And why remove the lock_kernel calls here, are they hurting anything?

I can't comment on the specific patch, but in general I thought we wanted to get rid of lock_kernel() / unlock_kernel() over time? If that is indeed the case, then patches like this one are a step in the right direction - no?

--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#4 lore raw
In reply to carlos neira
Quoted 8 lines · Jesper Juhl
Quoted 7 lines · Greg KH
Quoted 5 lines · carlos neira

Greetings :

patch :linux-2.6.15-rc7/drivers/pci/syscall.c

replaced a lock_kernel with spinlocks , compile tested ok

Quoted 8 lines
Quoted 4 lines

What arch did you compile this for?

And why remove the lock_kernel calls here, are they hurting anything?

I can't comment on the specific patch, but in general I thought we wanted to get rid of lock_kernel() / unlock_kernel() over time? If that is indeed the case, then patches like this one are a step in the right direction - no?

"over time, if it makes sense to do so."

For this specific example, the code should be converted to the kthread api, which would remove these instances.

thanks,

greg k-h

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#5 lore raw
In reply to carlos neira
Quoted 9 lines · Greg KH
Quoted 8 lines · Jesper Juhl
Quoted 7 lines · Greg KH
Quoted 5 lines · carlos neira

Greetings :

patch :linux-2.6.15-rc7/drivers/pci/syscall.c

replaced a lock_kernel with spinlocks , compile tested ok

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

What arch did you compile this for?

And why remove the lock_kernel calls here, are they hurting anything?

"over time, if it makes sense to do so."

For this specific example, the code should be converted to the kthread api, which would remove these instances.

I think you're confused with which patch is being commented on. The locks around daemonize() should be converted to kthread(), but this patch is for the PCI syscalls. As I said in a recent post to linux-pci, I think they can be deleted without bad effect.

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#6 lore raw
In reply to carlos neira
Quoted 16 lines · Matthew Wilcox
Quoted 15 lines · Greg KH
Quoted 11 lines · Jesper Juhl
Quoted 10 lines · Greg KH
Quoted 5 lines · carlos neira

Greetings :

patch :linux-2.6.15-rc7/drivers/pci/syscall.c

replaced a lock_kernel with spinlocks , compile tested ok

What arch did you compile this for?

And why remove the lock_kernel calls here, are they hurting anything?

"over time, if it makes sense to do so."

Quoted 7 lines
Quoted 2 lines

For this specific example, the code should be converted to the kthread api, which would remove these instances.

I think you're confused with which patch is being commented on. The locks around daemonize() should be converted to kthread(), but this patch is for the PCI syscalls. As I said in a recent post to linux-pci, I think they can be deleted without bad effect.

Ugh, yeah, sorry, -ETOOMANYPATCHES

And yes, I think they can probably be deleted, but not replaced with a spinlock like was done here.

thanks,

greg k-h

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors