new Kernel4.16 and Nvidia Driver

Sauerland, thanks for sharing https://bugzilla.opensuse.org/attachment.cgi?id=766471&action=diff.

If I understand correctly, I can hand-edit as root /usr/src/nvidia-390.48/common/inc/nv-linux.h , add

#if 0

after NvBool swiotlb_in_use = NV_FALSE; on line 1211. I then scroll to the second of two #endif on what will now be line 1254, and add an additional

#endif

after it (thus giving me three #endif in a row before return swiotlb_in_use;

And that’s it! No other changes. (Although I think you mentioned the need to delete a line in your post #14, above. If so, I couldn’t find the line that needs to be cut.)

(I ask because I already tried the patch – my first ever – and didn’t make it work. I may not understand how to edit the path lines at the patch start.)

You have to rebuild the rpm…

But I think, there will be soon a new Nvidia packege in the Repo.

Is there a command to rebuild the rpm? That’s a new term for me, I’m afraid, and Google just gave me contradictory answers on what it means. (I understand that I’d need to reinstall the driver, of course.)

I also could extract the .run file, hand edit the nv-linux.h file as described, then run nvidia-installer as you suggested in post 14.

Yes, the patch has been added in the devel project on OBS 5 hours ago.
I’d expect it to show up in the repo in a day or two…

Thanks for joining in, Wolfi. I wasn’t able to get the Cinnamon desktop to work with the nvidia repo – IceWM only, as I recall – so have installed the driver “the hard way.” Will the addition to the repo help me, or will I either have to wait for a new driver from nvidia or figure out how to make the patch work?

You can patch the nvidia run file directly with

NVIDIAxxx.run --apply-patch /path/to/patch

It produces another run file with a slightly different name.
You may have to tell it the corect file to patch if it starts in the wrong folder level but that’s fairly easy because it tells you what it’s looking for. That’s what the ‘p’ option is for in one of the previous replies but I’m not sure --apply-patch accepts that option.

O, simplicity … :wink:

The repo will contain driver packages with the patch applied already. So yes, if you add the repo, you don’t have to patch it yourself.
But it’s not in the repo yet.
And you should uninstall the installed driver first before you install the rpms from the repo.

Also, you should be able to just boot the older 4.15.x kernel for now (choose it in “Advanced Options” in the boot menu), where the driver should work, until an update is available. (Unless this is a fresh installation of course)
openSUSE normally keeps 2 kernels installed by default.

Thank you all for your help.
I did not want to be misunderstood with this post. I did not know what to do yet.

There is a word: When a man knows more he need few words to understand. When he knows less he need more words.
I am the second one in linux.

I have nvidia installed from repository not “hard way”.

So, in my #16 post when I said “I read it” I want to say that I open the patch file and I see the right and left panel.
What I did not understand:
in patch file was : Unknown/Nvidia-Linux-x86…/kernel/common/inc/nv-linux.h ,
what I find in my TW was: /usr/src/kernel-module/nvidia-390.48-default/common/inc/nv-linux.h
Another nv-linux.h I did not find.

I read #14 - I find two files to add but I did not find one file to delete.

So, if the path is the same, after I will modify the nv-linux.h (I add 2 lines how patch say), what I have to to?

Thank you again for your patience.

PS. I try with patch -p0 (I think p0 not p 0) - cd /directory where nv-linux.h is, patch p0 < /path to patch file, and …
PPS. I find an old post about nvidia driver and how to pacth it. In that post Wolfi said that the command is p1 not p0. I read and the number delete a slash from original file. I tried that way and …
PPPS. I am sure that I do something wrong but I did not know what.

To make it more simplier if you still can’t solve the patch.
Best thing to do is to put the nvidia .run file and the patch file in the same folder.

Now, open a file manager like dolphin, in my case I am using thunar and navigate to the folder where your .run file and the patch file resides.
right click your mouse in dolphin after right clicking the mouse you will see actions in the popup, click it and click open terminal here.
While in the terminal your command will be:

sh NVIDIA-Linux-x86-_64-390.48.run --extract-only

After the command is done it will extract the .run file and will create a new folder named

NVIDIA-Linux-x86-_64-390.48

Using dolphin navigate inside that new folder which is the NVIDIA-Linux-x86-_64-390.48 and right click the mouse and open the terminal as like explained from
above and command

patch -p1 < /path/to/patch/kernel 4.16.patch

(the /path/to/patch/kernel 4.16.patch is the folder where the patch file resides. (Maybe you should
name the patch file as kernel 4.16.patch so as it is easy to remember.

After you are finish with that command to make it easier to install,
put the patch NVIDIA-Linux-x86-_64-390.48 folder into your /home/another_roadrunner.

Now reboot your machine, in the boot selection eg. tumbleweed, press e, at the end of the kernel lines put 3 and press F10
Then login as your user, then cd /home/road_runner/NVIDIA-Linux-x86-_64-390.48
Now when your into the /home/road_runner/NVIDIA-Linux-x86-_64-390.48, su to become root and you issue the command

./nvidia-installer. 

and that’s it, cross your fingers and wait for the result.

Hope this helps.

Thank you @conram.

Sometimes I am a lazy person. With nvidia driver I am sure that I am. So I prefer to install it from repo not “hard way”.

I read about “hard way”.
https://devtalk.nvidia.com/default/topic/1019362/linux/fully-working-patch-for-nvidia-driver-340-102-compiler-installer-file-and-linux-kernel-4-12/
What I did not understand: why you and wolfi323 use “patch p1” (and is working) and the link above and Knurpht said “patch p0”?
I read about p0, 1 etc and the number delete a slash…?

I want to know if a will aplly the patch to /usr/src/kernel-module/nvidia-390.48-default/common/inc/nv-linux.h, what will be the next step?
Or this is not the good way?

Thank you again to all.

After all I installed Nvidia in “hard way” (kernel 4.16) and it is working.
It seems that is the way on TW. I prefer (TW+hard way) than (Leap+repo way). :slight_smile:

BTW now I understand patch p(x) command. With this link (pct.4):
https://www.thegeekstuff.com/2014/12/patch-command-examples/

and this:
http://stephenjungels.com/jungels.net/articles/diff-patch-ten-minutes.html

Thank you for your help.

And I find the answer. How to patch the nvidia driver from TW repo:

https://lists.opensuse.org/opensuse-factory/2018-04/msg00337.html

I am very happy with openSUSE. Thank you all.

Hm?
I did not write anything about “patch” or the -p1 option, and I don’t use it either as I don’t even have an nvidia card… :wink:

But that option tells patch what it should strip from the file names in the patchfile to find the mentioned files.
-p0 means leave them as they are, -p1 means remove the part before the first ‘/’.

I.e. say the patchfile contains this:

--- NVIDIA-Linux-x86_64-390.48/kernel/common/inc/nv-linux.h
+++ NVIDIA-Linux-x86_64-390.48/kernel/common/inc/nv-linux.h
@@ -1209,6 +1209,7 @@ static inline NvU32 nv_alloc_init_flags(
...

(which basically means that the file NVIDIA-Linux-x86_64-390.48/kernel/common/inc/nv-linux.h is to be modified)

‘-p0’ will make patch try to modify the file NVIDIA-Linux-x86_64-390.48/kernel/common/inc/nv-linux.h, i.e. you need a directory NVIDIA-Linux-x86_64-390.48 in the current directory, with subfolders kernel/common/inc/ that contains nv-linux.h.
‘-p1’ will strip the first part, so it will look for kernel/common/inc/nv-linux.h.

What is correct depends e.g. on what your current directory is.

You could also cd to NVIDIA-Linux-x86_64-390.48/kernel/common/inc/ and use “patch -p4”… :wink:

After all I installed Nvidia in “hard way” (kernel 4.16) and it is working.
It seems that is the way on TW.

Well, it’s not the only way.

The nvidia repo does exist for Tumbleweed as well since some months, so the “easy way” is possible on TW as well (only contains the latest G04 driver though, i.e. 390.xx currently). As mentioned this will contain the patch shortly, and then should just work again without any manual action.

Instead of using the .run installer (and applying the patch), it would also be possible to get the rpm packages’ source files from OBS and build the rpm packages yourself (for now, until the patch is in the repo). That’s some way inbetween the “hard way” and the “easy way”… :wink:

But I’ll stop now, as I don’t want to cause more confusion.

I just want to stress again that if you would want to switch back to the repo again at some point, you need to uninstall the manual (“hard way”) driver installation first.
That also applies in the other direction of course, if you used the repo and want to switch to the .run installer, you need to uninstall the nvidia rpm packages first.

Thank you wolfi323.

This is what I talk about:
https://forums.opensuse.org/showthread.php/494816-How-to-patch-nvidia-drivers

Before I put a questions I read what I find. And where I did not understand, I cry for help.:):slight_smile:

Well, that’s been a while, and I think I just copy/pasted this from somewhere (I did not have an nvidia card back then either, nor did/do I use Tumbleweed).

But as I indicated, the “correct” -p value depends on what is specified in the .patch file and what the current directory is.
In the mentioned thread, the patch had:

--- a/kernel/nv-acpi.c
+++ b/kernel/nv-acpi.c

a ‘-p1’ was needed there to get rid of the a/ and b/, which don’t exist in the nvidia sources, so that it would look for kernel/nv-acpi.c instead.
But it’s common to use two differently named folders when creating a .patch file. I.e. you’d put the original sources into a folder ‘a’ e.g. and your modified copy into folder ‘b’, and then run something like “diff -r a b” to create the .patch file (which then will contain the paths a/… and b/… respectively of course).

Thank you wolfi323 for your detailed explanations.
I think now I understand.

I have in my /home/my_name/ directory an Nvidia directory (/home/my_name/NVIDIA-Linux-x86_64-390.48) - after I extract it from nvidia driver.
If a cd in it (/home/my_name/NVIDIA-Linux-x86_64-390.48/) I write "patch p1"because I am inside the directory and I don’t need the first slash (/NVIDIA-Linux-x86_64-390.48/kernel/common/inc/nv-linux.h will be /kernel/common/inc/nv-linux.h).
If I will apply the patch from “/home/my_name/” I will write “patch p0” because the patch will modify “/NVIDIA-Linux-x86_64-390.48/kernel/common/inc/nv-linux.h” not “/kernel/common/inc/nv-linux.h” like above.
It depends from where I write the command.

Yes.

Except that your paths in that post are wrong. “/NVIDIA-Linux-x86_64-390.48” would always be a directory in ‘/’, not in ‘/home/my_name/’. I.e. it’s an absolute path not a relative one.

So to be completely correct, your post should read:

I have in my /home/my_name/ directory an Nvidia directory (/home/my_name/NVIDIA-Linux-x86_64-390.48) - after I extract it from nvidia driver.
If a cd in it (/home/my_name/NVIDIA-Linux-x86_64-390.48/) I write “patch -p1” because I am inside the directory and I don’t need the part before the first slash (NVIDIA-Linux-x86_64-390.48/kernel/common/inc/nv-linux.h will be kernel/common/inc/nv-linux.h).
If I will apply the patch from “/home/my_name/” I will write “patch -p0” because the patch will modify “NVIDIA-Linux-x86_64-390.48/kernel/common/inc/nv-linux.h” not “kernel/common/inc/nv-linux.h” like above.

:wink:

I install the nvidia driver from /home/my_name/Nvidia and it is working.
From command line I write “sh Nvidia …–extract-only”. I cd in this directory (/home/my_name/Nvidia…) and I patch it.
From “/home/my_name/NVIDIA-Linux-x86_64-390.48” I write ./nvidia-installer.
This is the way I install this driver today.
Of course after I boot with “3”. And all I do as “root” with “su-”.

Does it work without any patch for 4.16?