LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Mike Turquette <mturquette@linaro.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	"Sergei Shtylyov" <sergei.shtylyov@cogentembedded.com>
Cc: "Wolfram Sang" <wsa@the-dreams.de>,
	"Geert Uytterhoeven" <geert+renesas@glider.be>,
	"Stephen Boyd" <sboyd@codeaurora.org>,
	"Ulrich Hecht" <ulrich.hecht+renesas@gmail.com>,
	"Wolfram Sang" <wsa@sang-engineering.com>,
	linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clk: shmobile: div6: Avoid division by zero in .round_rate()
Date: Thu, 05 Feb 2015 09:46:10 -0800	[thread overview]
Message-ID: <20150205174610.421.31308@quantum> (raw)
In-Reply-To: <4034374.lq5RZGeRAm@avalon>

Quoting Laurent Pinchart (2015-02-05 09:19:14)
> Hi Sergei,
> 
> On Thursday 05 February 2015 01:14:46 Sergei Shtylyov wrote:
> > On 02/05/2015 01:04 AM, Sergei Shtylyov wrote:
> > >>>>> Anyone may call clk_round_rate() with a zero rate value, so we have to
> > >>>>> protect against that.
> > >>>>> 
> > >>>>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > >>>> 
> > >>>> Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > >>>> 
> > >>>> I agree that this should not be fixed in the core because the fixup is
> > >>>> really driver dependant.
> > >>>> 
> > >>> Dunno, zero frequency seems generally insane to me.
> > >> 
> > >> It is useful to find the lowest frequency a clock can support. Basically
> > >> it is a search for the floor frequency.
> > >> 
> > > Why not just use 1? Or are you assuming that some hardware could actually
> > > support 0 Hz?
> > 
> > Replying to myself: yes, this has happened to me, when I forgot to override
> > the EXTAL frequency in the board .dts file (default was 0).
> 
> So it was a good thing that the driver crashed, it let you find a bug ;-)
> 
> Jokes aside, a zero frequency is the usual way to find the lowest frequency, 
> but I agree that there aren't many integers between 0 and 1. Mike, do you have 
> an opinion ?

Yes, I think we should support passing a zero rate for two reasons:

1) it's crazy to not sanitize a value that is passed into a function and
used as a divisor. This is not really a shortcoming of the framework.

2) during the fractional divider discussion there was the idea of making
unsigned long rate into something like millihertz. E.g. rate = 1000 is
1Hz. If we start cheating by passing a rate of 1 into .round_rate, then
we've just created a bug for ourselves if we ever move to millihertz.

Regards,
Mike

> 
> -- 
> Regards,
> 
> Laurent Pinchart
> 

  reply	other threads:[~2015-02-05 17:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-04 12:27 Geert Uytterhoeven
2015-02-04 13:31 ` Sergei Shtylyov
2015-02-04 13:50   ` Laurent Pinchart
2015-02-04 17:32 ` Wolfram Sang
2015-02-04 17:45   ` Sergei Shtylyov
2015-02-04 22:01     ` Mike Turquette
2015-02-04 22:04       ` Sergei Shtylyov
2015-02-04 22:14         ` Sergei Shtylyov
2015-02-05 17:19           ` Laurent Pinchart
2015-02-05 17:46             ` Mike Turquette [this message]
2015-02-06 11:12             ` Sergei Shtylyov
2015-02-04 22:05   ` Mike Turquette

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=20150205174610.421.31308@quantum \
    --to=mturquette@linaro.org \
    --cc=geert+renesas@glider.be \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=ulrich.hecht+renesas@gmail.com \
    --cc=wsa@sang-engineering.com \
    --cc=wsa@the-dreams.de \
    --subject='Re: [PATCH] clk: shmobile: div6: Avoid division by zero in .round_rate()' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).