Commit 71eb559f authored by Jeff Garzik's avatar Jeff Garzik

[libata] do not call pci_disable_device() for certain errors

If PCI request regions fails, then someone else is using the
hardware we wish to use.  For that one case, calling pci_disable_device()
is rather rude.
parent 327f7fd0
......@@ -940,6 +940,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
unsigned long base;
void *mmio_base;
unsigned int board_idx = (unsigned int) ent->driver_data;
int pci_dev_busy = 0;
int rc;
VPRINTK("ENTER\n");
......@@ -952,8 +953,10 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
return rc;
rc = pci_request_regions(pdev, DRV_NAME);
if (rc)
if (rc) {
pci_dev_busy = 1;
goto err_out;
}
pci_enable_intx(pdev);
......@@ -1015,7 +1018,8 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
err_out_regions:
pci_release_regions(pdev);
err_out:
pci_disable_device(pdev);
if (!pci_dev_busy)
pci_disable_device(pdev);
return rc;
}
......
......@@ -3656,6 +3656,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
struct ata_port_info *port[2];
u8 tmp8, mask;
unsigned int legacy_mode = 0;
int disable_dev_on_err = 1;
int rc;
DPRINTK("ENTER\n");
......@@ -3686,8 +3687,10 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
return rc;
rc = pci_request_regions(pdev, DRV_NAME);
if (rc)
if (rc) {
disable_dev_on_err = 0;
goto err_out;
}
if (legacy_mode) {
if (!request_region(0x1f0, 8, "libata")) {
......@@ -3697,8 +3700,10 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
conflict = ____request_resource(&ioport_resource, &res);
if (!strcmp(conflict->name, "libata"))
legacy_mode |= (1 << 0);
else
else {
disable_dev_on_err = 0;
printk(KERN_WARNING "ata: 0x1f0 IDE port busy\n");
}
} else
legacy_mode |= (1 << 0);
......@@ -3709,8 +3714,10 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
conflict = ____request_resource(&ioport_resource, &res);
if (!strcmp(conflict->name, "libata"))
legacy_mode |= (1 << 1);
else
else {
disable_dev_on_err = 0;
printk(KERN_WARNING "ata: 0x170 IDE port busy\n");
}
} else
legacy_mode |= (1 << 1);
}
......@@ -3763,7 +3770,8 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
release_region(0x170, 8);
pci_release_regions(pdev);
err_out:
pci_disable_device(pdev);
if (disable_dev_on_err)
pci_disable_device(pdev);
return rc;
}
......
......@@ -332,6 +332,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
struct nv_host *host;
struct ata_port_info *ppi;
struct ata_probe_ent *probe_ent;
int pci_dev_busy = 0;
int rc;
u32 bar;
......@@ -350,8 +351,10 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_out;
rc = pci_request_regions(pdev, DRV_NAME);
if (rc)
if (rc) {
pci_dev_busy = 1;
goto err_out_disable;
}
rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
if (rc)
......@@ -427,7 +430,8 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
err_out_regions:
pci_release_regions(pdev);
err_out_disable:
pci_disable_device(pdev);
if (!pci_dev_busy)
pci_disable_device(pdev);
err_out:
return rc;
}
......
......@@ -556,6 +556,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
unsigned long base;
void *mmio_base;
unsigned int board_idx = (unsigned int) ent->driver_data;
int pci_dev_busy = 0;
int rc;
if (!printed_version++)
......@@ -570,8 +571,10 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
return rc;
rc = pci_request_regions(pdev, DRV_NAME);
if (rc)
if (rc) {
pci_dev_busy = 1;
goto err_out;
}
rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
if (rc)
......@@ -650,7 +653,8 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
err_out_regions:
pci_release_regions(pdev);
err_out:
pci_disable_device(pdev);
if (!pci_dev_busy)
pci_disable_device(pdev);
return rc;
}
......
......@@ -336,6 +336,7 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
void *mmio_base;
int rc;
unsigned int i;
int pci_dev_busy = 0;
u32 tmp, irq_mask;
if (!printed_version++)
......@@ -350,8 +351,10 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
return rc;
rc = pci_request_regions(pdev, DRV_NAME);
if (rc)
if (rc) {
pci_dev_busy = 1;
goto err_out;
}
rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
if (rc)
......@@ -438,7 +441,8 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
err_out_regions:
pci_release_regions(pdev);
err_out:
pci_disable_device(pdev);
if (!pci_dev_busy)
pci_disable_device(pdev);
return rc;
}
......
......@@ -200,14 +200,17 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
int rc;
u32 genctl;
struct ata_port_info *ppi;
int pci_dev_busy = 0;
rc = pci_enable_device(pdev);
if (rc)
return rc;
rc = pci_request_regions(pdev, DRV_NAME);
if (rc)
if (rc) {
pci_dev_busy = 1;
goto err_out;
}
rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
if (rc)
......@@ -259,7 +262,8 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
pci_release_regions(pdev);
err_out:
pci_disable_device(pdev);
if (!pci_dev_busy)
pci_disable_device(pdev);
return rc;
}
......
......@@ -338,6 +338,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
struct ata_probe_ent *probe_ent = NULL;
unsigned long base;
void *mmio_base;
int pci_dev_busy = 0;
int rc;
if (!printed_version++)
......@@ -359,8 +360,10 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
/* Request PCI regions */
rc = pci_request_regions(pdev, DRV_NAME);
if (rc)
if (rc) {
pci_dev_busy = 1;
goto err_out;
}
rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
if (rc)
......@@ -433,7 +436,8 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
err_out_regions:
pci_release_regions(pdev);
err_out:
pci_disable_device(pdev);
if (!pci_dev_busy)
pci_disable_device(pdev);
return rc;
}
......
......@@ -1366,6 +1366,7 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
void *mmio_base, *dimm_mmio = NULL;
struct pdc_host_priv *hpriv = NULL;
unsigned int board_idx = (unsigned int) ent->driver_data;
int pci_dev_busy = 0;
int rc;
if (!printed_version++)
......@@ -1380,8 +1381,10 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
return rc;
rc = pci_request_regions(pdev, DRV_NAME);
if (rc)
if (rc) {
pci_dev_busy = 1;
goto err_out;
}
rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
if (rc)
......@@ -1471,7 +1474,8 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
err_out_regions:
pci_release_regions(pdev);
err_out:
pci_disable_device(pdev);
if (!pci_dev_busy)
pci_disable_device(pdev);
return rc;
}
......
......@@ -185,14 +185,17 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
struct ata_port_info *ppi;
int rc;
unsigned int board_idx = (unsigned int) ent->driver_data;
int pci_dev_busy = 0;
rc = pci_enable_device(pdev);
if (rc)
return rc;
rc = pci_request_regions(pdev, DRV_NAME);
if (rc)
if (rc) {
pci_dev_busy = 1;
goto err_out;
}
rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
if (rc)
......@@ -260,7 +263,8 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
pci_release_regions(pdev);
err_out:
pci_disable_device(pdev);
if (!pci_dev_busy)
pci_disable_device(pdev);
return rc;
}
......
......@@ -290,6 +290,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
struct ata_probe_ent *probe_ent;
int board_id = (int) ent->driver_data;
const int *bar_sizes;
int pci_dev_busy = 0;
u8 tmp8;
if (!printed_version++)
......@@ -300,8 +301,10 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
return rc;
rc = pci_request_regions(pdev, DRV_NAME);
if (rc)
if (rc) {
pci_dev_busy = 1;
goto err_out;
}
if (board_id == vt6420) {
pci_read_config_byte(pdev, SATA_PATA_SHARING, &tmp8);
......@@ -360,7 +363,8 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
err_out_regions:
pci_release_regions(pdev);
err_out:
pci_disable_device(pdev);
if (!pci_dev_busy)
pci_disable_device(pdev);
return rc;
}
......
......@@ -255,6 +255,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
static int printed_version;
struct ata_probe_ent *probe_ent = NULL;
unsigned long base;
int pci_dev_busy = 0;
void *mmio_base;
int rc;
......@@ -274,8 +275,10 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
}
rc = pci_request_regions(pdev, DRV_NAME);
if (rc)
if (rc) {
pci_dev_busy = 1;
goto err_out;
}
/*
* Use 32 bit DMA mask, because 64 bit address support is poor.
......@@ -352,7 +355,8 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
err_out_regions:
pci_release_regions(pdev);
err_out:
pci_disable_device(pdev);
if (!pci_dev_busy)
pci_disable_device(pdev);
return rc;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment