aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-dma.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-10-16 16:29:55 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-10-16 16:29:55 -0400
commit0ae2e178652753ae1797d407755a3505f7c1d2a7 (patch)
treefa725edcfb4b9752ebf2aa49a3e42e158537d4ed /drivers/ide/ide-dma.c
parentb8b739d3361c16773a30fe5c0360336bbc19f435 (diff)
ide: remove ->ide_dma_check (take 2)
* Add IDE_HFLAG_TRUST_BIOS_FOR_DMA host flag for host drivers that depend on BIOS for programming device/controller for DMA. Set it in cy82c693, generic, ns87415, opti621 and trm290 host drivers. * Add IDE_HFLAG_VDMA host flag for host drivers using VDMA. Set it in cs5520 host driver. * Teach ide_tune_dma() about IDE_HFLAG_TRUST_BIOS_FOR_DMA flag. * Add generic ide_dma_check() helper and remove all open coded ->ide_dma_check implementations. Fix all places checking for presence of ->ide_dma_check hook to check for ->ide_dma_on instead. * Remove no longer needed code from config_drive_for_dma(). * Make ide_tune_dma() static. v2: * Fix config_drive_for_dma() return values. * Fix ide-dma.c build for CONFIG_BLK_DEV_IDEDMA_PCI=n by adding dummy config_drive_for_dma() inline. * Fix IDE_HFLAG_TRUST_BIOS_FOR_DMA handling in ide_dma_check(). * Fix init_hwif_it8213() comment. There should be no functionality changes caused by this patch. Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-dma.c')
-rw-r--r--drivers/ide/ide-dma.c75
1 files changed, 45 insertions, 30 deletions
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index a4cbbbaccde9..716a4fdcc0b5 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -338,35 +338,30 @@ static int config_drive_for_dma (ide_drive_t *drive)
338 ide_hwif_t *hwif = drive->hwif; 338 ide_hwif_t *hwif = drive->hwif;
339 struct hd_driveid *id = drive->id; 339 struct hd_driveid *id = drive->id;
340 340
341 /* consult the list of known "bad" drives */
342 if (__ide_dma_bad_drive(drive))
343 return -1;
344
345 if (drive->media != ide_disk && hwif->atapi_dma == 0) 341 if (drive->media != ide_disk && hwif->atapi_dma == 0)
346 return -1; 342 return 0;
347 343
348 if ((id->capability & 1) && drive->autodma) { 344 /*
349 /* 345 * Enable DMA on any drive that has
350 * Enable DMA on any drive that has 346 * UltraDMA (mode 0/1/2/3/4/5/6) enabled
351 * UltraDMA (mode 0/1/2/3/4/5/6) enabled 347 */
352 */ 348 if ((id->field_valid & 4) && ((id->dma_ultra >> 8) & 0x7f))
353 if ((id->field_valid & 4) && ((id->dma_ultra >> 8) & 0x7f)) 349 return 1;
354 return 0; 350
355 /* 351 /*
356 * Enable DMA on any drive that has mode2 DMA 352 * Enable DMA on any drive that has mode2 DMA
357 * (multi or single) enabled 353 * (multi or single) enabled
358 */ 354 */
359 if (id->field_valid & 2) /* regular DMA */ 355 if (id->field_valid & 2) /* regular DMA */
360 if ((id->dma_mword & 0x404) == 0x404 || 356 if ((id->dma_mword & 0x404) == 0x404 ||
361 (id->dma_1word & 0x404) == 0x404) 357 (id->dma_1word & 0x404) == 0x404)
362 return 0; 358 return 1;
363
364 /* Consult the list of known "good" drives */
365 if (ide_dma_good_drive(drive))
366 return 0;
367 }
368 359
369 return -1; 360 /* Consult the list of known "good" drives */
361 if (ide_dma_good_drive(drive))
362 return 1;
363
364 return 0;
370} 365}
371 366
372/** 367/**
@@ -627,6 +622,8 @@ static int __ide_dma_test_irq(ide_drive_t *drive)
627 drive->name, __FUNCTION__); 622 drive->name, __FUNCTION__);
628 return 0; 623 return 0;
629} 624}
625#else
626static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; }
630#endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ 627#endif /* CONFIG_BLK_DEV_IDEDMA_PCI */
631 628
632int __ide_dma_bad_drive (ide_drive_t *drive) 629int __ide_dma_bad_drive (ide_drive_t *drive)
@@ -758,7 +755,7 @@ u8 ide_find_dma_mode(ide_drive_t *drive, u8 req_mode)
758 755
759EXPORT_SYMBOL_GPL(ide_find_dma_mode); 756EXPORT_SYMBOL_GPL(ide_find_dma_mode);
760 757
761int ide_tune_dma(ide_drive_t *drive) 758static int ide_tune_dma(ide_drive_t *drive)
762{ 759{
763 u8 speed; 760 u8 speed;
764 761
@@ -769,6 +766,9 @@ int ide_tune_dma(ide_drive_t *drive)
769 if (__ide_dma_bad_drive(drive)) 766 if (__ide_dma_bad_drive(drive))
770 return 0; 767 return 0;
771 768
769 if (drive->hwif->host_flags & IDE_HFLAG_TRUST_BIOS_FOR_DMA)
770 return config_drive_for_dma(drive);
771
772 speed = ide_max_dma_mode(drive); 772 speed = ide_max_dma_mode(drive);
773 773
774 if (!speed) 774 if (!speed)
@@ -785,6 +785,23 @@ int ide_tune_dma(ide_drive_t *drive)
785 785
786EXPORT_SYMBOL_GPL(ide_tune_dma); 786EXPORT_SYMBOL_GPL(ide_tune_dma);
787 787
788static int ide_dma_check(ide_drive_t *drive)
789{
790 ide_hwif_t *hwif = drive->hwif;
791 int vdma = (hwif->host_flags & IDE_HFLAG_VDMA)? 1 : 0;
792
793 if (!vdma && ide_tune_dma(drive))
794 return 0;
795
796 /* TODO: always do PIO fallback */
797 if (hwif->host_flags & IDE_HFLAG_TRUST_BIOS_FOR_DMA)
798 return -1;
799
800 ide_set_max_pio(drive);
801
802 return vdma ? 0 : -1;
803}
804
788void ide_dma_verbose(ide_drive_t *drive) 805void ide_dma_verbose(ide_drive_t *drive)
789{ 806{
790 struct hd_driveid *id = drive->id; 807 struct hd_driveid *id = drive->id;
@@ -842,7 +859,7 @@ int ide_set_dma(ide_drive_t *drive)
842 ide_hwif_t *hwif = drive->hwif; 859 ide_hwif_t *hwif = drive->hwif;
843 int rc; 860 int rc;
844 861
845 rc = hwif->ide_dma_check(drive); 862 rc = ide_dma_check(drive);
846 863
847 switch(rc) { 864 switch(rc) {
848 case -1: /* DMA needs to be disabled */ 865 case -1: /* DMA needs to be disabled */
@@ -1019,8 +1036,6 @@ void ide_setup_dma (ide_hwif_t *hwif, unsigned long dma_base, unsigned int num_p
1019 hwif->ide_dma_on = &__ide_dma_on; 1036 hwif->ide_dma_on = &__ide_dma_on;
1020 if (!hwif->dma_host_on) 1037 if (!hwif->dma_host_on)
1021 hwif->dma_host_on = &ide_dma_host_on; 1038 hwif->dma_host_on = &ide_dma_host_on;
1022 if (!hwif->ide_dma_check)
1023 hwif->ide_dma_check = &config_drive_for_dma;
1024 if (!hwif->dma_setup) 1039 if (!hwif->dma_setup)
1025 hwif->dma_setup = &ide_dma_setup; 1040 hwif->dma_setup = &ide_dma_setup;
1026 if (!hwif->dma_exec_cmd) 1041 if (!hwif->dma_exec_cmd)