public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org,
	stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Tobias Diedrich <ranma+kernel@tdiedrich.de>,
	Robert de Rooy <robert.de.rooy@gmail.com>
Subject: [31/30] thinkpad-acpi: fix incorrect use of TPACPI_BRGHT_MODE_ECNVRAM
Date: Fri, 2 Oct 2009 09:42:13 -0700	[thread overview]
Message-ID: <20091002164213.GA3711@kroah.com> (raw)
In-Reply-To: <20091001233504.GA17709@kroah.com>

2.6.30-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>

HBRV-based default selection of backlight control strategy didn't work
well, at least the X41 defines it but doesn't use it and I don't think
it will stop there.  Switch to a blacklist, and make sure only Radeon-
based models get ECNVRAM.

Symptoms of incorrect backlight mode selection are:

1. Non-working backlight control through sysfs;

2. Backlight gets reset to the lowest level at every shutdown, reboot
   and when thinkpad-acpi gets unloaded;

This fixes a regression in 2.6.30, bugzilla #13826.  This fix is
already present on 2.6.31.

This is a minimal patch for 2.6.30-stable, based on mainline
commits: 050df107c408a3df048524b3783a5fc6d4dccfdb,
	 7d95a3d564901e88ed42810f054e579874151999,
	 59fe4fe34d7afdf63208124f313be9056feaa2f4,
	 6da25bf51689a5cc60370d30275dbb9e6852e0cb

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Reported-by: Tobias Diedrich <ranma+kernel@tdiedrich.de>
Reported-by: Robert de Rooy <robert.de.rooy@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/platform/x86/thinkpad_acpi.c |   74 ++++++++++++++++++++++++++++-------
 1 file changed, 61 insertions(+), 13 deletions(-)

--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -286,6 +286,8 @@ struct thinkpad_id_data {
 
 	u16 bios_model;		/* Big Endian, TP-1Y = 0x5931, 0 = unknown */
 	u16 ec_model;
+	u16 bios_release;	/* 1ZETK1WW = 0x314b, 0 = unknown */
+	u16 ec_release;
 
 	char *model_str;	/* ThinkPad T43 */
 	char *nummodel_str;	/* 9384A9C for a 9384-A9C model */
@@ -362,6 +364,45 @@ static void tpacpi_log_usertask(const ch
 		} \
 	} while (0)
 
+#define TPACPI_MATCH_ANY		0xffffU
+#define TPACPI_MATCH_UNKNOWN		0U
+
+/* TPID('1', 'Y') == 0x5931 */
+#define TPID(__c1, __c2) (((__c2) << 8) | (__c1))
+
+#define TPACPI_Q_IBM(__id1, __id2, __quirk)	\
+	{ .vendor = PCI_VENDOR_ID_IBM,		\
+	  .bios = TPID(__id1, __id2),		\
+	  .ec = TPACPI_MATCH_ANY,		\
+	  .quirks = (__quirk) }
+
+struct tpacpi_quirk {
+	unsigned int vendor;
+	u16 bios;
+	u16 ec;
+	unsigned long quirks;
+};
+
+static unsigned long __init tpacpi_check_quirks(
+			const struct tpacpi_quirk *qlist,
+			unsigned int qlist_size)
+{
+	while (qlist_size) {
+		if ((qlist->vendor == thinkpad_id.vendor ||
+				qlist->vendor == TPACPI_MATCH_ANY) &&
+		    (qlist->bios == thinkpad_id.bios_model ||
+				qlist->bios == TPACPI_MATCH_ANY) &&
+		    (qlist->ec == thinkpad_id.ec_model ||
+				qlist->ec == TPACPI_MATCH_ANY))
+			return qlist->quirks;
+
+		qlist_size--;
+		qlist++;
+	}
+	return 0;
+}
+
+
 /****************************************************************************
  ****************************************************************************
  *
@@ -5757,14 +5798,27 @@ static struct backlight_ops ibm_backligh
 
 /* --------------------------------------------------------------------- */
 
