From 34d813e45ecb8e84f7154509b1acf7dda57ef09f Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Sat, 4 Jan 2025 09:58:28 +0200 Subject: [PATCH 01/10] drm/display: hdmi-state-helper: add drm_display_mode declaration Add forward-declaration for the struct drm_display_mode, missed in the commit 47368ab437fd ("drm/display: hdmi: add generic mode_valid helper") Fixes: 47368ab437fd ("drm/display: hdmi: add generic mode_valid helper") Signed-off-by: Dmitry Baryshkov Link: https://patchwork.freedesktop.org/patch/msgid/20250104-hdmi-state-display-mode-v1-1-3c06d36e726f@linaro.org Signed-off-by: Maxime Ripard --- include/drm/display/drm_hdmi_state_helper.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/drm/display/drm_hdmi_state_helper.h b/include/drm/display/drm_hdmi_state_helper.h index 9ae19f3caf727..44ec5c4a7503c 100644 --- a/include/drm/display/drm_hdmi_state_helper.h +++ b/include/drm/display/drm_hdmi_state_helper.h @@ -6,6 +6,7 @@ struct drm_atomic_state; struct drm_connector; struct drm_connector_state; +struct drm_display_mode; struct hdmi_audio_infoframe; enum drm_connector_status; From 0d337b40ca1e532af42516d9e9024baad466319a Mon Sep 17 00:00:00 2001 From: Liu Ying Date: Fri, 10 Jan 2025 16:48:20 +0800 Subject: [PATCH 02/10] drm/connector: hdmi: Do atomic check when necessary It's ok to pass atomic check successfully if an atomic commit tries to disable the display pipeline which the connector belongs to. That is, when the crtc or the best_encoder pointers in struct drm_connector_state are NULL, drm_atomic_helper_connector_hdmi_check() should return 0. Without the check against the NULL pointers, drm_default_rgb_quant_range() called by drm_atomic_helper_connector_hdmi_check() would dereference the NULL pointer to_match in drm_match_cea_mode(). Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 Call trace: drm_default_rgb_quant_range+0x0/0x4c (P) drm_bridge_connector_atomic_check+0x20/0x2c drm_atomic_helper_check_modeset+0x488/0xc78 drm_atomic_helper_check+0x20/0xa4 drm_atomic_check_only+0x4b8/0x984 drm_atomic_commit+0x48/0xc4 drm_framebuffer_remove+0x44c/0x530 drm_mode_rmfb_work_fn+0x7c/0xa0 process_one_work+0x150/0x294 worker_thread+0x2dc/0x3dc kthread+0x130/0x204 ret_from_fork+0x10/0x20 Fixes: 8ec116ff21a9 ("drm/display: bridge_connector: provide atomic_check for HDMI bridges") Fixes: 84e541b1e58e ("drm/sun4i: use drm_atomic_helper_connector_hdmi_check()") Fixes: 65548c8ff0ab ("drm/rockchip: inno_hdmi: Switch to HDMI connector") Signed-off-by: Liu Ying Reviewed-by: Dmitry Baryshkov Link: https://patchwork.freedesktop.org/patch/msgid/20250110084821.3239518-2-victor.liu@nxp.com Signed-off-by: Maxime Ripard --- drivers/gpu/drm/display/drm_hdmi_state_helper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c index cfc2aaee1da08..daaf68b80e5fe 100644 --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c @@ -503,6 +503,9 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector, connector_state_get_mode(new_conn_state); int ret; + if (!new_conn_state->crtc || !new_conn_state->best_encoder) + return 0; + new_conn_state->hdmi.is_limited_range = hdmi_is_limited_range(connector, new_conn_state); ret = hdmi_compute_config(connector, new_conn_state, mode); From e12b9dc6f982d1e110f87215a9114d14dbd60fbc Mon Sep 17 00:00:00 2001 From: Liu Ying Date: Fri, 10 Jan 2025 16:48:21 +0800 Subject: [PATCH 03/10] drm/tests: hdmi: Add connector disablement test Atomic check should succeed when disabling a connector. Add a test case drm_test_check_disabling_connector() to make sure of this. Suggested-by: Dmitry Baryshkov Signed-off-by: Liu Ying Link: https://patchwork.freedesktop.org/patch/msgid/20250110084821.3239518-3-victor.liu@nxp.com Signed-off-by: Maxime Ripard --- .../drm/tests/drm_hdmi_state_helper_test.c | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c index c3b693bb966f1..b976a5e9aef58 100644 --- a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c +++ b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c @@ -1568,6 +1568,57 @@ static void drm_test_check_output_bpc_format_display_8bpc_only(struct kunit *tes KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_format, HDMI_COLORSPACE_RGB); } +/* Test that atomic check succeeds when disabling a connector. */ +static void drm_test_check_disable_connector(struct kunit *test) +{ + struct drm_atomic_helper_connector_hdmi_priv *priv; + struct drm_modeset_acquire_ctx *ctx; + struct drm_connector_state *conn_state; + struct drm_crtc_state *crtc_state; + struct drm_atomic_state *state; + struct drm_display_mode *preferred; + struct drm_connector *conn; + struct drm_device *drm; + struct drm_crtc *crtc; + int ret; + + priv = drm_kunit_helper_connector_hdmi_init(test, + BIT(HDMI_COLORSPACE_RGB), + 8); + KUNIT_ASSERT_NOT_NULL(test, priv); + + ctx = drm_kunit_helper_acquire_ctx_alloc(test); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); + + conn = &priv->connector; + preferred = find_preferred_mode(conn); + KUNIT_ASSERT_NOT_NULL(test, preferred); + + drm = &priv->drm; + crtc = priv->crtc; + ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); + KUNIT_ASSERT_EQ(test, ret, 0); + + state = drm_kunit_helper_atomic_state_alloc(test, drm, ctx); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); + + crtc_state = drm_atomic_get_crtc_state(state, crtc); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_state); + + crtc_state->active = false; + ret = drm_atomic_set_mode_for_crtc(crtc_state, NULL); + KUNIT_EXPECT_EQ(test, ret, 0); + + conn_state = drm_atomic_get_connector_state(state, conn); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, conn_state); + + ret = drm_atomic_set_crtc_for_connector(conn_state, NULL); + KUNIT_EXPECT_EQ(test, ret, 0); + + ret = drm_atomic_check_only(state); + KUNIT_ASSERT_EQ(test, ret, 0); +} + static struct kunit_case drm_atomic_helper_connector_hdmi_check_tests[] = { KUNIT_CASE(drm_test_check_broadcast_rgb_auto_cea_mode), KUNIT_CASE(drm_test_check_broadcast_rgb_auto_cea_mode_vic_1), @@ -1582,6 +1633,7 @@ static struct kunit_case drm_atomic_helper_connector_hdmi_check_tests[] = { */ KUNIT_CASE(drm_test_check_broadcast_rgb_crtc_mode_changed), KUNIT_CASE(drm_test_check_broadcast_rgb_crtc_mode_not_changed), + KUNIT_CASE(drm_test_check_disable_connector), KUNIT_CASE(drm_test_check_hdmi_funcs_reject_rate), KUNIT_CASE(drm_test_check_max_tmds_rate_bpc_fallback), KUNIT_CASE(drm_test_check_max_tmds_rate_format_fallback), From 78a5acf5433d8c675fa826da3ce8646c999f2842 Mon Sep 17 00:00:00 2001 From: Cristian Ciocaltea Date: Mon, 13 Jan 2025 15:36:18 +0200 Subject: [PATCH 04/10] drm/display: hdmi: Do not read EDID on disconnected connectors The recently introduced hotplug event handler in the HDMI Connector framework attempts to unconditionally read the EDID data, leading to a bunch of non-harmful, yet quite annoying DDC/I2C related errors being reported. Ensure the operation is done only for connectors having the status connected or unknown. Additionally, perform an explicit reset of the connector information when dealing with a disconnected status. Fixes: ab716b74dc9d ("drm/display/hdmi: implement hotplug functions") Signed-off-by: Cristian Ciocaltea Link: https://patchwork.freedesktop.org/patch/msgid/20250113-hdmi-conn-edid-read-fix-v2-1-d2a0438a44ab@collabora.com Signed-off-by: Maxime Ripard --- drivers/gpu/drm/display/drm_hdmi_state_helper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c index daaf68b80e5fe..9b2ee23856343 100644 --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c @@ -791,6 +791,8 @@ drm_atomic_helper_connector_hdmi_update(struct drm_connector *connector, if (status == connector_status_disconnected) { // TODO: also handle CEC and scramber, HDMI sink disconnected. drm_connector_hdmi_audio_plugged_notify(connector, false); + drm_edid_connector_update(connector, NULL); + return; } if (connector->hdmi.funcs->read_edid) From 8f52fd7a7de6097089f73bd7dad7c558ea9a8a3f Mon Sep 17 00:00:00 2001 From: Jiapeng Chong Date: Tue, 14 Jan 2025 14:28:04 +0800 Subject: [PATCH 05/10] kernel/cgroup: Remove the unused variable climit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Variable climit is not effectively used, so delete it. kernel/cgroup/dmem.c:302:23: warning: variable ‘climit’ set but not used. Reported-by: Abaci Robot Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=13512 Signed-off-by: Jiapeng Chong Acked-by: Tejun Heo Link: https://patchwork.freedesktop.org/patch/msgid/20250114062804.5092-1-jiapeng.chong@linux.alibaba.com Signed-off-by: Maxime Ripard --- kernel/cgroup/dmem.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/cgroup/dmem.c b/kernel/cgroup/dmem.c index 52736ef0ccf25..78d9361ed5216 100644 --- a/kernel/cgroup/dmem.c +++ b/kernel/cgroup/dmem.c @@ -299,7 +299,7 @@ bool dmem_cgroup_state_evict_valuable(struct dmem_cgroup_pool_state *limit_pool, bool ignore_low, bool *ret_hit_low) { struct dmem_cgroup_pool_state *pool = test_pool; - struct page_counter *climit, *ctest; + struct page_counter *ctest; u64 used, min, low; /* Can always evict from current pool, despite limits */ @@ -324,7 +324,6 @@ bool dmem_cgroup_state_evict_valuable(struct dmem_cgroup_pool_state *limit_pool, {} } - climit = &limit_pool->cnt; ctest = &test_pool->cnt; dmem_cgroup_calculate_protection(limit_pool, test_pool); From e33b51499a0a6bcaf44824f5b6e6bc65bb75b79d Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Mon, 13 Jan 2025 10:26:05 +0100 Subject: [PATCH 06/10] cgroup/dmem: Select PAGE_COUNTER The dmem cgroup the page counting API implemented behing the PAGE_COUNTER kconfig option. However, it doesn't select it, resulting in potential build breakages. Select PAGE_COUNTER. Fixes: b168ed458dde ("kernel/cgroup: Add "dmem" memory accounting cgroup") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202501111330.3VuUx8vf-lkp@intel.com/ Acked-by: Tejun Heo Reviewed-by: Simona Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20250113092608.1349287-1-mripard@kernel.org Signed-off-by: Maxime Ripard --- init/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/init/Kconfig b/init/Kconfig index 61f50cafa8151..5e53285061381 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1139,6 +1139,7 @@ config CGROUP_RDMA config CGROUP_DMEM bool "Device memory controller (DMEM)" + select PAGE_COUNTER help The DMEM controller allows compatible devices to restrict device memory usage based on the cgroup hierarchy. From feb85972b82c9747ebb0843f91e4c1e023b47f3d Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Mon, 13 Jan 2025 10:26:06 +0100 Subject: [PATCH 07/10] cgroup/dmem: Fix parameters documentation During the dmem cgroup development, the parameters to the dmem_cgroup_state_evict_valuable() and dmem_cgroup_try_charge() were changed, but the documentation wasn't adjusted accordingly. This results in a documentation build warning. Adjust the documentation to reflect what the final functions parameters are. Fixes: b168ed458dde ("kernel/cgroup: Add "dmem" memory accounting cgroup") Reported-by: Stephen Rothwell Closes: https://lore.kernel.org/r/20250113160334.1f09f881@canb.auug.org.au/ Acked-by: Tejun Heo Reviewed-by: Simona Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20250113092608.1349287-2-mripard@kernel.org Signed-off-by: Maxime Ripard --- kernel/cgroup/dmem.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kernel/cgroup/dmem.c b/kernel/cgroup/dmem.c index 78d9361ed5216..fbe34299673d3 100644 --- a/kernel/cgroup/dmem.c +++ b/kernel/cgroup/dmem.c @@ -280,8 +280,6 @@ dmem_cgroup_calculate_protection(struct dmem_cgroup_pool_state *limit_pool, /** * dmem_cgroup_state_evict_valuable() - Check if we should evict from test_pool - * @dev: &dmem_cgroup_region - * @index: The index number of the region being tested. * @limit_pool: The pool for which we hit limits * @test_pool: The pool for which to test * @ignore_low: Whether we have to respect low watermarks. @@ -610,13 +608,12 @@ EXPORT_SYMBOL_GPL(dmem_cgroup_uncharge); /** * dmem_cgroup_try_charge() - Try charging a new allocation to a region. - * @dev: Device to charge + * @region: dmem region to charge * @size: Size (in bytes) to charge. * @ret_pool: On succesfull allocation, the pool that is charged. * @ret_limit_pool: On a failed allocation, the limiting pool. * - * This function charges the current pool for @dev with region at @index for a - * size of @size bytes. + * This function charges the @region region for a size of @size bytes. * * If the function succeeds, @ret_pool is set, which must be passed to * dmem_cgroup_uncharge() when undoing the allocation. From f45cdbc9e1a3f4367dc92792cb1ace2b9e133e37 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Mon, 13 Jan 2025 10:26:07 +0100 Subject: [PATCH 08/10] drm/doc: Include new drm-compute documentation Commit b168ed458dde ("kernel/cgroup: Add "dmem" memory accounting cgroup") introduced a new documentation file, but didn't link it anywhere. It was thus triggering a documentation build warning. Make sure it's included as part of the DRM documentation. Fixes: b168ed458dde ("kernel/cgroup: Add "dmem" memory accounting cgroup") Reported-by: Stephen Rothwell Closes: https://lore.kernel.org/r/20250113155000.4a99e7b0@canb.auug.org.au/ Acked-by: Tejun Heo Reviewed-by: Simona Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20250113092608.1349287-3-mripard@kernel.org Signed-off-by: Maxime Ripard --- Documentation/gpu/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/gpu/index.rst b/Documentation/gpu/index.rst index 37e383ccf73f2..7dcb15850afdb 100644 --- a/Documentation/gpu/index.rst +++ b/Documentation/gpu/index.rst @@ -13,6 +13,7 @@ GPU Driver Developer's Guide drm-usage-stats driver-uapi drm-client + drm-compute drivers backlight vga-switcheroo From 79c4b4f431bb39d6d14787f1ff458c637a72754d Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Mon, 13 Jan 2025 10:26:08 +0100 Subject: [PATCH 09/10] doc/cgroup: Fix title underline length Commit b168ed458dde ("kernel/cgroup: Add "dmem" memory accounting cgroup") introduced a new documentation file, with a shorter than expected underline. This results in a documentation build warning. Fix that underline length. Fixes: b168ed458dde ("kernel/cgroup: Add "dmem" memory accounting cgroup") Reported-by: Stephen Rothwell Closes: https://lore.kernel.org/r/20250113154611.624256bf@canb.auug.org.au/ Acked-by: Tejun Heo Reviewed-by: Simona Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20250113092608.1349287-4-mripard@kernel.org Signed-off-by: Maxime Ripard --- Documentation/core-api/cgroup.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/core-api/cgroup.rst b/Documentation/core-api/cgroup.rst index 8696e9513f511..734ea21e1e17a 100644 --- a/Documentation/core-api/cgroup.rst +++ b/Documentation/core-api/cgroup.rst @@ -3,7 +3,7 @@ Cgroup Kernel APIs ================== Device Memory Cgroup API (dmemcg) -========================= +================================= .. kernel-doc:: kernel/cgroup/dmem.c :export: From f1359f46f1f1305340970b5073240126fe87254f Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Tue, 7 Jan 2025 12:06:39 +0200 Subject: [PATCH 10/10] drm/bridge: fix documentation for the hdmi_audio_prepare() callback Fix c&p error and change linuxdoc comment for the hdmi_audio_prepare() callback from drm_bridge_funcs to mention the callback name instead of the original prepare() callback. Fixes: 0beba3f9d366 ("drm/bridge: connector: add support for HDMI codec framework") Reported-by: Stephen Rothwell Closes: https://lore.kernel.org/linux-next/20250106174645.463927e0@canb.auug.org.au/ Acked-by: Maxime Ripard Reviewed-by: Rodrigo Vivi Link: https://patchwork.freedesktop.org/patch/msgid/20250107-drm-bridge-fix-docs-v1-1-84e539e6f348@linaro.org Signed-off-by: Dmitry Baryshkov --- include/drm/drm_bridge.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 4b84faf14e368..496dbbd2ad7ed 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -691,7 +691,7 @@ struct drm_bridge_funcs { struct drm_bridge *bridge); /** - * @prepare: + * @hdmi_audio_prepare: * Configures HDMI-encoder for audio stream. Can be called multiple * times for each setup. Mandatory if HDMI audio is enabled in the * bridge's configuration.