[packages/xorg-driver-video-nvidia-legacy3] - import debian's patchwork to build properly with latest kernels (3.10+) - rel 15

baggins baggins at pld-linux.org
Sun Aug 25 12:28:14 CEST 2013


commit 82e9c52fb157978f9e04542b89004af3f3f87af0
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sun Aug 25 12:27:45 2013 +0200

    - import debian's patchwork to build properly with latest kernels (3.10+)
    - rel 15

 conftest.h                                   | 470 ++++++++++++++++++++
 conftest.sh                                  |   7 +
 linux-3.10-i2c.patch                         |  49 +++
 linux-3.10-procfs.patch                      | 633 +++++++++++++++++++++++++++
 linux-3.11.patch                             |  27 ++
 nvidia-blacklist-vga-pmu-registers-195.patch |  30 ++
 patches.h                                    |   5 +
 xorg-driver-video-nvidia-legacy3.spec        |  17 +-
 8 files changed, 1237 insertions(+), 1 deletion(-)
---
diff --git a/xorg-driver-video-nvidia-legacy3.spec b/xorg-driver-video-nvidia-legacy3.spec
index bd254b5..d9a668b 100644
--- a/xorg-driver-video-nvidia-legacy3.spec
+++ b/xorg-driver-video-nvidia-legacy3.spec
@@ -19,7 +19,7 @@
 %endif
 %define		no_install_post_check_so	1
 
-%define		rel		14
+%define		rel		15
 %define		pname		xorg-driver-video-nvidia-legacy3
 Summary:	Linux Drivers for nVidia GeForce/Quadro Chips (173.14.xx series)
 Summary(hu.UTF-8):	Linux meghajtók nVidia GeForce/Quadro chipekhez
@@ -36,8 +36,15 @@ Source1:	ftp://download.nvidia.com/XFree86/Linux-x86_64/%{version}/NVIDIA-Linux-
 Source2:	%{pname}-xinitrc.sh
 Source3:	10-nvidia.conf
 Source4:	10-nvidia-modules.conf
+Source5:	patches.h
+Source6:	conftest.h
+Source7:	conftest.sh
 Patch0:		X11-driver-nvidia-GL.patch
 Patch1:		X11-driver-nvidia-legacy-desktop.patch
+Patch2:		linux-3.10-i2c.patch
+Patch3:		linux-3.10-procfs.patch
+Patch4:		linux-3.11.patch
+Patch5:		nvidia-blacklist-vga-pmu-registers-195.patch
 URL:		http://www.nvidia.com/object/unix.html
 %if %{with kernel}
 %{?with_dist_kernel:BuildRequires:	kernel%{_alt_kernel}-module-build >= 3:2.6.20.2}
@@ -218,6 +225,14 @@ rm -rf NVIDIA-Linux-x86*-%{version}-pkg*
 %endif
 %patch0 -p1
 %patch1 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+
+install %{SOURCE5} usr/src/nv/
+install %{SOURCE6} usr/src/nv/
+install -m 755 %{SOURCE7} usr/src/nv/
 echo 'EXTRA_CFLAGS += -Wno-pointer-arith -Wno-sign-compare -Wno-unused' >> usr/src/nv/Makefile.kbuild
 
 %build
