LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-23-2015, 12:01 PM   #1
Lenard Spencer
Member
 
Registered: Sep 2004
Location: Florida
Distribution: Slackware, Linux from Scratch
Posts: 329

Rep: Reputation: 199Reputation: 199
FYI - Nvidia legacy340 and -current


I'm sure many of you have noticed that the Nvidia 340 kernel will no longer build in -current with the new 4.x kernel. I just happened to find a patch over on the nvidia-devel forums that fixes that. I just did it, and it works like a charm. (I'm using it now.)

First the patch (I called it nvidia-upstream.patch)
Code:
--- a/nv-pat.c.orig     2015-02-20 02:49:40.000000000 +0100
+++ b/nv-pat.c  2015-02-25 07:56:40.000000000 +0100
@@ -35,8 +35,13 @@
     unsigned long cr0 = read_cr0();
     write_cr0(((cr0 & (0xdfffffff)) | 0x40000000));
     wbinvd();
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 20, 0)
     *cr4 = read_cr4();
     if (*cr4 & 0x80) write_cr4(*cr4 & ~0x80);
+#else
+    *cr4 = __read_cr4();
+    if (*cr4 & 0x80) __write_cr4(*cr4 & ~0x80);
+#endif
     __flush_tlb();
 }
 
@@ -46,7 +51,11 @@
     wbinvd();
     __flush_tlb();
     write_cr0((cr0 & 0x9fffffff));
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 20, 0)
     if (cr4 & 0x80) write_cr4(cr4);
+#else
+    if (cr4 & 0x80) __write_cr4(cr4);
+#endif   
 }
  static int nv_determine_pat_mode(void)
Then I added this line to the slackbuild script:
Code:
(cd kernel || exit 1 

# Apply patch from upstream to build with 4.x kernels
patch -p1 < $CWD/nvidia-upstream.patch

  make SYSSRC=$KERNELPATH module || exit 1
  cd uvm
  make SYSSRC=$KERNELPATH module || exit 1
)
Note the patch statement is placed BETWEEN 'cd kernel' and the first 'make' statement.

Full credit to the guys on nvidia-devel for the patch, NOT me.

I hope this helps.

PS I almost forgot, only the kernel SB script needs the patch, NOT the driver.

Last edited by Lenard Spencer; 08-23-2015 at 12:02 PM.
 
Old 08-23-2015, 07:10 PM   #2
kingbeowulf
Senior Member
 
Registered: Oct 2003
Location: WA
Distribution: Slackware
Posts: 1,266
Blog Entries: 11

Rep: Reputation: 744Reputation: 744Reputation: 744Reputation: 744Reputation: 744Reputation: 744Reputation: 744
Kernel 4.x may well kill off most of the legacy Nvidia drivers.

@Lenard Spencer, Do you have a link to the original Nvidia-dev post?

Nvidia-304.125 has issues as well:
http://slackblogs.blogspot.com/2015/...kernel-41.html
I'll add these to the my SBo to-do list for when Slackware-current goes stable.

EDIT: Also, allend posted a patch recently: http://www.linuxquestions.org/questi...ml#post5409843
Why doesn't anyone provide source references to patches?

Last edited by kingbeowulf; 08-23-2015 at 07:28 PM. Reason: additional information
 
1 members found this post helpful.
Old 08-24-2015, 01:29 AM   #3
mats_b_tegner
Member
 
Registered: Nov 2009
Location: Gothenburg, Sweden
Distribution: Slackware
Posts: 946

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
Here it is Ed:

https://devtalk.nvidia.com/default/t...functions-fix/

Mats

Last edited by mats_b_tegner; 08-24-2015 at 01:32 AM.
 
Old 08-24-2015, 01:41 AM   #4
Panagiotis Nik
Member
 
Registered: Jul 2014
Distribution: Slackware64-Current, Slackware64-14.2
Posts: 33

Rep: Reputation: Disabled
Just upgraded to 4.x kernel and my 340 kernel refuse to work...
Fixed with this patch!

Thanks @Lenard Spencer
 
Old 08-24-2015, 02:30 AM   #5
ardvark71
LQ Veteran
 
Registered: Feb 2015
Location: USA
Distribution: Lubuntu 14.04, 22.04, Windows 8.1 and 10
Posts: 6,282
Blog Entries: 4

Rep: Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842
Hi Lenard...

Thank you for posting this.

Regards...
 
Old 08-24-2015, 09:23 AM   #6
Lenard Spencer
Member
 
Registered: Sep 2004
Location: Florida
Distribution: Slackware, Linux from Scratch
Posts: 329

Original Poster
Rep: Reputation: 199Reputation: 199
I found another thread for the 304 series. I have a crude patch working, and I will post it as soon as I get it cleaned up.
 
1 members found this post helpful.
Old 08-24-2015, 09:39 AM   #7
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
Many thanks Lenard.
 
Old 08-24-2015, 10:27 AM   #8
Lenard Spencer
Member
 
Registered: Sep 2004
Location: Florida
Distribution: Slackware, Linux from Scratch
Posts: 329

Original Poster
Rep: Reputation: 199Reputation: 199
Final patches for Nvidia 3xx drivers and kernel 4.x

Ok, here are the final patches.

First, for the 340 driver (I changed the names for clarity)

FILENAME: nvidia-legacy340-kernel4.patch

Code:
--- a/nv-pat.c.orig     2015-02-20 02:49:40.000000000 +0100
+++ b/nv-pat.c  2015-02-25 07:56:40.000000000 +0100
@@ -35,8 +35,13 @@
     unsigned long cr0 = read_cr0();
     write_cr0(((cr0 & (0xdfffffff)) | 0x40000000));
     wbinvd();
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 20, 0)
     *cr4 = read_cr4();
     if (*cr4 & 0x80) write_cr4(*cr4 & ~0x80);
+#else
+    *cr4 = __read_cr4();
+    if (*cr4 & 0x80) __write_cr4(*cr4 & ~0x80);
+#endif
     __flush_tlb();
 }
 
@@ -46,7 +51,11 @@
     wbinvd();
     __flush_tlb();
     write_cr0((cr0 & 0x9fffffff));
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 20, 0)
     if (cr4 & 0x80) write_cr4(cr4);
+#else
+    if (cr4 & 0x80) __write_cr4(cr4);
+#endif   
 }
  static int nv_determine_pat_mode(void)
Add these lines at line 82 in nvidia-legacy340-kernel.SlackBuild:

Code:
# Apply patch from nvidia-devel to build with 4.x kernels
patch -p1 < $CWD/nvidia-legacy340-kernel4.patch
For the 304 driver:

FILENAME: nvidia-legacy304-kernel4.patch

Code:
--- a/nv.c 2014-12-01 19:58:34.000000000 -0800
+++ b/nv.c 2015-07-09 16:45:09.997840781 -0700
@@ -2026,7 +2026,11 @@
     unsigned long i_arg
 )
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 20, 0)
     return nv_kern_ioctl(file->f_dentry->d_inode, file, cmd, i_arg);
+#else
+    return nv_kern_ioctl(file_inode(file), file, cmd, i_arg);
+#endif
 }
 
 long nv_kern_compat_ioctl(
@@ -2035,7 +2039,11 @@
 unsigned long i_arg
 )
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 20, 0)
     return nv_kern_ioctl(file->f_dentry->d_inode, file, cmd, i_arg);
+#else
+    return nv_kern_ioctl(file_inode(file), file, cmd, i_arg);
+#endif
 }
 
 /*
--- a/nv-pat.c 2014-12-01 19:58:34.000000000 -0800
+++ b/nv-pat.c 2015-07-09 16:48:00.069823572 -0700
@@ -35,8 +35,13 @@
     unsigned long cr0 = read_cr0();
     write_cr0(((cr0 & (0xdfffffff)) | 0x40000000));
     wbinvd();
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 20, 0)
     *cr4 = read_cr4();
     if (*cr4 & 0x80) write_cr4(*cr4 & ~0x80);
+#else
+    *cr4 = __read_cr4();
+    if (*cr4 & 0x80) __write_cr4(*cr4 & ~0x80);
+#endif
     __flush_tlb();
 }
 
@@ -46,7 +51,11 @@
     wbinvd();
     __flush_tlb();
     write_cr0((cr0 & 0x9fffffff));
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 20, 0)
     if (cr4 & 0x80) write_cr4(cr4);
+#else
+    if (cr4 & 0x80) __write_cr4(cr4);
+#endif   
 }
  static int nv_determine_pat_mode(void)
In nvidia-legacy304-kernel.SlackBuild, add these lines, also at line 82:

Code:
# Apply patch from nvidia-devel to build with 4.x kernels
patch -p1 < $CWD/nvidia-legacy304-kernel4.patch
I hope these help.

Maybe someday when I hear the men in the white coats sneaking up behind me, I may look at the 174 driver as well. (Yes, I still have a couple of 5200FX cards lying around!)
 
3 members found this post helpful.
Old 08-24-2015, 10:32 AM   #9
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,901

Rep: Reputation: 5024Reputation: 5024Reputation: 5024Reputation: 5024Reputation: 5024Reputation: 5024Reputation: 5024Reputation: 5024Reputation: 5024Reputation: 5024Reputation: 5024
update:

My patch is no longer necessary as nvidia have released 304.128 which supports up to and including 4.1.y, so I've removed it.

Last edited by GazL; 09-01-2015 at 04:53 AM.
 
Old 08-24-2015, 11:40 AM   #10
Lenard Spencer
Member
 
Registered: Sep 2004
Location: Florida
Distribution: Slackware, Linux from Scratch
Posts: 329

Original Poster
Rep: Reputation: 199Reputation: 199
Kingbeowulf, you can probably put these in the Slack 14.1 SB repo as well, for the benefit of those running multiboot machines with -current (as I am). I just went back and checked them out in 14.1 with no issues.

Thanks for your SB scripts!
 
Old 08-24-2015, 05:20 PM   #11
willysr
Senior Member
 
Registered: Jul 2004
Location: Jogja, Indonesia
Distribution: Slackware-Current
Posts: 4,664

Rep: Reputation: 1786Reputation: 1786Reputation: 1786Reputation: 1786Reputation: 1786Reputation: 1786Reputation: 1786Reputation: 1786Reputation: 1786Reputation: 1786Reputation: 1786
SBo is designed to be used against -stable releases, so it's not needed for now, not until next SLackware is released
 
Old 08-24-2015, 05:30 PM   #12
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
It can always be added with the patch command commented out. Getting -Current ready for 14.2 is what has been ongoing for some time in the other topic, plus it could always be relegated to the main trunk or testing branch trunk (?) of the SBo tree while remaining out of 14.1 branch. Good question, but does it affect 14.1 and prevent building the kernel module?
 
Old 08-24-2015, 05:54 PM   #13
willysr
Senior Member
 
Registered: Jul 2004
Location: Jogja, Indonesia
Distribution: Slackware-Current
Posts: 4,664

Rep: Reputation: 1786Reputation: 1786Reputation: 1786Reputation: 1786Reputation: 1786Reputation: 1786Reputation: 1786Reputation: 1786Reputation: 1786Reputation: 1786Reputation: 1786
perhaps adding it to Ponce's current branch is more appropriate. It will gets merged to master when we think next Slackware is close to be released
 
Old 08-24-2015, 09:20 PM   #14
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
+1 on that.
 
Old 08-27-2015, 01:24 AM   #15
kingbeowulf
Senior Member
 
Registered: Oct 2003
Location: WA
Distribution: Slackware
Posts: 1,266
Blog Entries: 11

Rep: Reputation: 744Reputation: 744Reputation: 744Reputation: 744Reputation: 744Reputation: 744Reputation: 744
Thanks to lenard, gazl and willysr for the nvidia patches and links. I hadn't noticed since I was fiddling with current on 2 laptops with Intel GPUs. I'll add them to my local SBo branch and track ponce's to get ready for when current goes stable "real soon now" <crosses fingers>.

Lenard, trying to wrestle support for older nvidia legacy might be an exercise in futility. Nothing prior to 304.xx has been updated for newer X.Org servers and Mesa since 2013. Your 5200FX cards might be a lost cause. I've stopped supporting 173-legacy and 96-legacy in SBo and dumped my old cards. "Help me, nouveau, you're my only hope."
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
FYI: libmad-0.15.1b wont build in slackwar64-current 66slacker Slackware 1 06-28-2009 07:24 AM
just FYI, article nvidia geforce8200 igp hottdogg Linux - Hardware 0 06-22-2008 10:19 AM
nvidia driver 'missing' after ~current and running sh NVIDIA soylentgreen Slackware 13 03-26-2007 09:17 PM
just FYI on new Nvidia driver site Lleb_KCir Linux - Hardware 2 02-24-2005 09:21 PM
FYI: current elflibs-9.1.0-2 causes 'startx' problems for me BearClaw Slackware 0 09-20-2003 10:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration