This patch adds generic ATA auto-tuning to kernel 2.4.0-test1-ac17... I hope idea of it isn't totally braindamaged :) PS Sorry for eventually broken english I was a bit tired writing this Here are some historical background: While playing with IDE I have noticed that all PCI-IDE drivers use almost the same auto-tuning functions. After some thinking I came to conclusion that auto-tuning can be dealt with use of some generic routines. Here are pros and cons: + source code is smaller (~23kB removed) + kernel is smaller (when we compile support for all chipsets ~5kB ;) + code is cleaner, easier to understand + we can but _don't have to_ use generic auto-tuning functions + we check chipset capabilities only once + blah... blah... - code is slighlty (unnoticable) slower - we have additional fields in hwif_t: - I haven't yet made a CONFIG option so generic a-t functions get compiled even when they aren't used - it can be done better (and will be!) One more thing to consider is if we should add some quirks-dealing functions Just look through hpt366.c and you will know what I'm taking about. Here is a very detailed description of changes: [Q] - mean question/thing to think about *drivers/ide/aec62xx.c: - aec62xx_tune_chipset() removed, we decide whether use aec6210_tune_chipset() or aec6260_tune_chipset() during chipset initialization (ide_init_aec62xx() ) - config_aec6210_chipset_for_dma(), config_aec6260_chipset_for_dma() and config_chipset_for_dma() renamed to aec62xx_config_dma() which now make use of ide_config_chipset_for_dma() diffirencies between old and new behaviour: [Q] - drive's DMA is disabled in ide_config_drive_speed() called from aec62xx_tune_chipset(), or we have to disable DMA on drive before tuning chipset? - speed variable was by default set to -1, but this is irrelevant because pci_bus_clock_list() called from aec62xx_tune_chipset() will set it to 0x00 anyway [Q] - if drive has UDMA4/3 we were tuning aec6210 to UDMA2, now we are doing it for UDMA4, if drive has UDMA3 we tune aec6210 to UDMA1, is this ok? [Q] - if drive has UDMA3/4 enabled config_aec6210_chipset_for_dma() will return ide_dma_off, but this shouldn't happend beacuse ide_config_drive_speed() sets correct drive speed - config_drive_xfer_rate() removed, now we use ide_config_drive_xfer_rate() *drivers/ide/alim15x3.c - config_chipset_for_pio() renamed to ali15x3_config_pio() - config_chipset_for_dma() removed, now we use ide_config_chipset_for_pio(), no changes in old/new code behaviour - ali15x3_config_drive_for_dma() can be in future replaced by ide_config_drive_xfer_rate() (but only if we add some quirks support to it) *drivers/ide/amd7509.c - DEBUG symbol replaced by AMD7409_DEBUG to avoid confusion - enabling/disabling DMA on drive removed from amd7409_tune_chipset(), because right after it we call ide_config_drive_speed() which do the same - config_chipset_for_pio() removed, now we use ide_config_chipset_for_pio() which is identical - config_chipset_for_dma() removed, now we use ide_config_chipset_for_dma(), no changes in old/new code behaviour - config_drive_xfer_rate() removed, now we use ide_config_drive_xfer_rate(), diffirencies between old and new behaviour: - swdma is checked later in ide_config_chipset_for_dma() *drivers/ide/cmd64x.c - config_chipset_for_pio() renamed to cmd64x_config_pio() - config_chipset_for_dma() removed, now we use ide_config_chipset_for_dma() diffirencies between old and new behaviour: - we don't set PIO modes here (done in ide_config_drive_xfer_rate() ) - removed duplicate check for drive->media != ide_disk, it is checked already in cmd64x_dmaproc() - cmd64x_config_drive_for_dma() removed, we use ide_config_drive_xfer_rate() instead (no changes in old/new code behaviour) *drivers/ide/hpt34x.c - config_chipset_for_pio() removed, now we use ide_config_chipset_for_pio() diffirencies between old and new behaviour: - we are now checking drive->id->tPIO - config_chipset_for_dma() renamed to hpt34x_config_dma(), it make use of ide_config_chipset_for_dma() diffirencies between old and new behaviour: [Q] - if drive has UDMA3/4 enabled hpt34x_config_dma() will return ide_dma_off, but this shouldn't happend beacuse ide_config_drive_speed() sets correct drive speed - config_drive_xfer_rate() removed, now we use ide_config_drive_xfer_rate(), diffirencies between old and new behaviour: [Q] - CONFIG_HPT34X_AUTODMA is now moved to hpt34x_config_dma(), it won't now return ide_dma_off but ide_dma_off_quietly, can somebody explain this config option? *drivers/ide/hpt366.c - DEBUG symbol renamed to HPT366_DEBUG_ATA66 to avoid confusion - config_chipset_for_pio() removed, now we use ide_config_chipset_for_pio(), no changes in old/new code behaviour - config_chipset_for_dma() renamed to hpt3xx_config_dma() - hpt3xx_config_dma() can be in future replaced by ide_config_drive_xfer_rate() (but only if we add some quirks support to it) - config_drive_xfer_rate() removed, now we use ide_config_drive_xfer_rate(), no changes in old/new code behaviour *drivers/ide/ide-dma.c - generic functions ide_config_chipset_for_dma(), ide_config_drive_xfer_rate() added here *drivers/ide/ide-features.c - generic function ide_config_chipset_for_pio() added here *drivers/ide/pdc202xx.c - config_chipset_for_pio() renamed to pdc202xx_config_pio() - config_chipset_for_dma() renamed to pdc202xx_config_dma() - config_drive_xfer_rate() removed, now we use ide_config_drive_xfer_rate(), diffirencies between old and new behaviour: [Q] - by defalt dma_func was set to ide_dma_off_quietly, now it is set to ide_dma_on *drivers/ide/piix.c - piix_config_drive_for_dma() renamed to piix_config_dma(), capabilities checks moved to ide_init_piix() *drivers/ide/sis5513.c - config_art_rwp_pio() cleaned a bit - config_chipset_for_pio() renamed to sis5513_config_pio(), now it makes use of ide_config_chipset_for_pio() diffirencies between old and new behaviour: - we are now checking drive->id->tPIO - config_chipset_for_dma() renamed to sis5513_config_dma() diffirencies between old and new behaviour: [Q] - by defalt dma_func was set to ide_dma_off_quietly, now it is set to ide_dma_on [Q] - we were checking if id->eide_dma_time > 150, if yes we eventually enable DMA, in all other drivers if id->eide_dma_time > 150 we don't enable DMA -> this is the current behaviour now *drivers/ide/via82cxxx.c - config_chipset_for_pio() removed, now we use ide_config_chipset_for_pio(), no changes in old/new code behaviour - config_chipset_for_dma() removed, now we use ide_config_chipset_for_dma(), no changes in old/new code behaviour, but [Q] - in ATA-100 patch against 240t1-ac12 Andre removed SW_DMA support, why? - config_drive_xfer_rate() removed, now we use ide_config_drive_xfer_rate(), no changes in old/new code behaviour *include/linux/ide.h - new things added to hwif_t: config_pio() - tune drive & chipset to best available PIO mode config_dma() - tune drive & chipset to best available DMA mode ultra100 - do chipset support ATA100 ? ultra66 - do chipset support ATA66 ? ultra33 - do chipset support ATA33 ? dma_1word - do chipset support SW-DMA modes? *CREDITS - I added myself to credits :-)