linux/drivers/gpu/drm/rockchip
Chris Morgan 64ec4912c5 drm/rockchip: Update crtc fixup to account for fractional clk change
After commit 928f9e2686 ("clk: fractional-divider: Hide
clk_fractional_divider_ops from wide audience") was merged it appears
that the DSI panel on my Odroid Go Advance stopped working. Upon closer
examination of the problem, it looks like it was the fixup in the
rockchip_drm_vop.c file was causing the issue. The changes made to the
clk driver appear to change some assumptions made in the fixup.

After debugging the working 5.14 kernel and the no-longer working
5.15 kernel, it looks like this was broken all along but still
worked, whereas after the fractional clock change it stopped
working despite the issue (it went from sort-of broken to very broken).

In the 5.14 kernel the dclk_vopb_frac was being requested to be set to
17000999 on my board. The clock driver was taking the value of the
parent clock and attempting to divide the requested value from it
(17000000/17000999 = 0), then subtracting 1 from it (making it -1),
and running it through fls_long to get 64. It would then subtract
the value of fd->mwidth from it to get 48, and then bit shift
17000999 to the left by 48, coming up with a very large number of
7649082492112076800. This resulted in a numerator of 65535 and a
denominator of 1 from the clk driver. The driver seemingly would
try again and get a correct 1:1 value later, and then move on.

Output from my 5.14 kernel (with some printfs for good measure):
[    2.830066] rockchip-drm display-subsystem: bound ff460000.vop (ops vop_component_ops)
[    2.839431] rockchip-drm display-subsystem: bound ff450000.dsi (ops dw_mipi_dsi_rockchip_ops)
[    2.855980] Clock is dclk_vopb_frac
[    2.856004] Scale 64, Rate 7649082492112076800, Oldrate 17000999, Parent Rate 17000000, Best Numerator 65535, Best Denominator 1, fd->mwidth 16
[    2.903529] Clock is dclk_vopb_frac
[    2.903556] Scale 0, Rate 17000000, Oldrate 17000000, Parent Rate 17000000, Best Numerator 1, Best Denominator 1, fd->mwidth 16
[    2.903579] Clock is dclk_vopb_frac
[    2.903583] Scale 0, Rate 17000000, Oldrate 17000000, Parent Rate 17000000, Best Numerator 1, Best Denominator 1, fd->mwidth 16

Contrast this with 5.15 after the clk change where the rate of 17000999
was getting passed and resulted in numerators/denomiators of 17001/
17000.

Output from my 5.15 kernel (with some printfs added for good measure):
[    2.817571] rockchip-drm display-subsystem: bound ff460000.vop (ops vop_component_ops)
[    2.826975] rockchip-drm display-subsystem: bound ff450000.dsi (ops dw_mipi_dsi_rockchip_ops)
[    2.843430] Rate 17000999, Parent Rate 17000000, Best Numerator 17018, Best Denominator 17017
[    2.891073] Rate 17001000, Parent Rate 17000000, Best Numerator 17001, Best Denominator 17000
[    2.891269] Rate 17001000, Parent Rate 17000000, Best Numerator 17001, Best Denominator 17000
[    2.891281] Rate 17001000, Parent Rate 17000000, Best Numerator 17001, Best Denominator 17000

I have tested the change extensively on my Odroid Go Advance (Rockchip
RK3326) and it appears to work well. However, this change will affect
all Rockchip SoCs that use this driver so I believe further testing
is warranted. Please note that without this change I can confirm
at least all PX30s with DSI panels will stop working with the 5.15
kernel.

Upon advice from Doug Anderson <dianders@chromium.org> it was decided
that we would first check if the clock rate can be set exactly as
requested, and only if it could not would we then add 999 to it and
attempt the process again. This way we can preserve the behavior for
clocks that still need it while resolving the specific issue for the
PX30 and DSI panels (since it is using a fractional clock).

Changes since v2:
 - Moved fixes to correct location.

Changes since v1:
 - Made the addition of 999 conditional based on whether the clock
   subsystem can set the actual clock rate as requested.
 - Updated the notes in the fixup routine to reflect this new behavior.
 - Added reference to original commit, as this has technically been
   broken since then however only now is it an issue due to the clock
   changes.

Fixes: 4e7cf74fa3 ("clk: fractional-divider: Export approximation algorithm to the CCF users")
Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210916202907.18394-1-macroalpha82@gmail.com
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
2021-10-06 11:05:45 +02:00
..
analogix_dp-rockchip.c
cdn-dp-core.c drm/rockchip: cdn-dp-core: Make cdn_dp_core_resume __maybe_unused 2021-09-16 12:02:33 -07:00
cdn-dp-core.h
cdn-dp-reg.c drm/rockchip: cdn-dp: fix sign extension on an int multiply for a u64 result 2021-05-28 20:27:44 +02:00
cdn-dp-reg.h
dw_hdmi-rockchip.c drm/rockchip: dw_hdmi: fix incorrect clock in vpll clock error message 2020-11-29 17:39:21 +01:00
dw-mipi-dsi-rockchip.c drm/rockchip: dsi: add ability to work as a phy instead of full dsi 2021-07-25 17:19:49 +02:00
inno_hdmi.c
inno_hdmi.h
Kconfig drm/rockchip: dsi: add ability to work as a phy instead of full dsi 2021-07-25 17:19:49 +02:00
Makefile
rk3066_hdmi.c
rk3066_hdmi.h
rockchip_drm_drv.c drm/aperture: Pass DRM driver structure instead of driver name 2021-07-01 11:11:55 +02:00
rockchip_drm_drv.h
rockchip_drm_fb.c
rockchip_drm_fb.h
rockchip_drm_fbdev.c
rockchip_drm_fbdev.h
rockchip_drm_gem.c drm/gem: Use struct dma_buf_map in GEM vmap ops and convert GEM backends 2020-11-09 09:19:24 +01:00
rockchip_drm_gem.h drm/gem: Use struct dma_buf_map in GEM vmap ops and convert GEM backends 2020-11-09 09:19:24 +01:00
rockchip_drm_vop.c drm/rockchip: Update crtc fixup to account for fractional clk change 2021-10-06 11:05:45 +02:00
rockchip_drm_vop.h drm/rockchip: Require the YTR modifier for AFBC 2021-02-25 10:18:45 +01:00
rockchip_lvds.c drm/bridge: Centralize error message when bridge attach fails 2021-07-28 16:33:12 +03:00
rockchip_lvds.h
rockchip_rgb.c drm/bridge: Centralize error message when bridge attach fails 2021-07-28 16:33:12 +03:00
rockchip_rgb.h
rockchip_vop_reg.c drm/rockchip: vop: add PX30 version info 2021-05-28 20:30:35 +02:00
rockchip_vop_reg.h drm: rockchip: add alpha support for RK3036, RK3066, RK3126 and RK3188 2021-05-28 19:28:00 +02:00