Changes in 4.9.209 PM / devfreq: Don't fail devfreq_dev_release if not in list RDMA/cma: add missed unregister_pernet_subsys in init failure scsi: lpfc: Fix memory leak on lpfc_bsg_write_ebuf_set func scsi: qla2xxx: Don't call qlt_async_event twice scsi: iscsi: qla4xxx: fix double free in probe scsi: libsas: stop discovering if oob mode is disconnected usb: gadget: fix wrong endpoint desc md: raid1: check rdev before reference in raid1_sync_request func s390/cpum_sf: Adjust sampling interval to avoid hitting sample limits s390/cpum_sf: Avoid SBD overflow condition in irq handler IB/mlx4: Follow mirror sequence of device add during device removal xen-blkback: prevent premature module unload xen/balloon: fix ballooned page accounting without hotplug enabled PM / hibernate: memory_bm_find_bit(): Tighten node optimisation xfs: fix mount failure crash on invalid iclog memory access taskstats: fix data-race drm: limit to INT_MAX in create_blob ioctl Revert "perf report: Add warning when libunwind not compiled in" ALSA: ice1724: Fix sleep-in-atomic in Infrasonic Quartet support code MIPS: Avoid VDSO ABI breakage due to global register variable mm/zsmalloc.c: fix the migrated zspage statistics. memcg: account security cred as well to kmemcg locks: print unsigned ino in /proc/locks dmaengine: Fix access to uninitialized dma_slave_caps compat_ioctl: block: handle Persistent Reservations ata: libahci_platform: Export again ahci_platform_<en/dis>able_phys() ata: ahci_brcm: Allow optional reset controller to be used ata: ahci_brcm: Fix AHCI resources management gpiolib: fix up emulated open drain outputs tracing: Have the histogram compare functions convert to u64 first ALSA: cs4236: fix error return comparison of an unsigned integer ftrace: Avoid potential division by zero in function profiler arm64: Revert support for execute-only user mappings PM / devfreq: Check NULL governor in available_governors_show nfsd4: fix up replay_matches_cache() xfs: don't check for AG deadlock for realtime files in bunmapi Bluetooth: btusb: fix PM leak in error case of setup Bluetooth: delete a stray unlock Bluetooth: Fix memory leak in hci_connect_le_scan media: flexcop-usb: ensure -EIO is returned on error condition regulator: ab8500: Remove AB8505 USB regulator media: usb: fix memory leak in af9005_identify_state tty: serial: msm_serial: Fix lockup for sysrq and oops fix compat handling of FICLONERANGE, FIDEDUPERANGE and FS_IOC_FIEMAP drm/mst: Fix MST sideband up-reply failure handling powerpc/pseries/hvconsole: Fix stack overread via udbg rxrpc: Fix possible NULL pointer access in ICMP handling ath9k_htc: Modify byte order for an error message ath9k_htc: Discard undersized packets net: add annotations on hh->hh_len lockless accesses s390/smp: fix physical to logical CPU map for SMT xen/blkback: Avoid unmapping unmapped grant pages locking/x86: Remove the unused atomic_inc_short() methd pstore/ram: Write new dumps to start of recycled zones locking/spinlock/debug: Fix various data races netfilter: ctnetlink: netns exit must wait for callbacks efi/gop: Return EFI_NOT_FOUND if there are no usable GOPs efi/gop: Return EFI_SUCCESS if a usable GOP was found efi/gop: Fix memory leak in __gop_query32/64() ARM: vexpress: Set-up shared OPP table instead of individual for each CPU netfilter: uapi: Avoid undefined left-shift in xt_sctp.h spi: spi-cavium-thunderx: Add missing pci_release_regions() ARM: dts: am437x-gp/epos-evm: fix panel compatible samples: bpf: Replace symbol compare of trace_event powerpc: Ensure that swiotlb buffer is allocated from low memory bnx2x: Do not handle requests from VFs after parity bnx2x: Fix logic to get total no. of PFs per engine net: usb: lan78xx: Fix error message format specifier rfkill: Fix incorrect check to avoid NULL pointer dereference ASoC: wm8962: fix lambda value regulator: rn5t618: fix module aliases kconfig: don't crash on NULL expressions in expr_eq() perf/x86/intel: Fix PT PMI handling net: stmmac: RX buffer size must be 16 byte aligned block: fix memleak when __blk_rq_map_user_iov() is failed parisc: Fix compiler warnings in debug_core.c llc2: Fix return statement of llc_stat_ev_rx_null_dsap_xid_c (and _test_c) macvlan: do not assume mac_header is set in macvlan_broadcast() net: stmmac: dwmac-sunxi: Allow all RGMII modes net: usb: lan78xx: fix possible skb leak pkt_sched: fq: do not accept silly TCA_FQ_QUANTUM sctp: free cmd->obj.chunk for the unprocessed SCTP_CMD_REPLY tcp: fix "old stuff" D-SACK causing SACK to be treated as D-SACK vxlan: fix tos value before xmit vlan: vlan_changelink() should propagate errors net: sch_prio: When ungrafting, replace with FIFO vlan: fix memory leak in vlan_dev_set_egress_priority USB: core: fix check for duplicate endpoints USB: serial: option: add Telit ME910G1 0x110a composition Linux 4.9.209 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I37562d713bddce2ead7934800c3f9e231884c43f
315 lines
8.0 KiB
C
315 lines
8.0 KiB
C
/* -----------------------------------------------------------------------
|
|
*
|
|
* Copyright 2011 Intel Corporation; author Matt Fleming
|
|
*
|
|
* This file is part of the Linux kernel, and is made available under
|
|
* the terms of the GNU General Public License version 2.
|
|
*
|
|
* ----------------------------------------------------------------------- */
|
|
|
|
#include <linux/efi.h>
|
|
#include <linux/screen_info.h>
|
|
#include <asm/efi.h>
|
|
#include <asm/setup.h>
|
|
|
|
static void find_bits(unsigned long mask, u8 *pos, u8 *size)
|
|
{
|
|
u8 first, len;
|
|
|
|
first = 0;
|
|
len = 0;
|
|
|
|
if (mask) {
|
|
while (!(mask & 0x1)) {
|
|
mask = mask >> 1;
|
|
first++;
|
|
}
|
|
|
|
while (mask & 0x1) {
|
|
mask = mask >> 1;
|
|
len++;
|
|
}
|
|
}
|
|
|
|
*pos = first;
|
|
*size = len;
|
|
}
|
|
|
|
static void
|
|
setup_pixel_info(struct screen_info *si, u32 pixels_per_scan_line,
|
|
struct efi_pixel_bitmask pixel_info, int pixel_format)
|
|
{
|
|
if (pixel_format == PIXEL_RGB_RESERVED_8BIT_PER_COLOR) {
|
|
si->lfb_depth = 32;
|
|
si->lfb_linelength = pixels_per_scan_line * 4;
|
|
si->red_size = 8;
|
|
si->red_pos = 0;
|
|
si->green_size = 8;
|
|
si->green_pos = 8;
|
|
si->blue_size = 8;
|
|
si->blue_pos = 16;
|
|
si->rsvd_size = 8;
|
|
si->rsvd_pos = 24;
|
|
} else if (pixel_format == PIXEL_BGR_RESERVED_8BIT_PER_COLOR) {
|
|
si->lfb_depth = 32;
|
|
si->lfb_linelength = pixels_per_scan_line * 4;
|
|
si->red_size = 8;
|
|
si->red_pos = 16;
|
|
si->green_size = 8;
|
|
si->green_pos = 8;
|
|
si->blue_size = 8;
|
|
si->blue_pos = 0;
|
|
si->rsvd_size = 8;
|
|
si->rsvd_pos = 24;
|
|
} else if (pixel_format == PIXEL_BIT_MASK) {
|
|
find_bits(pixel_info.red_mask, &si->red_pos, &si->red_size);
|
|
find_bits(pixel_info.green_mask, &si->green_pos,
|
|
&si->green_size);
|
|
find_bits(pixel_info.blue_mask, &si->blue_pos, &si->blue_size);
|
|
find_bits(pixel_info.reserved_mask, &si->rsvd_pos,
|
|
&si->rsvd_size);
|
|
si->lfb_depth = si->red_size + si->green_size +
|
|
si->blue_size + si->rsvd_size;
|
|
si->lfb_linelength = (pixels_per_scan_line * si->lfb_depth) / 8;
|
|
} else {
|
|
si->lfb_depth = 4;
|
|
si->lfb_linelength = si->lfb_width / 2;
|
|
si->red_size = 0;
|
|
si->red_pos = 0;
|
|
si->green_size = 0;
|
|
si->green_pos = 0;
|
|
si->blue_size = 0;
|
|
si->blue_pos = 0;
|
|
si->rsvd_size = 0;
|
|
si->rsvd_pos = 0;
|
|
}
|
|
}
|
|
|
|
static efi_status_t
|
|
setup_gop32(efi_system_table_t *sys_table_arg, struct screen_info *si,
|
|
efi_guid_t *proto, unsigned long size, void **gop_handle)
|
|
{
|
|
struct efi_graphics_output_protocol_32 *gop32, *first_gop;
|
|
unsigned long nr_gops;
|
|
u16 width, height;
|
|
u32 pixels_per_scan_line;
|
|
u32 ext_lfb_base;
|
|
u64 fb_base;
|
|
struct efi_pixel_bitmask pixel_info;
|
|
int pixel_format;
|
|
efi_status_t status;
|
|
u32 *handles = (u32 *)(unsigned long)gop_handle;
|
|
int i;
|
|
|
|
first_gop = NULL;
|
|
gop32 = NULL;
|
|
|
|
nr_gops = size / sizeof(u32);
|
|
for (i = 0; i < nr_gops; i++) {
|
|
struct efi_graphics_output_protocol_mode_32 *mode;
|
|
struct efi_graphics_output_mode_info *info = NULL;
|
|
efi_guid_t conout_proto = EFI_CONSOLE_OUT_DEVICE_GUID;
|
|
bool conout_found = false;
|
|
void *dummy = NULL;
|
|
efi_handle_t h = (efi_handle_t)(unsigned long)handles[i];
|
|
u64 current_fb_base;
|
|
|
|
status = efi_call_early(handle_protocol, h,
|
|
proto, (void **)&gop32);
|
|
if (status != EFI_SUCCESS)
|
|
continue;
|
|
|
|
status = efi_call_early(handle_protocol, h,
|
|
&conout_proto, &dummy);
|
|
if (status == EFI_SUCCESS)
|
|
conout_found = true;
|
|
|
|
mode = (void *)(unsigned long)gop32->mode;
|
|
info = (void *)(unsigned long)mode->info;
|
|
current_fb_base = mode->frame_buffer_base;
|
|
|
|
if ((!first_gop || conout_found) &&
|
|
info->pixel_format != PIXEL_BLT_ONLY) {
|
|
/*
|
|
* Systems that use the UEFI Console Splitter may
|
|
* provide multiple GOP devices, not all of which are
|
|
* backed by real hardware. The workaround is to search
|
|
* for a GOP implementing the ConOut protocol, and if
|
|
* one isn't found, to just fall back to the first GOP.
|
|
*/
|
|
width = info->horizontal_resolution;
|
|
height = info->vertical_resolution;
|
|
pixel_format = info->pixel_format;
|
|
pixel_info = info->pixel_information;
|
|
pixels_per_scan_line = info->pixels_per_scan_line;
|
|
fb_base = current_fb_base;
|
|
|
|
/*
|
|
* Once we've found a GOP supporting ConOut,
|
|
* don't bother looking any further.
|
|
*/
|
|
first_gop = gop32;
|
|
if (conout_found)
|
|
break;
|
|
}
|
|
}
|
|
|
|
/* Did we find any GOPs? */
|
|
if (!first_gop)
|
|
return EFI_NOT_FOUND;
|
|
|
|
/* EFI framebuffer */
|
|
si->orig_video_isVGA = VIDEO_TYPE_EFI;
|
|
|
|
si->lfb_width = width;
|
|
si->lfb_height = height;
|
|
si->lfb_base = fb_base;
|
|
|
|
ext_lfb_base = (u64)(unsigned long)fb_base >> 32;
|
|
if (ext_lfb_base) {
|
|
si->capabilities |= VIDEO_CAPABILITY_64BIT_BASE;
|
|
si->ext_lfb_base = ext_lfb_base;
|
|
}
|
|
|
|
si->pages = 1;
|
|
|
|
setup_pixel_info(si, pixels_per_scan_line, pixel_info, pixel_format);
|
|
|
|
si->lfb_size = si->lfb_linelength * si->lfb_height;
|
|
|
|
si->capabilities |= VIDEO_CAPABILITY_SKIP_QUIRKS;
|
|
|
|
return EFI_SUCCESS;
|
|
}
|
|
|
|
static efi_status_t
|
|
setup_gop64(efi_system_table_t *sys_table_arg, struct screen_info *si,
|
|
efi_guid_t *proto, unsigned long size, void **gop_handle)
|
|
{
|
|
struct efi_graphics_output_protocol_64 *gop64, *first_gop;
|
|
unsigned long nr_gops;
|
|
u16 width, height;
|
|
u32 pixels_per_scan_line;
|
|
u32 ext_lfb_base;
|
|
u64 fb_base;
|
|
struct efi_pixel_bitmask pixel_info;
|
|
int pixel_format;
|
|
efi_status_t status;
|
|
u64 *handles = (u64 *)(unsigned long)gop_handle;
|
|
int i;
|
|
|
|
first_gop = NULL;
|
|
gop64 = NULL;
|
|
|
|
nr_gops = size / sizeof(u64);
|
|
for (i = 0; i < nr_gops; i++) {
|
|
struct efi_graphics_output_protocol_mode_64 *mode;
|
|
struct efi_graphics_output_mode_info *info = NULL;
|
|
efi_guid_t conout_proto = EFI_CONSOLE_OUT_DEVICE_GUID;
|
|
bool conout_found = false;
|
|
void *dummy = NULL;
|
|
efi_handle_t h = (efi_handle_t)(unsigned long)handles[i];
|
|
u64 current_fb_base;
|
|
|
|
status = efi_call_early(handle_protocol, h,
|
|
proto, (void **)&gop64);
|
|
if (status != EFI_SUCCESS)
|
|
continue;
|
|
|
|
status = efi_call_early(handle_protocol, h,
|
|
&conout_proto, &dummy);
|
|
if (status == EFI_SUCCESS)
|
|
conout_found = true;
|
|
|
|
mode = (void *)(unsigned long)gop64->mode;
|
|
info = (void *)(unsigned long)mode->info;
|
|
current_fb_base = mode->frame_buffer_base;
|
|
|
|
if ((!first_gop || conout_found) &&
|
|
info->pixel_format != PIXEL_BLT_ONLY) {
|
|
/*
|
|
* Systems that use the UEFI Console Splitter may
|
|
* provide multiple GOP devices, not all of which are
|
|
* backed by real hardware. The workaround is to search
|
|
* for a GOP implementing the ConOut protocol, and if
|
|
* one isn't found, to just fall back to the first GOP.
|
|
*/
|
|
width = info->horizontal_resolution;
|
|
height = info->vertical_resolution;
|
|
pixel_format = info->pixel_format;
|
|
pixel_info = info->pixel_information;
|
|
pixels_per_scan_line = info->pixels_per_scan_line;
|
|
fb_base = current_fb_base;
|
|
|
|
/*
|
|
* Once we've found a GOP supporting ConOut,
|
|
* don't bother looking any further.
|
|
*/
|
|
first_gop = gop64;
|
|
if (conout_found)
|
|
break;
|
|
}
|
|
}
|
|
|
|
/* Did we find any GOPs? */
|
|
if (!first_gop)
|
|
return EFI_NOT_FOUND;
|
|
|
|
/* EFI framebuffer */
|
|
si->orig_video_isVGA = VIDEO_TYPE_EFI;
|
|
|
|
si->lfb_width = width;
|
|
si->lfb_height = height;
|
|
si->lfb_base = fb_base;
|
|
|
|
ext_lfb_base = (u64)(unsigned long)fb_base >> 32;
|
|
if (ext_lfb_base) {
|
|
si->capabilities |= VIDEO_CAPABILITY_64BIT_BASE;
|
|
si->ext_lfb_base = ext_lfb_base;
|
|
}
|
|
|
|
si->pages = 1;
|
|
|
|
setup_pixel_info(si, pixels_per_scan_line, pixel_info, pixel_format);
|
|
|
|
si->lfb_size = si->lfb_linelength * si->lfb_height;
|
|
|
|
si->capabilities |= VIDEO_CAPABILITY_SKIP_QUIRKS;
|
|
|
|
return EFI_SUCCESS;
|
|
}
|
|
|
|
/*
|
|
* See if we have Graphics Output Protocol
|
|
*/
|
|
efi_status_t efi_setup_gop(efi_system_table_t *sys_table_arg,
|
|
struct screen_info *si, efi_guid_t *proto,
|
|
unsigned long size)
|
|
{
|
|
efi_status_t status;
|
|
void **gop_handle = NULL;
|
|
|
|
status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
|
|
size, (void **)&gop_handle);
|
|
if (status != EFI_SUCCESS)
|
|
return status;
|
|
|
|
status = efi_call_early(locate_handle,
|
|
EFI_LOCATE_BY_PROTOCOL,
|
|
proto, NULL, &size, gop_handle);
|
|
if (status != EFI_SUCCESS)
|
|
goto free_handle;
|
|
|
|
if (efi_is_64bit()) {
|
|
status = setup_gop64(sys_table_arg, si, proto, size,
|
|
gop_handle);
|
|
} else {
|
|
status = setup_gop32(sys_table_arg, si, proto, size,
|
|
gop_handle);
|
|
}
|
|
|
|
free_handle:
|
|
efi_call_early(free_pool, gop_handle);
|
|
return status;
|
|
}
|