No description
Find a file
maxime@cerno.tech defc98a013 drm/vc4: hdmi: Fix HSM clock too low on Pi4
[ Upstream commit 3bc6a37f59 ]

Commit ae71ab585c ("drm/vc4: hdmi: Enforce the minimum rate at
runtime_resume") reintroduced the call to clk_set_min_rate in an attempt
to fix the boot without a monitor connected on the RaspberryPi3.

However, that introduced a regression breaking the display output
entirely (black screen but no vblank timeout) on the Pi4.

This is due to the fact that we now have in a typical modeset at boot,
in vc4_hdmi_encoder_pre_crtc_configure(), we have a first call to
clk_set_min_rate() asking for the minimum rate of the HSM clock for our
given resolution, and then a call to pm_runtime_resume_and_get(). We
will thus execute vc4_hdmi_runtime_resume() which, since the commit
mentioned above, will call clk_set_min_rate() a second time with the
absolute minimum rate we want to enforce on the HSM clock.

We're thus effectively erasing the minimum mandated by the mode we're
trying to set. The fact that only the Pi4 is affected is due to the fact
that it uses a different clock driver that tries to minimize the HSM
clock at all time. It will thus lower the HSM clock rate to 120MHz on
the second clk_set_min_rate() call.

The Pi3 doesn't use the same driver and will not change the frequency on
the second clk_set_min_rate() call since it's still within the new
boundaries and it doesn't have the code to minimize the clock rate as
needed. So even though the boundaries are still off, the clock rate is
still the right one for our given mode, so everything works.

There is a lot of moving parts, so I couldn't find any obvious
solution:

  - Reverting the original is not an option, as that would break the Pi3
    again.

  - We can't move the clk_set_min_rate() call in _pre_crtc_configure()
    since because, on the Pi3, the HSM clock has the CLK_SET_RATE_GATE
    flag which prevents the clock rate from being changed after it's
    been enabled. Our calls to clk_set_min_rate() can change it, so they
    need to be done before clk_prepare_enable().

  - We can't remove the call to clk_prepare_enable() from the
    runtime_resume hook to put it into _pre_crtc_configure() either,
    since we need that clock to be enabled to access the registers, and
    we can't count on the fact that the display will be active in all
    situations (doing any CEC operation, or listing the modes while
    inactive are valid for example()).

  - We can't drop the call to clk_set_min_rate() in
    _pre_crtc_configure() since we would need to still enforce the
    minimum rate for a given resolution, and runtime_resume doesn't have
    access to the current mode, if there's any.

  - We can't copy the TMDS character rate into vc4_hdmi and reuse it
    since, because it's part of the KMS atomic state, it needs to be
    protected by a mutex. Unfortunately, some functions (CEC operations,
    mostly) can be reentrant (through the CEC framework) and still need
    a pm_runtime_get.

However, we can work around this issue by leveraging the fact that the
clk_set_min_rate() calls set boundaries for its given struct clk, and
that each different clk_get() call will return a different instance of
struct clk. The clock framework will then aggregate the boundaries for
each struct clk instances linked to a given clock, plus its hardware
boundaries, and will use that.

We can thus get an extra HSM clock user for runtime_pm use only, and use
our different clock instances depending on the context: runtime_pm will
use its own to set the absolute minimum clock setup so that we never
lock the CPU waiting for a register access, and the modeset part will
set its requirement for the current resolution. And we let the CCF do
the coordination.

It's not an ideal solution, but it's fairly unintrusive and doesn't
really change any part of the logic so it looks like a rather safe fix.

Link: https://bugzilla.redhat.com/show_bug.cgi?id=2136234
Fixes: ae71ab585c ("drm/vc4: hdmi: Enforce the minimum rate at runtime_resume")
Reported-by: Peter Robinson <pbrobinson@gmail.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Link: https://lore.kernel.org/r/20221021131339.2203291-1-maxime@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-11-16 10:03:52 +01:00
arch m68k: Rework BI_VIRT_RNG_SEED as BI_RNG_SEED 2022-11-16 10:03:48 +01:00
block blk-mq: Fix kmemleak in blk_mq_init_allocated_queue 2022-11-10 18:17:29 +01:00
certs certs: make system keyring depend on built-in x509 parser 2022-09-24 04:31:18 +09:00
crypto crypto: akcipher - default implementation for setting a private key 2022-10-21 12:38:59 +02:00
Documentation tracing/histogram: Update document for KEYS_MAX size 2022-11-10 18:17:33 +01:00
drivers drm/vc4: hdmi: Fix HSM clock too low on Pi4 2022-11-16 10:03:52 +01:00
fs cifs: fix regression in very old smb1 mounts 2022-11-10 18:17:39 +01:00
include KVM: Initialize gfn_to_pfn_cache locks in dedicated helper 2022-11-10 18:17:38 +01:00
init arm64 fixes for -rc3 2022-08-26 11:32:53 -07:00
io_uring io_uring: don't iopoll from io_ring_ctx_wait_and_kill() 2022-11-10 18:17:25 +01:00
ipc ipc: mqueue: fix possible memory leak in init_mqueue_fs() 2022-10-21 12:38:55 +02:00
kernel bpf, verifier: Fix memory leak in array reallocation for stack state 2022-11-16 10:03:51 +01:00
lib lib/Kconfig.debug: Add check for non-constant .{s,u}leb128 support to DWARF5 2022-10-21 12:39:29 +02:00
LICENSES LICENSES/LGPL-2.1: Add LGPL-2.1-or-later as valid identifiers 2021-12-16 14:33:10 +01:00
mm mm: prep_compound_tail() clear page->private 2022-11-04 00:00:23 +09:00
net wifi: mac80211: Set TWT Information Frame Disabled bit as 1 2022-11-16 10:03:51 +01:00
samples Tracing updates for 5.20 / 6.0 2022-08-05 09:41:12 -07:00
scripts kbuild: rpm-pkg: fix breakage when V=1 is used 2022-10-21 12:39:01 +02:00
security capabilities: fix potential memleak on error path from vfs_getxattr_alloc() 2022-11-10 18:17:33 +01:00
sound ALSA: arm: pxa: pxa2xx-ac97-lib: fix return value check of platform_get_irq() 2022-11-16 10:03:51 +01:00
tools bpftool: Fix NULL pointer dereference when pin {PROG, MAP, LINK} without FILE 2022-11-16 10:03:51 +01:00
usr Not a lot of material this cycle. Many singleton patches against various 2022-05-27 11:22:03 -07:00
virt KVM: debugfs: Return retval of simple_attr_open() if it fails 2022-11-16 10:03:48 +01:00
.clang-format PCI/DOE: Add DOE mailbox support functions 2022-07-19 15:38:04 -07:00
.cocciconfig
.get_maintainer.ignore get_maintainer: add Alan to .get_maintainer.ignore 2022-08-20 15:17:44 -07:00
.gitattributes .gitattributes: use 'dts' diff driver for dts files 2019-12-04 19:44:11 -08:00
.gitignore kbuild: split the second line of *.mod into *.usyms 2022-05-08 03:16:59 +09:00
.mailmap Qualcomm ARM64 DTS fixes for 6.0 2022-09-23 16:44:37 +02:00
COPYING COPYING: state that all contributions really are covered by this file 2020-02-10 13:32:20 -08:00
CREDITS drm for 5.20/6.0 2022-08-03 19:52:08 -07:00
Kbuild kbuild: rename hostprogs-y/always to hostprogs/always-y 2020-02-04 01:53:07 +09:00
Kconfig kbuild: ensure full rebuild when the compiler is updated 2020-05-12 13:28:33 +09:00
MAINTAINERS One MAINTAINERS update, two MM fixes, both cc:stable 2022-10-01 09:13:29 -07:00
Makefile Linux 6.0.8 2022-11-10 18:17:40 +01:00
README Drop all 00-INDEX files from Documentation/ 2018-09-09 15:08:58 -06:00

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.