All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier
  2010-03-04  0:25 [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier Rafael J. Wysocki
  2010-03-04  0:24 ` Matthew Garrett
@ 2010-03-04  0:24 ` Matthew Garrett
  2010-03-04 11:11   ` Rafał Miłecki
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Matthew Garrett @ 2010-03-04  0:24 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Len Brown, ACPI Devel Maling List, pm list, LKML

On Thu, Mar 04, 2010 at 01:25:30AM +0100, Rafael J. Wysocki wrote:
> There is a problem with the ACPI video resume routine that it's
> executed before the GPU that may be accessed by it.  To fix this
> issue, move the ACPI video resume to a power management notifier,
> so that it's executed after resuming all devices, including the GPU.
> 
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Matthew Garrett <mjg@redhat.com>

-- 
Matthew Garrett | mjg59@srcf.ucam.org

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier
  2010-03-04  0:25 [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier Rafael J. Wysocki
@ 2010-03-04  0:24 ` Matthew Garrett
  2010-03-04  0:24 ` Matthew Garrett
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Matthew Garrett @ 2010-03-04  0:24 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: ACPI Devel Maling List, pm list, LKML

On Thu, Mar 04, 2010 at 01:25:30AM +0100, Rafael J. Wysocki wrote:
> There is a problem with the ACPI video resume routine that it's
> executed before the GPU that may be accessed by it.  To fix this
> issue, move the ACPI video resume to a power management notifier,
> so that it's executed after resuming all devices, including the GPU.
> 
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Matthew Garrett <mjg@redhat.com>

-- 
Matthew Garrett | mjg59@srcf.ucam.org

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier
@ 2010-03-04  0:25 Rafael J. Wysocki
  2010-03-04  0:24 ` Matthew Garrett
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Rafael J. Wysocki @ 2010-03-04  0:25 UTC (permalink / raw)
  To: Len Brown; +Cc: Matthew Garrett, ACPI Devel Maling List, pm list, LKML

There is a problem with the ACPI video resume routine that it's
executed before the GPU that may be accessed by it.  To fix this
issue, move the ACPI video resume to a power management notifier,
so that it's executed after resuming all devices, including the GPU.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/acpi/video.c |   31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

Index: linux-2.6/drivers/acpi/video.c
===================================================================
--- linux-2.6.orig/drivers/acpi/video.c
+++ linux-2.6/drivers/acpi/video.c
@@ -43,6 +43,7 @@
 #include <linux/dmi.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
+#include <linux/suspend.h>
 
 #define PREFIX "ACPI: "
 
@@ -88,7 +89,6 @@ module_param(allow_duplicates, bool, 064
 static int register_count = 0;
 static int acpi_video_bus_add(struct acpi_device *device);
 static int acpi_video_bus_remove(struct acpi_device *device, int type);
-static int acpi_video_resume(struct acpi_device *device);
 static void acpi_video_bus_notify(struct acpi_device *device, u32 event);
 
 static const struct acpi_device_id video_device_ids[] = {
@@ -104,7 +104,6 @@ static struct acpi_driver acpi_video_bus
 	.ops = {
 		.add = acpi_video_bus_add,
 		.remove = acpi_video_bus_remove,
-		.resume = acpi_video_resume,
 		.notify = acpi_video_bus_notify,
 		},
 };
@@ -159,6 +158,7 @@ struct acpi_video_bus {
 	struct proc_dir_entry *dir;
 	struct input_dev *input;
 	char phys[32];	/* for input device */
+	struct notifier_block pm_nb;
 };
 
 struct acpi_video_device_flags {
@@ -2226,24 +2226,31 @@ static void acpi_video_device_notify(acp
 	return;
 }
 
-static int instance;
-static int acpi_video_resume(struct acpi_device *device)
+static int acpi_video_resume(struct notifier_block *nb,
+				unsigned long val, void *ign)
 {
 	struct acpi_video_bus *video;
 	struct acpi_video_device *video_device;
 	int i;
 
-	if (!device || !acpi_driver_data(device))
-		return -EINVAL;
+	switch (val) {
+	case PM_HIBERNATION_PREPARE:
+	case PM_SUSPEND_PREPARE:
+	case PM_RESTORE_PREPARE:
+		return NOTIFY_DONE;
+	}
 
-	video = acpi_driver_data(device);
+	video = container_of(nb, struct acpi_video_bus, pm_nb);
+
+	dev_info(&video->device->dev, "Restoring backlight state\n");
 
 	for (i = 0; i < video->attached_count; i++) {
 		video_device = video->attached_array[i].bind_info;
 		if (video_device && video_device->backlight)
 			acpi_video_set_brightness(video_device->backlight);
 	}
-	return AE_OK;
+
+	return NOTIFY_OK;
 }
 
 static acpi_status
@@ -2267,6 +2274,8 @@ acpi_video_bus_match(acpi_handle handle,
 	return AE_OK;
 }
 
+static int instance;
+
 static int acpi_video_bus_add(struct acpi_device *device)
 {
 	struct acpi_video_bus *video;
@@ -2360,6 +2369,10 @@ static int acpi_video_bus_add(struct acp
 	       video->flags.rom ? "yes" : "no",
 	       video->flags.post ? "yes" : "no");
 
+	video->pm_nb.notifier_call = acpi_video_resume;
+	video->pm_nb.priority = 0;
+	register_pm_notifier(&video->pm_nb);
+
 	return 0;
 
  err_free_input_dev:
@@ -2386,6 +2399,8 @@ static int acpi_video_bus_remove(struct 
 
 	video = acpi_driver_data(device);
 
+	unregister_pm_notifier(&video->pm_nb);
+
 	acpi_video_bus_stop_devices(video);
 	acpi_video_bus_put_devices(video);
 	acpi_video_bus_remove_fs(device);

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier
  2010-03-04  0:25 [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier Rafael J. Wysocki
@ 2010-03-04 11:11   ` Rafał Miłecki
  2010-03-04  0:24 ` Matthew Garrett
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Rafał Miłecki @ 2010-03-04 11:11 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Len Brown, Matthew Garrett, ACPI Devel Maling List, pm list, LKML

2010/3/4 Rafael J. Wysocki <rjw@sisk.pl>:
> There is a problem with the ACPI video resume routine that it's
> executed before the GPU that may be accessed by it.  To fix this
> issue, move the ACPI video resume to a power management notifier,
> so that it's executed after resuming all devices, including the GPU.
>
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> ---

Tested-by: Rafał Miłecki <zajec5@gmail.com>

It partially fixes bugzilla bug #15096 and it first needed step to fix
it completely.

Can we send this to stable for .32 and .33?

-- 
Rafał
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier
@ 2010-03-04 11:11   ` Rafał Miłecki
  0 siblings, 0 replies; 17+ messages in thread
From: Rafał Miłecki @ 2010-03-04 11:11 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Len Brown, Matthew Garrett, ACPI Devel Maling List, pm list, LKML

2010/3/4 Rafael J. Wysocki <rjw@sisk.pl>:
> There is a problem with the ACPI video resume routine that it's
> executed before the GPU that may be accessed by it.  To fix this
> issue, move the ACPI video resume to a power management notifier,
> so that it's executed after resuming all devices, including the GPU.
>
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> ---

Tested-by: Rafał Miłecki <zajec5@gmail.com>

It partially fixes bugzilla bug #15096 and it first needed step to fix
it completely.

Can we send this to stable for .32 and .33?

-- 
Rafał

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier
  2010-03-04  0:25 [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier Rafael J. Wysocki
                   ` (2 preceding siblings ...)
  2010-03-04 11:11   ` Rafał Miłecki
@ 2010-03-04 11:11 ` Rafał Miłecki
  2010-04-04 23:43 ` Rafael J. Wysocki
  2010-04-04 23:43 ` Rafael J. Wysocki
  5 siblings, 0 replies; 17+ messages in thread
From: Rafał Miłecki @ 2010-03-04 11:11 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: pm list, ACPI Devel Maling List, LKML

2010/3/4 Rafael J. Wysocki <rjw@sisk.pl>:
> There is a problem with the ACPI video resume routine that it's
> executed before the GPU that may be accessed by it.  To fix this
> issue, move the ACPI video resume to a power management notifier,
> so that it's executed after resuming all devices, including the GPU.
>
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> ---

Tested-by: Rafał Miłecki <zajec5@gmail.com>

It partially fixes bugzilla bug #15096 and it first needed step to fix
it completely.

Can we send this to stable for .32 and .33?

-- 
Rafał
_______________________________________________
linux-pm mailing list
linux-pm@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/linux-pm

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier
  2010-03-04 11:11   ` Rafał Miłecki
@ 2010-03-04 19:12     ` Rafael J. Wysocki
  -1 siblings, 0 replies; 17+ messages in thread
From: Rafael J. Wysocki @ 2010-03-04 19:12 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Len Brown, Matthew Garrett, ACPI Devel Maling List, pm list, LKML

On Thursday 04 March 2010, Rafał Miłecki wrote:
> 2010/3/4 Rafael J. Wysocki <rjw@sisk.pl>:
> > There is a problem with the ACPI video resume routine that it's
> > executed before the GPU that may be accessed by it.  To fix this
> > issue, move the ACPI video resume to a power management notifier,
> > so that it's executed after resuming all devices, including the GPU.
> >
> > Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> > ---
> 
> Tested-by: Rafał Miłecki <zajec5@gmail.com>

Thanks!

> It partially fixes bugzilla bug #15096 and it first needed step to fix
> it completely.

To fix that completely we'd need to avoid calling acpi_video_resume() in the
non-KMS case, but it's not clear how to tell the ACPI driver which case we're
in.  It's not certain how to reliably distinguish the KMS and non-KMS cases at
this level in the first place.

> Can we send this to stable for .32 and .33?

That depends on Len.

Rafael
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier
@ 2010-03-04 19:12     ` Rafael J. Wysocki
  0 siblings, 0 replies; 17+ messages in thread
From: Rafael J. Wysocki @ 2010-03-04 19:12 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Len Brown, Matthew Garrett, ACPI Devel Maling List, pm list, LKML

On Thursday 04 March 2010, Rafał Miłecki wrote:
> 2010/3/4 Rafael J. Wysocki <rjw@sisk.pl>:
> > There is a problem with the ACPI video resume routine that it's
> > executed before the GPU that may be accessed by it.  To fix this
> > issue, move the ACPI video resume to a power management notifier,
> > so that it's executed after resuming all devices, including the GPU.
> >
> > Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> > ---
> 
> Tested-by: Rafał Miłecki <zajec5@gmail.com>

Thanks!

> It partially fixes bugzilla bug #15096 and it first needed step to fix
> it completely.

To fix that completely we'd need to avoid calling acpi_video_resume() in the
non-KMS case, but it's not clear how to tell the ACPI driver which case we're
in.  It's not certain how to reliably distinguish the KMS and non-KMS cases at
this level in the first place.

> Can we send this to stable for .32 and .33?

That depends on Len.

Rafael

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier
  2010-03-04 11:11   ` Rafał Miłecki
  (?)
@ 2010-03-04 19:12   ` Rafael J. Wysocki
  -1 siblings, 0 replies; 17+ messages in thread
From: Rafael J. Wysocki @ 2010-03-04 19:12 UTC (permalink / raw)
  To: Rafał Miłecki; +Cc: pm list, ACPI Devel Maling List, LKML

On Thursday 04 March 2010, Rafał Miłecki wrote:
> 2010/3/4 Rafael J. Wysocki <rjw@sisk.pl>:
> > There is a problem with the ACPI video resume routine that it's
> > executed before the GPU that may be accessed by it.  To fix this
> > issue, move the ACPI video resume to a power management notifier,
> > so that it's executed after resuming all devices, including the GPU.
> >
> > Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> > ---
> 
> Tested-by: Rafał Miłecki <zajec5@gmail.com>

Thanks!

> It partially fixes bugzilla bug #15096 and it first needed step to fix
> it completely.

To fix that completely we'd need to avoid calling acpi_video_resume() in the
non-KMS case, but it's not clear how to tell the ACPI driver which case we're
in.  It's not certain how to reliably distinguish the KMS and non-KMS cases at
this level in the first place.

> Can we send this to stable for .32 and .33?

That depends on Len.

Rafael
_______________________________________________
linux-pm mailing list
linux-pm@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/linux-pm

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier
  2010-03-04 19:12     ` Rafael J. Wysocki
@ 2010-03-12 21:25       ` Rafał Miłecki
  -1 siblings, 0 replies; 17+ messages in thread
From: Rafał Miłecki @ 2010-03-12 21:25 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Len Brown, Matthew Garrett, ACPI Devel Maling List, pm list, LKML

W dniu 4 marca 2010 20:12 użytkownik Rafael J. Wysocki <rjw@sisk.pl> napisał:
>> Can we send this to stable for .32 and .33?
>
> That depends on Len.

Len?

-- 
Rafał
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier
@ 2010-03-12 21:25       ` Rafał Miłecki
  0 siblings, 0 replies; 17+ messages in thread
From: Rafał Miłecki @ 2010-03-12 21:25 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Len Brown, Matthew Garrett, ACPI Devel Maling List, pm list, LKML

W dniu 4 marca 2010 20:12 użytkownik Rafael J. Wysocki <rjw@sisk.pl> napisał:
>> Can we send this to stable for .32 and .33?
>
> That depends on Len.

Len?

-- 
Rafał

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier
  2010-03-04 19:12     ` Rafael J. Wysocki
  (?)
  (?)
@ 2010-03-12 21:25     ` Rafał Miłecki
  -1 siblings, 0 replies; 17+ messages in thread
From: Rafał Miłecki @ 2010-03-12 21:25 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: pm list, ACPI Devel Maling List, LKML

W dniu 4 marca 2010 20:12 użytkownik Rafael J. Wysocki <rjw@sisk.pl> napisał:
>> Can we send this to stable for .32 and .33?
>
> That depends on Len.

Len?

-- 
Rafał
_______________________________________________
linux-pm mailing list
linux-pm@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/linux-pm

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier
  2010-03-12 21:25       ` Rafał Miłecki
@ 2010-03-17 21:36         ` Len Brown
  -1 siblings, 0 replies; 17+ messages in thread
From: Len Brown @ 2010-03-17 21:36 UTC (permalink / raw)
  To: Rafał Miłecki; +Cc: pm list, LKML, ACPI Devel Maling List

applied

thanks,
Len Brown, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier
@ 2010-03-17 21:36         ` Len Brown
  0 siblings, 0 replies; 17+ messages in thread
From: Len Brown @ 2010-03-17 21:36 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Rafael J. Wysocki, Matthew Garrett, ACPI Devel Maling List,
	pm list, LKML

applied

thanks,
Len Brown, Intel Open Source Technology Center


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier
  2010-03-04  0:25 [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier Rafael J. Wysocki
                   ` (3 preceding siblings ...)
  2010-03-04 11:11 ` Rafał Miłecki
@ 2010-04-04 23:43 ` Rafael J. Wysocki
  2010-04-04 23:43 ` Rafael J. Wysocki
  5 siblings, 0 replies; 17+ messages in thread
From: Rafael J. Wysocki @ 2010-04-04 23:43 UTC (permalink / raw)
  To: Len Brown; +Cc: Matthew Garrett, ACPI Devel Maling List, pm list, LKML

Hi Len,

On Thursday 04 March 2010, Rafael J. Wysocki wrote:
> There is a problem with the ACPI video resume routine that it's
> executed before the GPU that may be accessed by it.  To fix this
> issue, move the ACPI video resume to a power management notifier,
> so that it's executed after resuming all devices, including the GPU.
> 
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>

Please replace the $subject patch with the appended one.

The problem is that the notifier is also executed while we're checking for
the presence of hibernation image during boot and in that case we'll set the
brightness to a wrong value if device->backlight->props.brightness  is not
initialized by acpi_video_device_find_cap().

Rafael

---
From: Rafael J. Wysocki <rjw@sisk.pl>
Subject: ACPI / PM: Move ACPI video resume to a PM notifier

There is a problem with the ACPI video resume routine that it's
executed before the GPU that may be accessed by it.  To fix this
issue, move the ACPI video resume to a power management notifier,
so that's executed after resuming all devices, including the GPU.

Fixes https://bugzilla.kernel.org/show_bug.cgi?id=15096, which is
a listed regression from 2.6.31.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/acpi/video.c |   38 ++++++++++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 8 deletions(-)

Index: linux-2.6/drivers/acpi/video.c
===================================================================
--- linux-2.6.orig/drivers/acpi/video.c
+++ linux-2.6/drivers/acpi/video.c
@@ -43,6 +43,7 @@
 #include <linux/dmi.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
+#include <linux/suspend.h>
 
 #define PREFIX "ACPI: "
 
@@ -88,7 +89,6 @@ module_param(allow_duplicates, bool, 064
 static int register_count = 0;
 static int acpi_video_bus_add(struct acpi_device *device);
 static int acpi_video_bus_remove(struct acpi_device *device, int type);
-static int acpi_video_resume(struct acpi_device *device);
 static void acpi_video_bus_notify(struct acpi_device *device, u32 event);
 
 static const struct acpi_device_id video_device_ids[] = {
@@ -104,7 +104,6 @@ static struct acpi_driver acpi_video_bus
 	.ops = {
 		.add = acpi_video_bus_add,
 		.remove = acpi_video_bus_remove,
-		.resume = acpi_video_resume,
 		.notify = acpi_video_bus_notify,
 		},
 };
@@ -159,6 +158,7 @@ struct acpi_video_bus {
 	struct proc_dir_entry *dir;
 	struct input_dev *input;
 	char phys[32];	/* for input device */
+	struct notifier_block pm_nb;
 };
 
 struct acpi_video_device_flags {
@@ -1020,6 +1020,13 @@ static void acpi_video_device_find_cap(s
 		if (IS_ERR(device->backlight))
 			return;
 
+		/*
+		 * Save current brightness level in case we have to restore it
+		 * before acpi_video_device_lcd_set_level() is called next time.
+		 */
+		device->backlight->props.brightness =
+				acpi_video_get_brightness(device->backlight);
+
 		result = sysfs_create_link(&device->backlight->dev.kobj,
 					   &device->dev->dev.kobj, "device");
 		if (result)
@@ -2235,24 +2242,31 @@ static void acpi_video_device_notify(acp
 	return;
 }
 
-static int instance;
-static int acpi_video_resume(struct acpi_device *device)
+static int acpi_video_resume(struct notifier_block *nb,
+				unsigned long val, void *ign)
 {
 	struct acpi_video_bus *video;
 	struct acpi_video_device *video_device;
 	int i;
 
-	if (!device || !acpi_driver_data(device))
-		return -EINVAL;
+	switch (val) {
+	case PM_HIBERNATION_PREPARE:
+	case PM_SUSPEND_PREPARE:
+	case PM_RESTORE_PREPARE:
+		return NOTIFY_DONE;
+	}
 
-	video = acpi_driver_data(device);
+	video = container_of(nb, struct acpi_video_bus, pm_nb);
+
+	dev_info(&video->device->dev, "Restoring backlight state\n");
 
 	for (i = 0; i < video->attached_count; i++) {
 		video_device = video->attached_array[i].bind_info;
 		if (video_device && video_device->backlight)
 			acpi_video_set_brightness(video_device->backlight);
 	}
-	return AE_OK;
+
+	return NOTIFY_OK;
 }
 
 static acpi_status
@@ -2276,6 +2290,8 @@ acpi_video_bus_match(acpi_handle handle,
 	return AE_OK;
 }
 
+static int instance;
+
 static int acpi_video_bus_add(struct acpi_device *device)
 {
 	struct acpi_video_bus *video;
@@ -2369,6 +2385,10 @@ static int acpi_video_bus_add(struct acp
 	       video->flags.rom ? "yes" : "no",
 	       video->flags.post ? "yes" : "no");
 
+	video->pm_nb.notifier_call = acpi_video_resume;
+	video->pm_nb.priority = 0;
+	register_pm_notifier(&video->pm_nb);
+
 	return 0;
 
  err_free_input_dev:
@@ -2395,6 +2415,8 @@ static int acpi_video_bus_remove(struct 
 
 	video = acpi_driver_data(device);
 
+	unregister_pm_notifier(&video->pm_nb);
+
 	acpi_video_bus_stop_devices(video);
 	acpi_video_bus_put_devices(video);
 	acpi_video_bus_remove_fs(device);

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier
  2010-03-04  0:25 [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier Rafael J. Wysocki
                   ` (4 preceding siblings ...)
  2010-04-04 23:43 ` Rafael J. Wysocki
@ 2010-04-04 23:43 ` Rafael J. Wysocki
  5 siblings, 0 replies; 17+ messages in thread
From: Rafael J. Wysocki @ 2010-04-04 23:43 UTC (permalink / raw)
  To: Len Brown; +Cc: pm list, LKML, ACPI Devel Maling List

Hi Len,

On Thursday 04 March 2010, Rafael J. Wysocki wrote:
> There is a problem with the ACPI video resume routine that it's
> executed before the GPU that may be accessed by it.  To fix this
> issue, move the ACPI video resume to a power management notifier,
> so that it's executed after resuming all devices, including the GPU.
> 
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>

Please replace the $subject patch with the appended one.

The problem is that the notifier is also executed while we're checking for
the presence of hibernation image during boot and in that case we'll set the
brightness to a wrong value if device->backlight->props.brightness  is not
initialized by acpi_video_device_find_cap().

Rafael

---
From: Rafael J. Wysocki <rjw@sisk.pl>
Subject: ACPI / PM: Move ACPI video resume to a PM notifier

There is a problem with the ACPI video resume routine that it's
executed before the GPU that may be accessed by it.  To fix this
issue, move the ACPI video resume to a power management notifier,
so that's executed after resuming all devices, including the GPU.

Fixes https://bugzilla.kernel.org/show_bug.cgi?id=15096, which is
a listed regression from 2.6.31.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/acpi/video.c |   38 ++++++++++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 8 deletions(-)

Index: linux-2.6/drivers/acpi/video.c
===================================================================
--- linux-2.6.orig/drivers/acpi/video.c
+++ linux-2.6/drivers/acpi/video.c
@@ -43,6 +43,7 @@
 #include <linux/dmi.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
+#include <linux/suspend.h>
 
 #define PREFIX "ACPI: "
 
@@ -88,7 +89,6 @@ module_param(allow_duplicates, bool, 064
 static int register_count = 0;
 static int acpi_video_bus_add(struct acpi_device *device);
 static int acpi_video_bus_remove(struct acpi_device *device, int type);
-static int acpi_video_resume(struct acpi_device *device);
 static void acpi_video_bus_notify(struct acpi_device *device, u32 event);
 
 static const struct acpi_device_id video_device_ids[] = {
@@ -104,7 +104,6 @@ static struct acpi_driver acpi_video_bus
 	.ops = {
 		.add = acpi_video_bus_add,
 		.remove = acpi_video_bus_remove,
-		.resume = acpi_video_resume,
 		.notify = acpi_video_bus_notify,
 		},
 };
@@ -159,6 +158,7 @@ struct acpi_video_bus {
 	struct proc_dir_entry *dir;
 	struct input_dev *input;
 	char phys[32];	/* for input device */
+	struct notifier_block pm_nb;
 };
 
 struct acpi_video_device_flags {
@@ -1020,6 +1020,13 @@ static void acpi_video_device_find_cap(s
 		if (IS_ERR(device->backlight))
 			return;
 
+		/*
+		 * Save current brightness level in case we have to restore it
+		 * before acpi_video_device_lcd_set_level() is called next time.
+		 */
+		device->backlight->props.brightness =
+				acpi_video_get_brightness(device->backlight);
+
 		result = sysfs_create_link(&device->backlight->dev.kobj,
 					   &device->dev->dev.kobj, "device");
 		if (result)
@@ -2235,24 +2242,31 @@ static void acpi_video_device_notify(acp
 	return;
 }
 
-static int instance;
-static int acpi_video_resume(struct acpi_device *device)
+static int acpi_video_resume(struct notifier_block *nb,
+				unsigned long val, void *ign)
 {
 	struct acpi_video_bus *video;
 	struct acpi_video_device *video_device;
 	int i;
 
-	if (!device || !acpi_driver_data(device))
-		return -EINVAL;
+	switch (val) {
+	case PM_HIBERNATION_PREPARE:
+	case PM_SUSPEND_PREPARE:
+	case PM_RESTORE_PREPARE:
+		return NOTIFY_DONE;
+	}
 
-	video = acpi_driver_data(device);
+	video = container_of(nb, struct acpi_video_bus, pm_nb);
+
+	dev_info(&video->device->dev, "Restoring backlight state\n");
 
 	for (i = 0; i < video->attached_count; i++) {
 		video_device = video->attached_array[i].bind_info;
 		if (video_device && video_device->backlight)
 			acpi_video_set_brightness(video_device->backlight);
 	}
-	return AE_OK;
+
+	return NOTIFY_OK;
 }
 
 static acpi_status
@@ -2276,6 +2290,8 @@ acpi_video_bus_match(acpi_handle handle,
 	return AE_OK;
 }
 
+static int instance;
+
 static int acpi_video_bus_add(struct acpi_device *device)
 {
 	struct acpi_video_bus *video;
@@ -2369,6 +2385,10 @@ static int acpi_video_bus_add(struct acp
 	       video->flags.rom ? "yes" : "no",
 	       video->flags.post ? "yes" : "no");
 
+	video->pm_nb.notifier_call = acpi_video_resume;
+	video->pm_nb.priority = 0;
+	register_pm_notifier(&video->pm_nb);
+
 	return 0;
 
  err_free_input_dev:
@@ -2395,6 +2415,8 @@ static int acpi_video_bus_remove(struct 
 
 	video = acpi_driver_data(device);
 
+	unregister_pm_notifier(&video->pm_nb);
+
 	acpi_video_bus_stop_devices(video);
 	acpi_video_bus_put_devices(video);
 	acpi_video_bus_remove_fs(device);

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier
@ 2010-03-04  0:25 Rafael J. Wysocki
  0 siblings, 0 replies; 17+ messages in thread
From: Rafael J. Wysocki @ 2010-03-04  0:25 UTC (permalink / raw)
  To: Len Brown; +Cc: pm list, LKML, ACPI Devel Maling List

There is a problem with the ACPI video resume routine that it's
executed before the GPU that may be accessed by it.  To fix this
issue, move the ACPI video resume to a power management notifier,
so that it's executed after resuming all devices, including the GPU.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/acpi/video.c |   31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

Index: linux-2.6/drivers/acpi/video.c
===================================================================
--- linux-2.6.orig/drivers/acpi/video.c
+++ linux-2.6/drivers/acpi/video.c
@@ -43,6 +43,7 @@
 #include <linux/dmi.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
+#include <linux/suspend.h>
 
 #define PREFIX "ACPI: "
 
@@ -88,7 +89,6 @@ module_param(allow_duplicates, bool, 064
 static int register_count = 0;
 static int acpi_video_bus_add(struct acpi_device *device);
 static int acpi_video_bus_remove(struct acpi_device *device, int type);
-static int acpi_video_resume(struct acpi_device *device);
 static void acpi_video_bus_notify(struct acpi_device *device, u32 event);
 
 static const struct acpi_device_id video_device_ids[] = {
@@ -104,7 +104,6 @@ static struct acpi_driver acpi_video_bus
 	.ops = {
 		.add = acpi_video_bus_add,
 		.remove = acpi_video_bus_remove,
-		.resume = acpi_video_resume,
 		.notify = acpi_video_bus_notify,
 		},
 };
@@ -159,6 +158,7 @@ struct acpi_video_bus {
 	struct proc_dir_entry *dir;
 	struct input_dev *input;
 	char phys[32];	/* for input device */
+	struct notifier_block pm_nb;
 };
 
 struct acpi_video_device_flags {
@@ -2226,24 +2226,31 @@ static void acpi_video_device_notify(acp
 	return;
 }
 
-static int instance;
-static int acpi_video_resume(struct acpi_device *device)
+static int acpi_video_resume(struct notifier_block *nb,
+				unsigned long val, void *ign)
 {
 	struct acpi_video_bus *video;
 	struct acpi_video_device *video_device;
 	int i;
 
-	if (!device || !acpi_driver_data(device))
-		return -EINVAL;
+	switch (val) {
+	case PM_HIBERNATION_PREPARE:
+	case PM_SUSPEND_PREPARE:
+	case PM_RESTORE_PREPARE:
+		return NOTIFY_DONE;
+	}
 
-	video = acpi_driver_data(device);
+	video = container_of(nb, struct acpi_video_bus, pm_nb);
+
+	dev_info(&video->device->dev, "Restoring backlight state\n");
 
 	for (i = 0; i < video->attached_count; i++) {
 		video_device = video->attached_array[i].bind_info;
 		if (video_device && video_device->backlight)
 			acpi_video_set_brightness(video_device->backlight);
 	}
-	return AE_OK;
+
+	return NOTIFY_OK;
 }
 
 static acpi_status
@@ -2267,6 +2274,8 @@ acpi_video_bus_match(acpi_handle handle,
 	return AE_OK;
 }
 
+static int instance;
+
 static int acpi_video_bus_add(struct acpi_device *device)
 {
 	struct acpi_video_bus *video;
@@ -2360,6 +2369,10 @@ static int acpi_video_bus_add(struct acp
 	       video->flags.rom ? "yes" : "no",
 	       video->flags.post ? "yes" : "no");
 
+	video->pm_nb.notifier_call = acpi_video_resume;
+	video->pm_nb.priority = 0;
+	register_pm_notifier(&video->pm_nb);
+
 	return 0;
 
  err_free_input_dev:
@@ -2386,6 +2399,8 @@ static int acpi_video_bus_remove(struct 
 
 	video = acpi_driver_data(device);
 
+	unregister_pm_notifier(&video->pm_nb);
+
 	acpi_video_bus_stop_devices(video);
 	acpi_video_bus_put_devices(video);
 	acpi_video_bus_remove_fs(device);

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2010-05-01  1:44 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-04  0:25 [PATCH] ACPI / PM: Move ACPI video resume to a PM notifier Rafael J. Wysocki
2010-03-04  0:24 ` Matthew Garrett
2010-03-04  0:24 ` Matthew Garrett
2010-03-04 11:11 ` Rafał Miłecki
2010-03-04 11:11   ` Rafał Miłecki
2010-03-04 19:12   ` Rafael J. Wysocki
2010-03-04 19:12   ` Rafael J. Wysocki
2010-03-04 19:12     ` Rafael J. Wysocki
2010-03-12 21:25     ` Rafał Miłecki
2010-03-12 21:25       ` Rafał Miłecki
2010-03-17 21:36       ` Len Brown
2010-03-17 21:36         ` Len Brown
2010-03-12 21:25     ` Rafał Miłecki
2010-03-04 11:11 ` Rafał Miłecki
2010-04-04 23:43 ` Rafael J. Wysocki
2010-04-04 23:43 ` Rafael J. Wysocki
2010-03-04  0:25 Rafael J. Wysocki

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.