Commit 1678df37 authored by John Keller's avatar John Keller Committed by Linus Torvalds

[PATCH] sgiioc4: fixup use of mmio ops

Fix some bugs in the patch that converted the IOC4 driver from port IO ops to
memio ops.

http://marc.theaimsgroup.com/?l=linux-ide&m=114895892231438&w=2

  Problems fixed are:
   - Call to default_hwif_mmiops() was not being done until _after_
     first IO operation, resulting in the first IO operation being
     done as a port IO op, instead of memio.
   - request_region() calls needed to be request_mem_region()
   - Incomplete error case handling.
   - Non-usage of ioremap() and __iomem.
Signed-off-by: default avatarJohn Keller <jpk@sgi.com>
Signed-off-by: default avatarJeremy Higdon <jeremy@sgi.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 7931e2a9
...@@ -367,12 +367,13 @@ sgiioc4_INB(unsigned long port) ...@@ -367,12 +367,13 @@ sgiioc4_INB(unsigned long port)
static void __devinit static void __devinit
ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base)
{ {
void __iomem *virt_dma_base;
int num_ports = sizeof (ioc4_dma_regs_t); int num_ports = sizeof (ioc4_dma_regs_t);
printk(KERN_INFO "%s: BM-DMA at 0x%04lx-0x%04lx\n", hwif->name, printk(KERN_INFO "%s: BM-DMA at 0x%04lx-0x%04lx\n", hwif->name,
dma_base, dma_base + num_ports - 1); dma_base, dma_base + num_ports - 1);
if (!request_region(dma_base, num_ports, hwif->name)) { if (!request_mem_region(dma_base, num_ports, hwif->name)) {
printk(KERN_ERR printk(KERN_ERR
"%s(%s) -- ERROR, Addresses 0x%p to 0x%p " "%s(%s) -- ERROR, Addresses 0x%p to 0x%p "
"ALREADY in use\n", "ALREADY in use\n",
...@@ -381,13 +382,21 @@ ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) ...@@ -381,13 +382,21 @@ ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base)
goto dma_alloc_failure; goto dma_alloc_failure;
} }
hwif->dma_base = dma_base; virt_dma_base = ioremap(dma_base, num_ports);
if (virt_dma_base == NULL) {
printk(KERN_ERR
"%s(%s) -- ERROR, Unable to map addresses 0x%lx to 0x%lx\n",
__FUNCTION__, hwif->name, dma_base, dma_base + num_ports - 1);
goto dma_remap_failure;
}
hwif->dma_base = (unsigned long) virt_dma_base;
hwif->dmatable_cpu = pci_alloc_consistent(hwif->pci_dev, hwif->dmatable_cpu = pci_alloc_consistent(hwif->pci_dev,
IOC4_PRD_ENTRIES * IOC4_PRD_BYTES, IOC4_PRD_ENTRIES * IOC4_PRD_BYTES,
&hwif->dmatable_dma); &hwif->dmatable_dma);
if (!hwif->dmatable_cpu) if (!hwif->dmatable_cpu)
goto dma_alloc_failure; goto dma_pci_alloc_failure;
hwif->sg_max_nents = IOC4_PRD_ENTRIES; hwif->sg_max_nents = IOC4_PRD_ENTRIES;
...@@ -411,6 +420,12 @@ dma_base2alloc_failure: ...@@ -411,6 +420,12 @@ dma_base2alloc_failure:
printk(KERN_INFO printk(KERN_INFO
"Changing from DMA to PIO mode for Drive %s\n", hwif->name); "Changing from DMA to PIO mode for Drive %s\n", hwif->name);
dma_pci_alloc_failure:
iounmap(virt_dma_base);
dma_remap_failure:
release_mem_region(dma_base, num_ports);
dma_alloc_failure: dma_alloc_failure:
/* Disable DMA because we couldnot allocate any DMA maps */ /* Disable DMA because we couldnot allocate any DMA maps */
hwif->autodma = 0; hwif->autodma = 0;
...@@ -607,18 +622,15 @@ ide_init_sgiioc4(ide_hwif_t * hwif) ...@@ -607,18 +622,15 @@ ide_init_sgiioc4(ide_hwif_t * hwif)
hwif->ide_dma_lostirq = &sgiioc4_ide_dma_lostirq; hwif->ide_dma_lostirq = &sgiioc4_ide_dma_lostirq;
hwif->ide_dma_timeout = &__ide_dma_timeout; hwif->ide_dma_timeout = &__ide_dma_timeout;
/*
* The IOC4 uses MMIO rather than Port IO.
* It also needs special workarounds for INB.
*/
default_hwif_mmiops(hwif);
hwif->INB = &sgiioc4_INB; hwif->INB = &sgiioc4_INB;
} }
static int __devinit static int __devinit
sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d) sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d)
{ {
unsigned long base, ctl, dma_base, irqport; unsigned long cmd_base, dma_base, irqport;
unsigned long bar0, cmd_phys_base, ctl;
void __iomem *virt_base;
ide_hwif_t *hwif; ide_hwif_t *hwif;
int h; int h;
...@@ -636,23 +648,32 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d) ...@@ -636,23 +648,32 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d)
} }
/* Get the CmdBlk and CtrlBlk Base Registers */ /* Get the CmdBlk and CtrlBlk Base Registers */
base = pci_resource_start(dev, 0) + IOC4_CMD_OFFSET; bar0 = pci_resource_start(dev, 0);
ctl = pci_resource_start(dev, 0) + IOC4_CTRL_OFFSET; virt_base = ioremap(bar0, pci_resource_len(dev, 0));
irqport = pci_resource_start(dev, 0) + IOC4_INTR_OFFSET; if (virt_base == NULL) {
printk(KERN_ERR "%s: Unable to remap BAR 0 address: 0x%lx\n",
d->name, bar0);
return -ENOMEM;
}
cmd_base = (unsigned long) virt_base + IOC4_CMD_OFFSET;
ctl = (unsigned long) virt_base + IOC4_CTRL_OFFSET;
irqport = (unsigned long) virt_base + IOC4_INTR_OFFSET;
dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET; dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET;
if (!request_region(base, IOC4_CMD_CTL_BLK_SIZE, hwif->name)) { cmd_phys_base = bar0 + IOC4_CMD_OFFSET;
if (!request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE,
hwif->name)) {
printk(KERN_ERR printk(KERN_ERR
"%s : %s -- ERROR, Port Addresses " "%s : %s -- ERROR, Addresses "
"0x%p to 0x%p ALREADY in use\n", "0x%p to 0x%p ALREADY in use\n",
__FUNCTION__, hwif->name, (void *) base, __FUNCTION__, hwif->name, (void *) cmd_phys_base,
(void *) base + IOC4_CMD_CTL_BLK_SIZE); (void *) cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE);
return -ENOMEM; return -ENOMEM;
} }
if (hwif->io_ports[IDE_DATA_OFFSET] != base) { if (hwif->io_ports[IDE_DATA_OFFSET] != cmd_base) {
/* Initialize the IO registers */ /* Initialize the IO registers */
sgiioc4_init_hwif_ports(&hwif->hw, base, ctl, irqport); sgiioc4_init_hwif_ports(&hwif->hw, cmd_base, ctl, irqport);
memcpy(hwif->io_ports, hwif->hw.io_ports, memcpy(hwif->io_ports, hwif->hw.io_ports,
sizeof (hwif->io_ports)); sizeof (hwif->io_ports));
hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET]; hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET];
...@@ -665,6 +686,9 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d) ...@@ -665,6 +686,9 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d)
hwif->cds = (struct ide_pci_device_s *) d; hwif->cds = (struct ide_pci_device_s *) d;
hwif->gendev.parent = &dev->dev;/* setup proper ancestral information */ hwif->gendev.parent = &dev->dev;/* setup proper ancestral information */
/* The IOC4 uses MMIO rather than Port IO. */
default_hwif_mmiops(hwif);
/* Initializing chipset IRQ Registers */ /* Initializing chipset IRQ Registers */
hwif->OUTL(0x03, irqport + IOC4_INTR_SET * 4); hwif->OUTL(0x03, irqport + IOC4_INTR_SET * 4);
......
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