From 21090e23f5fea8ec1bf89c1dbc3e3255e2e0f817 Mon Sep 17 00:00:00 2001 From: Yash Gupta Date: Mon, 24 Aug 2026 13:47:00 +0530 Subject: [PATCH] disp: msm: compat: add kernel 7.2 backward-compatibility shims Kernel 7.2 introduced several breaking API changes that prevent sde-dlkm from compiling. Add a new compat header include/linux/msm_drm_compat.h that centralises all version-guarded shims, and include it at the affected call sites. All shims are gated on LINUX_VERSION_CODE >= KERNEL_VERSION(7, 2, 0) so there is no functional change on kernel < 7.2. Changes covered: 1. struct drm_atomic_state renamed to struct drm_atomic_commit. All associated APIs renamed accordingly: drm_atomic_state_init/get/put/alloc/clear drm_atomic_state_default_clear/default_release Fix: #define aliases mapping old names to new names. Include compat header in msm_drv.h so all TUs pick it up. 2. drm_atomic_private_obj_init() dropped its initial state argument. Fix: inline wrapper absorbs the removed argument without touching call sites. 3. drm_private_state_funcs gained atomic_create_state callback. Fix: dp_mst_drm.c adds the callback under a version guard. 4. thermal_of_cooling_device_register() gained a new u32 cdev_id argument as its 2nd parameter. Fix: inline wrapper accepts the old 4-arg form and forwards to the new 5-arg API with cdev_id=0 (preserving legacy behaviour). Inline is defined before the #define to avoid macro recursion. Include compat header in msm_cooling_device.c. 5. drm_panel_init() made static/unexported. sde-dlkm kzalloc-s a bare drm_panel and calls drm_panel_init(). Fix: inline __msm_drm_panel_init_compat() replicates the last exported body (INIT_LIST_HEAD list/followers, mutex_init, field assignments), shadowed by a #define at call sites. 6. qcom_clk_set_flags() and CLKFLAG_RETAIN_MEM/CLKFLAG_NORETAIN_MEM removed from . The header still exists with a different API so the __has_include guard in sde_power_handle.c passes, but the symbol is no longer declared or exported. Fix: no-op stubs in compat header; the retain-mem hint is advisory only and safe to elide. Include compat header in sde_power_handle.c. Signed-off-by: Yash Gupta --- include/linux/msm_drm_compat.h | 114 +++++++++++++++++++++++++++++++++ msm/dp/dp_mst_drm.c | 19 ++++++ msm/msm_cooling_device.c | 1 + msm/msm_drv.h | 1 + msm/sde_power_handle.c | 1 + 5 files changed, 136 insertions(+) create mode 100755 include/linux/msm_drm_compat.h diff --git a/include/linux/msm_drm_compat.h b/include/linux/msm_drm_compat.h new file mode 100755 index 0000000..4fce577 --- /dev/null +++ b/include/linux/msm_drm_compat.h @@ -0,0 +1,114 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * + * Backward-compatibility shims for sde-dlkm across kernel versions. + * + * Kernel 7.2 (v7.2-rc1, commit 5164f7e7ff8e): + * - struct drm_atomic_state renamed to struct drm_atomic_commit + * - drm_atomic_state_init/get/put/default_clear/default_release/clear renamed + * - drm_atomic_private_obj_init() state argument removed + * - drm_private_state_funcs gained atomic_create_state callback + * - thermal_of_cooling_device_register() gained u32 cdev_id as 2nd arg + * - drm_panel_init() made static / unexported (commit fe417df954a9) + * - qcom_clk_set_flags() / CLKFLAG_RETAIN_MEM removed from + */ + +#ifndef __MSM_DRM_COMPAT_H__ +#define __MSM_DRM_COMPAT_H__ + +#include + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(7, 2, 0)) + +/* + * struct drm_atomic_state was renamed to struct drm_atomic_commit in 7.2. + * We cannot use a simple #define because it would also mangle + * "drm_atomic_state_helper" in include paths and identifiers. + */ +#define drm_atomic_state drm_atomic_commit + +/* Function renames: drm_atomic_state_* -> drm_atomic_commit_* */ +#define drm_atomic_state_init drm_atomic_commit_init +#define drm_atomic_state_default_clear drm_atomic_commit_default_clear +#define drm_atomic_state_default_release drm_atomic_commit_default_release +#define drm_atomic_state_get drm_atomic_commit_get +#define drm_atomic_state_put drm_atomic_commit_put +#define drm_atomic_state_alloc drm_atomic_commit_alloc +#define drm_atomic_state_clear drm_atomic_commit_clear + +/* + * drm_atomic_private_obj_init() dropped its initial state argument in 7.2 + * (commit 3590a52f0d09). Wrap the 4-arg call form used in sde-dlkm so it + * compiles on both kernels without touching the call sites. + */ +#include +static inline int +__msm_atomic_private_obj_init_compat(struct drm_device *dev, + struct drm_private_obj *obj, + struct drm_private_state *state, + const struct drm_private_state_funcs *funcs) +{ + return drm_atomic_private_obj_init(dev, obj, funcs); +} +#define drm_atomic_private_obj_init(dev, obj, state, funcs) \ + __msm_atomic_private_obj_init_compat(dev, obj, state, funcs) + +/* + * thermal_of_cooling_device_register() gained a new u32 cdev_id argument + * as its 2nd parameter in kernel 7.2. The inline helper is defined before + * the #define so its body sees the real 5-arg prototype, not the macro. + */ +#include +static inline struct thermal_cooling_device * +__msm_thermal_of_cdev_register_compat(struct device_node *np, + const char *type, void *data, + const struct thermal_cooling_device_ops *ops) +{ + /* cdev_id=0 preserves the legacy single-device-per-node behaviour */ + return thermal_of_cooling_device_register(np, 0, type, data, ops); +} +/* Now shadow the 4-arg call sites — the inline above is already resolved */ +#define thermal_of_cooling_device_register(np, type, data, ops) \ + __msm_thermal_of_cdev_register_compat(np, type, data, ops) + +/* + * drm_panel_init() was made static / unexported in 7.2 (commit fe417df954a9). + * Provide an equivalent open-coded initialiser so sde-dlkm call sites that + * kzalloc a bare drm_panel and call drm_panel_init() continue to work. + * The body mirrors the last exported implementation exactly. + */ +#include +static inline void +__msm_drm_panel_init_compat(struct drm_panel *panel, struct device *dev, + const struct drm_panel_funcs *funcs, + int connector_type) +{ + INIT_LIST_HEAD(&panel->list); + INIT_LIST_HEAD(&panel->followers); + mutex_init(&panel->follower_lock); + panel->dev = dev; + panel->funcs = funcs; + panel->connector_type = connector_type; +} +#define drm_panel_init(panel, dev, funcs, connector_type) \ + __msm_drm_panel_init_compat(panel, dev, funcs, connector_type) + +/* + * qcom_clk_set_flags() and CLKFLAG_RETAIN_MEM/CLKFLAG_NORETAIN_MEM were + * removed from in 7.2. The call site in sde_power_handle.c + * is already guarded by __has_include() which now resolves to the + * new header that no longer declares these symbols. Provide no-op stubs so the + * guarded code compiles and links cleanly; the retain-mem hint is advisory only. + */ +#include +#define CLKFLAG_RETAIN_MEM 0 +#define CLKFLAG_NORETAIN_MEM 0 +static inline int qcom_clk_set_flags(struct clk *clk, unsigned long flags) +{ + return 0; +} + +#endif /* LINUX_VERSION_CODE >= 7.2.0 */ + +#endif /* __MSM_DRM_COMPAT_H__ */ diff --git a/msm/dp/dp_mst_drm.c b/msm/dp/dp_mst_drm.c index 785042a..08e4d4a 100644 --- a/msm/dp/dp_mst_drm.c +++ b/msm/dp/dp_mst_drm.c @@ -214,7 +214,26 @@ static void dp_mst_destroy_bridge_state(struct drm_private_obj *obj, kfree(priv_state); } +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(7, 2, 0)) +static struct drm_private_state *dp_mst_create_bridge_state( + struct drm_private_obj *obj) +{ + struct dp_mst_bridge_state *state; + + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return ERR_PTR(-ENOMEM); + + __drm_atomic_helper_private_obj_create_state(obj, &state->base); + + return &state->base; +} +#endif + static const struct drm_private_state_funcs dp_mst_bridge_state_funcs = { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(7, 2, 0)) + .atomic_create_state = dp_mst_create_bridge_state, +#endif .atomic_duplicate_state = dp_mst_duplicate_bridge_state, .atomic_destroy_state = dp_mst_destroy_bridge_state, }; diff --git a/msm/msm_cooling_device.c b/msm/msm_cooling_device.c index c2cc26e..348f5cf 100644 --- a/msm/msm_cooling_device.c +++ b/msm/msm_cooling_device.c @@ -5,6 +5,7 @@ #include #include #include "msm_cooling_device.h" +#include #define BRIGHTNESS_CDEV_MAX 255 diff --git a/msm/msm_drv.h b/msm/msm_drv.h index 58a2e01..792f7a7 100644 --- a/msm/msm_drv.h +++ b/msm/msm_drv.h @@ -43,6 +43,7 @@ #include #include +#include #include #include #include diff --git a/msm/sde_power_handle.c b/msm/sde_power_handle.c index 80c812d..3ecaf54 100644 --- a/msm/sde_power_handle.c +++ b/msm/sde_power_handle.c @@ -32,6 +32,7 @@ #include #endif /* CONFIG_QTI_HW_FENCE */ +#include #include "sde_power_handle.h" #include "sde_trace.h" #include "sde_dbg.h"