Linux clock framework development
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Marek Vasut <marek.vasut@gmail.com>
Cc: linux-clk@vger.kernel.org,
	Marek Vasut <marek.vasut+renesas@gmail.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Alexey Firago <alexey_firago@mentor.com>,
	Michael Turquette <mturquette@baylibre.com>,
	linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH 1/8] clk: vc5: Prevent division by zero on unconfigured outputs
Date: Thu, 29 Jun 2017 13:26:09 +0300	[thread overview]
Message-ID: <6045977.UVitDAHN3D@avalon> (raw)
In-Reply-To: <20170629101851.23972-1-marek.vasut@gmail.com>

Hi Marek,

Thank you for the patches.

On Thursday 29 Jun 2017 12:18:44 Marek Vasut wrote:
> From: Marek Vasut <marek.vasut+renesas@gmail.com>
> 
> In case the initial values of the FOD registers are not configured in
> the OTP or by the bootloader, it is possible that the FOD registers
> will contain zeroes. The code in vc5_fod_recalc_rate() immediately
> feeds the FOD divider value obtained from the FOD registers into the
> div64_u64() and if the FOD divider value is zero, triggers division
> by zero exception.
> 
> Check if the FOD divider value is zero and return the frequency of
> the FOD output as 0 Hz if it is so. This prevents the division by
> zero exception.
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Cc: Alexey Firago <alexey_firago@mentor.com>
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: linux-renesas-soc@vger.kernel.org

For the whole series,

Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

on Salvator-XS with the display LVDS output.

> ---
>  drivers/clk/clk-versaclock5.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
> index ea7d552a2f2b..60bf4afb51bd 100644
> --- a/drivers/clk/clk-versaclock5.c
> +++ b/drivers/clk/clk-versaclock5.c
> @@ -426,6 +426,10 @@ static unsigned long vc5_fod_recalc_rate(struct clk_hw
> *hw, div_frc = (od_frc[0] << 22) | (od_frc[1] << 14) |
>  		  (od_frc[2] << 6) | (od_frc[3] >> 2);
> 
> +	/* Avoid division by zero if the output is not configured. */
> +	if ((div_int == 0) && (div_frc == 0))
> +		return 0;
> +
>  	/* The PLL divider has 12 integer bits and 30 fractional bits */
>  	return div64_u64((u64)f_in << 24ULL, ((u64)div_int << 24ULL) + 
div_frc);
>  }

-- 
Regards,

Laurent Pinchart

  parent reply	other threads:[~2017-06-29 10:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-29 10:18 [PATCH 1/8] clk: vc5: Prevent division by zero on unconfigured outputs Marek Vasut
2017-06-29 10:18 ` [PATCH 2/8] clk: vc5: Fix trivial typo Marek Vasut
2017-06-29 10:18 ` [PATCH 3/8] clk: vc5: Do not warn about disabled output buffer input muxes Marek Vasut
2017-06-30 19:26   ` Stephen Boyd
2017-07-01 20:00     ` Marek Vasut
2017-06-29 10:18 ` [PATCH 4/8] clk: vc5: Configure the output buffer input mux on prepare Marek Vasut
2017-06-29 10:18 ` [PATCH 5/8] clk: vc5: Split clock input mux and predivider Marek Vasut
2017-06-29 10:18 ` [PATCH 6/8] clk: vc5: Add support for the input frequency doubler Marek Vasut
2017-06-29 10:18 ` [PATCH 7/8] clk: vc5: Add bindings for IDT VersaClock 5P49V6901 Marek Vasut
2017-06-29 11:38   ` Geert Uytterhoeven
2017-06-29 15:49     ` Marek Vasut
2017-06-29 16:27       ` Geert Uytterhoeven
2017-06-29 10:18 ` [PATCH 8/8] clk: vc5: Add support " Marek Vasut
2017-06-29 11:41   ` Geert Uytterhoeven
2017-06-29 15:54     ` Marek Vasut
2017-06-29 10:26 ` Laurent Pinchart [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-07-01 20:04 [PATCH 1/8] clk: vc5: Prevent division by zero on unconfigured outputs Marek Vasut
2017-07-02  8:19 ` Laurent Pinchart
2017-07-02  8:28   ` Marek Vasut

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=6045977.UVitDAHN3D@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=alexey_firago@mentor.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=marek.vasut+renesas@gmail.com \
    --cc=marek.vasut@gmail.com \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@codeaurora.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox