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 <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Signed-off-by: Patrik Jakobsson <[email protected]>
---
 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 via email to