Building nvidia driver on kernel 3.9.0

[nekroman@nekroman ~]$ optirun glxgears
Error: nConfigOptions (16) does not match the actual number of options in
       __driConfigOptions (10).
X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  72 (X_PutImage)
  Serial number of failed request:  33
  Current serial number in output stream:  35

//edit:
Ok I’ve got it! It was wrong configuration of bumblebee. If you have same problem, just change paths in /etc/bumblbee/bumblebee.conf from /usr/lib/nvidia to /usr/lib/nvidia-bumblebee.

Thanks @Unhelpful, you patch woks like a charm.

towo:Defiant> inxi -SG
System:    Host: Defiant Kernel: 3.10-rc2.towo.1 x86_64 (64 bit) 
           Desktop: Xfce 4.10.2 Distro: siduction 12.2.0 Riders on the Storm - xfce - (201212092126)
Graphics:  Card: NVIDIA GK106 [GeForce GTX 650 Ti] X.Org: 1.14.1 driver: nvidia Resolution: 1920x1080@60.0hz 
           GLX Renderer: GeForce GTX 650 Ti/PCIe/SSE2 GLX Version: 4.3.0 NVIDIA 319.17

it is quite different what driver you start with (resp. 32-bit or 64-bit machine):

here is kernel 3.9 on Intel core-i-7 with Sandybridge and
[pearOS 7.0 (Ubuntu 12.10)] with Geforce CUDA Optimus 540M:

the driver package
NVIDIA_CUDA_SDK_1.1_Beta_Linux.run
is working proper here.

I only dont know where to get SDK_2.2 for Linux and knowing not too, if this package
is better than now ? Or is there a newer SDK-package for CUDA under Linux ???

sorry, the posting above is a bit “newbish” of myself - have seen now on nvidia.com
that SDK 1.1 as CUDA package for Linux is the newest at present.
And SDK 2.2 as CUDA packags is for Apple the newest at present.

works in release 3.10.0-0.rc3.git0.1.fc20.x86_64

— nv-procfs.c.orig 2013-05-27 18:51:04.361832467 -0430
+++ nv-procfs.c 2013-05-27 18:52:30.267642126 -0430
@@ -34,6 +34,27 @@
“provides a short text file with a short description of itself\n”
“in this directory.\n”;

+struct proc_dir_entry {

  • unsigned int low_ino;
  • umode_t mode;
  • nlink_t nlink;
  • kuid_t uid;
  • kgid_t gid;
  • loff_t size;
  • const struct inode_operations *proc_iops;
  • const struct file_operations *proc_fops;
  • struct proc_dir_entry *next, *parent, *subdir;
  • void *data;
  • atomic_t count; /* use count */
  • atomic_t in_use; /* number of callers into module in progress; */
  •   	/* negative -> it's going away RSN */
    
  • struct completion *pde_unload_completion;
  • struct list_head pde_openers; /* who did ->open, but not ->release */
  • spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */
  • u8 namelen;
  • char name;
  • };

static struct proc_dir_entry *proc_nvidia;
static struct proc_dir_entry *proc_nvidia_warnings;
static struct proc_dir_entry *proc_nvidia_patches;
@@ -45,48 +66,33 @@

static char nv_registry_keys[NV_MAX_REGISTRY_KEYS_LENGTH];

-#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
-#define NV_SET_PROC_ENTRY_OWNER(entry) ((entry)->owner = THIS_MODULE)
-#else
-#define NV_SET_PROC_ENTRY_OWNER(entry)
-#endif

-#define NV_CREATE_PROC_ENTRY(name,mode,parent) \

  • ({ \
  •    struct proc_dir_entry *__entry;                   \
    
  •    __entry = create_proc_entry(name, mode, parent);  \
    
  •    if (__entry != NULL)                              \
    
  •        NV_SET_PROC_ENTRY_OWNER(__entry);             \
    
  •    __entry;                                          \
    
  • })

#define NV_CREATE_PROC_FILE(name,parent,__read_proc,
__write_proc,__fops,__data)
({ \

  •    struct proc_dir_entry *__entry;                        \
    
  •    int __mode = (S_IFREG | S_IRUGO);                      \
    
  •   int __mode;                                             \
    
  •   static struct file_operations fops = {                  \
    
  •      .owner = THIS_MODULE,                                \
    
  • }; \
  •                                                           \
    
  •    if((NvUPtr)(__fops) != 0 )                             \
    
  •    fops = *(struct file_operations * )__fops;             \
    
  • fops.read = (ssize_t (*) (struct file *, char __user *, size_t, loff_t *))__read_proc; \
  • fops.write = (ssize_t (*) (struct file *, const char __user *, size_t, loff_t *))__write_proc; \
  •                                                           \
    
  •    __mode = (S_IFREG | S_IRUGO);                          \
       if ((NvUPtr)(__write_proc) != 0)                       \
           __mode |= S_IWUSR;                                 \
    
  •    __entry = NV_CREATE_PROC_ENTRY(name, __mode, parent);  \
    
  •    if (__entry != NULL)                                   \
    
  •    {                                                      \
    
  •        if ((NvUPtr)(__read_proc) != 0)                    \
    
  •            __entry->read_proc = (__read_proc);            \
    
  •        if ((NvUPtr)(__write_proc) != 0)                   \
    
  •        {                                                  \
    
  •            __entry->write_proc = (__write_proc);          \
    
  •            __entry->proc_fops = (__fops);                 \
    
  •        }                                                  \
    
  •        __entry->data = (__data);                          \
    
  •    }                                                      \
    
  •    __entry;                                               \
    
  •                                                           \
    
  •   proc_create_data(name, __mode,  parent, &fops, __data); \
    
    })

#define NV_CREATE_PROC_DIR(name,parent)
({
struct proc_dir_entry *__entry;
int __mode = (S_IFDIR | S_IRUGO | S_IXUGO); \

  •    __entry = NV_CREATE_PROC_ENTRY(name, __mode, parent);  \
    
  •    __entry = proc_create("gpus",__mode, parent,NULL);     \
       __entry;                                               \
    
    })

The patch compiles fine, but not working so fine.
It give some prints in dmesg, and in optimus technology it wont turn off the power of the card.

andresu, one of the calls to NV_CREATE_PROC_FILE is wrapped in nv_procfs_add_text_file. I don’t see how you don’t end up with a single static struct file_operations that every caller for this shares, or how a simple cast is supposed to do anything about the different call signatures of the struct file_operations members and the deprecated struct proc_dir_entry members. Did you test the files under /proc with this patch?

How do you apply this patch ??

Thanks

mahashakti89

Run the NVIDIA-XXXXX.run with --extract-only, cd into the directory and run

patch -p1 <$PATCHFILE

Thanks unhelpful, but I don’t know what to do with the patched and extracted files…I can’t run the biinary file nvidia-installer inside the extracted directory, and --apply-patch complains that i don’t know what i’m doing (true). Do I re-archive the .run? How does that happen? Thanks for any help – I’m so close!

my super awesome 3.10 kernel with bcache is stuck in tty…sad…

i used the --apply-patch option and pointed it at the files with a copy and paste, which worked to make the -custom.run.

And it works! A reboot brings up X. thanks again unhelpful. i’m going to try it against the 319.23 now, which i’d been running on my gt 630.

# sh ./NVIDIA-Linux-x86_64-319.17.run --apply-patch nvidia-3.10-rc2.diff 
Verifying archive integrity... OK
Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 319.17.....................................................................................................................................................................
can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -ur -X - NVIDIA-Linux-x86_64-319.17-no-compat32.orig/kernel/nv-i2c.c NVIDIA-Linux-x86_64-319.17-no-compat32/kernel/nv-i2c.c
|--- NVIDIA-Linux-x86_64-319.17-no-compat32.orig/kernel/nv-i2c.c	2013-04-26 00:22:30.000000000 -0400
|+++ NVIDIA-Linux-x86_64-319.17-no-compat32/kernel/nv-i2c.c	2013-05-13 05:20:55.571981365 -0400
--------------------------
File to patch: kernel/nv-i2c.c
patching file kernel/nv-i2c.c
can't find file to patch at input line 35
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -ur -X - NVIDIA-Linux-x86_64-319.17-no-compat32.orig/kernel/nv-procfs.c NVIDIA-Linux-x86_64-319.17-no-compat32/kernel/nv-procfs.c
|--- NVIDIA-Linux-x86_64-319.17-no-compat32.orig/kernel/nv-procfs.c	2013-04-26 00:22:30.000000000 -0400
|+++ NVIDIA-Linux-x86_64-319.17-no-compat32/kernel/nv-procfs.c	2013-05-22 04:52:45.229495748 -0400
--------------------------
File to patch: kernel/nv-procfs.c
patching file kernel/nv-procfs.c
Adding files to archive named "NVIDIA-Linux-x86_64-319.17-custom.run"...
./32/
./32/libnvidia-encode.so.319.17
(adding files)
./libnvidia-glcore.so.319.17

CRC: 2048563996
MD5: 53e412c78d7ca4717313fd35a133dab6

Self-extractible archive "NVIDIA-Linux-x86_64-319.17-custom.run" successfully created.

the patch works on 319.23 with the same copy and paste of kernel/nv-i2c.c and kernel/nv-procfs.c to build a -319.23-custom.run which installs a working driver, uninstalling .17 along the way. Needed a killall gdm first.

Hi, I modified the patch to apply successfully on 325.08

https://gist.github.com/clemensg/5958970

Usage:

patch -p1 < nvidia-linux-3.10.patch