Skip to contentSkip to conversation

avoid pci_find_device

PATCH In review Jiri Slaby 5 participants 6 messages Jun 5, 2006 – Jun 6, 2006 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

cover avoid pci_find_device

Hello,

there are some patches to avoid pci_find_device in drivers. I will make a bcm43xx patch against wireless git too.

Take #3.

It's against 2.6.17-rc5-mm3 tree.

01-i2c-scx200-acb-avoid-pci-find-device.patch
02-bcm43xx-avoid-pci-find-device.patch
03-gt96100eth-avoid-pci-find-device.patch

 i2c/busses/scx200_acb.c             |    9 ++++++---
 net/gt96100eth.c                    |   23 ++++++++++++++++++-----
 net/wireless/bcm43xx/bcm43xx_main.c |   21 ++++++++++++++++-----
 3 files changed, 40 insertions(+), 13 deletions(-)

Thanks.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Re: [PATCH 2/3] pci: bcm43xx avoid pci_find_device

Quoted 43 lines · Jiri Slaby

bcm43xx avoid pci_find_device

Change pci_find_device to safer pci_get_device with support for more devices.

---
commit 4b73c16f5411d97360d5f26f292ffddeb670ff75
tree 6e43c8bd02498eb1ceec6bdc64277fa8408da9e2
parent d59f9ea8489749f59cd0c7333a4784cab964daa8
author Jiri Slaby <[email protected]> Mon, 05 Jun 2006 22:01:03 +0159 committer Jiri Slaby <[email protected]> Mon, 05 Jun 2006 22:01:03 +0159

 drivers/net/wireless/bcm43xx/bcm43xx_main.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)
drivers/net/wireless/bcm43xx/bcm43xx_main.c +7 -4
index 22b8fa6..d1a9975 100644
@@ -2133,6 +2133,13 @@ out:
 	return err;
 }
 
+#ifdef CONFIG_BCM947XX
+static struct pci_device_id bcm43xx_47xx_ids[] = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4324) },
+	{ 0 }
+};
+#endif
+
 static int bcm43xx_initialize_irq(struct bcm43xx_private *bcm)
 {
 	int res;
@@ -2142,11 +2149,15 @@ static int bcm43xx_initialize_irq(struct
 	bcm->irq = bcm->pci_dev->irq;
 #ifdef CONFIG_BCM947XX
 	if (bcm->pci_dev->bus->number == 0) {
-		struct pci_dev *d = NULL;
-		/* FIXME: we will probably need more device IDs here... */
-		d = pci_find_device(PCI_VENDOR_ID_BROADCOM, 0x4324, NULL);
-		if (d != NULL) {

drivers/net/wireless/bcm43xx/bcm43xx_main.c static int bcm43xx_initialize_irq(struct · line 2160

Quoted 10 lines
drivers/net/wireless/bcm43xx/bcm43xx_main.c +9 -1
-			bcm->irq = d->irq;
+		struct pci_dev *d;
+		struct pci_device_id *id;
+		for (id = bcm43xx_47xx_ids; id->vendor; id++) {
+			d = pci_get_device(id->vendor, id->device, NULL);
+			if (d != NULL) {
+				bcm->irq = d->irq;
+				pci_dev_put(d);
+				break;
+			}

This will not work if you have more than one of the same devices in the system.

Well, the original code will not either :(

Why not just use the proper pci interface? Why poke around in another pci device to steal an irq, when that irq might not even be valid? (irqs are not valid until pci_enable_device() is called on them...)

thanks,

greg k-h

author
#3 lore raw

Re: [PATCH 2/3] pci: bcm43xx avoid pci_find_device

Greg KH napsal(a):

Quoted 58 lines · Jiri Slaby
Quoted 43 lines

bcm43xx avoid pci_find_device

Change pci_find_device to safer pci_get_device with support for more devices.

---
commit 4b73c16f5411d97360d5f26f292ffddeb670ff75
tree 6e43c8bd02498eb1ceec6bdc64277fa8408da9e2
parent d59f9ea8489749f59cd0c7333a4784cab964daa8
author Jiri Slaby <[email protected]> Mon, 05 Jun 2006 22:01:03 +0159 committer Jiri Slaby <[email protected]> Mon, 05 Jun 2006 22:01:03 +0159

 drivers/net/wireless/bcm43xx/bcm43xx_main.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)
drivers/net/wireless/bcm43xx/bcm43xx_main.c +7 -4
index 22b8fa6..d1a9975 100644
@@ -2133,6 +2133,13 @@ out:
 	return err;
 }
 
+#ifdef CONFIG_BCM947XX
+static struct pci_device_id bcm43xx_47xx_ids[] = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4324) },
+	{ 0 }
+};
+#endif
+
 static int bcm43xx_initialize_irq(struct bcm43xx_private *bcm)
 {
 	int res;
@@ -2142,11 +2149,15 @@ static int bcm43xx_initialize_irq(struct
 	bcm->irq = bcm->pci_dev->irq;
 #ifdef CONFIG_BCM947XX
 	if (bcm->pci_dev->bus->number == 0) {
-		struct pci_dev *d = NULL;
-		/* FIXME: we will probably need more device IDs here... */
-		d = pci_find_device(PCI_VENDOR_ID_BROADCOM, 0x4324, NULL);
-		if (d != NULL) {

drivers/net/wireless/bcm43xx/bcm43xx_main.c static int bcm43xx_initialize_irq(struct · line 2160

Quoted 10 lines
drivers/net/wireless/bcm43xx/bcm43xx_main.c +9 -1
-			bcm->irq = d->irq;
+		struct pci_dev *d;
+		struct pci_device_id *id;
+		for (id = bcm43xx_47xx_ids; id->vendor; id++) {
+			d = pci_get_device(id->vendor, id->device, NULL);
+			if (d != NULL) {
+				bcm->irq = d->irq;
+				pci_dev_put(d);
+				break;
+			}

This will not work if you have more than one of the same devices in the system.

Quoted 5 lines

Well, the original code will not either :(

Why not just use the proper pci interface? Why poke around in another pci device to steal an irq, when that irq might not even be valid? (irqs are not valid until pci_enable_device() is called on them...)

Ok, this is some bus or something, not "real" device, so no pci probing or anything else could be done. There is only one in the system, if any, since CONFIG_BCM947XX is set for some sort of embedded systems, but this would be uttered by somebody more responsible.

Should I call pci_enable_device anyway, I am confused now :/? And then, should I hold the reference all time until ifdown for this "some kind of parent"?

thanks,

Signature · 3 lines
Jiri Slaby         www.fi.muni.cz/~xslaby
\_.-^-._   [email protected]   _.-^-._/
B67499670407CE62ACC8 22A032CC55C339D47A7E
#4 lore raw

Re: [PATCH 2/3] pci: bcm43xx avoid pci_find_device

In reply to Greg KH
Quoted 3 lines · Greg KH

Why not just use the proper pci interface? Why poke around in another pci device to steal an irq, when that irq might not even be valid? (irqs are not valid until pci_enable_device() is called on them...)

Answered this question the last time you asked.

Answer: this is an embedded platform that needs such poking. The wireless device is _another_ device.

Jeff

#5 lore raw

Re: [PATCH 2/3] pci: bcm43xx avoid pci_find_device

Quoted 9 lines · Jeff Garzik
Quoted 3 lines · Greg KH

Why not just use the proper pci interface? Why poke around in another pci device to steal an irq, when that irq might not even be valid? (irqs are not valid until pci_enable_device() is called on them...)

Answered this question the last time you asked.

Answer: this is an embedded platform that needs such poking. The wireless device is _another_ device.

Ugh, sorry, too many patches, too many different threads... You are right...

greg k-h

#6 lore raw

Re: [PATCH 2/3] pci: bcm43xx avoid pci_find_device

In reply to Greg KH
Quoted 58 lines · Greg KH
Quoted 43 lines · Jiri Slaby

bcm43xx avoid pci_find_device

Change pci_find_device to safer pci_get_device with support for more devices.

---
commit 4b73c16f5411d97360d5f26f292ffddeb670ff75
tree 6e43c8bd02498eb1ceec6bdc64277fa8408da9e2
parent d59f9ea8489749f59cd0c7333a4784cab964daa8
author Jiri Slaby <[email protected]> Mon, 05 Jun 2006 22:01:03 +0159 committer Jiri Slaby <[email protected]> Mon, 05 Jun 2006 22:01:03 +0159

 drivers/net/wireless/bcm43xx/bcm43xx_main.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)
drivers/net/wireless/bcm43xx/bcm43xx_main.c +7 -4
index 22b8fa6..d1a9975 100644
@@ -2133,6 +2133,13 @@ out:
 	return err;
 }
 
+#ifdef CONFIG_BCM947XX
+static struct pci_device_id bcm43xx_47xx_ids[] = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4324) },
+	{ 0 }
+};
+#endif
+
 static int bcm43xx_initialize_irq(struct bcm43xx_private *bcm)
 {
 	int res;
@@ -2142,11 +2149,15 @@ static int bcm43xx_initialize_irq(struct
 	bcm->irq = bcm->pci_dev->irq;
 #ifdef CONFIG_BCM947XX
 	if (bcm->pci_dev->bus->number == 0) {
-		struct pci_dev *d = NULL;
-		/* FIXME: we will probably need more device IDs here... */
-		d = pci_find_device(PCI_VENDOR_ID_BROADCOM, 0x4324, NULL);
-		if (d != NULL) {

drivers/net/wireless/bcm43xx/bcm43xx_main.c static int bcm43xx_initialize_irq(struct · line 2160

Quoted 10 lines
drivers/net/wireless/bcm43xx/bcm43xx_main.c +9 -1
-			bcm->irq = d->irq;
+		struct pci_dev *d;
+		struct pci_device_id *id;
+		for (id = bcm43xx_47xx_ids; id->vendor; id++) {
+			d = pci_get_device(id->vendor, id->device, NULL);
+			if (d != NULL) {
+				bcm->irq = d->irq;
+				pci_dev_put(d);
+				break;
+			}

This will not work if you have more than one of the same devices in the system.

Quoted 5 lines

Well, the original code will not either :(

Why not just use the proper pci interface? Why poke around in another pci device to steal an irq, when that irq might not even be valid? (irqs are not valid until pci_enable_device() is called on them...)

Ok, if someone really wants to have this patch in mainline.

But the whole purpose of this patch is really questionable.
* This code is only compiled for the OpenWRT Router kernel. This kernel does not use softmac, but dscape stack. So nobody will ever actually use this code.
One could even argue, if the code should be removed from the softmac driver, but I think openwrt people use it for some kind of hacking, testing, whatever.
It's not so much code, so I don't care. It does not add maintainance work.
* Do we really need to increment some reference counters? I mean, we are asking for a bus here. This bus is not hotpluggable or something and will never go away. Either it is soldered on the board or not. That is what we test here.

So, Jiri, if you really want to have this patch upstream, you have my Signed-off-by. If nobody else cares, it will get lost in the deep black netdev hole. ;)

Signature · 1 line
Greetings Michael.