FS#6789 - Shorten unnecessarily long sleep() in ata_init()

Attached to Project: Rockbox
Opened by Barry Wardell (barrywardell) - Saturday, 10 March 2007, 18:10 GMT
Last edited by Nils Wallménius (nls) - Sunday, 04 November 2007, 07:58 GMT
Task Type Patches
Category Drivers
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


The initialization code in the ATA driver has what appears to be an excessively long sleep() of 1HZ. The portion of code turns IDE power on only if it is currently off so it may only be rarely reached, if ever.

The comment that goes with the sleep(HZ) suggests that it is to "allow voltage to build up", but 1HZ seems like an excessively long time for this. Also, if it is needed, I think the sleep() would be better off inside the ide_power_enable() function as is already done on some targets.

Looking back over the SVN history, this code was added in revision 4095 ( to fix "spinning disk while charging flashed FM+V2". Is this problem still relevant and is this code still necessary?

This patch just shortens the sleep() to 1 tick, which should still be more than enough time for voltage stabalisation. I have tested on my H10 both with current SVN and with current SVN modified to turn IDE power off right before ata_init() is called. It seems to work fine there. I think what really needs to be tested is the issue that SVN commit 4095 fixed, so hopefully someone with a FM+V2 can test this patch and report back.
This task depends upon

Closed by  Nils Wallménius (nls)
Sunday, 04 November 2007, 07:58 GMT
Reason for closing:  Out of Date
Additional comments about closing:  Amiconn included a similar change in his recent commit that enabled ata poweroff for ipods.
Comment by Boris Gjenero (dreamlayers) - Friday, 24 August 2007, 19:04 GMT
Currently on an Archos FM or V2 Recorder ide_powered() always returns true because HAVE_ATA_POWER_OFF is not defined. Because of this the ide_power_enable(true) and sleep(HZ) are never executed. Turning on IDE power shortly before calling ata_init() works fine.