Skip to contentSkip to conversation

pciehp: dont call pci_enable_dev

PATCH In review Kristen Accardi 3 participants 6 messages Apr 24, 2006 – Apr 26, 2006 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pciehp: dont call pci_enable_dev

Don't call pci_enable_device from pciehp because the pcie port service driver already does this.

---
 drivers/pci/hotplug/pciehp_hpc.c |    3 ---
 1 files changed, 3 deletions(-)
drivers/pci/hotplug/pciehp_hpc.c +0 -3
@@ -1404,9 +1404,6 @@ int pcie_init(struct controller * ctrl, 
 	info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device, 
 		pdev->subsystem_vendor, pdev->subsystem_device);
 
-	if (pci_enable_device(pdev))
-		goto abort_free_ctlr;
-	
 	mutex_init(&ctrl->crit_sect);
 	/* setup wait queue */
 	init_waitqueue_head(&ctrl->queue);
#1 lore raw
Quoted 2 lines · Kristen Accardi

Don't call pci_enable_device from pciehp because the pcie port service driver already does this.

hmmmm shouldn't pci_enable_device on a previously enabled device just succeed? Sounds more than logical to me to make it that way at least...

#2 lore raw
Quoted 6 lines · Arjan van de Ven
Quoted 2 lines · Kristen Accardi

Don't call pci_enable_device from pciehp because the pcie port service driver already does this.

hmmmm shouldn't pci_enable_device on a previously enabled device just succeed? Sounds more than logical to me to make it that way at least...

I can't think of any reason why not. Something like this what you had in mind perhaps?

---
 drivers/pci/pci.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
drivers/pci/pci.c +9 -5
@@ -504,11 +504,15 @@ pci_enable_device_bars(struct pci_dev *d
 int
 pci_enable_device(struct pci_dev *dev)
 {
-	int err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1);
-	if (err)
-		return err;
-	pci_fixup_device(pci_fixup_enable, dev);
-	dev->is_enabled = 1;
+	int err;
+
+	if (!dev->is_enabled) {
+		err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1);
+		if (err)
+			return err;
+		pci_fixup_device(pci_fixup_enable, dev);
+		dev->is_enabled = 1;
+	}
 	return 0;
 }
 
#3 lore raw

Am Mittwoch, 26. April 2006 00:00 schrieb Kristen Accardi:

Quoted 35 lines · Arjan van de Ven
Quoted 6 lines · Kristen Accardi
Quoted 2 lines

Don't call pci_enable_device from pciehp because the pcie port service driver already does this.

hmmmm shouldn't pci_enable_device on a previously enabled device just succeed? Sounds more than logical to me to make it that way at least...

I can't think of any reason why not. Something like this what you had in mind perhaps?

---
drivers/pci/pci.c | 14 +++++++++-----

1 files changed, 9 insertions(+), 5 deletions(-)
drivers/pci/pci.c +0 -0
@@ -504,11 +504,15 @@ pci_enable_device_bars(struct pci_dev *d

int
pci_enable_device(struct pci_dev *dev)
{

drivers/pci/pci.c +9 -5
-	int err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1);
-	if (err)
-		return err;
-	pci_fixup_device(pci_fixup_enable, dev);
-	dev->is_enabled = 1;
+	int err;
+
+	if (!dev->is_enabled) {
+		err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1);
+		if (err)
+			return err;
+		pci_fixup_device(pci_fixup_enable, dev);
+		dev->is_enabled = 1;
+	}
Quoted 2 lines
	return 0;
}

What about

if (dev->is_enabled)

	return 0;

and leaving the rest as it is? This would save one level of identation. Opinions?

Eike

#4 lore raw
In reply to Kristen Accardi
Quoted 5 lines · Kristen Accardi
Quoted 4 lines · Arjan van de Ven
Quoted 2 lines · Kristen Accardi

Don't call pci_enable_device from pciehp because the pcie port service driver already does this.

Quoted 7 lines
Quoted 2 lines

hmmmm shouldn't pci_enable_device on a previously enabled device just succeed? Sounds more than logical to me to make it that way at least...

I can't think of any reason why not. Something like this what you had in mind perhaps?

---

the question then becomes if enable/disable should become "counting", eg enable twice disable once leaves enabled at count one....

#5 lore raw
Quoted 9 lines · Arjan van de Ven
Quoted 8 lines · Kristen Accardi
Quoted 6 lines · Arjan van de Ven
Quoted 2 lines · Kristen Accardi

Don't call pci_enable_device from pciehp because the pcie port service driver already does this.

hmmmm shouldn't pci_enable_device on a previously enabled device just succeed? Sounds more than logical to me to make it that way at least...

Quoted 7 lines
Quoted 4 lines

I can't think of any reason why not. Something like this what you had in mind perhaps?

---

the question then becomes if enable/disable should become "counting", eg enable twice disable once leaves enabled at count one....

ugh, no. 1) I think we should avoid adding more counting unless it's absolutely necessary. 2) if a device calls pci_disable_device it should always actually disable the device, because it is generally called in drivers either when the device is being shutdown, or suspended.