public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: maxime.ripard@free-electrons.com (Maxime Ripard)
To: linux-arm-kernel@lists.infradead.org
Subject: [linux-sunxi] [PATCH] clk: sunxi-ng: fix PLL_CPUX adjusting on H3
Date: Wed, 18 Jan 2017 17:56:12 +0100	[thread overview]
Message-ID: <20170118165612.zkjaj36kedg64rjw@lukather> (raw)
In-Reply-To: <f1ccd8ce-df6c-8204-71ab-2f774ac269d5@megous.com>

Hi,

On Mon, Jan 16, 2017 at 05:51:30PM +0100, Ond?ej Jirman wrote:
> Hi Maxime,
> 
> Dne 16.1.2017 v 17:43 Maxime Ripard napsal(a):
> >> It does lock up quickly with mainline ccu_nkmp_find_best algorithm
> >> for finding factors.
> >>
> >> Even with linux kernel, it breaks. It's just more difficult to hit the
> >> right conditions. I got oops only right after boot when running cpuburn
> >> to trigger thermal_zone issued OPP change, if I first run some cpupower
> >> commands. That's why I wrote this program to stress test various CPU_PLL
> >> change/factor selection algorithms independently of everything else, to
> >> get more predictable and quicker testing results.
> > 
> > Understood. Do you have the code available somewhere?
> 
> It's a bit messy, but it's here:
> 
> https://github.com/megous/h3-firmware/blob/master/main.c

Awesome, thanks!

> >>>> What works is selecting NKMP factors so that M is always 1 and P is
> >>>> anything other than /1 only for frequencies under 288MHz. As mandated by
> >>>> the H3 datasheet. Mainline ccu_nkmp_find_best doesn't respect these
> >>>> conditions. With that I can change CPUX frequencies randomly 20x a
> >>>> second so far indefinitely without the main CPU ever locking up.
> >>>>
> >>>> Please drop or revert this patch. It is not a correct approach to the
> >>>> problem. I'd suggest dropping the entire clock notifier mechanism, too,
> >>>> unless it can be proven to work reliably.
> >>>
> >>> It has been proven to work reliably on a number of other SoCs.
> >>
> >> Unless it was stress tested like this with randomy changed settings, I
> >> doubt you can call it reliable. It may just be very hard to hit the
> >> issue on linux with particular OPP/thermal zone configuration. That's
> >> because the issue is dependent on before and after NKMP values. People
> >> may have just been lucky so far.
> > 
> > Yes, or maybe we just have OPPs that just don't trigger a low enough P
> > factor.
> > 
> > There's no rush anyway, the H3 cpufreq support is not enabled at the
> > moment, so that code basically does nothing for the moment.
> > 
> > What's your current plan to fix that? I guess the easiest (and most
> > likely to be reusable) would be to allow for clock tables, instead of
> > using the generic approach. We might have some other clocks (like
> > audio or video) that would need such a precise tuning in the future
> > too.
> 
> My proposed solution is this for M factor (H3 specific solution):
> 
> https://github.com/megous/linux/commit/88be3d421e958579026135d8acec4b3983958738

This one is fine.

> and this for P factor:
> 
> https://github.com/megous/linux/commit/d7f274ed0c13fa9b4099445cb6bf9b2f8f2cfa8a
> 
> Perhaps it should be configurable if the P limitation is not universal
> for all NKMP clocks. But I haven't read all the datasheets.

And this is exactly what I wanted to avoid, for the reason you're
giving :)

This is some generic code, and yet you're putting a clock and SoC
specific limit in there. You have two ways to deal with that. Either
come up with some generic throttling mecanism to force a particular
value above or below a given threshold, but that might be tedious to
do, and require some significant rework.

Or you can use a table, which is generic and should be relatively
easy. I really think this is the most straightforward solution, and
even more so since we just want to support a limited number of
frequencies in this case.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170118/269f7a7e/attachment.sig>

  reply	other threads:[~2017-01-18 16:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-25  0:28 [PATCH] clk: sunxi-ng: fix PLL_CPUX adjusting on H3 megous at megous.com
2016-11-25  3:22 ` [linux-sunxi] " Chen-Yu Tsai
2016-11-25  6:35 ` Maxime Ripard
2017-01-07 15:49 ` [linux-sunxi] " Ondřej Jirman
2017-01-09  9:59   ` Maxime Ripard
2017-01-09 14:50     ` Ondřej Jirman
2017-01-16 16:43       ` Maxime Ripard
2017-01-16 16:51         ` Ondřej Jirman
2017-01-18 16:56           ` Maxime Ripard [this message]
2017-01-18 17:48             ` Ondřej Jirman
2017-01-19 15:45               ` Maxime Ripard

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=20170118165612.zkjaj36kedg64rjw@lukather \
    --to=maxime.ripard@free-electrons.com \
    --cc=linux-arm-kernel@lists.infradead.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