linux/drivers/gpu/drm
Douglas Anderson 287422a95f drm/rockchip: Round up _before_ giving to the clock framework
I'm embarassed to say that even though I've touched
vop_crtc_mode_fixup() twice and I swear I tested it, there's still a
stupid glaring bug in it.  Specifically, on veyron_minnie (with all
the latest display timings) we want to be setting our pixel clock to
66,666,666.67 Hz and we tell userspace that's what we set, but we're
actually choosing 66,000,000 Hz.  This is confirmed by looking at the
clock tree.

The problem is that in drm_display_mode_from_videomode() we convert
from Hz to kHz with:

  dmode->clock = vm->pixelclock / 1000;

...and drm_display_mode_from_videomode() is called from panel-simple
when we have an "override_mode" like we do on veyron_minnie.  See
commit 123643e5c4 ("ARM: dts: rockchip: Specify
rk3288-veyron-minnie's display timings").

...so when the device tree specifies a clock of 66666667 for the panel
then DRM translates that to 66666000.  The clock framework will always
pick a clock that is _lower_ than the one requested, so it will refuse
to pick 66666667 and we'll end up at 66000000.

While we could try to fix drm_display_mode_from_videomode() to round
to the nearest kHz and it would fix our problem, it wouldn't help if
the clock we actually needed was 60,000,001 Hz.  We could
alternatively have DRM always round up, but maybe this would break
someone else who already baked in the assumption that DRM rounds down.
Specifically note that clock drivers are not consistent about whether
they round up or round down when you call clk_set_rate().  We know how
Rockchip's clock driver works, but (for instance) you can see that on
most Qualcomm clocks the default is clk_rcg2_ops which rounds up.

Let's solve this by just adding 999 Hz before calling
clk_round_rate().  This should be safe and work everywhere.  As
discussed in more detail in comments in the commit, Rockchip's PLLs
are configured in a way that there shouldn't be another PLL setting
that is only a few kHz off so we won't get mixed up.

NOTE: if this is picked to stable, it's probably easiest to first pick
commit 527e4ca3b6 ("drm/rockchip: Base adjustments of the mode based
on prev adjustments") which shouldn't hurt in stable.

Fixes: b59b8de314 ("drm/rockchip: return a true clock rate to adjusted_mode")
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191003114726.v2.1.Ib233b3e706cf6317858384264d5b0ed35657456e@changeid
2019-10-09 15:13:58 -04:00
..
amd Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
arc drm: Stop including drm_bridge.h from drm_crtc.h 2019-08-28 22:11:03 +02:00
arm drm/komeda: remove redundant assignment to pointer disable_done 2019-10-09 16:07:06 +08:00
armada drm/armada: drop use of drmP.h 2019-08-14 18:31:10 +02:00
aspeed drm/aspeed: gfc_crtc: Make structure aspeed_gfx_funcs constant 2019-08-14 19:27:26 +02:00
ast drm/ast: Allocate cursor BOs at high end of video memory 2019-10-04 10:00:21 +02:00
atmel-hlcdc drm/bridge: panel: Infer connector type from panel by default 2019-09-08 19:04:23 +02:00
bochs drm/vram: Have VRAM MM call GEM VRAM functions directly 2019-09-12 19:54:42 +02:00
bridge drm/bridge: dw-hdmi: Refuse DDC/CI transfers on the internal I2C controller 2019-10-07 14:27:48 +02:00
cirrus drm: drop resource_id parameter from drm_fb_helper_remove_conflicting_pci_framebuffers 2019-08-23 10:48:31 +02:00
etnaviv Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
exynos Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
fsl-dcu drm: Stop including drm_bridge.h from drm_crtc.h 2019-08-28 22:11:03 +02:00
gma500
hisilicon Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
i2c cec: add cec_adapter to cec_notifier_cec_adap_unregister() 2019-10-07 12:47:43 +02:00
i810 drm/i810: Prevent underflow in ioctl 2019-10-04 17:04:05 +01:00
i915 drm/mm: Convert drm_mm_node booleans to bitops 2019-10-04 13:43:13 +01:00
imx Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
ingenic drm main pull for 5.4-rc1 2019-09-19 16:24:24 -07:00
lib
lima drm/lima: Add support for multiple reset lines 2019-10-05 17:51:16 +08:00
mcde Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
mediatek Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
meson drm/meson: vclk: use the correct G12A frac max value 2019-09-30 15:22:09 +02:00
mga
mgag200 drm/mgag200: Allocate cursor BOs at high end of video memory 2019-10-04 10:01:12 +02:00
msm Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
mxsfb dma-buf: rename reservation_object to dma_resv 2019-08-13 09:09:30 +02:00
nouveau Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
omapdrm drm/omap: hdmi4: fix use of uninitialized var 2019-10-04 11:30:28 +03:00
panel drm: panel-lvds: Potential Oops in probe error handling 2019-09-21 20:48:09 +02:00
panfrost drm/panfrost: Remove commented out call to panfrost_core_dump 2019-10-09 13:36:56 -05:00
pl111 drm/bridge: panel: Infer connector type from panel by default 2019-09-08 19:04:23 +02:00
qxl Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
r128
radeon Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
rcar-du Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
rockchip drm/rockchip: Round up _before_ giving to the clock framework 2019-10-09 15:13:58 -04:00
savage
scheduler drm/scheduler: use job count instead of peek 2019-08-15 10:52:10 -05:00
selftests drm/mm: Use helpers for drm_mm_node booleans 2019-10-04 13:42:33 +01:00
shmobile
sis
sti drm: sti: fix W=1 warnings 2019-09-16 15:14:43 +02:00
stm drm/stm: dsi: higher pll out only in video burst mode 2019-09-16 15:14:10 +02:00
sun4i drm/sun4i: dsi: Fix video start delay computation 2019-10-08 07:56:41 +02:00
tdfx
tegra drm main pull for 5.4-rc1 2019-09-19 16:24:24 -07:00
tilcdc drm/tilcdc: plane: Make structure tilcdc_plane_funcs constant 2019-10-07 21:37:20 +03:00
tiny drm/tiny: Kconfig: Remove always-y THERMAL dep. from TINYDRM_REPAPER 2019-10-01 12:51:18 +02:00
ttm Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
tve200 drm/bridge: panel: Infer connector type from panel by default 2019-09-08 19:04:23 +02:00
udl drm/connector: Share with non-atomic drivers the function to get the single encoder 2019-09-16 15:13:02 -07:00
v3d drm/v3d: clean caches at the end of render jobs on request from user space 2019-09-19 12:57:44 -07:00
vboxvideo drm/vram: Have VRAM MM call GEM VRAM functions directly 2019-09-12 19:54:42 +02:00
vc4 drm/mm: Use helpers for drm_mm_node booleans 2019-10-04 13:42:33 +01:00
vgem dma-buf: rename reservation_object to dma_resv 2019-08-13 09:09:30 +02:00
via drivers/gpu/drm/via: convert put_page() to put_user_page*() 2019-09-24 15:54:08 -07:00
virtio drm main pull for 5.4-rc1 2019-09-19 16:24:24 -07:00
vkms drm/vkms: prime import support 2019-10-08 18:44:47 -04:00
vmwgfx Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
xen drm/xen-front: Make structure fb_funcs constant 2019-08-19 08:32:52 +03:00
zte
Kconfig drm/vkms: Fix an undefined reference error in vkms_composer_worker 2019-10-09 17:07:15 +02:00
Makefile Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
ati_pcigart.c
drm_agpsupport.c
drm_atomic.c
drm_atomic_helper.c Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
drm_atomic_state_helper.c drm/atomic: Rename crtc_state->pageflip_flags to async_flip 2019-09-18 18:43:36 +02:00
drm_atomic_uapi.c Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
drm_auth.c
drm_blend.c drm: two planes with the same zpos have undefined ordering 2019-10-09 20:04:55 +02:00
drm_bridge.c
drm_bufs.c
drm_cache.c
drm_client.c
drm_client_modeset.c Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
drm_color_mgmt.c
drm_connector.c drm: Add DisplayPort colorspace property creation function 2019-09-20 18:46:18 +03:00
drm_context.c
drm_crtc.c
drm_crtc_helper.c Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
drm_crtc_helper_internal.h drm/connector: Share with non-atomic drivers the function to get the single encoder 2019-09-16 15:13:02 -07:00
drm_crtc_internal.h
drm_damage_helper.c drm: damage_helper: Fix race checking plane->state->fb 2019-10-08 09:41:06 -04:00
drm_debugfs.c
drm_debugfs_crc.c drm: Fix return type of crc .poll() 2019-09-30 20:17:31 +03:00
drm_dma.c
drm_dp_aux_dev.c
drm_dp_cec.c drm_dp_cec: drop use of drmP.h 2019-10-08 18:29:00 +02:00
drm_dp_dual_mode_helper.c
drm_dp_helper.c drm/doc: Improve docs around connector (un)registration 2019-09-18 12:41:08 +02:00
drm_dp_mst_topology.c drm/print: add drm_debug_enabled() 2019-10-02 16:28:55 +03:00
drm_dp_mst_topology_internal.h drm/dp_mst: Add sideband down request tracing + selftests 2019-09-03 19:30:06 -04:00
drm_drv.c Merge drm/drm-next into drm-misc-next 2019-10-03 16:38:50 +02:00
drm_dsc.c drm/dsc: Fix bogus cpu_to_be16() usage 2019-09-30 20:15:53 +03:00
drm_dumb_buffers.c Revert "drm/gem: Rename drm_gem_dumb_map_offset() to drm_gem_map_offset()" 2019-08-07 11:56:48 -04:00
drm_edid.c drm/edid: Select DMT timing if EDID's display feature not support GTF 2019-10-09 15:27:59 +03:00
drm_edid_load.c drm/print: add drm_debug_enabled() 2019-10-02 16:28:55 +03:00
drm_encoder.c drm: Stop including drm_bridge.h from drm_crtc.h 2019-08-28 22:11:03 +02:00
drm_encoder_slave.c
drm_fb_cma_helper.c
drm_fb_helper.c drm/fb-helper: Include prototype for drm_fb_helper_modinit() 2019-09-30 20:15:07 +03:00
drm_file.c
drm_flip_work.c
drm_format_helper.c
drm_fourcc.c
drm_framebuffer.c
drm_gem.c dma-buf: rename reservation_object to dma_resv 2019-08-13 09:09:30 +02:00
drm_gem_cma_helper.c
drm_gem_framebuffer_helper.c dma-buf: rename reservation_object to dma_resv 2019-08-13 09:09:30 +02:00
drm_gem_shmem_helper.c drm/shmem: Use mutex_trylock in drm_gem_shmem_purge 2019-08-28 10:02:39 -05:00
drm_gem_ttm_helper.c drm: tweak drm_print_bits() 2019-09-24 09:57:21 +02:00
drm_gem_vram_helper.c drm/vram: Support top-down placement flag 2019-09-27 09:48:53 +02:00
drm_hashtab.c
drm_hdcp.c drm/hdcp: reference for srm file format 2019-08-06 13:18:42 +05:30
drm_internal.h
drm_ioc32.c
drm_ioctl.c drm/atomic: Take the atomic toys away from X 2019-09-18 18:42:21 +02:00
drm_irq.c
drm_kms_helper_common.c drm: fix module name in edid_firmware log message 2019-08-22 10:41:06 +03:00
drm_lease.c
drm_legacy.h
drm_legacy_misc.c
drm_lock.c
drm_memory.c drm: Include prototype for drm_need_swiotlb() 2019-09-30 20:16:28 +03:00
drm_mipi_dbi.c drm/print: add drm_debug_enabled() 2019-10-02 16:28:55 +03:00
drm_mipi_dsi.c
drm_mm.c drm/mm: Use clear_bit_unlock() for releasing the drm_mm_node() 2019-10-04 13:43:43 +01:00
drm_mode_config.c
drm_mode_object.c drm/kms: Duct-tape for mode object lifetime checks 2019-09-18 11:27:18 +02:00
drm_modes.c drm main pull for 5.4-rc1 2019-09-19 16:24:24 -07:00
drm_modeset_helper.c
drm_modeset_lock.c
drm_of.c drm: Remove redundant of_device_is_available check 2019-09-20 15:03:42 -04:00
drm_panel.c drm/panel: Add and fill drm_panel type field 2019-09-08 19:04:01 +02:00
drm_panel_orientation_quirks.c
drm_pci.c
drm_plane.c
drm_plane_helper.c
drm_prime.c
drm_print.c drm/print: add drm_debug_enabled() 2019-10-02 16:28:55 +03:00
drm_probe_helper.c drm/connector: Allow max possible encoders to attach to a connector 2019-09-16 15:13:53 -07:00
drm_property.c
drm_rect.c
drm_scatter.c
drm_scdc_helper.c
drm_self_refresh_helper.c drm: Measure Self Refresh Entry/Exit times to avoid thrashing 2019-09-19 10:03:32 -04:00
drm_simple_kms_helper.c drm: Stop including drm_bridge.h from drm_crtc.h 2019-08-28 22:11:03 +02:00
drm_syncobj.c drm/syncobj: Include the prototype for drm_timeout_abs_to_jiffies() 2019-09-30 20:17:00 +03:00
drm_sysfs.c drm: uevent for connector status change 2019-08-06 13:16:54 +05:30
drm_trace.h drm: Add high-precision time to vblank trace event 2019-09-03 09:46:18 +02:00
drm_trace_points.c
drm_vblank.c drm/drm_vblank: Change EINVAL by the correct errno 2019-10-08 18:43:26 -04:00
drm_vm.c
drm_vma_manager.c
drm_vram_helper_common.c drm/vram: Have VRAM MM call GEM VRAM functions directly 2019-09-12 19:54:42 +02:00
drm_writeback.c