diff options
author | Mike Frysinger <vapier@gentoo.org> | 2008-04-18 19:54:05 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2008-04-18 19:54:05 +0000 |
commit | ed6a4ca8b74ae3b7a5dff5f615548844cc2b28ca (patch) | |
tree | f3d7e5548ec4fff676469cc957d99f41556ae23d /x11-drivers/nvidia-drivers | |
parent | add patch for building with gcc4.3 submitted by Peter Alfredsen via bug #218299 (diff) | |
download | historical-ed6a4ca8b74ae3b7a5dff5f615548844cc2b28ca.tar.gz historical-ed6a4ca8b74ae3b7a5dff5f615548844cc2b28ca.tar.bz2 historical-ed6a4ca8b74ae3b7a5dff5f615548844cc2b28ca.zip |
Add fix from upstream for building with linux-2.6.25 #218178.
Package-Manager: portage-2.2_pre5
Diffstat (limited to 'x11-drivers/nvidia-drivers')
-rw-r--r-- | x11-drivers/nvidia-drivers/ChangeLog | 7 | ||||
-rw-r--r-- | x11-drivers/nvidia-drivers/Manifest | 13 | ||||
-rw-r--r-- | x11-drivers/nvidia-drivers/files/NVIDIA_kernel-96.43.05-2290218.diff | 622 | ||||
-rw-r--r-- | x11-drivers/nvidia-drivers/nvidia-drivers-96.43.05.ebuild | 3 |
4 files changed, 637 insertions, 8 deletions
diff --git a/x11-drivers/nvidia-drivers/ChangeLog b/x11-drivers/nvidia-drivers/ChangeLog index 54d9ad4859d9..821879113ba3 100644 --- a/x11-drivers/nvidia-drivers/ChangeLog +++ b/x11-drivers/nvidia-drivers/ChangeLog @@ -1,6 +1,11 @@ # 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.92 2008/04/18 02:10:25 vapier Exp $ +# $Header: /var/cvsroot/gentoo-x86/x11-drivers/nvidia-drivers/ChangeLog,v 1.93 2008/04/18 19:54:04 vapier Exp $ + + 18 Apr 2008; Mike Frysinger <vapier@gentoo.org> + +files/NVIDIA_kernel-96.43.05-2290218.diff, + nvidia-drivers-96.43.05.ebuild: + Add fix from upstream for building with linux-2.6.25 #218178. 18 Apr 2008; Mike Frysinger <vapier@gentoo.org> +files/NVIDIA_kernel-169.12-2286310.diff, nvidia-drivers-169.12.ebuild: diff --git a/x11-drivers/nvidia-drivers/Manifest b/x11-drivers/nvidia-drivers/Manifest index 49881a31a7ed..fae171edf987 100644 --- a/x11-drivers/nvidia-drivers/Manifest +++ b/x11-drivers/nvidia-drivers/Manifest @@ -7,6 +7,7 @@ AUX NVIDIA_glx-glheader.patch 380 RMD160 ee9a10cfbed10d5711f58a80553ffebeea5853b AUX NVIDIA_glx-makefile.patch 602 RMD160 6c92e177c7a551ee43dc9bb0a58790d18497fef4 SHA1 cea7e59f91b0baa41d980a07de92d7dcde4baa77 SHA256 074d041899563641d65bf257b3835fe5aea9e7220af24830d96d1183cd18392e AUX NVIDIA_i2c-hwmon.patch 669 RMD160 812e7081d8f31116031edb0d8eb9c570b09caf89 SHA1 b0f132851cb1a7d8bdd9f205b4f187fcaf9e87d8 SHA256 0aaa05e1167bd722e00fcb90bd9853413ceb4ce3b00b308c314330f47c82f21a AUX NVIDIA_kernel-169.12-2286310.diff 22442 RMD160 20d6473e2762d3fc5e65ccfeb529540ac50b1a71 SHA1 7e445a84b9d73ce7d6febbb04b1ebf8fee6d5ba2 SHA256 4cbd64d7606cbc759f903adabf050911da2a80415f1cef592efe5f2ecaaf2d4d +AUX NVIDIA_kernel-96.43.05-2290218.diff 22045 RMD160 3dceffdc2b37dbdb2535bf44e9025c0ed6844c5a SHA1 4762156dfe4c8a32063da1ed7399f21ffa3855d5 SHA256 79e16a0b9c2fa3804e376a06c095079430ec5932ceb789f39a061d88820884f4 AUX libGL.la-r2 733 RMD160 479612ab30c04ca0683c7d9edaf9ab3de783e4a9 SHA1 88656b7e7234ade4f5564373fd6eb5c040167655 SHA256 4856e7a2c31763ade41c93a395f3e80a2705ac2ab4dbd73e5161cdba132f407b AUX nvidia 1510 RMD160 ca0d0e5375109d9edf682d9bdda743b7c693e4d4 SHA1 85cf9bff167dcc063ba61426523973e9598085f7 SHA256 b193cc3f6d6f39138720a2282d9f161fc8f2e8a15bc43d183a30eb879add06c5 AUX nvidia-169.07 639 RMD160 8baddb6fd1bf7f0e2688870a78e8ace051d62e3f SHA1 b30487ba2a24a6b1359d1fd831eeb1705060953c SHA256 a8c4860f008d53776fda7a17b59524f271236559af688e9a2c9845cbbcba1577 @@ -51,13 +52,13 @@ EBUILD nvidia-drivers-169.12.ebuild 14974 RMD160 8345f5c357173d953fc94a156b5b01b EBUILD nvidia-drivers-71.86.01.ebuild 14218 RMD160 44a3cbc6c1c1aad593dfac08ce8070d3ba5e2c54 SHA1 875154af5015448fc238e34c6b9bf95211b8460d SHA256 0db0dc634b5d4cfb06bd50b6cd2ff97844786bc5e9bc5af20ce9b4983da0b3f1 EBUILD nvidia-drivers-71.86.04.ebuild 14121 RMD160 a850cd138c52f4e8b79887a7f3ecd0c600eba585 SHA1 b0fe2cf1c58f061cdb85391a9a101ac34e22f5c3 SHA256 1eb4a290ebb01e00cbff9bec950f4b6c46c3953ef8cb6ff4c5fdbbd91d7da200 EBUILD nvidia-drivers-96.43.01.ebuild 14557 RMD160 9ec8f373685cba6402687b7f9fa4fbd62ae307f1 SHA1 21886ca6fbc46a998aaefadad06a21c60ba83249 SHA256 247dede1b041aff2b08dc8a630c83bddba9ab77f4392ddf76dbefad4860a321b -EBUILD nvidia-drivers-96.43.05.ebuild 14458 RMD160 568920a799691876e00d51b653b232482d81c439 SHA1 8f346301c1054b0bd1df2a14ce42f1285f82c050 SHA256 eb56c7cd62ede01c1aa49b1b86224ee722adcad1455ab377877d71d5c44cbc40 -MISC ChangeLog 19323 RMD160 f05deff4d9df72f0d02ee07b177ab4f5b102d531 SHA1 36acf5f24b6a2be59d84a68be0f9f155be354d48 SHA256 7db87e9da870ec26a276b63fba8945101da3c10135cd3b70f99e2cf58a6f15ae +EBUILD nvidia-drivers-96.43.05.ebuild 14538 RMD160 29ff35578de12b65668a1448b12f4599eaf0eebc SHA1 964abfdb3f4c6780e0e557ee79d0bb3981776e67 SHA256 6f87d063b26fb9cb896932c885a000e0d559e884ea9ab0b54480ecc55ac0e156 +MISC ChangeLog 19518 RMD160 14b44a2d4191375881dae368592d2689856ef1e9 SHA1 5dea0a22d9297aae1fb57d5c0447c2c39d7fc067 SHA256 972756e7b845896bd2e83fdcc456e69f739902a7a423d3c18e523cebbffc846c MISC metadata.xml 290 RMD160 66ba1c11dc5c04b4a554a5635946552294496efe SHA1 109194d161805cdf7c9c7a0e4a6d95967952b16e SHA256 8537d578e142848f65f5d0a1e00e54a3298e4f65133c9837b83bef6ca3234f8f -----BEGIN PGP SIGNATURE----- -Version: GnuPG v2.0.9 (GNU/Linux) +Version: GnuPG v2.0.7 (GNU/Linux) -iEYEARECAAYFAkgIGN8ACgkQ/ejvha5XGaMqywCfWMKcmfqry1uCeHY+0xm7RU2J -+KIAnjRXNeAiqCiC39eVipCvWUgQx7yw -=TZ+T +iD8DBQFICPxPj9hvisErhMIRAqwFAJ4kPL2nrI2gwVjn/7WEKNVVehVi8gCfYH1N +6PF7RS/e8l6j7Xa/7tzuZqI= +=qFx7 -----END PGP SIGNATURE----- diff --git a/x11-drivers/nvidia-drivers/files/NVIDIA_kernel-96.43.05-2290218.diff b/x11-drivers/nvidia-drivers/files/NVIDIA_kernel-96.43.05-2290218.diff new file mode 100644 index 000000000000..47b721a34354 --- /dev/null +++ b/x11-drivers/nvidia-drivers/files/NVIDIA_kernel-96.43.05-2290218.diff @@ -0,0 +1,622 @@ +http://www.nvnews.net/vbulletin/showthread.php?t=110088 +http://bugs.gentoo.org/218178 + +diff -ru usr/src/nv/Makefile.kbuild usr/src/nv.2290218/Makefile.kbuild +--- usr/src/nv/Makefile.kbuild 2008-01-22 20:12:23.000000000 -0800 ++++ usr/src/nv.2290218/Makefile.kbuild 2008-03-18 13:15:30.394522179 -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.2290218/conftest.sh +--- usr/src/nv/conftest.sh 2008-01-22 20:12:23.000000000 -0800 ++++ usr/src/nv.2290218/conftest.sh 2008-03-18 13:15:32.710654166 -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 + ;; +@@ -501,6 +529,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.2290218/nv-linux.h +--- usr/src/nv/nv-linux.h 2008-01-22 20:12:23.000000000 -0800 ++++ usr/src/nv.2290218/nv-linux.h 2008-03-18 13:15:26.674310174 -0700 +@@ -808,9 +808,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; \ +@@ -1097,21 +1098,24 @@ + #define NV_ATOMIC_DEC_AND_TEST(data) atomic_dec_and_test(&(data)) + #define NV_ATOMIC_READ(data) atomic_read(&(data)) + ++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) +@@ -1123,7 +1127,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-vm.c usr/src/nv.2290218/nv-vm.c +--- usr/src/nv/nv-vm.c 2008-01-22 20:12:23.000000000 -0800 ++++ usr/src/nv.2290218/nv-vm.c 2008-03-18 13:15:34.806773619 -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,8 +358,11 @@ + #if defined(NV_CPA_NEEDS_FLUSHING) + nv_execute_on_all_cpus(cache_flush, NULL); + #endif ++#if (defined(NVCPU_X86) || defined(NVCPU_X86_64)) && \ ++ defined(NV_CHANGE_PAGE_ATTR_PRESENT) + global_flush_tlb(); + #endif ++#endif + } + + /* +@@ -656,7 +657,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.2290218/nv.c +--- usr/src/nv/nv.c 2008-01-22 20:12:23.000000000 -0800 ++++ usr/src/nv.2290218/nv.c 2008-03-18 13:15:35.950838813 -0700 +@@ -112,10 +112,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; +@@ -919,30 +916,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) +@@ -950,7 +943,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; + +@@ -1060,35 +1053,42 @@ + + 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 + ) + { +- struct mm_struct *mm; ++#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) + pgd_t *pgd = NULL; + pmd_t *pmd = NULL; + pte_t *pte = NULL; +- unsigned long retval = -1; + unsigned int flags, expected; + 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); +@@ -1154,7 +1154,11 @@ + } + + failed: ++#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) +@@ -1200,7 +1204,8 @@ + 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); + + #if defined(VM_CHECKER) + nv_init_lock(vm_lock); +@@ -1359,43 +1364,41 @@ + /* 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(nv, "NVreg", "UpdateMemoryTypes", &data); ++ if ((rc == 0) && ((int)data != ~0)) + { +- int data; +- +- // allow the user to override us with a registry key +- rc = rm_read_registry_dword(NV_STATE_PTR(&nv_ctl_device), "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 conversions for 32 bit clients */ +@@ -3230,8 +3233,21 @@ + pte_t *pte = NULL; + NvU64 retval; + +- mm = (kern) ? &init_mm : current->mm; +- if (!kern) down_read(¤t->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)) +@@ -3252,22 +3268,24 @@ + retval &= ~_PAGE_NX; + #endif + +- if (!kern) up_read(¤t->mm->mmap_sem); ++ if (!kern) ++ up_read(&mm->mmap_sem); + return retval; + + failed: +- if (!kern) up_read(¤t->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; + } +@@ -3282,12 +3300,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; + } +@@ -3989,13 +4007,10 @@ + return -1; + } + +-int NV_API_CALL nv_no_incoherent_mappings +-( +- void +-) ++int NV_API_CALL nv_no_incoherent_mappings(void) + { +-#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.2290218/os-interface.c +--- usr/src/nv/os-interface.c 2008-01-22 20:12:23.000000000 -0800 ++++ usr/src/nv.2290218/os-interface.c 2008-03-18 13:15:38.098961229 -0700 +@@ -1130,6 +1130,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, +@@ -1162,6 +1174,9 @@ + NvU64 size_bytes + ) + { ++ if (addr == (void *)PAGE_OFFSET) ++ return; ++ + NV_IOUNMAP(addr, size_bytes); + } + +diff -ru usr/src/nv/os-registry.c usr/src/nv.2290218/os-registry.c +--- usr/src/nv/os-registry.c 2008-01-22 20:12:23.000000000 -0800 ++++ usr/src/nv.2290218/os-registry.c 2008-03-18 13:15:40.631105529 -0700 +@@ -381,34 +381,36 @@ + NV_MODULE_PARAMETER(NVreg_RemapLimit); + + /* +- * 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. + */ + +-static int NVreg_UseCPA = -1; +-NV_MODULE_PARAMETER(NVreg_UseCPA); ++static int NVreg_UpdateMemoryTypes = ~0; ++NV_MODULE_PARAMETER(NVreg_UpdateMemoryTypes); + + /* + * Option: DetectPrimaryVga +@@ -511,7 +513,7 @@ + { "NVreg", "DeviceFileGID", &NVreg_DeviceFileGID, 1 }, + { "NVreg", "DeviceFileMode", &NVreg_DeviceFileMode, 1 }, + { "NVreg", "RemapLimit", &NVreg_RemapLimit, 1 }, +- { "NVreg", "UseCPA", &NVreg_UseCPA, 1 }, ++ { "NVreg", "UpdateMemoryTypes", &NVreg_UpdateMemoryTypes, 1 }, + { "NVreg", "DetectPrimaryVga", &NVreg_DetectPrimaryVga, 1 }, + { "NVreg", "EnableBrightnessControl", &NVreg_EnableBrightnessControl, 1 }, + { "NVreg", "PanelPWMFrequency", &NVreg_PanelPWMFrequency, 1 }, diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-96.43.05.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-96.43.05.ebuild index 2f72294d3a19..6e35a74f9346 100644 --- a/x11-drivers/nvidia-drivers/nvidia-drivers-96.43.05.ebuild +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-96.43.05.ebuild @@ -1,6 +1,6 @@ # Copyright 1999-2008 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/x11-drivers/nvidia-drivers/nvidia-drivers-96.43.05.ebuild,v 1.2 2008/03/19 21:05:43 armin76 Exp $ +# $Header: /var/cvsroot/gentoo-x86/x11-drivers/nvidia-drivers/nvidia-drivers-96.43.05.ebuild,v 1.3 2008/04/18 19:54:04 vapier Exp $ inherit eutils multilib versionator linux-mod flag-o-matic nvidia-driver @@ -183,6 +183,7 @@ src_unpack() { epatch "${FILESDIR}"/NVIDIA_glx-glheader.patch # allow on board sensors to work with lm_sensors epatch "${FILESDIR}"/NVIDIA_i2c-hwmon.patch + kernel_is ge 2 6 25 && epatch "${FILESDIR}"/NVIDIA_kernel-96.43.05-2290218.diff if ! use x86-fbsd; then # Quiet down warnings the user does not need to see |