License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2007-11-29 08:21:55 +08:00
|
|
|
/*
|
|
|
|
* Framebuffer driver for EFI/UEFI based system
|
|
|
|
*
|
|
|
|
* (c) 2006 Edgar Hucek <gimli@dark-green.com>
|
|
|
|
* Original efi driver written by Gerd Knorr <kraxel@goldbach.in-berlin.de>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-12-20 00:05:09 +08:00
|
|
|
#include <linux/aperture.h>
|
2007-11-29 08:21:55 +08:00
|
|
|
#include <linux/kernel.h>
|
2016-04-26 04:06:50 +08:00
|
|
|
#include <linux/efi.h>
|
2018-07-03 23:43:10 +08:00
|
|
|
#include <linux/efi-bgrt.h>
|
2007-11-29 08:21:55 +08:00
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/fb.h>
|
2017-04-04 23:27:44 +08:00
|
|
|
#include <linux/pci.h>
|
2007-11-29 08:21:55 +08:00
|
|
|
#include <linux/platform_device.h>
|
2018-07-03 23:43:10 +08:00
|
|
|
#include <linux/printk.h>
|
2007-11-29 08:21:55 +08:00
|
|
|
#include <linux/screen_info.h>
|
2021-01-29 16:43:27 +08:00
|
|
|
#include <linux/pm_runtime.h>
|
2007-11-29 08:21:55 +08:00
|
|
|
#include <video/vga.h>
|
2016-04-26 04:06:50 +08:00
|
|
|
#include <asm/efi.h>
|
2017-11-26 03:35:52 +08:00
|
|
|
#include <drm/drm_utils.h> /* For drm_get_panel_orientation_quirk */
|
|
|
|
#include <drm/drm_connector.h> /* For DRM_MODE_PANEL_ORIENTATION_* */
|
2007-11-29 08:21:55 +08:00
|
|
|
|
2018-07-03 23:43:10 +08:00
|
|
|
struct bmp_file_header {
|
|
|
|
u16 id;
|
|
|
|
u32 file_size;
|
|
|
|
u32 reserved;
|
|
|
|
u32 bitmap_offset;
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct bmp_dib_header {
|
|
|
|
u32 dib_header_size;
|
|
|
|
s32 width;
|
|
|
|
s32 height;
|
|
|
|
u16 planes;
|
|
|
|
u16 bpp;
|
|
|
|
u32 compression;
|
|
|
|
u32 bitmap_size;
|
|
|
|
u32 horz_resolution;
|
|
|
|
u32 vert_resolution;
|
|
|
|
u32 colors_used;
|
|
|
|
u32 colors_important;
|
|
|
|
} __packed;
|
|
|
|
|
2018-09-27 00:11:22 +08:00
|
|
|
static bool use_bgrt = true;
|
2011-05-26 22:13:32 +08:00
|
|
|
static bool request_mem_succeeded = false;
|
2018-07-11 17:40:40 +08:00
|
|
|
static u64 mem_flags = EFI_MEMORY_WC | EFI_MEMORY_UC;
|
2011-05-26 22:13:32 +08:00
|
|
|
|
2021-08-09 21:31:46 +08:00
|
|
|
static struct pci_dev *efifb_pci_dev; /* dev with BAR covering the efifb */
|
|
|
|
|
2022-12-20 00:05:08 +08:00
|
|
|
struct efifb_par {
|
|
|
|
u32 pseudo_palette[16];
|
2022-12-20 00:05:09 +08:00
|
|
|
resource_size_t base;
|
|
|
|
resource_size_t size;
|
2022-12-20 00:05:08 +08:00
|
|
|
};
|
|
|
|
|
2012-12-22 05:07:39 +08:00
|
|
|
static struct fb_var_screeninfo efifb_defined = {
|
2007-11-29 08:21:55 +08:00
|
|
|
.activate = FB_ACTIVATE_NOW,
|
|
|
|
.height = -1,
|
|
|
|
.width = -1,
|
|
|
|
.right_margin = 32,
|
|
|
|
.upper_margin = 16,
|
|
|
|
.lower_margin = 4,
|
|
|
|
.vsync_len = 4,
|
|
|
|
.vmode = FB_VMODE_NONINTERLACED,
|
|
|
|
};
|
|
|
|
|
2012-12-22 05:07:39 +08:00
|
|
|
static struct fb_fix_screeninfo efifb_fix = {
|
2007-11-29 08:21:55 +08:00
|
|
|
.id = "EFI VGA",
|
|
|
|
.type = FB_TYPE_PACKED_PIXELS,
|
|
|
|
.accel = FB_ACCEL_NONE,
|
|
|
|
.visual = FB_VISUAL_TRUECOLOR,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int efifb_setcolreg(unsigned regno, unsigned red, unsigned green,
|
|
|
|
unsigned blue, unsigned transp,
|
|
|
|
struct fb_info *info)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Set a single color register. The values supplied are
|
|
|
|
* already rounded down to the hardware's capabilities
|
|
|
|
* (according to the entries in the `var' structure). Return
|
|
|
|
* != 0 for invalid regno.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (regno >= info->cmap.len)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (regno < 16) {
|
2016-06-14 01:15:59 +08:00
|
|
|
red >>= 16 - info->var.red.length;
|
|
|
|
green >>= 16 - info->var.green.length;
|
|
|
|
blue >>= 16 - info->var.blue.length;
|
2007-11-29 08:21:55 +08:00
|
|
|
((u32 *)(info->pseudo_palette))[regno] =
|
|
|
|
(red << info->var.red.offset) |
|
|
|
|
(green << info->var.green.offset) |
|
|
|
|
(blue << info->var.blue.offset);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-07-03 23:43:10 +08:00
|
|
|
/*
|
|
|
|
* If fbcon deffered console takeover is configured, the intent is for the
|
|
|
|
* framebuffer to show the boot graphics (e.g. vendor logo) until there is some
|
|
|
|
* (error) message to display. But the boot graphics may have been destroyed by
|
|
|
|
* e.g. option ROM output, detect this and restore the boot graphics.
|
|
|
|
*/
|
|
|
|
#if defined CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER && \
|
|
|
|
defined CONFIG_ACPI_BGRT
|
|
|
|
static void efifb_copy_bmp(u8 *src, u32 *dst, int width, struct screen_info *si)
|
|
|
|
{
|
|
|
|
u8 r, g, b;
|
|
|
|
|
|
|
|
while (width--) {
|
|
|
|
b = *src++;
|
|
|
|
g = *src++;
|
|
|
|
r = *src++;
|
|
|
|
*dst++ = (r << si->red_pos) |
|
|
|
|
(g << si->green_pos) |
|
|
|
|
(b << si->blue_pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-25 01:11:28 +08:00
|
|
|
#ifdef CONFIG_X86
|
|
|
|
/*
|
|
|
|
* On x86 some firmwares use a low non native resolution for the display when
|
|
|
|
* they have shown some text messages. While keeping the bgrt filled with info
|
|
|
|
* for the native resolution. If the bgrt image intended for the native
|
|
|
|
* resolution still fits, it will be displayed very close to the right edge of
|
|
|
|
* the display looking quite bad. This function checks for this.
|
|
|
|
*/
|
|
|
|
static bool efifb_bgrt_sanity_check(struct screen_info *si, u32 bmp_width)
|
|
|
|
{
|
2019-07-21 21:19:18 +08:00
|
|
|
/*
|
|
|
|
* All x86 firmwares horizontally center the image (the yoffset
|
|
|
|
* calculations differ between boards, but xoffset is predictable).
|
|
|
|
*/
|
|
|
|
u32 expected_xoffset = (si->lfb_width - bmp_width) / 2;
|
2018-07-25 01:11:28 +08:00
|
|
|
|
2019-07-21 21:19:18 +08:00
|
|
|
return bgrt_tab.image_offset_x == expected_xoffset;
|
2018-07-25 01:11:28 +08:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
static bool efifb_bgrt_sanity_check(struct screen_info *si, u32 bmp_width)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-07-03 23:43:10 +08:00
|
|
|
static void efifb_show_boot_graphics(struct fb_info *info)
|
|
|
|
{
|
2020-12-07 03:02:45 +08:00
|
|
|
u32 bmp_width, bmp_height, bmp_pitch, dst_x, y, src_y;
|
2018-07-03 23:43:10 +08:00
|
|
|
struct screen_info *si = &screen_info;
|
|
|
|
struct bmp_file_header *file_header;
|
|
|
|
struct bmp_dib_header *dib_header;
|
|
|
|
void *bgrt_image = NULL;
|
|
|
|
u8 *dst = info->screen_base;
|
|
|
|
|
2018-09-27 00:11:22 +08:00
|
|
|
if (!use_bgrt)
|
|
|
|
return;
|
|
|
|
|
2018-07-03 23:43:10 +08:00
|
|
|
if (!bgrt_tab.image_address) {
|
|
|
|
pr_info("efifb: No BGRT, not showing boot graphics\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-21 21:13:14 +08:00
|
|
|
if (bgrt_tab.status & 0x06) {
|
|
|
|
pr_info("efifb: BGRT rotation bits set, not showing boot graphics\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-03 23:43:10 +08:00
|
|
|
/* Avoid flashing the logo if we're going to print std probe messages */
|
|
|
|
if (console_loglevel > CONSOLE_LOGLEVEL_QUIET)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* bgrt_tab.status is unreliable, so we don't check it */
|
|
|
|
|
|
|
|
if (si->lfb_depth != 32) {
|
|
|
|
pr_info("efifb: not 32 bits, not showing boot graphics\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bgrt_image = memremap(bgrt_tab.image_address, bgrt_image_size,
|
|
|
|
MEMREMAP_WB);
|
|
|
|
if (!bgrt_image) {
|
|
|
|
pr_warn("efifb: Ignoring BGRT: failed to map image memory\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bgrt_image_size < (sizeof(*file_header) + sizeof(*dib_header)))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
file_header = bgrt_image;
|
|
|
|
if (file_header->id != 0x4d42 || file_header->reserved != 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
dib_header = bgrt_image + sizeof(*file_header);
|
|
|
|
if (dib_header->dib_header_size != 40 || dib_header->width < 0 ||
|
|
|
|
dib_header->planes != 1 || dib_header->bpp != 24 ||
|
|
|
|
dib_header->compression != 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
bmp_width = dib_header->width;
|
|
|
|
bmp_height = abs(dib_header->height);
|
|
|
|
bmp_pitch = round_up(3 * bmp_width, 4);
|
|
|
|
|
|
|
|
if ((file_header->bitmap_offset + bmp_pitch * bmp_height) >
|
|
|
|
bgrt_image_size)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if ((bgrt_tab.image_offset_x + bmp_width) > si->lfb_width ||
|
|
|
|
(bgrt_tab.image_offset_y + bmp_height) > si->lfb_height)
|
|
|
|
goto error;
|
|
|
|
|
2018-07-25 01:11:28 +08:00
|
|
|
if (!efifb_bgrt_sanity_check(si, bmp_width))
|
|
|
|
goto error;
|
|
|
|
|
2018-07-03 23:43:10 +08:00
|
|
|
pr_info("efifb: showing boot graphics\n");
|
|
|
|
|
|
|
|
for (y = 0; y < si->lfb_height; y++, dst += si->lfb_linelength) {
|
|
|
|
/* Only background? */
|
|
|
|
if (y < bgrt_tab.image_offset_y ||
|
|
|
|
y >= (bgrt_tab.image_offset_y + bmp_height)) {
|
|
|
|
memset(dst, 0, 4 * si->lfb_width);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
src_y = y - bgrt_tab.image_offset_y;
|
|
|
|
/* Positive header height means upside down row order */
|
|
|
|
if (dib_header->height > 0)
|
|
|
|
src_y = (bmp_height - 1) - src_y;
|
|
|
|
|
|
|
|
memset(dst, 0, bgrt_tab.image_offset_x * 4);
|
|
|
|
dst_x = bgrt_tab.image_offset_x;
|
|
|
|
efifb_copy_bmp(bgrt_image + file_header->bitmap_offset +
|
|
|
|
src_y * bmp_pitch,
|
|
|
|
(u32 *)dst + dst_x, bmp_width, si);
|
|
|
|
dst_x += bmp_width;
|
|
|
|
memset((u32 *)dst + dst_x, 0, (si->lfb_width - dst_x) * 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
memunmap(bgrt_image);
|
|
|
|
return;
|
|
|
|
|
|
|
|
error:
|
|
|
|
memunmap(bgrt_image);
|
|
|
|
pr_warn("efifb: Ignoring BGRT: unexpected or invalid BMP data\n");
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static inline void efifb_show_boot_graphics(struct fb_info *info) {}
|
|
|
|
#endif
|
|
|
|
|
2022-05-06 06:05:40 +08:00
|
|
|
/*
|
|
|
|
* fb_ops.fb_destroy is called by the last put_fb_info() call at the end
|
|
|
|
* of unregister_framebuffer() or fb_release(). Do any cleanup here.
|
|
|
|
*/
|
2010-02-23 04:44:22 +08:00
|
|
|
static void efifb_destroy(struct fb_info *info)
|
|
|
|
{
|
2022-12-20 00:05:09 +08:00
|
|
|
struct efifb_par *par = info->par;
|
|
|
|
|
2021-08-09 21:31:46 +08:00
|
|
|
if (efifb_pci_dev)
|
|
|
|
pm_runtime_put(&efifb_pci_dev->dev);
|
|
|
|
|
2018-07-11 17:40:40 +08:00
|
|
|
if (info->screen_base) {
|
|
|
|
if (mem_flags & (EFI_MEMORY_UC | EFI_MEMORY_WC))
|
|
|
|
iounmap(info->screen_base);
|
|
|
|
else
|
|
|
|
memunmap(info->screen_base);
|
|
|
|
}
|
2022-05-06 06:05:40 +08:00
|
|
|
|
2011-05-26 22:13:32 +08:00
|
|
|
if (request_mem_succeeded)
|
2022-12-20 00:05:09 +08:00
|
|
|
release_mem_region(par->base, par->size);
|
2013-07-25 23:48:11 +08:00
|
|
|
fb_dealloc_cmap(&info->cmap);
|
2022-05-06 21:22:25 +08:00
|
|
|
|
|
|
|
framebuffer_release(info);
|
2010-02-23 04:44:22 +08:00
|
|
|
}
|
|
|
|
|
2019-12-04 00:38:50 +08:00
|
|
|
static const struct fb_ops efifb_ops = {
|
2007-11-29 08:21:55 +08:00
|
|
|
.owner = THIS_MODULE,
|
2010-02-23 04:44:22 +08:00
|
|
|
.fb_destroy = efifb_destroy,
|
2007-11-29 08:21:55 +08:00
|
|
|
.fb_setcolreg = efifb_setcolreg,
|
|
|
|
.fb_fillrect = cfb_fillrect,
|
|
|
|
.fb_copyarea = cfb_copyarea,
|
|
|
|
.fb_imageblit = cfb_imageblit,
|
|
|
|
};
|
|
|
|
|
2013-08-02 20:05:26 +08:00
|
|
|
static int efifb_setup(char *options)
|
2008-10-16 13:03:43 +08:00
|
|
|
{
|
|
|
|
char *this_opt;
|
|
|
|
|
2012-04-17 04:26:05 +08:00
|
|
|
if (options && *options) {
|
|
|
|
while ((this_opt = strsep(&options, ",")) != NULL) {
|
|
|
|
if (!*this_opt) continue;
|
2008-10-16 13:03:43 +08:00
|
|
|
|
2016-04-26 04:06:50 +08:00
|
|
|
efifb_setup_from_dmi(&screen_info, this_opt);
|
|
|
|
|
2012-04-17 04:26:05 +08:00
|
|
|
if (!strncmp(this_opt, "base:", 5))
|
|
|
|
screen_info.lfb_base = simple_strtoul(this_opt+5, NULL, 0);
|
|
|
|
else if (!strncmp(this_opt, "stride:", 7))
|
|
|
|
screen_info.lfb_linelength = simple_strtoul(this_opt+7, NULL, 0) * 4;
|
|
|
|
else if (!strncmp(this_opt, "height:", 7))
|
|
|
|
screen_info.lfb_height = simple_strtoul(this_opt+7, NULL, 0);
|
|
|
|
else if (!strncmp(this_opt, "width:", 6))
|
|
|
|
screen_info.lfb_width = simple_strtoul(this_opt+6, NULL, 0);
|
efifb: allow user to disable write combined mapping.
This patch allows the user to disable write combined mapping
of the efifb framebuffer console using an nowc option.
A customer noticed major slowdowns while logging to the console
with write combining enabled, on other tasks running on the same
CPU. (10x or greater slow down on all other cores on the same CPU
as is doing the logging).
I reproduced this on a machine with dual CPUs.
Intel(R) Xeon(R) CPU E5-2609 v3 @ 1.90GHz (6 core)
I wrote a test that just mmaps the pci bar and writes to it in
a loop, while this was running in the background one a single
core with (taskset -c 1), building a kernel up to init/version.o
(taskset -c 8) went from 13s to 133s or so. I've yet to explain
why this occurs or what is going wrong I haven't managed to find
a perf command that in any way gives insight into this.
11,885,070,715 instructions # 1.39 insns per cycle
vs
12,082,592,342 instructions # 0.13 insns per cycle
is the only thing I've spotted of interest, I've tried at least:
dTLB-stores,dTLB-store-misses,L1-dcache-stores,LLC-store,LLC-store-misses,LLC-load-misses,LLC-loads,\mem-loads,mem-stores,iTLB-loads,iTLB-load-misses,cache-references,cache-misses
For now it seems at least a good idea to allow a user to disable write
combining if they see this until we can figure it out.
Note also most users get a real framebuffer driver loaded when kms
kicks in, it just happens on these machines the kernel didn't support
the gpu specific driver.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Peter Jones <pjones@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
2017-08-01 00:45:41 +08:00
|
|
|
else if (!strcmp(this_opt, "nowc"))
|
2018-07-11 17:40:40 +08:00
|
|
|
mem_flags &= ~EFI_MEMORY_WC;
|
2018-09-27 00:11:22 +08:00
|
|
|
else if (!strcmp(this_opt, "nobgrt"))
|
|
|
|
use_bgrt = false;
|
2008-10-16 13:03:43 +08:00
|
|
|
}
|
|
|
|
}
|
2012-04-17 04:26:05 +08:00
|
|
|
|
2008-10-16 13:03:43 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-08-25 23:32:55 +08:00
|
|
|
static inline bool fb_base_is_valid(void)
|
|
|
|
{
|
|
|
|
if (screen_info.lfb_base)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!(screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (screen_info.ext_lfb_base)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-10-18 22:33:17 +08:00
|
|
|
#define efifb_attr_decl(name, fmt) \
|
|
|
|
static ssize_t name##_show(struct device *dev, \
|
|
|
|
struct device_attribute *attr, \
|
|
|
|
char *buf) \
|
|
|
|
{ \
|
|
|
|
return sprintf(buf, fmt "\n", (screen_info.lfb_##name)); \
|
|
|
|
} \
|
|
|
|
static DEVICE_ATTR_RO(name)
|
|
|
|
|
|
|
|
efifb_attr_decl(base, "0x%x");
|
|
|
|
efifb_attr_decl(linelength, "%u");
|
|
|
|
efifb_attr_decl(height, "%u");
|
|
|
|
efifb_attr_decl(width, "%u");
|
|
|
|
efifb_attr_decl(depth, "%u");
|
|
|
|
|
|
|
|
static struct attribute *efifb_attrs[] = {
|
|
|
|
&dev_attr_base.attr,
|
|
|
|
&dev_attr_linelength.attr,
|
|
|
|
&dev_attr_width.attr,
|
|
|
|
&dev_attr_height.attr,
|
|
|
|
&dev_attr_depth.attr,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
ATTRIBUTE_GROUPS(efifb);
|
|
|
|
|
2017-04-04 23:27:44 +08:00
|
|
|
static bool pci_dev_disabled; /* FB base matches BAR of a disabled device */
|
|
|
|
|
drivers/fbdev/efifb: Allow BAR to be moved instead of claiming it
On UEFI systems, the firmware may expose a Graphics Output Protocol (GOP)
instance to which the efifb driver attempts to attach in order to provide
a minimal, unaccelerated framebuffer. The GOP protocol itself is not very
sophisticated, and only describes the offset and size of the framebuffer
in memory, and the pixel format.
If the GOP framebuffer is provided by a PCI device, it will have been
configured and enabled by the UEFI firmware, and the GOP protocol will
simply point into a live BAR region. However, the GOP protocol itself does
not describe this relation, and so we have to take care not to reconfigure
the BAR without taking efifb's dependency on it into account.
Commit:
55d728a40d36 ("efi/fb: Avoid reconfiguration of BAR that covers the framebuffer")
attempted to do so by claiming the BAR resource early on, which prevents the
PCI resource allocation routines from changing it. However, it turns out
that this only works if the PCI device is not behind any bridges, since
the bridge resources need to be claimed first.
So instead, allow the BAR to be moved, but make the efifb driver deal
with that gracefully. So record the resource that covers the BAR early
on, and if it turns out to have moved by the time we probe the efifb
driver, update the framebuffer address accordingly.
While this is less likely to occur on x86, given that the firmware's
PCI resource allocation is more likely to be preserved, this is a
worthwhile sanity check to have in place, and so let's remove the
preprocessor conditional that makes it !X86 only.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Peter Jones <pjones@redhat.com>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170818194947.19347-8-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-08-19 03:49:40 +08:00
|
|
|
static struct resource *bar_resource;
|
|
|
|
static u64 bar_offset;
|
|
|
|
|
2013-08-02 20:05:26 +08:00
|
|
|
static int efifb_probe(struct platform_device *dev)
|
2007-11-29 08:21:55 +08:00
|
|
|
{
|
|
|
|
struct fb_info *info;
|
2022-12-20 00:05:08 +08:00
|
|
|
struct efifb_par *par;
|
2017-11-26 03:35:52 +08:00
|
|
|
int err, orientation;
|
2007-11-29 08:21:55 +08:00
|
|
|
unsigned int size_vmode;
|
|
|
|
unsigned int size_remap;
|
|
|
|
unsigned int size_total;
|
2013-08-02 20:05:26 +08:00
|
|
|
char *option = NULL;
|
2018-07-11 17:40:40 +08:00
|
|
|
efi_memory_desc_t md;
|
2013-08-02 20:05:26 +08:00
|
|
|
|
2017-04-04 23:27:44 +08:00
|
|
|
if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI || pci_dev_disabled)
|
2013-08-02 20:05:26 +08:00
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if (fb_get_options("efifb", &option))
|
|
|
|
return -ENODEV;
|
|
|
|
efifb_setup(option);
|
|
|
|
|
|
|
|
/* We don't get linelength from UGA Draw Protocol, only from
|
|
|
|
* EFI Graphics Protocol. So if it's not in DMI, and it's not
|
|
|
|
* passed in from the user, we really can't use the framebuffer.
|
|
|
|
*/
|
|
|
|
if (!screen_info.lfb_linelength)
|
|
|
|
return -ENODEV;
|
2008-10-16 13:03:43 +08:00
|
|
|
|
|
|
|
if (!screen_info.lfb_depth)
|
|
|
|
screen_info.lfb_depth = 32;
|
|
|
|
if (!screen_info.pages)
|
|
|
|
screen_info.pages = 1;
|
2015-08-25 23:32:55 +08:00
|
|
|
if (!fb_base_is_valid()) {
|
2009-04-14 05:39:44 +08:00
|
|
|
printk(KERN_DEBUG "efifb: invalid framebuffer address\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
printk(KERN_INFO "efifb: probing for efifb\n");
|
2008-10-16 13:03:43 +08:00
|
|
|
|
|
|
|
/* just assume they're all unset if any are */
|
|
|
|
if (!screen_info.blue_size) {
|
|
|
|
screen_info.blue_size = 8;
|
|
|
|
screen_info.blue_pos = 0;
|
|
|
|
screen_info.green_size = 8;
|
|
|
|
screen_info.green_pos = 8;
|
|
|
|
screen_info.red_size = 8;
|
|
|
|
screen_info.red_pos = 16;
|
|
|
|
screen_info.rsvd_size = 8;
|
|
|
|
screen_info.rsvd_pos = 24;
|
|
|
|
}
|
2007-11-29 08:21:55 +08:00
|
|
|
|
|
|
|
efifb_fix.smem_start = screen_info.lfb_base;
|
2015-08-25 23:32:55 +08:00
|
|
|
|
|
|
|
if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE) {
|
|
|
|
u64 ext_lfb_base;
|
|
|
|
|
|
|
|
ext_lfb_base = (u64)(unsigned long)screen_info.ext_lfb_base << 32;
|
|
|
|
efifb_fix.smem_start |= ext_lfb_base;
|
|
|
|
}
|
|
|
|
|
drivers/fbdev/efifb: Allow BAR to be moved instead of claiming it
On UEFI systems, the firmware may expose a Graphics Output Protocol (GOP)
instance to which the efifb driver attempts to attach in order to provide
a minimal, unaccelerated framebuffer. The GOP protocol itself is not very
sophisticated, and only describes the offset and size of the framebuffer
in memory, and the pixel format.
If the GOP framebuffer is provided by a PCI device, it will have been
configured and enabled by the UEFI firmware, and the GOP protocol will
simply point into a live BAR region. However, the GOP protocol itself does
not describe this relation, and so we have to take care not to reconfigure
the BAR without taking efifb's dependency on it into account.
Commit:
55d728a40d36 ("efi/fb: Avoid reconfiguration of BAR that covers the framebuffer")
attempted to do so by claiming the BAR resource early on, which prevents the
PCI resource allocation routines from changing it. However, it turns out
that this only works if the PCI device is not behind any bridges, since
the bridge resources need to be claimed first.
So instead, allow the BAR to be moved, but make the efifb driver deal
with that gracefully. So record the resource that covers the BAR early
on, and if it turns out to have moved by the time we probe the efifb
driver, update the framebuffer address accordingly.
While this is less likely to occur on x86, given that the firmware's
PCI resource allocation is more likely to be preserved, this is a
worthwhile sanity check to have in place, and so let's remove the
preprocessor conditional that makes it !X86 only.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Peter Jones <pjones@redhat.com>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170818194947.19347-8-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-08-19 03:49:40 +08:00
|
|
|
if (bar_resource &&
|
|
|
|
bar_resource->start + bar_offset != efifb_fix.smem_start) {
|
|
|
|
dev_info(&efifb_pci_dev->dev,
|
|
|
|
"BAR has moved, updating efifb address\n");
|
|
|
|
efifb_fix.smem_start = bar_resource->start + bar_offset;
|
|
|
|
}
|
|
|
|
|
2007-11-29 08:21:55 +08:00
|
|
|
efifb_defined.bits_per_pixel = screen_info.lfb_depth;
|
|
|
|
efifb_defined.xres = screen_info.lfb_width;
|
|
|
|
efifb_defined.yres = screen_info.lfb_height;
|
|
|
|
efifb_fix.line_length = screen_info.lfb_linelength;
|
|
|
|
|
|
|
|
/* size_vmode -- that is the amount of memory needed for the
|
|
|
|
* used video mode, i.e. the minimum amount of
|
|
|
|
* memory we need. */
|
|
|
|
size_vmode = efifb_defined.yres * efifb_fix.line_length;
|
|
|
|
|
|
|
|
/* size_total -- all video memory we have. Used for
|
|
|
|
* entries, ressource allocation and bounds
|
|
|
|
* checking. */
|
|
|
|
size_total = screen_info.lfb_size;
|
|
|
|
if (size_total < size_vmode)
|
|
|
|
size_total = size_vmode;
|
|
|
|
|
|
|
|
/* size_remap -- the amount of video memory we are going to
|
|
|
|
* use for efifb. With modern cards it is no
|
|
|
|
* option to simply use size_total as that
|
|
|
|
* wastes plenty of kernel address space. */
|
|
|
|
size_remap = size_vmode * 2;
|
|
|
|
if (size_remap > size_total)
|
|
|
|
size_remap = size_total;
|
2008-10-16 13:03:43 +08:00
|
|
|
if (size_remap % PAGE_SIZE)
|
|
|
|
size_remap += PAGE_SIZE - (size_remap % PAGE_SIZE);
|
2007-11-29 08:21:55 +08:00
|
|
|
efifb_fix.smem_len = size_remap;
|
|
|
|
|
2008-10-16 13:03:43 +08:00
|
|
|
if (request_mem_region(efifb_fix.smem_start, size_remap, "efifb")) {
|
2011-05-26 22:13:32 +08:00
|
|
|
request_mem_succeeded = true;
|
2008-10-16 13:03:43 +08:00
|
|
|
} else {
|
2007-11-29 08:21:55 +08:00
|
|
|
/* We cannot make this fatal. Sometimes this comes from magic
|
|
|
|
spaces our resource handlers simply don't know about */
|
2016-10-18 22:33:17 +08:00
|
|
|
pr_warn("efifb: cannot reserve video memory at 0x%lx\n",
|
2007-11-29 08:21:55 +08:00
|
|
|
efifb_fix.smem_start);
|
2008-10-16 13:03:43 +08:00
|
|
|
}
|
2007-11-29 08:21:55 +08:00
|
|
|
|
2022-12-20 00:05:08 +08:00
|
|
|
info = framebuffer_alloc(sizeof(*par), &dev->dev);
|
2007-11-29 08:21:55 +08:00
|
|
|
if (!info) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto err_release_mem;
|
|
|
|
}
|
2014-01-23 22:14:55 +08:00
|
|
|
platform_set_drvdata(dev, info);
|
2022-12-20 00:05:08 +08:00
|
|
|
par = info->par;
|
|
|
|
info->pseudo_palette = par->pseudo_palette;
|
2007-11-29 08:21:55 +08:00
|
|
|
|
2022-12-20 00:05:09 +08:00
|
|
|
par->base = efifb_fix.smem_start;
|
|
|
|
par->size = size_remap;
|
2009-06-17 06:34:38 +08:00
|
|
|
|
2020-07-10 22:16:51 +08:00
|
|
|
if (efi_enabled(EFI_MEMMAP) &&
|
2019-03-29 03:34:26 +08:00
|
|
|
!efi_mem_desc_lookup(efifb_fix.smem_start, &md)) {
|
2018-07-11 17:40:40 +08:00
|
|
|
if ((efifb_fix.smem_start + efifb_fix.smem_len) >
|
|
|
|
(md.phys_addr + (md.num_pages << EFI_PAGE_SHIFT))) {
|
|
|
|
pr_err("efifb: video memory @ 0x%lx spans multiple EFI memory regions\n",
|
|
|
|
efifb_fix.smem_start);
|
|
|
|
err = -EIO;
|
|
|
|
goto err_release_fb;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If the UEFI memory map covers the efifb region, we may only
|
|
|
|
* remap it using the attributes the memory map prescribes.
|
|
|
|
*/
|
2019-05-17 05:31:59 +08:00
|
|
|
md.attribute &= EFI_MEMORY_UC | EFI_MEMORY_WC |
|
|
|
|
EFI_MEMORY_WT | EFI_MEMORY_WB;
|
|
|
|
if (md.attribute) {
|
|
|
|
mem_flags |= EFI_MEMORY_WT | EFI_MEMORY_WB;
|
|
|
|
mem_flags &= md.attribute;
|
|
|
|
}
|
2018-07-11 17:40:40 +08:00
|
|
|
}
|
|
|
|
if (mem_flags & EFI_MEMORY_WC)
|
|
|
|
info->screen_base = ioremap_wc(efifb_fix.smem_start,
|
|
|
|
efifb_fix.smem_len);
|
|
|
|
else if (mem_flags & EFI_MEMORY_UC)
|
|
|
|
info->screen_base = ioremap(efifb_fix.smem_start,
|
|
|
|
efifb_fix.smem_len);
|
|
|
|
else if (mem_flags & EFI_MEMORY_WT)
|
|
|
|
info->screen_base = memremap(efifb_fix.smem_start,
|
|
|
|
efifb_fix.smem_len, MEMREMAP_WT);
|
|
|
|
else if (mem_flags & EFI_MEMORY_WB)
|
|
|
|
info->screen_base = memremap(efifb_fix.smem_start,
|
|
|
|
efifb_fix.smem_len, MEMREMAP_WB);
|
2007-11-29 08:21:55 +08:00
|
|
|
if (!info->screen_base) {
|
2018-07-11 17:40:40 +08:00
|
|
|
pr_err("efifb: abort, cannot remap video memory 0x%x @ 0x%lx\n",
|
2007-11-29 08:21:55 +08:00
|
|
|
efifb_fix.smem_len, efifb_fix.smem_start);
|
|
|
|
err = -EIO;
|
2008-10-16 13:03:43 +08:00
|
|
|
goto err_release_fb;
|
2007-11-29 08:21:55 +08:00
|
|
|
}
|
|
|
|
|
2018-07-03 23:43:10 +08:00
|
|
|
efifb_show_boot_graphics(info);
|
|
|
|
|
2016-10-18 22:33:17 +08:00
|
|
|
pr_info("efifb: framebuffer at 0x%lx, using %dk, total %dk\n",
|
2016-05-12 07:57:47 +08:00
|
|
|
efifb_fix.smem_start, size_remap/1024, size_total/1024);
|
2016-10-18 22:33:17 +08:00
|
|
|
pr_info("efifb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
|
2007-11-29 08:21:55 +08:00
|
|
|
efifb_defined.xres, efifb_defined.yres,
|
|
|
|
efifb_defined.bits_per_pixel, efifb_fix.line_length,
|
|
|
|
screen_info.pages);
|
|
|
|
|
|
|
|
efifb_defined.xres_virtual = efifb_defined.xres;
|
|
|
|
efifb_defined.yres_virtual = efifb_fix.smem_len /
|
|
|
|
efifb_fix.line_length;
|
2016-10-18 22:33:17 +08:00
|
|
|
pr_info("efifb: scrolling: redraw\n");
|
2007-11-29 08:21:55 +08:00
|
|
|
efifb_defined.yres_virtual = efifb_defined.yres;
|
|
|
|
|
|
|
|
/* some dummy values for timing to make fbset happy */
|
|
|
|
efifb_defined.pixclock = 10000000 / efifb_defined.xres *
|
|
|
|
1000 / efifb_defined.yres;
|
|
|
|
efifb_defined.left_margin = (efifb_defined.xres / 8) & 0xf8;
|
|
|
|
efifb_defined.hsync_len = (efifb_defined.xres / 8) & 0xf8;
|
|
|
|
|
|
|
|
efifb_defined.red.offset = screen_info.red_pos;
|
|
|
|
efifb_defined.red.length = screen_info.red_size;
|
|
|
|
efifb_defined.green.offset = screen_info.green_pos;
|
|
|
|
efifb_defined.green.length = screen_info.green_size;
|
|
|
|
efifb_defined.blue.offset = screen_info.blue_pos;
|
|
|
|
efifb_defined.blue.length = screen_info.blue_size;
|
|
|
|
efifb_defined.transp.offset = screen_info.rsvd_pos;
|
|
|
|
efifb_defined.transp.length = screen_info.rsvd_size;
|
|
|
|
|
2016-10-18 22:33:17 +08:00
|
|
|
pr_info("efifb: %s: "
|
2007-11-29 08:21:55 +08:00
|
|
|
"size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
|
|
|
|
"Truecolor",
|
|
|
|
screen_info.rsvd_size,
|
|
|
|
screen_info.red_size,
|
|
|
|
screen_info.green_size,
|
|
|
|
screen_info.blue_size,
|
|
|
|
screen_info.rsvd_pos,
|
|
|
|
screen_info.red_pos,
|
|
|
|
screen_info.green_pos,
|
|
|
|
screen_info.blue_pos);
|
|
|
|
|
|
|
|
efifb_fix.ypanstep = 0;
|
|
|
|
efifb_fix.ywrapstep = 0;
|
|
|
|
|
|
|
|
info->fbops = &efifb_ops;
|
|
|
|
info->var = efifb_defined;
|
|
|
|
info->fix = efifb_fix;
|
2022-12-20 00:05:09 +08:00
|
|
|
info->flags = FBINFO_FLAG_DEFAULT;
|
2007-11-29 08:21:55 +08:00
|
|
|
|
2017-11-26 03:35:52 +08:00
|
|
|
orientation = drm_get_panel_orientation_quirk(efifb_defined.xres,
|
|
|
|
efifb_defined.yres);
|
|
|
|
switch (orientation) {
|
|
|
|
default:
|
|
|
|
info->fbcon_rotate_hint = FB_ROTATE_UR;
|
|
|
|
break;
|
|
|
|
case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
|
|
|
|
info->fbcon_rotate_hint = FB_ROTATE_UD;
|
|
|
|
break;
|
|
|
|
case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
|
|
|
|
info->fbcon_rotate_hint = FB_ROTATE_CCW;
|
|
|
|
break;
|
|
|
|
case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
|
|
|
|
info->fbcon_rotate_hint = FB_ROTATE_CW;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-10-18 22:33:17 +08:00
|
|
|
err = sysfs_create_groups(&dev->dev.kobj, efifb_groups);
|
|
|
|
if (err) {
|
|
|
|
pr_err("efifb: cannot add sysfs attrs\n");
|
2007-11-29 08:21:55 +08:00
|
|
|
goto err_unmap;
|
|
|
|
}
|
2016-10-18 22:33:17 +08:00
|
|
|
err = fb_alloc_cmap(&info->cmap, 256, 0);
|
|
|
|
if (err < 0) {
|
|
|
|
pr_err("efifb: cannot allocate colormap\n");
|
|
|
|
goto err_groups;
|
|
|
|
}
|
2021-08-09 21:31:46 +08:00
|
|
|
|
|
|
|
if (efifb_pci_dev)
|
|
|
|
WARN_ON(pm_runtime_get_sync(&efifb_pci_dev->dev) < 0);
|
|
|
|
|
2022-12-20 00:05:09 +08:00
|
|
|
err = devm_aperture_acquire_for_platform_device(dev, par->base, par->size);
|
|
|
|
if (err) {
|
|
|
|
pr_err("efifb: cannot acquire aperture\n");
|
|
|
|
goto err_put_rpm_ref;
|
|
|
|
}
|
2016-10-18 22:33:17 +08:00
|
|
|
err = register_framebuffer(info);
|
|
|
|
if (err < 0) {
|
|
|
|
pr_err("efifb: cannot register framebuffer\n");
|
2021-08-09 21:31:46 +08:00
|
|
|
goto err_put_rpm_ref;
|
2007-11-29 08:21:55 +08:00
|
|
|
}
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_info(info, "%s frame buffer device\n", info->fix.id);
|
2007-11-29 08:21:55 +08:00
|
|
|
return 0;
|
|
|
|
|
2021-08-09 21:31:46 +08:00
|
|
|
err_put_rpm_ref:
|
|
|
|
if (efifb_pci_dev)
|
|
|
|
pm_runtime_put(&efifb_pci_dev->dev);
|
|
|
|
|
2007-11-29 08:21:55 +08:00
|
|
|
fb_dealloc_cmap(&info->cmap);
|
2016-10-18 22:33:17 +08:00
|
|
|
err_groups:
|
|
|
|
sysfs_remove_groups(&dev->dev.kobj, efifb_groups);
|
2007-11-29 08:21:55 +08:00
|
|
|
err_unmap:
|
2018-07-11 17:40:40 +08:00
|
|
|
if (mem_flags & (EFI_MEMORY_UC | EFI_MEMORY_WC))
|
|
|
|
iounmap(info->screen_base);
|
|
|
|
else
|
|
|
|
memunmap(info->screen_base);
|
2008-10-16 13:03:43 +08:00
|
|
|
err_release_fb:
|
2007-11-29 08:21:55 +08:00
|
|
|
framebuffer_release(info);
|
|
|
|
err_release_mem:
|
2011-05-26 22:13:32 +08:00
|
|
|
if (request_mem_succeeded)
|
2008-10-16 13:03:43 +08:00
|
|
|
release_mem_region(efifb_fix.smem_start, size_total);
|
2007-11-29 08:21:55 +08:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2023-03-19 07:53:50 +08:00
|
|
|
static void efifb_remove(struct platform_device *pdev)
|
2014-01-23 22:14:55 +08:00
|
|
|
{
|
|
|
|
struct fb_info *info = platform_get_drvdata(pdev);
|
|
|
|
|
2022-05-06 06:05:40 +08:00
|
|
|
/* efifb_destroy takes care of info cleanup */
|
2014-01-23 22:14:55 +08:00
|
|
|
unregister_framebuffer(info);
|
2016-10-18 22:33:17 +08:00
|
|
|
sysfs_remove_groups(&pdev->dev.kobj, efifb_groups);
|
2014-01-23 22:14:55 +08:00
|
|
|
}
|
|
|
|
|
2007-11-29 08:21:55 +08:00
|
|
|
static struct platform_driver efifb_driver = {
|
2013-08-02 20:05:26 +08:00
|
|
|
.driver = {
|
|
|
|
.name = "efi-framebuffer",
|
2007-11-29 08:21:55 +08:00
|
|
|
},
|
2013-08-02 20:05:26 +08:00
|
|
|
.probe = efifb_probe,
|
2023-03-19 07:53:50 +08:00
|
|
|
.remove_new = efifb_remove,
|
2007-11-29 08:21:55 +08:00
|
|
|
};
|
|
|
|
|
2016-04-26 04:06:51 +08:00
|
|
|
builtin_platform_driver(efifb_driver);
|
2017-04-04 23:27:44 +08:00
|
|
|
|
drivers/fbdev/efifb: Allow BAR to be moved instead of claiming it
On UEFI systems, the firmware may expose a Graphics Output Protocol (GOP)
instance to which the efifb driver attempts to attach in order to provide
a minimal, unaccelerated framebuffer. The GOP protocol itself is not very
sophisticated, and only describes the offset and size of the framebuffer
in memory, and the pixel format.
If the GOP framebuffer is provided by a PCI device, it will have been
configured and enabled by the UEFI firmware, and the GOP protocol will
simply point into a live BAR region. However, the GOP protocol itself does
not describe this relation, and so we have to take care not to reconfigure
the BAR without taking efifb's dependency on it into account.
Commit:
55d728a40d36 ("efi/fb: Avoid reconfiguration of BAR that covers the framebuffer")
attempted to do so by claiming the BAR resource early on, which prevents the
PCI resource allocation routines from changing it. However, it turns out
that this only works if the PCI device is not behind any bridges, since
the bridge resources need to be claimed first.
So instead, allow the BAR to be moved, but make the efifb driver deal
with that gracefully. So record the resource that covers the BAR early
on, and if it turns out to have moved by the time we probe the efifb
driver, update the framebuffer address accordingly.
While this is less likely to occur on x86, given that the firmware's
PCI resource allocation is more likely to be preserved, this is a
worthwhile sanity check to have in place, and so let's remove the
preprocessor conditional that makes it !X86 only.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Peter Jones <pjones@redhat.com>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170818194947.19347-8-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-08-19 03:49:40 +08:00
|
|
|
#if defined(CONFIG_PCI)
|
2017-04-04 23:27:44 +08:00
|
|
|
|
drivers/fbdev/efifb: Allow BAR to be moved instead of claiming it
On UEFI systems, the firmware may expose a Graphics Output Protocol (GOP)
instance to which the efifb driver attempts to attach in order to provide
a minimal, unaccelerated framebuffer. The GOP protocol itself is not very
sophisticated, and only describes the offset and size of the framebuffer
in memory, and the pixel format.
If the GOP framebuffer is provided by a PCI device, it will have been
configured and enabled by the UEFI firmware, and the GOP protocol will
simply point into a live BAR region. However, the GOP protocol itself does
not describe this relation, and so we have to take care not to reconfigure
the BAR without taking efifb's dependency on it into account.
Commit:
55d728a40d36 ("efi/fb: Avoid reconfiguration of BAR that covers the framebuffer")
attempted to do so by claiming the BAR resource early on, which prevents the
PCI resource allocation routines from changing it. However, it turns out
that this only works if the PCI device is not behind any bridges, since
the bridge resources need to be claimed first.
So instead, allow the BAR to be moved, but make the efifb driver deal
with that gracefully. So record the resource that covers the BAR early
on, and if it turns out to have moved by the time we probe the efifb
driver, update the framebuffer address accordingly.
While this is less likely to occur on x86, given that the firmware's
PCI resource allocation is more likely to be preserved, this is a
worthwhile sanity check to have in place, and so let's remove the
preprocessor conditional that makes it !X86 only.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Peter Jones <pjones@redhat.com>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170818194947.19347-8-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-08-19 03:49:40 +08:00
|
|
|
static void record_efifb_bar_resource(struct pci_dev *dev, int idx, u64 offset)
|
2017-04-04 23:27:44 +08:00
|
|
|
{
|
|
|
|
u16 word;
|
|
|
|
|
drivers/fbdev/efifb: Allow BAR to be moved instead of claiming it
On UEFI systems, the firmware may expose a Graphics Output Protocol (GOP)
instance to which the efifb driver attempts to attach in order to provide
a minimal, unaccelerated framebuffer. The GOP protocol itself is not very
sophisticated, and only describes the offset and size of the framebuffer
in memory, and the pixel format.
If the GOP framebuffer is provided by a PCI device, it will have been
configured and enabled by the UEFI firmware, and the GOP protocol will
simply point into a live BAR region. However, the GOP protocol itself does
not describe this relation, and so we have to take care not to reconfigure
the BAR without taking efifb's dependency on it into account.
Commit:
55d728a40d36 ("efi/fb: Avoid reconfiguration of BAR that covers the framebuffer")
attempted to do so by claiming the BAR resource early on, which prevents the
PCI resource allocation routines from changing it. However, it turns out
that this only works if the PCI device is not behind any bridges, since
the bridge resources need to be claimed first.
So instead, allow the BAR to be moved, but make the efifb driver deal
with that gracefully. So record the resource that covers the BAR early
on, and if it turns out to have moved by the time we probe the efifb
driver, update the framebuffer address accordingly.
While this is less likely to occur on x86, given that the firmware's
PCI resource allocation is more likely to be preserved, this is a
worthwhile sanity check to have in place, and so let's remove the
preprocessor conditional that makes it !X86 only.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Peter Jones <pjones@redhat.com>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170818194947.19347-8-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-08-19 03:49:40 +08:00
|
|
|
efifb_pci_dev = dev;
|
2017-04-04 23:27:44 +08:00
|
|
|
|
|
|
|
pci_read_config_word(dev, PCI_COMMAND, &word);
|
|
|
|
if (!(word & PCI_COMMAND_MEMORY)) {
|
|
|
|
pci_dev_disabled = true;
|
|
|
|
dev_err(&dev->dev,
|
|
|
|
"BAR %d: assigned to efifb but device is disabled!\n",
|
|
|
|
idx);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
drivers/fbdev/efifb: Allow BAR to be moved instead of claiming it
On UEFI systems, the firmware may expose a Graphics Output Protocol (GOP)
instance to which the efifb driver attempts to attach in order to provide
a minimal, unaccelerated framebuffer. The GOP protocol itself is not very
sophisticated, and only describes the offset and size of the framebuffer
in memory, and the pixel format.
If the GOP framebuffer is provided by a PCI device, it will have been
configured and enabled by the UEFI firmware, and the GOP protocol will
simply point into a live BAR region. However, the GOP protocol itself does
not describe this relation, and so we have to take care not to reconfigure
the BAR without taking efifb's dependency on it into account.
Commit:
55d728a40d36 ("efi/fb: Avoid reconfiguration of BAR that covers the framebuffer")
attempted to do so by claiming the BAR resource early on, which prevents the
PCI resource allocation routines from changing it. However, it turns out
that this only works if the PCI device is not behind any bridges, since
the bridge resources need to be claimed first.
So instead, allow the BAR to be moved, but make the efifb driver deal
with that gracefully. So record the resource that covers the BAR early
on, and if it turns out to have moved by the time we probe the efifb
driver, update the framebuffer address accordingly.
While this is less likely to occur on x86, given that the firmware's
PCI resource allocation is more likely to be preserved, this is a
worthwhile sanity check to have in place, and so let's remove the
preprocessor conditional that makes it !X86 only.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Peter Jones <pjones@redhat.com>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170818194947.19347-8-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-08-19 03:49:40 +08:00
|
|
|
bar_resource = &dev->resource[idx];
|
|
|
|
bar_offset = offset;
|
2017-04-04 23:27:44 +08:00
|
|
|
|
|
|
|
dev_info(&dev->dev, "BAR %d: assigned to efifb\n", idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void efifb_fixup_resources(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
u64 base = screen_info.lfb_base;
|
|
|
|
u64 size = screen_info.lfb_size;
|
|
|
|
int i;
|
|
|
|
|
drivers/fbdev/efifb: Allow BAR to be moved instead of claiming it
On UEFI systems, the firmware may expose a Graphics Output Protocol (GOP)
instance to which the efifb driver attempts to attach in order to provide
a minimal, unaccelerated framebuffer. The GOP protocol itself is not very
sophisticated, and only describes the offset and size of the framebuffer
in memory, and the pixel format.
If the GOP framebuffer is provided by a PCI device, it will have been
configured and enabled by the UEFI firmware, and the GOP protocol will
simply point into a live BAR region. However, the GOP protocol itself does
not describe this relation, and so we have to take care not to reconfigure
the BAR without taking efifb's dependency on it into account.
Commit:
55d728a40d36 ("efi/fb: Avoid reconfiguration of BAR that covers the framebuffer")
attempted to do so by claiming the BAR resource early on, which prevents the
PCI resource allocation routines from changing it. However, it turns out
that this only works if the PCI device is not behind any bridges, since
the bridge resources need to be claimed first.
So instead, allow the BAR to be moved, but make the efifb driver deal
with that gracefully. So record the resource that covers the BAR early
on, and if it turns out to have moved by the time we probe the efifb
driver, update the framebuffer address accordingly.
While this is less likely to occur on x86, given that the firmware's
PCI resource allocation is more likely to be preserved, this is a
worthwhile sanity check to have in place, and so let's remove the
preprocessor conditional that makes it !X86 only.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Peter Jones <pjones@redhat.com>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170818194947.19347-8-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-08-19 03:49:40 +08:00
|
|
|
if (efifb_pci_dev || screen_info.orig_video_isVGA != VIDEO_TYPE_EFI)
|
2017-04-04 23:27:44 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
|
|
|
|
base |= (u64)screen_info.ext_lfb_base << 32;
|
|
|
|
|
|
|
|
if (!base)
|
|
|
|
return;
|
|
|
|
|
2019-09-28 07:43:08 +08:00
|
|
|
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
|
2017-04-04 23:27:44 +08:00
|
|
|
struct resource *res = &dev->resource[i];
|
|
|
|
|
|
|
|
if (!(res->flags & IORESOURCE_MEM))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (res->start <= base && res->end >= base + size - 1) {
|
drivers/fbdev/efifb: Allow BAR to be moved instead of claiming it
On UEFI systems, the firmware may expose a Graphics Output Protocol (GOP)
instance to which the efifb driver attempts to attach in order to provide
a minimal, unaccelerated framebuffer. The GOP protocol itself is not very
sophisticated, and only describes the offset and size of the framebuffer
in memory, and the pixel format.
If the GOP framebuffer is provided by a PCI device, it will have been
configured and enabled by the UEFI firmware, and the GOP protocol will
simply point into a live BAR region. However, the GOP protocol itself does
not describe this relation, and so we have to take care not to reconfigure
the BAR without taking efifb's dependency on it into account.
Commit:
55d728a40d36 ("efi/fb: Avoid reconfiguration of BAR that covers the framebuffer")
attempted to do so by claiming the BAR resource early on, which prevents the
PCI resource allocation routines from changing it. However, it turns out
that this only works if the PCI device is not behind any bridges, since
the bridge resources need to be claimed first.
So instead, allow the BAR to be moved, but make the efifb driver deal
with that gracefully. So record the resource that covers the BAR early
on, and if it turns out to have moved by the time we probe the efifb
driver, update the framebuffer address accordingly.
While this is less likely to occur on x86, given that the firmware's
PCI resource allocation is more likely to be preserved, this is a
worthwhile sanity check to have in place, and so let's remove the
preprocessor conditional that makes it !X86 only.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Peter Jones <pjones@redhat.com>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170818194947.19347-8-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-08-19 03:49:40 +08:00
|
|
|
record_efifb_bar_resource(dev, i, base - res->start);
|
2017-04-04 23:27:44 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY,
|
|
|
|
16, efifb_fixup_resources);
|
|
|
|
|
|
|
|
#endif
|