sdhci can turn off irq up to 200 ms
Hi,
sdhci code got tasklets (sdhci_tasklet_card and sdhci_tasklet_finish), that does :
{spin_lock_irqsave
if (cond) {sdhci_resetsdhci_reset
}
spin_unlock_irqrestore
}
The problem is that sdhci_reset [1] does busy pooling on a register up to a timeout of 100 ms.
That's not low latency friendly.
On our system, we saw that sdhci_reset take 1 ms. That should be because we enter in mdelay, even if the hardware clears the bit faster. I wonder why there is an mdelay(1). Using cpu_relax and time_is_after_jiffies should make sdhci_reset faster.
Matthieu
[1]
static void sdhci_reset(struct sdhci_host *host, u8 mask)
{
unsigned long timeout;
u32 uninitialized_var(ier);
[...]
sdhci_writeb(host, mask, SDHCI_SOFTWARE_RESET);
if (mask & SDHCI_RESET_ALL)
host->clock = 0;
/* Wait max 100 ms */
timeout = 100;
/* hw clears the bit when it's done */
while (sdhci_readb(host, SDHCI_SOFTWARE_RESET) & mask) {
if (timeout == 0) {
printk(KERN_ERR "%s: Reset 0x%x never completed.\n",
mmc_hostname(host->mmc), (int)mask);
sdhci_dumpregs(host);
return;
}
timeout--;
mdelay(1);
}[...]
}
Quoted 15 lines · Matthieu CASTET
Hi,
sdhci code got tasklets (
sdhci_tasklet_cardandsdhci_tasklet_finish), that does :
{spin_lock_irqsaveif (cond) {
sdhci_resetsdhci_reset
}
spin_unlock_irqrestore
}
Quoted 9 lines
The problem is that
sdhci_reset[1] does busy pooling on a register up to a timeout of 100 ms.
That's not low latency friendly.On our system, we saw that
sdhci_resettake 1 ms. That should be because we enter in mdelay, even if the hardware clears the bit faster. I wonder why there is an mdelay(1). Usingcpu_relaxandtime_is_after_jiffiesshould makesdhci_resetfaster.
In case somebody cares, here a patch that reduce on our hardware sdhci_reset from 1 ms to 30 us.
Matthieu
drivers/mmc/host/sdhci.c +3 -4
@@ -156,18 +156,17 @@ static void sdhci_reset(struct sdhci_host *host, u8 mask) host->clock =0 ;/* Wait max 100 ms */ - timeout =100 ; + timeout = jiffies +msecs_to_jiffies (100 );/* hw clears the bit when it's done */ while (sdhci_readb (host,SDHCI_SOFTWARE_RESET ) & mask) { -if (timeout ==0 ) { +if (time_is_before_jiffies (timeout)) {printk (KERN_ERR "%s: Reset 0x%x never completed.\n" ,mmc_hostname (host->mmc), (int )mask);sdhci_dumpregs (host);return ; } - timeout--; -mdelay (1 ); +cpu_relax (); }if (host->quirks &SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET )
Quoted 20 lines · On Thu, 9 Jul 2009 12:28:01 +0200 Matthieu CASTET <[email protected]>…
Quoted 19 lines · Matthieu CASTET
Hi,
sdhci code got tasklets (
sdhci_tasklet_cardandsdhci_tasklet_finish), that does :
{spin_lock_irqsaveif (cond) {
sdhci_resetsdhci_reset
}
spin_unlock_irqrestore
}The problem is that
sdhci_reset[1] does busy pooling on a register up to a timeout of 100 ms.
That's not low latency friendly.
Quoted 8 lines
Quoted 5 lines
On our system, we saw that
sdhci_resettake 1 ms. That should be because we enter in mdelay, even if the hardware clears the bit faster. I wonder why there is an mdelay(1). Usingcpu_relaxandtime_is_after_jiffiesshould makesdhci_resetfaster.In case somebody cares, here a patch that reduce on our hardware
sdhci_resetfrom 1 ms to 30 us.
I seem to recall having problems with jiffies not updating with those locks held (or perhaps it was when inside the isr).
What arch have you been testing this on?
Rgds
Signature · 6 lines
-- Pierre Ossman WARNING: This correspondence is being monitored by the Swedish government. Make sure your server uses encryption for SMTP traffic and consider using PGP for end-to-end encryption.
Quoted 28 lines · Pierre Ossman
Quoted 25 lines · On Thu, 9 Jul 2009 12:28:01 +0200 Matthieu CASTET <[email protected]>…
Quoted 24 lines · Matthieu CASTET
Hi,
sdhci code got tasklets (
sdhci_tasklet_cardandsdhci_tasklet_finish), that does :
{spin_lock_irqsaveif (cond) {
sdhci_resetsdhci_reset
}
spin_unlock_irqrestore
}The problem is that
sdhci_reset[1] does busy pooling on a register up to a timeout of 100 ms.
That's not low latency friendly.On our system, we saw that
sdhci_resettake 1 ms. That should be because we enter in mdelay, even if the hardware clears the bit faster. I wonder why there is an mdelay(1). Usingcpu_relaxandtime_is_after_jiffiesshould makesdhci_resetfaster.
Quoted 8 lines
Quoted 3 lines
In case somebody cares, here a patch that reduce on our hardware
sdhci_resetfrom 1 ms to 30 us.I seem to recall having problems with jiffies not updating with those locks held (or perhaps it was when inside the isr).
What arch have you been testing this on?
It have been tested on arm.
Matthieu
Quoted 8 lines · On Mon, 7 Sep 2009 11:56:10 +0200 Matthieu CASTET <[email protected]>…
Quoted 5 lines · Pierre Ossman
I seem to recall having problems with jiffies not updating with those locks held (or perhaps it was when inside the isr).
What arch have you been testing this on?
It have been tested on arm.
Things might be different there. I suggest you also try to get it tested on x86, where this driver sees most of its use.
Rgds
Signature · 6 lines
-- Pierre Ossman WARNING: This correspondence is being monitored by the Swedish government. Make sure your server uses encryption for SMTP traffic and consider using PGP for end-to-end encryption.
Quoted 7 lines · Pierre Ossman
Quoted 4 lines · On Mon, 7 Sep 2009 11:56:10 +0200 Matthieu CASTET <[email protected]>…
Quoted 3 lines · Pierre Ossman
I seem to recall having problems with jiffies not updating with those locks held (or perhaps it was when inside the isr).
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
What arch have you been testing this on?
It have been tested on arm.
Things might be different there. I suggest you also try to get it tested on x86, where this driver sees most of its use.
I don't have sdhci device on x86. Can somebody on this list try it ?
Thanks
Matthieu