Cleanup for CS5535 IDE driver
RFC 1/1 Cleanup for CS5535 IDE driver
Hi Bartlomiej, IDE folk,
Appended is my patch attempting to fix up the cs5535 driver as per your suggestions from the thread:
http://marc.theaimsgroup.com/?l=linux-ide&m=112533052120330&w=2
I listed what I did with respect to that todo list below:
Quoted 3 lines
*
cs5535_tuneproc()needs to be fixed to not abuse ->tuneproc interface (which is exported to user-space), all DMA tuning should be done through ->speedproc interface only
Done.
Quoted 2 lines
*
cs5535_set_drive()needs to useide_rate_filter()to limit values passed from the user-space
Done. btw, thanks for the eighty93 explaination yesterday. I hope I got that part right in this.
Quoted 2 lines
*
cs5535_set_drive()needs to set drive's speed unconditionally otherwise drive may not be setup correctly after resume
Done.
Quoted 1 line
*
cs5535_set_drive()shouldn't changedrive->current_speed
Done.
Quoted 1 line
* cable detection needs to be in separate function (for hotplug - later)
I'm not sure I followed. By cable detection, I think you are pointing to init_hwif_cs5535:
/* if a 80 wire cable was detected */ pci_read_config_byte(hwif->pci_dev, CS5535_CABLE_DETECT, &bit); hwif->udma_four = bit & 1;
I think we can leave this as is because the cs5535 is a SOC companion that doesn't have hotplug capability. Is that okay?
Quoted 1 line
* driver lacks device side cable detection [ see
eighty_ninty_three()]
I put eighty93 into ratemask which gets called from set_drive.
Quoted 1 line
* driver needs to check for blacklisted DMA devices [ see
ide_use_dma()]
Done. I added it in dma_check to match what the other drivers do.
Quoted 1 line
*
init_hwif_cs5535()should be marked__devinitnot__init
Since 5535 has no hotplug capability, I set all to __init.
Quoted 1 line
*
cs5535_ide_init()lacks__inittag
Done.
Quoted 1 line
* .name in driver struct should be "
CS5535_IDE" (w/o space)
Done.
Quoted 1 line
* what taking
ide_lockininit_chipset_cs5535()is supposed to protect?
Nothing as far as I can tell so I took it out.
Quoted 2 lines
* it would be simpler to always set ->autotune and tune PIO instead of checking for BIOS settings
Sounds logical. So I took out the reg reads and just set autotune.
Quoted 1 line
* use '
drive->hwif' instead of 'HWIF' macro
Done.
Quoted 1 line
* use 'u8' instead of 'byte' type
Done.
Quoted 1 line
* remove unneeded includes
Done.
Quoted 1 line
* proper coding style:
Done.
I did the patch against 2.6.13.1. fyi, the part adding 5535_IDE to pci_ids.h duplicates a prior alsa patch I did that is in akpm's -mm. I think I should have made the pci_ids diff separate.
I only tested with a single drive that turned out to only be capable of MWDMA2 since that's what I have available right now. I'll try to borrow a UDMA4 capable drive and 80c cable if I have a chance.
Model=QUANTUM FIREBALL_TM1280A, FwRev=A6B.2D00, SerialNo=692716821653 Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>5Mbs TrkOff } RawCHS=2484/16/63, TrkSize=32256, SectSize=512, ECCbytes=4 BuffType=DualPortCache, BuffSize=76kB, MaxMultSect=16, MultSect=16 CurCHS=2484/16/63, CurSects=2503872, LBA=yes, LBAsects=2503872 IORDY=on/off, tPIO={min:300,w/IORDY:120}, tDMA={min:120,rec:120} PIO modes: pio0 pio1 pio2 pio3 pio4
DMA modes: sdma0 sdma1 sdma2 mdma0 mdma1 *mdma2 AdvancedPM=no
* signifies the current active mode
Timing buffer-cache reads: 668 MB in 2.01 seconds = 332.65 MB/sec
Timing buffered disk reads: 20 MB in 3.06 seconds = 6.54 MB/sec
Please let me know how it looks and if you have any feedback.
Thanks,
Jaya Kumar
---
drivers/ide/Kconfig | 10 + drivers/ide/pci/Makefile | 1 drivers/ide/pci/cs5535.c | 365 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/pci_ids.h | 1 4 files changed, 377 insertions(+)
drivers/ide/Kconfig +10 -0
@@ -539,6 +539,16 @@ config BLK_DEV_CS5530 It is safe to say Y to this question. +config BLK_DEV_CS5535 + tristate "AMD CS5535 MediaGX chipset support" + depends on X86 && !X86_64 + help + Include support for UDMA on the Cyrix MediaGX 5535 chipset. This + will automatically be detected and configured if found. This chip + is also called NSC CS5535 geode companion in some literature. + + It is safe to say Y to this question. + config BLK_DEV_HPT34X tristate "HPT34X chipset support" help
drivers/ide/pci/cs5535.c +365 -0
365 lines not on this page · raw message
drivers/ide/pci/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_BLK_DEV_ATIIXP) += atiixp. obj-$(CONFIG_BLK_DEV_CMD64X) += cmd64x.o obj-$(CONFIG_BLK_DEV_CS5520) += cs5520.o obj-$(CONFIG_BLK_DEV_CS5530) += cs5530.o +obj-$(CONFIG_BLK_DEV_CS5535) += cs5535.o obj-$(CONFIG_BLK_DEV_SC1200) += sc1200.o obj-$(CONFIG_BLK_DEV_CY82C693) += cy82c693.o obj-$(CONFIG_BLK_DEV_HPT34X) += hpt34x.o
include/linux/pci_ids.h +1 -0
@@ -402,6 +402,7 @@#define PCI_DEVICE_ID_NS_SC1100_SMI 0x0511#define PCI_DEVICE_ID_NS_SC1100_XBUS 0x0515#define PCI_DEVICE_ID_NS_87410 0xd001 +#define PCI_DEVICE_ID_NS_CS5535_IDE 0x002d#define PCI_VENDOR_ID_TSENG 0x100c#define PCI_DEVICE_ID_TSENG_W32P_2 0x3202
Quoted 1 line · On 9/23/05, [email protected] <[email protected]> wrote:
Hi Bartlomiej, IDE folk,
Hi,
Quoted 10 lines
Appended is my patch attempting to fix up the cs5535 driver as per your suggestions from the thread:
http://marc.theaimsgroup.com/?l=linux-ide&m=112533052120330&w=2
I listed what I did with respect to that todo list below:
Quoted 3 lines
*
cs5535_tuneproc()needs to be fixed to not abuse ->tuneproc interface (which is exported to user-space), all DMA tuning should be done through ->speedproc interface only
Quoted 6 lines
Done.
Quoted 2 lines
*
cs5535_set_drive()needs to useide_rate_filter()to limit values passed from the user-spaceDone. btw, thanks for the eighty93 explaination yesterday. I hope I got that part right in this.
Yep. :)
Quoted 11 lines
Quoted 2 lines
*
cs5535_set_drive()needs to set drive's speed unconditionally otherwise drive may not be setup correctly after resumeDone.
Quoted 1 line
*
cs5535_set_drive()shouldn't changedrive->current_speedDone.
Quoted 1 line
* cable detection needs to be in separate function (for hotplug - later)
I'm not sure I followed. By cable detection, I think you are pointing to
init_hwif_cs5535:
Quoted 6 lines
/* if a 80 wire cable was detected */ pci_read_config_byte(hwif->pci_dev, CS5535_CABLE_DETECT, &bit); hwif->udma_four = bit & 1;I think we can leave this as is because the cs5535 is a SOC companion that doesn't have hotplug capability. Is that okay?
Even if chipset itself doesn't have hotplug capability please abstract cable detection code to match future IDE core changes.
Quoted 8 lines
Quoted 1 line
* driver lacks device side cable detection [ see
eighty_ninty_three()]I put eighty93 into ratemask which gets called from
set_drive.Quoted 1 line
* driver needs to check for blacklisted DMA devices [ see
ide_use_dma()]Done. I added it in
dma_checkto match what the other drivers do.Quoted 1 line
*
init_hwif_cs5535()should be marked__devinitnot__initSince 5535 has no hotplug capability, I set all to
__init.
Please use __devinit:
* there is fake PCI hotplug driver which allows you to hot(un)plug any devices
* sparse complains about wrong __init usage
Quoted 43 lines
Quoted 1 line
*
cs5535_ide_init()lacks__inittagDone.
Quoted 1 line
* .name in driver struct should be "
CS5535_IDE" (w/o space)Done.
Quoted 1 line
* what taking
ide_lockininit_chipset_cs5535()is supposed to protect?Nothing as far as I can tell so I took it out.
Quoted 2 lines
* it would be simpler to always set ->autotune and tune PIO instead of checking for BIOS settings
Sounds logical. So I took out the reg reads and just set autotune.
Quoted 1 line
* use '
drive->hwif' instead of 'HWIF' macroDone.
Quoted 1 line
* use 'u8' instead of 'byte' type
Done.
Quoted 1 line
* remove unneeded includes
Done.
Quoted 1 line
* proper coding style:
Done.
I did the patch against 2.6.13.1. fyi, the part adding 5535_IDE to
pci_ids.hduplicates a prior alsa patch I did that is in akpm's -mm. I think I should have made thepci_idsdiff separate.I only tested with a single drive that turned out to only be capable of MWDMA2 since that's what I have available right now. I'll try to borrow a UDMA4 capable drive and 80c cable if I have a chance.
Model=QUANTUM
FIREBALL_TM1280A, FwRev=A6B.2D00, SerialNo=692716821653 Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>5Mbs TrkOff } RawCHS=2484/16/63, TrkSize=32256, SectSize=512, ECCbytes=4 BuffType=DualPortCache, BuffSize=76kB, MaxMultSect=16, MultSect=16 CurCHS=2484/16/63, CurSects=2503872, LBA=yes, LBAsects=2503872 IORDY=on/off, tPIO={min:300,w/IORDY:120}, tDMA={min:120,rec:120} PIO modes: pio0 pio1 pio2 pio3 pio4
DMA modes: sdma0 sdma1 sdma2 mdma0 mdma1 *mdma2 AdvancedPM=no
Quoted 6 lines
* signifies the current active mode
Timing buffer-cache reads: 668 MB in 2.01 seconds = 332.65 MB/sec
Timing buffered disk reads: 20 MB in 3.06 seconds = 6.54 MB/secPlease let me know how it looks and if you have any feedback.
two comments below
drivers/ide/pci/cs5535.c line 250
Quoted 9 lines
drivers/ide/pci/cs5535.c +9
-0+static int cs5535_config_drive_for_dma (ide_drive_t *drive) +{ +u8 speed; + + speed =ide_dma_speed (drive,cs5535_ratemask (drive)); + +/* If no DMA speed was available then disable DMA and use PIO. */ +if (!speed) { + speed =ide_get_best_pio_mode (drive,255 ,5 ,NULL );
just return 0 and let cs5535_dma_check() take care of tuning PIO mode
Quoted 15 lines
drivers/ide/pci/cs5535.c +14
-0+ } + +cs5535_set_drive (drive, speed); +return ide_dma_enable (drive); +} +static int cs5535_dma_check (ide_drive_t *drive) +{ +ide_hwif_t *hwif = drive->hwif; +struct hd_driveid *id = drive->id; +u8 speed; + + drive->init_speed =0 ; + +if ((id->capability &1 ) && drive->autodma) {
drivers/ide/pci/cs5535.c line 275
Quoted 10 lines
drivers/ide/pci/cs5535.c +10
-0+if (ide_use_dma (drive)) { +if (cs5535_config_drive_for_dma (drive)) +return hwif->ide_dma_on (drive); + } + + goto fast_ata_pio; + + }else if ((id->capability &8 ) || (id->field_valid &2 )) { +fast_ata_pio: + speed =ide_get_best_pio_mode (drive,255 ,5 ,NULL );
wrong arguments (max PIO is 4 not 5)
drivers/ide/pci/cs5535.c line 281
Quoted 6 lines
drivers/ide/pci/cs5535.c +6
-0+cs5535_set_drive (drive, speed); +return hwif->ide_dma_off_quietly (drive); + } +/* IORDY not supported */ +return 0 ; +}
Otherwise it looks fine and I'll happily apply it after corrections.
Thanks,
Bartlomiej
Quoted 6 lines · Bartlomiej Zolnierkiewicz
Quoted 2 lines · On 9/23/05, [email protected] <[email protected]> wrote:
I think we can leave this as is because the cs5535 is a SOC companion that doesn't have hotplug capability. Is that okay?
Even if chipset itself doesn't have hotplug capability please abstract cable detection code to match future IDE core changes.
Ok. Will do.
Quoted 4 lines
Please use
__devinit:
* there is fake PCI hotplug driver which allows you to hot(un)plug any devices
* sparse complains about wrong__initusage
Will do.
Quoted 6 lines
drivers/ide/pci/cs5535.c line 250
Quoted 3 lines
drivers/ide/pci/cs5535.c +3
-0+/* If no DMA speed was available then disable DMA and use PIO. */ +if (!speed) { + speed =ide_get_best_pio_mode (drive,255 ,5 ,NULL );just return 0 and let
cs5535_dma_check()take care of tuning PIO mode
Will do.
Quoted 5 lines
drivers/ide/pci/cs5535.c line 275
Quoted 3 lines
drivers/ide/pci/cs5535.c +3
-0+ }else if ((id->capability &8 ) || (id->field_valid &2 )) { +fast_ata_pio: + speed =ide_get_best_pio_mode (drive,255 ,5 ,NULL );wrong arguments (max PIO is 4 not 5)
Oops. Corrected. I'll send these changes shortly.
Thanks,
jaya