+#define TPACPI_BRGHT_Q_EC	0x0002  /* Should or must use EC HBRV */
+
+static const struct tpacpi_quirk brightness_quirk_table[] __initconst = {
+	TPACPI_Q_IBM('1', 'Y', TPACPI_BRGHT_Q_EC),
+	TPACPI_Q_IBM('1', 'Q', TPACPI_BRGHT_Q_EC),
+	TPACPI_Q_IBM('7', '6', TPACPI_BRGHT_Q_EC),
+	TPACPI_Q_IBM('7', '8', TPACPI_BRGHT_Q_EC),
+};
+
 static int __init brightness_init(struct ibm_init_struct *iibm)
 {
 	int b;
+	unsigned long quirks;
 
 	vdbg_printk(TPACPI_DBG_INIT, "initializing brightness subdriver\n");
 
 	mutex_init(&brightness_mutex);
 
+	quirks = tpacpi_check_quirks(brightness_quirk_table,
+				ARRAY_SIZE(brightness_quirk_table));
+
 	/*
 	 * We always attempt to detect acpi support, so as to switch
 	 * Lenovo Vista BIOS to ACPI brightness mode even if we are not
@@ -5821,19 +5875,9 @@ static int __init brightness_init(struct
 	/* TPACPI_BRGHT_MODE_AUTO not implemented yet, just use default */
 	if (brightness_mode == TPACPI_BRGHT_MODE_AUTO ||
 	    brightness_mode == TPACPI_BRGHT_MODE_MAX) {
-		if (thinkpad_id.vendor == PCI_VENDOR_ID_IBM) {
-			/*
-			 * IBM models that define HBRV probably have
-			 * EC-based backlight level control
-			 */
-			if (acpi_evalf(ec_handle, NULL, "HBRV", "qd"))
-				/* T40-T43, R50-R52, R50e, R51e, X31-X41 */
-				brightness_mode = TPACPI_BRGHT_MODE_ECNVRAM;
-			else
-				/* all other IBM ThinkPads */
-				brightness_mode = TPACPI_BRGHT_MODE_UCMS_STEP;
-		} else
-			/* All Lenovo ThinkPads */
+		if (quirks & TPACPI_BRGHT_Q_EC)
+			brightness_mode = TPACPI_BRGHT_MODE_ECNVRAM;
+		else
 			brightness_mode = TPACPI_BRGHT_MODE_UCMS_STEP;
 
 		dbg_printk(TPACPI_DBG_BRGHT,
@@ -7387,6 +7431,8 @@ static int __must_check __init get_think
 		return 0;
 	tp->bios_model = tp->bios_version_str[0]
 			 | (tp->bios_version_str[1] << 8);
+	tp->bios_release = (tp->bios_version_str[4] << 8)
+			 | tp->bios_version_str[5];
 
 	/*
 	 * ThinkPad T23 or newer, A31 or newer, R50e or newer,
@@ -7407,6 +7453,8 @@ static int __must_check __init get_think
 				return -ENOMEM;
 			tp->ec_model = ec_fw_string[0]
 					| (ec_fw_string[1] << 8);
+			tp->ec_release = (ec_fw_string[4] << 8)
+					| ec_fw_string[5];
 			break;
 		}
 	}

  parent reply	other threads:[~2009-10-02 16:52 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20091001233116.947658905@mini.kroah.org>
2009-10-01 23:35 ` [patch 00/30] 2.6.30.9-stable review Greg KH
2009-10-01 23:31   ` [patch 01/30] ACPI: pci_slot.ko wants a 64-bit _SUN Greg KH
2009-10-01 23:31   ` [patch 02/30] fs: make sure data stored into inode is properly seen before unlocking new inode Greg KH
2009-10-01 23:31   ` [patch 03/30] kallsyms: fix segfault in prefix_underscores_count() Greg KH
2009-10-01 23:31   ` [patch 04/30] nilfs2: fix missing zero-fill initialization of btree node cache Greg KH
2009-10-01 23:31   ` [patch 05/30] p54usb: add Zcomax XG-705A usbid Greg KH
2009-10-01 23:31   ` [patch 06/30] [CIFS] Re-enable Lanman security Greg KH
2009-10-01 23:31   ` [patch 07/30] KVM: VMX: Check cpl before emulating debug register access Greg KH
2009-10-01 23:31   ` [patch 08/30] KVM: VMX: Fix cr8 exiting control clobbering by EPT Greg KH
2009-10-01 23:31   ` [patch 09/30] KVM: MMU: make __kvm_mmu_free_some_pages handle empty list Greg KH
2009-10-01 23:31   ` [patch 10/30] KVM: x86: Disallow hypercalls for guest callers in rings > 0 Greg KH
2009-10-01 23:31   ` [patch 11/30] KVM: MMU: fix missing locking in alloc_mmu_pages Greg KH
2009-10-01 23:31   ` [patch 12/30] KVM: MMU: fix bogus alloc_mmu_pages assignment Greg KH
2009-10-01 23:31   ` [patch 13/30] KVM: limit lapic periodic timer frequency Greg KH
2009-10-01 23:31   ` [patch 14/30] KVM guest: fix bogus wallclock physical address calculation Greg KH
2009-10-01 23:31   ` [patch 15/30] KVM: fix cpuid E2BIG handling for extended request types Greg KH
2009-10-01 23:31   ` [patch 16/30] Revert "KVM: x86: check for cr3 validity in ioctl_set_sregs" Greg KH
2009-10-01 23:31   ` [patch 17/30] ahci: restore pci_intx() handling Greg KH
2009-10-01 23:31   ` [patch 18/30] net ax25: Fix signed comparison in the sockopt handler Greg KH
2009-10-01 23:31   ` [patch 19/30] net: Make the copy length in af_packet sockopt handler unsigned Greg KH
2009-10-01 23:31   ` [patch 20/30] [CPUFREQ] Fix NULL ptr regression in powernow-k8 Greg KH
2009-10-01 23:31   ` [patch 21/30] netfilter: bridge: refcount fix Greg KH
2009-10-01 23:31   ` [patch 22/30] netfilter: ebt_ulog: fix checkentry return value Greg KH
2009-10-01 23:31   ` [patch 23/30] netfilter: nf_nat: fix inverted logic for persistent NAT mappings Greg KH
2009-10-01 23:31   ` [patch 24/30] Fix idle time field in /proc/uptime Greg KH
2009-10-01 23:31   ` [patch 25/30] hugetlb: restore interleaving of bootmem huge pages (2.6.31) Greg KH
2009-10-01 23:31   ` [patch 26/30] powerpc/8xx: Fix regression introduced by cache coherency rewrite Greg KH
2009-10-01 23:31   ` [patch 27/30] powerpc: Fix incorrect setting of __HAVE_ARCH_PTE_SPECIAL Greg KH
2009-10-01 23:31   ` [patch 28/30] /proc/kcore: work around a BUG() Greg KH
2009-10-01 23:31   ` [patch 29/30] PM / PCMCIA: Drop second argument of pcmcia_socket_dev_suspend() Greg KH
2009-10-01 23:31   ` [patch 30/30] PM / yenta: Fix cardbus suspend/resume regression Greg KH
2009-10-02  2:43   ` [patch 00/30] 2.6.30.9-stable review Henrique de Moraes Holschuh
2009-10-02 14:20     ` [stable] " Greg KH
2009-10-03 14:39       ` Henrique de Moraes Holschuh
2009-10-02 16:42   ` Greg KH [this message]
2009-10-02 17:20   ` [patch 32/30] mm: fix anonymous dirtying Greg KH
2009-10-02 17:21   ` [patch 33/30] mmap: avoid unnecessary anon_vma lock acquisition in vma_adjust() Greg KH
2009-10-02 17:23   ` [patch 00/30] 2.6.30.9-stable review Greg KH

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=20091002164213.GA3711@kroah.com \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=hmh@hmh.eng.br \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ranma+kernel@tdiedrich.de \
    --cc=robert.de.rooy@gmail.com \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox