Bug 35267

Summary: nouveau fails to load BIOS on EFI boot.
Product: xorg Reporter: hanfi <freedesktop.org>
Component: Driver/nouveauAssignee: Nouveau Project <nouveau>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium CC: freedesktop.org, mads
Version: git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
full dmesg output
none
dmesg output 2.6.38.0-rc5 MBP4,1
none
read grub faked bios from memory
none
dmesg output from patched nouveau
none
Xorg.0.log from working system
none
X.org.log for non-working system (using nvidia 319.17)
none
Output from various commands none

Description hanfi 2011-03-13 03:50:03 UTC
Created attachment 44410 [details]
full dmesg output

I try use nouveau on my gentoo. As this is a MacBook, i installed Grub2 and boot directly in EFI mode (eg, no BIOS simulation.... i think).
At loading the nouveau driver, it fails due to no valid BIOS found.

The relevant error message is (dmesg output attached):nouveau 0000:01:00.0: enabling device (0002 -> 0003)
nouveau 0000:01:00.0: PCI INT A -> GSI 16 (level, low) -> IRQ 16
nouveau 0000:01:00.0: setting latency timer to 64
[drm] nouveau 0000:01:00.0: Detected an NV50 generation card (0x084700a2)
checking generic (80060000 960000) vs hw (80000000 10000000)
fb: conflicting fb hw usage nouveaufb vs EFI VGA - removing generic driver
Console: switching to colour dummy device 80x25
[drm] nouveau 0000:01:00.0: Attempting to load BIOS image from PRAMIN
[drm] nouveau 0000:01:00.0: ... BIOS signature not found
[drm] nouveau 0000:01:00.0: Attempting to load BIOS image from PROM
[drm] nouveau 0000:01:00.0: ... BIOS signature not found
[drm] nouveau 0000:01:00.0: Attempting to load BIOS image from PCIROM
nouveau 0000:01:00.0: Invalid ROM contents
[drm] nouveau 0000:01:00.0: ... BIOS signature not found
[drm] nouveau 0000:01:00.0: Attempting to load BIOS image from ACPI
[drm] nouveau 0000:01:00.0: ... BIOS signature not found
[drm] nouveau 0000:01:00.0: No valid BIOS image found
nouveau 0000:01:00.0: PCI INT A disabled

From this point I do not get any graphical output anymore (but i can ssh into the host). (On a side note: can i somehow tell the kernel to switch back to efifb?)

I tried this with the gentoo-sources (36-rc5 kernel), with the git-sources (38-rc2 and rc3 kernel) always getting the same problem in dmesg.
I too tried use nouveau as a module or compiled into the kernel, no difference.

I tried tell grub to use "fakebios", but it did not worked (or I did somethng wrong, im not that familiar with grub/efi/bios)
Comment 2 hanfi 2011-03-13 08:06:18 UTC
I have seen that bugreport, that was about KMS? i think i have that enabled (according to http://nouveau.freedesktop.org/wiki/KernelModeSetting)

Anyway, i go install nvidia drivers and report back.
Comment 3 hanfi 2011-03-13 12:06:47 UTC
Ah, now after recompile the kernel with no nouveau and then install nvidia-blob i get the same error as mentioned in the email at http://lists.freedesktop.org/archives/nouveau/2010-September/006608.html

NVRM: failed to copy vbios to system memory.
NVRM: RmInitAdapter failed! (0x30:0xffffffff:832)
NVRM: rm_init_adapter(0) failed
NVRM: failed to copy vbios to system memory.
NVRM: RmInitAdapter failed! (0x30:0xffffffff:832)
NVRM: rm_init_adapter(0) failed
NVRM: failed to copy vbios to system memory.
NVRM: RmInitAdapter failed! (0x30:0xffffffff:832)
NVRM: rm_init_adapter(0) failed

looks like i got the same problem.
Comment 4 Chris Murphy 2011-03-23 15:51:36 UTC
I have the exact same problem, except in this case Fedora 14 with Linux 2.6.35.11-83.fc14.x86_64. But same hardware, Macbook Pro 4,1.

I have succesfully gotten this hardware to boot Fedora 14/Linux 2.6.35-11+ using rEFIt + Grub 0.97 (with GPT + MBR syncd using rEFIt). This is almost certainly using BIOS emulation.

This web site indicates that native EFI boot is possible with this hardware.
http://grub.enbug.org/TestingOnMacbook

I have not been able to reproduce these results. There are three anomalies on this web site under "Tested configurations" that I haven't done regression against.


a.) Kernel: I did not test with this listed kernel.

