All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Enrico Bartky <enrico.bartky@gmail.com>,
	Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH] drm/gma500: Check power status before accessing lid data in opregion
Date: Fri, 12 Apr 2024 09:24:09 +0200	[thread overview]
Message-ID: <20240412072409.27650-1-patrik.r.jakobsson@gmail.com> (raw)

Due to changes in the order of initialization the psb_lid_timer_func
could get called without the device being powered. Fix this by checking
the power status before accessing the opregion.

Cc: Enrico Bartky <enrico.bartky@gmail.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
---
 drivers/gpu/drm/gma500/psb_lid.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/gma500/psb_lid.c b/drivers/gpu/drm/gma500/psb_lid.c
index 58a7fe392636..eeb91d11336e 100644
--- a/drivers/gpu/drm/gma500/psb_lid.c
+++ b/drivers/gpu/drm/gma500/psb_lid.c
@@ -10,6 +10,7 @@
 #include "psb_drv.h"
 #include "psb_intel_reg.h"
 #include "psb_reg.h"
+#include "power.h"
 
 static void psb_lid_timer_func(struct timer_list *t)
 {
@@ -20,9 +21,12 @@ static void psb_lid_timer_func(struct timer_list *t)
 	u32 __iomem *lid_state = dev_priv->opregion.lid_state;
 	u32 pp_status;
 
-	if (readl(lid_state) == dev_priv->lid_last_state)
+	if (!gma_power_begin(dev, false))
 		goto lid_timer_schedule;
 
+	if (readl(lid_state) == dev_priv->lid_last_state)
+		goto power_end;
+
 	if ((readl(lid_state)) & 0x01) {
 		/*lid state is open*/
 		REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) | POWER_TARGET_ON);
@@ -36,6 +40,7 @@ static void psb_lid_timer_func(struct timer_list *t)
 			psb_intel_lvds_set_brightness(dev, 100);
 		} else {
 			DRM_DEBUG("LVDS panel never powered up");
+			gma_power_end(dev);
 			return;
 		}
 	} else {
@@ -48,6 +53,9 @@ static void psb_lid_timer_func(struct timer_list *t)
 	}
 	dev_priv->lid_last_state =  readl(lid_state);
 
+power_end:
+	gma_power_end(dev);
+
 lid_timer_schedule:
 	spin_lock_irqsave(&dev_priv->lid_lock, irq_flags);
 	if (!timer_pending(lid_timer)) {
-- 
2.44.0


             reply	other threads:[~2024-04-12  7:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-12  7:24 Patrik Jakobsson [this message]
2024-04-12  8:02 ` [PATCH] drm/gma500: Check power status before accessing lid data in opregion Thomas Zimmermann
2024-04-12  8:16   ` Thomas Zimmermann
2024-04-12  8:16   ` Patrik Jakobsson
2024-04-12  8:23     ` Thomas Zimmermann

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=20240412072409.27650-1-patrik.r.jakobsson@gmail.com \
    --to=patrik.r.jakobsson@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=enrico.bartky@gmail.com \
    --cc=tzimmermann@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.