diff options
author | John Keller <jpk@sgi.com> | 2006-09-01 00:27:51 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-01 14:39:10 -0400 |
commit | 1678df37be8abbb381becdc40242ed915e775550 (patch) | |
tree | f7401c5c552ca4660280550ebeb1b6fd833c7e5a /drivers/ide | |
parent | 7931e2a92b4de23093362308087daa8aabd3848a (diff) |
[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: John Keller <jpk@sgi.com>
Signed-off-by: Jeremy Higdon <jeremy@sgi.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/pci/sgiioc4.c | 60 |
1 files changed, 42 insertions, 18 deletions
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c index e125032bb403..d8a0d87df734 100644 --- a/drivers/ide/pci/sgiioc4.c +++ b/drivers/ide/pci/sgiioc4.c | |||
@@ -367,12 +367,13 @@ sgiioc4_INB(unsigned long port) | |||
367 | static void __devinit | 367 | static void __devinit |
368 | ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) | 368 | ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) |
369 | { | 369 | { |
370 | void __iomem *virt_dma_base; | ||
370 | int num_ports = sizeof (ioc4_dma_regs_t); | 371 | int num_ports = sizeof (ioc4_dma_regs_t); |
371 | 372 | ||
372 | printk(KERN_INFO "%s: BM-DMA at 0x%04lx-0x%04lx\n", hwif->name, | 373 | printk(KERN_INFO "%s: BM-DMA at 0x%04lx-0x%04lx\n", hwif->name, |
373 | dma_base, dma_base + num_ports - 1); | 374 | dma_base, dma_base + num_ports - 1); |
374 | 375 | ||
375 | if (!request_region(dma_base, num_ports, hwif->name)) { | 376 | if (!request_mem_region(dma_base, num_ports, hwif->name)) { |
376 | printk(KERN_ERR | 377 | printk(KERN_ERR |
377 | "%s(%s) -- ERROR, Addresses 0x%p to 0x%p " | 378 | "%s(%s) -- ERROR, Addresses 0x%p to 0x%p " |
378 | "ALREADY in use\n", | 379 | "ALREADY in use\n", |
@@ -381,13 +382,21 @@ ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) | |||
381 | goto dma_alloc_failure; | 382 | goto dma_alloc_failure; |
382 | } | 383 | } |
383 | 384 | ||
384 | hwif->dma_base = dma_base; | 385 | virt_dma_base = ioremap(dma_base, num_ports); |
386 | if (virt_dma_base == NULL) { | ||
387 | printk(KERN_ERR | ||
388 | "%s(%s) -- ERROR, Unable to map addresses 0x%lx to 0x%lx\n", | ||
389 | __FUNCTION__, hwif->name, dma_base, dma_base + num_ports - 1); | ||
390 | goto dma_remap_failure; | ||
391 | } | ||
392 | hwif->dma_base = (unsigned long) virt_dma_base; | ||
393 | |||
385 | hwif->dmatable_cpu = pci_alloc_consistent(hwif->pci_dev, | 394 | hwif->dmatable_cpu = pci_alloc_consistent(hwif->pci_dev, |
386 | IOC4_PRD_ENTRIES * IOC4_PRD_BYTES, | 395 | IOC4_PRD_ENTRIES * IOC4_PRD_BYTES, |
387 | &hwif->dmatable_dma); | 396 | &hwif->dmatable_dma); |
388 | 397 | ||
389 | if (!hwif->dmatable_cpu) | 398 | if (!hwif->dmatable_cpu) |
390 | goto dma_alloc_failure; | 399 | goto dma_pci_alloc_failure; |
391 | 400 | ||
392 | hwif->sg_max_nents = IOC4_PRD_ENTRIES; | 401 | hwif->sg_max_nents = IOC4_PRD_ENTRIES; |
393 | 402 | ||
@@ -411,6 +420,12 @@ dma_base2alloc_failure: | |||
411 | printk(KERN_INFO | 420 | printk(KERN_INFO |
412 | "Changing from DMA to PIO mode for Drive %s\n", hwif->name); | 421 | "Changing from DMA to PIO mode for Drive %s\n", hwif->name); |
413 | 422 | ||
423 | dma_pci_alloc_failure: | ||
424 | iounmap(virt_dma_base); | ||
425 | |||
426 | dma_remap_failure: | ||
427 | release_mem_region(dma_base, num_ports); | ||
428 | |||
414 | dma_alloc_failure: | 429 | dma_alloc_failure: |
415 | /* Disable DMA because we couldnot allocate any DMA maps */ | 430 | /* Disable DMA because we couldnot allocate any DMA maps */ |
416 | hwif->autodma = 0; | 431 | hwif->autodma = 0; |
@@ -607,18 +622,15 @@ ide_init_sgiioc4(ide_hwif_t * hwif) | |||
607 | hwif->ide_dma_lostirq = &sgiioc4_ide_dma_lostirq; | 622 | hwif->ide_dma_lostirq = &sgiioc4_ide_dma_lostirq; |
608 | hwif->ide_dma_timeout = &__ide_dma_timeout; | 623 | hwif->ide_dma_timeout = &__ide_dma_timeout; |
609 | 624 | ||
610 | /* | ||
611 | * The IOC4 uses MMIO rather than Port IO. | ||
612 | * It also needs special workarounds for INB. | ||
613 | */ | ||
614 | default_hwif_mmiops(hwif); | ||
615 | hwif->INB = &sgiioc4_INB; | 625 | hwif->INB = &sgiioc4_INB; |
616 | } | 626 | } |
617 | 627 | ||
618 | static int __devinit | 628 | static int __devinit |
619 | sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d) | 629 | sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d) |
620 | { | 630 | { |
621 | unsigned long base, ctl, dma_base, irqport; | 631 | unsigned long cmd_base, dma_base, irqport; |
632 | unsigned long bar0, cmd_phys_base, ctl; | ||
633 | void __iomem *virt_base; | ||
622 | ide_hwif_t *hwif; | 634 | ide_hwif_t *hwif; |
623 | int h; | 635 | int h; |
624 | 636 | ||
@@ -636,23 +648,32 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d) | |||
636 | } | 648 | } |
637 | 649 | ||
638 | /* Get the CmdBlk and CtrlBlk Base Registers */ | 650 | /* Get the CmdBlk and CtrlBlk Base Registers */ |
639 | base = pci_resource_start(dev, 0) + IOC4_CMD_OFFSET; | 651 | bar0 = pci_resource_start(dev, 0); |
640 | ctl = pci_resource_start(dev, 0) + IOC4_CTRL_OFFSET; | 652 | virt_base = ioremap(bar0, pci_resource_len(dev, 0)); |
641 | irqport = pci_resource_start(dev, 0) + IOC4_INTR_OFFSET; | 653 | if (virt_base == NULL) { |
654 | printk(KERN_ERR "%s: Unable to remap BAR 0 address: 0x%lx\n", | ||
655 | d->name, bar0); | ||
656 | return -ENOMEM; | ||
657 | } | ||
658 | cmd_base = (unsigned long) virt_base + IOC4_CMD_OFFSET; | ||
659 | ctl = (unsigned long) virt_base + IOC4_CTRL_OFFSET; | ||
660 | irqport = (unsigned long) virt_base + IOC4_INTR_OFFSET; | ||
642 | dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET; | 661 | dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET; |
643 | 662 | ||
644 | if (!request_region(base, IOC4_CMD_CTL_BLK_SIZE, hwif->name)) { | 663 | cmd_phys_base = bar0 + IOC4_CMD_OFFSET; |
664 | if (!request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE, | ||
665 | hwif->name)) { | ||
645 | printk(KERN_ERR | 666 | printk(KERN_ERR |
646 | "%s : %s -- ERROR, Port Addresses " | 667 | "%s : %s -- ERROR, Addresses " |
647 | "0x%p to 0x%p ALREADY in use\n", | 668 | "0x%p to 0x%p ALREADY in use\n", |
648 | __FUNCTION__, hwif->name, (void *) base, | 669 | __FUNCTION__, hwif->name, (void *) cmd_phys_base, |
649 | (void *) base + IOC4_CMD_CTL_BLK_SIZE); | 670 | (void *) cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE); |
650 | return -ENOMEM; | 671 | return -ENOMEM; |
651 | } | 672 | } |
652 | 673 | ||
653 | if (hwif->io_ports[IDE_DATA_OFFSET] != base) { | 674 | if (hwif->io_ports[IDE_DATA_OFFSET] != cmd_base) { |
654 | /* Initialize the IO registers */ | 675 | /* Initialize the IO registers */ |
655 | sgiioc4_init_hwif_ports(&hwif->hw, base, ctl, irqport); | 676 | sgiioc4_init_hwif_ports(&hwif->hw, cmd_base, ctl, irqport); |
656 | memcpy(hwif->io_ports, hwif->hw.io_ports, | 677 | memcpy(hwif->io_ports, hwif->hw.io_ports, |
657 | sizeof (hwif->io_ports)); | 678 | sizeof (hwif->io_ports)); |
658 | hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET]; | 679 | 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 | hwif->cds = (struct ide_pci_device_s *) d; | 686 | hwif->cds = (struct ide_pci_device_s *) d; |
666 | hwif->gendev.parent = &dev->dev;/* setup proper ancestral information */ | 687 | hwif->gendev.parent = &dev->dev;/* setup proper ancestral information */ |
667 | 688 | ||
689 | /* The IOC4 uses MMIO rather than Port IO. */ | ||
690 | default_hwif_mmiops(hwif); | ||
691 | |||
668 | /* Initializing chipset IRQ Registers */ | 692 | /* Initializing chipset IRQ Registers */ |
669 | hwif->OUTL(0x03, irqport + IOC4_INTR_SET * 4); | 693 | hwif->OUTL(0x03, irqport + IOC4_INTR_SET * 4); |
670 | 694 | ||