Skip to contentSkip to conversation

x86: intel_ips: do not use PCI resources before pci_enable_device()

PATCH In review Kulikov Vasiliy 2 participants 2 messages Aug 3, 2010

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

PATCH 8/11 x86: intel_ips: do not use PCI resources before pci_enable_device()

IRQ and resource[] may not have correct values until after PCI hotplug setup occurs at pci_enable_device() time.

The semantic match that finds this problem is as follows:

// <smpl>
@@
identifier x;
identifier request ~= "pci_request.*|pci_resource.*"; @@

(
* x->irq
|
* x->resource
|
* request(x, ...)
)
...
*pci_enable_device(x)
// </smpl>

---
 drivers/platform/x86/intel_ips.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
drivers/platform/x86/intel_ips.c +6 -5
index 0344822..90c9549 100644
@@ -1432,6 +1432,12 @@ static int ips_probe(struct pci_dev *dev, const struct pci_device_id *id)
 
 	spin_lock_init(&ips->turbo_status_lock);
 
+	ret = pci_enable_device(dev);
+	if (ret) {
+		dev_err(&dev->dev, "can't enable PCI device, aborting\n");
+		goto error_free;
+	}
+
 	if (!pci_resource_start(dev, 0)) {
 		dev_err(&dev->dev, "TBAR not assigned, aborting\n");
 		ret = -ENXIO;
@@ -1444,11 +1450,6 @@ static int ips_probe(struct pci_dev *dev, const struct pci_device_id *id)
 		goto error_free;
 	}
 
-	ret = pci_enable_device(dev);
-	if (ret) {
-		dev_err(&dev->dev, "can't enable PCI device, aborting\n");
-		goto error_free;
-	}
 
 	ips->regmap = ioremap(pci_resource_start(dev, 0),
 			      pci_resource_len(dev, 0));
Signature · 1 line
1.7.0.4
Reviewed-by on v1 8/11
#1 lore raw
Quoted 22 lines · On Tue, 3 Aug 2010 19:44:16 +0400 Kulikov Vasiliy <[email protected]> wrote:

IRQ and resource[] may not have correct values until after PCI hotplug setup occurs at pci_enable_device() time.

The semantic match that finds this problem is as follows:

// <smpl>
@@
identifier x;
identifier request ~= "pci_request.*|pci_resource.*"; @@

(
* x->irq
|
* x->resource
|
* request(x, ...)
)
...
*pci_enable_device(x)
// </smpl>

Quoted 4 lines
---
 drivers/platform/x86/intel_ips.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

Yep, thanks.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center