Skip to contentSkip to conversation

mmc: bcm2835: fix delays in bug workaround

PATCH New Stephen Warren 2 participants 3 messages Mar 22, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: bcm2835: fix delays in bug workaround

The back-to-back-writes workaround in the BCM2835 MMC driver assumed that get_timer() returned uS. Now that it returns mS, the delay is far too long. Use udelay() directly to avoid this. Dispense with the "last_write" code since we now have no way of recording an absolute time in uS. The difference between two un-averaged tests loading a zImage is 445 mS vs the original 412 mS, so the difference doesn't appear too relevant.

---
 drivers/mmc/bcm2835_sdhci.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/mmc/bcm2835_sdhci.c +1 -5
index b0afc3c..240b5ec 100644
@@ -46,7 +46,6 @@
 struct bcm2835_sdhci_host {
 	struct sdhci_host host;
 	uint twoticks_delay;
-	ulong last_write;
 };
 
 static inline struct bcm2835_sdhci_host *to_bcm(struct sdhci_host *host)
@@ -67,11 +66,9 @@ static inline void bcm2835_sdhci_raw_writel(struct sdhci_host *host, u32 val,
 	 * (Which is just as well - otherwise we'd have to nobble the DMA engine
 	 * too)
 	 */
-	while (get_timer(bcm_host->last_write) < bcm_host->twoticks_delay)
-		;
+	udelay(bcm_host->twoticks_delay);
 
 	writel(val, host->ioaddr + reg);
-	bcm_host->last_write = get_timer(0);
 }
 
 static inline u32 bcm2835_sdhci_raw_readl(struct sdhci_host *host, int reg)
@@ -172,7 +169,6 @@ int bcm2835_sdhci_init(u32 regbase, u32 emmc_freq)
 	 * +1 for hack rounding.
 	 */
 	bcm_host->twoticks_delay = ((2 * 1000000) / MIN_FREQ) + 1;
-	bcm_host->last_write = 0;
 
 	host = &bcm_host->host;
 	host->name = "bcm2835_sdhci";
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/1 mmc: bcm2835: fix delays in bug workaround

Hi Stephen,

Quoted 7 lines · Stephen Warren

The back-to-back-writes workaround in the BCM2835 MMC driver assumed that get_timer() returned uS. Now that it returns mS, the delay is far too long. Use udelay() directly to avoid this. Dispense with the "last_write" code since we now have no way of recording an absolute time in uS. The difference between two un-averaged tests loading a zImage is 445 mS vs the original 412 mS, so the difference doesn't appear too relevant.

I don't entirely get the 'we have no way of recording an absolute time in us': doesn't get_timer_us() precisely provide this absolute us time just like 'old' get_timer(base) did? IOW, could you not simply turn every get_timer(X) into (get_timer_us()-X)?

Quoted 31 lines
---
 drivers/mmc/bcm2835_sdhci.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/mmc/bcm2835_sdhci.c +1 -4
index b0afc3c..240b5ec 100644
@@ -46,7 +46,6 @@
 struct bcm2835_sdhci_host {
 	struct sdhci_host host;
 	uint twoticks_delay;
-	ulong last_write;
 };
 
 static inline struct bcm2835_sdhci_host *to_bcm(struct sdhci_host *host)
@@ -67,11 +66,9 @@ static inline void bcm2835_sdhci_raw_writel(struct sdhci_host *host, u32 val,
 	 * (Which is just as well - otherwise we'd have to nobble the DMA engine
 	 * too)
 	 */
-	while (get_timer(bcm_host->last_write) < bcm_host->twoticks_delay)
-		;
+	udelay(bcm_host->twoticks_delay);
 
 	writel(val, host->ioaddr + reg);
-	bcm_host->last_write = get_timer(0);
 }
 
 static inline u32 bcm2835_sdhci_raw_readl(struct sdhci_host *host, int reg)

drivers/mmc/bcm2835_sdhci.c int bcm2835_sdhci_init(u32 regbase, u32 emmc_freq) · line 174

Quoted 7 lines
drivers/mmc/bcm2835_sdhci.c +0 -1
@@ -172,7 +169,6 @@ int bcm2835_sdhci_init(u32 regbase, u32 emmc_freq)
 	 * +1 for hack rounding.
 	 */
 	bcm_host->twoticks_delay = ((2 * 1000000) / MIN_FREQ) + 1;
-	bcm_host->last_write = 0;
 
 	host = &bcm_host->host;
 	host->name = "bcm2835_sdhci";

Amicalement,

Signature · 1 line
Albert.
#2 lore raw

PATCH 1/1 mmc: bcm2835: fix delays in bug workaround

Quoted 13 lines · Albert ARIBAUD

Hi Stephen,

Quoted 7 lines · Stephen Warren

The back-to-back-writes workaround in the BCM2835 MMC driver assumed that get_timer() returned uS. Now that it returns mS, the delay is far too long. Use udelay() directly to avoid this. Dispense with the "last_write" code since we now have no way of recording an absolute time in uS. The difference between two un-averaged tests loading a zImage is 445 mS vs the original 412 mS, so the difference doesn't appear too relevant.

Quoted 4 lines

I don't entirely get the 'we have no way of recording an absolute time in us': doesn't get_timer_us() precisely provide this absolute us time just like 'old' get_timer(base) did? IOW, could you not simply turn every get_timer(X) into (get_timer_us()-X)?

Well, I could do that, but that's an internal private API inside timer.c, not something exported. Should I explicitly export it and allow the driver to use that?