From a59a271769149f0b8258507276f3d2a24370cbdb Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Wed, 28 May 2025 11:29:36 +0200 Subject: [PATCH 01/11] drm/bridge: tc358767: convert to devm_drm_bridge_alloc() API This is the new API for allocating DRM bridges. Converting this driver is a bit complex because the drm_bridge funcs pointer differs based on the bridge mode. So the current code does: * tc_probe() * devm_kzalloc() private struct embedding drm_bridge * call tc_probe_bridge_endpoint() which * parses DT description into struct fields * computes the mode * calls different bridge init functions based on the mode * each sets a different bridge.funcs pointer The new API expects the funcs pointer to be known at alloc time, which does not fit in the current code structure. Solve this by splitting tc_probe_bridge_endpoint() in two functions: * tc_probe_get_mode(), computing the mode without needing the private driver structure * tc_probe_bridge_endpoint(), only initializing the endpoints So now the mode is known before allocation and so is the funcs pointer, while all other operations are still happening after allocation, directly into the private struct data, as they used to. The new code flow is: * tc_probe() * tc_probe_get_mode() * parses DT description * computes and returns the mode * based onf the mode, pick the funcs pointer * devm_drm_bridfge_alloc(..., funcs) * call tc_probe_bridge_endpoint() which * calls different bridge init functions based on the mode * these don't set the funcs pointer, it was done by _alloc This solution is chosen to minimize the changes in the driver logical code flow. The drawback is we now iterate twice over the endpoints during probe. Reviewed-by: Dmitry Baryshkov Link: https://lore.kernel.org/r/20250528-drm-bridge-convert-to-alloc-api-v4-1-f04e698c9a77@bootlin.com Signed-off-by: Luca Ceresoli --- drivers/gpu/drm/bridge/tc358767.c | 56 ++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 7e5449fb86a3..61559467e2d2 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -344,6 +344,14 @@ #define COLOR_BAR_MODE_BARS 2 #define PLL_DBG 0x0a04 +enum tc_mode { + mode_dpi_to_edp = BIT(1) | BIT(2), + mode_dpi_to_dp = BIT(1), + mode_dsi_to_edp = BIT(0) | BIT(2), + mode_dsi_to_dp = BIT(0), + mode_dsi_to_dpi = BIT(0) | BIT(1), +}; + static bool tc_test_pattern; module_param_named(test, tc_test_pattern, bool, 0644); @@ -2327,7 +2335,6 @@ static int tc_probe_dpi_bridge_endpoint(struct tc_data *tc) if (bridge) { tc->panel_bridge = bridge; tc->bridge.type = DRM_MODE_CONNECTOR_DPI; - tc->bridge.funcs = &tc_dpi_bridge_funcs; return 0; } @@ -2360,7 +2367,6 @@ static int tc_probe_edp_bridge_endpoint(struct tc_data *tc) tc->bridge.type = DRM_MODE_CONNECTOR_DisplayPort; } - tc->bridge.funcs = &tc_edp_bridge_funcs; if (tc->hpd_pin >= 0) tc->bridge.ops |= DRM_BRIDGE_OP_DETECT; tc->bridge.ops |= DRM_BRIDGE_OP_EDID; @@ -2368,17 +2374,11 @@ static int tc_probe_edp_bridge_endpoint(struct tc_data *tc) return 0; } -static int tc_probe_bridge_endpoint(struct tc_data *tc) +static enum tc_mode tc_probe_get_mode(struct device *dev) { - struct device *dev = tc->dev; struct of_endpoint endpoint; struct device_node *node = NULL; - const u8 mode_dpi_to_edp = BIT(1) | BIT(2); - const u8 mode_dpi_to_dp = BIT(1); - const u8 mode_dsi_to_edp = BIT(0) | BIT(2); - const u8 mode_dsi_to_dp = BIT(0); - const u8 mode_dsi_to_dpi = BIT(0) | BIT(1); - u8 mode = 0; + enum tc_mode mode = 0; /* * Determine bridge configuration. @@ -2401,7 +2401,27 @@ static int tc_probe_bridge_endpoint(struct tc_data *tc) return -EINVAL; } mode |= BIT(endpoint.port); + } + if (mode != mode_dpi_to_edp && + mode != mode_dpi_to_dp && + mode != mode_dsi_to_dpi && + mode != mode_dsi_to_edp && + mode != mode_dsi_to_dp) { + dev_warn(dev, "Invalid mode (0x%x) is not supported!\n", mode); + return -EINVAL; + } + + return mode; +} + +static int tc_probe_bridge_endpoint(struct tc_data *tc, enum tc_mode mode) +{ + struct device *dev = tc->dev; + struct of_endpoint endpoint; + struct device_node *node = NULL; + + for_each_endpoint_of_node(dev->of_node, node) { if (endpoint.port == 2) { of_property_read_u8_array(node, "toshiba,pre-emphasis", tc->pre_emphasis, @@ -2427,24 +2447,28 @@ static int tc_probe_bridge_endpoint(struct tc_data *tc) return tc_probe_edp_bridge_endpoint(tc); } - dev_warn(dev, "Invalid mode (0x%x) is not supported!\n", mode); - + /* Should never happen, mode was validated by tc_probe_get_mode() */ return -EINVAL; } static int tc_probe(struct i2c_client *client) { struct device *dev = &client->dev; + const struct drm_bridge_funcs *funcs; struct tc_data *tc; + int mode; int ret; - tc = devm_kzalloc(dev, sizeof(*tc), GFP_KERNEL); - if (!tc) - return -ENOMEM; + mode = tc_probe_get_mode(dev); + funcs = (mode == mode_dsi_to_dpi) ? &tc_dpi_bridge_funcs : &tc_edp_bridge_funcs; + + tc = devm_drm_bridge_alloc(dev, struct tc_data, bridge, funcs); + if (IS_ERR(tc)) + return PTR_ERR(tc); tc->dev = dev; - ret = tc_probe_bridge_endpoint(tc); + ret = tc_probe_bridge_endpoint(tc, mode); if (ret) return ret; From ea024e6e7a64f7f9a12bfaace61105006ba863e5 Mon Sep 17 00:00:00 2001 From: Louis-Alexis Eyraud Date: Fri, 9 May 2025 12:12:47 +0200 Subject: [PATCH 02/11] dt-bindings: gpu: mali-bifrost: Add compatible for MT8370 SoC Add a compatible for the MediaTek MT8370 SoC, with an integrated ARM Mali G57 MC2 GPU (Valhall-JM, dual core). None of the already existing SoC specific compatibles is usable as fallback, as those either do not match the number of cores (and number of power domains), or are for a different GPU architecture. Reviewed-by: AngeloGioacchino Del Regno Acked-by: Conor Dooley Signed-off-by: Louis-Alexis Eyraud Signed-off-by: Steven Price Link: https://lore.kernel.org/r/20250509-mt8370-enable-gpu-v6-1-2833888cb1d3@collabora.com --- Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml b/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml index b8d659d272d0..7e947016dee9 100644 --- a/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml +++ b/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml @@ -42,6 +42,7 @@ properties: - enum: - mediatek,mt8188-mali - mediatek,mt8192-mali + - mediatek,mt8370-mali - const: arm,mali-valhall-jm # Mali Valhall GPU model/revision is fully discoverable reg: @@ -225,7 +226,9 @@ allOf: properties: compatible: contains: - const: mediatek,mt8186-mali + enum: + - mediatek,mt8186-mali + - mediatek,mt8370-mali then: properties: power-domains: From 6905b0d9813176087fc0f28bc5e4ee2b86e6ce13 Mon Sep 17 00:00:00 2001 From: Louis-Alexis Eyraud Date: Fri, 9 May 2025 12:12:48 +0200 Subject: [PATCH 03/11] drm/panfrost: Drop duplicated Mediatek supplies arrays In the panfrost driver, the platform data of several Mediatek SoC declares and uses custom supplies array definitions (mediatek_mt8192_supplies, mediatek_mt8183_b_supplies), that are the same as default_supplies (used by default platform data). So drop these duplicated definitions and use default_supplies instead. Also, rename mediatek_mt8183_supplies to a more generic name too (legacy_supplies). Signed-off-by: Louis-Alexis Eyraud Reviewed-by: Steven Price Signed-off-by: Steven Price Link: https://lore.kernel.org/r/20250509-mt8370-enable-gpu-v6-2-2833888cb1d3@collabora.com --- drivers/gpu/drm/panfrost/panfrost_drv.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index 842239b43cdf..8cf1b8089a4b 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -874,19 +874,18 @@ static const struct panfrost_compatible amlogic_data = { * On new devicetrees please use the _b variant with a single and * coupled regulators instead. */ -static const char * const mediatek_mt8183_supplies[] = { "mali", "sram", NULL }; +static const char * const legacy_supplies[] = { "mali", "sram", NULL }; static const char * const mediatek_mt8183_pm_domains[] = { "core0", "core1", "core2" }; static const struct panfrost_compatible mediatek_mt8183_data = { - .num_supplies = ARRAY_SIZE(mediatek_mt8183_supplies) - 1, - .supply_names = mediatek_mt8183_supplies, + .num_supplies = ARRAY_SIZE(legacy_supplies) - 1, + .supply_names = legacy_supplies, .num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains), .pm_domain_names = mediatek_mt8183_pm_domains, }; -static const char * const mediatek_mt8183_b_supplies[] = { "mali", NULL }; static const struct panfrost_compatible mediatek_mt8183_b_data = { - .num_supplies = ARRAY_SIZE(mediatek_mt8183_b_supplies) - 1, - .supply_names = mediatek_mt8183_b_supplies, + .num_supplies = ARRAY_SIZE(default_supplies) - 1, + .supply_names = default_supplies, .num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains), .pm_domain_names = mediatek_mt8183_pm_domains, .pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF), @@ -894,8 +893,8 @@ static const struct panfrost_compatible mediatek_mt8183_b_data = { static const char * const mediatek_mt8186_pm_domains[] = { "core0", "core1" }; static const struct panfrost_compatible mediatek_mt8186_data = { - .num_supplies = ARRAY_SIZE(mediatek_mt8183_b_supplies) - 1, - .supply_names = mediatek_mt8183_b_supplies, + .num_supplies = ARRAY_SIZE(default_supplies) - 1, + .supply_names = default_supplies, .num_pm_domains = ARRAY_SIZE(mediatek_mt8186_pm_domains), .pm_domain_names = mediatek_mt8186_pm_domains, .pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF), @@ -903,20 +902,19 @@ static const struct panfrost_compatible mediatek_mt8186_data = { /* MT8188 uses the same power domains and power supplies as MT8183 */ static const struct panfrost_compatible mediatek_mt8188_data = { - .num_supplies = ARRAY_SIZE(mediatek_mt8183_b_supplies) - 1, - .supply_names = mediatek_mt8183_b_supplies, + .num_supplies = ARRAY_SIZE(default_supplies) - 1, + .supply_names = default_supplies, .num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains), .pm_domain_names = mediatek_mt8183_pm_domains, .pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF), .gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE), }; -static const char * const mediatek_mt8192_supplies[] = { "mali", NULL }; static const char * const mediatek_mt8192_pm_domains[] = { "core0", "core1", "core2", "core3", "core4" }; static const struct panfrost_compatible mediatek_mt8192_data = { - .num_supplies = ARRAY_SIZE(mediatek_mt8192_supplies) - 1, - .supply_names = mediatek_mt8192_supplies, + .num_supplies = ARRAY_SIZE(default_supplies) - 1, + .supply_names = default_supplies, .num_pm_domains = ARRAY_SIZE(mediatek_mt8192_pm_domains), .pm_domain_names = mediatek_mt8192_pm_domains, .pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF), From bd77b870eb190c9cf5d9b7208625513e99e5be2d Mon Sep 17 00:00:00 2001 From: Louis-Alexis Eyraud Date: Fri, 9 May 2025 12:12:49 +0200 Subject: [PATCH 04/11] drm/panfrost: Commonize Mediatek power domain array definitions In the panfrost driver, the platform data of several Mediatek SoC declares and uses several different power domains arrays according to GPU core number present in the SoC: - mediatek_mt8186_pm_domains (2 cores) - mediatek_mt8183_pm_domains (3 cores) - mediatek_mt8192_pm_domains (5 cores) As they all are fixed arrays, starting with the same entries and the platform data also has a power domains array length field (num_pm_domains), they can be replaced by a single array, containing all entries, if the num_pm_domains field of the platform data is also set to the matching core number. So, create a generic power domain array (mediatek_pm_domains) and use it in the mt8183(b), mt8186, mt8188 and mt8192 platform data instead. Signed-off-by: Louis-Alexis Eyraud Reviewed-by: Steven Price Signed-off-by: Steven Price Link: https://lore.kernel.org/r/20250509-mt8370-enable-gpu-v6-3-2833888cb1d3@collabora.com --- drivers/gpu/drm/panfrost/panfrost_drv.c | 27 +++++++++++-------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index 8cf1b8089a4b..642c2a8a75ec 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -866,6 +866,8 @@ static const struct panfrost_compatible amlogic_data = { .vendor_quirk = panfrost_gpu_amlogic_quirk, }; +static const char * const mediatek_pm_domains[] = { "core0", "core1", "core2", + "core3", "core4" }; /* * The old data with two power supplies for MT8183 is here only to * keep retro-compatibility with older devicetrees, as DVFS will @@ -875,48 +877,43 @@ static const struct panfrost_compatible amlogic_data = { * coupled regulators instead. */ static const char * const legacy_supplies[] = { "mali", "sram", NULL }; -static const char * const mediatek_mt8183_pm_domains[] = { "core0", "core1", "core2" }; static const struct panfrost_compatible mediatek_mt8183_data = { .num_supplies = ARRAY_SIZE(legacy_supplies) - 1, .supply_names = legacy_supplies, - .num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains), - .pm_domain_names = mediatek_mt8183_pm_domains, + .num_pm_domains = 3, + .pm_domain_names = mediatek_pm_domains, }; static const struct panfrost_compatible mediatek_mt8183_b_data = { .num_supplies = ARRAY_SIZE(default_supplies) - 1, .supply_names = default_supplies, - .num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains), - .pm_domain_names = mediatek_mt8183_pm_domains, + .num_pm_domains = 3, + .pm_domain_names = mediatek_pm_domains, .pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF), }; -static const char * const mediatek_mt8186_pm_domains[] = { "core0", "core1" }; static const struct panfrost_compatible mediatek_mt8186_data = { .num_supplies = ARRAY_SIZE(default_supplies) - 1, .supply_names = default_supplies, - .num_pm_domains = ARRAY_SIZE(mediatek_mt8186_pm_domains), - .pm_domain_names = mediatek_mt8186_pm_domains, + .num_pm_domains = 2, + .pm_domain_names = mediatek_pm_domains, .pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF), }; -/* MT8188 uses the same power domains and power supplies as MT8183 */ static const struct panfrost_compatible mediatek_mt8188_data = { .num_supplies = ARRAY_SIZE(default_supplies) - 1, .supply_names = default_supplies, - .num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains), - .pm_domain_names = mediatek_mt8183_pm_domains, + .num_pm_domains = 3, + .pm_domain_names = mediatek_pm_domains, .pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF), .gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE), }; -static const char * const mediatek_mt8192_pm_domains[] = { "core0", "core1", "core2", - "core3", "core4" }; static const struct panfrost_compatible mediatek_mt8192_data = { .num_supplies = ARRAY_SIZE(default_supplies) - 1, .supply_names = default_supplies, - .num_pm_domains = ARRAY_SIZE(mediatek_mt8192_pm_domains), - .pm_domain_names = mediatek_mt8192_pm_domains, + .num_pm_domains = 5, + .pm_domain_names = mediatek_pm_domains, .pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF), .gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE), }; From 81645377c231803389ab0f2d09df6622e32dd327 Mon Sep 17 00:00:00 2001 From: Louis-Alexis Eyraud Date: Fri, 9 May 2025 12:12:50 +0200 Subject: [PATCH 05/11] drm/panfrost: Add support for Mali on the MT8370 SoC Add a compatible for the MediaTek MT8370 SoC, with an integrated ARM Mali G57 MC2 GPU (Valhall-JM, dual core), with new platform data for its support in the panfrost driver. It uses the same data as MT8186 for the power management features to describe power supplies, pm_domains and enablement (one regulator, two power domains) but also sets the FORCE_AARCH64_PGTABLE flag in the GPU configuration quirks bitfield to enable AARCH64 4K page table format mode. As MT8186 and MT8370 SoC have different GPU architecture (Mali G52 2EE MC2 for MT8186), making them not compatible, and this mode is only enabled for Mediatek SoC that are Mali G57 based (compatible with mediatek,mali-mt8188 or mediatek,mali-8192), having specific platform data allows to set this flag for MT8370 without modifying MT8186 configuration and behaviour. Reviewed-by: Steven Price Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Louis-Alexis Eyraud Signed-off-by: Steven Price Link: https://lore.kernel.org/r/20250509-mt8370-enable-gpu-v6-4-2833888cb1d3@collabora.com --- drivers/gpu/drm/panfrost/panfrost_drv.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index 642c2a8a75ec..1ea6c509a5d5 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -918,6 +918,15 @@ static const struct panfrost_compatible mediatek_mt8192_data = { .gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE), }; +static const struct panfrost_compatible mediatek_mt8370_data = { + .num_supplies = ARRAY_SIZE(default_supplies) - 1, + .supply_names = default_supplies, + .num_pm_domains = 2, + .pm_domain_names = mediatek_pm_domains, + .pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF), + .gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE), +}; + static const struct of_device_id dt_match[] = { /* Set first to probe before the generic compatibles */ { .compatible = "amlogic,meson-gxm-mali", @@ -940,6 +949,7 @@ static const struct of_device_id dt_match[] = { { .compatible = "mediatek,mt8186-mali", .data = &mediatek_mt8186_data }, { .compatible = "mediatek,mt8188-mali", .data = &mediatek_mt8188_data }, { .compatible = "mediatek,mt8192-mali", .data = &mediatek_mt8192_data }, + { .compatible = "mediatek,mt8370-mali", .data = &mediatek_mt8370_data }, { .compatible = "allwinner,sun50i-h616-mali", .data = &allwinner_h616_data }, {} }; From 3828a643e808b8f2a90f8ba08f68ad3138b1026e Mon Sep 17 00:00:00 2001 From: Louis-Alexis Eyraud Date: Fri, 9 May 2025 12:12:51 +0200 Subject: [PATCH 06/11] arm64: dts: mediatek: mt8370: Enable gpu support Add a new gpu node in mt8370.dtsi to enable support for the ARM Mali G57 MC2 GPU (Valhall-JM) found on the MT8370 SoC, using the Panfrost driver. On a Mediatek Genio 510 EVK board, the panfrost driver probed with the following message: ``` panfrost 13000000.gpu: clock rate = 390000000 panfrost 13000000.gpu: mali-g57 id 0x9093 major 0x0 minor 0x0 status 0x0 panfrost 13000000.gpu: features: 00000000,000019f7, issues: 00000003, 80000400 panfrost 13000000.gpu: Features: L2:0x08130206 Shader:0x00000000 Tiler:0x00000809 Mem:0x1 MMU:0x00002830 AS:0xff JS:0x7 panfrost 13000000.gpu: shader_present=0x5 l2_present=0x1 [drm] Initialized panfrost 1.3.0 for 13000000.gpu on minor 0 ``` Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Louis-Alexis Eyraud Signed-off-by: Steven Price Link: https://lore.kernel.org/r/20250509-mt8370-enable-gpu-v6-5-2833888cb1d3@collabora.com --- arch/arm64/boot/dts/mediatek/mt8370.dtsi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/arm64/boot/dts/mediatek/mt8370.dtsi b/arch/arm64/boot/dts/mediatek/mt8370.dtsi index cf1a3759451f..7ac8b8d03494 100644 --- a/arch/arm64/boot/dts/mediatek/mt8370.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8370.dtsi @@ -59,6 +59,22 @@ <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; }; +/* + * Please note that overriding compatibles is a discouraged practice and is a + * clear indication of nodes not being, well, compatible! + * + * This is a special case, where the GPU is the same as MT8188, but with one + * of the cores fused out in this lower-binned SoC. + */ +&gpu { + compatible = "mediatek,mt8370-mali", "arm,mali-valhall-jm"; + + power-domains = <&spm MT8188_POWER_DOMAIN_MFG2>, + <&spm MT8188_POWER_DOMAIN_MFG3>; + + power-domain-names = "core0", "core1"; +}; + &ppi_cluster0 { affinity = <&cpu0 &cpu1 &cpu2 &cpu3>; }; From a629feabb53b8d714caa8fb9f307517218a5fbcd Mon Sep 17 00:00:00 2001 From: Ryosuke Yasuoka Date: Fri, 13 Jun 2025 22:20:14 +0900 Subject: [PATCH 07/11] drm/bochs: Add support for drm_panic Add drm_panic module for bochs drm so that panic screen can be displayed on panic. Signed-off-by: Ryosuke Yasuoka Reviewed-by: Jocelyn Falempe Link: https://lore.kernel.org/r/20250613132023.106946-1-ryasuoka@redhat.com Signed-off-by: Jocelyn Falempe --- drivers/gpu/drm/tiny/bochs.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c index 8706763af8fb..8d3b7c4fa6a4 100644 --- a/drivers/gpu/drm/tiny/bochs.c +++ b/drivers/gpu/drm/tiny/bochs.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -469,10 +470,28 @@ static void bochs_primary_plane_helper_atomic_update(struct drm_plane *plane, bochs_hw_setformat(bochs, fb->format); } +static int bochs_primary_plane_helper_get_scanout_buffer(struct drm_plane *plane, + struct drm_scanout_buffer *sb) +{ + struct bochs_device *bochs = to_bochs_device(plane->dev); + struct iosys_map map = IOSYS_MAP_INIT_VADDR_IOMEM(bochs->fb_map); + + if (plane->state && plane->state->fb) { + sb->format = plane->state->fb->format; + sb->width = plane->state->fb->width; + sb->height = plane->state->fb->height; + sb->pitch[0] = plane->state->fb->pitches[0]; + sb->map[0] = map; + return 0; + } + return -ENODEV; +} + static const struct drm_plane_helper_funcs bochs_primary_plane_helper_funcs = { DRM_GEM_SHADOW_PLANE_HELPER_FUNCS, .atomic_check = bochs_primary_plane_helper_atomic_check, .atomic_update = bochs_primary_plane_helper_atomic_update, + .get_scanout_buffer = bochs_primary_plane_helper_get_scanout_buffer, }; static const struct drm_plane_funcs bochs_primary_plane_funcs = { From deac70abb12a4a613bbc3ba69aa7377c16cda3d0 Mon Sep 17 00:00:00 2001 From: Vignesh Raman Date: Mon, 23 Jun 2025 14:20:27 +0530 Subject: [PATCH 08/11] drm/ci: Add jobs to validate devicetrees Add jobs to run dt_binding_check and dtbs_check. If warnings are seen, exit with a non-zero error code while configuring them as warning in the GitLab CI pipeline. Signed-off-by: Vignesh Raman Acked-by: Helen Koike Reviewed-by: Maxime Ripard Acked-by: Dmitry Baryshkov Link: https://lore.kernel.org/r/20250623085033.39680-2-vignesh.raman@collabora.com Signed-off-by: Maxime Ripard --- drivers/gpu/drm/ci/check-devicetrees.yml | 50 ++++++++++++++++++++++++ drivers/gpu/drm/ci/dt-binding-check.sh | 19 +++++++++ drivers/gpu/drm/ci/dtbs-check.sh | 22 +++++++++++ drivers/gpu/drm/ci/gitlab-ci.yml | 2 + drivers/gpu/drm/ci/setup-llvm-links.sh | 13 ++++++ 5 files changed, 106 insertions(+) create mode 100644 drivers/gpu/drm/ci/check-devicetrees.yml create mode 100755 drivers/gpu/drm/ci/dt-binding-check.sh create mode 100755 drivers/gpu/drm/ci/dtbs-check.sh create mode 100755 drivers/gpu/drm/ci/setup-llvm-links.sh diff --git a/drivers/gpu/drm/ci/check-devicetrees.yml b/drivers/gpu/drm/ci/check-devicetrees.yml new file mode 100644 index 000000000000..727bd56018b8 --- /dev/null +++ b/drivers/gpu/drm/ci/check-devicetrees.yml @@ -0,0 +1,50 @@ +.dt-check-base: + stage: static-checks + timeout: "30m" + variables: + GIT_DEPTH: 1 + FF_USE_NEW_BASH_EVAL_STRATEGY: 'true' + SCHEMA: "display:gpu" + VENV_PATH: "/tmp/dtcheck-venv" + before_script: + - apt-get update -qq + # Minimum supported version of LLVM for building x86 kernels is 15.0.0. + # In mesa-ci containers, LLVM_VERSION is defined as a container-level property and is currently set to 19. + - apt-get install -y --no-install-recommends clang-${LLVM_VERSION} lld-${LLVM_VERSION} llvm-${LLVM_VERSION} python3-dev python3-venv python3-pip yamllint + - python3 -m venv "${VENV_PATH}" + - source "${VENV_PATH}/bin/activate" + - pip3 install dtschema + script: + - drivers/gpu/drm/ci/${SCRIPT_NAME} + artifacts: + when: on_failure + paths: + - ${ARTIFACT_FILE} + allow_failure: + exit_codes: + - 102 + +dtbs-check:arm32: + extends: + - .build:arm32 + - .dt-check-base + variables: + SCRIPT_NAME: "dtbs-check.sh" + ARTIFACT_FILE: "dtbs-check.log" + +dtbs-check:arm64: + extends: + - .build:arm64 + - .dt-check-base + variables: + SCRIPT_NAME: "dtbs-check.sh" + ARTIFACT_FILE: "dtbs-check.log" + +dt-binding-check: + extends: + - .build + - .use-debian/x86_64_build + - .dt-check-base + variables: + SCRIPT_NAME: "dt-binding-check.sh" + ARTIFACT_FILE: "dt-binding-check.log" diff --git a/drivers/gpu/drm/ci/dt-binding-check.sh b/drivers/gpu/drm/ci/dt-binding-check.sh new file mode 100755 index 000000000000..99e1c0df84b7 --- /dev/null +++ b/drivers/gpu/drm/ci/dt-binding-check.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT + +set -euxo pipefail + +VENV_PATH="${VENV_PATH:-/tmp/dtschema-venv}" +source "${VENV_PATH}/bin/activate" + +if ! make -j"${FDO_CI_CONCURRENT:-4}" dt_binding_check \ + DT_SCHEMA_FILES="${SCHEMA:-}" 2>dt-binding-check.log; then + echo "ERROR: 'make dt_binding_check' failed. Please check dt-binding-check.log for details." + exit 1 +fi + +if [[ -s dt-binding-check.log ]]; then + echo "WARNING: dt_binding_check reported warnings. Please check dt-binding-check.log" \ + "for details." + exit 102 +fi diff --git a/drivers/gpu/drm/ci/dtbs-check.sh b/drivers/gpu/drm/ci/dtbs-check.sh new file mode 100755 index 000000000000..57842c452439 --- /dev/null +++ b/drivers/gpu/drm/ci/dtbs-check.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT + +set -euxo pipefail + +: "${KERNEL_ARCH:?ERROR: KERNEL_ARCH must be set}" +: "${LLVM_VERSION:?ERROR: LLVM_VERSION must be set}" + +./drivers/gpu/drm/ci/setup-llvm-links.sh + +make LLVM=1 ARCH="${KERNEL_ARCH}" defconfig + +if ! make -j"${FDO_CI_CONCURRENT:-4}" ARCH="${KERNEL_ARCH}" LLVM=1 dtbs_check \ + DT_SCHEMA_FILES="${SCHEMA:-}" 2>dtbs-check.log; then + echo "ERROR: 'make dtbs_check' failed. Please check dtbs-check.log for details." + exit 1 +fi + +if [[ -s dtbs-check.log ]]; then + echo "WARNING: dtbs_check reported warnings. Please check dtbs-check.log for details." + exit 102 +fi diff --git a/drivers/gpu/drm/ci/gitlab-ci.yml b/drivers/gpu/drm/ci/gitlab-ci.yml index ba75b3a7eca4..1be757c0c530 100644 --- a/drivers/gpu/drm/ci/gitlab-ci.yml +++ b/drivers/gpu/drm/ci/gitlab-ci.yml @@ -110,6 +110,7 @@ include: - drivers/gpu/drm/ci/static-checks.yml - drivers/gpu/drm/ci/build.yml - drivers/gpu/drm/ci/test.yml + - drivers/gpu/drm/ci/check-devicetrees.yml - 'https://gitlab.freedesktop.org/gfx-ci/lab-status/-/raw/main/lab-status.yml' @@ -119,6 +120,7 @@ stages: - git-archive - build-for-tests - build-only + - static-checks - code-validation - amdgpu - i915 diff --git a/drivers/gpu/drm/ci/setup-llvm-links.sh b/drivers/gpu/drm/ci/setup-llvm-links.sh new file mode 100755 index 000000000000..ace33af82a3f --- /dev/null +++ b/drivers/gpu/drm/ci/setup-llvm-links.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MIT +set -euo pipefail + +ln -svf "$(which clang++-${LLVM_VERSION})" /usr/bin/clang++ +ln -svf "$(which clang-${LLVM_VERSION})" /usr/bin/clang +ln -svf "$(which ld.lld-${LLVM_VERSION})" /usr/bin/ld.lld +ln -svf "$(which lld-${LLVM_VERSION})" /usr/bin/lld +ln -svf "$(which llvm-ar-${LLVM_VERSION})" /usr/bin/llvm-ar +ln -svf "$(which llvm-nm-${LLVM_VERSION})" /usr/bin/llvm-nm +ln -svf "$(which llvm-objcopy-${LLVM_VERSION})" /usr/bin/llvm-objcopy +ln -svf "$(which llvm-readelf-${LLVM_VERSION})" /usr/bin/llvm-readelf +ln -svf "$(which llvm-strip-${LLVM_VERSION})" /usr/bin/llvm-strip From 786bd08c0055a133cbafa5f2c044433849906c1d Mon Sep 17 00:00:00 2001 From: Vignesh Raman Date: Mon, 23 Jun 2025 14:20:28 +0530 Subject: [PATCH 09/11] drm/ci: Add jobs to run KUnit tests Add jobs to run KUnit tests using tools/testing/kunit/kunit.py tool. Signed-off-by: Vignesh Raman Acked-by: Helen Koike Reviewed-by: Maxime Ripard Link: https://lore.kernel.org/r/20250623085033.39680-3-vignesh.raman@collabora.com Signed-off-by: Maxime Ripard --- drivers/gpu/drm/ci/gitlab-ci.yml | 2 ++ drivers/gpu/drm/ci/kunit.sh | 16 ++++++++++++++ drivers/gpu/drm/ci/kunit.yml | 37 ++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100755 drivers/gpu/drm/ci/kunit.sh create mode 100644 drivers/gpu/drm/ci/kunit.yml diff --git a/drivers/gpu/drm/ci/gitlab-ci.yml b/drivers/gpu/drm/ci/gitlab-ci.yml index 1be757c0c530..9a32cd736f2f 100644 --- a/drivers/gpu/drm/ci/gitlab-ci.yml +++ b/drivers/gpu/drm/ci/gitlab-ci.yml @@ -111,6 +111,7 @@ include: - drivers/gpu/drm/ci/build.yml - drivers/gpu/drm/ci/test.yml - drivers/gpu/drm/ci/check-devicetrees.yml + - drivers/gpu/drm/ci/kunit.yml - 'https://gitlab.freedesktop.org/gfx-ci/lab-status/-/raw/main/lab-status.yml' @@ -121,6 +122,7 @@ stages: - build-for-tests - build-only - static-checks + - kunit - code-validation - amdgpu - i915 diff --git a/drivers/gpu/drm/ci/kunit.sh b/drivers/gpu/drm/ci/kunit.sh new file mode 100755 index 000000000000..7a1052fd3f17 --- /dev/null +++ b/drivers/gpu/drm/ci/kunit.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT + +set -euxo pipefail + +: "${KERNEL_ARCH:?ERROR: KERNEL_ARCH must be set}" +: "${LLVM_VERSION:?ERROR: LLVM_VERSION must be set}" + +./drivers/gpu/drm/ci/setup-llvm-links.sh + +export PATH="/usr/bin:$PATH" + +./tools/testing/kunit/kunit.py run \ + --arch "${KERNEL_ARCH}" \ + --make_options LLVM=1 \ + --kunitconfig=drivers/gpu/drm/tests diff --git a/drivers/gpu/drm/ci/kunit.yml b/drivers/gpu/drm/ci/kunit.yml new file mode 100644 index 000000000000..0d5b2c4433d2 --- /dev/null +++ b/drivers/gpu/drm/ci/kunit.yml @@ -0,0 +1,37 @@ +.kunit-packages: &kunit-packages + - apt-get update -qq + # Minimum supported version of LLVM for building x86 kernels is 15.0.0. + # In mesa-ci containers, LLVM_VERSION is defined as a container-level property and is currently set to 19. + - apt-get install -y --no-install-recommends clang-${LLVM_VERSION} lld-${LLVM_VERSION} llvm-${LLVM_VERSION} + +.kunit-base: + stage: kunit + timeout: "30m" + variables: + GIT_DEPTH: 1 + script: + - drivers/gpu/drm/ci/kunit.sh + +kunit:arm32: + extends: + - .build:arm32 + - .kunit-base + before_script: + - *kunit-packages + - apt-get install -y --no-install-recommends qemu-system-arm + +kunit:arm64: + extends: + - .build:arm64 + - .kunit-base + before_script: + - *kunit-packages + - apt-get install -y --no-install-recommends qemu-system-aarch64 + +kunit:x86_64: + extends: + - .build:x86_64 + - .kunit-base + before_script: + - *kunit-packages + - apt-get install -y --no-install-recommends qemu-system-x86 From 1174bf15bd601f17556f721798cd9183e169549a Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Mon, 19 May 2025 14:29:00 +0300 Subject: [PATCH 10/11] drm/connector: move HDR sink metadata to display info Information parsed from the display EDID should be stored in display info. Move HDR sink metadata there. Reviewed-by: Dmitry Baryshkov Link: https://lore.kernel.org/r/20250519112900.1383997-1-jani.nikula@intel.com Signed-off-by: Jani Nikula --- drivers/gpu/drm/display/drm_hdmi_helper.c | 2 +- drivers/gpu/drm/drm_connector.c | 2 +- drivers/gpu/drm/drm_edid.c | 19 ++++++++++--------- .../drm/i915/display/intel_dp_aux_backlight.c | 2 +- include/drm/drm_connector.h | 8 +++++--- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/display/drm_hdmi_helper.c b/drivers/gpu/drm/display/drm_hdmi_helper.c index 6063c155bdea..a237dc55805d 100644 --- a/drivers/gpu/drm/display/drm_hdmi_helper.c +++ b/drivers/gpu/drm/display/drm_hdmi_helper.c @@ -45,7 +45,7 @@ int drm_hdmi_infoframe_set_hdr_metadata(struct hdmi_drm_infoframe *frame, /* Sink EOTF is Bit map while infoframe is absolute values */ if (!is_eotf_supported(hdr_metadata->hdmi_metadata_type1.eotf, - connector->hdr_sink_metadata.hdmi_type1.eotf)) + connector->display_info.hdr_sink_metadata.hdmi_type1.eotf)) DRM_DEBUG_KMS("Unknown EOTF %d\n", hdr_metadata->hdmi_metadata_type1.eotf); err = hdmi_drm_infoframe_init(frame); diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 0167e0e0d425..272d6254ea47 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -1687,7 +1687,7 @@ EXPORT_SYMBOL(drm_hdmi_connector_get_output_format_name); * structure from userspace. This is received as blob and stored in * &drm_connector_state.hdr_output_metadata. It parses EDID and saves the * sink metadata in &struct hdr_sink_metadata, as - * &drm_connector.hdr_sink_metadata. Driver uses + * &drm_connector.display_info.hdr_sink_metadata. Driver uses * drm_hdmi_infoframe_set_hdr_metadata() helper to set the HDR metadata, * hdmi_drm_infoframe_pack() to pack the infoframe as per spec, in case of * HDMI encoder. diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 4b4f27896161..c21b5e570013 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -5374,7 +5374,8 @@ static void fixup_detailed_cea_mode_clock(struct drm_connector *connector, static void drm_calculate_luminance_range(struct drm_connector *connector) { - struct hdr_static_metadata *hdr_metadata = &connector->hdr_sink_metadata.hdmi_type1; + const struct hdr_static_metadata *hdr_metadata = + &connector->display_info.hdr_sink_metadata.hdmi_type1; struct drm_luminance_range_info *luminance_range = &connector->display_info.luminance_range; static const u8 pre_computed_values[] = { @@ -5435,21 +5436,21 @@ static uint8_t hdr_metadata_type(const u8 *edid_ext) static void drm_parse_hdr_metadata_block(struct drm_connector *connector, const u8 *db) { + struct hdr_static_metadata *hdr_metadata = + &connector->display_info.hdr_sink_metadata.hdmi_type1; u16 len; len = cea_db_payload_len(db); - connector->hdr_sink_metadata.hdmi_type1.eotf = - eotf_supported(db); - connector->hdr_sink_metadata.hdmi_type1.metadata_type = - hdr_metadata_type(db); + hdr_metadata->eotf = eotf_supported(db); + hdr_metadata->metadata_type = hdr_metadata_type(db); if (len >= 4) - connector->hdr_sink_metadata.hdmi_type1.max_cll = db[4]; + hdr_metadata->max_cll = db[4]; if (len >= 5) - connector->hdr_sink_metadata.hdmi_type1.max_fall = db[5]; + hdr_metadata->max_fall = db[5]; if (len >= 6) { - connector->hdr_sink_metadata.hdmi_type1.min_cll = db[6]; + hdr_metadata->min_cll = db[6]; /* Calculate only when all values are available */ drm_calculate_luminance_range(connector); @@ -6597,7 +6598,7 @@ static void drm_reset_display_info(struct drm_connector *connector) info->has_hdmi_infoframe = false; info->rgb_quant_range_selectable = false; memset(&info->hdmi, 0, sizeof(info->hdmi)); - memset(&connector->hdr_sink_metadata, 0, sizeof(connector->hdr_sink_metadata)); + memset(&info->hdr_sink_metadata, 0, sizeof(info->hdr_sink_metadata)); info->edid_hdmi_rgb444_dc_modes = 0; info->edid_hdmi_ycbcr444_dc_modes = 0; diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c index 271b27c9de51..5537136c367a 100644 --- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c +++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c @@ -145,7 +145,7 @@ intel_dp_aux_supports_hdr_backlight(struct intel_connector *connector) * ranges for such panels. */ if (display->params.enable_dpcd_backlight != INTEL_DP_AUX_BACKLIGHT_FORCE_INTEL && - !(connector->base.hdr_sink_metadata.hdmi_type1.metadata_type & + !(connector->base.display_info.hdr_sink_metadata.hdmi_type1.metadata_type & BIT(HDMI_STATIC_METADATA_TYPE1))) { drm_info(display->drm, "[CONNECTOR:%d:%s] Panel is missing HDR static metadata. Possible support for Intel HDR backlight interface is not used. If your backlight controls don't work try booting with i915.enable_dpcd_backlight=%d.\n", diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 73903c3c842f..9fdc4581dd90 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -799,6 +799,11 @@ struct drm_display_info { */ struct drm_hdmi_info hdmi; + /** + * @hdr_sink_metadata: HDR Metadata Information read from sink + */ + struct hdr_sink_metadata hdr_sink_metadata; + /** * @non_desktop: Non desktop display (HMD). */ @@ -2284,9 +2289,6 @@ struct drm_connector { */ struct llist_node free_node; - /** @hdr_sink_metadata: HDR Metadata Information read from sink */ - struct hdr_sink_metadata hdr_sink_metadata; - /** * @hdmi: HDMI-related variable and properties. */ From d6b93bfa5d1eba452e494d3a05d6bef65bc569b7 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 9 Apr 2025 13:33:44 +0300 Subject: [PATCH 11/11] drm/nouveau/disp: Use dev->dev to get the device The local variable dev points to drm->dev already, use dev directly. Link: https://lore.kernel.org/r/20250409103344.3661603-1-sakari.ailus@linux.intel.com Signed-off-by: Sakari Ailus Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/nouveau/nouveau_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c index add006fc8d81..c50ec347b30a 100644 --- a/drivers/gpu/drm/nouveau/nouveau_display.c +++ b/drivers/gpu/drm/nouveau/nouveau_display.c @@ -495,7 +495,7 @@ nouveau_display_hpd_work(struct work_struct *work) if (first_changed_connector) drm_connector_put(first_changed_connector); - pm_runtime_mark_last_busy(drm->dev->dev); + pm_runtime_mark_last_busy(dev->dev); noop: pm_runtime_put_autosuspend(dev->dev); }