On Wednesday 04 February 2009, David Brownell wrote:
> On Wednesday 04 February 2009, Kumar, Purushotam wrote:
> > I will take the responsibility of taking the MMC driver upstream.
> 
> Great, thanks.  Appended is a minor it-compiles cleanup patch,
> mostly getting rid of the needless ASM hacks (let's just expect
> DMA to be used always, now that it behaves) and saving ~160 bytes.

Oh, and one more issue likely to appear in a public review:
there are a couple un-bounded loops, which should get terminated.
Appended is a patch I've been running with, which at least gets
rid of the "system hangs" aspect of such loop (even if there's
no particularly good cleanup).

I hope you're planning to send this up for review soon, so that
it will be in the 2.6.30 merge queue when the merge window opens...

- Dave



unbounded loopiness considered evil

---
 drivers/mmc/host/davinci_mmc.c |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

--- a/drivers/mmc/host/davinci_mmc.c
+++ b/drivers/mmc/host/davinci_mmc.c
@@ -816,11 +816,23 @@ static void mmc_davinci_set_ios(struct m
 
        host->bus_mode = ios->bus_mode;
        if (ios->power_mode == MMC_POWER_UP) {
+               unsigned long timeout = jiffies + msecs_to_jiffies(50);
+               bool lose = true;
+
                /* Send clock cycles, poll completion */
                writel(0, host->base + DAVINCI_MMCARGHL);
                writel(MMCCMD_INITCK, host->base + DAVINCI_MMCCMD);
-               while (!(readl(host->base + DAVINCI_MMCST0) & MMCST0_RSPDNE))
+               while (time_before(jiffies, timeout)) {
+                       u32 tmp = readl(host->base + DAVINCI_MMCST0);
+
+                       if (tmp & MMCST0_RSPDNE) {
+                               lose = false;
+                               break;
+                       }
                        cpu_relax();
+               }
+               if (lose)
+                       dev_warn(mmc_dev(host->mmc), "powerup timeout\n");
        }
 
        /* FIXME on power OFF, reset things ... */
@@ -907,6 +919,7 @@ static inline int handle_core_command(
        int end_transfer = 0;
        unsigned int qstatus = status;
        struct mmc_data *data = host->data;
+       unsigned count = 0;
 
        /* handle FIFO first when using PIO for data */
        while (host->bytes_left && (status & (MMCST0_DXRDY | MMCST0_DRRDY))) {
@@ -914,7 +927,12 @@ static inline int handle_core_command(
                status = readl(host->base + DAVINCI_MMCST0);
                if (!status)
                        break;
+
                qstatus |= status;
+               if (count++ > 40) {
+                       dev_dbg(mmc_dev(host->mmc), "PIO timeout\n");
+                       break;
+               }
        }
 
        if (qstatus & MMCST0_DATDNE) {



_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to