aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKulikov Vasiliy <segooon@gmail.com>2010-08-03 01:43:15 -0400
committerDavid S. Miller <davem@davemloft.net>2010-08-04 19:18:02 -0400
commit7a0c2029d655e03499b1e2a3daeeab6a56d72b87 (patch)
tree2de949a524222b5391483ddeba9e9e3b154584ff
parent7aaaaa1e44b2a4047dfe05f304a5090eb995cf44 (diff)
cxgb4vf: 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> Signed-off-by: Kulikov Vasiliy <segooon@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/cxgb4vf/cxgb4vf_main.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/drivers/net/cxgb4vf/cxgb4vf_main.c b/drivers/net/cxgb4vf/cxgb4vf_main.c
index a16563219ac9..7b6d07f50c71 100644
--- a/drivers/net/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/cxgb4vf/cxgb4vf_main.c
@@ -2462,23 +2462,24 @@ static int __devinit cxgb4vf_pci_probe(struct pci_dev *pdev,
2462 version_printed = 1; 2462 version_printed = 1;
2463 } 2463 }
2464 2464
2465
2465 /* 2466 /*
2466 * Reserve PCI resources for the device. If we can't get them some 2467 * Initialize generic PCI device state.
2467 * other driver may have already claimed the device ...
2468 */ 2468 */
2469 err = pci_request_regions(pdev, KBUILD_MODNAME); 2469 err = pci_enable_device(pdev);
2470 if (err) { 2470 if (err) {
2471 dev_err(&pdev->dev, "cannot obtain PCI resources\n"); 2471 dev_err(&pdev->dev, "cannot enable PCI device\n");
2472 return err; 2472 return err;
2473 } 2473 }
2474 2474
2475 /* 2475 /*
2476 * Initialize generic PCI device state. 2476 * Reserve PCI resources for the device. If we can't get them some
2477 * other driver may have already claimed the device ...
2477 */ 2478 */
2478 err = pci_enable_device(pdev); 2479 err = pci_request_regions(pdev, KBUILD_MODNAME);
2479 if (err) { 2480 if (err) {
2480 dev_err(&pdev->dev, "cannot enable PCI device\n"); 2481 dev_err(&pdev->dev, "cannot obtain PCI resources\n");
2481 goto err_release_regions; 2482 goto err_disable_device;
2482 } 2483 }
2483 2484
2484 /* 2485 /*
@@ -2491,14 +2492,14 @@ static int __devinit cxgb4vf_pci_probe(struct pci_dev *pdev,
2491 if (err) { 2492 if (err) {
2492 dev_err(&pdev->dev, "unable to obtain 64-bit DMA for" 2493 dev_err(&pdev->dev, "unable to obtain 64-bit DMA for"
2493 " coherent allocations\n"); 2494 " coherent allocations\n");
2494 goto err_disable_device; 2495 goto err_release_regions;
2495 } 2496 }
2496 pci_using_dac = 1; 2497 pci_using_dac = 1;
2497 } else { 2498 } else {
2498 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 2499 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
2499 if (err != 0) { 2500 if (err != 0) {
2500 dev_err(&pdev->dev, "no usable DMA configuration\n"); 2501 dev_err(&pdev->dev, "no usable DMA configuration\n");
2501 goto err_disable_device; 2502 goto err_release_regions;
2502 } 2503 }
2503 pci_using_dac = 0; 2504 pci_using_dac = 0;
2504 } 2505 }
@@ -2514,7 +2515,7 @@ static int __devinit cxgb4vf_pci_probe(struct pci_dev *pdev,
2514 adapter = kzalloc(sizeof(*adapter), GFP_KERNEL); 2515 adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
2515 if (!adapter) { 2516 if (!adapter) {
2516 err = -ENOMEM; 2517 err = -ENOMEM;
2517 goto err_disable_device; 2518 goto err_release_regions;
2518 } 2519 }
2519 pci_set_drvdata(pdev, adapter); 2520 pci_set_drvdata(pdev, adapter);
2520 adapter->pdev = pdev; 2521 adapter->pdev = pdev;
@@ -2750,13 +2751,13 @@ err_free_adapter:
2750 kfree(adapter); 2751 kfree(adapter);
2751 pci_set_drvdata(pdev, NULL); 2752 pci_set_drvdata(pdev, NULL);
2752 2753
2753err_disable_device:
2754 pci_disable_device(pdev);
2755 pci_clear_master(pdev);
2756
2757err_release_regions: 2754err_release_regions:
2758 pci_release_regions(pdev); 2755 pci_release_regions(pdev);
2759 pci_set_drvdata(pdev, NULL); 2756 pci_set_drvdata(pdev, NULL);
2757 pci_clear_master(pdev);
2758
2759err_disable_device:
2760 pci_disable_device(pdev);
2760 2761
2761err_out: 2762err_out:
2762 return err; 2763 return err;