From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maxime Ripard Subject: Re: [PATCH 4/4] drm/sun4i: dotclock: Round to closest clock rate Date: Tue, 20 Sep 2016 09:20:27 +0200 Message-ID: <20160920072027.GC8719@lukather> References: <20160915151402.15992-1-wens@csie.org> <20160915151402.15992-5-wens@csie.org> <20160918191648.GJ17518@lukather> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1343299820==" Return-path: Received: from mail.free-electrons.com (down.free-electrons.com [37.187.137.238]) by gabe.freedesktop.org (Postfix) with ESMTP id 1E2B56E728 for ; Tue, 20 Sep 2016 15:46:10 +0000 (UTC) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Chen-Yu Tsai Cc: linux-arm-kernel , dri-devel , linux-kernel List-Id: dri-devel@lists.freedesktop.org --===============1343299820== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="mr6Y9adkPWMVljTv" Content-Disposition: inline --mr6Y9adkPWMVljTv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 19, 2016 at 11:36:18PM +0800, Chen-Yu Tsai wrote: > On Mon, Sep 19, 2016 at 3:16 AM, Maxime Ripard > wrote: > > Hi, > > > > On Thu, Sep 15, 2016 at 11:14:02PM +0800, Chen-Yu Tsai wrote: > >> With display pixel clocks we want to have the closest possible clock > >> rate, to minimize timing and refresh rate skews. Whether the actual > >> clock rate is higher or lower than the requested rate is less importan= t. > >> > >> Also check candidates against the requested rate, rather than the > >> ideal parent rate, the varying dividers also influence the difference > >> between the requested rate and the rounded rate. > >> > >> Signed-off-by: Chen-Yu Tsai > >> --- > >> drivers/gpu/drm/sun4i/sun4i_dotclock.c | 3 ++- > >> 1 file changed, 2 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/gpu/drm/sun4i/sun4i_dotclock.c b/drivers/gpu/drm/= sun4i/sun4i_dotclock.c > >> index 3eb99784f371..d401156490f3 100644 > >> --- a/drivers/gpu/drm/sun4i/sun4i_dotclock.c > >> +++ b/drivers/gpu/drm/sun4i/sun4i_dotclock.c > >> @@ -90,7 +90,8 @@ static long sun4i_dclk_round_rate(struct clk_hw *hw,= unsigned long rate, > >> goto out; > >> } > >> > >> - if ((rounded < ideal) && (rounded > best_parent)) { > >> + if (abs(rate - rounded / i) < > >> + abs(rate - best_parent / best_div)) { > > > > I'm not sure what you're trying to do here. Why is the divider involved? >=20 > Say you want the dotclock at X, so you try Y =3D 6 ~ 127 for the divider. > Now you're asking the CCF to round (X*Y). >=20 > In the original code, you were comparing the result of rounding (X * Y). >=20 > if ((rounded < ideal) && (rounded > best_parent)) { > best_parent =3D rounded; > best_div =3D i; > } >=20 > where ideal =3D X * Y (i in the code). Given the divider increases in > the loop, you are actually not closing in on the best divider, but the > highest divider that doesn't give a higher rate than the ideal rate. >=20 > Including the divider makes it compare the actual dot clock frequency > if a given divider was used. >=20 > Does this makes sense? Explaining this kind of makes my head spin... Yes, sorry, I didn't remember rounded was actually the rounded parent rate. Thanks! Maxime --=20 Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com --mr6Y9adkPWMVljTv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJX4OM7AAoJEBx+YmzsjxAgLc4P/j4igQz+bQOUgCtvVIz4JFNl RYmqX9DNHcUvpqYuLuA75JWps6e4xsWpoKBJC93QlCtMXkIQ8sXFCoa7d1x1ytII QCFCOT34kESOWiUxJc5WjEdbqaXV1lzM3aYyODqu/YGneYNkcnyQRL+MGDuc1hZB 2sAqi7ZQ7wT/U73wnpLqzKBk8YBNWmYk+Rk7c1XdosGR0R3W/OofS8jWUM0c/a80 XobGyeAt/IimOFr5ZjUjkMQnVdZQ6zDVi4ADvhAvqV5F7H5J1IK2/iosWJpju5j+ FfBU6sM82kmr372Wid/SOJvJOF6Dx9nLQjd1oEKbwllSsGKEY9ZxoGVkYahDaLi/ htweI5n+APikJQzTKtr6J4b4xQV69zgO01zaFj9U194OD/WH/Jb4TVhyDNKLmrpx uIqYuM2SlKrSgXgp1AzM6/JU7iAeT3E4L3clXOtaZWBjsARBIxtvDVRYHNintbKx 9/OugUJGNRsWYmY17M3CgOaZOmZlQJEnkb4bIhb4nqXXXQVKLsYSD+2U4RQoU20R Z2i2q82XKneXoHMg5Siz4Mm2wBQBHK9XpOzK5Jd9b7stHz0Au3zaNJ5/4UkdLbqE 1KN2n0mNVTkqYQJFfCGRxAN8xKKtevGbOyQbuWHcv+zxHPLx1whjylAaBOOXiD8V ePP4ar3zol4dNB3Qttnn =5f2z -----END PGP SIGNATURE----- --mr6Y9adkPWMVljTv-- --===============1343299820== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============1343299820==--