From: Adrian Hunter <ext-adrian.hunter@nokia.com>
To: Jean Pihet <jpihet@mvista.com>
Cc: Pierre Ossman <drzeus-mmc@drzeus.cx>,
"tony@atomide.com" <tony@atomide.com>,
Paul Walmsley <paul@pwsan.com>,
Andrew Morton <akpm@linux-foundation.org>,
"linux-arm-kernel@lists.arm.linux.org.uk"
<linux-arm-kernel@lists.arm.linux.org.uk>,
"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
"Lavinen Jarkko (Nokia-D/Helsinki)" <jarkko.lavinen@nokia.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] OMAP: MMC: replace infinite loops with timeouts (was Re: [PATCH] OMAP: MMC: recover from transfer failures - Resend)
Date: Mon, 09 Feb 2009 17:58:14 +0200 [thread overview]
Message-ID: <49905296.2060308@nokia.com> (raw)
In-Reply-To: <200902061653.12821.jpihet@mvista.com>
Jean Pihet wrote:
> Hi,
>
>>>> On Thu, 5 Feb 2009, Andrew Morton wrote:
>>>>> An infinite loop which assumes the hardware is perfect is always a
>>>>> worry. But I see the driver already does that, so we're no worse
>>>>> off..
>>> Do you want a finite loop with udelay in it? I located 4 places were this
>>> could be used. If so I can generate a new patch for that.
>> Even if Andrew doesn't, I'd sure like it. (the finite bit at least) :)
> Ok here is a patch that replaces the infinite loops with a timeout version.
> This patch applies on top of the previous one I sent ('[PATCH] OMAP: MMC:
> recover from transfer failures - Resend'). Is that OK?
>
What about making use of a function like this:
static void reset_host_controller(struct mmc_omap_host *host, unsigned bit)
{
unsigned long i, limit = loops_per_jiffy;
OMAP_HSMMC_WRITE(host->base, SYSCTL,
OMAP_HSMMC_READ(host->base, SYSCTL) | bit);
for (i = 0; i < limit; i++) {
if (!(OMAP_HSMMC_READ(host->base, SYSCTL) & bit))
return;
cpu_relax();
}
dev_err(mmc_dev(host->mmc), "%s: timeout waiting on software reset\n",
mmc_hostname(host->mmc));
}
And then just put:
reset_host_controller(host, SRD);
and
reset_host_controller(host, SRC);
in the right places.
>> Related, who is the maintainer of this driver? Tony? I'd like to have
>> someone who checks patches before I queue them up.
>>
>>
>> Rgds
>
>>From 5ee867d09efe22a903ac7373a05e9e047bad6544 Mon Sep 17 00:00:00 2001
> From: Jean Pihet <jpihet@mvista.com>
> Date: Fri, 6 Feb 2009 16:42:51 +0100
> Subject: [PATCH] OMAP: MMC: replace infinite loops with timeouts
>
> Replace the 'while() ;' with a timeout
>
> Signed-off-by: Jean Pihet <jpihet@mvista.com>
> ---
> drivers/mmc/host/omap_hsmmc.c | 56
> +++++++++++++++++++++++++++++++++--------
> 1 files changed, 45 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index 1ac6918..7ddc77e 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -102,6 +102,8 @@
> #define OMAP_MMC_DATADIR_READ 1
> #define OMAP_MMC_DATADIR_WRITE 2
> #define MMC_TIMEOUT_MS 20
> +#define MMC_TIMEOUT_WAIT 100 /* Active wait duration, in usec */
> +#define MMC_TIMEOUT_WAIT_LOOPS ((MMC_TIMEOUT_MS * 1000) / MMC_TIMEOUT_WAIT)
> #define OMAP_MMC_MASTER_CLOCK 96000000
> #define DRIVER_NAME "mmci-omap-hs"
>
> @@ -384,6 +386,7 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
> struct mmc_omap_host *host = dev_id;
> struct mmc_data *data;
> int end_cmd = 0, end_trans = 0, status;
> + unsigned long timeout_counter;
>
> if (host->cmd == NULL && host->data == NULL) {
> OMAP_HSMMC_WRITE(host->base, STAT,
> @@ -406,9 +409,17 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
> OMAP_HSMMC_WRITE(host->base, SYSCTL,
> OMAP_HSMMC_READ(host->base,
> SYSCTL) |
> SRC);
> - while (OMAP_HSMMC_READ(host->base,
> - SYSCTL) & SRC)
> - ;
> + timeout_counter = 0;
> + while ((OMAP_HSMMC_READ(host->base,
> + SYSCTL) & SRC)
> + && (timeout_counter++ <
> +
> MMC_TIMEOUT_WAIT_LOOPS))
> +
> udelay(MMC_TIMEOUT_WAIT);
> +
> + if (OMAP_HSMMC_READ(host->base,
> + SYSCTL) & SRC)
> + dev_err(mmc_dev(host->mmc),
> + "Timeout waiting on
> SRC\n");
>
> host->cmd->error = -ETIMEDOUT;
> } else {
> @@ -421,9 +432,17 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
> OMAP_HSMMC_WRITE(host->base, SYSCTL,
> OMAP_HSMMC_READ(host->base,
> SYSCTL) | SRD);
> - while (OMAP_HSMMC_READ(host->base,
> - SYSCTL) & SRD)
> - ;
> + timeout_counter = 0;
> + while ((OMAP_HSMMC_READ(host->base,
> + SYSCTL) & SRD)
> + && (timeout_counter++ <
> +
> MMC_TIMEOUT_WAIT_LOOPS))
> + udelay(MMC_TIMEOUT_WAIT);
> +
> + if (OMAP_HSMMC_READ(host->base,
> + SYSCTL) & SRD)
> + dev_err(mmc_dev(host->mmc),
> + "Timeout waiting on SRD\n");
> }
> }
> if ((status & DATA_TIMEOUT) ||
> @@ -436,9 +455,17 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
> OMAP_HSMMC_WRITE(host->base, SYSCTL,
> OMAP_HSMMC_READ(host->base,
> SYSCTL) | SRD);
> - while (OMAP_HSMMC_READ(host->base,
> - SYSCTL) & SRD)
> - ;
> + timeout_counter = 0;
> + while ((OMAP_HSMMC_READ(host->base,
> + SYSCTL) & SRD)
> + && (timeout_counter++ <
> +
> MMC_TIMEOUT_WAIT_LOOPS))
> + udelay(MMC_TIMEOUT_WAIT);
> +
> + if (OMAP_HSMMC_READ(host->base,
> + SYSCTL) & SRD)
> + dev_err(mmc_dev(host->mmc),
> + "Timeout waiting on SRD\n");
> end_trans = 1;
> }
> }
> @@ -524,6 +551,7 @@ static void mmc_omap_detect(struct work_struct *work)
> {
> struct mmc_omap_host *host = container_of(work, struct mmc_omap_host,
> mmc_carddetect_work);
> + unsigned long timeout;
>
> sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch");
> if (host->carddetect) {
> @@ -531,8 +559,14 @@ static void mmc_omap_detect(struct work_struct *work)
> } else {
> OMAP_HSMMC_WRITE(host->base, SYSCTL,
> OMAP_HSMMC_READ(host->base, SYSCTL) | SRD);
> - while (OMAP_HSMMC_READ(host->base, SYSCTL) & SRD)
> - ;
> + /* Wait till the SRD bit is reset */
> + timeout = jiffies + msecs_to_jiffies(MMC_TIMEOUT_MS);
> + while ((OMAP_HSMMC_READ(host->base, SYSCTL) & SRD)
> + && time_before(jiffies, timeout))
> + msleep(1);
> +
> + if (OMAP_HSMMC_READ(host->base, SYSCTL) & SRD)
> + dev_err(mmc_dev(host->mmc), "Timeout waiting on
> SRD\n");
>
> mmc_detect_change(host->mmc, (HZ * 50) / 1000);
> }
> --
> 1.6.0.1.42.gf8c9c
>
next prev parent reply other threads:[~2009-02-09 15:51 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-07 21:45 [PATCH 0/5] Omap MMC init updates and new controller for 2.6.29 merge window Tony Lindgren
2008-12-07 21:46 ` [PATCH 1/5] omap mmc: Remove broken MMC init code Tony Lindgren
2008-12-07 21:47 ` [PATCH 2/5] omap mmc: Add better MMC low-level init Tony Lindgren
2009-01-10 22:49 ` Ladislav Michl
2009-01-10 23:00 ` Ladislav Michl
2009-01-13 13:43 ` Tony Lindgren
2009-03-23 17:47 ` Ladislav Michl
2009-03-24 20:04 ` [APPLIED] " Tony Lindgren
2009-01-10 23:03 ` Ladislav Michl
2008-12-07 21:49 ` [PATCH 3/5] omap mmc: Add low-level initialization for hsmmc controller Tony Lindgren
2008-12-07 21:50 ` [PATCH 4/5] omap mmc: force MMC module reset on boot Tony Lindgren
2008-12-07 21:51 ` [PATCH 5/5] omap mmc: Add new omap hsmmc controller for 2430 and 34xx Tony Lindgren
2008-12-21 16:17 ` Pierre Ossman
2008-12-29 16:55 ` Tony Lindgren
2008-12-30 8:36 ` Tony Lindgren
2008-12-31 17:59 ` Pierre Ossman
2009-01-07 10:18 ` Tony Lindgren
2009-01-07 10:28 ` [PATCH] OMAP: MMC: recover from transfer failures (was: Re: [PATCH 5/5] omap mmc: Add new omap hsmmc controller for 2430 and 34xx) Jean Pihet
2009-01-07 15:40 ` Tony Lindgren
2009-01-08 9:02 ` [PATCH] OMAP: MMC: recover from transfer failures Adrian Hunter
2009-01-08 11:49 ` Jean Pihet
2009-01-08 12:17 ` Adrian Hunter
2009-02-02 8:46 ` Jean Pihet
2009-02-02 19:05 ` Tony Lindgren
2009-02-03 14:05 ` [PATCH] OMAP: MMC: recover from transfer failures - Resend Jean Pihet
2009-02-05 20:10 ` Andrew Morton
2009-02-05 20:32 ` Paul Walmsley
2009-02-06 13:22 ` Jean Pihet
2009-02-06 13:53 ` Pierre Ossman
2009-02-06 15:53 ` [PATCH] OMAP: MMC: replace infinite loops with timeouts (was Re: [PATCH] OMAP: MMC: recover from transfer failures - Resend) Jean Pihet
2009-02-09 15:58 ` Adrian Hunter [this message]
2009-02-11 9:41 ` Jean Pihet
2009-02-09 17:58 ` [PATCH] OMAP: MMC: recover from transfer failures - Resend Jarkko Lavinen
2009-02-09 18:46 ` Tony Lindgren
2009-02-10 0:09 ` Paul Walmsley
2009-02-08 20:27 ` David Brownell
2008-12-15 22:26 ` git pull request for omap mmc init changes (Re: [PATCH 0/5] Omap MMC init updates and new controller for 2.6.29 merge window) Tony Lindgren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49905296.2060308@nokia.com \
--to=ext-adrian.hunter@nokia.com \
--cc=akpm@linux-foundation.org \
--cc=drzeus-mmc@drzeus.cx \
--cc=jarkko.lavinen@nokia.com \
--cc=jpihet@mvista.com \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=paul@pwsan.com \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox