From: Marc Koschewski <marc@osknowledge.org>
To: "Dong, Chuanxiao" <chuanxiao.dong@intel.com>
Cc: "linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
"cjb@laptop.org" <cjb@laptop.org>,
"adrian.hunter@nokia.com" <adrian.hunter@nokia.com>,
"linus.walleij@linaro.org" <linus.walleij@linaro.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1]mmc: fix division by zero when calculate mmc erase time
Date: Thu, 24 Feb 2011 13:22:35 +0100 [thread overview]
Message-ID: <20110224122235.GC7260@marc.osknowledge.org> (raw)
In-Reply-To: <5D8008F58939784290FAB48F5497519835CE59FE52@shsmsx502.ccr.corp.intel.com>
* Dong, Chuanxiao <chuanxiao.dong@intel.com> [2011-02-24 20:09:59 +0800]:
>
>
> > -----Original Message-----
> > From: Marc Koschewski [mailto:marc@osknowledge.org]
> > Sent: Thursday, February 24, 2011 7:38 PM
> > To: Dong, Chuanxiao
> > Cc: linux-mmc@vger.kernel.org; cjb@laptop.org; adrian.hunter@nokia.com;
> > linus.walleij@linaro.org; linux-kernel@vger.kernel.org
> > Subject: Re: [PATCH 1/1]mmc: fix division by zero when calculate mmc erase time
> >
> > Hi,
> >
> > * Chuanxiao Dong <chuanxiao.dong@intel.com> [2011-02-24 19:18:01 +0800]:
> >
> > > Since if clock gating feature is enabled, the clock frequency may be zero when
> > > host clock is gated. In such scenario, mmc_set_mmc_erase_timeout() may have a
> > > division by zero bug.
> > >
> > > So this patch used mmc_host_clk_rate() to fix this.
> > >
> > > Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
> > > ---
> > > drivers/mmc/core/core.c | 10 ++++++++--
> > > 1 files changed, 8 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> > > index 34a7e8c..12d0eb8 100644
> > > --- a/drivers/mmc/core/core.c
> > > +++ b/drivers/mmc/core/core.c
> > > @@ -1201,8 +1201,14 @@ static void mmc_set_mmc_erase_timeout(struct
> > mmc_card *card,
> > > * less but not that much less, so fudge it by multiplying by 2.
> > > */
> > > timeout_clks <<= 1;
> > > - timeout_us += (timeout_clks * 1000) /
> > > - (card->host->ios.clock / 1000);
> > > +
> > > + /*
> > > + * at this moment, host controller maybe clock gated, so make
> > > + * sure we can get a correct host clock freq.
> > > + */
> > > + if (mmc_host_clk_rate(card->host))
> > > + timeout_us += (timeout_clks * 1000) /
> > > + (mmc_host_clk_rate(card->host) / 1000);
> >
> > Why don't you just reuse mmc_host_clk_rate()'s result instead of calling it twice?
> This is a incline function and just return host->ios.clock. Reuse mmc_host_clk_rate()'s result need to add a new variable to save the value.
It's not inline on trunk and it spinlocks.
drivers/mmc/core/host.c:195
194 */
195 unsigned int mmc_host_clk_rate(struct mmc_host *host)
196 {
Cheers,
Marc
>
> Thanks
> Chuanxiao
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
>
--
Marc Koschewski
next prev parent reply other threads:[~2011-02-24 12:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-24 11:18 [PATCH 1/1]mmc: fix division by zero when calculate mmc erase time Chuanxiao Dong
2011-02-24 11:37 ` Marc Koschewski
2011-02-24 12:09 ` Dong, Chuanxiao
2011-02-24 12:22 ` Marc Koschewski [this message]
2011-02-24 12:25 ` Dong, Chuanxiao
2011-02-24 12:34 ` Marc Koschewski
2011-02-24 12:35 ` Linus Walleij
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=20110224122235.GC7260@marc.osknowledge.org \
--to=marc@osknowledge.org \
--cc=adrian.hunter@nokia.com \
--cc=chuanxiao.dong@intel.com \
--cc=cjb@laptop.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.