Date:2010-03-21 16:46:49 (3 years 2 months ago)
Author:lars
Commit:8ffe821c146827bebd18ddce865681ff2b661dc0
Message:[xburst] jz_mmc: Fix timeout timer. Annotate timeout checks as unlikely()

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@20349 3c298f89-4303-0410-b956-a3cf2f4a3e73
Files: target/linux/xburst/files-2.6.32/drivers/mmc/host/jz_mmc.c (11 diffs)

Change Details

target/linux/xburst/files-2.6.32/drivers/mmc/host/jz_mmc.c
101101
102102#define JZ_MMC_CLK_RATE 24000000
103103
104#define JZ4740_MMC_MAX_TIMEOUT 10000000
105
104106struct jz4740_mmc_host {
105107    struct mmc_host *mmc;
106108    struct platform_device *pdev;
...... 
212214        j = i >> 3;
213215        i = i & 0x7;
214216        while (j) {
215            timeout = 100000;
217            timeout = JZ4740_MMC_MAX_TIMEOUT;
216218            do {
217219                status = readw(host->base + JZ_REG_MMC_IREG);
218220            } while (!(status & JZ_MMC_IRQ_TXFIFO_WR_REQ) && --timeout);
219            if (timeout == 0)
221            if (unlikely(timeout == 0))
220222                goto err_timeout;
221223
222224            writew(JZ_MMC_IRQ_TXFIFO_WR_REQ, host->base + JZ_REG_MMC_IREG);
...... 
233235            --j;
234236        }
235237        if (i) {
236            timeout = 100000;
238            timeout = JZ4740_MMC_MAX_TIMEOUT;
237239            do {
238240                status = readw(host->base + JZ_REG_MMC_IREG);
239241            } while (!(status & JZ_MMC_IRQ_TXFIFO_WR_REQ) && --timeout);
240            if (timeout == 0)
242            if (unlikely(timeout == 0))
241243                goto err_timeout;
242244
243245            writew(JZ_MMC_IRQ_TXFIFO_WR_REQ, host->base + JZ_REG_MMC_IREG);
...... 
256258        goto err;
257259
258260    writew(JZ_MMC_IRQ_TXFIFO_WR_REQ, host->base + JZ_REG_MMC_IREG);
259    timeout = 100000;
261    timeout = JZ4740_MMC_MAX_TIMEOUT;
260262    do {
261263        status = readl(host->base + JZ_REG_MMC_STATUS);
262264    } while ((status & JZ_MMC_STATUS_DATA_TRAN_DONE) == 0 && --timeout);
263    if (timeout == 0)
265
266    if (unlikely(timeout == 0))
264267        goto err_timeout;
265268    writew(JZ_MMC_IRQ_DATA_TRAN_DONE, host->base + JZ_REG_MMC_IREG);
266269
...... 
312315        j = i >> 5;
313316        i = i & 0x1f;
314317        while (j) {
315            timeout = 100000;
318            timeout = JZ4740_MMC_MAX_TIMEOUT;
316319            do {
317320                status = readw(host->base + JZ_REG_MMC_IREG);
318321            } while (!(status & JZ_MMC_IRQ_RXFIFO_RD_REQ) && --timeout);
...... 
336339        }
337340
338341        while (i >= 4) {
339            timeout = 100000;
342            timeout = JZ4740_MMC_MAX_TIMEOUT;
340343            do {
341344                status = readl(host->base + JZ_REG_MMC_STATUS);
342345            } while ((status & JZ_MMC_STATUS_DATA_FIFO_EMPTY) && --timeout);
...... 
416419        writew(tmp & ~irq_reg, host->base + JZ_REG_MMC_IREG);
417420    }
418421
422
419423    if (irq_reg & JZ_MMC_IRQ_SDIO) {
420424        writew(JZ_MMC_IRQ_SDIO, host->base + JZ_REG_MMC_IREG);
421425        mmc_signal_sdio_irq(host->mmc);
...... 
466470
467471static int jz4740_mmc_set_clock_rate(struct jz4740_mmc_host *host, int rate) {
468472    int div = 0;
469    int real_rate = host->max_clock;
473    int real_rate;
474
470475    jz4740_mmc_clock_disable(host);
476    clk_set_rate(host->clk, JZ_MMC_CLK_RATE);
477
478    real_rate = clk_get_rate(host->clk);
471479
472    while ((real_rate >> 1) >= rate && div < 7) {
480    while (real_rate > rate && div < 7) {
473481        ++div;
474482        real_rate >>= 1;
475483    }
476    clk_set_rate(host->clk, JZ_MMC_CLK_RATE);
477484
478485    writew(div, host->base + JZ_REG_MMC_CLKRT);
479486    return real_rate;
...... 
543550
544551    host->waiting = 1;
545552    jz4740_mmc_clock_enable(host, 1);
546    mod_timer(&host->timeout_timer, 4*HZ);
553    mod_timer(&host->timeout_timer, jiffies + 5*HZ);
547554}
548555
549556static void jz4740_mmc_cmd_done(struct jz4740_mmc_host *host)
...... 
551558    uint32_t status;
552559    struct mmc_command *cmd = host->req->cmd;
553560    struct mmc_request *req = host->req;
554    unsigned int timeout = 100000;
555    status = readl(host->base + JZ_REG_MMC_STATUS);
561    unsigned int timeout = JZ4740_MMC_MAX_TIMEOUT;
556562
557563    if (cmd->flags & MMC_RSP_PRESENT)
558564        jz4740_mmc_read_response(host, cmd);
...... 
567573    if (req->stop) {
568574        jz4740_mmc_send_command(host, req->stop);
569575        do {
570            status = readl(host->base + JZ_REG_MMC_STATUS);
571        } while ((status & JZ_MMC_STATUS_PRG_DONE) == 0 && --timeout);
576            status = readw(host->base + JZ_REG_MMC_IREG);
577        } while ((status & JZ_MMC_IRQ_PRG_DONE) == 0 && --timeout);
572578        writew(JZ_MMC_IRQ_PRG_DONE, host->base + JZ_REG_MMC_IREG);
573579    }
574580
575    if (timeout == 0)
581    if (unlikely(timeout == 0))
576582        req->stop->error = -ETIMEDOUT;
577583
578584    jz4740_mmc_request_done(host);

Archive Download the corresponding diff file



interactive