b.) Video driver: nvidia-260.19.06-0ubuntu1 is not one I'm familiar with how to install on Fedora. So I have been unable to test this.

c.) Grub: All models are listed with grub-efi64 *except* this Macbook 4,1 model. Earlier it says to check EFI using: 
ioreg -l -p IODeviceTree | grep firmware-abi
which reports back:
    | |   "firmware-abi" = <"EFI64">

So it seems I should built Grub 1.99 as x86_64, which I did. I have not tried recompiling for i686.

d.) Extra steps says "Model details of "drivers/video/efifb.c" were wrong and needed patching/recompiling" 

This may mean Grub 1.99 is not passing the correct video information to the kernel.

Otherwise I have tried with and without the BIOS capture steps and it will will not boot. So I think there's either something with 32-bit EFI, or altering efifb.c. If efifb.c needs to be modified for this to work, it needs to be reported to Grub devel me thinks.
Comment 5 hanfi 2011-03-24 12:36:56 UTC
Back when I had a OSX on my laptop, I used refit with GPT/BIOS syncing, and nouveau worked back then (At least I think it did..I should been checking more carefully back then)
I was hoping to somehow get away with no bios sync.

about your points:
a) I use(d) 2.6.36/38 in various versions. If your kernel does not boot at all, you may want check my config at https://dev.spahan.ch/svn/linux/kernel/configs/config oh, and you MUST use a 64bit kernel with EFI64 I think.
c) that is a error on that page. I can boot with EFI64 but not with EFI32
d) I think I tried different values there. But I  did not get any different results at all, which makes me think I maybe did something worng, I will try test again. (As I do not have macosx installed, I am not able to do that dtrace thing as that is not installed in the install disk environment... well, I try install it on a external disk and see if I can get any results.)
Additionaly, those screen resolutions there are for the default macbookpro4,1 (1440x900) but i got the "HighDEf" (1920x1200).


