Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] nvidia-firmware: init at 325.15 - calling all nvidia users #25075

Closed
wants to merge 3 commits into from

Conversation

peterhoeg
Copy link
Member

@peterhoeg peterhoeg commented Apr 21, 2017

Motivation for this change

The nouveau driver requires firmware blobs from nvidia in order to enable proper acceleration on some cards (mine's a GK107).

This PR adds support for fetching and extracting the firmware which then needs to be included in the configuration. In order to test this out, you need to do the following:

  1. Change to the modesetting driver in configuration.nix:
{
  services.xserver.videoDrivers = [ "modesetting" ];
}
  1. Load the firmware files:
{
  boot.extraModprobeConfig = "options nouveau config=NvGrUseFw=1";
  hardware.firmware = with pkgs; [ firmwareLinuxNvidia ];
}
  1. Add vdpauinfo to the global environment (you can also just use nix-env -i) which we will need later:
{
  environment.systemPackages = with pkgs; [ vdpauinfo ];
}
  1. Generate the new configuration:
sudo nixos-rebuild boot -I nixpkgs=https://github.com/peterhoeg/nixpkgs/archive/p/nvidia.tar.gz
  1. Reboot and run vdpauinfo to trigger the loading and check in the journal that there are no errors:
vdpauinfo
journalctl -b | grep -i nouveau
  1. vdpauinfo should also tell you that you have acceleration:
vdpauinfo | head -n 30

display: :0   screen: 0
API version: 1
Information string: G3DVL VDPAU Driver Shared Library version 1.0

Video surface:

name   width height types
-------------------------------------------
420    16384 16384  NV12 YV12
422    16384 16384  UYVY YUYV
444    16384 16384  Y8U8V8A8 V8U8Y8A8

Decoder capabilities:

name                        level macbs width height
----------------------------------------------------
MPEG1                           0 65536  4096  4096
MPEG2_SIMPLE                    3 65536  4096  4096
MPEG2_MAIN                      3 65536  4096  4096
H264_BASELINE                  41 65536  4096  4096
H264_MAIN                      41 65536  4096  4096
H264_HIGH                      41 65536  4096  4096
VC1_SIMPLE                      1 65536  4096  4096
VC1_MAIN                        2 65536  4096  4096
VC1_ADVANCED                    4 65536  4096  4096
MPEG4_PART2_SP                  3 65536  4096  4096
MPEG4_PART2_ASP                 5 65536  4096  4096
DIVX4_QMOBILE                  --- not supported ---
DIVX4_MOBILE                   --- not supported ---
DIVX4_HOME_THEATER             --- not supported ---

Should this be part of "enableAllFirmware" ?

meta.hydraPlatforms is blanked out as we cannot redistribute the firmware blobs.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@peterhoeg peterhoeg self-assigned this Apr 21, 2017
@dezgeg
Copy link
Contributor

dezgeg commented Apr 21, 2017

Is your nouveau module getting loaded in the initrd? If so, you probably need to include the firmwares there as well.

@edolstra
Copy link
Member

Regarding inclusion in enableAllFirmware, could this package conflict with the full nvidia package? (E.g. cause nvidia.ko to use firmware from this package, which might be a different version of the upstream package.)

@peterhoeg
Copy link
Member Author

peterhoeg commented Apr 21, 2017

@edolstra, I don't think so as the firmware is extracted from the binary driver, so I would imagine that it is loaded as part of the nvidia driver being loaded. But in any case, I'll test that out.

@dezgeg, is there some magic to loading the firmware files into the initrd? I've tried the following but it simply causes the kernel to panic during boot:

{
  boot.initrd.prepend = [
    "${pkgs.firmwareLinuxNvidia}/lib/firmware/nouveau/*"
  ];
}

Do I need to make a cpio archive or something?

edit: The odd thing is, that if I do not add the package to hardware.firmware, I get a different error message where nouveau complains it cannot load the firmware files although the file names are different - they are the actual names of the firmware files instead of the =.bin= files.

@dezgeg
Copy link
Contributor

dezgeg commented Apr 21, 2017

I guess it's easier to debug by first getting it to work outside of initrd.

@peterhoeg
Copy link
Member Author

@dezgeg, sure, but how do I get it to delay loading the module?

@peterhoeg peterhoeg force-pushed the p/nvidia branch 3 times, most recently from cf33f68 to 08bfc29 Compare April 23, 2017 15:35
@peterhoeg
Copy link
Member Author

peterhoeg commented Apr 23, 2017

@dezgeg and @jansol, we're in business now. I can confirm that it works here.

I haven't mapped all the different card types but let's try with these first.

Please refer to the revised testing steps above.

@jansol
Copy link
Contributor

jansol commented Apr 24, 2017

SDDM still doesn't stay open. Not sure if it's a problem with the driver or something else. https://gist.github.com/jansol/3c88efb903bec9df3e578b942eb82eff

@peterhoeg
Copy link
Member Author

So X is segfaulting. Can you try with the modesetting X driver instead of nouveau (ref item 1)?

@jansol
Copy link
Contributor

jansol commented Apr 25, 2017

With that it works and vdpauinfo output matches what's mentioned here!

@peterhoeg
Copy link
Member Author

@fpletz, any thoughts/commens on this?

Copy link
Member

@fpletz fpletz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterhoeg Sorry for the late response. Code looks fine to me, but can't test as I don't own nvidia graphics hardware.

@peterhoeg
Copy link
Member Author

@fpletz I need to map the remaining models but I obviously cannot test those as I only have on card (and @jansol another). Do you have any preferences regarding how we handle that? Should we simply not map those because we cannot test them or put a massive disclaimer in the documentation? How have you handled firmware for hardware you cannot test in the past?

@7c6f434c
Copy link
Member

7c6f434c commented May 1, 2017

I would support just adding the full mapping while testing as the things go and documenting what is known.

After all, we don't test Linux kernel updates on everything we can find before pushing to master.

@7c6f434c
Copy link
Member

7c6f434c commented May 1, 2017

Hm, in addition to GK107 I have a GM108, what would I need to do to test there?

@peterhoeg
Copy link
Member Author

@7c6f434c, you need to map the gm108 to the correct chip name and then add a call to link_files - I used this for mapping the current ones:
https://nouveau.freedesktop.org/wiki/CodeNames/#NV110

I unfortunately do not know which file to map to for the gm108.

@7c6f434c
Copy link
Member

7c6f434c commented May 1, 2017

Do I understand correctly that you just map the entry outside the parenthesis to the entry inside the parenthesis?

@peterhoeg
Copy link
Member Author

peterhoeg commented May 2, 2017

Indeed it is, BUT in this case we don't have any of the firmware files for the NV110 family so I don't know if that's a case of them being called something else.

In my case (GK107), it was exactly what I did:
https://github.com/NixOS/nixpkgs/pull/25075/files#diff-8d5aad77f256d1c21742a3bc2f6a3e49R12

We have the following firmware files available:
nv98, nva3, nva5, nva8, nvaa, nvac, nvaf, nvc0, nvc1, nvc3, nvc4, nvc8, nvce, nvcf, nvd7, nvd9, nve4, nve6, nve7, nvf0, nvf1, nv106, nv108

But looking at the dates of the release, the Maxwell cards were released after the driver version we're using. I'll see if we can find a newer one.

@peterhoeg
Copy link
Member Author

@edolstra ,

Regarding inclusion in enableAllFirmware, could this package conflict with the full nvidia package? (E.g. cause nvidia.ko to use firmware from this package, which might be a different version of the upstream package.)

The firmware is now located in lib/firmware/nouveau instead and only those models we specifically link end up in lib/firmware/nvidia.

This way we don't inadvertently use the this firmware.

If linux-firmware starts carrying firmware for older nvidia cards we should get a collision.

@7c6f434c
Copy link
Member

7c6f434c commented May 2, 2017 via email

@calvertvl
Copy link
Contributor

I've got a GTX-285 which uses NVA0, if you can find the firmware for that one.

I also have a 560 Ti SLI system, which is either NVC8 or (more likely) NVCE, but it is down at the moment; if no one else can test that firmware, I should have it up enough for testing by the end of May.

@peterhoeg
Copy link
Member Author

I've added support for GTX-285 - can you give it a go please?

@peterhoeg
Copy link
Member Author

Brief update, I'm working on a proper nixos module for this which should make things much nicer to work with.

@baracoder
Copy link
Contributor

(triage) Any progress on this?

@peterhoeg
Copy link
Member Author

Well, it works - someone just need to write the module. I personally don't use the nvidia card any longer as it was just too much trouble and the onboard intel gfx are fine for my case.

@zyradyl
Copy link

zyradyl commented Jul 28, 2019

Hello,

I was actually working on trying to write this myself before I found this pull request, I'd like to take it the rest of the way to getting merged, but I was wondering where I should look for information on converting it to a module?

Sorry if this is obvious, I'm still new to Nix.

@peterhoeg
Copy link
Member Author

peterhoeg commented Jul 29, 2019 via email

@peterhoeg
Copy link
Member Author

Might also make sense to get #49703 merged first.

@stale
Copy link

stale bot commented Jun 1, 2020

Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the
    related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse. 3. Ask on the #nixos channel on
    irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 1, 2020
@peterhoeg
Copy link
Member Author

I'll get this done.

@peterhoeg
Copy link
Member Author

@zyradyl did you get any further with updating the nvidia module by chance?

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 4, 2020
@ryantm ryantm marked this pull request as draft October 23, 2020 03:14
@afrepues
Copy link
Contributor

afrepues commented Dec 4, 2020

@peterhoeg I have some changes that I use in my machine at: https://github.com/afrepues/nixpkgs/tree/nvidia-firmware

Feel free to incorporate whatever you find useful.

@stale
Copy link

stale bot commented Jul 27, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 27, 2021
@peterhoeg peterhoeg removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 29, 2021
@otavio
Copy link
Contributor

otavio commented Feb 15, 2022

What is the status of this PR? @peterhoeg have you finish it so it could be reviewed?

@peterhoeg
Copy link
Member Author

peterhoeg commented Feb 15, 2022 via email

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 21, 2022
@Artturin Artturin closed this Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet