diff options
Diffstat (limited to 'drivers/ide/ide-dma.c')
-rw-r--r-- | drivers/ide/ide-dma.c | 98 |
1 files changed, 38 insertions, 60 deletions
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 18c78ad2b31e..5bf32038dc43 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -153,13 +153,7 @@ ide_startstop_t ide_dma_intr (ide_drive_t *drive) | |||
153 | if (!dma_stat) { | 153 | if (!dma_stat) { |
154 | struct request *rq = HWGROUP(drive)->rq; | 154 | struct request *rq = HWGROUP(drive)->rq; |
155 | 155 | ||
156 | if (rq->rq_disk) { | 156 | task_end_request(drive, rq, stat); |
157 | ide_driver_t *drv; | ||
158 | |||
159 | drv = *(ide_driver_t **)rq->rq_disk->private_data; | ||
160 | drv->end_request(drive, 1, rq->nr_sectors); | ||
161 | } else | ||
162 | ide_end_request(drive, 1, rq->nr_sectors); | ||
163 | return ide_stopped; | 157 | return ide_stopped; |
164 | } | 158 | } |
165 | printk(KERN_ERR "%s: dma_intr: bad DMA status (dma_stat=%x)\n", | 159 | printk(KERN_ERR "%s: dma_intr: bad DMA status (dma_stat=%x)\n", |
@@ -408,23 +402,29 @@ static int dma_timer_expiry (ide_drive_t *drive) | |||
408 | } | 402 | } |
409 | 403 | ||
410 | /** | 404 | /** |
411 | * ide_dma_host_off - Generic DMA kill | 405 | * ide_dma_host_set - Enable/disable DMA on a host |
412 | * @drive: drive to control | 406 | * @drive: drive to control |
413 | * | 407 | * |
414 | * Perform the generic IDE controller DMA off operation. This | 408 | * Enable/disable DMA on an IDE controller following generic |
415 | * works for most IDE bus mastering controllers | 409 | * bus-mastering IDE controller behaviour. |
416 | */ | 410 | */ |
417 | 411 | ||
418 | void ide_dma_host_off(ide_drive_t *drive) | 412 | void ide_dma_host_set(ide_drive_t *drive, int on) |
419 | { | 413 | { |
420 | ide_hwif_t *hwif = HWIF(drive); | 414 | ide_hwif_t *hwif = HWIF(drive); |
421 | u8 unit = (drive->select.b.unit & 0x01); | 415 | u8 unit = (drive->select.b.unit & 0x01); |
422 | u8 dma_stat = hwif->INB(hwif->dma_status); | 416 | u8 dma_stat = hwif->INB(hwif->dma_status); |
423 | 417 | ||
424 | hwif->OUTB((dma_stat & ~(1<<(5+unit))), hwif->dma_status); | 418 | if (on) |
419 | dma_stat |= (1 << (5 + unit)); | ||
420 | else | ||
421 | dma_stat &= ~(1 << (5 + unit)); | ||
422 | |||
423 | hwif->OUTB(dma_stat, hwif->dma_status); | ||
425 | } | 424 | } |
426 | 425 | ||
427 | EXPORT_SYMBOL(ide_dma_host_off); | 426 | EXPORT_SYMBOL_GPL(ide_dma_host_set); |
427 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ | ||
428 | 428 | ||
429 | /** | 429 | /** |
430 | * ide_dma_off_quietly - Generic DMA kill | 430 | * ide_dma_off_quietly - Generic DMA kill |
@@ -438,11 +438,10 @@ void ide_dma_off_quietly(ide_drive_t *drive) | |||
438 | drive->using_dma = 0; | 438 | drive->using_dma = 0; |
439 | ide_toggle_bounce(drive, 0); | 439 | ide_toggle_bounce(drive, 0); |
440 | 440 | ||
441 | drive->hwif->dma_host_off(drive); | 441 | drive->hwif->dma_host_set(drive, 0); |
442 | } | 442 | } |
443 | 443 | ||
444 | EXPORT_SYMBOL(ide_dma_off_quietly); | 444 | EXPORT_SYMBOL(ide_dma_off_quietly); |
445 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ | ||
446 | 445 | ||
447 | /** | 446 | /** |
448 | * ide_dma_off - disable DMA on a device | 447 | * ide_dma_off - disable DMA on a device |
@@ -455,52 +454,29 @@ EXPORT_SYMBOL(ide_dma_off_quietly); | |||
455 | void ide_dma_off(ide_drive_t *drive) | 454 | void ide_dma_off(ide_drive_t *drive) |
456 | { | 455 | { |
457 | printk(KERN_INFO "%s: DMA disabled\n", drive->name); | 456 | printk(KERN_INFO "%s: DMA disabled\n", drive->name); |
458 | drive->hwif->dma_off_quietly(drive); | 457 | ide_dma_off_quietly(drive); |
459 | } | 458 | } |
460 | 459 | ||
461 | EXPORT_SYMBOL(ide_dma_off); | 460 | EXPORT_SYMBOL(ide_dma_off); |
462 | 461 | ||
463 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | ||
464 | /** | ||
465 | * ide_dma_host_on - Enable DMA on a host | ||
466 | * @drive: drive to enable for DMA | ||
467 | * | ||
468 | * Enable DMA on an IDE controller following generic bus mastering | ||
469 | * IDE controller behaviour | ||
470 | */ | ||
471 | |||
472 | void ide_dma_host_on(ide_drive_t *drive) | ||
473 | { | ||
474 | if (drive->using_dma) { | ||
475 | ide_hwif_t *hwif = HWIF(drive); | ||
476 | u8 unit = (drive->select.b.unit & 0x01); | ||
477 | u8 dma_stat = hwif->INB(hwif->dma_status); | ||
478 | |||
479 | hwif->OUTB((dma_stat|(1<<(5+unit))), hwif->dma_status); | ||
480 | } | ||
481 | } | ||
482 | |||
483 | EXPORT_SYMBOL(ide_dma_host_on); | ||
484 | |||
485 | /** | 462 | /** |
486 | * __ide_dma_on - Enable DMA on a device | 463 | * ide_dma_on - Enable DMA on a device |
487 | * @drive: drive to enable DMA on | 464 | * @drive: drive to enable DMA on |
488 | * | 465 | * |
489 | * Enable IDE DMA for a device on this IDE controller. | 466 | * Enable IDE DMA for a device on this IDE controller. |
490 | */ | 467 | */ |
491 | 468 | ||
492 | int __ide_dma_on (ide_drive_t *drive) | 469 | void ide_dma_on(ide_drive_t *drive) |
493 | { | 470 | { |
494 | drive->using_dma = 1; | 471 | drive->using_dma = 1; |
495 | ide_toggle_bounce(drive, 1); | 472 | ide_toggle_bounce(drive, 1); |
496 | 473 | ||
497 | drive->hwif->dma_host_on(drive); | 474 | drive->hwif->dma_host_set(drive, 1); |
498 | |||
499 | return 0; | ||
500 | } | 475 | } |
501 | 476 | ||
502 | EXPORT_SYMBOL(__ide_dma_on); | 477 | EXPORT_SYMBOL(ide_dma_on); |
503 | 478 | ||
479 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | ||
504 | /** | 480 | /** |
505 | * ide_dma_setup - begin a DMA phase | 481 | * ide_dma_setup - begin a DMA phase |
506 | * @drive: target device | 482 | * @drive: target device |
@@ -755,6 +731,7 @@ EXPORT_SYMBOL_GPL(ide_find_dma_mode); | |||
755 | 731 | ||
756 | static int ide_tune_dma(ide_drive_t *drive) | 732 | static int ide_tune_dma(ide_drive_t *drive) |
757 | { | 733 | { |
734 | ide_hwif_t *hwif = drive->hwif; | ||
758 | u8 speed; | 735 | u8 speed; |
759 | 736 | ||
760 | if (noautodma || drive->nodma || (drive->id->capability & 1) == 0) | 737 | if (noautodma || drive->nodma || (drive->id->capability & 1) == 0) |
@@ -767,15 +744,21 @@ static int ide_tune_dma(ide_drive_t *drive) | |||
767 | if (ide_id_dma_bug(drive)) | 744 | if (ide_id_dma_bug(drive)) |
768 | return 0; | 745 | return 0; |
769 | 746 | ||
770 | if (drive->hwif->host_flags & IDE_HFLAG_TRUST_BIOS_FOR_DMA) | 747 | if (hwif->host_flags & IDE_HFLAG_TRUST_BIOS_FOR_DMA) |
771 | return config_drive_for_dma(drive); | 748 | return config_drive_for_dma(drive); |
772 | 749 | ||
773 | speed = ide_max_dma_mode(drive); | 750 | speed = ide_max_dma_mode(drive); |
774 | 751 | ||
775 | if (!speed) | 752 | if (!speed) { |
776 | return 0; | 753 | /* is this really correct/needed? */ |
754 | if ((hwif->host_flags & IDE_HFLAG_CY82C693) && | ||
755 | ide_dma_good_drive(drive)) | ||
756 | return 1; | ||
757 | else | ||
758 | return 0; | ||
759 | } | ||
777 | 760 | ||
778 | if (drive->hwif->host_flags & IDE_HFLAG_NO_SET_MODE) | 761 | if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) |
779 | return 0; | 762 | return 0; |
780 | 763 | ||
781 | if (ide_set_dma_mode(drive, speed)) | 764 | if (ide_set_dma_mode(drive, speed)) |
@@ -820,7 +803,6 @@ err_out: | |||
820 | 803 | ||
821 | int ide_set_dma(ide_drive_t *drive) | 804 | int ide_set_dma(ide_drive_t *drive) |
822 | { | 805 | { |
823 | ide_hwif_t *hwif = drive->hwif; | ||
824 | int rc; | 806 | int rc; |
825 | 807 | ||
826 | /* | 808 | /* |
@@ -829,13 +811,15 @@ int ide_set_dma(ide_drive_t *drive) | |||
829 | * things, if not checked and cleared. | 811 | * things, if not checked and cleared. |
830 | * PARANOIA!!! | 812 | * PARANOIA!!! |
831 | */ | 813 | */ |
832 | hwif->dma_off_quietly(drive); | 814 | ide_dma_off_quietly(drive); |
833 | 815 | ||
834 | rc = ide_dma_check(drive); | 816 | rc = ide_dma_check(drive); |
835 | if (rc) | 817 | if (rc) |
836 | return rc; | 818 | return rc; |
837 | 819 | ||
838 | return hwif->ide_dma_on(drive); | 820 | ide_dma_on(drive); |
821 | |||
822 | return 0; | ||
839 | } | 823 | } |
840 | 824 | ||
841 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | 825 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI |
@@ -972,14 +956,8 @@ void ide_setup_dma(ide_hwif_t *hwif, unsigned long base, unsigned num_ports) | |||
972 | if (!(hwif->dma_prdtable)) | 956 | if (!(hwif->dma_prdtable)) |
973 | hwif->dma_prdtable = (hwif->dma_base + 4); | 957 | hwif->dma_prdtable = (hwif->dma_base + 4); |
974 | 958 | ||
975 | if (!hwif->dma_off_quietly) | 959 | if (!hwif->dma_host_set) |
976 | hwif->dma_off_quietly = &ide_dma_off_quietly; | 960 | hwif->dma_host_set = &ide_dma_host_set; |
977 | if (!hwif->dma_host_off) | ||
978 | hwif->dma_host_off = &ide_dma_host_off; | ||
979 | if (!hwif->ide_dma_on) | ||
980 | hwif->ide_dma_on = &__ide_dma_on; | ||
981 | if (!hwif->dma_host_on) | ||
982 | hwif->dma_host_on = &ide_dma_host_on; | ||
983 | if (!hwif->dma_setup) | 961 | if (!hwif->dma_setup) |
984 | hwif->dma_setup = &ide_dma_setup; | 962 | hwif->dma_setup = &ide_dma_setup; |
985 | if (!hwif->dma_exec_cmd) | 963 | if (!hwif->dma_exec_cmd) |