Anyway, can a developer tell me if it should be possible to use nouveau without BIOS at all? If not, I wont waste more time on this and move on to waste time on try getting BIOS emulation work in Grub.
Comment 6 Chris Murphy 2011-03-28 21:18:25 UTC
(In reply to comment #5)
> If not, I wont waste more time on this and move on to waste time
> on try getting BIOS emulation work in Grub.

I've done this with both GRUBs. The problem is to get Apple's EFI into BIOS emulation means a hybrid (sync'd) MBR+GPT which means the worst combination of both: 4 partitions max, and no LVM.

I have done the sync with rEFIt + Grub 0.97. And without rEFIT using only GRUB2 (compiled normally, not with EFI support) with it's gptsync command.
Comment 7 Chris Murphy 2011-03-28 21:23:24 UTC
I can reproduce this problem with F15 alpha, using 2.6.38-0.rc5.git1.1.fc15.x86_64. It's fatal for EFI booting the F15 LiveCD which depends on nouveau.

Attaching dmesg.
Comment 8 Chris Murphy 2011-03-28 21:24:31 UTC
Created attachment 44978 [details]
dmesg output 2.6.38.0-rc5 MBP4,1
Comment 9 hanfi 2011-04-20 06:11:18 UTC
I played around a little more with this.

This is either a Grub bug, or the kernel does not honor the fake bios thingy created by grub.

I compiled the vbios i extracted (booting into bios mode with a live-CD) into the kernel (just for fun), and it actualy found that, and could read that BIT bios thing, however, it crashes as it does not find some other tables needed (i assume i would need to somehow update those ...at least i think thats what grub is doing...). The nouveauFB runs perfectly with that, but no X (and the kernel crashes around like mad :-p)

I tried play around with nouveau_bios.c, as i found the vbios at address 0xc0000 in /dev/mem, but i get kernel errors about not be able to access that address.

I keep on play around with it :-p
However, my knowledge about kernel stuff and hardware and acpi and bios is by far not enough to do real debugging here.
Comment 10 hanfi 2011-04-23 12:12:17 UTC
Created attachment 45997 [details] [review]
read grub faked bios from memory

The follwoing patch adds a stupid way to read the vbios from the location grub places it.
Use 'loadbios /boot/vbios.bin /int10.bin' in grub (1.99+) and starting X with nouveau driver works for me.
Comment 11 hanfi 2011-04-23 12:13:21 UTC
Created attachment 45998 [details]
dmesg output from patched nouveau

Some warnings in demsg, but nouveau works.
Comment 12 Daniel Kirchner 2011-05-09 04:09:20 UTC
I confirm that the hanfi's patch makes it work, but I think it would be better to patch grub to create proper ACPI table entries. That would maybe also make the proprietary nvidia drivers work and would be cleaner way anyways in my opinion.
Comment 13 hanfi 2011-05-09 06:36:00 UTC
GRUB does copy some ACPI stuff around in the loadbios command. I just don't understand enough of the ACPI stuff to actually work around the problem (i tried play with ACPI first, but failed to achieve anything :-p )
Comment 14 hanfi 2011-09-21 13:51:33 UTC
I seen this comment on the grub mailing list.
Looks like Macs with EFI will have to wait :-(
http://lists.gnu.org/archive/html/grub-devel/2009-02/msg00130.html

The relevant part of the mail:
"The accelerated graphics from what I understand are a general issue
with EFI booting, not much grub can do about it for now. If I
understand it correctly, either grub would have to play a bigger part
in video initilization, or more likely, the accelerated graphics
drivers would have to be rewritten, not very likely I think."
Comment 15 John 2013-05-15 07:15:40 UTC
Hi all,

I thought I might weigh in.

I am having some issues similar to what is mentioned here.
I was able to successfully boot my MacbookPro 4,1 from USB using EFI to install Ubuntu 13.04.

I could only use the "Install Ubuntu" option from the Grub menu, and I had to edit the kernel line adding "nouveau.blackliest=yes" before I could boot the installer.

After installation I would get lockups. I had to pass the same parameter to the linux boot line in grub again. Nouveau is still out for me. I tried a few nVidia driver versions and I have gotten nvidia-173 to work. I just had to apt-get Other versions give me the same 
NVRM: failed to copy vbios to system memory.
NVRM: RmInitAdapter failed! (0x30:0xffffffff:832)
NVRM: rm_init_adapter(0) failed

messages in my log, and a seemingly locked up system. I know its not locked up because when I press the power button it spits some shutdown messages to the screen and powers off.

I am also getting error messages in my X.org log about ACPI

[     5.804] (II) NVIDIA(0): Initialized GPU GART.
[     5.807] (WW) NVIDIA(0): Failed to determine power source of the system : Un
able to
[     5.807] (WW) NVIDIA(0):     find AC state file under /proc/acpi/ac_adapter/
[     5.816] (II) NVIDIA(0): Setting mode "nvidia-auto-select"
[     6.118] Loading extension NV-GLX

This might be why I have no brightness controls and being unable to suspend.
I can't work out if this is to do with the nVidia driver, or acpi.
the apple_bl module is loaded btw.

I don't know what it is about nvidia-173 that works, and none of the newer versions available in the repos, nor the version in the ppa, nor the latest version from the nvidia website work.

Hope this helps.
Comment 16 John 2013-05-15 07:58:34 UTC
I just wanted to add a few things I forgot. Even though I can get X to start and log into ubuntu Unity, it is a bit unstable. I ran GLX gears and got a segfault on one occasion. The following output was in dmesg

[ 2605.678169] show_signal_msg: 60 callbacks suppressed
[ 2605.678174] glxgears[3789]: segfault at 164 ip 00007fd8b2e9ece9 sp 00007ffff12fdc40 error 4 in libGLcore.so.173.14.37[7fd8b29f5000+bc5000]
[ 2618.945307] NVRM: Xid (0001:00): 13, 0004 00000000 0000502d 00000104 00000000 00000100
[ 2622.963507] NVRM: Xid (0001:00): 36,  L2 -> L1


If I try to switch to a VT I get a blank screen. Switching back is not always successful. Most of the time I get a blank screen for a while till it updates.
Mostly I can see the cursor moving. Occaasionally I have had X crash and restart.

I seem to be getting graphics artifacts in some applications like firefox and chrome. I also noticed running virt-manager graphical console in scaled mode makes the CPU work very hard. The system has freezes where it doesn't respond for a while then comes back.

It's not really a stable environment, am considering putting my old hard-disk back in. Makes me glad I just didnt upgrade over the top of it. I switched out for an SSD. It has made a difference, but I digress.

So, what is special about nvidia-173 that can seemingly intialise the hardware, and nouveau and others fails.

I am attaching some files with some output, as well as my kern log which will show successive boots, so you can see the NVRM failed to init messages before the last successful boot.
Comment 17 John 2013-05-15 08:00:45 UTC
Created attachment 79326 [details]
Xorg.0.log from working system
Comment 18 John 2013-05-15 08:02:17 UTC
Created attachment 79327 [details]
X.org.log for non-working system (using nvidia 319.17)
Comment 19 John 2013-05-15 08:03:32 UTC
Created attachment 79328 [details]
Output from various commands
Comment 20 Ilia Mirkin 2013-08-31 07:02:52 UTC
Is this still an issue with the latest kernel? Note that you can load a custom vbios by using nouveau.NvBios=path/to/vbios.rom (which will be loaded using the firmware loading logic, so make sure that file is available when nouveau is getting loaded, either built into the kernel, or in the initrd if you're using that).
Comment 21 hanfi 2013-09-04 20:16:11 UTC
(In reply to comment #20)
> Is this still an issue with the latest kernel? Note that you can load a
> custom vbios by using nouveau.NvBios=path/to/vbios.rom (which will be loaded
> using the firmware loading logic, so make sure that file is available when
> nouveau is getting loaded, either built into the kernel, or in the initrd if
> you're using that).

Where exactly should I set this option?
I tried pass it as a kernel parameter from grub, which did not work.
Then i blacklisted nouveau, and tried to load it after the system booted
But this always tells me:

laptop ~ # modprobe nouveau nouveau.NvBios='/boot/vbios.rom'
[   86.004292] nouveau: `/boot/vbios.rom' invalid for parameter `nouveau.NvBios'
modprobe: ERROR: could not insert 'nouveau': Invalid argument
laptop ~ # modprobe nouveau NvBios='/boot/vbios.rom'
[   92.214318] nouveau: `/boot/vbios.rom' invalid for parameter `NvBios'
modprobe: ERROR: could not insert 'nouveau': Invalid argument


This is on kernel 3.10.7 (gentoo sources) and greping trough the source i see that the option exists.
Do i need try linux for workgroup (aka 3.11)?

Im lost a little bit here.
Comment 22 Ilia Mirkin 2013-09-04 20:27:37 UTC
Ooops, did I say nouveau.NvBios? (Yes, I did...) That was a lie.

Try: nouveau.config=NvBios=path/to/vbios.rom

Note that this path is passed to the firmware loader, which might only work in paths relative to /lib/firmware -- I don't think doing "/boot/blah" will work. But I've never tried it. (Or it'll call out to the usermode helper, which will do who knows what.)
Comment 23 hanfi 2013-09-05 19:25:50 UTC
(In reply to comment #22)
> Ooops, did I say nouveau.NvBios? (Yes, I did...) That was a lie.
> 
> Try: nouveau.config=NvBios=path/to/vbios.rom
> 
> Note that this path is passed to the firmware loader, which might only work
> in paths relative to /lib/firmware -- I don't think doing "/boot/blah" will
> work. But I've never tried it. (Or it'll call out to the usermode helper,
> which will do who knows what.)

Ok, I can load the driver now; No errors from the vbios loading.
I copied the vbios.rom into /lib/firmware and used
"modprobe nouveau config=NvBios=vbios.rom"

This worked fine on the console, I had some problems starting X, but I need rebuild xorg and related stuff.

As this is not related to loading the vbios i think we can close this bug as a proper way to load the vbios exists without need using Grub/bootloader.
Comment 24 Ilia Mirkin 2013-09-06 01:03:47 UTC
How did you get that vbios though? There ought to be a way to retrieve the vbios... does a recent nvidia blob load OK? If so it'd be interesting to see a mmiotrace of it loading to see where it's getting a vbios from.
Comment 25 Ilia Mirkin 2013-10-08 16:58:53 UTC
Marking this as fixed as per the last comments.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.