From patchwork Wed Jul 15 09:18:08 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 35666 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6F9HLPH004265 for ; Wed, 15 Jul 2009 09:17:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751599AbZGOJRU (ORCPT ); Wed, 15 Jul 2009 05:17:20 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752149AbZGOJRU (ORCPT ); Wed, 15 Jul 2009 05:17:20 -0400 Received: from mga09.intel.com ([134.134.136.24]:63498 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751599AbZGOJRT (ORCPT ); Wed, 15 Jul 2009 05:17:19 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 15 Jul 2009 02:04:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.42,403,1243839600"; d="scan'208";a="430368637" Received: from rzhang-dt.sh.intel.com (HELO [10.239.36.94]) ([10.239.36.94]) by orsmga002.jf.intel.com with ESMTP; 15 Jul 2009 02:24:12 -0700 Subject: [PATCH -mm] ACPI video: only one ACPI bus video device is allowed for one VGA controller From: Zhang Rui To: Len Brown Cc: linux-acpi , "Zhang, Rui" , hector@marcansoft.com Date: Wed, 15 Jul 2009 17:18:08 +0800 Message-Id: <1247649488.26272.106.camel@rzhang-dt> Mime-Version: 1.0 X-Mailer: Evolution 2.22.1 (2.22.1-2.fc9) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Only one ACPI video bus device for a VGA controller. Some buggy BIOS exports multiple ACPI video bus devices for the same VGA controller, and multiple backlight control methods as well. This messes up the ACPI video backlight control. http://bugzilla.kernel.org/show_bug.cgi?id=13577 With this patch applied, only the first ACPI video bus device under a PCI device node is bind to ACPI video driver. The questions is that, we never notice this kind of devices before, thus I'm not sure this won't break any laptops. I suggest we put this patch in ACPI test tree first. Tested-by: Hector Martin Signed-off-by: Zhang Rui --- drivers/acpi/video.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) -- 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 Index: linux-2.6/drivers/acpi/video.c =================================================================== --- linux-2.6.orig/drivers/acpi/video.c +++ linux-2.6/drivers/acpi/video.c @@ -2195,11 +2195,43 @@ static int acpi_video_resume(struct acpi return AE_OK; } +static acpi_status +acpi_video_bus_match(acpi_handle handle, u32 level, void *context, + void **return_value) +{ + struct acpi_device *device = context; + struct acpi_device *sibling; + int result; + + if (handle == device->handle) + return AE_CTRL_TERMINATE; + + result = acpi_bus_get_device(handle, &sibling); + if (result) + return AE_OK; + + /* only one ACPI bus video device under a PCI device */ + if (!strcmp(acpi_device_name(sibling), ACPI_VIDEO_BUS_NAME)) + return AE_ALREADY_EXISTS; + + return AE_OK; +} + static int acpi_video_bus_add(struct acpi_device *device) { struct acpi_video_bus *video; struct input_dev *input; int error; + acpi_status status; + + status = acpi_walk_namespace(ACPI_TYPE_DEVICE, + device->parent->handle, 1, + acpi_video_bus_match, device, NULL); + if (status == AE_ALREADY_EXISTS) { + printk(KERN_WARNING PREFIX, "Duplicate ACPI video bus " + "devices for the same VGA controller\n"); + return -ENODEV; + } video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL); if (!video)