Skip to contentSkip to conversation

mxser: PCI refcounts

PATCH In review Alan Cox 2 participants 4 messages Sep 15, 2006 – Sep 16, 2006

Subsystems (2)
lore
Share & tools
lore

Alan Cox

author
#0 lore raw

PATCH 1/1 mxser: PCI refcounts

Switch to pci ref counts for mxser when handling PCI devices. Use pci_get_device and drop the reference when we finish and unload.

drivers/char/mxser.c +6 -2
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.18-rc6-mm1/drivers/char/mxser.c linux-2.6.18-rc6-mm1/drivers/char/mxser.c
@@ -538,6 +538,7 @@
 			if (pdev != NULL) {	/* PCI */
 				release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2));
 				release_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3));
+				pci_dev_put(pdev);
 			} else {
 				release_region(mxsercfg[i].ioaddr[0], 8 * mxsercfg[i].ports);
 				release_region(mxsercfg[i].vector, 1);
@@ -862,9 +865,9 @@
 	index = 0;
 	b = 0;
 	while (b < n) {
-		pdev = pci_find_device(mxser_pcibrds[b].vendor,
+		pdev = pci_get_device(mxser_pcibrds[b].vendor,
 				mxser_pcibrds[b].device, pdev);
-			if (pdev == NULL) {
+		if (pdev == NULL) {
 			b++;
 			continue;
 		}
@@ -916,6 +919,9 @@
 			if (mxser_initbrd(m, &hwconf) < 0)
 				continue;
 			m++;
+			/* Keep an extra reference if we succeeded. It will
+			   be returned at unload time */
+			pci_dev_get(pdev);
 		}
 	}
 #endif
#1 lore raw
Quoted 2 lines · Alan Cox

Switch to pci ref counts for mxser when handling PCI devices. Use pci_get_device and drop the reference when we finish and unload.

Please, don't do that. These all drivers need to be rewritten to pci probing (for this one I have a patch, but I waited for confirmation of previous patchset, but nothing has come, so perhaps I will clone it as NEW/EXPERIMENTAL 1.9.1-with-pci-probing-driver) and when pci_find_device is there, we can grep -r it to know, which drivers need that. The same holds for zoran cards, which somebody wanted to play with (and rework), but as I can see, nothing happened :/.

[Changes in devices such as mtd are OK in my eyes...]

Quoted 27 lines

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.18-rc6-mm1/drivers/char/mxser.c linux-2.6.18-rc6-mm1/drivers/char/mxser.c

drivers/char/mxser.c +3 -2
@@ -538,6 +538,7 @@
 			if (pdev != NULL) {	/* PCI */
 				release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2));
 				release_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3));
+				pci_dev_put(pdev);
 			} else {
 				release_region(mxsercfg[i].ioaddr[0], 8 * mxsercfg[i].ports);
 				release_region(mxsercfg[i].vector, 1);
@@ -862,9 +865,9 @@
 	index = 0;
 	b = 0;
 	while (b < n) {
-		pdev = pci_find_device(mxser_pcibrds[b].vendor,
+		pdev = pci_get_device(mxser_pcibrds[b].vendor,
 				mxser_pcibrds[b].device, pdev);
-			if (pdev == NULL) {
+		if (pdev == NULL) {
 			b++;
 			continue;
 		}

drivers/char/mxser.c line 927

Quoted 9 lines
drivers/char/mxser.c +3 -0
@@ -916,6 +919,9 @@
 			if (mxser_initbrd(m, &hwconf) < 0)
 				continue;
 			m++;
+			/* Keep an extra reference if we succeeded. It will
+			   be returned at unload time */
+			pci_dev_get(pdev);
 		}
 	}
 #endif

regards,

Signature · 4 lines
http://www.fi.muni.cz/~xslaby/            Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8  22A0 32CC 55C3 39D4 7A7E
#2 lore raw
Quoted 5 lines · Jiri Slaby
Quoted 2 lines · Alan Cox

Switch to pci ref counts for mxser when handling PCI devices. Use pci_get_device and drop the reference when we finish and unload.

Please, don't do that. These all drivers need to be rewritten to pci probing (for this one I have a patch, but I waited for confirmation of previous patchset, but nothing has come, so perhaps I will clone it as NEW/EXPERIMENTAL 1.9.1-with-pci-probing-driver) and when pci_find_device is there, we can grep -r it to know, which drivers need that. The same

Just a note. I tried to do all this work, but it was nacked:
http://www.fi.muni.cz/~xslaby/unpr/linux_patches/pci_find/

You can pick up from there some patches for non-device drivers (such as buses or so), if you want to not do the work yourself again...

regards,

Signature · 4 lines
http://www.fi.muni.cz/~xslaby/            Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8  22A0 32CC 55C3 39D4 7A7E
author
#3 lore raw
In reply to Jiri Slaby

Ar Sad, 2006-09-16 am 14:39 +0159, ysgrifennodd Jiri Slaby:

Quoted 10 lines
Quoted 2 lines · Alan Cox

Switch to pci ref counts for mxser when handling PCI devices. Use pci_get_device and drop the reference when we finish and unload.

Please, don't do that. These all drivers need to be rewritten to pci probing (for this one I have a patch, but I waited for confirmation of previous patchset, but nothing has come, so perhaps I will clone it as NEW/EXPERIMENTAL 1.9.1-with-pci-probing-driver) and when pci_find_device is there, we can grep -r it to know, which drivers need that. The same holds for zoran cards, which somebody wanted to play with (and rework), but as I can see, nothing happened :/.

Well if they need pci probing updates perhaps we should either apply the alternative patches and see what breaks, or delete the driver and see who screams.

Alan