ide: factor out simplex handling from ide_pci_dma_base()
* Factor out simplex handling from ide_pci_dma_base() to ide_pci_check_simplex(). * Set hwif->dma_base early in ->init_dma method / ide_hwif_setup_dma() and reset it in ide_init_port() if DMA initialization fails. * Use ->read_sff_dma_status instead of ->INB in ide_pci_dma_base(). There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
This commit is contained in:
parent
81e8d5a34f
commit
ebb00fb55d
|
@ -1363,6 +1363,7 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
printk(KERN_INFO "%s: DMA disabled\n", hwif->name);
|
printk(KERN_INFO "%s: DMA disabled\n", hwif->name);
|
||||||
|
hwif->dma_base = 0;
|
||||||
hwif->swdma_mask = 0;
|
hwif->swdma_mask = 0;
|
||||||
hwif->mwdma_mask = 0;
|
hwif->mwdma_mask = 0;
|
||||||
hwif->ultra_mask = 0;
|
hwif->ultra_mask = 0;
|
||||||
|
|
|
@ -471,7 +471,15 @@ static int __devinit init_dma_ali15x3(ide_hwif_t *hwif,
|
||||||
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
||||||
unsigned long base = ide_pci_dma_base(hwif, d);
|
unsigned long base = ide_pci_dma_base(hwif, d);
|
||||||
|
|
||||||
if (base == 0 || ide_pci_set_master(dev, d->name) < 0)
|
if (base == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
hwif->dma_base = base;
|
||||||
|
|
||||||
|
if (ide_pci_check_simplex(hwif, d) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (ide_pci_set_master(dev, d->name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!hwif->channel)
|
if (!hwif->channel)
|
||||||
|
@ -483,8 +491,6 @@ static int __devinit init_dma_ali15x3(ide_hwif_t *hwif,
|
||||||
if (ide_allocate_dma_engine(hwif))
|
if (ide_allocate_dma_engine(hwif))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
hwif->dma_base = base;
|
|
||||||
|
|
||||||
hwif->dma_ops = &sff_dma_ops;
|
hwif->dma_ops = &sff_dma_ops;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1320,7 +1320,15 @@ static int __devinit init_dma_hpt366(ide_hwif_t *hwif,
|
||||||
unsigned long flags, base = ide_pci_dma_base(hwif, d);
|
unsigned long flags, base = ide_pci_dma_base(hwif, d);
|
||||||
u8 dma_old, dma_new, masterdma = 0, slavedma = 0;
|
u8 dma_old, dma_new, masterdma = 0, slavedma = 0;
|
||||||
|
|
||||||
if (base == 0 || ide_pci_set_master(dev, d->name) < 0)
|
if (base == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
hwif->dma_base = base;
|
||||||
|
|
||||||
|
if (ide_pci_check_simplex(hwif, d) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (ide_pci_set_master(dev, d->name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
dma_old = inb(base + 2);
|
dma_old = inb(base + 2);
|
||||||
|
@ -1346,8 +1354,6 @@ static int __devinit init_dma_hpt366(ide_hwif_t *hwif,
|
||||||
if (ide_allocate_dma_engine(hwif))
|
if (ide_allocate_dma_engine(hwif))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
hwif->dma_base = base;
|
|
||||||
|
|
||||||
hwif->dma_ops = &sff_dma_ops;
|
hwif->dma_ops = &sff_dma_ops;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -73,15 +73,12 @@ static void ide_pci_clear_simplex(unsigned long dma_base, const char *name)
|
||||||
* @d: IDE port info
|
* @d: IDE port info
|
||||||
*
|
*
|
||||||
* Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space.
|
* Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space.
|
||||||
* Where a device has a partner that is already in DMA mode we check
|
|
||||||
* and enforce IDE simplex rules.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d)
|
unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d)
|
||||||
{
|
{
|
||||||
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
||||||
unsigned long dma_base = 0;
|
unsigned long dma_base = 0;
|
||||||
u8 dma_stat = 0;
|
|
||||||
|
|
||||||
if (hwif->host_flags & IDE_HFLAG_MMIO)
|
if (hwif->host_flags & IDE_HFLAG_MMIO)
|
||||||
return hwif->dma_base;
|
return hwif->dma_base;
|
||||||
|
@ -102,11 +99,19 @@ unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d)
|
||||||
if (hwif->channel)
|
if (hwif->channel)
|
||||||
dma_base += 8;
|
dma_base += 8;
|
||||||
|
|
||||||
if (d->host_flags & IDE_HFLAG_CS5520)
|
return dma_base;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(ide_pci_dma_base);
|
||||||
|
|
||||||
|
int ide_pci_check_simplex(ide_hwif_t *hwif, const struct ide_port_info *d)
|
||||||
|
{
|
||||||
|
u8 dma_stat;
|
||||||
|
|
||||||
|
if (d->host_flags & (IDE_HFLAG_MMIO | IDE_HFLAG_CS5520))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (d->host_flags & IDE_HFLAG_CLEAR_SIMPLEX) {
|
if (d->host_flags & IDE_HFLAG_CLEAR_SIMPLEX) {
|
||||||
ide_pci_clear_simplex(dma_base, d->name);
|
ide_pci_clear_simplex(hwif->dma_base, d->name);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,15 +125,15 @@ unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d)
|
||||||
* we tune the drive then try to grab DMA ownership if we want to be
|
* we tune the drive then try to grab DMA ownership if we want to be
|
||||||
* the DMA end. This has to be become dynamic to handle hot-plug.
|
* the DMA end. This has to be become dynamic to handle hot-plug.
|
||||||
*/
|
*/
|
||||||
dma_stat = hwif->INB(dma_base + 2);
|
dma_stat = hwif->read_sff_dma_status(hwif);
|
||||||
if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) {
|
if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) {
|
||||||
printk(KERN_INFO "%s: simplex device: DMA disabled\n", d->name);
|
printk(KERN_INFO "%s: simplex device: DMA disabled\n", d->name);
|
||||||
dma_base = 0;
|
return -1;
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
return dma_base;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(ide_pci_dma_base);
|
EXPORT_SYMBOL_GPL(ide_pci_check_simplex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up BM-DMA capability (PnP BIOS should have done this)
|
* Set up BM-DMA capability (PnP BIOS should have done this)
|
||||||
|
@ -363,7 +368,15 @@ int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d)
|
||||||
(dev->class & 0x80))) {
|
(dev->class & 0x80))) {
|
||||||
unsigned long base = ide_pci_dma_base(hwif, d);
|
unsigned long base = ide_pci_dma_base(hwif, d);
|
||||||
|
|
||||||
if (base == 0 || ide_pci_set_master(dev, d->name) < 0)
|
if (base == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
hwif->dma_base = base;
|
||||||
|
|
||||||
|
if (ide_pci_check_simplex(hwif, d) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (ide_pci_set_master(dev, d->name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (hwif->host_flags & IDE_HFLAG_MMIO)
|
if (hwif->host_flags & IDE_HFLAG_MMIO)
|
||||||
|
@ -377,8 +390,6 @@ int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d)
|
||||||
if (ide_allocate_dma_engine(hwif))
|
if (ide_allocate_dma_engine(hwif))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
hwif->dma_base = base;
|
|
||||||
|
|
||||||
hwif->dma_ops = &sff_dma_ops;
|
hwif->dma_ops = &sff_dma_ops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1008,6 +1008,7 @@ void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *);
|
||||||
int ide_pci_set_master(struct pci_dev *, const char *);
|
int ide_pci_set_master(struct pci_dev *, const char *);
|
||||||
unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *);
|
unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *);
|
||||||
extern const struct ide_dma_ops sff_dma_ops;
|
extern const struct ide_dma_ops sff_dma_ops;
|
||||||
|
int ide_pci_check_simplex(ide_hwif_t *, const struct ide_port_info *);
|
||||||
int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *);
|
int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *);
|
||||||
#else
|
#else
|
||||||
static inline int ide_hwif_setup_dma(ide_hwif_t *hwif,
|
static inline int ide_hwif_setup_dma(ide_hwif_t *hwif,
|
||||||
|
|
Loading…
Reference in New Issue