From nobody Fri Jul 24 05:21:28 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 175A53515E8 for ; Thu, 23 Jul 2026 04:26:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784780784; cv=none; b=HPaLXt5Qp/81fqIxei7tFbR3omTUNNKIbKpWktP+qpWcuyXAV26sHOIXYBjNldNplfbdRos9CX0LGzRhyhjDCLkJg8Ki/NLe5c2E3U50NFCInFHYngKX1Nu8NE6PG+pZaCobTovX43lndccGAa0yC3iYphhsBJOLHr7t9Oagcyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784780784; c=relaxed/simple; bh=iBrN6R0mSI6WzBRChlu7YVtgokVRezFAYdvI7SLnpPA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=kRo//iSCzhV1fHg0/UKmCBW/uDF3OvQO9FK0Xm5vvmJkqxq4bH2Tp+sJKApt6gMny9fh3wnYGnALqTnVpmlLq3iJv0BCnSYBvdPCZKIMryZybJRq2jrDNKDUGv9SUgai9j8rd52qWsZ9wwCAjItHdWjFq1Wyw59x54yQVsptyps= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hIkpad+Q; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hIkpad+Q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B75171F000E9; Thu, 23 Jul 2026 04:25:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784780753; bh=XOAiBQVsKE+a+mmnQ5qruWwz3JayhWyzQU7FibWfMRY=; h=From:To:Cc:Subject:Date; b=hIkpad+QEoEj5yIDC7JoO0ilqCJQJu/7GlUBYpWlx3/6TFH9CtJh7FY7aFKxj1m/d SogHWhgNB02Ie1uGA6E9DF63oyM2PaViWdRdyda95uB7yxqT2aIgChJp6P8Xnwj6E4 S4oTUP/mW+0uF+Y5eTRs3dLfD45W8XChrwW7e5HtlyOOR4xyLf1+LlgfKqiB5IqzqS n88SZihMAvbyL9wbE2gef8uVQoFQmgu5oFIdnvbe81/8hXdWTHvAcvm1IxZXLYKCdD u7ybbYcqiQ2w2IzhCyfKvSI7wtQMbS6trxJiphYyZCE8lwNhBecg0aytzn8V+dwWU9 66fbmV4gjdI8g== From: "Jiri Slaby (SUSE)" To: alexander.deucher@amd.com Cc: linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , "Lakha, Bhawanpreet" , Harry Wentland , Leo Li , Rodrigo Siqueira , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Airlie , Simona Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm/amd/display: use proper context for logging Date: Thu, 23 Jul 2026 06:25:48 +0200 Message-ID: <20260723042548.1225691-1-jirislaby@kernel.org> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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(). According to Sashiko, the very same problem exists in dce112_get_pix_clk_dividers() and dcn3_get_pix_clk_dividers() too. To avoid accessing the NULL context, use clk_src->base.ctx->logger everywhere. That context in base is initialized earlier in dce110_clk_src_construct() and dce112_clk_src_construct(). Before get_ss_info_from_atombios() or Sashiko's get_pix_clk_dividers functions above are actually called. This is done by redefining DC_LOGGER to CTX->logger. Before: dce110_clk_src_construct() did: -> sets clk_src->base.ctx =3D 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 =3D 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=3D1271175 Closes: https://lore.kernel.org/all/a9ee54e6-2413-4156-9bde-d528ae3c63a3@ke= rnel.org/ Fixes: 1296423bf23c ("drm/amd/display: define DC_LOGGER for logger") Signed-off-by: Jiri Slaby (SUSE) Cc: Lakha, Bhawanpreet Cc: Harry Wentland Cc: Leo Li Cc: Rodrigo Siqueira Cc: Alex Deucher Cc: "Christian K=C3=B6nig" Cc: David Airlie Cc: Simona Vetter Cc: amd-gfx@lists.freedesktop.org --- Cc: dri-devel@lists.freedesktop.org [v2] Set DC_LOGGER to CTX->logger unconditionally (Bhawanpreet). [v1] https://lore.kernel.org/all/20260722063210.1144266-1-jirislaby@kernel.= org/ --- .../drm/amd/display/dc/dce/dce_clock_source.c | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c b/driver= s/gpu/drm/amd/display/dc/dce/dce_clock_source.c index ecb8493ec523..8e3862f6dac2 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 @@ -45,9 +45,7 @@ clk_src->base.ctx =20 #define DC_LOGGER \ - calc_pll_cs->ctx->logger -#define DC_LOGGER_INIT() \ - struct calc_pll_clock_source *calc_pll_cs =3D &clk_src->calc_pll + CTX->logger =20 #undef FN #define FN(reg_name, field_name) \ @@ -287,6 +285,7 @@ static bool calc_pll_dividers_in_range( } =20 static uint32_t calculate_pixel_clock_pll_dividers( + struct dce110_clk_src *clk_src, struct calc_pll_clock_source *calc_pll_cs, struct pll_settings *pll_settings) { @@ -474,7 +473,7 @@ static uint32_t dce110_get_pix_clk_dividers_helper ( { uint32_t field =3D 0; uint32_t pll_calc_error =3D MAX_PLL_CALC_ERROR; - DC_LOGGER_INIT(); + /* Check if reference clock is external (not pcie/xtalin) * HW Dce80 spec: * 00 - PCIE_REFCLK, 01 - XTALIN, 02 - GENERICA, 03 - GENERICB @@ -517,12 +516,14 @@ static uint32_t dce110_get_pix_clk_dividers_helper ( /*Calculate Dividers by HDMI object, no SS case or SS case */ pll_calc_error =3D calculate_pixel_clock_pll_dividers( + clk_src, &clk_src->calc_pll_hdmi, pll_settings); else /*Calculate Dividers by default object, no SS case or SS case */ pll_calc_error =3D calculate_pixel_clock_pll_dividers( + clk_src, &clk_src->calc_pll, pll_settings); =20 @@ -568,7 +569,6 @@ static uint32_t dce110_get_pix_clk_dividers( { struct dce110_clk_src *clk_src =3D TO_DCE110_CLK_SRC(cs); uint32_t pll_calc_error =3D MAX_PLL_CALC_ERROR; - DC_LOGGER_INIT(); =20 if (pix_clk_params =3D=3D NULL || pll_settings =3D=3D NULL || pix_clk_params->requested_pix_clk_100hz =3D=3D 0) { @@ -600,7 +600,6 @@ static uint32_t dce112_get_pix_clk_dividers( struct pll_settings *pll_settings) { struct dce110_clk_src *clk_src =3D TO_DCE110_CLK_SRC(cs); - DC_LOGGER_INIT(); =20 if (pix_clk_params =3D=3D NULL || pll_settings =3D=3D NULL || pix_clk_params->requested_pix_clk_100hz =3D=3D 0) { @@ -1442,8 +1441,6 @@ static uint32_t dcn3_get_pix_clk_dividers( unsigned long long actual_pix_clk_100Hz =3D pix_clk_params ? pix_clk_para= ms->requested_pix_clk_100hz : 0; struct dce110_clk_src *clk_src =3D TO_DCE110_CLK_SRC(cs); =20 - DC_LOGGER_INIT(); - if (pix_clk_params =3D=3D NULL || pll_settings =3D=3D NULL || pix_clk_params->requested_pix_clk_100hz =3D=3D 0) { DC_LOG_ERROR( @@ -1513,7 +1510,6 @@ static const struct clock_source_funcs dce110_clk_src= _funcs =3D { .get_dp_dto_frequency_100hz =3D get_dp_dto_frequency_100hz }; =20 - static void get_ss_info_from_atombios( struct dce110_clk_src *clk_src, enum as_signal_type as_signal, @@ -1526,7 +1522,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 =3D=3D NULL) { DC_LOG_SYNC( "Invalid entry !!!\n"); @@ -1657,6 +1653,7 @@ static void ss_info_from_atombios_create( } =20 static bool calc_pll_max_vco_construct( + struct dce110_clk_src *clk_src, struct calc_pll_clock_source *calc_pll_cs, struct calc_pll_clock_source_init_data *init_data) { @@ -1808,6 +1805,7 @@ bool dce110_clk_src_construct( ss_info_from_atombios_create(clk_src); =20 if (!calc_pll_max_vco_construct( + clk_src, &clk_src->calc_pll, &calc_pll_cs_init_data)) { ASSERT_CRITICAL(false); @@ -1822,7 +1820,7 @@ bool dce110_clk_src_construct( =20 =20 if (!calc_pll_max_vco_construct( - &clk_src->calc_pll_hdmi, &calc_pll_cs_init_data_hdmi)) { + clk_src, &clk_src->calc_pll_hdmi, &calc_pll_cs_init_data_hdmi)) { ASSERT_CRITICAL(false); goto unexpected_failure; } --=20 2.55.0