aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2012-09-28 20:57:05 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2012-09-29 15:21:03 -0400
commit2223af389032425e3d1a70f9cb3a63feaa654ced (patch)
tree6874c07f26b3cdc5b10e06c34e7d0f6a9f5494aa /drivers
parent7bc90e01c3f66c137e7e761f574bbf883087d590 (diff)
efi: Fix the ACPI BGRT driver for images located in EFI boot services memory
The ACPI BGRT driver accesses the BIOS logo image when it initializes. However, ACPI 5.0 (which introduces the BGRT) recommends putting the logo image in EFI boot services memory, so that the OS can reclaim that memory. Production systems follow this recommendation, breaking the ACPI BGRT driver. Move the bulk of the BGRT code to run during a new EFI late initialization phase, which occurs after switching EFI to virtual mode, and after initializing ACPI, but before freeing boot services memory. Copy the BIOS logo image to kernel memory at that point, and make it accessible to the BGRT driver. Rework the existing ACPI BGRT driver to act as a simple wrapper exposing that image (and the properties from the BGRT) via sysfs. Signed-off-by: Josh Triplett <josh@joshtriplett.org> Link: http://lkml.kernel.org/r/93ce9f823f1c1f3bb88bdd662cce08eee7a17f5d.1348876882.git.josh@joshtriplett.org Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/Kconfig4
-rw-r--r--drivers/acpi/bgrt.c76
2 files changed, 11 insertions, 69 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 80998958cf45..119d58db8342 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -385,8 +385,8 @@ config ACPI_CUSTOM_METHOD
385 to override that restriction). 385 to override that restriction).
386 386
387config ACPI_BGRT 387config ACPI_BGRT
388 tristate "Boottime Graphics Resource Table support" 388 bool "Boottime Graphics Resource Table support"
389 default n 389 depends on EFI
390 help 390 help
391 This driver adds support for exposing the ACPI Boottime Graphics 391 This driver adds support for exposing the ACPI Boottime Graphics
392 Resource Table, which allows the operating system to obtain 392 Resource Table, which allows the operating system to obtain
diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
index 6680df36b963..be6039958545 100644
--- a/drivers/acpi/bgrt.c
+++ b/drivers/acpi/bgrt.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright 2012 Red Hat, Inc <mjg@redhat.com> 2 * Copyright 2012 Red Hat, Inc <mjg@redhat.com>
3 * Copyright 2012 Intel Corporation
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as 6 * it under the terms of the GNU General Public License version 2 as
@@ -11,20 +12,10 @@
11#include <linux/init.h> 12#include <linux/init.h>
12#include <linux/device.h> 13#include <linux/device.h>
13#include <linux/sysfs.h> 14#include <linux/sysfs.h>
14#include <linux/io.h> 15#include <linux/efi-bgrt.h>
15#include <acpi/acpi.h>
16#include <acpi/acpi_bus.h>
17 16
18static struct acpi_table_bgrt *bgrt_tab;
19static struct kobject *bgrt_kobj; 17static struct kobject *bgrt_kobj;
20 18
21struct bmp_header {
22 u16 id;
23 u32 size;
24} __attribute ((packed));
25
26static struct bmp_header bmp_header;
27
28static ssize_t show_version(struct device *dev, 19static ssize_t show_version(struct device *dev,
29 struct device_attribute *attr, char *buf) 20 struct device_attribute *attr, char *buf)
30{ 21{
@@ -63,18 +54,7 @@ static DEVICE_ATTR(yoffset, S_IRUGO, show_yoffset, NULL);
63static ssize_t show_image(struct file *file, struct kobject *kobj, 54static ssize_t show_image(struct file *file, struct kobject *kobj,
64 struct bin_attribute *attr, char *buf, loff_t off, size_t count) 55 struct bin_attribute *attr, char *buf, loff_t off, size_t count)
65{ 56{
66 int size = attr->size; 57 memcpy(buf, attr->private + off, count);
67 void __iomem *image = attr->private;
68
69 if (off >= size) {
70 count = 0;
71 } else {
72 if (off + count > size)
73 count = size - off;
74
75 memcpy_fromio(buf, image+off, count);
76 }
77
78 return count; 58 return count;
79} 59}
80 60
@@ -101,45 +81,18 @@ static struct attribute_group bgrt_attribute_group = {
101 81
102static int __init bgrt_init(void) 82static int __init bgrt_init(void)
103{ 83{
104 acpi_status status;
105 int ret; 84 int ret;
106 void __iomem *bgrt;
107 85
108 if (acpi_disabled) 86 if (!bgrt_image)
109 return -ENODEV;
110
111 status = acpi_get_table("BGRT", 0,
112 (struct acpi_table_header **)&bgrt_tab);
113
114 if (ACPI_FAILURE(status))
115 return -ENODEV; 87 return -ENODEV;
116 88
117 sysfs_bin_attr_init(&image_attr); 89 sysfs_bin_attr_init(&image_attr);
118 90 image_attr.private = bgrt_image;
119 bgrt = ioremap(bgrt_tab->image_address, sizeof(struct bmp_header)); 91 image_attr.size = bgrt_image_size;
120
121 if (!bgrt) {
122 ret = -EINVAL;
123 goto out_err;
124 }
125
126 memcpy_fromio(&bmp_header, bgrt, sizeof(bmp_header));
127 image_attr.size = bmp_header.size;
128 iounmap(bgrt);
129
130 image_attr.private = ioremap(bgrt_tab->image_address, image_attr.size);
131
132 if (!image_attr.private) {
133 ret = -EINVAL;
134 goto out_err;
135 }
136
137 92
138 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj); 93 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
139 if (!bgrt_kobj) { 94 if (!bgrt_kobj)
140 ret = -EINVAL; 95 return -EINVAL;
141 goto out_iounmap;
142 }
143 96
144 ret = sysfs_create_group(bgrt_kobj, &bgrt_attribute_group); 97 ret = sysfs_create_group(bgrt_kobj, &bgrt_attribute_group);
145 if (ret) 98 if (ret)
@@ -155,22 +108,11 @@ out_group:
155 sysfs_remove_group(bgrt_kobj, &bgrt_attribute_group); 108 sysfs_remove_group(bgrt_kobj, &bgrt_attribute_group);
156out_kobject: 109out_kobject:
157 kobject_put(bgrt_kobj); 110 kobject_put(bgrt_kobj);
158out_iounmap:
159 iounmap(image_attr.private);
160out_err:
161 return ret; 111 return ret;
162} 112}
163 113
164static void __exit bgrt_exit(void)
165{
166 iounmap(image_attr.private);
167 sysfs_remove_group(bgrt_kobj, &bgrt_attribute_group);
168 sysfs_remove_bin_file(bgrt_kobj, &image_attr);
169}
170
171module_init(bgrt_init); 114module_init(bgrt_init);
172module_exit(bgrt_exit);
173 115
174MODULE_AUTHOR("Matthew Garrett"); 116MODULE_AUTHOR("Matthew Garrett, Josh Triplett <josh@joshtriplett.org>");
175MODULE_DESCRIPTION("BGRT boot graphic support"); 117MODULE_DESCRIPTION("BGRT boot graphic support");
176MODULE_LICENSE("GPL"); 118MODULE_LICENSE("GPL");