radeon/radeon_bios.c: clean up coding style differences in radeon_get_bios()
radeon/radeon_bios.c: clean up coding style differences in radeon_get_bios() Signed-off-by: Wilfried Klaebe diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c index 6a03624..63ccb8f 100644 --- a/drivers/gpu/drm/radeon/radeon_bios.c +++ b/drivers/gpu/drm/radeon/radeon_bios.c @@ -658,12 +658,10 @@ bool radeon_get_bios(struct radeon_device *rdev) r = igp_read_bios_from_vram(rdev); if (r == false) r = radeon_read_bios(rdev); - if (r == false) { + if (r == false) r = radeon_read_disabled_bios(rdev); - } - if (r == false) { + if (r == false) r = radeon_read_platform_bios(rdev); - } if (r == false || rdev->bios == NULL) { DRM_ERROR("Unable to locate a BIOS ROM\n"); rdev->bios = NULL;
[PATCH] radeon: acquire BIOS via firmware subsystem if everything else failed
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 at 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;
[PATCH] radeon: acquire BIOS via firmware subsystem if everything else failed
tldr: works now, without patch, without GRUB, with efi-stub Am Tue, Nov 25, 2014 at 05:25:50PM + schrieb Matthew Garrett: > On Tue, Nov 25, 2014 at 12:14:21PM -0500, Alex Deucher wrote: > > The vbios image is available via ACPI prior to the OS taking over. > > IIRC, Matthew Garret fixed up the bootloader to fetch the vbios image > > prior to loading Linux so that it could be accessed after the OS > > loaded. > > EFI rather than ACPI, but yeah. In theory this should work fine if > you're using the EFI entry point. I don't know whether the patches for > linuxefi were ever accepted by grub upstream - if not, pushing those > would make more sense. I could not find any patches for GRUB in this context. I did find big numbers of web pages detailing how one would need to disable KMS to use the radeon, or how to patch the radeon driver to load a vbios dump from a file, or plain telling radeon didn't work. At least one for about every Linux distribution I have heard of, and then some. I could not find a way to use the EFI entry point from GRUB either. Using the "linux" command was what never worked for me. I tried "linuxefi", which complained about an invalid signature. I then had a look at rEFInd again, upgraded it to the current version, and then booted from rEFInd the same Linux 3.18-rc6 image (without the patch) that did not work with GRUB earlier, and everything works ok. Going to remove GRUB now :) Sorry for any inconvenience... Best regards, Wilfried --- Some details for others who might find this useful: Hardware: MacBookPro8,2 Boot "chain": EFI -> rEFInd 0.8.3 ("gnuefi" variant) -> Linux 3.18-rc6 Kernel Commandline: "ro root=/dev/vg0/root video=radeondrmfb:1680x1050-32 at 60 radeon.dpm=1 video=inteldrmfb:1680x1050-32 at 60 i915.lvds_use_ssc=0 i915.lvds_downclock=1"
[RESEND] [PATCH] radeon: clean up coding style differences in radeon_get_bios()
radeon: clean up coding style differences in radeon_get_bios() Signed-off-by: Wilfried Klaebe diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c index 6a03624..63ccb8f 100644 --- a/drivers/gpu/drm/radeon/radeon_bios.c +++ b/drivers/gpu/drm/radeon/radeon_bios.c @@ -658,12 +658,10 @@ bool radeon_get_bios(struct radeon_device *rdev) r = igp_read_bios_from_vram(rdev); if (r == false) r = radeon_read_bios(rdev); - if (r == false) { + if (r == false) r = radeon_read_disabled_bios(rdev); - } - if (r == false) { + if (r == false) r = radeon_read_platform_bios(rdev); - } if (r == false || rdev->bios == NULL) { DRM_ERROR("Unable to locate a BIOS ROM\n"); rdev->bios = NULL; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/