aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Renninger <trenn@suse.de>2008-08-01 11:37:54 -0400
committerLen Brown <len.brown@intel.com>2008-11-07 23:49:23 -0500
commit22c13f9d8179f4c9caecfcb60a95214562b9addc (patch)
tree3bf73f6e3e9c95cab2811b6a190ed804cbca2eca
parentfed4d59b6ec5481caceb17863f19a0b0e5eaa939 (diff)
ACPI: video: Ignore devices that aren't present in hardware
This is a reimplemention of commit 0119509c4fbc9adcef1472817fda295334612976 from Matthew Garrett <mjg59@srcf.ucam.org> This patch got removed because of a regression: ThinkPads with a Intel graphics card and an Integrated Graphics Device BIOS implementation stopped working. In fact, they only worked because the ACPI device of the discrete, the wrong one, got used (via int10). So ACPI functions were poking on the wrong hardware used which is a sever bug. The next patch provides support for above ThinkPads to be able to switch brightness via the legacy thinkpad_acpi driver and automatically detect when to use it. Original commit message from Matthew Garrett: Vendors often ship machines with a choice of integrated or discrete graphics, and use the same DSDT for both. As a result, the ACPI video module will locate devices that may not exist on this specific platform. Attempt to determine whether the device exists or not, and abort the device creation if it doesn't. http://bugzilla.kernel.org/show_bug.cgi?id=9614 Signed-off-by: Thomas Renninger <trenn@suse.de> Acked-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--drivers/acpi/glue.c40
-rw-r--r--drivers/acpi/video.c7
-rw-r--r--include/acpi/acpi_bus.h2
3 files changed, 48 insertions, 1 deletions
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 24649ada08df..adec3d15810a 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -140,6 +140,46 @@ struct device *acpi_get_physical_device(acpi_handle handle)
140 140
141EXPORT_SYMBOL(acpi_get_physical_device); 141EXPORT_SYMBOL(acpi_get_physical_device);
142 142
143/* ToDo: When a PCI bridge is found, return the PCI device behind the bridge
144 * This should work in general, but did not on a Lenovo T61 for the
145 * graphics card. But this must be fixed when the PCI device is
146 * bound and the kernel device struct is attached to the acpi device
147 * Note: A success call will increase reference count by one
148 * Do call put_device(dev) on the returned device then
149 */
150struct device *acpi_get_physical_pci_device(acpi_handle handle)
151{
152 struct device *dev;
153 long long device_id;
154 acpi_status status;
155
156 status =
157 acpi_evaluate_integer(handle, "_ADR", NULL, &device_id);
158
159 if (ACPI_FAILURE(status))
160 return NULL;
161
162 /* We need to attempt to determine whether the _ADR refers to a
163 PCI device or not. There's no terribly good way to do this,
164 so the best we can hope for is to assume that there'll never
165 be a device in the host bridge */
166 if (device_id >= 0x10000) {
167 /* It looks like a PCI device. Does it exist? */
168 dev = acpi_get_physical_device(handle);
169 } else {
170 /* It doesn't look like a PCI device. Does its parent
171 exist? */
172 acpi_handle phandle;
173 if (acpi_get_parent(handle, &phandle))
174 return NULL;
175 dev = acpi_get_physical_device(phandle);
176 }
177 if (!dev)
178 return NULL;
179 return dev;
180}
181EXPORT_SYMBOL(acpi_get_physical_pci_device);
182
143static int acpi_bind_one(struct device *dev, acpi_handle handle) 183static int acpi_bind_one(struct device *dev, acpi_handle handle)
144{ 184{
145 struct acpi_device *acpi_dev; 185 struct acpi_device *acpi_dev;
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index a29b0ccac65a..6597c2a37c36 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -842,11 +842,16 @@ static void acpi_video_bus_find_cap(struct acpi_video_bus *video)
842static int acpi_video_bus_check(struct acpi_video_bus *video) 842static int acpi_video_bus_check(struct acpi_video_bus *video)
843{ 843{
844 acpi_status status = -ENOENT; 844 acpi_status status = -ENOENT;
845 845 struct device *dev;
846 846
847 if (!video) 847 if (!video)
848 return -EINVAL; 848 return -EINVAL;
849 849
850 dev = acpi_get_physical_pci_device(video->device->handle);
851 if (!dev)
852 return -ENODEV;
853 put_device(dev);
854
850 /* Since there is no HID, CID and so on for VGA driver, we have 855 /* Since there is no HID, CID and so on for VGA driver, we have
851 * to check well known required nodes. 856 * to check well known required nodes.
852 */ 857 */
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 54a279e44c9a..e9f6574930ef 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -380,6 +380,8 @@ struct acpi_bus_type {
380int register_acpi_bus_type(struct acpi_bus_type *); 380int register_acpi_bus_type(struct acpi_bus_type *);
381int unregister_acpi_bus_type(struct acpi_bus_type *); 381int unregister_acpi_bus_type(struct acpi_bus_type *);
382struct device *acpi_get_physical_device(acpi_handle); 382struct device *acpi_get_physical_device(acpi_handle);
383struct device *acpi_get_physical_pci_device(acpi_handle);
384
383/* helper */ 385/* helper */
384acpi_handle acpi_get_child(acpi_handle, acpi_integer); 386acpi_handle acpi_get_child(acpi_handle, acpi_integer);
385acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int); 387acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int);