AMD General
Why not just do
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
@@ -45,7 +45,7 @@
clk_src->base.ctx
#define DC_LOGGER \
- calc_pll_cs->ctx->logger
+ clk_src->base.ctx->logger or CTX->logger
clk_src is available everywhere right after dce110_clk_src_construct()
Bhawan
________________________________
From: Jiri Slaby (SUSE) <[email protected]>
Sent: July 22, 2026 2:32 AM
To: Deucher, Alexander <[email protected]>
Cc: [email protected] <[email protected]>; Jiri Slaby
(SUSE) <[email protected]>; Lakha, Bhawanpreet <[email protected]>;
Wentland, Harry <[email protected]>; Li, Sun peng (Leo)
<[email protected]>; Rodrigo Siqueira <[email protected]>; Koenig, Christian
<[email protected]>; David Airlie <[email protected]>; Simona Vetter
<[email protected]>; [email protected]
<[email protected]>; [email protected]
<[email protected]>
Subject: [PATCH] drm/amd/display: use proper context for logging
The same as the rest of the code, get_ss_info_from_atombios() uses
calc_pll_cs->ctx->logger for logging. But calc_pll_cs->ctx is
initialized only later in calc_pll_max_vco_construct(). Therefore, any
output using DC_LOG_SYNC() leads to a NULL pointer deference in
get_ss_info_from_atombios().
To avoid accessing the NULL context, use clk_src->base.ctx->logger
in get_ss_info_from_atombios(). That context is initialized earlier in
dce110_clk_src_construct() -- before get_ss_info_from_atombios() is
actually called. This is done by temporarily redefining DC_LOGGER to
CTX->logger.
Before:
dce110_clk_src_construct() did:
-> sets clk_src->base.ctx = ctx;
-> ss_info_from_atombios_create()
-> get_ss_info_from_atombios() <- uses calc_pll_cs->ctx # BOOM
-> calc_pll_max_vco_construct() <- sets calc_pll_cs->ctx
After:
dce110_clk_src_construct() does:
-> sets clk_src->base.ctx = ctx;
-> ss_info_from_atombios_create()
-> get_ss_info_from_atombios() <- uses clk_src->base.ctx
Closes: https://bugzilla.suse.com/show_bug.cgi?id=1271175
Closes:
https://lore.kernel.org/all/[email protected]/
Fixes: 1296423bf23c ("drm/amd/display: define DC_LOGGER for logger")
Signed-off-by: Jiri Slaby (SUSE) <[email protected]>
Cc: Lakha, Bhawanpreet <[email protected]>
Cc: Harry Wentland <[email protected]>
Cc: Leo Li <[email protected]>
Cc: Rodrigo Siqueira <[email protected]>
Cc: Alex Deucher <[email protected]>
Cc: "Christian König" <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: [email protected]
---
Cc: [email protected]
---
drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
index ecb8493ec523..d3f7aa853e3a 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
@@ -1513,6 +1513,10 @@ static const struct clock_source_funcs
dce110_clk_src_funcs = {
.get_dp_dto_frequency_100hz = get_dp_dto_frequency_100hz
};
+/* calc_pll_cs->ctx is set only after get_ss_info_from_atombios(), unlike
clk_src->base */
+#pragma push_macro("DC_LOGGER")
+#undef DC_LOGGER
+#define DC_LOGGER CTX->logger
static void get_ss_info_from_atombios(
struct dce110_clk_src *clk_src,
@@ -1526,7 +1530,7 @@ static void get_ss_info_from_atombios(
struct spread_spectrum_info *ss_info_cur;
struct spread_spectrum_data *ss_data_cur;
uint32_t i;
- DC_LOGGER_INIT();
+
if (ss_entries_num == NULL) {
DC_LOG_SYNC(
"Invalid entry !!!\n");
@@ -1631,6 +1635,8 @@ static void get_ss_info_from_atombios(
kfree(ss_info);
}
+#pragma pop_macro("DC_LOGGER")
+
static void ss_info_from_atombios_create(
struct dce110_clk_src *clk_src)
{
--
2.55.0