All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mattia Dongili <malattia@linux.it>
To: "Marco Krüger" <krgsch@gmail.com>
Cc: platform-driver-x86@vger.kernel.org
Subject: Re: sony-laptop crash (Sony VPC SE 1V9E) for 3.8.0+
Date: Sun, 22 Sep 2013 12:10:01 +0900	[thread overview]
Message-ID: <20130922031001.GA6901@kamineko.org> (raw)
In-Reply-To: <523E1206.8080001@gmail.com>

On Sat, Sep 21, 2013 at 11:39:18PM +0200, Marco Krüger wrote:
> Hi Mattia,
> 
> you are right!
> If I comment out either one case  (0x0143/0x014b) no crash occurs. I
> also recognized that the gfx switch value is wrong. Using the gfx
> switch toggles the value, but it is the opposite to the actual
> switch position. What can I do to help you solving this bug?

apologies, this issue flew off my radar and I essentially forgot about
it.
I had prepared this patch back then, could you see if it also works?

I think these checks should be extended to all handles not just the
keyboard backlight one but that's a bigger patch.

--- 
commit 0fcf192e1bdd396cb510bed918ee6c450396c8e4
Author: Mattia Dongili <malattia@linux.it>
Date:   Sun Aug 18 19:32:08 2013 +0900

    sony-laptop: warn on multiple KBD backlight handles
    
    Some BIOS versions/Vaio models apparently ship with two nearly identical
    functions to handle backlight related controls.
    The only difference seems to be:
            If (LEqual (BUF1, 0x40))
            {
                Store (0x40, P80H)
                Store (BUF2, Local0)
    -           And (Local0, One, Local0)
    +           And (Local0, 0x03, Local0)
                Store (Local0, ^^H_EC.KLPC)
            }
    
    Avoid erroring out on initialization and messing things up on cleanup
    for now since we never call into those methods with anything different
    than 1 or 0.
    This issue was found on a Sony VPCSE1V9E/BIOS R2087H4.
    
    Cc: Marco Krüger <krgsch@gmail.com>
    Signed-off-by: Mattia Dongili <malattia@linux.it>

diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 3a1b6bf..b5a7f3c 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -146,7 +146,8 @@ static void sony_nc_thermal_resume(void);
 #endif
 static int sony_nc_kbd_backlight_setup(struct platform_device *pd,
 		unsigned int handle);
-static void sony_nc_kbd_backlight_cleanup(struct platform_device *pd);
+static void sony_nc_kbd_backlight_cleanup(struct platform_device *pd,
+		unsigned int handle);
 
 static int sony_nc_battery_care_setup(struct platform_device *pd,
 		unsigned int handle);
@@ -1448,7 +1449,7 @@ static void sony_nc_function_cleanup(struct platform_device *pd)
 		case 0x014b:
 		case 0x014c:
 		case 0x0163:
-			sony_nc_kbd_backlight_cleanup(pd);
+			sony_nc_kbd_backlight_cleanup(pd, handle);
 			break;
 		default:
 			continue;
@@ -1829,6 +1830,12 @@ static int sony_nc_kbd_backlight_setup(struct platform_device *pd,
 	int result;
 	int ret = 0;
 
+	if (kbdbl_ctl) {
+		pr_warn("handle 0x%.4x: keyboard backlight setup already done for 0x%.4x\n",
+				handle, kbdbl_ctl->handle);
+		return -EBUSY;
+	}
+
 	/* verify the kbd backlight presence, these handles are not used for
 	 * keyboard backlight only
 	 */
@@ -1886,9 +1893,10 @@ outkzalloc:
 	return ret;
 }
 
-static void sony_nc_kbd_backlight_cleanup(struct platform_device *pd)
+static void sony_nc_kbd_backlight_cleanup(struct platform_device *pd,
+		unsigned int handle)
 {
-	if (kbdbl_ctl) {
+	if (kbdbl_ctl && handle == kbdbl_ctl->handle) {
 		int result;
 
 		device_remove_file(&pd->dev, &kbdbl_ctl->mode_attr);
-- 
mattia
:wq!

  reply	other threads:[~2013-09-22  3:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-04 10:38 sony-laptop crash (Sony VPC SE 1V9E) for 3.8.0+ Marco Krüger
2013-08-04 22:14 ` Mattia Dongili
2013-08-05  0:28   ` Marco Krüger
2013-08-08 22:17     ` Mattia Dongili
2013-08-09 13:35       ` Marco Krüger
2013-09-21 21:39       ` Marco Krüger
2013-09-22  3:10         ` Mattia Dongili [this message]
2013-09-22  6:47           ` Marco Krüger
2013-09-22  7:55             ` Mattia Dongili
2013-09-22  9:07               ` Marco Krüger

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=20130922031001.GA6901@kamineko.org \
    --to=malattia@linux.it \
    --cc=krgsch@gmail.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /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.