diff --git a/conftest.h b/conftest.h
new file mode 100644
index 0000000..8013014
--- /dev/null
+++ b/conftest.h
@@ -0,0 +1,470 @@
+/* synchronized with conftest.sh from 325.15, 319.32, 313.30, 310.51, 304.108, 295.75, 173.14.37, 96.43.23, 71.86.15 */
+
+#ifndef LINUX_VERSION_CODE
+#include <linux/version.h>
+#endif
+
+#if !defined(IS_ENABLED) && LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
+#define __ARG_PLACEHOLDER_1 0,
+#define config_enabled(cfg) _config_enabled(cfg)
+#define _config_enabled(value) __config_enabled(__ARG_PLACEHOLDER_##value)
+#define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0)
+#define ___config_enabled(__ignored, val, ...) val
+#define IS_ENABLED(option) (config_enabled(option) || config_enabled(option##_MODULE))
+#endif
+
+/* Implement conftest.sh function nvidiafb_sanity_check */
+#if IS_ENABLED(CONFIG_FB_NVIDIA)
+#warning "The nvidia module is incompatible with nvidiafb!"
+#endif
+
+/* Implement conftest.sh function xen_sanity_check */
+#if IS_ENABLED(CONFIG_XEN) && ! IS_ENABLED(CONFIG_PARAVIRT)
+#warning "Xen kernels are not supported!"
+#endif
+
+/* Implement conftest.sh function preempt_rt_sanity_check */
+#if IS_ENABLED(CONFIG_PREEMPT_RT) || IS_ENABLED(CONFIG_PREEMPT_RT_FULL)
+#warning "PREEMPT_RT kernels are not supported!"
+#endif
+
+/* Implement conftest.sh function remap_page_range */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+  #define NV_REMAP_PAGE_RANGE_PRESENT
+  #define NV_REMAP_PAGE_RANGE_ARGUMENT_COUNT 4
+ #else
+  #define NV_REMAP_PAGE_RANGE_PRESENT
+  #define NV_REMAP_PAGE_RANGE_ARGUMENT_COUNT 5
+ #endif
+#else
+ #undef NV_REMAP_PAGE_RANGE_PRESENT
+#endif
+
+/* Implement conftest.sh function set_memory_uc */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25) && IS_ENABLED(CONFIG_X86)
+ #define NV_SET_MEMORY_UC_PRESENT
+#else
+ #undef NV_SET_MEMORY_UC_PRESENT
+#endif
+
+/* Implement conftest.sh function set_memory_array_uc */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28) && IS_ENABLED(CONFIG_X86)
+ #define NV_SET_MEMORY_ARRAY_UC_PRESENT
+#else
+ #undef NV_SET_MEMORY_ARRAY_UC_PRESENT
+#endif
+
+/* Implement conftest.sh function set_pages_uc */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25) && IS_ENABLED(CONFIG_X86)
+ #define NV_SET_PAGES_UC_PRESENT
+#else
+ #undef NV_SET_PAGES_UC_PRESENT
+#endif
+
+/* Implement conftest.sh function outer_flush_all */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34) && IS_ENABLED(CONFIG_ARM)
+ #define NV_OUTER_FLUSH_ALL_PRESENT
+#else
+ #undef NV_OUTER_FLUSH_ALL_PRESENT
+#endif
+
+/* Implement conftest.sh function change_page_attr */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20) && \
+               LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
+ #define NV_CHANGE_PAGE_ATTR_PRESENT
+#else
+ #undef NV_CHANGE_PAGE_ATTR_PRESENT
+#endif
+
+/* Implement conftest.sh function pci_get_class */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+ #define NV_PCI_GET_CLASS_PRESENT
+#else
+ #undef NV_PCI_GET_CLASS_PRESENT
+#endif
+
+/* Implement conftest.sh function pci_get_domain_bus_and_slot */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+ #define NV_PCI_GET_DOMAIN_BUS_AND_SLOT_PRESENT
+#else
+ #undef NV_PCI_GET_DOMAIN_BUS_AND_SLOT_PRESENT
+#endif
+
+/* Implement conftest.sh function remap_pfn_range */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+ #define NV_REMAP_PFN_RANGE_PRESENT
+#else
+ #undef NV_REMAP_PFN_RANGE_PRESENT
+#endif
+
+/* Implement conftest.sh function agp_backend_acquire */
+/* Only kernels sometime before 2.4.0 don't have this function, and who */
+/* cares anymore */
+#define NV_AGP_BACKEND_ACQUIRE_PRESENT
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
+ #define NV_AGP_BACKEND_ACQUIRE_ARGUMENT_COUNT 1
+#else
+ #define NV_AGP_BACKEND_ACQUIRE_ARGUMENT_COUNT 0
+#endif
+
+/* Implement conftest.sh function vmap */
+/* I can not find any released kernel that uses the 2 argument variant */
+/* of vmap */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,22)
+ #define NV_VMAP_PRESENT
+ #define NV_VMAP_ARGUMENT_COUNT 4
+#else
+ #undef NV_VMAP_PRESENT
+#endif
+
+/* Implement conftest.sh function i2c_adapter */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ #define NV_I2C_ADAPTER_HAS_INC_USE
+ #define NV_I2C_ADAPTER_HAS_DEC_USE
+ #define NV_I2C_ADAPTER_HAS_CLIENT_REGISTER
+#else
+ #undef NV_I2C_ADAPTER_HAS_INC_USE
+ #undef NV_I2C_ADAPTER_HAS_DEC_USE
+ #undef NV_I2C_ADAPTER_HAS_CLIENT_REGISTER
+#endif
+
+/* Implement conftest.sh function pm_message_t */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+ #define NV_PM_MESSAGE_T_PRESENT
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
+  #define NV_PM_MESSAGE_T_HAS_EVENT
+ #else
+  #undef NV_PM_MESSAGE_T_HAS_EVENT
+ #endif
+#else
+ #undef NV_PM_MESSAGE_T_PRESENT
+ #undef NV_PM_MESSAGE_T_HAS_EVENT
+#endif
+
+/* Implement conftest.sh function pci_choose_state */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+ #define NV_PCI_CHOOSE_STATE_PRESENT
+#else
+ #undef NV_PCI_CHOOSE_STATE_PRESENT
+#endif
+
+/* Implement conftest.sh function vm_insert_page */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
+ #define NV_VM_INSERT_PAGE_PRESENT
+#else
+ #undef NV_VM_INSERT_PAGE_PRESENT
+#endif
+
+/* Implement conftest.sh function irq_handler_t */
+/* I can not find any released kernel that uses the 3 argument variant */
+/* of irq_handler_t */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
+ #define NV_IRQ_HANDLER_T_PRESENT
+ #define NV_IRQ_HANDLER_T_ARGUMENT_COUNT 2
+#else
+ #undef NV_IRQ_HANDLER_T_PRESENT
+#endif
+
+/* Implement conftest.sh function acpi_device_ops */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10) && \
+               LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
+ #define NV_ACPI_DEVICE_OPS_HAS_MATCH
+#else
+ #undef NV_ACPI_DEVICE_OPS_HAS_MATCH
+#endif
+
+/* Implement conftest.sh function acpi_device_id */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
+ #define NV_ACPI_DEVICE_ID_HAS_DRIVER_DATA
+#else
+ #undef NV_ACPI_DEVICE_ID_HAS_DRIVER_DATA
+#endif
+
+/* Implement conftest.sh function acquire_console_sem */
+// 2.6.38 renamed {acquire,release}_console_sem() to console_{,un}lock()
+// but NVIDIA neither checks for these new names nor uses them
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,10) && \
+    LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
+ #define NV_ACQUIRE_CONSOLE_SEM_PRESENT
+#else
+ #undef NV_ACQUIRE_CONSOLE_SEM_PRESENT
+#endif
+
+/* Implement conftest.sh function kmem_cache_create */
+/* Only kernels sometime before 2.4.0 don't have this function, and who */
+/* cares anymore */
+#define NV_KMEM_CACHE_CREATE_PRESENT
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
+ #define NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT 5
+#else
+ #define NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT 6
+#endif
+
+/* Implement conftest.sh function smp_call_function */
+/* Only kernels sometime before 2.4.0 don't have this function, and who */
+/* cares anymore */
+#define NV_SMP_CALL_FUNCTION_PRESENT
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ #define NV_SMP_CALL_FUNCTION_ARGUMENT_COUNT 3
+#else
+ #define NV_SMP_CALL_FUNCTION_ARGUMENT_COUNT 4
+#endif
+
+/* Implement conftest.sh function on_each_cpu */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ #define NV_ON_EACH_CPU_PRESENT
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+  #define NV_ON_EACH_CPU_ARGUMENT_COUNT 3
+ #else
+  #define NV_ON_EACH_CPU_ARGUMENT_COUNT 4
+ #endif
+#else
+ #undef NV_ON_EACH_CPU_PRESENT
+#endif
+
+/* Implement conftest.sh function vmm_support */
+/* nv-xen.h does not exist */
+#undef HAVE_NV_XEN
+
+/* Implement conftest.sh function nvmap_support */
+/* nv-android.h does not exist */
+#undef HAVE_NV_ANDROID
+
+/* Implement conftest.sh function acpi_evaluate_integer */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,19)
+ #define NV_ACPI_EVALUATE_INTEGER_PRESENT
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
+  typedef unsigned long long nv_acpi_integer_t;
+ #else
+  typedef unsigned long nv_acpi_integer_t;
+ #endif
+#else
+ #undef NV_ACPI_EVALUATE_INTEGER_PRESENT
+ typedef unsigned long nv_acpi_integer_t;
+#endif
+
+/* Implement conftest.sh function acpi_walk_namespace */
+/* Only kernels sometime before 2.4.0 don't have this function, and who */
+/* cares anymore */
+#define NV_ACPI_WALK_NAMESPACE_PRESENT
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+ #define NV_ACPI_WALK_NAMESPACE_ARGUMENT_COUNT 7
+#else
+ #define NV_ACPI_WALK_NAMESPACE_ARGUMENT_COUNT 6
+#endif
+
+/* Implement conftest.sh function acpi_os_wait_events_complete */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,7)
+ #define NV_ACPI_OS_WAIT_EVENTS_COMPLETE_PRESENT
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+  #define NV_ACPI_OS_WAIT_EVENTS_COMPLETE_ARGUMENT_COUNT 0
+ #else
+  #define NV_ACPI_OS_WAIT_EVENTS_COMPLETE_ARGUMENT_COUNT 1
+ #endif
+#else
+ #undef NV_ACPI_OS_WAIT_EVENTS_COMPLETE_PRESENT
+#endif
+
+/* Implement conftest.sh function ioremap_cache */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25) && IS_ENABLED(CONFIG_X86)
+ #define NV_IOREMAP_CACHE_PRESENT
+#else
+ #undef NV_IOREMAP_CACHE_PRESENT
+#endif
+
+/* Implement conftest.sh function ioremap_wc */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
+ #define NV_IOREMAP_WC_PRESENT
+#else
+ #undef NV_IOREMAP_WC_PRESENT
+#endif
+
+/* Implement conftest.sh function proc_dir_entry */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
+ #define NV_PROC_DIR_ENTRY_HAS_OWNER
+#else
+ #undef NV_PROC_DIR_ENTRY_HAS_OWNER
+#endif
+
+/* Implement conftest.sh function INIT_WORK */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,41)
+ #define NV_INIT_WORK_PRESENT
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+  #define NV_INIT_WORK_ARGUMENT_COUNT 2
+ #else
+  #define NV_INIT_WORK_ARGUMENT_COUNT 3
+ #endif
+#else
+ #undef NV_INIT_WORK_PRESENT
+#endif
+
+/* Implement conftest.sh function pci_dma_mapping_error */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,5)
+ #define NV_PCI_DMA_MAPPING_ERROR_PRESENT
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+  #define NV_PCI_DMA_MAPPING_ERROR_ARGUMENT_COUNT 2
+ #else
+  #define NV_PCI_DMA_MAPPING_ERROR_ARGUMENT_COUNT 1
+ #endif
+#else
+ #undef NV_PCI_DMA_MAPPING_ERROR_PRESENT
+#endif
+
+/* Implement conftest.sh function agp_memory */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
+ #define NV_AGP_MEMORY_HAS_PAGES
+#else
+ #undef NV_AGP_MEMORY_HAS_PAGES
+#endif
+
+/* Implement conftest.sh function scatterlist */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
+ #define NV_SCATTERLIST_HAS_PAGE
+#else
+ #undef NV_SCATTERLIST_HAS_PAGE
+#endif
+
+/* Implement conftest.sh function pci_domain_nr */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,71)
+ #define NV_PCI_DOMAIN_NR_PRESENT
+#else
+ #undef NV_PCI_DOMAIN_NR_PRESENT
+#endif
+
+/* Implement conftest.sh function file_operations */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
+ #define NV_FILE_OPERATIONS_HAS_IOCTL
+#else
+ #undef NV_FILE_OPERATIONS_HAS_IOCTL
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+ #define NV_FILE_OPERATIONS_HAS_UNLOCKED_IOCTL
+ #define NV_FILE_OPERATIONS_HAS_COMPAT_IOCTL
+#else
+ #undef NV_FILE_OPERATIONS_HAS_UNLOCKED_IOCTL
+ #undef NV_FILE_OPERATIONS_HAS_COMPAT_IOCTL
+#endif
+
+/* Implement conftest.sh function efi_enabled */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,1)
+ #define NV_EFI_ENABLED_PRESENT
+#else
+ #undef NV_EFI_ENABLED_PRESENT
+#endif
+
+/* Implement conftest.sh function dom0_kernel_present */
+#if 0
+ #define NV_DOM0_KERNEL_PRESENT
+#else
+ #undef NV_DOM0_KERNEL_PRESENT
+#endif
+
+/* Implement conftest.sh function drm_available */
+#if 0
+ #define NV_DRM_AVAILABLE
+#else
+ #undef NV_DRM_AVAILABLE
+#endif
+
+/* Implement conftest.sh function proc_create_data */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
+ #define NV_PROC_CREATE_DATA_PRESENT
+#else
+ #undef NV_PROC_CREATE_DATA_PRESENT
+#endif
+
+/* Implement conftest.sh function pde_data */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
+ #define NV_PDE_DATA_PRESENT
+#else
+ #undef NV_PDE_DATA_PRESENT
+#endif
+
+/* Implement conftest.sh function proc_remove */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
+ #define NV_PROC_REMOVE_PRESENT
+#else
+ #undef NV_PROC_REMOVE_PRESENT
+#endif
+
+/* Implement conftest.sh function sg_init_table */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+ #define NV_SG_INIT_TABLE_PRESENT
+#else
+ #undef NV_SG_INIT_TABLE_PRESENT
+#endif
+
+/* Check for linux/semaphore.h */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
+ #define NV_LINUX_SEMAPHORE_H_PRESENT
+#else
+ #undef NV_LINUX_SEMAPHORE_H_PRESENT
+#endif
+
+/* Check for linux/cred.h */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ #define NV_LINUX_CRED_H_PRESENT
+#else
+ #undef NV_LINUX_CRED_H_PRESENT
+#endif
+
+/* Check for drm/drmP.h */
+#if 1
+ #define NV_DRM_DRMP_H_PRESENT
+#else
+ #undef NV_DRM_DRMP_H_PRESENT
+#endif
+
+/* Check for generated/autoconf.h */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+ #define NV_GENERATED_AUTOCONF_H_PRESENT
+#else
+ #undef NV_GENERATED_AUTOCONF_H_PRESENT
+#endif
+
+/* Check for generated/compile.h */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+ #define NV_GENERATED_COMPILE_H_PRESENT
+#else
+ #undef NV_GENERATED_COMPILE_H_PRESENT
+#endif
+
+/* Check for generated/utsrelease.h */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+ #define NV_GENERATED_UTSRELEASE_H_PRESENT
+#else
+ #undef NV_GENERATED_UTSRELEASE_H_PRESENT
+#endif
+
+/* Check for asm/system.h */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
+ #define NV_ASM_SYSTEM_H_PRESENT
+#else
+ #undef NV_ASM_SYSTEM_H_PRESENT
+#endif
+
+/* Check for linux/efi.h */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,33)
+ #define NV_LINUX_EFI_H_PRESENT
+#else
+ #undef NV_LINUX_EFI_H_PRESENT
+#endif
+
+/* Check for linux/kconfig.h */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
+ #define NV_LINUX_KCONFIG_H_PRESENT
+#else
+ #undef NV_LINUX_KCONFIG_H_PRESENT
+#endif
+
+/* Check for linux/screen_info.h */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+ #define NV_LINUX_SCREEN_INFO_H_PRESENT
+#else
+ #undef NV_LINUX_SCREEN_INFO_H_PRESENT
+#endif
+
+/* Check for linux/nvmap.h */
+// does not (yet) exist in kernel source
+ #undef NV_LINUX_NVMAP_H_PRESENT
diff --git a/conftest.sh b/conftest.sh
new file mode 100644
index 0000000..661cb4d
--- /dev/null
+++ b/conftest.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+# This is a replacement for nvidia's conftest.sh
+#
+# We have a new conftest.h that works with kbuild that we don't want
+# overwritten or generated or anything else, so we want any call to
+# conftest.sh to do absolutely nothing.
+exit 0
diff --git a/linux-3.10-i2c.patch b/linux-3.10-i2c.patch
new file mode 100644
index 0000000..4dada37
--- /dev/null
+++ b/linux-3.10-i2c.patch
@@ -0,0 +1,49 @@
+From d2b47404a12b763481660b942cef392ff803af1f Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe at debian.org>
+Date: Sat, 17 Aug 2013 15:47:01 +0200
+Subject: [PATCH] adjust for Linux 3.10 i2c interface changes
+
+backported from 304.108
+
+Bug-Debian: http://bugs.debian.org/717361
+---
+ nv-i2c.c |   15 ++++-----------
+ 1 file changed, 4 insertions(+), 11 deletions(-)
+
+diff --git a/nv-i2c.c b/nv-i2c.c
+index a702506..2aa0b77 100644
+--- a/usr/src/nv/nv-i2c.c
++++ b/usr/src/nv/nv-i2c.c
+@@ -311,8 +311,6 @@ void* NV_API_CALL nv_i2c_add_adapter(nv_state_t *nv, NvU32 port)
+ BOOL NV_API_CALL nv_i2c_del_adapter(nv_state_t *nv, void *data)
+ {
+     struct i2c_adapter *pI2cAdapter = (struct i2c_adapter *)data;
+-    int osstatus = 0;
+-    BOOL wasReleased = FALSE;
+ 
+ #if defined(KERNEL_2_4)
+     if (!NV_WEAK_SYMBOL_PRESENT(i2c_add_adapter))
+@@ -323,16 +321,11 @@ BOOL NV_API_CALL nv_i2c_del_adapter(nv_state_t *nv, void *data)
+ 
+     if (!pI2cAdapter) return FALSE;
+ 
+-    // attempt release with the OS
+-    osstatus = i2c_del_adapter(pI2cAdapter);
+-
+-    if (!osstatus)
+-    {
+-        os_free_mem(pI2cAdapter);
+-        wasReleased = TRUE;
+-    }
++    // release with the OS
++    i2c_del_adapter(pI2cAdapter);
++    os_free_mem(pI2cAdapter);
+ 
+-    return wasReleased;
++    return TRUE;
+ }
+ 
+ #else // (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
+-- 
+1.7.10.4
+
diff --git a/linux-3.10-procfs.patch b/linux-3.10-procfs.patch
new file mode 100644
index 0000000..ea76f28
--- /dev/null
+++ b/linux-3.10-procfs.patch
@@ -0,0 +1,633 @@
+From cfed26bf7fe6f8cc6787d987d63b470fc04d614f Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe at debian.org>
+Date: Sun, 18 Aug 2013 17:12:13 +0200
+Subject: [PATCH] adjust for Linux 3.10 procfs interface changes
+
+backported from 304.108 and adjusted for 173xx
+
+Bug-Debian: http://bugs.debian.org/717306
+---
+ nv-linux.h |    1 +
+ nv.c       |  333 +++++++++++++++++++++++++++++++++---------------------------
+ 2 files changed, 184 insertions(+), 150 deletions(-)
+
+diff --git a/nv-linux.h b/nv-linux.h
+index 963e059..9aac81a 100644
+--- a/usr/src/nv/nv-linux.h
++++ b/usr/src/nv/nv-linux.h
+@@ -163,6 +163,7 @@
+ 
+ #ifdef CONFIG_PROC_FS
+ #include <linux/proc_fs.h>
++#include <linux/seq_file.h>
+ #endif
+ 
+ #ifdef CONFIG_MTRR
+diff --git a/nv.c b/nv.c
+index f82e46f..898f372 100644
+--- a/usr/src/nv/nv.c
++++ b/usr/src/nv/nv.c
+@@ -333,12 +333,12 @@ void          nv_kern_rc_timer(unsigned long);
+ static int    nv_kern_apm_event(struct pm_dev *, pm_request_t, void *);
+ #endif
+ 
+-static int    nv_kern_read_cardinfo(char *, char **, off_t off, int, int *, void *);
+-static int    nv_kern_read_status(char *, char **, off_t off, int, int *, void *);
+-static int    nv_kern_read_registry(char *, char **, off_t off, int, int *, void *);       
+-static int    nv_kern_read_agpinfo(char *, char **, off_t off, int, int *, void *);
+-static int    nv_kern_read_version(char *, char **, off_t off, int, int *, void *);
+-static int    nv_kern_read_text_file(char *, char **, off_t off, int, int *, void *);
++static const struct file_operations nv_procfs_text_file_fops;
++static const struct file_operations nv_procfs_card_info_fops;
++static const struct file_operations nv_procfs_version_fops;
++static const struct file_operations nv_procfs_agp_info_fops;
++static const struct file_operations nv_procfs_agp_status_fops;
++static const struct file_operations nv_procfs_registry_fops;
+ 
+ int           nv_kern_ctl_open(struct inode *, struct file *);
+ int           nv_kern_ctl_close(struct inode *, struct file *);
+@@ -604,6 +604,92 @@ static struct pci_dev* nv_get_pci_device(nv_state_t *nv)
+     return NULL;
+ }
+ 
++#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
++
++#if defined(NV_PROC_CREATE_DATA_PRESENT)
++# define NV_CREATE_PROC_ENTRY(name,mode,parent,fops,__data) \
++    proc_create_data(name, __mode, parent, fops, __data)
++#else
++# define NV_CREATE_PROC_ENTRY(name,mode,parent,fops,__data) \
++   ({                                                       \
++        struct proc_dir_entry *__entry;                     \
++        __entry = create_proc_entry(name, mode, parent);    \
++        if (__entry != NULL)                                \
++        {                                                   \
++            NV_SET_PROC_ENTRY_OWNER(__entry);               \
++            __entry->proc_fops = fops;                      \
++            __entry->data = (__data);                       \
++        }                                                   \
++        __entry;                                            \
++    })
++#endif
++
++#define NV_CREATE_PROC_FILE(filename,parent,__name,__data)               \
++   ({                                                                    \
++        struct proc_dir_entry *__entry;                                  \
++        int __mode = (S_IFREG | S_IRUGO);                                \
++        const struct file_operations *fops = &nv_procfs_##__name##_fops; \
++        if (fops->write != 0)                                            \
++            __mode |= S_IWUSR;                                           \
++        __entry = NV_CREATE_PROC_ENTRY(filename, __mode, parent, fops,   \
++            __data);                                                     \
++        __entry;                                                         \
++    })
++
++/*
++ * proc_mkdir_mode exists in Linux 2.6.9, but isn't exported until Linux 3.0.
++ * Use the older interface instead unless the newer interface is necessary.
++ */
++#if defined(NV_PROC_REMOVE_PRESENT)
++# define NV_PROC_MKDIR_MODE(name, mode, parent)                \
++    proc_mkdir_mode(name, mode, parent)
++#else
++# define NV_PROC_MKDIR_MODE(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;                                               \
++    })
++#endif
++
++#define NV_CREATE_PROC_DIR(name,parent)                        \
++   ({                                                          \
++        struct proc_dir_entry *__entry;                        \
++        int __mode = (S_IFDIR | S_IRUGO | S_IXUGO);            \
++        __entry = NV_PROC_MKDIR_MODE(name, __mode, parent);    \
++        __entry;                                               \
++    })
++
++#if defined(NV_PDE_DATA_PRESENT)
++# define NV_PDE_DATA(inode) PDE_DATA(inode)
++#else
++# define NV_PDE_DATA(inode) PDE(inode)->data
++#endif
++
++#define NV_DEFINE_PROCFS_SINGLE_FILE(__name)                                  \
++    static int nv_procfs_open_##__name(                                       \
++        struct inode *inode,                                                  \
++        struct file *filep                                                    \
++    )                                                                         \
++    {                                                                         \
++        return single_open(filep, nv_procfs_read_##__name,                    \
++            NV_PDE_DATA(inode));                                              \
++    }                                                                         \
++                                                                              \
++    static const struct file_operations nv_procfs_##__name##_fops = {         \
++        .owner      = THIS_MODULE,                                            \
++        .open       = nv_procfs_open_##__name,                                \
++        .read       = seq_read,                                               \
++        .llseek     = seq_lseek,                                              \
++        .release    = single_release,                                         \
++    };
++
+ static void nvos_proc_create(void)
+ {
+ #ifdef CONFIG_PROC_FS
+@@ -614,42 +700,25 @@ static void nvos_proc_create(void)
+     struct proc_dir_entry *entry;
+     struct proc_dir_entry *proc_nvidia_agp, *proc_nvidia_cards;
+ 
+-    /* world readable directory */
+-    int d_flags = S_IFDIR | S_IRUGO | S_IXUGO;
+-
+-    /* world readable file */
+-    int flags = S_IFREG | S_IRUGO;
+-
+     nv_state_t *nv;
+     nv_linux_state_t *nvl;
+ 
+-    proc_nvidia = create_proc_entry("driver/nvidia", d_flags, NULL);
++    proc_nvidia = NV_CREATE_PROC_DIR("driver/nvidia", NULL);
+     if (!proc_nvidia)
+         goto failed;
+ 
+-    proc_nvidia_cards = create_proc_entry("cards", d_flags, proc_nvidia);
++    proc_nvidia_cards = NV_CREATE_PROC_DIR("cards", proc_nvidia);
+     if (!proc_nvidia_cards)
+         goto failed;
+ 
+-    proc_nvidia_warnings = create_proc_entry("warnings", d_flags, proc_nvidia);
++    proc_nvidia_warnings = NV_CREATE_PROC_DIR("warnings", proc_nvidia);
+     if (!proc_nvidia_warnings)
+         goto failed;
+ 
+-    proc_nvidia_patches = create_proc_entry("patches", d_flags, proc_nvidia);
++    proc_nvidia_patches = NV_CREATE_PROC_DIR("patches", proc_nvidia);
+     if (!proc_nvidia_patches)
+         goto failed;
+ 
+-    /*
+-     * Set the module owner to ensure that the reference
+-     * count reflects accesses to the proc files.
+-     */
+-#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
+-    proc_nvidia->owner = THIS_MODULE;
+-    proc_nvidia_cards->owner = THIS_MODULE;
+-    proc_nvidia_warnings->owner = THIS_MODULE;
+-    proc_nvidia_patches->owner = THIS_MODULE;
+-#endif
+-
+     for (j = 0; j < num_nv_devices; j++)
+     {
+         nvl = &nv_linux_devices[j];
+@@ -660,92 +729,56 @@ static void nvos_proc_create(void)
+             break;
+ 
+         sprintf(name, "%d", i++);
+-        entry = create_proc_entry(name, flags, proc_nvidia_cards);
++        entry = NV_CREATE_PROC_FILE(name, proc_nvidia_cards, card_info, nv);
+         if (!entry) {
+             NV_PCI_DEV_PUT(dev);
+             goto failed;
+         }
+ 
+-        entry->data = nv;
+-        entry->read_proc = nv_kern_read_cardinfo;
+-#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
+-        entry->owner = THIS_MODULE;
+-#endif
+-
+         if (nvos_find_agp_capability(dev)) {
+             /*
+              * Create the /proc/driver/nvidia/agp/{status,host-bridge,card}
+              * entries now that we know there's AGP hardware.
+              */
+-            entry = create_proc_entry("agp", d_flags, proc_nvidia);
++            entry = NV_CREATE_PROC_DIR("agp", proc_nvidia);
+             if (!entry) {
+                 NV_PCI_DEV_PUT(dev);
+                 goto failed;
+             }
+ 
+-#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
+-            entry->owner = THIS_MODULE;
+-#endif
+             proc_nvidia_agp = entry;
+ 
+-            entry = create_proc_entry("status", flags, proc_nvidia_agp);
++            entry = NV_CREATE_PROC_FILE("status", proc_nvidia_agp, agp_status, nv);
+             if (!entry) {
+                 NV_PCI_DEV_PUT(dev);
+                 goto failed;
+             }
+ 
+-            entry->data = nv;
+-            entry->read_proc = nv_kern_read_status;
+-#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
+-            entry->owner = THIS_MODULE;
+-#endif
+-
+-            entry = create_proc_entry("host-bridge", flags, proc_nvidia_agp);
++            entry = NV_CREATE_PROC_FILE("host-bridge", proc_nvidia_agp, agp_info, NULL);
+             if (!entry) {
+                 NV_PCI_DEV_PUT(dev);
+                 goto failed;
+             }
+ 
+-            entry->data = NULL;
+-            entry->read_proc = nv_kern_read_agpinfo;
+-#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
+-            entry->owner = THIS_MODULE;
+-#endif
+-
+-            entry = create_proc_entry("card", flags, proc_nvidia_agp);
++            entry = NV_CREATE_PROC_FILE("card", proc_nvidia_agp, agp_info, nv);
+             if (!entry) {
+                 NV_PCI_DEV_PUT(dev);
+                 goto failed;
+             }
+ 
+-            entry->data = nv;
+-            entry->read_proc = nv_kern_read_agpinfo;
+-#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
+-            entry->owner = THIS_MODULE;
+-#endif
+         }
+ 
+         NV_PCI_DEV_PUT(dev);
+     }
+ 
+-    entry = create_proc_entry("version", flags, proc_nvidia);
++    entry = NV_CREATE_PROC_FILE("version", proc_nvidia, version, NULL);
+     if (!entry)
+         goto failed;
+ 
+-    entry->read_proc = nv_kern_read_version;
+-#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
+-    entry->owner = THIS_MODULE;
+-#endif
+-
+-    entry = create_proc_entry("registry", flags, proc_nvidia);
++    entry = NV_CREATE_PROC_FILE("registry", proc_nvidia, registry, NULL);
+     if (!entry)
+         goto failed;
+ 
+-    entry->read_proc = nv_kern_read_registry;
+-#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
+-    entry->owner = THIS_MODULE;
+-#endif
+-
+     return;
+ 
+ failed:
+@@ -762,25 +795,16 @@ nvos_proc_add_text_file(
+ )
+ {
+ #ifdef CONFIG_PROC_FS
+-    struct proc_dir_entry *entry;
+-
+-    /* world readable file */
+-    int flags = S_IFREG | S_IRUGO;
+-
+-    entry = create_proc_entry(filename, flags, parent);
+-    if (!entry) return;
+-
+-    entry->data = (void *)text;
+-    entry->read_proc = nv_kern_read_text_file;
+-#if defined(NV_PROC_DIR_ENTRY_HAS_OWNER)
+-    entry->owner = THIS_MODULE;
+-#endif
++    NV_CREATE_PROC_FILE(filename, parent, text_file, (void *)text);
+ #endif
+ }
+ 
+ #ifdef CONFIG_PROC_FS
+ static void nvos_proc_remove_all(struct proc_dir_entry *entry)
+ {
++#if defined(NV_PROC_REMOVE_PRESENT)
++    proc_remove(entry);
++#else
+     while (entry) {
+         struct proc_dir_entry *next = entry->next;
+         if (entry->subdir)
+@@ -790,6 +814,7 @@ static void nvos_proc_remove_all(struct proc_dir_entry *entry)
+             break;
+         entry = next;
+     }
++#endif
+ }
+ #endif
+ 
+@@ -3065,19 +3090,18 @@ void   NV_API_CALL  nv_set_dma_address_size(
+ }
+ 
+ static int
+-nv_kern_read_cardinfo(char *page, char **start, off_t off,
+-        int count, int *eof, void *data)
++nv_procfs_read_card_info(
++    struct seq_file *s,
++    void *v
++)
+ {
++    nv_state_t *nv = s->private;
+     struct pci_dev *dev;
+     char *type, *fmt, tmpstr[NV_DEVICE_NAME_LENGTH];
+-    int len = 0, status;
++    int status;
+     U032 vbios_rev1, vbios_rev2, vbios_rev3, vbios_rev4, vbios_rev5;
+     nv_stack_t *sp = NULL;
+ 
+-    nv_state_t *nv;
+-    nv = (nv_state_t *) data;
+-    *eof = 1;
+-
+     dev = nv_get_pci_device(nv);
+     if (!dev)
+         return 0;
+@@ -3094,38 +3118,38 @@ nv_kern_read_cardinfo(char *page, char **start, off_t off,
+         strcpy (tmpstr, "Unknown");
+     }
+     
+-    len += sprintf(page+len, "Model: \t\t %s\n", tmpstr);
+-    len += sprintf(page+len, "IRQ:   \t\t %d\n", nv->interrupt_line);
++    seq_printf(s, "Model: \t\t %s\n", tmpstr);
++    seq_printf(s, "IRQ:   \t\t %d\n", nv->interrupt_line);
+ 
+     status = rm_get_vbios_version(sp, nv, &vbios_rev1, &vbios_rev2,
+                                   &vbios_rev3, &vbios_rev4, &vbios_rev5);
+ 
+     if (status < 0) {
+         /* before rm_init_adapter */
+-        len += sprintf(page+len, "Video BIOS: \t ??.??.??.??.??\n");
++        seq_printf(s, "Video BIOS: \t ??.??.??.??.??\n");
+     } else {
+         fmt = "Video BIOS: \t %02x.%02x.%02x.%02x.%02x\n";
+-        len += sprintf(page+len, fmt, vbios_rev1, vbios_rev2, vbios_rev3,
++        seq_printf(s, fmt, vbios_rev1, vbios_rev2, vbios_rev3,
+                                                   vbios_rev4, vbios_rev5);
+     }
+ 
+     if (nvos_find_agp_capability(dev)) type = "AGP";
+     else if (nvos_find_pci_express_capability(dev)) type = "PCI-E";
+     else type = "PCI";
+-    len += sprintf(page+len, "Card Type: \t %s\n", type);
++    seq_printf(s, "Card Type: \t %s\n", type);
+ 
+     // Report the number of bits set in dev->dma_mask
+-    len += sprintf(page+len, "DMA Size: \t %d bits\n",
++    seq_printf(s, "DMA Size: \t %d bits\n",
+      nv_count_bits(dev->dma_mask));
+-    len += sprintf(page+len, "DMA Mask: \t 0x%llx\n", dev->dma_mask);
+-    len += sprintf(page+len, "Bus Location: \t %02x.%02x.%x\n",
++    seq_printf(s, "DMA Mask: \t 0x%llx\n", dev->dma_mask);
++    seq_printf(s, "Bus Location: \t %02x.%02x.%x\n",
+                    nv->bus, nv->slot, PCI_FUNC(dev->devfn));
+ #ifdef DEBUG
+     do
+     {
+         int j;
+         for (j = 0; j < NV_GPU_NUM_BARS; j++)
+-            len += sprintf(page+len, "BAR%i: \t\t 0x%08x (%iMB)\n",
++            seq_printf(s, "BAR%i: \t\t 0x%08x (%iMB)\n",
+                            j, nv->bars[j].address, nv->bars[j].size >> 20);
+     } while(0);
+ #endif
+@@ -3133,35 +3157,36 @@ nv_kern_read_cardinfo(char *page, char **start, off_t off,
+     NV_KMEM_CACHE_FREE_STACK(sp);
+  
+     NV_PCI_DEV_PUT(dev);
+-    return len;
++    return 0;
+ }
+ 
++NV_DEFINE_PROCFS_SINGLE_FILE(card_info);
++
+ static int
+-nv_kern_read_version(char *page, char **start, off_t off,
+-        int count, int *eof, void *data)
++nv_procfs_read_version(
++    struct seq_file *s,
++    void *v
++)
+ {
+-    int len = 0;
+-    *eof = 1;
+-    
+-    len += sprintf(page+len, "NVRM version: %s\n", pNVRM_ID);
+-    len += sprintf(page+len, "GCC version:  %s\n", NV_COMPILER);
+-    
+-    return len;
++    seq_printf(s, "NVRM version: %s\n", pNVRM_ID);
++    seq_printf(s, "GCC version:  %s\n", NV_COMPILER);
++
++    return 0;
+ }
+ 
++NV_DEFINE_PROCFS_SINGLE_FILE(version);
++
+ static int
+-nv_kern_read_agpinfo(char *page, char **start, off_t off,
+-        int count, int *eof, void *data)
++nv_procfs_read_agp_info(
++    struct seq_file *s,
++    void *v
++)
+ {
++    nv_state_t *nv = s->private;
+     struct pci_dev *dev;
+     char   *fw, *sba;
+     u8     cap_ptr;
+     u32    status, command, agp_rate;
+-    int    len = 0;
+-    
+-    nv_state_t *nv;
+-    nv = (nv_state_t *) data;
+-    *eof = 1;
+ 
+     if (nv) {
+         dev = nv_get_pci_device(nv);
+@@ -3172,12 +3197,12 @@ nv_kern_read_agpinfo(char *page, char **start, off_t off,
+         if (!dev)
+             return 0;
+ 
+-        len += sprintf(page+len, "Host Bridge: \t ");
++        seq_printf(s, "Host Bridge: \t ");
+ 
+ #if defined(CONFIG_PCI_NAMES)
+-        len += sprintf(page+len, "%s\n", NV_PCI_DEVICE_NAME(dev));
++        seq_printf(s, "%s\n", NV_PCI_DEVICE_NAME(dev));
+ #else
+-        len += sprintf(page+len, "PCI device %04x:%04x\n",
++        seq_printf(s, "PCI device %04x:%04x\n",
+                 dev->vendor, dev->device);
+ #endif
+     }
+@@ -3191,41 +3216,41 @@ nv_kern_read_agpinfo(char *page, char **start, off_t off,
+     fw  = (status & 0x00000010) ? "Supported" : "Not Supported";
+     sba = (status & 0x00000200) ? "Supported" : "Not Supported";
+ 
+-    len += sprintf(page+len, "Fast Writes: \t %s\n", fw);
+-    len += sprintf(page+len, "SBA: \t\t %s\n", sba);
++    seq_printf(s, "Fast Writes: \t %s\n", fw);
++    seq_printf(s, "SBA: \t\t %s\n", sba);
+ 
+     agp_rate = status & 0x7;
+     if (status & 0x8) // agp 3.0
+         agp_rate <<= 2;
+ 
+-    len += sprintf(page+len, "AGP Rates: \t %s%s%s%s\n",
++    seq_printf(s, "AGP Rates: \t %s%s%s%s\n",
+             (agp_rate & 0x00000008) ? "8x " : "",
+             (agp_rate & 0x00000004) ? "4x " : "",
+             (agp_rate & 0x00000002) ? "2x " : "",
+             (agp_rate & 0x00000001) ? "1x " : "");
+ 
+-    len += sprintf(page+len, "Registers: \t 0x%08x:0x%08x\n", status, command);
++    seq_printf(s, "Registers: \t 0x%08x:0x%08x\n", status, command);
+ 
+     NV_PCI_DEV_PUT(dev);
+-    return len;
++    return 0;
+ }
+ 
++NV_DEFINE_PROCFS_SINGLE_FILE(agp_info);
++
+ static int
+-nv_kern_read_status(char *page, char **start, off_t off,
+-        int count, int *eof, void *data)
++nv_procfs_read_agp_status(
++    struct seq_file *s,
++    void *v
++)
+ {
++    nv_state_t *nv = s->private;
+     struct pci_dev *dev;
+     char   *fw, *sba, *drv;
+-    int    len = 0;
+     u8     cap_ptr;
+     u32    scratch;
+     u32    status, command, agp_rate;
+     nv_stack_t *sp = NULL;
+ 
+-    nv_state_t *nv;
+-    nv = (nv_state_t *) data;
+-    *eof = 1;
+-
+     dev = nvos_get_agp_device_by_class(PCI_CLASS_BRIDGE_HOST);
+     if (!dev)
+         return 0;
+@@ -3246,10 +3271,10 @@ nv_kern_read_status(char *page, char **start, off_t off,
+     command &= scratch;
+ 
+     if (NV_AGP_ENABLED(nv) && (command & 0x100)) {
+-        len += sprintf(page+len, "Status: \t Enabled\n");
++        seq_printf(s, "Status: \t Enabled\n");
+ 
+         drv = NV_OSAGP_ENABLED(nv) ? "AGPGART" : "NVIDIA";
+-        len += sprintf(page+len, "Driver: \t %s\n", drv);
++        seq_printf(s, "Driver: \t %s\n", drv);
+ 
+         // mask off agp rate. 
+         // If this is agp 3.0, we need to shift the value
+@@ -3257,13 +3282,13 @@ nv_kern_read_status(char *page, char **start, off_t off,
+         if (status & 0x8) // agp 3.0
+             agp_rate <<= 2;
+ 
+-        len += sprintf(page+len, "AGP Rate: \t %dx\n", agp_rate);
++        seq_printf(s, "AGP Rate: \t %dx\n", agp_rate);
+ 
+         fw = (command & 0x00000010) ? "Enabled" : "Disabled";
+-        len += sprintf(page+len, "Fast Writes: \t %s\n", fw);
++        seq_printf(s, "Fast Writes: \t %s\n", fw);
+ 
+         sba = (command & 0x00000200) ? "Enabled" : "Disabled";
+-        len += sprintf(page+len, "SBA: \t\t %s\n", sba);
++        seq_printf(s, "SBA: \t\t %s\n", sba);
+     } else {
+         int agp_config = 0;
+ 
+@@ -3274,7 +3299,7 @@ nv_kern_read_status(char *page, char **start, off_t off,
+             return 0;
+         }
+ 
+-        len += sprintf(page+len, "Status: \t Disabled\n\n");
++        seq_printf(s, "Status: \t Disabled\n\n");
+ 
+         /*
+          * If we find AGP is disabled, but the RM registry indicates it
+@@ -3288,7 +3313,7 @@ nv_kern_read_status(char *page, char **start, off_t off,
+         rm_read_registry_dword(sp, nv, "NVreg", "XNvAGP", &agp_config);
+ 
+         if (agp_config != NVOS_AGP_CONFIG_DISABLE_AGP && NV_AGP_FAILED(nv)) {
+-            len += sprintf(page+len,
++            seq_printf(s,
+                   "AGP initialization failed, please check the ouput  \n"
+                   "of the 'dmesg' command and/or your system log file \n"
+                   "for additional information on this problem.        \n");
+@@ -3298,37 +3323,45 @@ nv_kern_read_status(char *page, char **start, off_t off,
+     }
+ 
+     NV_PCI_DEV_PUT(dev);
+-    return len;
++    return 0;
+ }
+ 
++NV_DEFINE_PROCFS_SINGLE_FILE(agp_status);
++
+ extern nv_parm_t nv_parms[];
+ extern char *NVreg_RegistryDwords;
+ 
+ static int
+-nv_kern_read_registry(char *page, char **start, off_t off,
+-        int count, int *eof, void *data)
++nv_procfs_read_registry(
++    struct seq_file *s,
++    void *v
++)
+ {
+-    unsigned int i, len = 0;
++    unsigned int i;
+     nv_parm_t *entry;
+-    *eof = 1;
+ 
+     for (i = 0; (entry = &nv_parms[i])->name != NULL; i++)
+-        len += sprintf(page+len, "%s: %u\n", entry->name, *entry->data);
++        seq_printf(s, "%s: %u\n", entry->name, *entry->data);
+ 
+-    len += sprintf(page+len, "RegistryDwords: \"%s\"\n",
++    seq_printf(s, "RegistryDwords: \"%s\"\n",
+                 (NVreg_RegistryDwords != NULL) ? NVreg_RegistryDwords : "");
+ 
+-    return len;
++    return 0;
+ }
+ 
++NV_DEFINE_PROCFS_SINGLE_FILE(registry);
++
+ static int
+-nv_kern_read_text_file(char *page, char **start, off_t off,
+-        int count, int *eof, void *data)
++nv_procfs_read_text_file(
++    struct seq_file *s,
++    void *v
++)
+ {
+-    *eof = 1;
+-    return sprintf(page, "%s", (char *)data);
++    return seq_puts(s, s->private);
+ }
+ 
++NV_DEFINE_PROCFS_SINGLE_FILE(text_file);
++
+ /***
+  *** EXPORTS to rest of resman
+  ***/
+-- 
+1.7.10.4
+
diff --git a/linux-3.11.patch b/linux-3.11.patch
new file mode 100644
index 0000000..2f2f1ca
--- /dev/null
+++ b/linux-3.11.patch
@@ -0,0 +1,27 @@
+Description: fix module build for Linux 3.11
+Author: Andreas Beckmann <anbe at debian.org>
+
+--- a/usr/src/nv/nv-linux.h
++++ b/usr/src/nv/nv-linux.h
+@@ -1465,4 +1465,10 @@
+ #include "nv-linux-ext.h"
+ #endif
+ 
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
++#define NV_NUM_PHYSPAGES                get_num_physpages()
++#else
++#define NV_NUM_PHYSPAGES                num_physpages
++#endif
++
+ #endif  /* _NV_LINUX_H_ */
+--- a/usr/src/nv/os-interface.c
++++ b/usr/src/nv/os-interface.c
+@@ -292,7 +292,7 @@
+ 
+ NvU64 NV_API_CALL os_get_system_memory_size(void)
+ {
+-    return ((NvU64) num_physpages * PAGE_SIZE) / RM_PAGE_SIZE;
++    return ((NvU64) NV_NUM_PHYSPAGES * PAGE_SIZE) / RM_PAGE_SIZE;
+ }
+ 
+ //
diff --git a/nvidia-blacklist-vga-pmu-registers-195.patch b/nvidia-blacklist-vga-pmu-registers-195.patch
new file mode 100644
index 0000000..cd8ea58
--- /dev/null
+++ b/nvidia-blacklist-vga-pmu-registers-195.patch
@@ -0,0 +1,30 @@
+Subject: CVE-2012-4225
+ http://nvidia.custhelp.com/app/answers/detail/a_id/3140
+Origin: upstream, ftp://download.nvidia.com/XFree86/patches/security/2012-08-01/nvidia-blacklist-vga-pmu-registers-195.diff
+Bug-Debian: http://bugs.debian.org/684781
+
+diff -ur a/usr/src/nv/nv.h b/usr/src/nv/nv.h
+--- a/usr/src/nv/nv.h	2012-08-02 18:19:37.000000000 -0700
++++ b/usr/src/nv/nv.h 2012-08-02 18:19:37.000000000 -0700
+@@ -436,7 +436,20 @@
+ 
+ #define IS_BLACKLISTED_REG_OFFSET(nv, offset, length)                          \
+              ((IS_REG_RANGE_WITHIN_MAPPING(nv, 0x1000, 0x1000, offset, length)) ||\
+-             (IS_REG_RANGE_WITHIN_MAPPING(nv, 0x700000, 0x100000, offset, length)))
++              (IS_REG_RANGE_WITHIN_MAPPING(nv, 0x84000, 0x1000, offset, length)) ||\
++              (IS_REG_RANGE_WITHIN_MAPPING(nv, 0x85000, 0x1000, offset, length)) ||\
++              (IS_REG_RANGE_WITHIN_MAPPING(nv, 0x86000, 0x1000, offset, length)) ||\
++              (IS_REG_RANGE_WITHIN_MAPPING(nv, 0x87000, 0x1000, offset, length)) ||\
++              (IS_REG_RANGE_WITHIN_MAPPING(nv, 0x89000, 0x1000, offset, length)) ||\
++              (IS_REG_RANGE_WITHIN_MAPPING(nv, 0xa0000, 0x20000, offset, length)) ||\
++              (IS_REG_RANGE_WITHIN_MAPPING(nv, 0x104000, 0x1000, offset, length)) ||\
++              (IS_REG_RANGE_WITHIN_MAPPING(nv, 0x105000, 0x1000, offset, length)) ||\
++              (IS_REG_RANGE_WITHIN_MAPPING(nv, 0x10a000, 0x1000, offset, length)) ||\
++              (IS_REG_RANGE_WITHIN_MAPPING(nv, 0x1c2000, 0x1000, offset, length)) ||\
++              (IS_REG_RANGE_WITHIN_MAPPING(nv, 0x1c3000, 0x1000, offset, length)) ||\
++              (IS_REG_RANGE_WITHIN_MAPPING(nv, 0x618000, 0x2000, offset, length)) ||\
++              (IS_REG_RANGE_WITHIN_MAPPING(nv, 0x627000, 0x1000, offset, length)) ||\
++              (IS_REG_RANGE_WITHIN_MAPPING(nv, 0x700000, 0x100000, offset, length)))
+ 
+ /* duplicated from nvos.h for external builds */
+ #ifndef NVOS_AGP_CONFIG_DISABLE_AGP
diff --git a/patches.h b/patches.h
new file mode 100644
index 0000000..892d369
--- /dev/null
+++ b/patches.h
@@ -0,0 +1,5 @@
+static struct {
+	const char *short_description;
+	const char *description;
+} __nv_patches[] = {
+{ NULL, NULL } };
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/xorg-driver-video-nvidia-legacy3.git/commitdiff/82e9c52fb157978f9e04542b89004af3f3f87af0




More information about the pld-cvs-commit mailing list