From patchwork Fri Aug 28 12:12:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Fleming X-Patchwork-Id: 7091441 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8480CBEEC1 for ; Fri, 28 Aug 2015 12:12:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7C23C20672 for ; Fri, 28 Aug 2015 12:12:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E6CA20671 for ; Fri, 28 Aug 2015 12:12:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752342AbbH1MMY (ORCPT ); Fri, 28 Aug 2015 08:12:24 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:38855 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752111AbbH1MMW (ORCPT ); Fri, 28 Aug 2015 08:12:22 -0400 Received: by wibgu7 with SMTP id gu7so7534375wib.1 for ; Fri, 28 Aug 2015 05:12:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xZwK8mK9Wsux2UdOg9ODMQ0Z4oTRQhYVjU9Ut6mWFgE=; b=YSkmQdbcgGTCm1xlmGiIi0kDuKHuGLwqD7LAxz/QZkGYtyrOXWZiytqtmYNr9hCcUU h0KuimEgWNE+lVTHRax6N2rK/ByLtsyLKgctWI+REr1smFr087P0lVWZ3S7jksbPGstI OWG2CaPHiOqV3Bqm12u7i1vfSiPghog1F/tpLbAp6Tp1gL3vB8RDbnRHNV7z2Y8XvERa jnXDtqM4pFOLKPy0GjxyiNtK493IStIcnb8ThWvmC4aa8vSpApl/QYKIWcJ/CKjxGIbC EgwxFBCLdZ5vU5mA5x9p3pYmOKXHhY4R+Nwduv11dye6CTJW0ViWoPZUM+VMZ1sr3AhO kd8Q== X-Gm-Message-State: ALoCoQlBuK2QaYbVXoC3dnGpKCF7gZe1O+f7W/ZauNvKtn6rtpT4dZ512fW/ELmAIvpanGY6ISW+ X-Received: by 10.194.60.132 with SMTP id h4mr5942097wjr.1.1440763941476; Fri, 28 Aug 2015 05:12:21 -0700 (PDT) Received: from localhost (05428f34.skybroadband.com. [5.66.143.52]) by smtp.gmail.com with ESMTPSA id bm9sm3523526wib.10.2015.08.28.05.12.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2015 05:12:20 -0700 (PDT) From: Matt Fleming To: Peter Jones Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, Matt Fleming , Pete Hawkins , Matthew Garrett , Chad Page Subject: [PATCH] efifb: Add support for 64-bit frame buffer addresses Date: Fri, 28 Aug 2015 13:12:19 +0100 Message-Id: <1440763939-17027-1-git-send-email-matt@codeblueprint.co.uk> X-Mailer: git-send-email 2.1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Matt Fleming The EFI Graphics Output Protocol uses 64-bit frame buffer addresses but these get truncated to 32-bit by the EFI boot stub when storing the address in the 'lfb_base' field of 'struct screen_info'. Add a 'ext_lfb_base' field for the upper 32-bits of the frame buffer address and set VIDEO_TYPE_CAPABILITY_64BIT_BASE when the field is useable. It turns out that the reason no one has required this support so far is that there's actually code in tianocore to "downgrade" PCI resources that have option ROMs and 64-bit BARS from 64-bit to 32-bit to cope with legacy option ROMs that can't handle 64-bit addresses. The upshot is that basically all GOP devices in the wild use a 32-bit frame buffer address. Still, it is possible to build firmware that uses a full 64-bit GOP frame buffer address. Chad did, which led to him reporting this issue. Add support in anticipation of GOP devices using 64-bit addresses more widely, and so that efifb works out of the box when that happens. Reported-by: Chad Page Cc: Pete Hawkins Cc: Peter Jones Cc: Matthew Garrett Signed-off-by: Matt Fleming Acked-by: Peter Jones --- arch/x86/boot/compressed/eboot.c | 24 ++++++++++++++++++++---- drivers/video/fbdev/efifb.c | 24 +++++++++++++++++++++++- include/uapi/linux/screen_info.h | 5 +++-- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index 7d69afd8b6fa..43473bb86ac0 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -624,7 +624,7 @@ setup_pixel_info(struct screen_info *si, u32 pixels_per_scan_line, static efi_status_t __gop_query32(struct efi_graphics_output_protocol_32 *gop32, struct efi_graphics_output_mode_info **info, - unsigned long *size, u32 *fb_base) + unsigned long *size, u64 *fb_base) { struct efi_graphics_output_protocol_mode_32 *mode; efi_status_t status; @@ -650,7 +650,8 @@ setup_gop32(struct screen_info *si, efi_guid_t *proto, unsigned long nr_gops; u16 width, height; u32 pixels_per_scan_line; - u32 fb_base; + u32 ext_lfb_base; + u64 fb_base; struct efi_pixel_bitmask pixel_info; int pixel_format; efi_status_t status; @@ -713,6 +714,13 @@ setup_gop32(struct screen_info *si, efi_guid_t *proto, 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); @@ -727,7 +735,7 @@ out: static efi_status_t __gop_query64(struct efi_graphics_output_protocol_64 *gop64, struct efi_graphics_output_mode_info **info, - unsigned long *size, u32 *fb_base) + unsigned long *size, u64 *fb_base) { struct efi_graphics_output_protocol_mode_64 *mode; efi_status_t status; @@ -753,7 +761,8 @@ setup_gop64(struct screen_info *si, efi_guid_t *proto, unsigned long nr_gops; u16 width, height; u32 pixels_per_scan_line; - u32 fb_base; + u32 ext_lfb_base; + u64 fb_base; struct efi_pixel_bitmask pixel_info; int pixel_format; efi_status_t status; @@ -816,6 +825,13 @@ setup_gop64(struct screen_info *si, efi_guid_t *proto, 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); diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c index 4bfff349b1fb..95d293b7445a 100644 --- a/drivers/video/fbdev/efifb.c +++ b/drivers/video/fbdev/efifb.c @@ -114,6 +114,20 @@ static int efifb_setup(char *options) return 0; } +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; +} + static int efifb_probe(struct platform_device *dev) { struct fb_info *info; @@ -141,7 +155,7 @@ static int efifb_probe(struct platform_device *dev) screen_info.lfb_depth = 32; if (!screen_info.pages) screen_info.pages = 1; - if (!screen_info.lfb_base) { + if (!fb_base_is_valid()) { printk(KERN_DEBUG "efifb: invalid framebuffer address\n"); return -ENODEV; } @@ -160,6 +174,14 @@ static int efifb_probe(struct platform_device *dev) } efifb_fix.smem_start = screen_info.lfb_base; + + 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; + } + efifb_defined.bits_per_pixel = screen_info.lfb_depth; efifb_defined.xres = screen_info.lfb_width; efifb_defined.yres = screen_info.lfb_height; diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h index 7530e7447620..8b8d39dfb67f 100644 --- a/include/uapi/linux/screen_info.h +++ b/include/uapi/linux/screen_info.h @@ -43,7 +43,8 @@ struct screen_info { __u16 pages; /* 0x32 */ __u16 vesa_attributes; /* 0x34 */ __u32 capabilities; /* 0x36 */ - __u8 _reserved[6]; /* 0x3a */ + __u32 ext_lfb_base; /* 0x3a */ + __u8 _reserved[2]; /* 0x3e */ } __attribute__((packed)); #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */ @@ -69,6 +70,6 @@ struct screen_info { #define VIDEO_FLAGS_NOCURSOR (1 << 0) /* The video mode has no cursor set */ #define VIDEO_CAPABILITY_SKIP_QUIRKS (1 << 0) - +#define VIDEO_CAPABILITY_64BIT_BASE (1 << 1) /* Frame buffer base is 64-bit */ #endif /* _UAPI_SCREEN_INFO_H */