Re: [PATCH 10/15] ide: add ide_set_dma() helper
Hello again. :-) Bartlomiej Zolnierkiewicz wrote: [PATCH] ide: add ide_set_dma() helper * add ide_set_dma() helper and make ide_hwif_t.ide_dma_check return -1 when DMA needs to be disabled (== need to call ->ide_dma_off_quietly) 0 when DMA needs to be enabled (== need to call ->ide_dma_on) 1 when DMA setting shouldn't be changed * fix IDE code to use ide_set_dma() instead if using ->ide_dma_check directly Here are a few comments related to the code being patched: Index: b/drivers/ide/pci/alim15x3.c === --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c @@ -507,17 +507,15 @@ static int config_chipset_for_dma (ide_d * * Configure a drive for DMA operation. If DMA is not possible we * drop the drive into PIO mode instead. - * - * FIXME: exactly what are we trying to return here */ - + static int ali15x3_config_drive_for_dma(ide_drive_t *drive) { ide_hwif_t *hwif= HWIF(drive); struct hd_driveid *id = drive->id; if ((m5229_revision<=0x20) && (drive->media!=ide_disk)) - return hwif->ide_dma_off_quietly(drive); + goto no_dma_set; Isn't it better to just return -1? @@ -552,9 +550,10 @@ try_dma_modes: ata_pio: hwif->tuneproc(drive, 255); no_dma_set: - return hwif->ide_dma_off_quietly(drive); + return -1; } - return hwif->ide_dma_on(drive); + + return 0; } Ugh, this code looks like it's asking to be converted into calling ide_use_dma(). instead all of that... Index: b/drivers/ide/pci/cs5520.c === --- a/drivers/ide/pci/cs5520.c +++ b/drivers/ide/pci/cs5520.c @@ -132,12 +132,11 @@ static void cs5520_tune_drive(ide_drive_ static int cs5520_config_drive_xfer_rate(ide_drive_t *drive) { - ide_hwif_t *hwif = HWIF(drive); - /* Tune the drive for PIO modes up to PIO 4 */ cs5520_tune_drive(drive, 4); Ugh. Why not ask drive? :-/ /* Then tell the core to use DMA operations */ - return hwif->ide_dma_on(drive); + return 0; That must be the famous VDMA thing... :-) I wonder if it *actually* works on HPT36x/37x which seem to have support for it... Index: b/drivers/ide/pci/jmicron.c === --- a/drivers/ide/pci/jmicron.c +++ b/drivers/ide/pci/jmicron.c @@ -164,14 +164,12 @@ static int config_chipset_for_dma (ide_d static int jmicron_config_drive_for_dma (ide_drive_t *drive) { - ide_hwif_t *hwif= drive->hwif; + if (ide_use_dma(drive) && config_chipset_for_dma(drive)) + return 0; - if (ide_use_dma(drive)) { - if (config_chipset_for_dma(drive)) - return hwif->ide_dma_on(drive); - } config_jmicron_chipset_for_pio(drive, 1); The 2nd argument of that funtion is useless -- it basically does nothing if 0 is passed. Another case of mindless copy-paste. :-) Index: b/drivers/ide/pci/pdc202xx_old.c === --- a/drivers/ide/pci/pdc202xx_old.c +++ b/drivers/ide/pci/pdc202xx_old.c @@ -332,17 +332,15 @@ chipset_is_set: static int pdc202xx_config_drive_xfer_rate (ide_drive_t *drive) { - ide_hwif_t *hwif= HWIF(drive); - drive->init_speed = 0; if (ide_use_dma(drive) && config_chipset_for_dma(drive)) - return hwif->ide_dma_on(drive); + return 0; if (ide_use_fast_pio(drive)) - hwif->tuneproc(drive, 5); + config_chipset_for_pio(drive, 5); That part is obsoleted by my recent fix... Index: b/drivers/ide/pci/piix.c === --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c @@ -386,20 +386,18 @@ static int piix_config_drive_for_dma (id static int piix_config_drive_xfer_rate (ide_drive_t *drive) { - ide_hwif_t *hwif= HWIF(drive); - drive->init_speed = 0; if (ide_use_dma(drive) && piix_config_drive_for_dma(drive)) - return hwif->ide_dma_on(drive); + return 0; if (ide_use_fast_pio(drive)) { /* Find best PIO mode. */ - (void) hwif->speedproc(drive, XFER_PIO_0 + - ide_get_best_pio_mode(drive, 255, 4, NULL)); + u8 pio = ide_get_best_pio_mode(drive, 255, 4, NULL); + (void)piix_tune_chipset(drive, XFER_PIO_0 + pio); } Will try to fix the tuneproc() nuisance RSN. :-) Index: b/drivers/ide/pci/serverworks.c === --- a/drivers/ide/pci/serverworks.c +++ b/drivers/ide/pci/serverworks.c @@ -315,17 +315,15 @@ static int config_chipset_for_dma (ide_d static int
Re: [PATCH 10/15] ide: add ide_set_dma() helper
Hello again. :-) Bartlomiej Zolnierkiewicz wrote: [PATCH] ide: add ide_set_dma() helper * add ide_set_dma() helper and make ide_hwif_t.ide_dma_check return -1 when DMA needs to be disabled (== need to call -ide_dma_off_quietly) 0 when DMA needs to be enabled (== need to call -ide_dma_on) 1 when DMA setting shouldn't be changed * fix IDE code to use ide_set_dma() instead if using -ide_dma_check directly Here are a few comments related to the code being patched: Index: b/drivers/ide/pci/alim15x3.c === --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c @@ -507,17 +507,15 @@ static int config_chipset_for_dma (ide_d * * Configure a drive for DMA operation. If DMA is not possible we * drop the drive into PIO mode instead. - * - * FIXME: exactly what are we trying to return here */ - + static int ali15x3_config_drive_for_dma(ide_drive_t *drive) { ide_hwif_t *hwif= HWIF(drive); struct hd_driveid *id = drive-id; if ((m5229_revision=0x20) (drive-media!=ide_disk)) - return hwif-ide_dma_off_quietly(drive); + goto no_dma_set; Isn't it better to just return -1? @@ -552,9 +550,10 @@ try_dma_modes: ata_pio: hwif-tuneproc(drive, 255); no_dma_set: - return hwif-ide_dma_off_quietly(drive); + return -1; } - return hwif-ide_dma_on(drive); + + return 0; } Ugh, this code looks like it's asking to be converted into calling ide_use_dma(). instead all of that... Index: b/drivers/ide/pci/cs5520.c === --- a/drivers/ide/pci/cs5520.c +++ b/drivers/ide/pci/cs5520.c @@ -132,12 +132,11 @@ static void cs5520_tune_drive(ide_drive_ static int cs5520_config_drive_xfer_rate(ide_drive_t *drive) { - ide_hwif_t *hwif = HWIF(drive); - /* Tune the drive for PIO modes up to PIO 4 */ cs5520_tune_drive(drive, 4); Ugh. Why not ask drive? :-/ /* Then tell the core to use DMA operations */ - return hwif-ide_dma_on(drive); + return 0; That must be the famous VDMA thing... :-) I wonder if it *actually* works on HPT36x/37x which seem to have support for it... Index: b/drivers/ide/pci/jmicron.c === --- a/drivers/ide/pci/jmicron.c +++ b/drivers/ide/pci/jmicron.c @@ -164,14 +164,12 @@ static int config_chipset_for_dma (ide_d static int jmicron_config_drive_for_dma (ide_drive_t *drive) { - ide_hwif_t *hwif= drive-hwif; + if (ide_use_dma(drive) config_chipset_for_dma(drive)) + return 0; - if (ide_use_dma(drive)) { - if (config_chipset_for_dma(drive)) - return hwif-ide_dma_on(drive); - } config_jmicron_chipset_for_pio(drive, 1); The 2nd argument of that funtion is useless -- it basically does nothing if 0 is passed. Another case of mindless copy-paste. :-) Index: b/drivers/ide/pci/pdc202xx_old.c === --- a/drivers/ide/pci/pdc202xx_old.c +++ b/drivers/ide/pci/pdc202xx_old.c @@ -332,17 +332,15 @@ chipset_is_set: static int pdc202xx_config_drive_xfer_rate (ide_drive_t *drive) { - ide_hwif_t *hwif= HWIF(drive); - drive-init_speed = 0; if (ide_use_dma(drive) config_chipset_for_dma(drive)) - return hwif-ide_dma_on(drive); + return 0; if (ide_use_fast_pio(drive)) - hwif-tuneproc(drive, 5); + config_chipset_for_pio(drive, 5); That part is obsoleted by my recent fix... Index: b/drivers/ide/pci/piix.c === --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c @@ -386,20 +386,18 @@ static int piix_config_drive_for_dma (id static int piix_config_drive_xfer_rate (ide_drive_t *drive) { - ide_hwif_t *hwif= HWIF(drive); - drive-init_speed = 0; if (ide_use_dma(drive) piix_config_drive_for_dma(drive)) - return hwif-ide_dma_on(drive); + return 0; if (ide_use_fast_pio(drive)) { /* Find best PIO mode. */ - (void) hwif-speedproc(drive, XFER_PIO_0 + - ide_get_best_pio_mode(drive, 255, 4, NULL)); + u8 pio = ide_get_best_pio_mode(drive, 255, 4, NULL); + (void)piix_tune_chipset(drive, XFER_PIO_0 + pio); } Will try to fix the tuneproc() nuisance RSN. :-) Index: b/drivers/ide/pci/serverworks.c === --- a/drivers/ide/pci/serverworks.c +++ b/drivers/ide/pci/serverworks.c @@ -315,17 +315,15 @@ static int config_chipset_for_dma (ide_d static int
[PATCH 10/15] ide: add ide_set_dma() helper
[PATCH] ide: add ide_set_dma() helper * add ide_set_dma() helper and make ide_hwif_t.ide_dma_check return -1 when DMA needs to be disabled (== need to call ->ide_dma_off_quietly) 0 when DMA needs to be enabled (== need to call ->ide_dma_on) 1 when DMA setting shouldn't be changed * fix IDE code to use ide_set_dma() instead if using ->ide_dma_check directly Signed-off-by: Bartlomiej Zolnierkiewicz <[EMAIL PROTECTED]> --- drivers/ide/arm/icside.c |5 + drivers/ide/cris/ide-cris.c|6 ++ drivers/ide/ide-dma.c | 37 ++--- drivers/ide/ide-io.c |2 +- drivers/ide/ide-probe.c|2 +- drivers/ide/ide.c |3 ++- drivers/ide/mips/au1xxx-ide.c |4 ++-- drivers/ide/pci/aec62xx.c |6 ++ drivers/ide/pci/alim15x3.c | 11 +-- drivers/ide/pci/amd74xx.c |5 +++-- drivers/ide/pci/atiixp.c |7 +++ drivers/ide/pci/cmd64x.c |6 ++ drivers/ide/pci/cs5520.c |5 ++--- drivers/ide/pci/cs5530.c |5 + drivers/ide/pci/cs5535.c |5 ++--- drivers/ide/pci/hpt34x.c |8 +++- drivers/ide/pci/hpt366.c |6 ++ drivers/ide/pci/it8213.c | 14 ++ drivers/ide/pci/it821x.c | 12 +--- drivers/ide/pci/jmicron.c | 10 -- drivers/ide/pci/ns87415.c |3 ++- drivers/ide/pci/pdc202xx_new.c |8 +++- drivers/ide/pci/pdc202xx_old.c |8 +++- drivers/ide/pci/piix.c | 10 -- drivers/ide/pci/sc1200.c |5 + drivers/ide/pci/serverworks.c |6 ++ drivers/ide/pci/sgiioc4.c |4 ++-- drivers/ide/pci/siimage.c |6 ++ drivers/ide/pci/sis5513.c |6 ++ drivers/ide/pci/sl82c105.c |6 +++--- drivers/ide/pci/slc90e66.c | 10 -- drivers/ide/pci/tc86c001.c |6 ++ drivers/ide/pci/triflex.c |9 - drivers/ide/pci/via82cxxx.c|5 +++-- include/linux/ide.h|2 ++ 35 files changed, 118 insertions(+), 135 deletions(-) Index: b/drivers/ide/arm/icside.c === --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c @@ -365,10 +365,7 @@ static int icside_dma_check(ide_drive_t out: on = icside_set_speed(drive, xfer_mode); - if (on) - return icside_dma_on(drive); - else - return icside_dma_off_quietly(drive); + return on ? 0 : -1; } static int icside_dma_end(ide_drive_t *drive) Index: b/drivers/ide/cris/ide-cris.c === --- a/drivers/ide/cris/ide-cris.c +++ b/drivers/ide/cris/ide-cris.c @@ -1048,12 +1048,10 @@ static ide_startstop_t cris_dma_intr (id static int cris_dma_check(ide_drive_t *drive) { - ide_hwif_t *hwif = drive->hwif; - if (ide_use_dma(drive) && cris_config_drive_for_dma(drive)) - return hwif->ide_dma_on(drive); + return 0; - return hwif->ide_dma_off_quietly(drive); + return -1; } static int cris_dma_end(ide_drive_t *drive) Index: b/drivers/ide/ide-dma.c === --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c @@ -348,15 +348,14 @@ EXPORT_SYMBOL_GPL(ide_destroy_dmatable); static int config_drive_for_dma (ide_drive_t *drive) { struct hd_driveid *id = drive->id; - ide_hwif_t *hwif = HWIF(drive); - if ((id->capability & 1) && hwif->autodma) { + if ((id->capability & 1) && drive->hwif->autodma) { /* * Enable DMA on any drive that has * UltraDMA (mode 0/1/2/3/4/5/6) enabled */ if ((id->field_valid & 4) && ((id->dma_ultra >> 8) & 0x7f)) - return hwif->ide_dma_on(drive); + return 0; /* * Enable DMA on any drive that has mode2 DMA * (multi or single) enabled @@ -364,14 +363,14 @@ static int config_drive_for_dma (ide_dri if (id->field_valid & 2)/* regular DMA */ if ((id->dma_mword & 0x404) == 0x404 || (id->dma_1word & 0x404) == 0x404) - return hwif->ide_dma_on(drive); + return 0; /* Consult the list of known "good" drives */ if (__ide_dma_good_drive(drive)) - return hwif->ide_dma_on(drive); + return 0; } -// if (hwif->tuneproc != NULL) hwif->tuneproc(drive, 255); - return hwif->ide_dma_off_quietly(drive); + + return -1; } /** @@ -765,6 +764,30 @@ bug_dma_off: EXPORT_SYMBOL(ide_dma_verbose); +int ide_set_dma(ide_drive_t *drive) +{ + ide_hwif_t *hwif =
[PATCH 10/15] ide: add ide_set_dma() helper
[PATCH] ide: add ide_set_dma() helper * add ide_set_dma() helper and make ide_hwif_t.ide_dma_check return -1 when DMA needs to be disabled (== need to call -ide_dma_off_quietly) 0 when DMA needs to be enabled (== need to call -ide_dma_on) 1 when DMA setting shouldn't be changed * fix IDE code to use ide_set_dma() instead if using -ide_dma_check directly Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED] --- drivers/ide/arm/icside.c |5 + drivers/ide/cris/ide-cris.c|6 ++ drivers/ide/ide-dma.c | 37 ++--- drivers/ide/ide-io.c |2 +- drivers/ide/ide-probe.c|2 +- drivers/ide/ide.c |3 ++- drivers/ide/mips/au1xxx-ide.c |4 ++-- drivers/ide/pci/aec62xx.c |6 ++ drivers/ide/pci/alim15x3.c | 11 +-- drivers/ide/pci/amd74xx.c |5 +++-- drivers/ide/pci/atiixp.c |7 +++ drivers/ide/pci/cmd64x.c |6 ++ drivers/ide/pci/cs5520.c |5 ++--- drivers/ide/pci/cs5530.c |5 + drivers/ide/pci/cs5535.c |5 ++--- drivers/ide/pci/hpt34x.c |8 +++- drivers/ide/pci/hpt366.c |6 ++ drivers/ide/pci/it8213.c | 14 ++ drivers/ide/pci/it821x.c | 12 +--- drivers/ide/pci/jmicron.c | 10 -- drivers/ide/pci/ns87415.c |3 ++- drivers/ide/pci/pdc202xx_new.c |8 +++- drivers/ide/pci/pdc202xx_old.c |8 +++- drivers/ide/pci/piix.c | 10 -- drivers/ide/pci/sc1200.c |5 + drivers/ide/pci/serverworks.c |6 ++ drivers/ide/pci/sgiioc4.c |4 ++-- drivers/ide/pci/siimage.c |6 ++ drivers/ide/pci/sis5513.c |6 ++ drivers/ide/pci/sl82c105.c |6 +++--- drivers/ide/pci/slc90e66.c | 10 -- drivers/ide/pci/tc86c001.c |6 ++ drivers/ide/pci/triflex.c |9 - drivers/ide/pci/via82cxxx.c|5 +++-- include/linux/ide.h|2 ++ 35 files changed, 118 insertions(+), 135 deletions(-) Index: b/drivers/ide/arm/icside.c === --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c @@ -365,10 +365,7 @@ static int icside_dma_check(ide_drive_t out: on = icside_set_speed(drive, xfer_mode); - if (on) - return icside_dma_on(drive); - else - return icside_dma_off_quietly(drive); + return on ? 0 : -1; } static int icside_dma_end(ide_drive_t *drive) Index: b/drivers/ide/cris/ide-cris.c === --- a/drivers/ide/cris/ide-cris.c +++ b/drivers/ide/cris/ide-cris.c @@ -1048,12 +1048,10 @@ static ide_startstop_t cris_dma_intr (id static int cris_dma_check(ide_drive_t *drive) { - ide_hwif_t *hwif = drive-hwif; - if (ide_use_dma(drive) cris_config_drive_for_dma(drive)) - return hwif-ide_dma_on(drive); + return 0; - return hwif-ide_dma_off_quietly(drive); + return -1; } static int cris_dma_end(ide_drive_t *drive) Index: b/drivers/ide/ide-dma.c === --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c @@ -348,15 +348,14 @@ EXPORT_SYMBOL_GPL(ide_destroy_dmatable); static int config_drive_for_dma (ide_drive_t *drive) { struct hd_driveid *id = drive-id; - ide_hwif_t *hwif = HWIF(drive); - if ((id-capability 1) hwif-autodma) { + if ((id-capability 1) drive-hwif-autodma) { /* * Enable DMA on any drive that has * UltraDMA (mode 0/1/2/3/4/5/6) enabled */ if ((id-field_valid 4) ((id-dma_ultra 8) 0x7f)) - return hwif-ide_dma_on(drive); + return 0; /* * Enable DMA on any drive that has mode2 DMA * (multi or single) enabled @@ -364,14 +363,14 @@ static int config_drive_for_dma (ide_dri if (id-field_valid 2)/* regular DMA */ if ((id-dma_mword 0x404) == 0x404 || (id-dma_1word 0x404) == 0x404) - return hwif-ide_dma_on(drive); + return 0; /* Consult the list of known good drives */ if (__ide_dma_good_drive(drive)) - return hwif-ide_dma_on(drive); + return 0; } -// if (hwif-tuneproc != NULL) hwif-tuneproc(drive, 255); - return hwif-ide_dma_off_quietly(drive); + + return -1; } /** @@ -765,6 +764,30 @@ bug_dma_off: EXPORT_SYMBOL(ide_dma_verbose); +int ide_set_dma(ide_drive_t *drive) +{ + ide_hwif_t *hwif = drive-hwif; + int rc; + + rc =