summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Goldstein <cardoe@gentoo.org>2008-12-18 18:43:02 +0000
committerDoug Goldstein <cardoe@gentoo.org>2008-12-18 18:43:02 +0000
commit1ab0d807bfd2528d598ec1d583ad2a314700f35d (patch)
tree156f47c180c4a085f602216dc6b2516901527b05 /x11-drivers
parentFix quoting, remove unnecessary src_compile, reorder vars to reflect skel.ebu... (diff)
downloadgentoo-2-1ab0d807bfd2528d598ec1d583ad2a314700f35d.tar.gz
gentoo-2-1ab0d807bfd2528d598ec1d583ad2a314700f35d.tar.bz2
gentoo-2-1ab0d807bfd2528d598ec1d583ad2a314700f35d.zip
remove files that went along with removed versions
(Portage version: 2.1.6.1/cvs/Linux 2.6.27-gentoo-r2 x86_64)
Diffstat (limited to 'x11-drivers')
-rw-r--r--x11-drivers/nvidia-drivers/ChangeLog8
-rw-r--r--x11-drivers/nvidia-drivers/files/NVIDIA_kernel-169.12-2286310.diff640
-rw-r--r--x11-drivers/nvidia-drivers/files/NVIDIA_kernel-173.08-2404825.diff586
-rw-r--r--x11-drivers/nvidia-drivers/files/NVIDIA_kernel-173.14.05-2419292.diff624
4 files changed, 7 insertions, 1851 deletions
diff --git a/x11-drivers/nvidia-drivers/ChangeLog b/x11-drivers/nvidia-drivers/ChangeLog
index b5f14257b51d..3a2db5f2977d 100644
--- a/x11-drivers/nvidia-drivers/ChangeLog
+++ b/x11-drivers/nvidia-drivers/ChangeLog
@@ -1,6 +1,12 @@
# ChangeLog for x11-drivers/nvidia-drivers
# Copyright 1999-2008 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/x11-drivers/nvidia-drivers/ChangeLog,v 1.121 2008/12/18 18:36:31 cardoe Exp $
+# $Header: /var/cvsroot/gentoo-x86/x11-drivers/nvidia-drivers/ChangeLog,v 1.122 2008/12/18 18:43:02 cardoe Exp $
+
+ 18 Dec 2008; Doug Goldstein <cardoe@gentoo.org>
+ -files/NVIDIA_kernel-169.12-2286310.diff,
+ -files/NVIDIA_kernel-173.08-2404825.diff,
+ -files/NVIDIA_kernel-173.14.05-2419292.diff:
+ remove files that went along with removed versions
18 Dec 2008; Doug Goldstein <cardoe@gentoo.org>
nvidia-drivers-177.80.ebuild, nvidia-drivers-177.82.ebuild:
diff --git a/x11-drivers/nvidia-drivers/files/NVIDIA_kernel-169.12-2286310.diff b/x11-drivers/nvidia-drivers/files/NVIDIA_kernel-169.12-2286310.diff
deleted file mode 100644
index 68ff8680de1a..000000000000
--- a/x11-drivers/nvidia-drivers/files/NVIDIA_kernel-169.12-2286310.diff
+++ /dev/null
@@ -1,640 +0,0 @@
-http://www.nvnews.net/vbulletin/showthread.php?t=110088
-http://bugs.gentoo.org/218178
-
-diff -ru usr/src/nv/Makefile.kbuild usr/src/nv.2286310/Makefile.kbuild
---- usr/src/nv/Makefile.kbuild 2008-03-16 14:13:10.000000000 -0700
-+++ usr/src/nv.2286310/Makefile.kbuild 2008-03-16 14:37:47.204131496 -0700
-@@ -177,6 +177,7 @@
- vmap \
- signal_struct \
- agp_backend_acquire \
-+ set_pages_uc \
- change_page_attr \
- pci_get_class \
- sysctl_max_map_count \
-diff -ru usr/src/nv/conftest.sh usr/src/nv.2286310/conftest.sh
---- usr/src/nv/conftest.sh 2008-03-16 14:13:10.000000000 -0700
-+++ usr/src/nv.2286310/conftest.sh 2008-03-16 14:37:47.204131496 -0700
-@@ -100,6 +100,32 @@
- fi
- ;;
-
-+ set_pages_uc)
-+ #
-+ # Determine if the set_pages_uc() function is present.
-+ #
-+ echo "#include <linux/autoconf.h>
-+ #include <asm/cacheflush.h>
-+ void conftest_set_pages_uc(void) {
-+ set_pages_uc();
-+ }" > conftest$$.c
-+
-+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
-+ rm -f conftest$$.c
-+
-+ if [ -f conftest$$.o ]; then
-+ rm -f conftest$$.o
-+ echo "#undef NV_SET_PAGES_UC_PRESENT" >> conftest.h
-+ return
-+ else
-+ echo "#ifdef NV_CHANGE_PAGE_ATTR_PRESENT" >> conftest.h
-+ echo "#undef NV_CHANGE_PAGE_ATTR_PRESENT" >> conftest.h
-+ echo "#endif" >> conftest.h
-+ echo "#define NV_SET_PAGES_UC_PRESENT" >> conftest.h
-+ return
-+ fi
-+ ;;
-+
- change_page_attr)
- #
- # Determine if the change_page_attr() function is
-@@ -124,7 +150,9 @@
- rm -f conftest$$.o
- return
- else
-+ echo "#ifndef NV_SET_PAGES_UC_PRESENT" >> conftest.h
- echo "#define NV_CHANGE_PAGE_ATTR_PRESENT" >> conftest.h
-+ echo "#endif" >> conftest.h
- return
- fi
- ;;
-@@ -524,6 +552,8 @@
- return
- fi
-
-+ rm -f conftest$$.o
-+
- echo "#include <linux/autoconf.h>
- #include <linux/interrupt.h>
- irq_handler_t conftest_isr;
-diff -ru usr/src/nv/nv-linux.h usr/src/nv.2286310/nv-linux.h
---- usr/src/nv/nv-linux.h 2008-03-16 14:13:10.000000000 -0700
-+++ usr/src/nv.2286310/nv-linux.h 2008-03-16 14:37:47.204131496 -0700
-@@ -871,9 +871,10 @@
-
- #define NV_PGD_OFFSET(address, kernel, mm) \
- ({ \
-+ struct mm_struct *__mm = (mm); \
- pgd_t *__pgd; \
- if (!kernel) \
-- __pgd = pgd_offset(mm, address); \
-+ __pgd = pgd_offset(__mm, address); \
- else \
- __pgd = pgd_offset_k(address); \
- __pgd; \
-@@ -1208,21 +1209,24 @@
- nv_check_pci_config_space(nv, cb); \
- }
-
-+extern int nv_update_memory_types;
-+
- /*
-- * a BUG() is triggered on early 2.6 x86_64 kernels. the underlying
-- * problem actually exists on many architectures and kernels, but
-- * these are the only kernels that check the condition and trigger
-- * a BUG(). note that this is a problem of the core kernel, not an
-- * nvidia bug (and can still be triggered by agpgart). let's avoid
-- * change_page_attr on those kernels.
-+ * Using change_page_attr() on early Linux/x86-64 2.6 kernels may
-+ * result in a BUG() being triggered. The underlying problem
-+ * actually exists on multiple architectures and kernels, but only
-+ * the above check for the condition and trigger a BUG().
-+ *
-+ * Note that this is a due to a bug in the Linux kernel, not an
-+ * NVIDIA driver bug (it can also be triggered by AGPGART).
-+ *
-+ * We therefore need to determine at runtime if change_page_attr()
-+ * can be used safely on these kernels.
- */
--#if defined(NV_CHANGE_PAGE_ATTR_PRESENT)
--extern int nv_use_cpa;
--
--#if defined(NVCPU_X86_64) && !defined(KERNEL_2_4) && \
-- (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 11))
--#define NV_CHANGE_PAGE_ATTR_BUG_PRESENT 1
--#endif
-+#if defined(NV_CHANGE_PAGE_ATTR_PRESENT) && defined(NVCPU_X86_64) && \
-+ !defined(KERNEL_2_4) && \
-+ (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 11))
-+#define NV_CHANGE_PAGE_ATTR_BUG_PRESENT
- #endif
-
- #if defined(NVCPU_X86) || defined(NVCPU_X86_64)
-@@ -1234,7 +1238,7 @@
- *
- * We need to be careful to mask out _PAGE_NX when the host system
- * doesn't support this feature or when it's disabled: the kernel
-- * may not do this in its implementation of the change_page_attr()
-+ * may not do this in its implementation of the change_page_attr()
- * interface.
- */
- #ifndef X86_FEATURE_NX
-diff -ru usr/src/nv/nv-reg.h usr/src/nv.2286310/nv-reg.h
---- usr/src/nv/nv-reg.h 2008-03-16 14:13:10.000000000 -0700
-+++ usr/src/nv.2286310/nv-reg.h 2008-03-16 14:37:47.204131496 -0700
-@@ -391,34 +391,36 @@
- #define NV_REG_REMAP_LIMIT NV_REG_STRING(__NV_REMAP_LIMIT)
-
- /*
-- * Option: UseCPA
-+ * Option: UpdateMemoryTypes
- *
- * Description:
- *
-- * Many kernels have a broken implementation of change_page_attr that leads
-- * to cache aliasing problems. x86_64 kernels between 2.6.0 and 2.6.10 will
-- * force a kernel BUG_ON() when this condition is encountered. For this
-- * reason, the NVIDIA driver is very careful about not using the CPA kernel
-- * interface on these kernels.
-- *
-- * Some distributions have backported this fix to kernel versions that fall
-- * within this version range. The NVIDIA driver attempts to automatically
-- * detect these fixes and reenable usage of the change_page_attr interface.
-- *
-- * Due to the serious nature of the problems that can arise from this, the
-- * NVIDIA driver implements a manual registry key to force usage of this API
-- * to be enabled or disabled. This registry key can be used to force usage
-- * of the API on a known fixed kernel if the NVIDIA driver fails to detect
-- * the kernel as fixed. This registry key can also be used to disable usage
-- * of the API on a bad kernel that is misdetected as a fixed kernel.
-- *
-- * The default value is '-1' (use NVIDIA driver default logic)
-- * A value of '0' will forcibly disable change_page_attr calls.
-- * A value of '1' will forcibly enable change_page_attr calls.
-+ * Many kernels have broken implementations of the change_page_attr()
-+ * kernel interface that may cause cache aliasing problems. Linux/x86-64
-+ * kernels between 2.6.0 and 2.6.10 may prompt kernel BUG()s due to
-+ * improper accounting in the interface's large page management code, for
-+ * example. For this reason, the NVIDIA Linux driver is very careful about
-+ * not using the change_page_attr() kernel interface on these kernels.
-+ *
-+ * Due to the serious nature of the problems that can arise from bugs in
-+ * the change_page_attr(), set_pages_{uc,wb}() and other kernel interfaces
-+ * used to modify memory types, the NVIDIA driver implements a manual
-+ * registry key override to allow forcibly enabling or disabling use of
-+ * these APIs.
-+ *
-+ * Possible values:
-+ *
-+ * ~0 = use the NVIDIA driver's default logic (default)
-+ * 0 = enable use of change_page_attr(), etc.
-+ * 1 = disable use of change_page_attr(), etc.
-+ *
-+ * By default, the NVIDIA driver will attempt to auto-detect if it can
-+ * safely use the change_page_attr() and other kernel interfaces to modify
-+ * the memory types of kernel mappings.
- */
-
--#define __NV_USE_CPA UseCPA
--#define NV_REG_USE_CPA NV_REG_STRING(__NV_USE_CPA)
-+#define __NV_UPDATE_MEMORY_TYPES UpdateMemoryTypes
-+#define NV_REG_UPDATE_MEMORY_TYPES NV_REG_STRING(__NV_UPDATE_MEMORY_TYPES)
-
- /*
- * Option: RegistryDwords
-@@ -490,7 +492,7 @@
- NV_DEFINE_REG_ENTRY(__NV_DEVICE_FILE_GID, 0);
- NV_DEFINE_REG_ENTRY(__NV_DEVICE_FILE_MODE, 0666);
- NV_DEFINE_REG_ENTRY(__NV_REMAP_LIMIT, 0);
--NV_DEFINE_REG_ENTRY(__NV_USE_CPA, -1);
-+NV_DEFINE_REG_ENTRY(__NV_UPDATE_MEMORY_TYPES, ~0);
- NV_DEFINE_REG_ENTRY(__NV_USE_VBIOS, 1);
- NV_DEFINE_REG_ENTRY(__NV_RM_EDGE_INTR_CHECK, 1);
-
-@@ -535,7 +537,7 @@
- NV_DEFINE_PARAMS_TABLE_ENTRY(__NV_DEVICE_FILE_GID),
- NV_DEFINE_PARAMS_TABLE_ENTRY(__NV_DEVICE_FILE_MODE),
- NV_DEFINE_PARAMS_TABLE_ENTRY(__NV_REMAP_LIMIT),
-- NV_DEFINE_PARAMS_TABLE_ENTRY(__NV_USE_CPA),
-+ NV_DEFINE_PARAMS_TABLE_ENTRY(__NV_UPDATE_MEMORY_TYPES),
- NV_DEFINE_PARAMS_TABLE_ENTRY(__NV_USE_VBIOS),
- NV_DEFINE_PARAMS_TABLE_ENTRY(__NV_RM_EDGE_INTR_CHECK),
- {NULL, NULL, NULL}
-diff -ru usr/src/nv/nv-vm.c usr/src/nv.2286310/nv-vm.c
---- usr/src/nv/nv-vm.c 2008-03-16 14:13:09.000000000 -0700
-+++ usr/src/nv.2286310/nv-vm.c 2008-03-16 14:37:47.204131496 -0700
-@@ -43,42 +43,40 @@
- }
- #endif
-
--/*
-- * AMD Athlon processors expose a subtle bug in the Linux
-- * kernel, that may lead to AGP memory corruption. Recent
-- * kernel versions had a workaround for this problem, but
-- * 2.4.20 is the first kernel to address it properly. The
-- * page_attr API provides the means to solve the problem.
-- */
--
- static inline void nv_set_page_attrib_uncached(nv_pte_t *page_ptr)
- {
--#if defined(NV_CHANGE_PAGE_ATTR_PRESENT)
-- if (nv_use_cpa)
-+ if (nv_update_memory_types)
- {
-- struct page *page = virt_to_page(__va(page_ptr->phys_addr));
-+#if defined(NV_SET_PAGES_UC_PRESENT)
-+ struct page *page = NV_GET_PAGE_STRUCT(page_ptr->phys_addr);
-+ set_pages_uc(page, 1);
-+#elif defined(NV_CHANGE_PAGE_ATTR_PRESENT)
-+ struct page *page = NV_GET_PAGE_STRUCT(page_ptr->phys_addr);
- pgprot_t prot = PAGE_KERNEL_NOCACHE;
- #if defined(NVCPU_X86) || defined(NVCPU_X86_64)
- pgprot_val(prot) &= __nv_supported_pte_mask;
- #endif
- change_page_attr(page, 1, prot);
-- }
- #endif
-+ }
- }
-
- static inline void nv_set_page_attrib_cached(nv_pte_t *page_ptr)
- {
--#if defined(NV_CHANGE_PAGE_ATTR_PRESENT)
-- if (nv_use_cpa)
-+ if (nv_update_memory_types)
- {
-- struct page *page = virt_to_page(__va(page_ptr->phys_addr));
-+#if defined(NV_SET_PAGES_UC_PRESENT)
-+ struct page *page = NV_GET_PAGE_STRUCT(page_ptr->phys_addr);
-+ set_pages_wb(page, 1);
-+#elif defined(NV_CHANGE_PAGE_ATTR_PRESENT)
-+ struct page *page = NV_GET_PAGE_STRUCT(page_ptr->phys_addr);
- pgprot_t prot = PAGE_KERNEL;
- #if defined(NVCPU_X86) || defined(NVCPU_X86_64)
- pgprot_val(prot) &= __nv_supported_pte_mask;
- #endif
- change_page_attr(page, 1, prot);
-+#endif
- }
--#endif /* NV_CHANGE_PAGE_ATTR_PRESENT */
- }
-
- static inline void nv_lock_page(nv_pte_t *page_ptr)
-@@ -360,7 +358,8 @@
- #if defined(NV_CPA_NEEDS_FLUSHING)
- nv_execute_on_all_cpus(cache_flush, NULL);
- #endif
--#if defined (NVCPU_X86) || defined (NVCPU_X86_64)
-+#if (defined(NVCPU_X86) || defined(NVCPU_X86_64)) && \
-+ defined(NV_CHANGE_PAGE_ATTR_PRESENT)
- global_flush_tlb();
- #endif
- nv_ext_flush_caches(); // handle other platform flushes if present
-@@ -662,7 +661,7 @@
-
- address = (unsigned long)virt_addr + i * PAGE_SIZE;
-
-- pgd = NV_PGD_OFFSET(address, 1, &init_mm);
-+ pgd = NV_PGD_OFFSET(address, 1, NULL);
- if (!NV_PGD_PRESENT(pgd))
- goto failed;
-
-diff -ru usr/src/nv/nv.c usr/src/nv.2286310/nv.c
---- usr/src/nv/nv.c 2008-03-16 14:13:09.000000000 -0700
-+++ usr/src/nv.2286310/nv.c 2008-03-16 14:37:47.208131723 -0700
-@@ -15,6 +15,7 @@
- #include "nv_compiler.h"
- #include "os-agp.h"
- #include "nv-vm.h"
-+#include "nv-reg.h"
-
- #ifdef MODULE_ALIAS_CHARDEV_MAJOR
- MODULE_ALIAS_CHARDEV_MAJOR(NV_MAJOR_DEVICE_NUMBER);
-@@ -116,10 +117,7 @@
- unsigned int nv_remap_limit;
- #endif
-
--#if defined(NV_CHANGE_PAGE_ATTR_PRESENT)
--int nv_use_cpa = 1;
--#endif
--
-+int nv_update_memory_types = 1;
- static int nv_mmconfig_failure_detected = 0;
-
- static void *nv_pte_t_cache = NULL;
-@@ -1030,30 +1028,26 @@
- #endif /* defined(NV_BUILD_NV_PAT_SUPPORT) */
- }
-
--
- #if defined(NV_CHANGE_PAGE_ATTR_BUG_PRESENT)
--
--/* nv_verify_cpa_interface - determine if the change_page_attr bug is fixed
-- * in this kernel.
-+/*
-+ * nv_verify_cpa_interface() - determine if the change_page_attr() large page
-+ * management accounting bug known to exist in early Linux/x86-64 kernels
-+ * is present in this kernel.
- *
-- * there's really not a good way to determine if change_page_attr is fixed.
-- * we can't really use cpa on 2.6 x86_64 kernels < 2.6.11, as if we run into
-- * the accounting bug, the kernel will throw a BUG. this isn't 100% accurate,
-- * as it doesn't throw a bug until we try to restore the caching attributes
-- * of the page. so if we can track down a 4M allocation, we can mark it
-- * uncached and see if the accounting was done correctly.
-- *
-- * this is a little ugly, but the most accurate approach to determining if
-- * this kernel is good.
-+ * There's really no good way to determine if change_page_attr() is working
-+ * correctly. We can't reliably use change_page_attr() on Linux/x86-64 2.6
-+ * kernels < 2.6.11: if we run into the accounting bug, the Linux kernel will
-+ * trigger a BUG() if we attempt to restore the WB memory type of a page
-+ * originally part of a large page.
- *
-- * why do we even bother? some distributions have back-ported the cpa fix to
-- * kernels < 2.6.11. we want to use change_page_attr to avoid random corruption
-- * and hangs, but need to make sure it's safe to do so.
-+ * So if we can successfully allocate such a page, change its memory type to
-+ * UC and check if the accounting was done correctly, we can determine if
-+ * the change_page_attr() interface can be used safely.
- *
-- * return values:
-- * 0 - test passed, interface works
-- * 1 - test failed, status unclear
-- * -1 - test failed, interface broken
-+ * Return values:
-+ * 0 - test passed, the change_page_attr() interface works
-+ * 1 - test failed, the status is unclear
-+ * -1 - test failed, the change_page_attr() interface is broken
- */
-
- static inline pte_t *check_large_page(unsigned long vaddr)
-@@ -1061,7 +1055,7 @@
- pgd_t *pgd = NULL;
- pmd_t *pmd = NULL;
-
-- pgd = NV_PGD_OFFSET(vaddr, 1, &init_mm);
-+ pgd = NV_PGD_OFFSET(vaddr, 1, NULL);
- if (!NV_PGD_PRESENT(pgd))
- return NULL;
-
-@@ -1171,20 +1165,29 @@
-
- return 1;
- }
--
- #endif /* defined(NV_CHANGE_PAGE_ATTR_BUG_PRESENT) */
-
--
--// verify that the kernel's mapping matches the requested type
--// this is to protect against accidental cache aliasing problems
-+/*
-+ * nv_verify_page_mappings() - verify that the kernel mapping of the specified
-+ * page matches the specified type. This is to help detect bugs in the Linux
-+ * kernel's change_page_attr() interface, early.
-+ *
-+ * This function relies on the ability to perform kernel virtul address to PFN
-+ * translations and therefore on 'init_mm'. Unfortunately, the latter is no
-+ * longer exported in recent Linux/x86 2.6 kernels. The export was removed at
-+ * roughtly the same time as the set_pages_{uc,wb}() change_page_attr()
-+ * replacement interfaces were introduced; hopefully, it will be sufficient to
-+ * check for their presence.
-+ */
- int nv_verify_page_mappings(
- nv_pte_t *page_ptr,
- unsigned int cachetype
- )
- {
-+#if defined(NV_CHANGE_PAGE_ATTR_PRESENT) || \
-+ (defined(NV_SET_PAGES_UC_PRESENT) && !defined(NVCPU_X86))
- unsigned long retval = -1;
- #if defined(NVCPU_X86) || defined(NVCPU_X86_64)
-- struct mm_struct *mm;
- pgd_t *pgd = NULL;
- pmd_t *pmd = NULL;
- pte_t *pte = NULL;
-@@ -1192,15 +1195,12 @@
- unsigned long address;
- static int count = 0;
-
--#if defined(NV_CHANGE_PAGE_ATTR_PRESENT)
-- if (!nv_use_cpa)
-+ if (!nv_update_memory_types)
- return 0;
--#endif
-
- address = (unsigned long)__va(page_ptr->phys_addr);
-- mm = &init_mm; // always a kernel page
-
-- pgd = NV_PGD_OFFSET(address, 1, mm);
-+ pgd = NV_PGD_OFFSET(address, 1, NULL);
- if (!NV_PGD_PRESENT(pgd))
- {
- nv_printf(NV_DBG_ERRORS, "NVRM: pgd not present for addr 0x%lx\n", address);
-@@ -1266,8 +1266,11 @@
- }
-
- failed:
--#endif
-+#endif /* defined(NVCPU_X86) || defined(NVCPU_X86_64) */
- return retval;
-+#else
-+ return 0;
-+#endif
- }
-
- #if defined(NV_BUILD_NV_PAT_SUPPORT) && defined(CONFIG_HOTPLUG_CPU)
-@@ -1313,7 +1316,7 @@
- static int __init nvidia_init_module(void)
- {
- int rc;
-- U032 i, count;
-+ U032 i, count, data;
- nv_state_t *nv = NV_STATE_PTR(&nv_ctl_device);
- nv_stack_t *sp = NULL;
-
-@@ -1485,43 +1488,42 @@
- /* create /proc/driver/nvidia */
- nvos_proc_create();
-
--#if defined(NV_CHANGE_PAGE_ATTR_PRESENT)
-+ /*
-+ * Give users an opportunity to disable the driver's use of
-+ * the change_page_attr() and set_pages_{uc,wb}() kernel
-+ * interfaces.
-+ */
-+ rc = rm_read_registry_dword(sp, nv,
-+ "NVreg", NV_REG_UPDATE_MEMORY_TYPES, &data);
-+ if ((rc == 0) && ((int)data != ~0))
- {
-- int data;
--
-- // allow the user to override us with a registry key
-- rc = rm_read_registry_dword(sp, nv, "NVreg", "UseCPA", &data);
-- if ((rc == 0) && (data != -1))
-- {
-- nv_use_cpa = data;
-- }
-+ nv_update_memory_types = data;
-+ }
- #if defined(NV_CHANGE_PAGE_ATTR_BUG_PRESENT)
-- else
-+ /*
-+ * Unless we explicitely detect that the change_page_attr()
-+ * inteface is fixed, disable usage of the interface on
-+ * this kernel. Notify the user of this problem using the
-+ * driver's /proc warnings interface (read by the installer
-+ * and the bug report script).
-+ */
-+ else
-+ {
-+ rc = nv_verify_cpa_interface();
-+ if (rc < 0)
- {
-- /*
-- * Unless we explicitely detect that the change_page_attr()
-- * inteface is fixed, disable usage of the interface on
-- * this kernel. Notify the user of this problem using the
-- * driver's /proc warnings interface (read by the installer
-- * and the bug report script).
-- */
-- rc = nv_verify_cpa_interface();
-- if (rc < 0)
-- {
-- nv_prints(NV_DBG_ERRORS, __cpgattr_warning);
-- nvos_proc_add_warning_file("change_page_attr", __cpgattr_warning);
-- nv_use_cpa = 0;
-- }
-- else if (rc != 0)
-- {
-- nv_prints(NV_DBG_ERRORS, __cpgattr_warning_2);
-- nvos_proc_add_warning_file("change_page_attr", __cpgattr_warning_2);
-- nv_use_cpa = 0;
-- }
-+ nv_prints(NV_DBG_ERRORS, __cpgattr_warning);
-+ nvos_proc_add_warning_file("change_page_attr", __cpgattr_warning);
-+ nv_update_memory_types = 0;
-+ }
-+ else if (rc != 0)
-+ {
-+ nv_prints(NV_DBG_ERRORS, __cpgattr_warning_2);
-+ nvos_proc_add_warning_file("change_page_attr", __cpgattr_warning_2);
-+ nv_update_memory_types = 0;
- }
--#endif
- }
--#endif
-+#endif /* defined(NV_CHANGE_PAGE_ATTR_BUG_PRESENT) */
-
- #if defined(NVCPU_X86_64) && defined(CONFIG_IA32_EMULATION) && !defined(HAVE_COMPAT_IOCTL)
- /* Register ioctl()'s for 32-bit clients */
-@@ -3482,8 +3484,21 @@
- pte_t *pte = NULL;
- NvU64 retval;
-
-- mm = (kern) ? &init_mm : current->mm;
-- if (!kern) down_read(&current->mm->mmap_sem);
-+ if (!kern)
-+ {
-+ mm = current->mm;
-+ down_read(&mm->mmap_sem);
-+ }
-+ else
-+ {
-+#if defined(NV_SET_PAGES_UC_PRESENT) && defined(NVCPU_X86)
-+ /* nv_printf(NV_DBG_ERRORS,
-+ "NVRM: can't translate KVA in nv_get_phys_address()!\n"); */
-+ return 0;
-+#else
-+ mm = NULL;
-+#endif
-+ }
-
- pgd = NV_PGD_OFFSET(address, kern, mm);
- if (!NV_PGD_PRESENT(pgd))
-@@ -3504,22 +3519,24 @@
- retval &= ~_PAGE_NX;
- #endif
-
-- if (!kern) up_read(&current->mm->mmap_sem);
-+ if (!kern)
-+ up_read(&mm->mmap_sem);
- return retval;
-
- failed:
-- if (!kern) up_read(&current->mm->mmap_sem);
-+ if (!kern)
-+ up_read(&mm->mmap_sem);
- return 0;
- }
-
- NvU64 NV_API_CALL nv_get_kern_phys_address(NvU64 address)
- {
-- // make sure this address is a kernel pointer
-+ /* make sure this address is a kernel virtual address */
- #if defined(DEBUG) && !defined(CONFIG_X86_4G)
- if (address < PAGE_OFFSET)
- {
- nv_printf(NV_DBG_WARNINGS,
-- "NVRM: user address passed to get_kern_phys_address: 0x%lx\n",
-+ "NVRM: user address passed to get_kern_phys_address: 0x%llx!\n",
- address);
- return 0;
- }
-@@ -3534,12 +3551,12 @@
-
- NvU64 NV_API_CALL nv_get_kern_user_address(NvU64 address)
- {
-- // make sure this address is not a kernel pointer
-+ /* make sure this address is not a kernel virtual address */
- #if defined(DEBUG) && !defined(CONFIG_X86_4G)
- if (address >= PAGE_OFFSET)
- {
- nv_printf(NV_DBG_WARNINGS,
-- "NVRM: kernel address passed to get_user_phys_address: 0x%lx\n",
-+ "NVRM: kernel address passed to get_user_phys_address: 0x%llx!\n",
- address);
- return 0;
- }
-@@ -4316,16 +4333,12 @@
- return -1;
- }
-
--int NV_API_CALL nv_no_incoherent_mappings
--(
-- void
--)
-+int NV_API_CALL nv_no_incoherent_mappings(void)
- {
- if(nv_ext_no_incoherent_mappings() == 1)
- return 1;
--
--#if defined(NV_CHANGE_PAGE_ATTR_PRESENT)
-- return 1;
-+#if defined(NV_CHANGE_PAGE_ATTR_PRESENT) || defined(NV_SET_PAGES_UC_PRESENT)
-+ return (nv_update_memory_types);
- #else
- return 0;
- #endif
-diff -ru usr/src/nv/os-interface.c usr/src/nv.2286310/os-interface.c
---- usr/src/nv/os-interface.c 2008-03-16 14:13:09.000000000 -0700
-+++ usr/src/nv.2286310/os-interface.c 2008-03-16 14:37:47.208131723 -0700
-@@ -1198,6 +1198,18 @@
- {
- void *vaddr;
-
-+ if (start == 0)
-+ {
-+ if (mode != NV_MEMORY_CACHED)
-+ {
-+ nv_printf(NV_DBG_ERRORS,
-+ "NVRM: os_map_kernel_space: won't map address 0x%0llx UC!\n", start);
-+ return NULL;
-+ }
-+ else
-+ return (void *)PAGE_OFFSET;
-+ }
-+
- if (!NV_MAY_SLEEP())
- {
- nv_printf(NV_DBG_ERRORS,
-@@ -1230,6 +1242,9 @@
- NvU64 size_bytes
- )
- {
-+ if (addr == (void *)PAGE_OFFSET)
-+ return;
-+
- NV_IOUNMAP(addr, size_bytes);
- }
-
diff --git a/x11-drivers/nvidia-drivers/files/NVIDIA_kernel-173.08-2404825.diff b/x11-drivers/nvidia-drivers/files/NVIDIA_kernel-173.08-2404825.diff
deleted file mode 100644
index 9ff335006cb0..000000000000
--- a/x11-drivers/nvidia-drivers/files/NVIDIA_kernel-173.08-2404825.diff
+++ /dev/null
@@ -1,586 +0,0 @@
-diff -ru usr/src/nv/nv-linux.h usr/src/nv.2404825/nv-linux.h
---- usr/src/nv/nv-linux.h 2008-04-02 01:17:56.000000000 -0700
-+++ usr/src/nv.2404825/nv-linux.h 2008-05-06 16:22:16.603101044 -0700
-@@ -145,16 +145,19 @@
- #endif
-
- #if (defined(NVCPU_X86) || defined(NVCPU_X86_64)) && !defined(CONFIG_XEN)
--#define NV_BUILD_NV_PAT_SUPPORT 1
-+#define NV_ENABLE_PAT_SUPPORT
- #endif
-
--#if defined(NV_BUILD_NV_PAT_SUPPORT)
--#include "pat.h"
-+#define NV_PAT_MODE_DISABLED 0
-+#define NV_PAT_MODE_KERNEL 1
-+#define NV_PAT_MODE_BUILTIN 2
-+
-+extern int nv_pat_mode;
-+
- #if defined(CONFIG_HOTPLUG_CPU)
- #include <linux/cpu.h> /* CPU hotplug support */
- #include <linux/notifier.h> /* struct notifier_block, etc */
- #endif
--#endif
-
- #if (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
- #include <linux/i2c.h>
-@@ -681,6 +684,13 @@
- #define nv_down(lock) down(&lock)
- #define nv_up(lock) up(&lock)
-
-+#define NV_INIT_MUTEX(mutex) \
-+ { \
-+ struct semaphore __mutex = \
-+ __SEMAPHORE_INITIALIZER(*(mutex), 1); \
-+ *(mutex) = __mutex; \
-+ }
-+
- #if defined (KERNEL_2_4)
- # define NV_IS_SUSER() suser()
- # define NV_PCI_DEVICE_NAME(dev) ((dev)->name)
-@@ -1029,20 +1039,6 @@
- return new_prot;
- }
- #endif
--
--#if defined(NV_BUILD_NV_PAT_SUPPORT) && !defined (pgprot_writecombined)
--static inline pgprot_t pgprot_writecombined(pgprot_t old_prot)
-- {
-- pgprot_t new_prot = old_prot;
-- if (boot_cpu_data.x86 > 3)
-- {
-- pgprot_val(old_prot) &= ~(_PAGE_PCD | _PAGE_PWT);
-- new_prot = __pgprot(pgprot_val(old_prot) | _PAGE_WRTCOMB);
-- }
-- return new_prot;
-- }
--#endif
--
- #endif /* defined(NVCPU_X86) || defined(NVCPU_X86_64) */
-
- #if defined(KERNEL_2_4) && defined(NVCPU_X86) && !defined(pfn_to_page)
-@@ -1142,8 +1138,6 @@
- struct semaphore at_lock;
- } nv_linux_state_t;
-
--extern int nv_pat_enabled;
--
- #if defined(NV_LINUX_ACPI_EVENTS_SUPPORTED)
- /*
- * acpi data storage structure
-diff -ru usr/src/nv/nv-reg.h usr/src/nv.2404825/nv-reg.h
---- usr/src/nv/nv-reg.h 2008-04-02 01:17:56.000000000 -0700
-+++ usr/src/nv.2404825/nv-reg.h 2008-05-06 16:22:16.603101044 -0700
-@@ -471,6 +471,37 @@
- #define __NV_RM_EDGE_INTR_CHECK RMEdgeIntrCheck
- #define NV_REG_RM_EDGE_INTR_CHECK NV_REG_STRING(__NV_RM_EDGE_INTR_CHECK)
-
-+/*
-+ * Option: UsePageAttributeTable
-+ *
-+ * Description:
-+ *
-+ * Enable/disable use of the page attribute table (PAT) available in
-+ * modern x86/x86-64 processors to set the effective memory type of memory
-+ * mappings to write-combining (WC). If disabled, the driver will fall
-+ * back to using MTRRs, if possible.
-+ *
-+ * If enabled, an x86 processor with PAT support is present and the host
-+ * system's Linux kernel did not configure one of the PAT entries to
-+ * indicate the WC memory type, the driver will change the second entry in
-+ * the PAT from its default (write-through (WT)) to WC at module load
-+ * time. If the kernel did update one of the PAT entries, the driver will
-+ * not modify the PAT.
-+ *
-+ * In both cases, the driver will honor attempts to map memory with the WC
-+ * memory type by selecting the appropriate PAT entry using the correct
-+ * set of PTE flags.
-+ *
-+ * Possible values:
-+ *
-+ * ~0 = use the NVIDIA driver's default logic (default)
-+ * 1 = enable use of the PAT for WC mappings.
-+ * 0 = disable use of the PAT for WC mappings.
-+ */
-+
-+#define __NV_USE_PAGE_ATTRIBUTE_TABLE UsePageAttributeTable
-+#define NV_USE_PAGE_ATTRIBUTE_TABLE NV_REG_STRING(__NV_USE_PAGE_ATTRIBUTE_TABLE)
-+
-
-
- #if defined(NV_DEFINE_REGISTRY_KEY_TABLE)
-@@ -495,6 +526,7 @@
- NV_DEFINE_REG_ENTRY(__NV_UPDATE_MEMORY_TYPES, ~0);
- NV_DEFINE_REG_ENTRY(__NV_USE_VBIOS, 1);
- NV_DEFINE_REG_ENTRY(__NV_RM_EDGE_INTR_CHECK, 1);
-+NV_DEFINE_REG_ENTRY(__NV_USE_PAGE_ATTRIBUTE_TABLE, ~0);
-
- #if defined(NV_LINUX)
- NV_DEFINE_REG_STRING_ENTRY(__NV_REGISTRY_DWORDS, NULL);
-@@ -540,6 +572,7 @@
- NV_DEFINE_PARAMS_TABLE_ENTRY(__NV_UPDATE_MEMORY_TYPES),
- NV_DEFINE_PARAMS_TABLE_ENTRY(__NV_USE_VBIOS),
- NV_DEFINE_PARAMS_TABLE_ENTRY(__NV_RM_EDGE_INTR_CHECK),
-+ NV_DEFINE_PARAMS_TABLE_ENTRY(__NV_USE_PAGE_ATTRIBUTE_TABLE),
- {NULL, NULL, NULL}
- };
-
-diff -ru usr/src/nv/nv.c usr/src/nv.2404825/nv.c
---- usr/src/nv/nv.c 2008-04-02 01:17:56.000000000 -0700
-+++ usr/src/nv.2404825/nv.c 2008-05-06 16:22:16.603101044 -0700
-@@ -22,10 +22,9 @@
- #endif
-
- #if defined(KERNEL_2_4) && (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
--// weak linking?
- extern int i2c_add_adapter (struct i2c_adapter *) __attribute__ ((weak));
- extern int i2c_del_adapter (struct i2c_adapter *) __attribute__ ((weak));
--#endif // defined(KERNEL_2_4) && (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
-+#endif
-
- /*
- * our global state; one per device
-@@ -41,14 +40,7 @@
- static struct pm_dev *apm_nv_dev[NV_MAX_DEVICES] = { 0 };
- #endif
-
--int nv_pat_enabled = 0;
--
--#if !defined(NV_BUILD_NV_PAT_SUPPORT)
--static int nv_disable_pat = 1;
--#else
--static int nv_disable_pat = 0;
--NV_MODULE_PARAMETER(nv_disable_pat);
--#endif
-+int nv_pat_mode = NV_PAT_MODE_DISABLED;
-
- #if defined(NVCPU_X86) || defined(NVCPU_X86_64)
- NvU64 __nv_supported_pte_mask = ~_PAGE_NX;
-@@ -611,7 +603,7 @@
- nv_state_t *nv;
- nv_linux_state_t *nvl;
-
-- proc_nvidia = create_proc_entry("nvidia", d_flags, proc_root_driver);
-+ proc_nvidia = create_proc_entry("driver/nvidia", d_flags, NULL);
- if (!proc_nvidia)
- goto failed;
-
-@@ -863,18 +855,20 @@
- static int __nv_enable_pat_support (void);
- static void __nv_disable_pat_support (void);
-
--#if defined(NV_BUILD_NV_PAT_SUPPORT)
-+#if defined(NV_ENABLE_PAT_SUPPORT)
- /*
-- * Private PAT support for use by the NVIDIA driver. This is an
-- * interim solution until the kernel offers PAT support.
-+ * Private PAT support for use by the NVIDIA driver. This is used on
-+ * kernels that do not modify the PAT to include a write-combining
-+ * entry.
- */
- static int __check_pat_support (void);
- static void __nv_setup_pat_entries (void *);
- static void __nv_restore_pat_entries (void *);
-
--#define NV_READ_PAT_ENTRIES(pat1, pat2) rdmsr(IA32_CR_PAT, (pat1), (pat2))
--#define NV_WRITE_PAT_ENTRIES(pat1, pat2) wrmsr(IA32_CR_PAT, (pat1), (pat2))
--#define NV_PAT_ENTRY(pat, index) (((pat) & (0xff<<((index)*8)))>>((index)*8))
-+#define NV_READ_PAT_ENTRIES(pat1, pat2) rdmsr(0x277, (pat1), (pat2))
-+#define NV_WRITE_PAT_ENTRIES(pat1, pat2) wrmsr(0x277, (pat1), (pat2))
-+#define NV_PAT_ENTRY(pat, index) \
-+ (((pat) & (0xff << ((index)*8))) >> ((index)*8))
-
- static inline void __nv_disable_caches(unsigned long *cr4)
- {
-@@ -898,8 +892,10 @@
- static int __check_pat_support()
- {
- unsigned int pat1, pat2, i;
-+ U008 PAT_WC_index;
-
-- if (!test_bit(X86_FEATURE_PAT, (volatile unsigned long *)&boot_cpu_data.x86_capability))
-+ if (!test_bit(X86_FEATURE_PAT,
-+ (volatile unsigned long *)&boot_cpu_data.x86_capability))
- {
- nv_printf(NV_DBG_ERRORS,
- "NVRM: CPU does not support the PAT, falling back to MTRRs.\n");
-@@ -907,24 +903,30 @@
- }
-
- NV_READ_PAT_ENTRIES(pat1, pat2);
-+ PAT_WC_index = 0xf;
-
- for (i = 0; i < 4; i++)
- {
-- // we plan to mark PAT entry 1 as WC. if it's already marked such,
-- // that's fine, since it would be no different than us setting it.
-- if ((i != 1) && NV_PAT_ENTRY(pat1, i) == 1)
-- {
-- nv_printf(NV_DBG_ERRORS, "NVRM: PAT index %d already configured for Write-Combining!\n", i);
-- nv_printf(NV_DBG_ERRORS, "NVRM: Aborting, due to PAT already being configured\n");
-- return 0;
-- }
--
-- if (NV_PAT_ENTRY(pat2, i) == 1)
-- {
-- nv_printf(NV_DBG_ERRORS, "NVRM: PAT index %d already configured for Write-Combining!\n", i + 4);
-- nv_printf(NV_DBG_ERRORS, "NVRM: Aborting, due to PAT already being configured\n");
-- return 0;
-- }
-+ if (NV_PAT_ENTRY(pat1, i) == 0x01)
-+ {
-+ PAT_WC_index = i;
-+ break;
-+ }
-+
-+ if (NV_PAT_ENTRY(pat2, i) == 0x01)
-+ {
-+ PAT_WC_index = (i + 4);
-+ break;
-+ }
-+ }
-+
-+ if (PAT_WC_index == 1)
-+ nv_pat_mode = NV_PAT_MODE_KERNEL;
-+ else if (PAT_WC_index != 0xf)
-+ {
-+ nv_printf(NV_DBG_ERRORS,
-+ "NVRM: PAT configuration unsupported, falling back to MTRRs.\n");
-+ return 0;
- }
-
- return 1;
-@@ -978,20 +980,22 @@
- __nv_enable_caches(cr4);
- NV_RESTORE_FLAGS(eflags);
- }
--
--#endif /* defined(NV_BUILD_NV_PAT_SUPPORT) */
-+#endif
-
- static int __nv_enable_pat_support()
- {
--#if defined(NV_BUILD_NV_PAT_SUPPORT)
-+#if defined(NV_ENABLE_PAT_SUPPORT)
- unsigned long pat1, pat2;
-
-- if (nv_pat_enabled)
-+ if (nv_pat_mode != NV_PAT_MODE_DISABLED)
- return 1;
-
- if (!__check_pat_support())
- return 0;
-
-+ if (nv_pat_mode != NV_PAT_MODE_DISABLED)
-+ return 1;
-+
- NV_READ_PAT_ENTRIES(orig_pat1, orig_pat2);
- nv_printf(NV_DBG_SETUP, "saved orig pats as 0x%lx 0x%lx\n", orig_pat1, orig_pat2);
-
-@@ -1001,31 +1005,30 @@
- return 0;
- }
-
-- nv_pat_enabled = 1;
-+ nv_pat_mode = NV_PAT_MODE_BUILTIN;
-
- NV_READ_PAT_ENTRIES(pat1, pat2);
- nv_printf(NV_DBG_SETUP, "changed pats to 0x%lx 0x%lx\n", pat1, pat2);
--#endif /* defined(NV_BUILD_NV_PAT_SUPPORT) */
--
-+#endif
- return 1;
- }
-
- static void __nv_disable_pat_support()
- {
--#if defined(NV_BUILD_NV_PAT_SUPPORT)
-+#if defined(NV_ENABLE_PAT_SUPPORT)
- unsigned long pat1, pat2;
-
-- if (!nv_pat_enabled)
-+ if (nv_pat_mode != NV_PAT_MODE_BUILTIN)
- return;
-
- if (nv_execute_on_all_cpus(__nv_restore_pat_entries, NULL) != 0)
- return;
-
-- nv_pat_enabled = 0;
-+ nv_pat_mode = NV_PAT_MODE_DISABLED;
-
- NV_READ_PAT_ENTRIES(pat1, pat2);
- nv_printf(NV_DBG_SETUP, "restored orig pats as 0x%lx 0x%lx\n", pat1, pat2);
--#endif /* defined(NV_BUILD_NV_PAT_SUPPORT) */
-+#endif
- }
-
- #if defined(NV_CHANGE_PAGE_ATTR_BUG_PRESENT)
-@@ -1242,7 +1245,7 @@
- break;
- default:
- expected = pgprot_val(PAGE_KERNEL_NOCACHE);
-- if ((flags & ~_PAGE_NX) == (expected & ~_PAGE_NX))
-+ if ((flags & ~(_PAGE_NX | _PAGE_PWT)) == (expected & ~(_PAGE_NX | _PAGE_PWT)))
- retval = 0;
- break;
- }
-@@ -1273,7 +1276,7 @@
- #endif
- }
-
--#if defined(NV_BUILD_NV_PAT_SUPPORT) && defined(CONFIG_HOTPLUG_CPU)
-+#if defined(NV_ENABLE_PAT_SUPPORT) && defined(CONFIG_HOTPLUG_CPU)
- static int
- nv_kern_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
- {
-@@ -1305,8 +1308,7 @@
- .notifier_call = nv_kern_cpu_callback,
- .priority = 0
- };
--
--#endif /* defined(NV_BUILD_NV_PAT_SUPPORT) && defined(CONFIG_HOTPLUG_CPU) */
-+#endif
-
-
- /***
-@@ -1315,7 +1317,7 @@
-
- static int __init nvidia_init_module(void)
- {
-- int rc;
-+ int rc, disable_pat = 0;
- U032 i, count, data;
- nv_state_t *nv = NV_STATE_PTR(&nv_ctl_device);
- nv_stack_t *sp = NULL;
-@@ -1443,18 +1445,6 @@
- nv_printf(NV_DBG_ERRORS, "NVRM: pte cache allocation failed\n");
- goto failed;
- }
--
--#if defined(NV_BUILD_NV_PAT_SUPPORT) && defined(CONFIG_HOTPLUG_CPU)
-- if (!nv_disable_pat)
-- {
-- if (register_hotcpu_notifier(&nv_hotcpu_nfb) != 0)
-- {
-- rc = -EIO;
-- nv_printf(NV_DBG_ERRORS, "NVRM: CPU hotplug notifier registration failed!\n");
-- goto failed;
-- }
-- }
--#endif
-
- #if defined(NV_SG_MAP_BUFFERS)
- rm_read_registry_dword(sp, nv, "NVreg", "RemapLimit", &nv_remap_limit);
-@@ -1532,8 +1522,30 @@
-
- nvos_proc_add_warning_file("README", __README_warning);
-
-- if (!nv_disable_pat)
-+ rc = rm_read_registry_dword(sp, nv,
-+ "NVreg", NV_USE_PAGE_ATTRIBUTE_TABLE, &data);
-+ if ((rc == 0) && ((int)data != ~0))
-+ {
-+ disable_pat = (data == 0);
-+ }
-+
-+ if (!disable_pat)
-+ {
- __nv_enable_pat_support();
-+#if defined(NV_ENABLE_PAT_SUPPORT) && defined(CONFIG_HOTPLUG_CPU)
-+ if (nv_pat_mode == NV_PAT_MODE_BUILTIN)
-+ {
-+ if (register_hotcpu_notifier(&nv_hotcpu_nfb) != 0)
-+ {
-+ __nv_disable_pat_support();
-+ rc = -EIO;
-+ nv_printf(NV_DBG_ERRORS,
-+ "NVRM: CPU hotplug notifier registration failed!\n");
-+ goto failed;
-+ }
-+ }
-+#endif
-+ }
- else
- {
- nv_printf(NV_DBG_ERRORS,
-@@ -1686,10 +1698,10 @@
- rm_unregister_compatible_ioctls(sp);
- #endif
-
-- if (nv_pat_enabled)
-+ if (nv_pat_mode == NV_PAT_MODE_BUILTIN)
- {
- __nv_disable_pat_support();
--#if defined(NV_BUILD_NV_PAT_SUPPORT) && defined(CONFIG_HOTPLUG_CPU)
-+#if defined(NV_ENABLE_PAT_SUPPORT) && defined(CONFIG_HOTPLUG_CPU)
- unregister_hotcpu_notifier(&nv_hotcpu_nfb);
- #endif
- }
-@@ -1825,6 +1837,8 @@
- }
- }
-
-+#if !defined(NV_VM_INSERT_PAGE_PRESENT)
-+static
- struct page *nv_kern_vma_nopage(
- struct vm_area_struct *vma,
- unsigned long address,
-@@ -1835,22 +1849,21 @@
- #endif
- )
- {
--#if !defined(NV_VM_INSERT_PAGE_PRESENT)
- struct page *page;
-
- page = pfn_to_page(vma->vm_pgoff);
- get_page(page);
-
- return page;
--#else
-- return NOPAGE_SIGBUS;
--#endif
- }
-+#endif
-
- struct vm_operations_struct nv_vm_ops = {
- .open = nv_kern_vma_open,
- .close = nv_kern_vma_release, /* "close" */
-+#if !defined(NV_VM_INSERT_PAGE_PRESENT)
- .nopage = nv_kern_vma_nopage,
-+#endif
- };
-
- static nv_file_private_t *
-@@ -1864,7 +1877,7 @@
-
- memset(nvfp, 0, sizeof(nv_file_private_t));
-
-- sema_init(&nvfp->sp_lock, 1);
-+ NV_INIT_MUTEX(&nvfp->sp_lock);
-
- // initialize this file's event queue
- init_waitqueue_head(&nvfp->waitqueue);
-@@ -2214,11 +2227,12 @@
- break;
- #if defined(NVCPU_X86) || defined(NVCPU_X86_64)
- case NV_MEMORY_WRITECOMBINED:
--#if defined(NV_BUILD_NV_PAT_SUPPORT)
-- if (nv_pat_enabled &&
-- (memory_type != NV_MEMORY_TYPE_REGISTERS))
-+#if defined(NV_ENABLE_PAT_SUPPORT)
-+ if ((nv_pat_mode != NV_PAT_MODE_DISABLED) &&
-+ (memory_type != NV_MEMORY_TYPE_REGISTERS))
- {
-- *prot = pgprot_writecombined(*prot);
-+ pgprot_val(*prot) &= ~(_PAGE_PSE | _PAGE_PCD | _PAGE_PWT);
-+ *prot = __pgprot(pgprot_val(*prot) | _PAGE_PWT);
- break;
- }
- #endif
-@@ -2242,7 +2256,6 @@
- return 1;
- #endif
- case NV_MEMORY_CACHED:
-- //case NV_MEMORY_WRITEBACK:
- #if !defined(NVCPU_X86) && !defined(NVCPU_X86_64)
- if (memory_type != NV_MEMORY_TYPE_REGISTERS)
- break;
-@@ -2264,8 +2277,6 @@
- if (memory_type == NV_MEMORY_TYPE_SYSTEM)
- break;
- #endif
-- //case NV_MEMORY_WRITETHRU:
-- //case NV_MEMORY_WRITEPROTECT:
- default:
- if(nv_ext_encode_caching(prot, cache_type, memory_type) == 0)
- return 0;
-@@ -3501,6 +3512,10 @@
- BOOL kern
- )
- {
-+#if defined(NV_SET_PAGES_UC_PRESENT) && defined(NVCPU_X86)
-+ nv_printf(NV_DBG_ERRORS,
-+ "NVRM: can't translate address in nv_get_phys_address()!\n");
-+#else
- struct mm_struct *mm;
- pgd_t *pgd = NULL;
- pmd_t *pmd = NULL;
-@@ -3513,15 +3528,7 @@
- down_read(&mm->mmap_sem);
- }
- else
-- {
--#if defined(NV_SET_PAGES_UC_PRESENT) && defined(NVCPU_X86)
-- nv_printf(NV_DBG_ERRORS,
-- "NVRM: can't translate KVA in nv_get_phys_address()!\n");
-- return 0;
--#else
- mm = NULL;
--#endif
-- }
-
- pgd = NV_PGD_OFFSET(address, kern, mm);
- if (!NV_PGD_PRESENT(pgd))
-@@ -3549,6 +3556,7 @@
- failed:
- if (!kern)
- up_read(&mm->mmap_sem);
-+#endif
- return 0;
- }
-
-@@ -3789,8 +3797,9 @@
-
- nv_init_lock(nvl->rm_lock);
-
-- sema_init(&nvl->ldata_lock, 1);
-- sema_init(&nvl->at_lock, 1);
-+ NV_INIT_MUTEX(&nvl->ldata_lock);
-+ NV_INIT_MUTEX(&nvl->at_lock);
-+
- NV_ATOMIC_SET(nvl->usage_count, 0);
-
- nvl->rm_lock_cpu = -1;
-diff -ru usr/src/nv/os-agp.c usr/src/nv.2404825/os-agp.c
---- usr/src/nv/os-agp.c 2008-04-02 01:17:56.000000000 -0700
-+++ usr/src/nv.2404825/os-agp.c 2008-05-06 16:22:16.603101044 -0700
-@@ -115,7 +115,7 @@
- goto release;
- }
-
-- if (!nv_pat_enabled)
-+ if (nv_pat_mode == NV_PAT_MODE_DISABLED)
- {
- #ifdef CONFIG_MTRR
- /*
-@@ -175,7 +175,7 @@
-
- failed:
- #ifdef CONFIG_MTRR
-- if (!nv_pat_enabled)
-+ if (nv_pat_mode == NV_PAT_MODE_DISABLED)
- mtrr_del(-1, agp_info.aper_base, agp_info.aper_size << 20);
- #endif
- release:
-@@ -205,7 +205,7 @@
- nvl = NV_GET_NVL_FROM_NV_STATE(nv);
-
- #ifdef CONFIG_MTRR
-- if (!nv_pat_enabled)
-+ if (nv_pat_mode == NV_PAT_MODE_DISABLED)
- mtrr_del(-1, nv->agp.address, nv->agp.size);
- #endif
-
-diff -ru usr/src/nv/os-interface.c usr/src/nv.2404825/os-interface.c
---- usr/src/nv/os-interface.c 2008-04-02 01:17:56.000000000 -0700
-+++ usr/src/nv.2404825/os-interface.c 2008-05-06 16:22:16.607101272 -0700
-@@ -1355,7 +1355,7 @@
-
- BOOL NV_API_CALL os_pat_supported(void)
- {
-- return nv_pat_enabled;
-+ return (nv_pat_mode != NV_PAT_MODE_DISABLED);
- }
-
- void NV_API_CALL os_dump_stack()
diff --git a/x11-drivers/nvidia-drivers/files/NVIDIA_kernel-173.14.05-2419292.diff b/x11-drivers/nvidia-drivers/files/NVIDIA_kernel-173.14.05-2419292.diff
deleted file mode 100644
index 1c10533f234f..000000000000
--- a/x11-drivers/nvidia-drivers/files/NVIDIA_kernel-173.14.05-2419292.diff
+++ /dev/null
@@ -1,624 +0,0 @@
-diff -ru usr/src/nv/Makefile.kbuild usr/src/nv.2419292/Makefile.kbuild
---- usr/src/nv/Makefile.kbuild 2008-05-19 00:37:02.000000000 -0700
-+++ usr/src/nv.2419292/Makefile.kbuild 2008-05-21 12:07:57.551201274 -0700
-@@ -166,10 +166,6 @@
- CFLAGS += -DNV_MAP_REGISTERS_EARLY
- endif
-
--ifeq ($(shell echo $(NV_BUILD_NV_PAT_SUPPORT)),1)
--CFLAGS += -DNV_BUILD_NV_PAT_SUPPORT
--endif
--
- ifneq ($(PATCHLEVEL), 4)
- COMPILE_TESTS = \
- remap_page_range \
-diff -ru usr/src/nv/Makefile.nvidia usr/src/nv.2419292/Makefile.nvidia
---- usr/src/nv/Makefile.nvidia 2008-05-19 00:37:02.000000000 -0700
-+++ usr/src/nv.2419292/Makefile.nvidia 2008-05-21 12:08:08.771840702 -0700
-@@ -56,10 +56,6 @@
- CFLAGS += -DNV_MAP_REGISTERS_EARLY
- endif
-
--ifeq ($(shell echo $(NV_BUILD_NV_PAT_SUPPORT)),1)
--CFLAGS += -DNV_BUILD_NV_PAT_SUPPORT
--endif
--
- INCLUDES += -I$(KERNEL_HEADERS)
-
- COMPILE_TESTS = \
-diff -ru usr/src/nv/nv-linux.h usr/src/nv.2419292/nv-linux.h
---- usr/src/nv/nv-linux.h 2008-05-19 00:37:01.000000000 -0700
-+++ usr/src/nv.2419292/nv-linux.h 2008-05-21 12:07:19.741046595 -0700
-@@ -145,16 +145,19 @@
- #endif
-
- #if (defined(NVCPU_X86) || defined(NVCPU_X86_64)) && !defined(CONFIG_XEN)
--#define NV_BUILD_NV_PAT_SUPPORT 1
-+#define NV_ENABLE_PAT_SUPPORT
- #endif
-
--#if defined(NV_BUILD_NV_PAT_SUPPORT)
--#include "pat.h"
-+#define NV_PAT_MODE_DISABLED 0
-+#define NV_PAT_MODE_KERNEL 1
-+#define NV_PAT_MODE_BUILTIN 2
-+
-+extern int nv_pat_mode;
-+
- #if defined(CONFIG_HOTPLUG_CPU)
- #include <linux/cpu.h> /* CPU hotplug support */
- #include <linux/notifier.h> /* struct notifier_block, etc */
- #endif
--#endif
-
- #if (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
- #include <linux/i2c.h>
-@@ -681,6 +684,13 @@
- #define nv_down(lock) down(&lock)
- #define nv_up(lock) up(&lock)
-
-+#define NV_INIT_MUTEX(mutex) \
-+ { \
-+ struct semaphore __mutex = \
-+ __SEMAPHORE_INITIALIZER(*(mutex), 1); \
-+ *(mutex) = __mutex; \
-+ }
-+
- #if defined (KERNEL_2_4)
- # define NV_IS_SUSER() suser()
- # define NV_PCI_DEVICE_NAME(dev) ((dev)->name)
-@@ -1029,20 +1039,6 @@
- return new_prot;
- }
- #endif
--
--#if defined(NV_BUILD_NV_PAT_SUPPORT) && !defined (pgprot_writecombined)
--static inline pgprot_t pgprot_writecombined(pgprot_t old_prot)
-- {
-- pgprot_t new_prot = old_prot;
-- if (boot_cpu_data.x86 > 3)
-- {
-- pgprot_val(old_prot) &= ~(_PAGE_PCD | _PAGE_PWT);
-- new_prot = __pgprot(pgprot_val(old_prot) | _PAGE_WRTCOMB);
-- }
-- return new_prot;
-- }
--#endif
--
- #endif /* defined(NVCPU_X86) || defined(NVCPU_X86_64) */
-
- #if defined(KERNEL_2_4) && defined(NVCPU_X86) && !defined(pfn_to_page)
-@@ -1142,8 +1138,6 @@
- struct semaphore at_lock;
- } nv_linux_state_t;
-
--extern int nv_pat_enabled;
--
- #if defined(NV_LINUX_ACPI_EVENTS_SUPPORTED)
- /*
- * acpi data storage structure
-diff -ru usr/src/nv/nv-reg.h usr/src/nv.2419292/nv-reg.h
---- usr/src/nv/nv-reg.h 2008-05-19 00:37:01.000000000 -0700
-+++ usr/src/nv.2419292/nv-reg.h 2008-05-21 12:07:23.313250167 -0700
-@@ -471,6 +471,37 @@
- #define __NV_RM_EDGE_INTR_CHECK RMEdgeIntrCheck
- #define NV_REG_RM_EDGE_INTR_CHECK NV_REG_STRING(__NV_RM_EDGE_INTR_CHECK)
-
-+/*
-+ * Option: UsePageAttributeTable
-+ *
-+ * Description:
-+ *
-+ * Enable/disable use of the page attribute table (PAT) available in
-+ * modern x86/x86-64 processors to set the effective memory type of memory
-+ * mappings to write-combining (WC). If disabled, the driver will fall
-+ * back to using MTRRs, if possible.
-+ *
-+ * If enabled, an x86 processor with PAT support is present and the host
-+ * system's Linux kernel did not configure one of the PAT entries to
-+ * indicate the WC memory type, the driver will change the second entry in
-+ * the PAT from its default (write-through (WT)) to WC at module load
-+ * time. If the kernel did update one of the PAT entries, the driver will
-+ * not modify the PAT.
-+ *
-+ * In both cases, the driver will honor attempts to map memory with the WC
-+ * memory type by selecting the appropriate PAT entry using the correct
-+ * set of PTE flags.
-+ *
-+ * Possible values:
-+ *
-+ * ~0 = use the NVIDIA driver's default logic (default)
-+ * 1 = enable use of the PAT for WC mappings.
-+ * 0 = disable use of the PAT for WC mappings.
-+ */
-+
-+#define __NV_USE_PAGE_ATTRIBUTE_TABLE UsePageAttributeTable
-+#define NV_USE_PAGE_ATTRIBUTE_TABLE NV_REG_STRING(__NV_USE_PAGE_ATTRIBUTE_TABLE)
-+
-
-
- #if defined(NV_DEFINE_REGISTRY_KEY_TABLE)
-@@ -495,6 +526,7 @@
- NV_DEFINE_REG_ENTRY(__NV_UPDATE_MEMORY_TYPES, ~0);
- NV_DEFINE_REG_ENTRY(__NV_USE_VBIOS, 1);
- NV_DEFINE_REG_ENTRY(__NV_RM_EDGE_INTR_CHECK, 1);
-+NV_DEFINE_REG_ENTRY(__NV_USE_PAGE_ATTRIBUTE_TABLE, ~0);
-
- #if defined(NV_LINUX)
- NV_DEFINE_REG_STRING_ENTRY(__NV_REGISTRY_DWORDS, NULL);
-@@ -540,6 +572,7 @@
- NV_DEFINE_PARAMS_TABLE_ENTRY(__NV_UPDATE_MEMORY_TYPES),
- NV_DEFINE_PARAMS_TABLE_ENTRY(__NV_USE_VBIOS),
- NV_DEFINE_PARAMS_TABLE_ENTRY(__NV_RM_EDGE_INTR_CHECK),
-+ NV_DEFINE_PARAMS_TABLE_ENTRY(__NV_USE_PAGE_ATTRIBUTE_TABLE),
- {NULL, NULL, NULL}
- };
-
-diff -ru usr/src/nv/nv.c usr/src/nv.2419292/nv.c
---- usr/src/nv/nv.c 2008-05-19 00:37:01.000000000 -0700
-+++ usr/src/nv.2419292/nv.c 2008-05-21 12:07:28.313535114 -0700
-@@ -22,10 +22,9 @@
- #endif
-
- #if defined(KERNEL_2_4) && (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
--// weak linking?
- extern int i2c_add_adapter (struct i2c_adapter *) __attribute__ ((weak));
- extern int i2c_del_adapter (struct i2c_adapter *) __attribute__ ((weak));
--#endif // defined(KERNEL_2_4) && (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
-+#endif
-
- /*
- * our global state; one per device
-@@ -41,14 +40,7 @@
- static struct pm_dev *apm_nv_dev[NV_MAX_DEVICES] = { 0 };
- #endif
-
--int nv_pat_enabled = 0;
--
--#if !defined(NV_BUILD_NV_PAT_SUPPORT)
--static int nv_disable_pat = 1;
--#else
--static int nv_disable_pat = 0;
--NV_MODULE_PARAMETER(nv_disable_pat);
--#endif
-+int nv_pat_mode = NV_PAT_MODE_DISABLED;
-
- #if defined(NVCPU_X86) || defined(NVCPU_X86_64)
- NvU64 __nv_supported_pte_mask = ~_PAGE_NX;
-@@ -611,7 +603,7 @@
- nv_state_t *nv;
- nv_linux_state_t *nvl;
-
-- proc_nvidia = create_proc_entry("nvidia", d_flags, proc_root_driver);
-+ proc_nvidia = create_proc_entry("driver/nvidia", d_flags, NULL);
- if (!proc_nvidia)
- goto failed;
-
-@@ -863,18 +855,20 @@
- static int __nv_enable_pat_support (void);
- static void __nv_disable_pat_support (void);
-
--#if defined(NV_BUILD_NV_PAT_SUPPORT)
-+#if defined(NV_ENABLE_PAT_SUPPORT)
- /*
-- * Private PAT support for use by the NVIDIA driver. This is an
-- * interim solution until the kernel offers PAT support.
-+ * Private PAT support for use by the NVIDIA driver. This is used on
-+ * kernels that do not modify the PAT to include a write-combining
-+ * entry.
- */
--static int __check_pat_support (void);
-+static int __determine_pat_mode (void);
- static void __nv_setup_pat_entries (void *);
- static void __nv_restore_pat_entries (void *);
-
--#define NV_READ_PAT_ENTRIES(pat1, pat2) rdmsr(IA32_CR_PAT, (pat1), (pat2))
--#define NV_WRITE_PAT_ENTRIES(pat1, pat2) wrmsr(IA32_CR_PAT, (pat1), (pat2))
--#define NV_PAT_ENTRY(pat, index) (((pat) & (0xff<<((index)*8)))>>((index)*8))
-+#define NV_READ_PAT_ENTRIES(pat1, pat2) rdmsr(0x277, (pat1), (pat2))
-+#define NV_WRITE_PAT_ENTRIES(pat1, pat2) wrmsr(0x277, (pat1), (pat2))
-+#define NV_PAT_ENTRY(pat, index) \
-+ (((pat) & (0xff << ((index)*8))) >> ((index)*8))
-
- static inline void __nv_disable_caches(unsigned long *cr4)
- {
-@@ -895,39 +889,47 @@
- if (cr4 & 0x80) write_cr4(cr4);
- }
-
--static int __check_pat_support()
-+static int __determine_pat_mode()
- {
- unsigned int pat1, pat2, i;
-+ U008 PAT_WC_index;
-
-- if (!test_bit(X86_FEATURE_PAT, (volatile unsigned long *)&boot_cpu_data.x86_capability))
-+ if (!test_bit(X86_FEATURE_PAT,
-+ (volatile unsigned long *)&boot_cpu_data.x86_capability))
- {
- nv_printf(NV_DBG_ERRORS,
- "NVRM: CPU does not support the PAT, falling back to MTRRs.\n");
-- return 0;
-+ return NV_PAT_MODE_DISABLED;
- }
-
- NV_READ_PAT_ENTRIES(pat1, pat2);
-+ PAT_WC_index = 0xf;
-
- for (i = 0; i < 4; i++)
- {
-- // we plan to mark PAT entry 1 as WC. if it's already marked such,
-- // that's fine, since it would be no different than us setting it.
-- if ((i != 1) && NV_PAT_ENTRY(pat1, i) == 1)
-- {
-- nv_printf(NV_DBG_ERRORS, "NVRM: PAT index %d already configured for Write-Combining!\n", i);
-- nv_printf(NV_DBG_ERRORS, "NVRM: Aborting, due to PAT already being configured\n");
-- return 0;
-- }
--
-- if (NV_PAT_ENTRY(pat2, i) == 1)
-- {
-- nv_printf(NV_DBG_ERRORS, "NVRM: PAT index %d already configured for Write-Combining!\n", i + 4);
-- nv_printf(NV_DBG_ERRORS, "NVRM: Aborting, due to PAT already being configured\n");
-- return 0;
-- }
-+ if (NV_PAT_ENTRY(pat1, i) == 0x01)
-+ {
-+ PAT_WC_index = i;
-+ break;
-+ }
-+
-+ if (NV_PAT_ENTRY(pat2, i) == 0x01)
-+ {
-+ PAT_WC_index = (i + 4);
-+ break;
-+ }
- }
-
-- return 1;
-+ if (PAT_WC_index == 1)
-+ return NV_PAT_MODE_KERNEL;
-+ else if (PAT_WC_index != 0xf)
-+ {
-+ nv_printf(NV_DBG_ERRORS,
-+ "NVRM: PAT configuration unsupported, falling back to MTRRs.\n");
-+ return NV_PAT_MODE_DISABLED;
-+ }
-+ else
-+ return NV_PAT_MODE_BUILTIN;
- }
-
- static unsigned long orig_pat1, orig_pat2;
-@@ -978,19 +980,30 @@
- __nv_enable_caches(cr4);
- NV_RESTORE_FLAGS(eflags);
- }
--
--#endif /* defined(NV_BUILD_NV_PAT_SUPPORT) */
-+#endif
-
- static int __nv_enable_pat_support()
- {
--#if defined(NV_BUILD_NV_PAT_SUPPORT)
-+#if defined(NV_ENABLE_PAT_SUPPORT)
- unsigned long pat1, pat2;
-
-- if (nv_pat_enabled)
-+ if (nv_pat_mode != NV_PAT_MODE_DISABLED)
- return 1;
-
-- if (!__check_pat_support())
-- return 0;
-+ nv_pat_mode = __determine_pat_mode();
-+
-+ switch (nv_pat_mode)
-+ {
-+ case NV_PAT_MODE_DISABLED:
-+ /* avoid the PAT if unavailable/unusable */
-+ return 0;
-+ case NV_PAT_MODE_KERNEL:
-+ /* inherit the kernel's PAT layout */
-+ return 1;
-+ case NV_PAT_MODE_BUILTIN:
-+ /* use builtin code to modify the PAT layout */
-+ break;
-+ }
-
- NV_READ_PAT_ENTRIES(orig_pat1, orig_pat2);
- nv_printf(NV_DBG_SETUP, "saved orig pats as 0x%lx 0x%lx\n", orig_pat1, orig_pat2);
-@@ -1001,31 +1014,28 @@
- return 0;
- }
-
-- nv_pat_enabled = 1;
--
- NV_READ_PAT_ENTRIES(pat1, pat2);
- nv_printf(NV_DBG_SETUP, "changed pats to 0x%lx 0x%lx\n", pat1, pat2);
--#endif /* defined(NV_BUILD_NV_PAT_SUPPORT) */
--
-+#endif
- return 1;
- }
-
- static void __nv_disable_pat_support()
- {
--#if defined(NV_BUILD_NV_PAT_SUPPORT)
-+#if defined(NV_ENABLE_PAT_SUPPORT)
- unsigned long pat1, pat2;
-
-- if (!nv_pat_enabled)
-+ if (nv_pat_mode != NV_PAT_MODE_BUILTIN)
- return;
-
- if (nv_execute_on_all_cpus(__nv_restore_pat_entries, NULL) != 0)
- return;
-
-- nv_pat_enabled = 0;
-+ nv_pat_mode = NV_PAT_MODE_DISABLED;
-
- NV_READ_PAT_ENTRIES(pat1, pat2);
- nv_printf(NV_DBG_SETUP, "restored orig pats as 0x%lx 0x%lx\n", pat1, pat2);
--#endif /* defined(NV_BUILD_NV_PAT_SUPPORT) */
-+#endif
- }
-
- #if defined(NV_CHANGE_PAGE_ATTR_BUG_PRESENT)
-@@ -1273,7 +1283,7 @@
- #endif
- }
-
--#if defined(NV_BUILD_NV_PAT_SUPPORT) && defined(CONFIG_HOTPLUG_CPU)
-+#if defined(NV_ENABLE_PAT_SUPPORT) && defined(CONFIG_HOTPLUG_CPU)
- static int
- nv_kern_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
- {
-@@ -1305,8 +1315,7 @@
- .notifier_call = nv_kern_cpu_callback,
- .priority = 0
- };
--
--#endif /* defined(NV_BUILD_NV_PAT_SUPPORT) && defined(CONFIG_HOTPLUG_CPU) */
-+#endif
-
-
- /***
-@@ -1315,7 +1324,7 @@
-
- static int __init nvidia_init_module(void)
- {
-- int rc;
-+ int rc, disable_pat = 0;
- U032 i, count, data;
- nv_state_t *nv = NV_STATE_PTR(&nv_ctl_device);
- nv_stack_t *sp = NULL;
-@@ -1443,18 +1452,6 @@
- nv_printf(NV_DBG_ERRORS, "NVRM: pte cache allocation failed\n");
- goto failed;
- }
--
--#if defined(NV_BUILD_NV_PAT_SUPPORT) && defined(CONFIG_HOTPLUG_CPU)
-- if (!nv_disable_pat)
-- {
-- if (register_hotcpu_notifier(&nv_hotcpu_nfb) != 0)
-- {
-- rc = -EIO;
-- nv_printf(NV_DBG_ERRORS, "NVRM: CPU hotplug notifier registration failed!\n");
-- goto failed;
-- }
-- }
--#endif
-
- #if defined(NV_SG_MAP_BUFFERS)
- rm_read_registry_dword(sp, nv, "NVreg", "RemapLimit", &nv_remap_limit);
-@@ -1532,8 +1529,30 @@
-
- nvos_proc_add_warning_file("README", __README_warning);
-
-- if (!nv_disable_pat)
-+ rc = rm_read_registry_dword(sp, nv,
-+ "NVreg", NV_USE_PAGE_ATTRIBUTE_TABLE, &data);
-+ if ((rc == 0) && ((int)data != ~0))
-+ {
-+ disable_pat = (data == 0);
-+ }
-+
-+ if (!disable_pat)
-+ {
- __nv_enable_pat_support();
-+#if defined(NV_ENABLE_PAT_SUPPORT) && defined(CONFIG_HOTPLUG_CPU)
-+ if (nv_pat_mode == NV_PAT_MODE_BUILTIN)
-+ {
-+ if (register_hotcpu_notifier(&nv_hotcpu_nfb) != 0)
-+ {
-+ __nv_disable_pat_support();
-+ rc = -EIO;
-+ nv_printf(NV_DBG_ERRORS,
-+ "NVRM: CPU hotplug notifier registration failed!\n");
-+ goto failed;
-+ }
-+ }
-+#endif
-+ }
- else
- {
- nv_printf(NV_DBG_ERRORS,
-@@ -1686,10 +1705,10 @@
- rm_unregister_compatible_ioctls(sp);
- #endif
-
-- if (nv_pat_enabled)
-+ if (nv_pat_mode == NV_PAT_MODE_BUILTIN)
- {
- __nv_disable_pat_support();
--#if defined(NV_BUILD_NV_PAT_SUPPORT) && defined(CONFIG_HOTPLUG_CPU)
-+#if defined(NV_ENABLE_PAT_SUPPORT) && defined(CONFIG_HOTPLUG_CPU)
- unregister_hotcpu_notifier(&nv_hotcpu_nfb);
- #endif
- }
-@@ -1825,6 +1844,8 @@
- }
- }
-
-+#if !defined(NV_VM_INSERT_PAGE_PRESENT)
-+static
- struct page *nv_kern_vma_nopage(
- struct vm_area_struct *vma,
- unsigned long address,
-@@ -1835,22 +1856,21 @@
- #endif
- )
- {
--#if !defined(NV_VM_INSERT_PAGE_PRESENT)
- struct page *page;
-
- page = pfn_to_page(vma->vm_pgoff);
- get_page(page);
-
- return page;
--#else
-- return NOPAGE_SIGBUS;
--#endif
- }
-+#endif
-
- struct vm_operations_struct nv_vm_ops = {
- .open = nv_kern_vma_open,
- .close = nv_kern_vma_release, /* "close" */
-+#if !defined(NV_VM_INSERT_PAGE_PRESENT)
- .nopage = nv_kern_vma_nopage,
-+#endif
- };
-
- static nv_file_private_t *
-@@ -1864,7 +1884,7 @@
-
- memset(nvfp, 0, sizeof(nv_file_private_t));
-
-- sema_init(&nvfp->sp_lock, 1);
-+ NV_INIT_MUTEX(&nvfp->sp_lock);
-
- // initialize this file's event queue
- init_waitqueue_head(&nvfp->waitqueue);
-@@ -2214,11 +2234,12 @@
- break;
- #if defined(NVCPU_X86) || defined(NVCPU_X86_64)
- case NV_MEMORY_WRITECOMBINED:
--#if defined(NV_BUILD_NV_PAT_SUPPORT)
-- if (nv_pat_enabled &&
-- (memory_type != NV_MEMORY_TYPE_REGISTERS))
-+#if defined(NV_ENABLE_PAT_SUPPORT)
-+ if ((nv_pat_mode != NV_PAT_MODE_DISABLED) &&
-+ (memory_type != NV_MEMORY_TYPE_REGISTERS))
- {
-- *prot = pgprot_writecombined(*prot);
-+ pgprot_val(*prot) &= ~(_PAGE_PSE | _PAGE_PCD | _PAGE_PWT);
-+ *prot = __pgprot(pgprot_val(*prot) | _PAGE_PWT);
- break;
- }
- #endif
-@@ -2242,7 +2263,6 @@
- return 1;
- #endif
- case NV_MEMORY_CACHED:
-- //case NV_MEMORY_WRITEBACK:
- #if !defined(NVCPU_X86) && !defined(NVCPU_X86_64)
- if (memory_type != NV_MEMORY_TYPE_REGISTERS)
- break;
-@@ -2264,8 +2284,6 @@
- if (memory_type == NV_MEMORY_TYPE_SYSTEM)
- break;
- #endif
-- //case NV_MEMORY_WRITETHRU:
-- //case NV_MEMORY_WRITEPROTECT:
- default:
- if(nv_ext_encode_caching(prot, cache_type, memory_type) == 0)
- return 0;
-@@ -3502,6 +3520,10 @@
- BOOL kern
- )
- {
-+#if defined(NV_SET_PAGES_UC_PRESENT) && defined(NVCPU_X86)
-+ nv_printf(NV_DBG_ERRORS,
-+ "NVRM: can't translate address in nv_get_phys_address()!\n");
-+#else
- struct mm_struct *mm;
- pgd_t *pgd = NULL;
- pmd_t *pmd = NULL;
-@@ -3514,15 +3536,7 @@
- down_read(&mm->mmap_sem);
- }
- else
-- {
--#if defined(NV_SET_PAGES_UC_PRESENT) && defined(NVCPU_X86)
-- nv_printf(NV_DBG_ERRORS,
-- "NVRM: can't translate KVA in nv_get_phys_address()!\n");
-- return 0;
--#else
- mm = NULL;
--#endif
-- }
-
- pgd = NV_PGD_OFFSET(address, kern, mm);
- if (!NV_PGD_PRESENT(pgd))
-@@ -3550,6 +3564,7 @@
- failed:
- if (!kern)
- up_read(&mm->mmap_sem);
-+#endif
- return 0;
- }
-
-@@ -3790,8 +3805,9 @@
-
- nv_init_lock(nvl->rm_lock);
-
-- sema_init(&nvl->ldata_lock, 1);
-- sema_init(&nvl->at_lock, 1);
-+ NV_INIT_MUTEX(&nvl->ldata_lock);
-+ NV_INIT_MUTEX(&nvl->at_lock);
-+
- NV_ATOMIC_SET(nvl->usage_count, 0);
-
- nvl->rm_lock_cpu = -1;
-diff -ru usr/src/nv/os-agp.c usr/src/nv.2419292/os-agp.c
---- usr/src/nv/os-agp.c 2008-05-19 00:37:01.000000000 -0700
-+++ usr/src/nv.2419292/os-agp.c 2008-05-21 12:07:30.437656163 -0700
-@@ -115,7 +115,7 @@
- goto release;
- }
-
-- if (!nv_pat_enabled)
-+ if (nv_pat_mode == NV_PAT_MODE_DISABLED)
- {
- #ifdef CONFIG_MTRR
- /*
-@@ -175,7 +175,7 @@
-
- failed:
- #ifdef CONFIG_MTRR
-- if (!nv_pat_enabled)
-+ if (nv_pat_mode == NV_PAT_MODE_DISABLED)
- mtrr_del(-1, agp_info.aper_base, agp_info.aper_size << 20);
- #endif
- release:
-@@ -205,7 +205,7 @@
- nvl = NV_GET_NVL_FROM_NV_STATE(nv);
-
- #ifdef CONFIG_MTRR
-- if (!nv_pat_enabled)
-+ if (nv_pat_mode == NV_PAT_MODE_DISABLED)
- mtrr_del(-1, nv->agp.address, nv->agp.size);
- #endif
-
-diff -ru usr/src/nv/os-interface.c usr/src/nv.2419292/os-interface.c
---- usr/src/nv/os-interface.c 2008-05-19 00:37:01.000000000 -0700
-+++ usr/src/nv.2419292/os-interface.c 2008-05-21 12:07:33.365823028 -0700
-@@ -1355,7 +1355,7 @@
-
- BOOL NV_API_CALL os_pat_supported(void)
- {
-- return nv_pat_enabled;
-+ return (nv_pat_mode != NV_PAT_MODE_DISABLED);
- }
-
- void NV_API_CALL os_dump_stack()