From patchwork Sat Nov 22 19:30:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wilfried Klaebe X-Patchwork-Id: 5360141 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 900789F2F1 for ; Sun, 23 Nov 2014 02:55:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C492D201F4 for ; Sun, 23 Nov 2014 02:55:31 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7B552201BB for ; Sun, 23 Nov 2014 02:55:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9805E6EF03; Sat, 22 Nov 2014 18:55:25 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 327 seconds by postgrey-1.34 at gabe; Sat, 22 Nov 2014 11:43:48 PST Received: from mail0.toppoint.de (mail0.toppoint.de [217.70.197.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 2FADF6E838 for ; Sat, 22 Nov 2014 11:43:48 -0800 (PST) Received: from yoda.toppoint.de (yoda.toppoint.de [217.70.197.2]) by mail0.toppoint.de (Postfix) with ESMTPS id 10DC672987; Sat, 22 Nov 2014 20:34:58 +0100 (CET) Received: from uucp01.toppoint.de (uucp01.toppoint.de [217.70.197.22]) by yoda.toppoint.de (8.14.4/8.14.4/Debian-8) with ESMTP id sAMJZ2Hl010403; Sat, 22 Nov 2014 20:35:02 +0100 Received: by uucp01.toppoint.de (Postfix, from userid 10) id 967C516B935; Sat, 22 Nov 2014 20:34:53 +0100 (CET) Received: from w by kaos.ip4 with local (Exim 4.84) (envelope-from ) id 1XsGO2-0002gv-Bg; Sat, 22 Nov 2014 19:30:26 +0000 Date: Sat, 22 Nov 2014 19:30:26 +0000 From: Wilfried Klaebe To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH] radeon: acquire BIOS via firmware subsystem if everything else failed Message-ID: <20141122193025.GA5782@kaos.lebenslange-mailadresse.de> Mail-Followup-To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Alex Deucher , Christian =?iso-8859-1?Q?K=F6nig?= , David Airlie MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Mailman-Approved-At: Sat, 22 Nov 2014 18:55:24 -0800 Cc: Alex Deucher , Christian =?iso-8859-1?Q?K=F6nig?= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 At least Apple's MacBook Pro 8,2 booting EFI -> GRUB2 -> Linux (without BIOS emulation) seems to have no Radeon BIOS accessible via conventional means. Loading one via firmware system previously dumped (with "dd if=/dev/mem of=/lib/firmware/radeon/vbios.bin bs=65536 skip=12 count=1") when booted with BIOS emulation works. I carry this patch around since about 3.8 and never had any problems, not even with several dozen cycles of suspend2ram and resume. Also, I tested every new release if this patch was still necessary, and it always was. Thanks to Stefan Dösinger and others at https://www.libreoffice.org/bugzilla/show_bug.cgi?id=26891 Signed-off-by: Wilfried Klaebe --- Note: I'm not subscribed to dri-devel@lists.freedesktop.org, please cc: me if replying there. diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c index 63ccb8f..cf55e0e 100644 --- a/drivers/gpu/drm/radeon/radeon_bios.c +++ b/drivers/gpu/drm/radeon/radeon_bios.c @@ -29,6 +29,7 @@ #include "radeon_reg.h" #include "radeon.h" #include "atom.h" +#include #include #include @@ -74,6 +75,44 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev) return true; } +static bool radeon_read_bios_from_firmware(struct radeon_device *rdev) +{ + const uint8_t __iomem *bios; + resource_size_t size; + const struct firmware *fw = NULL; + char *err = NULL; + + request_firmware(&fw, "radeon/vbios.bin", rdev->dev); + if (!fw) { + err = "firmware request returned NULL\n"; + goto out; + } + size = fw->size; + bios = fw->data; + + if (size == 0 || !bios) { + err = "firmware request returned zero sized or NULL data\n"; + goto out; + } + + if (bios[0] != 0x55 || bios[1] != 0xaa) { + err = "wrong signature on firmware\n"; + goto out; + } + rdev->bios = kmalloc(size, GFP_KERNEL); + if (rdev->bios == NULL) { + err = "failed to kmalloc() memory for firmware\n"; + goto out; + } + memcpy(rdev->bios, bios, size); +out: + if (err) + DRM_ERROR(err); + if (fw) + release_firmware(fw); + return !err; +} + static bool radeon_read_bios(struct radeon_device *rdev) { uint8_t __iomem *bios; @@ -662,6 +701,8 @@ bool radeon_get_bios(struct radeon_device *rdev) r = radeon_read_disabled_bios(rdev); if (r == false) r = radeon_read_platform_bios(rdev); + if (r == false) + r = radeon_read_bios_from_firmware(rdev); if (r == false || rdev->bios == NULL) { DRM_ERROR("Unable to locate a BIOS ROM\n"); rdev->bios = NULL;