From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jernej =?utf-8?B?xaBrcmFiZWM=?= Subject: Re: [PATCH v3 02/28] clk: sunxi-ng: Adjust MP clock parent rate when allowed Date: Wed, 16 Jan 2019 18:00:32 +0100 Message-ID: <11550554.k1qAFTnke5@jernej-laptop> References: <20181104182705.18047-1-jernej.skrabec@siol.net> <2085880.8AFF3nNMGQ@jernej-laptop> <20190116120958.gvxr6tpstvhjpe5a@plaes.org> Reply-To: jernej.skrabec-gGgVlfcn5nU@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Return-path: Sender: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org In-Reply-To: <20190116120958.gvxr6tpstvhjpe5a-q/aMd4JkU83YtjvyW6yDsg@public.gmane.org> List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , To: Priit Laes Cc: maxime.ripard-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org, wens-jdAy2FN1RRM@public.gmane.org, robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, mturquette-rdvid1DuHRBWk0Htik3J/w@public.gmane.org, sboyd-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, airlied-cv59FeDIM0c@public.gmane.org, architt-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org, a.hajda-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org, Laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-Id: devicetree@vger.kernel.org Dne sreda, 16. januar 2019 ob 13:09:58 CET je Priit Laes napisal(a): > On Thu, Jan 10, 2019 at 06:10:59PM +0100, Jernej =C5=A0krabec wrote: > > Dne =C4=8Detrtek, 10. januar 2019 ob 10:15:48 CET je Priit Laes napisal= (a): > > > On Sun, Nov 04, 2018 at 07:26:39PM +0100, Jernej Skrabec wrote: > > > > Currently MP clocks don't consider adjusting parent rate even if th= ey > > > > are allowed to do so. Such behaviour considerably lowers amount of > > > > possible rates, which is very inconvenient when such clock is used = for > > > > pixel clock, for example. > > > >=20 > > > > In order to improve the situation, adjusting parent rate is conside= red > > > > when allowed. > > > >=20 > > > > This code is inspired by clk_divider_bestdiv() function, which does > > > > basically the same thing for different clock type. > > >=20 > > > This patch seems to break the eMMC support on Olinuxino-Lime2-eMMC > > > boards: > > >=20 > > > EXT4-fs (mmcblk1p4): INFO: recovery required on readonly filesystem > > > EXT4-fs (mmcblk1p4): write access will be enabled during recovery > > > sunxi-mmc 1c11000.mmc: data error, sending stop command > > > sunxi-mmc 1c11000.mmc: send stop command failed > >=20 > > I'm not familiar with A20. What is interesting is that emmc clocks don'= t > > have CLK_SET_RATE_PARENT flag set, so you shouldn't see any difference. > >=20 > > Can you post content of clk_summary with and without this patch? >=20 > In both cases I booted from FEL with rootfs on sdcard and tried to mount > partition from eMMC to /mnt. With your patch, last step it fails. >=20 > pre-patch working: > pll-ddr-other[768MHz] -> mmc2[512MHz]. (For some reason ahb-mmc2 is off?) >=20 > post-patch not working: > pll-periph[600MHz] -> mmc2[500Mhz], (ahb-mmc2 is enabled) >=20 > Also, attached the logs. Thanks. Just one more request. Can you enable debug messages in mmc driver?= =20 I'm interested in output of this line: dev_dbg(mmc_dev(mmc), "setting clk to %d, rounded %ld\n", clock, rate); Just wondering what it should be. Best regards, Jernej >=20 > > Best regards, > > Jernej > >=20 > > > $ git bisect log > > > git bisect start > > > # good: [3df407b2a5346db1c48809706ece7a8616c79e0b] mmc: > > > dw_mmc-bluefield: > > > simplify the probe() function git bisect good > > > 3df407b2a5346db1c48809706ece7a8616c79e0b > > > # bad: [00d59fde8532b2d42e80909d2e58678755e04da9] Merge tag 'mmc-v4.2= 1' > > > of > > > git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc git bisect bad > > > 00d59fde8532b2d42e80909d2e58678755e04da9 > > > # good: [01e421feec0817bb3141eaae4c517410d193d440] Merge branch 'fixe= s' > > > into next git bisect good 01e421feec0817bb3141eaae4c517410d193d440 > > > # bad: [1eefdec18eded41833401cfd64749643ff72e7da] Merge branch > > > 'locking-core-for-linus' of > > > git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip git bisect bad > > > 1eefdec18eded41833401cfd64749643ff72e7da > > > # good: [eaa76499711535fd64d747cc4ef0d78ab0fd41c6] Merge tag > > > 'mtd/for-4.21' > > > of git://git.infradead.org/linux-mtd git bisect good > > > eaa76499711535fd64d747cc4ef0d78ab0fd41c6 > > > # good: [4e4390ad067a61ce4e7607bd0df31f19a4caa36a] Merge tag > > > 'leds-for-4.21-rc1' of > > > git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds > > > git > > > bisect good 4e4390ad067a61ce4e7607bd0df31f19a4caa36a > > > # bad: [c2f1f3e0e17d94ab0c66d83e669492cb9e9a3698] Merge > > > git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-next git > > > bisect > > > bad c2f1f3e0e17d94ab0c66d83e669492cb9e9a3698 > > > # bad: [e4b99d415c3908581d4703203e1e805f043a3e71] Merge branch > > > 'irq-core-for-linus' of > > > git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip git bisect bad > > > e4b99d415c3908581d4703203e1e805f043a3e71 > > > # bad: [ffe05540d18013db62c43627836a3638e9a2c7aa] Merge branches > > > 'clk-renesas', 'clk-allwinner', 'clk-tegra', 'clk-meson' and > > > 'clk-rockchip' > > > into clk-next git bisect bad ffe05540d18013db62c43627836a3638e9a2c7aa > > > # good: [1a501c8defe950571316d5ddd917bf44f5ed7bd4] Merge branches > > > 'clk-managed-registration', 'clk-spdx', 'clk-remove-basic' and > > > 'clk-ops-const' into clk-next git bisect good > > > 1a501c8defe950571316d5ddd917bf44f5ed7bd4 > > > # good: [e74581b79ddd9b49b8c61e2791fc4dffc0245afb] Merge tag > > > 'meson-clk-4.21-2' of https://github.com/BayLibre/clk-meson into > > > clk-meson > > > git bisect good e74581b79ddd9b49b8c61e2791fc4dffc0245afb > > > # good: [60baf75e3f5b76043c25328ac0c5320aaef5ea41] Merge tag > > > 'clk-renesas-for-v4.21-tag2' of > > > git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers i= nto > > > clk-renesas git bisect good 60baf75e3f5b76043c25328ac0c5320aaef5ea41 > > > # bad: [a41f85b6017ee20952a60e4330bcae2527fe2c2a] Merge tag > > > 'sunxi-clk-for-4.21' of > > > https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux into > > > clk-allwinner git bisect bad a41f85b6017ee20952a60e4330bcae2527fe2c2a > > > # bad: [ee678706e46d0d185c27cc214ad97828e0643159] clk: sunxi-ng: a64: > > > Fix > > > gate bit of DSI DPHY git bisect bad > > > ee678706e46d0d185c27cc214ad97828e0643159 > > > # bad: [65b6657672388b72822e0367f06d41c1e3ffb5bb] clk: sunxi-ng: Use = u64 > > > for calculation of NM rate git bisect bad > > > 65b6657672388b72822e0367f06d41c1e3ffb5bb > > > # good: [db7548934603d9eda12649dff97ea5c29884405d] clk: sunxi-ng: > > > sun50i: > > > h6: Fix MMC clock mux width git bisect good > > > db7548934603d9eda12649dff97ea5c29884405d > > > # bad: [3f790433c3cb27ecaf2ca0e07ac25964e4fd9f15] clk: sunxi-ng: Adju= st > > > MP > > > clock parent rate when allowed git bisect bad > > > 3f790433c3cb27ecaf2ca0e07ac25964e4fd9f15 > > > # first bad commit: [3f790433c3cb27ecaf2ca0e07ac25964e4fd9f15] clk: > > > sunxi-ng: Adjust MP clock parent rate when allowed > > >=20 > > > > Signed-off-by: Jernej Skrabec > > > > --- > > > >=20 > > > > drivers/clk/sunxi-ng/ccu_mp.c | 64 > > > > +++++++++++++++++++++++++++++++++-- > > > > 1 file changed, 62 insertions(+), 2 deletions(-) > > > >=20 > > > > diff --git a/drivers/clk/sunxi-ng/ccu_mp.c > > > > b/drivers/clk/sunxi-ng/ccu_mp.c > > > > index 5d0af4051737..0357349eb767 100644 > > > > --- a/drivers/clk/sunxi-ng/ccu_mp.c > > > > +++ b/drivers/clk/sunxi-ng/ccu_mp.c > > > > @@ -40,6 +40,61 @@ static void ccu_mp_find_best(unsigned long paren= t, > > > > unsigned long rate,> > > > >=20 > > > > *p =3D best_p; > > > > =20 > > > > } > > > >=20 > > > > +static unsigned long ccu_mp_find_best_with_parent_adj(struct clk_h= w > > > > *hw, > > > > + > >=20 > > unsigned long *parent, > >=20 > > > > + > >=20 > > unsigned long rate, > >=20 > > > > + > >=20 > > unsigned int max_m, > >=20 > > > > + > >=20 > > unsigned int max_p) > >=20 > > > > +{ > > > > + unsigned long parent_rate_saved; > > > > + unsigned long parent_rate, now; > > > > + unsigned long best_rate =3D 0; > > > > + unsigned int _m, _p, div; > > > > + unsigned long maxdiv; > > > > + > > > > + parent_rate_saved =3D *parent; > > > > + > > > > + /* > > > > + * The maximum divider we can use without overflowing > > > > + * unsigned long in rate * m * p below > > > > + */ > > > > + maxdiv =3D max_m * max_p; > > > > + maxdiv =3D min(ULONG_MAX / rate, maxdiv); > > > > + > > > > + for (_p =3D 1; _p <=3D max_p; _p <<=3D 1) { > > > > + for (_m =3D 1; _m <=3D max_m; _m++) { > > > > + div =3D _m * _p; > > > > + > > > > + if (div > maxdiv) > > > > + break; > > > > + > > > > + if (rate * div =3D=3D parent_rate_saved) { > > > > + /* > > > > + * It's the most ideal case if > >=20 > > the requested > >=20 > > > > + * rate can be divided from > >=20 > > parent clock without > >=20 > > > > + * needing to change parent=20 rate, > >=20 > > so return the > >=20 > > > > + * divider immediately. > > > > + */ > > > > + *parent =3D parent_rate_saved; > > > > + return rate; > > > > + } > > > > + > > > > + parent_rate =3D clk_hw_round_rate(hw, rate * > >=20 > > div); > >=20 > > > > + now =3D parent_rate / div; > > > > + > > > > + if (now <=3D rate && now > best_rate) { > > > > + best_rate =3D now; > > > > + *parent =3D parent_rate; > > > > + > > > > + if (now =3D=3D rate) > > > > + return rate; > > > > + } > > > > + } > > > > + } > > > > + > > > > + return best_rate; > > > > +} > > > > + > > > >=20 > > > > static unsigned long ccu_mp_round_rate(struct ccu_mux_internal *mu= x, > > > > =20 > > > > struct clk_hw *hw, > > > > unsigned long > >=20 > > *parent_rate, > >=20 > > > > @@ -56,8 +111,13 @@ static unsigned long ccu_mp_round_rate(struct > > > > ccu_mux_internal *mux,> > > > >=20 > > > > max_m =3D cmp->m.max ?: 1 << cmp->m.width; > > > > max_p =3D cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1); > > > >=20 > > > > - ccu_mp_find_best(*parent_rate, rate, max_m, max_p, &m, &p); > > > > - rate =3D *parent_rate / p / m; > > > > + if (!(clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT)) { > > > > + ccu_mp_find_best(*parent_rate, rate, max_m, max_p, &m, > >=20 > > &p); > >=20 > > > > + rate =3D *parent_rate / p / m; > > > > + } else { > > > > + rate =3D ccu_mp_find_best_with_parent_adj(hw,=20 parent_rate, > >=20 > > rate, > >=20 > > > > + > >=20 > > max_m, max_p); > >=20 > > > > + } > > > >=20 > > > > if (cmp->common.features & CCU_FEATURE_FIXED_POSTDIV) > > > > =09 > > > > rate /=3D cmp->fixed_post_div; --=20 You received this message because you are subscribed to the Google Groups "= linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an e= mail to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/d/optout.