mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: Maxime Ripard <mripard@kernel.org>,
	Alex Deucher <alexander.deucher@amd.com>,
	Jani Nikula <jani.nikula@linux.intel.com>,
	Javier Martinez Canillas <javierm@redhat.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	"Harry Wentland" <harry.wentland@amd.com>,
	Leo Li <sunpeng.li@amd.com>,
	"Rodrigo Siqueira" <siqueira@igalia.com>
Cc: Mario Limonciello <superm1@kernel.org>,
	Xaver Hugl <xaver.hugl@gmail.com>,
	<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
	<amd-gfx@lists.freedesktop.org>,
	<intel-gfx@lists.freedesktop.org>,
	<intel-xe@lists.freedesktop.org>, <nouveau@lists.freedesktop.org>
Subject: [PATCH v12 03/12] drm/amdgpu: Check bios_scratch_reg_offset in backlight level helper
Date: Thu, 19 Nov 2026 17:27:30 -0600	[thread overview]
Message-ID: <20261119-superm1-backlight-property-v12-3-89d5217d3618@amd.com> (raw)
In-Reply-To: <20261119-superm1-backlight-property-v12-0-89d5217d3618@amd.com>

From: "Mario Limonciello (AMD)" <superm1@kernel.org>

Ensure adev->bios_scratch_reg_offset is non-zero before accessing
scratch registers in amdgpu_atombios_scratch_regs_set_backlight_level(),
so they are not accessed when they were never set up, such as in KUnit
tests.

Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
---
v11:
 * Clarify the commit message
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
index 27c0dc8f6137a..2d8c2ba04e670 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
@@ -1622,7 +1622,12 @@ void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev,
 void amdgpu_atombios_scratch_regs_set_backlight_level(struct amdgpu_device *adev,
 						      u32 backlight_level)
 {
-	u32 tmp = RREG32(adev->bios_scratch_reg_offset + 2);
+	u32 tmp;
+
+	if (!adev->bios_scratch_reg_offset)
+		return;
+
+	tmp = RREG32(adev->bios_scratch_reg_offset + 2);
 
 	tmp &= ~ATOM_S2_CURRENT_BL_LEVEL_MASK;
 	tmp |= (backlight_level << ATOM_S2_CURRENT_BL_LEVEL_SHIFT) &

-- 
2.43.0


  parent reply	other threads:[~2026-11-19 23:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 23:27 [PATCH v12 00/12] Add support for a DRM backlight capability Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 01/12] drm: add connector LUMINANCE property Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 02/12] drm/amd/display: Pass up errors reading actual brightness Mario Limonciello
2026-11-19 23:27 ` Mario Limonciello [this message]
2026-11-19 23:27 ` [PATCH v12 04/12] drm/amd: add luminance property support Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 05/12] drm/i915/display: " Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 06/12] drm/bridge: add connector luminance operations Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 07/12] drm/panel: add connector luminance forwarding Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 08/12] drm/bridge_connector: add luminance support Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 09/12] drm/nouveau: add connector " Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 10/12] drm/gud: " Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 11/12] drm/bridge: add PS8622 " Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 12/12] drm/solomon: add SSD130x " Mario Limonciello

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261119-superm1-backlight-property-v12-3-89d5217d3618@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=harry.wentland@amd.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=javierm@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=simona@ffwll.ch \
    --cc=siqueira@igalia.com \
    --cc=sunpeng.li@amd.com \
    --cc=superm1@kernel.org \
    --cc=tzimmermann@suse.de \
    --cc=xaver.hugl@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®