Message ID | 20141122193025.GA5782@kaos.lebenslange-mailadresse.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Sat, Nov 22, 2014 at 2:30 PM, Wilfried Klaebe <w-lkml@lebenslange-mailadresse.de> wrote: > 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 <w-lkml@lebenslange-mailadresse.de> NACK. This mac specific and is not something I want to support in radeon. 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. Alex > > --- > > 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 <linux/firmware.h> > > #include <linux/vga_switcheroo.h> > #include <linux/slab.h> > @@ -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; > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/dri-devel
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.
tldr: works now, without patch, without GRUB, with efi-stub Am Tue, Nov 25, 2014 at 05:25:50PM +0000 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@60 radeon.dpm=1 video=inteldrmfb:1680x1050-32@60 i915.lvds_use_ssc=0 i915.lvds_downclock=1"
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 <linux/firmware.h> #include <linux/vga_switcheroo.h> #include <linux/slab.h> @@ -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;
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 <w-lkml@lebenslange-mailadresse.de> --- Note: I'm not subscribed to dri-devel@lists.freedesktop.org, please cc: me if replying there.