diff --git a/x11-drivers/nvidia-drivers/Manifest b/x11-drivers/nvidia-drivers/Manifest deleted file mode 100644 index dcd216c..0000000 --- a/x11-drivers/nvidia-drivers/Manifest +++ /dev/null @@ -1,29 +0,0 @@ -AUX 95-nvidia-settings 54 SHA256 c4b293c6c2659bebcbad9cffc1e237c6908a3763599e432aba89d07bc2826ba0 SHA512 0fdaff8701598081eeb78defcd140b78f75309ace998df67569a15d0ff653aca7ad0576912bf9a619f42990e6fb35cdb79e21f8181d3cd04dea719d912da8be9 WHIRLPOOL d71fef01f8c346089ef2556ffe62c5094f89582b73500711a7f18f25424e59baa12f6b0861bd8efd9bf4c5bbf794642927ca322cee218fd2da9fc7baa50fa827 -AUX nvidia-169.07 639 SHA256 a8c4860f008d53776fda7a17b59524f271236559af688e9a2c9845cbbcba1577 SHA512 3af295c026280dc3a2b73c2cc7772254686b09cad15f1333ab0b4de8cb0ccf78e725ced2a399b10edcf8af6ba42ab1485dc0661af67461b0c3789f786357772f WHIRLPOOL 626ae3c01c879e0cfe05bd373e0b9dfd6f462dd9ef6ae94a7d60276fe2d17c57fbb20aaa4d2a186a0ffc2a860076692aac854d00a3545bc9736e7bb8d0581055 -AUX nvidia-drivers-331.13-pax-usercopy.patch 2127 SHA256 669ffcab77432f116c2b9bc7ed55e2a1f4e208ff19b63d43003af2b346f7c0c0 SHA512 c6ebd534d1e88fe5c1b71ef5ccced8957e34931cab72d1adb4017c703fc2e285f6e36a778bb36a319f505cfe6408be098569944aa5d78c00c8837ffe880d006a WHIRLPOOL 798d3f3edeae2361f039372f5fe13cf9df5aef20ee63c7cdc83e806cbad097b0ddccd6b30968c2b2ceb768ad0425b02aaefe1ba41709e3f0fb79a82f908579a6 -AUX nvidia-drivers-337.12-pax-constify.patch 1042 SHA256 abb0c616a1187fd1958fea3e9fe8d3a9207d393cb9b76ccbf9f25f44c427ffc5 SHA512 203b0baf036e4f301959516ab17b6748814bed850bc79da30ae524a3c902fda57942587aba0803ad25891fb4867d88a003658b630849e12bc2c95015a62661b0 WHIRLPOOL 1ca05ff6737455032babf352ce08fdcefd5a006c3c4bc3607385896a5b0b3961fb9c7e1ff0010a28041ff9f9d49e35210d0d350df534a0e238df3e82f7023c64 -AUX nvidia-drivers-337.25-3.18.patch 104608 SHA256 8c6c5781e8dbeabf63dd14f9fcbba2f64f1a471f47b008640d4f184d6fddd22a SHA512 f4e327b460cd845ad0c8bfcebeb5285595d7bd0238dcd7daf274e5c266ee5c4f66bbd22b3df34d12b31d335e7569f31e4e6a16aa9e50904632677a12ce05a5cb WHIRLPOOL 9968ef8865a9f79cb7d0c11f6fd5ab77a95bd4f0569ed313f831beca906c1537d59e3ac27db5be14eeb83ae2ff06e725cd759623fde2192c871a9abc1248c9b6 -AUX nvidia-drivers-340.65-3.18.patch 1468 SHA256 2c2218204479d787a2c339f724ffc6f80743a16000ff3e99c7e841821ed4151f SHA512 7fcd4c05d0daf85aee50bc41726a72927826439fdd6447410961a3760917c0c5bb8e9f2958b0d1787cbdb29558fb4a1d0a80d4aa8b0dcc4c51989c3f8bf4aecb WHIRLPOOL 0552a7371bfa431dc72e98f2c6b779921f1dc135746c4529c25522e622225f45029350265fda9052fe5bdd0fffe90ccde66fbfee06b0b566946c15fe52442253 -AUX nvidia-drivers-340.76-nv-pat.c.patch 802 SHA256 30c5178bb63ad93d73235232bd2f43d18aa8e9ad492d3c61d1b564fd49b2029e SHA512 e2dad2b9979d959f4716a8740e6672366c161654017d4151a42b58cdababfed0907250acebcc9a3f43b9b40326760c3429a2aff249dc57c736f623a9e97101ec WHIRLPOOL ce20aaed6d15493eafe5876586d20b710524fae25050777dd5c6d983e86bdd8fadf0d1fac4b1850b002ea94cfeb1d3628b9da878433121b03c914e4f01970845 -AUX nvidia-drivers-settings.desktop 193 SHA256 31c062449b8bcc8adcd3ee649d8aebf0bef502400bcbbbb46124217e1efb17a3 SHA512 fbb81d2520e9025fbffb2a8e7b3647f621ddc9d36c79d063d49e901286e8d1ea45de1274f42e33ff1aece5cebd547a42829d65b421db39d808947554b0f57453 WHIRLPOOL c797eb0ec1044ecaaa979ca5180f840d9c82c5c040dd81b2d86ca4afade9f0c006fb8951f04cc4d2b206110d38b339690386d291ff8f625a22b38178a3cd970b -AUX nvidia-persistenced.conf 250 SHA256 347437868119e8ae12852a574597936e855f534a9ad290fef3f62b4083a38516 SHA512 9c9562bb15bf4552754dd50a1b01dec5df76f7f5666fba2fff642a169f87e9ed421a260f2258ab469f7e4cd9ef8161653355795624387fe7ad5ae6a0d71e5f46 WHIRLPOOL 1422504c6688fce28719146c7d95fe196ca617556942e8dc04c7f8c1412fa80b5b8289c0f86b835eece90eed4b4017093d686779f88d44cd41fa3de1a10e9bbe -AUX nvidia-persistenced.init 778 SHA256 b2a0a60b76090a78deddd7cdc323dcc1717530b0e7a3b51c069127ba3fe015b9 SHA512 6ed419ba17a1d273ca9024e74ebc24135e5cbc041f15019ec1266a48d69c206a7b2792bccdd623db3c65a8192d893f27e8b1593d79bdac7cb5fcd255b81c217b WHIRLPOOL 46113daf493157c6fc97511094f6d2032a65485145d372ac27c3120aebfe1d4051c9ec7122eba373db2eb57a7a227f671fa84c7603f05c823bb977f2dc9910c4 -AUX nvidia-smi.init 664 SHA256 c996033b81cc1512d8370d62575a0ea0c694f6e1b91cc948b4529625130601a7 SHA512 f7cc27d6cce7c13adecb0b927680979ca6a398bc742a93492ab7f85702e4442d8fc00c476f381a0177ae031a9ae45c5cbb6777f20c545d5cd695150f9551a4ce WHIRLPOOL 66bf1a70fa0038a54ca9254cd5543f61bdc69a4c070544660f4ef9b2a004d28f1defdb26b1bc102b1eabd24e679f36fec14c9b313fba4b54c7a9a51a73ca021e -AUX nvidia-udev.sh 185 SHA256 120c0af2b64fbcbd7032217a78eec8b104874c1ca68726367bce22c57944e07e SHA512 166df3a4e7c1862ca2e0f634bf5eed7aad1bdd7e55764ca42371b91a7077c59f0bc243de5616fd38dac9694159d1695d54fbd08ac89d4d3f3649c70c7db5977e WHIRLPOOL cb9995029cdb2fe1bc7fe5ae54041ee5de8da86bf5eb3616d062475e56c44d436e1e66683ecddd986fc5bca5723d88da4b1a42f65f3cd7e15636928bd21fce14 -AUX nvidia-uvm.conf 82 SHA256 4407c7ceed58ead98492560c07fc44d4285a70ed5165407f1b959e46d6e6d081 SHA512 cbdb946934a0b7c7d0fab0937ead0a161ff20238e0b53f9e05ea18a4fa0507df8d37594bd13402e3ec2001d488daeb2bec718d612f68202768d62a3cec97aacb WHIRLPOOL a79d65d67b0ff446bb2c65f5f3ec16ffaf0268ab0abbc137b413168aa7f5e617e502eaaf00fd21a149778bdd134da532b25bb066fc70bfa601caa97397aaf424 -AUX nvidia.udev-rule 462 SHA256 37b152a5055a16d1947171567178e2841679ddf03dba9d48e7d30f1e3b469ac6 SHA512 96f9edaa0b46bea5fce17596f868bea5265b303d7185af6ba81527bbd7b8fdf92de9311317cbde51a29d222083d451c25ab77c3d6837cbc4072a50d9af89aa86 WHIRLPOOL 89ed95f33db7485a3a1acd91df33ecdfb7d0a249db2d7674f134fb85b35a54653d0458e478503315ce506ae5d3c8dcd4ac20420711fdbdd087ea4bd779627d13 -DIST NVIDIA-FreeBSD-x86-337.25.tar.gz 58137349 SHA256 9857b24b5d910fb8688a2b9e11039d88b70ec250e900149183454675a363e8db SHA512 0c85814061732bd09948b5fd203d5d3a1fd5df0e1c23f4af11e1cfae6f7d8c7d7f569f35398c2c5551abf7eb5ce357229fa9b16ce2c21799e96396cff3313777 WHIRLPOOL a7ca516e184334117e1cdd45b3f4c1b0a8c50281ffd1c3859865d877c2bfb20136c308b1ff09e4d64d0e7fef8eeddacab488d0bc30c98d82a9280572be5f0de0 -DIST NVIDIA-FreeBSD-x86-340.65.tar.gz 59368245 SHA256 e8b5df30c4c2fd7b715d143dca987894bf4d3c28e43132c0cd02143cc0d96d5a SHA512 280d3dd928a6660885d8bdb93bd1fb93a2f19856ea72ce2423fcee4804e465e73ff6c62ad7221826dd95c4d337be42b86991733cecc5a7a9adb33a8460af7727 WHIRLPOOL 467a668d8f3074c0ae3296b97c737cd68e13a049825d1c08ee9cc74e81339a55c04f98a52373e984996f01a3969492a4408f2ac532ee7769e725549079416644 -DIST NVIDIA-FreeBSD-x86-340.76.tar.gz 59362290 SHA256 0abbcc3bed3f017e7f1887a5c2d014e2b5a020462071998986ed49cdb8e7119f SHA512 e6d8b6d03fe0f9ab25ddeef680e0159ea4073d03762d3419761c02b917edefa9a1f81c209bd386838141c1924364c81126b0a356c325b056a0c2451865bed5eb WHIRLPOOL 7ec0cef6f92bfbd4c8b6a051dc8de4b6b138f63fd4f7e18756178a9aebb91ea32523d5ca885481d8c8c3d1531b153699f4e5606c155d6c3aa79a340637d3744b -DIST NVIDIA-FreeBSD-x86_64-337.25.tar.gz 58941876 SHA256 189dc0f70528d0099d0396a52bf759af74d6a99203484be2d2d6514faf0d4161 SHA512 458c9200579a6caed02aabbc196ec998a0d19149cca665c5ef9bc709c018b991b27713c92d00bdd1ea6ddd86e04c641f387e1ec8a1235cc9581af9e7a3b19ebf WHIRLPOOL d819cf486edc443b1da39ea67582a12698b1dea1501f3b6738014a80f8a96260aa0ba30a9e2f1fac075f0f7d604dc94978f7f82092b40531dd4989a2954cc420 -DIST NVIDIA-FreeBSD-x86_64-340.65.tar.gz 60204269 SHA256 b613d806d02686bd61b6dcbed1ba29f63a009a504a2a59094208328aac08a029 SHA512 e04f892ce0771a8261d3b3b4168230af5d0ef9e864d2af9c6ec5de41e7d030f7c8e7696f66bb410b2ff17b3f24b0642584bbab0d5787bac9f8a7a4242f5a1c13 WHIRLPOOL 7f4324ef2fd98904224b7c12ab4822c68c8ab0281d1013fd24609773971b8ac18d5c87772f84465ddf24859152f3da99893e07bb52651a84ce162e18919734fe -DIST NVIDIA-FreeBSD-x86_64-340.76.tar.gz 60206978 SHA256 60037d035b9af9f1d4dcdd5033e1b28b0cd4c7ca94f6bcb8d267e037a930fdc0 SHA512 d478eac282dfb43205f7464d6542cf1f71ed4dea6b8381314affb8647d104c5ddf7e658b6b8eb5e0bdb18207b92f76c574b24959ce23034d375cc712998e6e7c WHIRLPOOL 98ebffd792a47e3a9ef369976db11909bc13551f38977f85ece41e5a31a790c2c173badfc166e3a0bfe4361d5221129d19364c074ba11fc4aa9062d5cb1499a8 -DIST NVIDIA-Linux-x86-337.25.run 37649836 SHA256 f76ece6bd98bfe2ae641a1847094e98c6f7ad7a01af682b4f38108d6b6227f9b SHA512 f68105a43f9129f4112c8a091ed7c9641708b62d20c199544e5e7079d5c5bdc0b6c83427be868e62c7134400ca62cab6a65eaff96ddb940768750250cbd50112 WHIRLPOOL 1ff92ffe33dad59bf393a7b6fe7523362433704dc8329701e74814c2eef833d15e44334264601080b90f723f5390ce6502fa3ed530fe9fadaf3efff139e65047 -DIST NVIDIA-Linux-x86-340.65.run 38831415 SHA256 e78511435d7794cac09916b98857d98d0c36607ac4dfde0b05ea4aef26ecd973 SHA512 7a67b4d75469696b27a0f474a67982634a2df108d941dbe80c3b0502f30c40f885ea3838e41a52526b424f94eaa9cae44590db1855f8e0303999beb0fe95bcdb WHIRLPOOL a8e5233ccb9aa0dbc3981529fbe2c56c6cedb1ad2e9df4f67e3bace2cde872e7c55adb3bf8e84dcaede3003f1e8d718e464997fddf1f73574088ce4082e4a8ca -DIST NVIDIA-Linux-x86-340.76.run 38818911 SHA256 9b29d93b49009caed84a8852825c3e7c6ebbbba8ec99b03ee5113108c8b036d0 SHA512 45d7b29670f9ca50de80d6d61260015b45f74422bbd12039923d04ae8b033b903b27e9f4c174461055f3cf45a4af44565ce9a8b9cd671e0e54d37770a1156839 WHIRLPOOL da7e072a56e3aff8b4688e60c5acd76c97804fa582d21c70dce043b13fa2317d1021f19927e827cf6132aebe2d40371c750e3eb56697bc7eda16bb7369bf2994 -DIST NVIDIA-Linux-x86_64-337.25.run 68053486 SHA256 83280f7738f65bb2e790e7530a38978cf0bd0aa741eda51629c9e9b068128af0 SHA512 27cb5030da00d6fa2a2dd6701cc149ce885e7ff7e7ca4f1629c27737357fdadedec41e830f5cacabef14646515d6d2729f753d78424260316e28111f2c3e53b9 WHIRLPOOL 72eba5239ae7272d3501403ef292f0e131896b3dd852a7e2423e79206d99aa5a4a3b98eb4193ad5cd1e0247ffd48189d3a3ba02ca307a759a4f15b9c9a386dbd -DIST NVIDIA-Linux-x86_64-340.65.run 69903305 SHA256 cd3948db5c1e2468c50140efb4bb50f1a4c84c923db8ec756bd56ff35df9ff04 SHA512 dbc1ffd5c5c2ddf82530c2575d1219662bc630ba23cd38816c4500e7d4549a6345213029b947dca319b6bed367aff96d9f27c681cb9c511916ba0b4c35134d33 WHIRLPOOL 23eefb5142d29e886dece47f2e40ff2b27348b6b2e97883cebb630b074a852aa726c4fed6e01b736dc314dfe6b901534e1f46c68d82b99adb00ebe0c72358aea -DIST NVIDIA-Linux-x86_64-340.76.run 69955037 SHA256 3bf670e9a2bdb184648dec54ce06fab65e798a9a4c9dd5155e2be4efee3e0994 SHA512 59ad49a49f170ec971e2b5ee3a45b9f972521bc4b7ab6f02f46a5cfc5b1998841195cc5c91dffc417d2183de39c5a589eabf7b48864e0c6842363a75051db40c WHIRLPOOL 8c846f2b5b6f56bd2962fe4660751a4485e0ddd2186bde0affccece32271b03f4f3c226377c0b1877ea391ab130ed6f282c316f227205488a63e4f0a19db82cc -EBUILD nvidia-drivers-337.25.ebuild 13690 SHA256 3dd63988be81ab45248420412b0691419d965c177e7858faaf901b79905d30fe SHA512 b4263ef42d119f79a4c6c51f5610549e8698a6415e3b44943823d33c04bf01f2c8444b1c2695bc855c56bfc2bb61e25d0d8f888aac4028299f33b5fca625a371 WHIRLPOOL 46fe7f362a3e2bc36e35c106d1d475726168ba5422709c960baa82c7902877b77272f3c2f478497a63df031056b37ee84027c36b134efc1ea6e1b9693c9dba9a -EBUILD nvidia-drivers-340.65.ebuild 13689 SHA256 2a9aa8c91a5b08aaa107b3e132f4001f37ed64cb2fb9bd10c5a7ec393e7f9055 SHA512 5591ce29a340863d53f939f0c2107b467fb58287d71bb7cada93fab858cbf48b3df47da31276ff54bbd8026c9fb41280b6f6e9be7e6b4723fe413160bc0bbaea WHIRLPOOL f88fe1f8cc3a343ecc77b9573e68b676662023e80e5c83f0f72cb293723c83b20da8c83da30ec183e3b128a9ab6ecb372e7f8267470713370b476b2f17342210 -EBUILD nvidia-drivers-340.76.ebuild 13606 SHA256 a90b98f8f1fc41542a2dfee5927df5083d6d949cc3f8fbab866a2ba6629436dd SHA512 d597fa8ca86b3fee27502e73e9a9257ddf23aa78cf80966a530cef0ed886faff26bd7ee1f804ec722a12918f90e0ecd42aca2aa2217266b6efffd7153088a712 WHIRLPOOL 036314bb871096af806068088dd67c7554e957583818f18141c6901ec5830e61d55054a824d9c8e8b7098d41d057806e7b8ef2a023cf2f005861a5fca2f836d7 diff --git a/x11-drivers/nvidia-drivers/files/95-nvidia-settings b/x11-drivers/nvidia-drivers/files/95-nvidia-settings deleted file mode 100644 index e9d6274..0000000 --- a/x11-drivers/nvidia-drivers/files/95-nvidia-settings +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -/opt/bin/nvidia-settings --load-config-only diff --git a/x11-drivers/nvidia-drivers/files/nvidia-169.07 b/x11-drivers/nvidia-drivers/files/nvidia-169.07 deleted file mode 100644 index a96b0cd..0000000 --- a/x11-drivers/nvidia-drivers/files/nvidia-169.07 +++ /dev/null @@ -1,14 +0,0 @@ -# Nvidia drivers support -alias char-major-195 nvidia -alias /dev/nvidiactl char-major-195 - -# To tweak the driver the following options can be used, note that -# you should be careful, as it could cause instability!! For more -# options see /usr/share/doc/PACKAGE/README -# -# !!! SECURITY WARNING !!! -# DO NOT MODIFY OR REMOVE THE DEVICE FILE RELATED OPTIONS UNLESS YOU KNOW -# WHAT YOU ARE DOING. -# ONLY ADD TRUSTED USERS TO THE VIDEO GROUP, THESE USERS MAY BE ABLE TO CRASH, -# COMPROMISE, OR IRREPARABLY DAMAGE THE MACHINE. -options nvidia NVreg_DeviceFileMode=432 NVreg_DeviceFileUID=0 NVreg_DeviceFileGID=VIDEOGID NVreg_ModifyDeviceFiles=1 diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-331.13-pax-usercopy.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-331.13-pax-usercopy.patch deleted file mode 100644 index 9777ce6..0000000 --- a/x11-drivers/nvidia-drivers/files/nvidia-drivers-331.13-pax-usercopy.patch +++ /dev/null @@ -1,52 +0,0 @@ ---- a/kernel/nv-linux.h -+++ b/kernel/nv-linux.h -@@ -757,16 +757,16 @@ - - #if defined(NV_KMEM_CACHE_CREATE_PRESENT) - #if (NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT == 6) --#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type) \ -+#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type, flags) \ - { \ - kmem_cache = kmem_cache_create(name, sizeof(type), \ -- 0, 0, NULL, NULL); \ -+ 0, flags, NULL, NULL); \ - } - #elif (NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT == 5) --#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type) \ -+#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type, flags) \ - { \ - kmem_cache = kmem_cache_create(name, sizeof(type), \ -- 0, 0, NULL); \ -+ 0, flags, NULL); \ - } - #else - #error "NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT value unrecognized!" ---- a/kernel/nv.c -+++ b/kernel/nv.c -@@ -794,7 +794,7 @@ - NV_SPIN_LOCK_INIT(&km_lock); - #endif - -- NV_KMEM_CACHE_CREATE(nv_stack_t_cache, NV_STACK_CACHE_STR, nv_stack_t); -+ NV_KMEM_CACHE_CREATE(nv_stack_t_cache, NV_STACK_CACHE_STR, nv_stack_t, SLAB_USERCOPY); - if (nv_stack_t_cache == NULL) - { - nv_printf(NV_DBG_ERRORS, "NVRM: stack cache allocation failed!\n"); -@@ -924,7 +924,7 @@ - nv->os_state = (void *) &nv_ctl_device; - nv_lock_init_locks(nv); - -- NV_KMEM_CACHE_CREATE(nv_pte_t_cache, NV_PTE_CACHE_STR, nv_pte_t); -+ NV_KMEM_CACHE_CREATE(nv_pte_t_cache, NV_PTE_CACHE_STR, nv_pte_t, 0); - if (nv_pte_t_cache == NULL) - { - rc = -ENOMEM; -@@ -935,7 +935,7 @@ - if (NV_BUILD_MODULE_INSTANCES == 0) - { - NV_KMEM_CACHE_CREATE(nvidia_p2p_page_t_cache, "nvidia_p2p_page_t", -- nvidia_p2p_page_t); -+ nvidia_p2p_page_t, 0); - if (nvidia_p2p_page_t_cache == NULL) - { - rc = -ENOMEM; diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-337.12-pax-constify.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-337.12-pax-constify.patch deleted file mode 100644 index 0ec9edf..0000000 --- a/x11-drivers/nvidia-drivers/files/nvidia-drivers-337.12-pax-constify.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- a/kernel/uvm/nvidia_uvm_common.c -+++ b/kernel/uvm/nvidia_uvm_common.c -@@ -95,7 +95,6 @@ static RM_STATUS uvmnext_gpu_event_stop_ - #endif // NVIDIA_UVM_NEXT_ENABLED - - static dev_t g_uvmBaseDev; --struct UvmOpsUvmEvents g_exportedUvmOps; - - // TODO: This would be easier if RM allowed for multiple registrations, since we - // could register UVM-Lite and UVM-Next separately (bug 1372835). -@@ -147,9 +146,11 @@ static RM_STATUS uvmSetupGpuProvider(voi - RM_STATUS status = RM_OK; - - #ifdef NVIDIA_UVM_RM_ENABLED -- g_exportedUvmOps.startDevice = uvm_gpu_event_start_device; -- g_exportedUvmOps.stopDevice = uvm_gpu_event_stop_device; -- g_exportedUvmOps.isrTopHalf = uvmnext_isr_top_half; -+ static struct UvmOpsUvmEvents g_exportedUvmOps = { -+ .startDevice = uvm_gpu_event_start_device, -+ .stopDevice = uvm_gpu_event_stop_device, -+ .isrTopHalf = uvmnext_isr_top_half, -+ }; - - // call RM to exchange the function pointers. - status = nvUvmInterfaceRegisterUvmCallbacks(&g_exportedUvmOps); diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-337.25-3.18.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-337.25-3.18.patch deleted file mode 100644 index cb7221b..0000000 --- a/x11-drivers/nvidia-drivers/files/nvidia-drivers-337.25-3.18.patch +++ /dev/null @@ -1,3613 +0,0 @@ -diff -urN kernel.orig/nv.c kernel/nv.c ---- kernel.orig/nv.c 2014-05-27 22:59:51.000000000 +0400 -+++ kernel/nv.c 2015-01-17 23:33:57.949450431 +0300 -@@ -1827,7 +1827,7 @@ - unsigned long i_arg - ) - { -- return nvidia_ioctl(file->f_dentry->d_inode, file, cmd, i_arg); -+ return nvidia_ioctl(file->f_path.dentry->d_inode, file, cmd, i_arg); - } - - /* -diff -urN kernel.orig/nv.c.orig kernel/nv.c.orig ---- kernel.orig/nv.c.orig 1970-01-01 03:00:00.000000000 +0300 -+++ kernel/nv.c.orig 2014-05-27 22:59:51.000000000 +0400 -@@ -0,0 +1,3319 @@ -+/* _NVRM_COPYRIGHT_BEGIN_ -+ * -+ * Copyright 1999-2013 by NVIDIA Corporation. All rights reserved. All -+ * information contained herein is proprietary and confidential to NVIDIA -+ * Corporation. Any use, reproduction, or disclosure without the written -+ * permission of NVIDIA Corporation is prohibited. -+ * -+ * _NVRM_COPYRIGHT_END_ -+ */ -+ -+#include "nv-misc.h" -+#include "os-interface.h" -+#include "nv-linux.h" -+#include "nv-p2p.h" -+#include "nv-reg.h" -+#include "rmil.h" -+ -+#if defined(NV_UVM_ENABLE) || defined(NV_UVM_NEXT_ENABLE) -+#include "nv_uvm_interface.h" -+#endif -+ -+#if !defined(NV_VMWARE) -+#include "nv-frontend.h" -+#endif -+ -+/* -+ * The module information macros for Linux single-module builds -+ * are present in nv-frontend.c. -+ */ -+ -+#if defined(NV_VMWARE) || (NV_BUILD_MODULE_INSTANCES != 0) -+#if defined(MODULE_LICENSE) -+MODULE_LICENSE("NVIDIA"); -+#endif -+#if defined(MODULE_INFO) -+MODULE_INFO(supported, "external"); -+#endif -+#if defined(MODULE_VERSION) -+MODULE_VERSION(NV_VERSION_STRING); -+#endif -+#ifdef MODULE_ALIAS_CHARDEV_MAJOR -+MODULE_ALIAS_CHARDEV_MAJOR(NV_MAJOR_DEVICE_NUMBER); -+#endif -+#endif -+ -+#include "conftest/patches.h" -+ -+/* -+ * our global state; one per device -+ */ -+ -+static NvU32 num_nv_devices = 0; -+NvU32 num_probed_nv_devices = 0; -+ -+NvU32 nv_assign_gpu_count = 0; -+nv_pci_info_t nv_assign_gpu_pci_info[NV_MAX_DEVICES]; -+ -+nv_linux_state_t *nv_linux_devices; -+static nv_smu_state_t nv_smu_device; -+ -+#define NV_STACK_CACHE_STR (NV_DEV_NAME"_stack_t") -+#define NV_PTE_CACHE_STR (NV_DEV_NAME"_pte_t") -+ -+#if defined(NVCPU_X86) || defined(NVCPU_X86_64) -+NvU64 __nv_supported_pte_mask = ~_PAGE_NX; -+#endif -+ -+/* -+ * And one for the control device -+ */ -+ -+nv_linux_state_t nv_ctl_device = { { 0 } }; -+wait_queue_head_t nv_ctl_waitqueue; -+ -+#if defined(NV_CHANGE_PAGE_ATTR_BUG_PRESENT) -+static const char *__cpgattr_warning = \ -+ "Your Linux kernel has known problems in its implementation of\n" -+ "the change_page_attr() kernel interface.\n\n" -+ "The NVIDIA graphics driver will attempt to work around these\n" -+ "problems, but system stability may be adversely affected.\n" -+ "It is recommended that you update to Linux 2.6.11 (or a newer\n" -+ "Linux kernel release).\n"; -+ -+static const char *__cpgattr_warning_2 = \ -+ "Your Linux kernel's version and architecture indicate that it\n" -+ "may have an implementation of the change_page_attr() kernel\n" -+ "kernel interface known to have problems. The NVIDIA graphics\n" -+ "driver made an attempt to determine whether your kernel is\n" -+ "affected, but could not. It will assume the interface does not\n" -+ "work correctly and attempt to employ workarounds.\n" -+ "This may adversely affect system stability.\n" -+ "It is recommended that you update to Linux 2.6.11 (or a newer\n" -+ "Linux kernel release).\n"; -+#endif -+ -+static int nv_mmconfig_failure_detected = 0; -+static const char *__mmconfig_warning = \ -+ "Your current system configuration has known problems when\n" -+ "accessing PCI Configuration Space that can lead to accesses\n" -+ "to the PCI Configuration Space of the wrong PCI device. This\n" -+ "is known to cause instabilities with the NVIDIA graphics driver.\n\n" -+ "Please see the MMConfig section in the readme for more information\n" -+ "on how to work around this problem.\n"; -+ -+#if !defined(NV_VMWARE) && \ -+ (defined(NVCPU_X86) || defined(NVCPU_X86_64)) -+static int nv_fbdev_failure_detected = 0; -+static const char *__fbdev_warning = \ -+ "Your system is not currently configured to drive a VGA console\n" -+ "on the primary VGA device. The NVIDIA Linux graphics driver\n" -+ "requires the use of a text-mode VGA console. Use of other console\n" -+ "drivers including, but not limited to, vesafb, may result in\n" -+ "corruption and stability problems, and is not supported.\n"; -+#endif -+ -+#if defined(NV_SG_MAP_BUFFERS) && defined(NV_NEED_REMAP_CHECK) -+unsigned int nv_remap_count; -+unsigned int nv_remap_limit; -+#endif -+ -+#if defined(NV_CONFIG_PREEMPT_RT) -+#define NV_UPDATE_MEMORY_TYPES_DEFAULT 0 -+#else -+#define NV_UPDATE_MEMORY_TYPES_DEFAULT 1 -+#endif -+ -+int nv_update_memory_types = NV_UPDATE_MEMORY_TYPES_DEFAULT; -+ -+void *nvidia_p2p_page_t_cache; -+static void *nv_pte_t_cache; -+void *nv_stack_t_cache; -+static nv_stack_t *__nv_init_sp; -+ -+/* -+ * vGPU specific macro to lock/unlock nv_linux_devices list -+ * These macros are enabled only for vGPU module -+ * Lock acquisition order while using the nv_linux_devices list -+ * 1. LOCK_NV_LINUX_DEVICES() -+ * 2. Traverse the list -+ * If the list is traversed to search for an element say nvl, -+ * acquire the nvl->ldata_lock before step 3 -+ * 3. UNLOCK_NV_LINUX_DEVICES() -+ * 4. Release nvl->ldata_lock after any read/write access to the -+ * nvl element is complete -+ */ -+#if defined(NV_VGX_HYPER) -+struct semaphore nv_linux_devices_lock; -+#define LOCK_NV_LINUX_DEVICES() down(&nv_linux_devices_lock) -+#define UNLOCK_NV_LINUX_DEVICES() up(&nv_linux_devices_lock) -+#else -+#define LOCK_NV_LINUX_DEVICES() -+#define UNLOCK_NV_LINUX_DEVICES() -+#endif -+ -+// allow an easy way to convert all debug printfs related to events -+// back and forth between 'info' and 'errors' -+#if defined(NV_DBG_EVENTS) -+#define NV_DBG_EVENTINFO NV_DBG_ERRORS -+#else -+#define NV_DBG_EVENTINFO NV_DBG_INFO -+#endif -+ -+// -+// Attempt to determine if we are running into the MMCONFIG coherency -+// issue and, if so, warn the user and stop attempting to verify -+// and correct the BAR values (see NV_CHECK_PCI_CONFIG_SPACE()), so -+// that we do not do more harm than good. -+// -+#define NV_CHECK_MMCONFIG_FAILURE(nv,bar,value) \ -+ { \ -+ nv_linux_state_t *nvl; \ -+ for (nvl = nv_linux_devices; nvl != NULL; nvl = nvl->next) \ -+ { \ -+ nv_state_t *nv_tmp = NV_STATE_PTR(nvl); \ -+ if (((nv) != nv_tmp) && \ -+ (nv_tmp->bars[(bar)].address == (value))) \ -+ { \ -+ nv_prints(NV_DBG_ERRORS, __mmconfig_warning); \ -+ nv_procfs_add_warning("mmconfig", __mmconfig_warning); \ -+ nv_mmconfig_failure_detected = 1; \ -+ return; \ -+ } \ -+ } \ -+ } -+ -+static void -+verify_pci_bars( -+ nv_state_t *nv, -+ void *dev_handle -+) -+{ -+ NvU32 bar, bar_hi, bar_lo; -+ -+ // -+ // If an MMCONFIG specific failure was detected, skip the -+ // PCI BAR verification to avoid overwriting the BAR(s) -+ // of a given device with those of this GPU. See above for -+ // more information. -+ // -+ if (nv_mmconfig_failure_detected) -+ return; -+ -+ for (bar = 0; bar < NV_GPU_NUM_BARS; bar++) -+ { -+ nv_aperture_t *tmp = &nv->bars[bar]; -+ -+ bar_lo = bar_hi = 0; -+ if (tmp->offset == 0) -+ continue; -+ -+ os_pci_read_dword(dev_handle, tmp->offset, &bar_lo); -+ -+ if ((bar_lo & NVRM_PCICFG_BAR_ADDR_MASK) -+ != (tmp->address & 0xffffffff)) -+ { -+ nv_printf(NV_DBG_USERERRORS, -+ "NVRM: BAR%u(L) is 0x%08x, will restore to 0x%08llx.\n", -+ bar, bar_lo, (tmp->address & 0xffffffff)); -+ -+ NV_CHECK_MMCONFIG_FAILURE(nv, bar, -+ (bar_lo & NVRM_PCICFG_BAR_ADDR_MASK)); -+ -+ os_pci_write_dword(dev_handle, tmp->offset, tmp->address); -+ } -+ -+ if ((bar_lo & NVRM_PCICFG_BAR_MEMTYPE_MASK) -+ != NVRM_PCICFG_BAR_MEMTYPE_64BIT) -+ continue; -+ -+ os_pci_read_dword(dev_handle, (tmp->offset + 4), &bar_hi); -+ -+ if (bar_hi != (tmp->address >> 32)) -+ { -+ nv_printf(NV_DBG_USERERRORS, -+ "NVRM: BAR%u(H) is 0x%08x, will restore to 0x%08llx.\n", -+ bar, bar_hi, (tmp->address >> 32)); -+ -+ os_pci_write_dword(dev_handle, (tmp->offset + 4), -+ (tmp->address >> 32)); -+ } -+ } -+} -+ -+void nv_check_pci_config_space(nv_state_t *nv, BOOL check_the_bars) -+{ -+ nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv); -+ unsigned short cmd, flag = 0; -+ -+ pci_read_config_word(nvl->dev, PCI_COMMAND, &cmd); -+ if (!(cmd & PCI_COMMAND_MASTER)) -+ { -+ nv_printf(NV_DBG_USERERRORS, "NVRM: restoring bus mastering!\n"); -+ cmd |= PCI_COMMAND_MASTER; -+ flag = 1; -+ } -+ -+ if (!(cmd & PCI_COMMAND_MEMORY)) -+ { -+ nv_printf(NV_DBG_USERERRORS, "NVRM: restoring MEM access!\n"); -+ cmd |= PCI_COMMAND_MEMORY; -+ flag = 1; -+ } -+ -+ if (cmd & PCI_COMMAND_SERR) -+ { -+ nv_printf(NV_DBG_USERERRORS, "NVRM: clearing SERR enable bit!\n"); -+ cmd &= ~PCI_COMMAND_SERR; -+ flag = 1; -+ } -+ -+ if (cmd & PCI_COMMAND_INTX_DISABLE) -+ { -+ nv_printf(NV_DBG_USERERRORS, "NVRM: clearing INTx disable bit!\n"); -+ cmd &= ~PCI_COMMAND_INTX_DISABLE; -+ flag = 1; -+ } -+ -+ if (flag) -+ pci_write_config_word(nvl->dev, PCI_COMMAND, cmd); -+ -+ if (check_the_bars && NV_MAY_SLEEP() && !(nv->flags & NV_FLAG_PASSTHRU)) -+ verify_pci_bars(nv, nvl->dev); -+} -+ -+void NV_API_CALL nv_verify_pci_config( -+ nv_state_t *nv, -+ BOOL check_the_bars -+) -+{ -+ nv_linux_state_t *nvl; -+ nv_stack_t *sp; -+ -+ if ((nv)->flags & NV_FLAG_USE_BAR0_CFG) -+ { -+ nvl = NV_GET_NVL_FROM_NV_STATE(nv); -+ sp = nvl->pci_cfgchk_sp; -+ -+ rm_check_pci_config_space(sp, nv, -+ check_the_bars, FALSE, NV_MAY_SLEEP()); -+ } -+ else -+ nv_check_pci_config_space(nv, NV_MAY_SLEEP()); -+} -+ -+/*** -+ *** STATIC functions, only in this file -+ ***/ -+ -+/* nvos_ functions.. do not take a state device parameter */ -+static int nvos_count_devices(nv_stack_t *); -+ -+static nv_alloc_t *nvos_create_alloc(struct pci_dev *, int); -+static int nvos_free_alloc(nv_alloc_t *); -+ -+/* lock-related functions that should only be called from this file */ -+static void nv_lock_init_locks(nv_state_t *nv); -+ -+ -+/*** -+ *** EXPORTS to Linux Kernel -+ ***/ -+ -+static int nvidia_open (struct inode *, struct file *); -+static int nvidia_close (struct inode *, struct file *); -+static unsigned int nvidia_poll (struct file *, poll_table *); -+static int nvidia_ioctl (struct inode *, struct file *, unsigned int, unsigned long); -+static long nvidia_unlocked_ioctl (struct file *, unsigned int, unsigned long); -+static void nvidia_isr_bh (unsigned long); -+#if !defined(NV_IRQ_HANDLER_T_PRESENT) || (NV_IRQ_HANDLER_T_ARGUMENT_COUNT == 3) -+static irqreturn_t nvidia_isr (int, void *, struct pt_regs *); -+#else -+static irqreturn_t nvidia_isr (int, void *); -+#endif -+static void nvidia_rc_timer (unsigned long); -+ -+static int nvidia_ctl_open (struct inode *, struct file *); -+static int nvidia_ctl_close (struct inode *, struct file *); -+ -+static int nvidia_probe (struct pci_dev *, const struct pci_device_id *); -+static void nvidia_remove (struct pci_dev *); -+static int nvidia_smu_probe (struct pci_dev *); -+ -+#if defined(NV_PM_SUPPORT_DEVICE_DRIVER_MODEL) -+static int nvidia_suspend (struct pci_dev *, pm_message_t); -+static int nvidia_smu_suspend (void); -+static int nvidia_resume (struct pci_dev *); -+static int nvidia_smu_resume (void); -+#endif -+ -+/*** -+ *** see nv.h for functions exported to other parts of resman -+ ***/ -+ -+static struct pci_device_id nv_pci_table[] = { -+ { -+ .vendor = PCI_VENDOR_ID_NVIDIA, -+ .device = PCI_ANY_ID, -+ .subvendor = PCI_ANY_ID, -+ .subdevice = PCI_ANY_ID, -+ .class = (PCI_CLASS_DISPLAY_VGA << 8), -+ .class_mask = ~0 -+ }, -+ { -+ .vendor = PCI_VENDOR_ID_NVIDIA, -+ .device = PCI_ANY_ID, -+ .subvendor = PCI_ANY_ID, -+ .subdevice = PCI_ANY_ID, -+ .class = (PCI_CLASS_DISPLAY_3D << 8), -+ .class_mask = ~0 -+ }, -+ { -+ .vendor = PCI_VENDOR_ID_NVIDIA, -+ .device = NV_PCI_DEVICE_ID_SMU, -+ .subvendor = PCI_ANY_ID, -+ .subdevice = PCI_ANY_ID, -+ .class = (PCI_CLASS_PROCESSOR_CO << 8), /* SMU device class */ -+ .class_mask = ~0 -+ }, -+ { -+ .vendor = PCI_VENDOR_ID_NVIDIA, -+ .device = 0x0e00, -+ .subvendor = PCI_ANY_ID, -+ .subdevice = PCI_ANY_ID, -+ .class = (PCI_CLASS_MULTIMEDIA_OTHER << 8), -+ .class_mask = ~0 -+ }, -+ { } -+}; -+ -+MODULE_DEVICE_TABLE(pci, nv_pci_table); -+ -+static struct pci_driver nv_pci_driver = { -+ .name = NV_DEV_NAME, -+ .id_table = nv_pci_table, -+ .probe = nvidia_probe, -+#if defined(NV_VGX_HYPER) -+ .remove = nvidia_remove, -+#endif -+#if defined(NV_PM_SUPPORT_DEVICE_DRIVER_MODEL) -+ .suspend = nvidia_suspend, -+ .resume = nvidia_resume, -+#endif -+}; -+ -+#if defined(NV_VMWARE) -+/* character driver entry points */ -+ -+static struct file_operations nv_fops = { -+ .owner = THIS_MODULE, -+ .poll = nvidia_poll, -+#if defined(NV_FILE_OPERATIONS_HAS_IOCTL) -+ .ioctl = nvidia_ioctl, -+#endif -+#if defined(NV_FILE_OPERATIONS_HAS_UNLOCKED_IOCTL) -+ .unlocked_ioctl = nvidia_unlocked_ioctl, -+#endif -+ .open = nvidia_open, -+ .release = nvidia_close, -+}; -+#else -+static nvidia_module_t nv_fops = { -+ .owner = THIS_MODULE, -+ .module_name = NV_DEV_NAME, -+ .open = nvidia_open, -+ .close = nvidia_close, -+ .ioctl = nvidia_ioctl, -+ .mmap = nvidia_mmap, -+ .poll = nvidia_poll, -+}; -+#endif -+ -+#if defined(VM_CHECKER) -+/* kernel virtual memory usage/allocation information */ -+NvU32 vm_usage = 0; -+struct mem_track_t *vm_list = NULL; -+nv_spinlock_t vm_lock; -+#endif -+ -+#if defined(KM_CHECKER) -+/* kernel logical memory usage/allocation information */ -+NvU32 km_usage = 0; -+struct mem_track_t *km_list = NULL; -+nv_spinlock_t km_lock; -+#endif -+ -+ -+/*** -+ *** STATIC functions -+ ***/ -+ -+static -+nv_alloc_t *nvos_create_alloc( -+ struct pci_dev *dev, -+ int num_pages -+) -+{ -+ nv_alloc_t *at; -+ unsigned int pt_size, i; -+ -+ NV_KMALLOC(at, sizeof(nv_alloc_t)); -+ if (at == NULL) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate alloc info\n"); -+ return NULL; -+ } -+ -+ memset(at, 0, sizeof(nv_alloc_t)); -+ -+ pt_size = num_pages * sizeof(nv_pte_t *); -+ if (os_alloc_mem((void **)&at->page_table, pt_size) != RM_OK) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate page table\n"); -+ NV_KFREE(at, sizeof(nv_alloc_t)); -+ return NULL; -+ } -+ -+ memset(at->page_table, 0, pt_size); -+ at->num_pages = num_pages; -+ NV_ATOMIC_SET(at->usage_count, 0); -+ -+ for (i = 0; i < at->num_pages; i++) -+ { -+ NV_KMEM_CACHE_ALLOC(at->page_table[i], nv_pte_t_cache, nv_pte_t); -+ if (at->page_table[i] == NULL) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: failed to allocate page table entry\n"); -+ nvos_free_alloc(at); -+ return NULL; -+ } -+ memset(at->page_table[i], 0, sizeof(nv_pte_t)); -+ } -+ -+ at->pid = os_get_current_process(); -+ -+ return at; -+} -+ -+static -+int nvos_free_alloc( -+ nv_alloc_t *at -+) -+{ -+ unsigned int i; -+ -+ if (at == NULL) -+ return -1; -+ -+ if (NV_ATOMIC_READ(at->usage_count)) -+ return 1; -+ -+ for (i = 0; i < at->num_pages; i++) -+ { -+ if (at->page_table[i] != NULL) -+ NV_KMEM_CACHE_FREE(at->page_table[i], nv_pte_t, nv_pte_t_cache); -+ } -+ os_free_mem(at->page_table); -+ -+ NV_KFREE(at, sizeof(nv_alloc_t)); -+ -+ return 0; -+} -+ -+NvU8 nv_find_pci_capability(struct pci_dev *dev, NvU8 capability) -+{ -+ u16 status; -+ u8 cap_ptr, cap_id; -+ -+ pci_read_config_word(dev, PCI_STATUS, &status); -+ status &= PCI_STATUS_CAP_LIST; -+ if (!status) -+ return 0; -+ -+ switch (dev->hdr_type) { -+ case PCI_HEADER_TYPE_NORMAL: -+ case PCI_HEADER_TYPE_BRIDGE: -+ pci_read_config_byte(dev, PCI_CAPABILITY_LIST, &cap_ptr); -+ break; -+ default: -+ return 0; -+ } -+ -+ do { -+ cap_ptr &= 0xfc; -+ pci_read_config_byte(dev, cap_ptr + PCI_CAP_LIST_ID, &cap_id); -+ if (cap_id == capability) -+ return cap_ptr; -+ pci_read_config_byte(dev, cap_ptr + PCI_CAP_LIST_NEXT, &cap_ptr); -+ } while (cap_ptr && cap_id != 0xff); -+ -+ return 0; -+} -+ -+#if defined(NV_CHANGE_PAGE_ATTR_BUG_PRESENT) -+/* -+ * 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 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. -+ * -+ * 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, 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) -+{ -+ pgd_t *pgd = NULL; -+ pmd_t *pmd = NULL; -+ -+ pgd = NV_PGD_OFFSET(vaddr, 1, NULL); -+ if (!NV_PGD_PRESENT(pgd)) -+ return NULL; -+ -+ pmd = NV_PMD_OFFSET(vaddr, pgd); -+ if (!pmd || pmd_none(*pmd)) -+ return NULL; -+ -+ if (!pmd_large(*pmd)) -+ return NULL; -+ -+ return (pte_t *) pmd; -+} -+ -+#define CPA_FIXED_MAX_ALLOCS 500 -+ -+int nv_verify_cpa_interface(void) -+{ -+ unsigned int i, size; -+ unsigned long large_page = 0; -+ unsigned long *vaddr_list; -+ size = sizeof(unsigned long) * CPA_FIXED_MAX_ALLOCS; -+ -+ NV_KMALLOC(vaddr_list, size); -+ if (!vaddr_list) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: nv_verify_cpa_interface: failed to allocate " -+ "page table\n"); -+ return 1; -+ } -+ -+ memset(vaddr_list, 0, size); -+ -+ /* try to track down an allocation from a 2M page. */ -+ for (i = 0; i < CPA_FIXED_MAX_ALLOCS; i++) -+ { -+ vaddr_list[i] = __get_free_page(GFP_KERNEL); -+ if (!vaddr_list[i]) -+ continue; -+ -+#if defined(_PAGE_NX) -+ if ((pgprot_val(PAGE_KERNEL) & _PAGE_NX) && -+ virt_to_phys((void *)vaddr_list[i]) < 0x400000) -+ continue; -+#endif -+ -+ if (check_large_page(vaddr_list[i]) != NULL) -+ { -+ large_page = vaddr_list[i]; -+ vaddr_list[i] = 0; -+ break; -+ } -+ } -+ -+ for (i = 0; i < CPA_FIXED_MAX_ALLOCS; i++) -+ { -+ if (vaddr_list[i]) -+ free_page(vaddr_list[i]); -+ } -+ NV_KFREE(vaddr_list, size); -+ -+ if (large_page) -+ { -+ struct page *page = virt_to_page(large_page); -+ struct page *kpte_page; -+ pte_t *kpte; -+ unsigned long kpte_val; -+ pgprot_t prot; -+ -+ // lookup a pointer to our pte -+ kpte = check_large_page(large_page); -+ kpte_val = pte_val(*kpte); -+ kpte_page = virt_to_page(((unsigned long)kpte) & PAGE_MASK); -+ -+ prot = PAGE_KERNEL_NOCACHE; -+ pgprot_val(prot) &= __nv_supported_pte_mask; -+ -+ // this should split the large page -+ change_page_attr(page, 1, prot); -+ -+ // broken kernels may get confused after splitting the page and -+ // restore the page before returning to us. detect that case. -+ if (((pte_val(*kpte) & ~_PAGE_NX) == kpte_val) && -+ (pte_val(*kpte) & _PAGE_PSE)) -+ { -+ if ((pte_val(*kpte) & _PAGE_NX) && -+ (__nv_supported_pte_mask & _PAGE_NX) == 0) -+ clear_bit(_PAGE_BIT_NX, kpte); -+ // don't change the page back, as it's already been reverted -+ put_page(kpte_page); -+ free_page(large_page); -+ return -1; // yep, we're broken -+ } -+ -+ // ok, now see if our bookkeeping is broken -+ if (page_count(kpte_page) != 0) -+ return -1; // yep, we're broken -+ -+ prot = PAGE_KERNEL; -+ pgprot_val(prot) &= __nv_supported_pte_mask; -+ -+ // everything's ok! -+ change_page_attr(page, 1, prot); -+ free_page(large_page); -+ return 0; -+ } -+ -+ return 1; -+} -+#endif /* defined(NV_CHANGE_PAGE_ATTR_BUG_PRESENT) */ -+ -+int __init nvidia_init_module(void) -+{ -+ RM_STATUS status; -+ int rc; -+ NvU32 count, data, i; -+ nv_state_t *nv = NV_STATE_PTR(&nv_ctl_device); -+ nv_stack_t *sp = NULL; -+ nv_linux_state_t *nvl; -+ nv_smu_state_t *nv_smu = &nv_smu_device; -+ -+ if (NV_BUILD_MODULE_INSTANCES != 0) -+ { -+ nv_printf(NV_DBG_INFO, "NVRM: nvidia module instance %d\n", -+ NV_MODULE_INSTANCE); -+ } -+ -+ nv_user_map_init(); -+ -+ rc = nv_heap_create(); -+ if (rc < 0) -+ { -+ goto failed4; -+ } -+ -+ rc = nv_mem_pool_create(); -+ if (rc < 0) -+ { -+ goto failed4; -+ } -+ -+#if defined(NV_LINUX_NVMAP_H_PRESENT) && defined(HAVE_NV_ANDROID) -+ status = nv_nvmap_create_client(); -+ if (RM_OK != status) -+ { -+ rc = -EIO; -+ goto failed4; -+ } -+#endif -+ -+#if defined(VM_CHECKER) -+ NV_SPIN_LOCK_INIT(&vm_lock); -+#endif -+#if defined(KM_CHECKER) -+ NV_SPIN_LOCK_INIT(&km_lock); -+#endif -+ -+ NV_KMEM_CACHE_CREATE(nv_stack_t_cache, NV_STACK_CACHE_STR, nv_stack_t); -+ if (nv_stack_t_cache == NULL) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: stack cache allocation failed!\n"); -+ rc = -ENOMEM; -+ goto failed4; -+ } -+ -+ NV_KMEM_CACHE_ALLOC_STACK(sp); -+ if (sp == NULL) -+ { -+ NV_KMEM_CACHE_DESTROY(nv_stack_t_cache); -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate stack!\n"); -+ rc = -ENOMEM; -+ goto failed4; -+ } -+ -+ if (!rm_init_rm(sp)) -+ { -+ NV_KMEM_CACHE_FREE_STACK(sp); -+ NV_KMEM_CACHE_DESTROY(nv_stack_t_cache); -+ nv_printf(NV_DBG_ERRORS, "NVRM: rm_init_rm() failed!\n"); -+ return -EIO; -+ } -+ -+ count = nvos_count_devices(sp); -+ if (count == 0) -+ { -+ if (NV_IS_ASSIGN_GPU_PCI_INFO_SPECIFIED()) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: The requested GPU assignments are invalid. Please ensure\n" -+ "NVRM: that the GPUs you wish to assign to this kernel module\n" -+ "NVRM: are present and available.\n"); -+ } -+ else -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: No NVIDIA graphics adapter found!\n"); -+ } -+ rc = -ENODEV; -+ goto failed5; -+ } -+ -+ nv_linux_devices = NULL; -+#if defined(NV_VGX_HYPER) -+ NV_INIT_MUTEX(&nv_linux_devices_lock); -+#endif -+ -+ memset(&nv_smu_device, 0, sizeof(nv_smu_state_t)); -+ -+ rc = nv_register_chrdev((void *)&nv_fops); -+ if (rc < 0) -+ goto failed5; -+ -+ /* create /proc/driver/nvidia/... */ -+ rc = nv_register_procfs(); -+ if (rc < 0) -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to register procfs!\n"); -+ -+ if (pci_register_driver(&nv_pci_driver) < 0) -+ { -+ rc = -ENODEV; -+ nv_printf(NV_DBG_ERRORS, "NVRM: No NVIDIA graphics adapter found!\n"); -+ goto failed4; -+ } -+ -+ if (nv_drm_init(&nv_pci_driver) < 0) -+ { -+ rc = -ENODEV; -+ nv_printf(NV_DBG_ERRORS, "NVRM: DRM init failed\n"); -+ goto failed3; -+ } -+ -+ if (nv_smu->handle != NULL) -+ { -+ /* init SMU functionality */ -+ rm_init_smu(sp, nv_smu); -+ } -+ -+ if (num_probed_nv_devices != count) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: The NVIDIA probe routine was not called for %d device(s).\n", -+ count - num_probed_nv_devices); -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: This can occur when a driver such as: \n" -+ "NVRM: nouveau, rivafb, nvidiafb or rivatv " -+#if (NV_BUILD_MODULE_INSTANCES != 0) -+ "NVRM: or another NVIDIA kernel module " -+#endif -+ "\nNVRM: was loaded and obtained ownership of the NVIDIA device(s).\n"); -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: Try unloading the conflicting kernel module (and/or\n" -+ "NVRM: reconfigure your kernel without the conflicting\n" -+ "NVRM: driver(s)), then try loading the NVIDIA kernel module\n" -+ "NVRM: again.\n"); -+ } -+ -+ if (num_probed_nv_devices == 0) -+ { -+ rc = -ENODEV; -+ nv_printf(NV_DBG_ERRORS, "NVRM: No NVIDIA graphics adapter probed!\n"); -+ goto failed2; -+ } -+ -+ if (num_probed_nv_devices != num_nv_devices) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: The NVIDIA probe routine failed for %d device(s).\n", -+ num_probed_nv_devices - num_nv_devices); -+ } -+ -+ if (num_nv_devices == 0) -+ { -+ rc = -ENODEV; -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: None of the NVIDIA graphics adapters were initialized!\n"); -+ goto failed2; -+ } -+ -+ nv_printf(NV_DBG_ERRORS, "NVRM: loading %s", pNVRM_ID); -+ if (__nv_patches[0].short_description != NULL) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ " (applied patches: %s", __nv_patches[0].short_description); -+ for (i = 1; __nv_patches[i].short_description; i++) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ ",%s", __nv_patches[i].short_description); -+ } -+ nv_printf(NV_DBG_ERRORS, ")"); -+ } -+ nv_printf(NV_DBG_ERRORS, "\n"); -+ -+ // init the nvidia control device -+ nv->os_state = (void *) &nv_ctl_device; -+ nv_lock_init_locks(nv); -+ -+ NV_KMEM_CACHE_CREATE(nv_pte_t_cache, NV_PTE_CACHE_STR, nv_pte_t); -+ if (nv_pte_t_cache == NULL) -+ { -+ rc = -ENOMEM; -+ nv_printf(NV_DBG_ERRORS, "NVRM: pte cache allocation failed\n"); -+ goto failed; -+ } -+ -+ if (NV_BUILD_MODULE_INSTANCES == 0) -+ { -+ NV_KMEM_CACHE_CREATE(nvidia_p2p_page_t_cache, "nvidia_p2p_page_t", -+ nvidia_p2p_page_t); -+ if (nvidia_p2p_page_t_cache == NULL) -+ { -+ rc = -ENOMEM; -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: p2p page cache allocation failed\n"); -+ goto failed; -+ } -+ } -+ -+#if defined(NV_SG_MAP_BUFFERS) && defined(NV_NEED_REMAP_CHECK) -+ rm_read_registry_dword(sp, nv, "NVreg", "RemapLimit", &nv_remap_limit); -+ -+ // allow an override, but use default if no override -+ if (nv_remap_limit == 0) -+ nv_remap_limit = NV_REMAP_LIMIT_DEFAULT; -+ -+ nv_remap_count = 0; -+#endif -+ -+#if !defined(NV_VMWARE) && \ -+ (defined(NVCPU_X86_64) || (defined(NVCPU_X86) && defined(CONFIG_X86_PAE))) -+ if (boot_cpu_has(X86_FEATURE_NX)) -+ { -+ NvU32 __eax, __edx; -+ rdmsr(MSR_EFER, __eax, __edx); -+ if ((__eax & EFER_NX) != 0) -+ __nv_supported_pte_mask |= _PAGE_NX; -+ } -+ if (_PAGE_NX != ((NvU64)1<<63)) -+ { -+ /* -+ * Make sure we don't strip software no-execute -+ * bits from PAGE_KERNEL(_NOCACHE) before calling -+ * change_page_attr(). -+ */ -+ __nv_supported_pte_mask |= _PAGE_NX; -+ } -+#endif -+ -+ /* -+ * Give users an opportunity to disable the driver's use of -+ * the change_page_attr(), set_pages_{uc,wb}() and set_memory_{uc,wb}() kernel -+ * interfaces. -+ */ -+ status = rm_read_registry_dword(sp, nv, -+ "NVreg", NV_REG_UPDATE_MEMORY_TYPES, &data); -+ if ((status == RM_OK) && ((int)data != ~0)) -+ { -+ nv_update_memory_types = data; -+ } -+ -+#if defined(NV_CHANGE_PAGE_ATTR_BUG_PRESENT) -+ /* -+ * 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) -+ { -+ nv_prints(NV_DBG_ERRORS, __cpgattr_warning); -+ nv_procfs_add_warning("change_page_attr", __cpgattr_warning); -+ nv_update_memory_types = 0; -+ } -+ else if (rc != 0) -+ { -+ nv_prints(NV_DBG_ERRORS, __cpgattr_warning_2); -+ nv_procfs_add_warning("change_page_attr", __cpgattr_warning_2); -+ nv_update_memory_types = 0; -+ } -+ } -+#endif /* defined(NV_CHANGE_PAGE_ATTR_BUG_PRESENT) */ -+ -+#if defined(NVCPU_X86_64) && defined(CONFIG_IA32_EMULATION) && \ -+ !defined(NV_FILE_OPERATIONS_HAS_COMPAT_IOCTL) -+ rm_register_compatible_ioctls(sp); -+#endif -+ -+ rc = nv_init_pat_support(sp); -+ if (rc < 0) -+ goto failed; -+ -+ __nv_init_sp = sp; -+ -+ for (nvl = nv_linux_devices; nvl != NULL; nvl = nvl->next) -+ { -+#if defined(NV_PM_MESSAGE_T_HAS_EVENT) -+ nvl->nv_state.flags |= NV_FLAG_S4_AVAILABLE; -+#else -+ nvl->nv_state.flags &= ~NV_FLAG_S4_AVAILABLE; -+#endif -+#if defined(NV_PM_VT_SWITCH_REQUIRED_PRESENT) -+ pm_vt_switch_required(&nvl->dev->dev, NV_TRUE); -+#endif -+ } -+ return 0; -+ -+failed: -+ if (nvidia_p2p_page_t_cache != NULL) -+ NV_KMEM_CACHE_DESTROY(nvidia_p2p_page_t_cache); -+ -+ if (nv_pte_t_cache != NULL) -+ NV_KMEM_CACHE_DESTROY(nv_pte_t_cache); -+ -+ nv_unregister_chrdev((void *)&nv_fops); -+ -+failed2: -+ while (nv_linux_devices != NULL) -+ { -+ nv_linux_state_t *tmp; -+ if (nv_linux_devices->dev) -+ { -+ struct pci_dev *dev = nv_linux_devices->dev; -+ release_mem_region(NV_PCI_RESOURCE_START(dev, NV_GPU_BAR_INDEX_REGS), -+ NV_PCI_RESOURCE_SIZE(dev, NV_GPU_BAR_INDEX_REGS)); -+ NV_PCI_DISABLE_DEVICE(dev); -+ pci_set_drvdata(dev, NULL); -+ } -+ tmp = nv_linux_devices; -+ nv_linux_devices = nv_linux_devices->next; -+ NV_KFREE(tmp, sizeof(nv_linux_state_t)); -+ } -+ -+ nv_drm_exit(&nv_pci_driver); -+ -+failed3: -+ if (nv_smu->handle != NULL) -+ { -+ struct pci_dev *dev = nv_smu->handle; -+ rm_shutdown_smu(sp, nv_smu); -+ release_mem_region(NV_PCI_RESOURCE_START(dev, 0), -+ NV_PCI_RESOURCE_SIZE(dev, 0)); -+ pci_disable_device(dev); -+ pci_set_drvdata(dev, NULL); -+ memset(&nv_smu_device, 0, sizeof(nv_smu_state_t)); -+ } -+ -+ pci_unregister_driver(&nv_pci_driver); -+ -+failed5: -+ rm_shutdown_rm(sp); -+ -+ NV_KMEM_CACHE_FREE_STACK(sp); -+ NV_KMEM_CACHE_DESTROY(nv_stack_t_cache); -+ -+failed4: -+ nv_mem_pool_destroy(); -+ nv_heap_destroy(); -+ -+ return rc; -+} -+ -+void __exit nvidia_exit_module(void) -+{ -+ nv_smu_state_t *nv_smu = &nv_smu_device; -+ nv_stack_t *sp = __nv_init_sp; -+ struct pci_dev *dev; -+ -+ nv_printf(NV_DBG_INFO, "NVRM: nvidia_exit_module\n"); -+ -+ nv_drm_exit(&nv_pci_driver); -+ -+ if ((dev = (struct pci_dev *)(nv_smu->handle)) != NULL) -+ { -+ rm_shutdown_smu(sp, nv_smu); -+ release_mem_region(NV_PCI_RESOURCE_START(dev, 0), -+ NV_PCI_RESOURCE_SIZE(dev, 0)); -+ pci_disable_device(dev); -+ pci_set_drvdata(dev, NULL); -+ memset(&nv_smu_device, 0, sizeof(nv_smu_state_t)); -+ } -+ -+ while (nv_linux_devices != NULL) -+ { -+ nv_linux_state_t *next = nv_linux_devices->next; -+ -+ if ((dev = nv_linux_devices->dev) != NULL) -+ { -+#if defined(NV_PM_VT_SWITCH_REQUIRED_PRESENT) -+ pm_vt_switch_unregister(&dev->dev); -+#endif -+ nvidia_remove(dev); -+ } -+ nv_linux_devices = next; -+ } -+ -+ pci_unregister_driver(&nv_pci_driver); -+ -+ /* remove /proc/driver/nvidia/... */ -+ nv_unregister_procfs(); -+ -+ nv_unregister_chrdev((void *)&nv_fops); -+ -+#if defined(NV_LINUX_NVMAP_H_PRESENT) && defined(HAVE_NV_ANDROID) -+ nv_nvmap_destroy_client(); -+#endif -+ // Shutdown the resource manager -+ rm_shutdown_rm(sp); -+ -+#if defined(NVCPU_X86_64) && defined(CONFIG_IA32_EMULATION) && \ -+ !defined(NV_FILE_OPERATIONS_HAS_COMPAT_IOCTL) -+ rm_unregister_compatible_ioctls(sp); -+#endif -+ -+ nv_teardown_pat_support(); -+ -+#if defined(NV_ENABLE_MEM_TRACKING) -+#if defined(VM_CHECKER) -+ if (vm_usage != 0) -+ { -+ nv_list_mem("VM", vm_list); -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: final VM memory usage: 0x%x bytes\n", vm_usage); -+ } -+#endif -+#if defined(KM_CHECKER) -+ if (km_usage != 0) -+ { -+ nv_list_mem("KM", km_list); -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: final KM memory usage: 0x%x bytes\n", km_usage); -+ } -+#endif -+#if defined(NV_SG_MAP_BUFFERS) && defined(NV_NEED_REMAP_CHECK) -+ if (nv_remap_count != 0) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: final SG memory usage: 0x%x bytes\n", nv_remap_count); -+ } -+#endif -+#endif /* NV_ENABLE_MEM_TRACKING */ -+ -+ if (NV_BUILD_MODULE_INSTANCES == 0) -+ { -+ NV_KMEM_CACHE_DESTROY(nvidia_p2p_page_t_cache); -+ } -+ NV_KMEM_CACHE_DESTROY(nv_pte_t_cache); -+ -+ NV_KMEM_CACHE_FREE_STACK(sp); -+ NV_KMEM_CACHE_DESTROY(nv_stack_t_cache); -+ -+ nv_mem_pool_destroy(); -+ nv_heap_destroy(); -+} -+ -+ -+/* -+ * Module entry and exit functions for Linux single-module builds -+ * are present in nv-frontend.c. -+ */ -+ -+#if defined(NV_VMWARE) || (NV_BUILD_MODULE_INSTANCES != 0) -+module_init(nvidia_init_module); -+module_exit(nvidia_exit_module); -+#endif -+ -+void *nv_alloc_file_private(void) -+{ -+ nv_file_private_t *nvfp; -+ unsigned int i; -+ -+ NV_KMALLOC(nvfp, sizeof(nv_file_private_t)); -+ if (!nvfp) -+ return NULL; -+ -+ memset(nvfp, 0, sizeof(nv_file_private_t)); -+ -+ for (i = 0; i < NV_FOPS_STACK_INDEX_COUNT; ++i) -+ { -+ NV_INIT_MUTEX(&nvfp->fops_sp_lock[i]); -+ } -+ init_waitqueue_head(&nvfp->waitqueue); -+ NV_SPIN_LOCK_INIT(&nvfp->fp_lock); -+ -+ return nvfp; -+} -+ -+void nv_free_file_private(nv_file_private_t *nvfp) -+{ -+ nvidia_event_t *nvet; -+ -+ if (nvfp == NULL) -+ return; -+ -+ for (nvet = nvfp->event_head; nvet != NULL; nvet = nvfp->event_head) -+ { -+ nvfp->event_head = nvfp->event_head->next; -+ NV_KFREE(nvet, sizeof(nvidia_event_t)); -+ } -+ NV_KFREE(nvfp, sizeof(nv_file_private_t)); -+} -+ -+ -+/* -+** nvidia_open -+** -+** nv driver open entry point. Sessions are created here. -+*/ -+static int -+nvidia_open( -+ struct inode *inode, -+ struct file *file -+) -+{ -+ nv_state_t *nv = NULL; -+ nv_linux_state_t *nvl = NULL; -+ NvU32 minor_num; -+ int rc = 0; -+ nv_file_private_t *nvfp = NULL; -+ nv_stack_t *sp = NULL; -+#if defined(NV_LINUX_PCIE_MSI_SUPPORTED) -+ NvU32 msi_config = 0; -+#endif -+#if defined(NV_UVM_ENABLE) || defined(NV_UVM_NEXT_ENABLE) -+ NvU8 *uuid; -+#endif -+ unsigned int i; -+ unsigned int k; -+ -+ nv_printf(NV_DBG_INFO, "NVRM: nvidia_open...\n"); -+ -+ nvfp = nv_alloc_file_private(); -+ if (nvfp == NULL) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate file private!\n"); -+ return -ENOMEM; -+ } -+ -+ NV_KMEM_CACHE_ALLOC_STACK(sp); -+ if (sp == NULL) -+ { -+ nv_free_file_private(nvfp); -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate stack!\n"); -+ return -ENOMEM; -+ } -+ -+ for (i = 0; i < NV_FOPS_STACK_INDEX_COUNT; ++i) -+ { -+ NV_KMEM_CACHE_ALLOC_STACK(nvfp->fops_sp[i]); -+ if (nvfp->fops_sp[i] == NULL) -+ { -+ NV_KMEM_CACHE_FREE_STACK(sp); -+ for (k = 0; k < i; ++k) -+ { -+ NV_KMEM_CACHE_FREE_STACK(nvfp->fops_sp[k]); -+ } -+ nv_free_file_private(nvfp); -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate stack[%d]\n", i); -+ return -ENOMEM; -+ } -+ } -+ -+ /* what device are we talking about? */ -+ minor_num = NV_DEVICE_MINOR_NUMBER(inode); -+ -+ nvfp->minor_num = minor_num; -+ -+ NV_SET_FILE_PRIVATE(file, nvfp); -+ nvfp->sp = sp; -+ -+ /* for control device, just jump to its open routine */ -+ /* after setting up the private data */ -+ if (NV_IS_CONTROL_DEVICE(inode)) -+ { -+ rc = nvidia_ctl_open(inode, file); -+ if (rc != 0) -+ goto failed2; -+ return rc; -+ } -+ -+ LOCK_NV_LINUX_DEVICES(); -+ nvl = nv_linux_devices; -+ while (nvl != NULL) -+ { -+ if (nvl->minor_num == minor_num) -+ break; -+ nvl = nvl->next; -+ } -+ -+ if (nvl == NULL) -+ { -+ UNLOCK_NV_LINUX_DEVICES(); -+ rc = -ENODEV; -+ goto failed2; -+ } -+ -+ nv = NV_STATE_PTR(nvl); -+ -+ down(&nvl->ldata_lock); -+ -+ UNLOCK_NV_LINUX_DEVICES(); -+ -+ if (IS_VGX_HYPER()) -+ { -+ /* fail open if GPU is being unbound */ -+ if (nv->flags & NV_FLAG_UNBIND_LOCK) -+ { -+ rc = -ENODEV; -+ nv_printf(NV_DBG_ERRORS, "NVRM: nvidia_open on device %04x:%02x:%02x.0" -+ " failed as GPU is locked for unbind operation\n", -+ nv->pci_info.domain, nv->pci_info.bus, nv->pci_info.slot); -+ goto failed; -+ } -+ } -+ -+ nv_printf(NV_DBG_INFO, "NVRM: nvidia_open on device " -+ "bearing minor number %d\n", minor_num); -+ -+ NV_CHECK_PCI_CONFIG_SPACE(sp, nv, TRUE, TRUE, NV_MAY_SLEEP()); -+ -+ nvfp->nvptr = nvl; -+ -+ /* -+ * map the memory and allocate isr on first open -+ */ -+ -+ if ( ! (nv->flags & NV_FLAG_OPEN)) -+ { -+ if (nv->pci_info.device_id == 0) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: open of nonexistent " -+ "device bearing minor number %d\n", minor_num); -+ rc = -ENXIO; -+ goto failed; -+ } -+ -+ if (!(nv->flags & NV_FLAG_PERSISTENT_SW_STATE)) -+ { -+ NV_KMEM_CACHE_ALLOC_STACK(nvl->isr_sp); -+ if (nvl->isr_sp == NULL) -+ { -+ rc = -ENOMEM; -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate stack!\n"); -+ goto failed; -+ } -+ -+ NV_KMEM_CACHE_ALLOC_STACK(nvl->pci_cfgchk_sp); -+ if (nvl->pci_cfgchk_sp == NULL) -+ { -+ rc = -ENOMEM; -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate stack!\n"); -+ goto failed; -+ } -+ -+ NV_KMEM_CACHE_ALLOC_STACK(nvl->isr_bh_sp); -+ if (nvl->isr_bh_sp == NULL) -+ { -+ rc = -ENOMEM; -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate stack!\n"); -+ goto failed; -+ } -+ -+ NV_KMEM_CACHE_ALLOC_STACK(nvl->timer_sp); -+ if (nvl->timer_sp == NULL) -+ { -+ rc = -ENOMEM; -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate stack!\n"); -+ goto failed; -+ } -+ } -+ -+#if defined(NV_LINUX_PCIE_MSI_SUPPORTED) -+ if (!NV_IS_GVI_DEVICE(nv)) -+ { -+ if (!(nv->flags & NV_FLAG_PERSISTENT_SW_STATE)) -+ { -+ rm_read_registry_dword(sp, nv, "NVreg", NV_REG_ENABLE_MSI, -+ &msi_config); -+ if ((msi_config == 1) && -+ (nv_find_pci_capability(nvl->dev, PCI_CAP_ID_MSI))) -+ { -+ rc = pci_enable_msi(nvl->dev); -+ if (rc == 0) -+ { -+ nv->interrupt_line = nvl->dev->irq; -+ nv->flags |= NV_FLAG_USES_MSI; -+ } -+ else -+ { -+ nv->flags &= ~NV_FLAG_USES_MSI; -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: failed to enable MSI, \n" -+ "using PCIe virtual-wire interrupts.\n"); -+ } -+ } -+ } -+ } -+#endif -+ -+ if (NV_IS_GVI_DEVICE(nv)) -+ { -+ rc = request_irq(nv->interrupt_line, nv_gvi_kern_isr, -+ IRQF_SHARED, NV_DEV_NAME, (void *)nvl); -+ if (rc == 0) -+ { -+ nvl->work.data = (void *)nvl; -+ NV_TASKQUEUE_INIT(&nvl->work.task, nv_gvi_kern_bh, -+ (void *)&nvl->work); -+ rm_init_gvi_device(sp, nv); -+ goto done; -+ } -+ } -+ else -+ { -+ rc = 0; -+ if (!(nv->flags & NV_FLAG_PERSISTENT_SW_STATE)) -+ { -+ rc = request_irq(nv->interrupt_line, nvidia_isr, IRQF_SHARED, -+ NV_DEV_NAME, (void *)nvl); -+ } -+ } -+ if (rc != 0) -+ { -+ if ((nv->interrupt_line != 0) && (rc == -EBUSY)) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: Tried to get IRQ %d, but another driver\n", -+ (unsigned int) nv->interrupt_line); -+ nv_printf(NV_DBG_ERRORS, "NVRM: has it and is not sharing it.\n"); -+ nv_printf(NV_DBG_ERRORS, "NVRM: You may want to verify that no audio driver"); -+ nv_printf(NV_DBG_ERRORS, " is using the IRQ.\n"); -+ } -+ nv_printf(NV_DBG_ERRORS, "NVRM: request_irq() failed (%d)\n", rc); -+ goto failed; -+ } -+ -+ if (!(nv->flags & NV_FLAG_PERSISTENT_SW_STATE)) -+ { -+ tasklet_init(&nvl->tasklet, nvidia_isr_bh, (NvUPtr)NV_STATE_PTR(nvl)); -+ } -+ -+ if (!rm_init_adapter(sp, nv)) -+ { -+ if (!(nv->flags & NV_FLAG_PERSISTENT_SW_STATE)) -+ { -+ tasklet_kill(&nvl->tasklet); -+ } -+ free_irq(nv->interrupt_line, (void *) nvl); -+ nv_printf(NV_DBG_ERRORS, "NVRM: rm_init_adapter failed " -+ "for device bearing minor number %d\n", minor_num); -+ rc = -EIO; -+ goto failed; -+ } -+ -+#if defined(NV_UVM_ENABLE) || defined(NV_UVM_NEXT_ENABLE) -+ if (!NV_IS_GVI_DEVICE(nv)) -+ { -+ if (rm_get_gpu_uuid_raw(sp, nv, &uuid, NULL) == RM_OK) -+ { -+ nv_uvm_notify_start_device(uuid); -+ os_free_mem(uuid); -+ } -+ } -+#endif -+#if !defined(NV_VMWARE) && \ -+ (defined(NVCPU_X86) || defined(NVCPU_X86_64)) -+ if (nv->primary_vga && (screen_info.orig_video_isVGA != 0x01)) -+ { -+ if (!nv_fbdev_failure_detected) -+ { -+ nv_prints(NV_DBG_ERRORS, __fbdev_warning); -+ nv_procfs_add_warning("fbdev", __fbdev_warning); -+ } -+ nv_fbdev_failure_detected = 1; -+ } -+#endif -+ -+done: -+ nv->flags |= NV_FLAG_OPEN; -+ } -+ -+ NV_ATOMIC_INC(nvl->usage_count); -+ -+failed: -+ if (rc != 0) -+ { -+#if defined(NV_LINUX_PCIE_MSI_SUPPORTED) -+ if (nv->flags & NV_FLAG_USES_MSI) -+ { -+ nv->flags &= ~NV_FLAG_USES_MSI; -+ NV_PCI_DISABLE_MSI(nvl->dev); -+ } -+#endif -+ if (nvl->timer_sp != NULL) -+ NV_KMEM_CACHE_FREE_STACK(nvl->timer_sp); -+ if (nvl->isr_bh_sp != NULL) -+ NV_KMEM_CACHE_FREE_STACK(nvl->isr_bh_sp); -+ if (nvl->pci_cfgchk_sp != NULL) -+ NV_KMEM_CACHE_FREE_STACK(nvl->pci_cfgchk_sp); -+ if (nvl->isr_sp != NULL) -+ NV_KMEM_CACHE_FREE_STACK(nvl->isr_sp); -+ } -+ up(&nvl->ldata_lock); -+failed2: -+ if (rc != 0) -+ { -+ if (nvfp != NULL) -+ { -+ NV_KMEM_CACHE_FREE_STACK(sp); -+ for (i = 0; i < NV_FOPS_STACK_INDEX_COUNT; ++i) -+ { -+ NV_KMEM_CACHE_FREE_STACK(nvfp->fops_sp[i]); -+ } -+ nv_free_file_private(nvfp); -+ NV_SET_FILE_PRIVATE(file, NULL); -+ } -+ } -+ -+ return rc; -+} -+ -+/* -+** nvidia_close -+** -+** Master driver close entry point. -+*/ -+ -+static int -+nvidia_close( -+ struct inode *inode, -+ struct file *file -+) -+{ -+ nv_linux_state_t *nvl = NV_GET_NVL_FROM_FILEP(file); -+ nv_state_t *nv = NV_STATE_PTR(nvl); -+ nv_file_private_t *nvfp = NV_GET_FILE_PRIVATE(file); -+ nv_stack_t *sp = nvfp->sp; -+ unsigned int i; -+ -+ NV_CHECK_PCI_CONFIG_SPACE(sp, nv, TRUE, TRUE, NV_MAY_SLEEP()); -+ -+ /* for control device, just jump to its open routine */ -+ /* after setting up the private data */ -+ if (NV_IS_CONTROL_DEVICE(inode)) -+ return nvidia_ctl_close(inode, file); -+ -+ nv_printf(NV_DBG_INFO, "NVRM: nvidia_close on device " -+ "bearing minor number %d\n", NV_DEVICE_MINOR_NUMBER(inode)); -+ -+ rm_free_unused_clients(sp, nv, nvfp); -+ -+ down(&nvl->ldata_lock); -+ if (NV_ATOMIC_DEC_AND_TEST(nvl->usage_count)) -+ { -+ if (NV_IS_GVI_DEVICE(nv)) -+ { -+ rm_shutdown_gvi_device(sp, nv); -+ NV_TASKQUEUE_FLUSH(); -+ free_irq(nv->interrupt_line, (void *)nvl); -+ } -+ else -+ { -+#if defined(NV_UVM_ENABLE) || defined(NV_UVM_NEXT_ENABLE) -+ { -+ NvU8 *uuid; -+ // Inform UVM before disabling adapter -+ if(rm_get_gpu_uuid_raw(sp, nv, &uuid, NULL) == RM_OK) -+ { -+ // this function cannot fail -+ nv_uvm_notify_stop_device(uuid); -+ // get_uuid allocates memory for this call free it here -+ os_free_mem(uuid); -+ } -+ } -+#endif -+ if (nv->flags & NV_FLAG_PERSISTENT_SW_STATE) -+ { -+ rm_disable_adapter(sp, nv); -+ } -+ else -+ { -+ NV_SHUTDOWN_ADAPTER(sp, nv, nvl); -+ } -+ } -+ -+ if (!(nv->flags & NV_FLAG_PERSISTENT_SW_STATE)) -+ { -+ NV_KMEM_CACHE_FREE_STACK(nvl->timer_sp); -+ NV_KMEM_CACHE_FREE_STACK(nvl->isr_bh_sp); -+ NV_KMEM_CACHE_FREE_STACK(nvl->pci_cfgchk_sp); -+ NV_KMEM_CACHE_FREE_STACK(nvl->isr_sp); -+ } -+ -+ /* leave INIT flag alone so we don't reinit every time */ -+ nv->flags &= ~NV_FLAG_OPEN; -+ } -+ up(&nvl->ldata_lock); -+ -+ for (i = 0; i < NV_FOPS_STACK_INDEX_COUNT; ++i) -+ { -+ NV_KMEM_CACHE_FREE_STACK(nvfp->fops_sp[i]); -+ } -+ -+ nv_free_file_private(nvfp); -+ NV_SET_FILE_PRIVATE(file, NULL); -+ -+ NV_KMEM_CACHE_FREE_STACK(sp); -+ -+ return 0; -+} -+ -+static unsigned int -+nvidia_poll( -+ struct file *file, -+ poll_table *wait -+) -+{ -+ unsigned int mask = 0; -+ nv_file_private_t *nvfp = NV_GET_FILE_PRIVATE(file); -+ unsigned long eflags; -+ -+ if ((file->f_flags & O_NONBLOCK) == 0) -+ poll_wait(file, &nvfp->waitqueue, wait); -+ -+ NV_SPIN_LOCK_IRQSAVE(&nvfp->fp_lock, eflags); -+ -+ if ((nvfp->event_head != NULL) || nvfp->event_pending) -+ { -+ mask = (POLLPRI | POLLIN); -+ nvfp->event_pending = FALSE; -+ } -+ -+ NV_SPIN_UNLOCK_IRQRESTORE(&nvfp->fp_lock, eflags); -+ -+ return mask; -+} -+ -+#define NV_CTL_DEVICE_ONLY(nv) \ -+{ \ -+ if (((nv)->flags & NV_FLAG_CONTROL) == 0) \ -+ { \ -+ status = -EINVAL; \ -+ goto done; \ -+ } \ -+} -+ -+static int -+nvidia_ioctl( -+ struct inode *inode, -+ struct file *file, -+ unsigned int cmd, -+ unsigned long i_arg) -+{ -+ RM_STATUS rmStatus; -+ int status = 0; -+ nv_linux_state_t *nvl = NV_GET_NVL_FROM_FILEP(file); -+ nv_state_t *nv = NV_STATE_PTR(nvl); -+ nv_file_private_t *nvfp = NV_GET_FILE_PRIVATE(file); -+ nv_stack_t *sp = NULL; -+ nv_ioctl_xfer_t ioc_xfer; -+ void *arg_ptr = (void *) i_arg; -+ void *arg_copy = NULL; -+ size_t arg_size; -+ int arg_cmd; -+ -+ nv_printf(NV_DBG_INFO, "NVRM: ioctl(0x%x, 0x%x, 0x%x)\n", -+ _IOC_NR(cmd), (unsigned int) i_arg, _IOC_SIZE(cmd)); -+ -+ down(&nvfp->fops_sp_lock[NV_FOPS_STACK_INDEX_IOCTL]); -+ sp = nvfp->fops_sp[NV_FOPS_STACK_INDEX_IOCTL]; -+ -+ NV_CHECK_PCI_CONFIG_SPACE(sp, nv, TRUE, TRUE, NV_MAY_SLEEP()); -+ -+ arg_size = _IOC_SIZE(cmd); -+ arg_cmd = _IOC_NR(cmd); -+ -+ if (arg_cmd == NV_ESC_IOCTL_XFER_CMD) -+ { -+ if (arg_size != sizeof(nv_ioctl_xfer_t)) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: invalid ioctl XFER structure size!\n"); -+ status = -EINVAL; -+ goto done; -+ } -+ -+ if (NV_COPY_FROM_USER(&ioc_xfer, arg_ptr, sizeof(ioc_xfer))) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: failed to copy in ioctl XFER data!\n"); -+ status = -EFAULT; -+ goto done; -+ } -+ -+ arg_cmd = ioc_xfer.cmd; -+ arg_size = ioc_xfer.size; -+ arg_ptr = NvP64_VALUE(ioc_xfer.ptr); -+ -+ if (arg_size > NV_ABSOLUTE_MAX_IOCTL_SIZE) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: invalid ioctl XFER size!\n"); -+ status = -EINVAL; -+ goto done; -+ } -+ } -+ -+ NV_KMALLOC(arg_copy, arg_size); -+ if (arg_copy == NULL) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate ioctl memory\n"); -+ status = -ENOMEM; -+ goto done; -+ } -+ -+ if (NV_COPY_FROM_USER(arg_copy, arg_ptr, arg_size)) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to copy in ioctl data!\n"); -+ status = -EFAULT; -+ goto done; -+ } -+ -+ switch (arg_cmd) -+ { -+ /* pass out info about the card */ -+ case NV_ESC_CARD_INFO: -+ { -+ nv_ioctl_card_info_t *ci; -+ nv_linux_state_t *tnvl; -+ nv_ioctl_rm_api_old_version_t *rm_api; -+ -+ NV_CTL_DEVICE_ONLY(nv); -+ -+ if (arg_size < (sizeof(*ci) * num_nv_devices)) -+ { -+ status = -EINVAL; -+ goto done; -+ } -+ -+ /* the first element of card info passed from the client will have -+ * the rm_api_version_magic value to show that the client is new -+ * enough to support versioning. If the client is too old to -+ * support versioning, our mmap interfaces are probably different -+ * enough to cause serious damage. -+ * just copy in the one dword to check. -+ */ -+ rm_api = arg_copy; -+ switch (rm_api->magic) -+ { -+ case NV_RM_API_OLD_VERSION_MAGIC_REQ: -+ case NV_RM_API_OLD_VERSION_MAGIC_LAX_REQ: -+ case NV_RM_API_OLD_VERSION_MAGIC_OVERRIDE_REQ: -+ /* the client is using the old major-minor-patch -+ * API version check; reject it. -+ */ -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: API mismatch: the client has the version %d.%d-%d, but\n" -+ "NVRM: this kernel module has the version %s. Please\n" -+ "NVRM: make sure that this kernel module and all NVIDIA driver\n" -+ "NVRM: components have the same version.\n", -+ rm_api->major, rm_api->minor, rm_api->patch, -+ NV_VERSION_STRING); -+ status = -EINVAL; -+ goto done; -+ -+ case NV_RM_API_OLD_VERSION_MAGIC_IGNORE: -+ /* the client is telling us to ignore the old -+ * version scheme; it will do a version check via -+ * NV_ESC_CHECK_VERSION_STR -+ */ -+ break; -+ default: -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: client does not support versioning!!\n"); -+ status = -EINVAL; -+ goto done; -+ } -+ -+ ci = arg_copy; -+ memset(ci, 0, arg_size); -+ LOCK_NV_LINUX_DEVICES(); -+ for (tnvl = nv_linux_devices; tnvl != NULL; tnvl = tnvl->next) -+ { -+ nv_state_t *tnv; -+ tnv = NV_STATE_PTR(tnvl); -+ if (tnv->pci_info.device_id) -+ { -+ ci->flags = NV_IOCTL_CARD_INFO_FLAG_PRESENT; -+ ci->pci_info.domain = tnv->pci_info.domain; -+ ci->pci_info.bus = tnv->pci_info.bus; -+ ci->pci_info.slot = tnv->pci_info.slot; -+ ci->pci_info.vendor_id = tnv->pci_info.vendor_id; -+ ci->pci_info.device_id = tnv->pci_info.device_id; -+ ci->gpu_id = tnv->gpu_id; -+ ci->interrupt_line = tnv->interrupt_line; -+ ci->reg_address = tnv->regs->address; -+ ci->reg_size = tnv->regs->size; -+ ci->fb_address = tnv->fb->address; -+ ci->fb_size = tnv->fb->size; -+ ci->minor_number = tnvl->minor_num; -+ ci++; -+ } -+ } -+ UNLOCK_NV_LINUX_DEVICES(); -+ break; -+ } -+ -+ case NV_ESC_CHECK_VERSION_STR: -+ { -+ NV_CTL_DEVICE_ONLY(nv); -+ -+ rmStatus = rm_perform_version_check(sp, arg_copy, arg_size); -+ status = ((rmStatus == RM_OK) ? 0 : -EINVAL); -+ break; -+ } -+ -+ default: -+ rmStatus = rm_ioctl(sp, nv, nvfp, arg_cmd, arg_copy, arg_size); -+ status = ((rmStatus == RM_OK) ? 0 : -EINVAL); -+ break; -+ } -+ -+done: -+ up(&nvfp->fops_sp_lock[NV_FOPS_STACK_INDEX_IOCTL]); -+ -+ if (arg_copy != NULL) -+ { -+ if (status != -EFAULT) -+ { -+ if (NV_COPY_TO_USER(arg_ptr, arg_copy, arg_size)) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to copy out ioctl data\n"); -+ status = -EFAULT; -+ } -+ } -+ NV_KFREE(arg_copy, arg_size); -+ } -+ -+ return status; -+} -+ -+static long -+nvidia_unlocked_ioctl( -+ struct file *file, -+ unsigned int cmd, -+ unsigned long i_arg -+) -+{ -+ return nvidia_ioctl(file->f_dentry->d_inode, file, cmd, i_arg); -+} -+ -+/* -+ * driver receives an interrupt -+ * if someone waiting, then hand it off. -+ */ -+static irqreturn_t -+nvidia_isr( -+ int irq, -+ void *arg -+#if !defined(NV_IRQ_HANDLER_T_PRESENT) || (NV_IRQ_HANDLER_T_ARGUMENT_COUNT == 3) -+ ,struct pt_regs *regs -+#endif -+) -+{ -+ nv_linux_state_t *nvl = (void *) arg; -+ nv_state_t *nv = NV_STATE_PTR(nvl); -+ NvU32 need_to_run_bottom_half = 0; -+ BOOL rm_handled = FALSE, uvm_handled = FALSE; -+ -+#if defined (NV_UVM_NEXT_ENABLE) -+ // -+ // Returns RM_OK if the UVM driver handled the interrupt -+ // Returns RM_ERR_NO_INTR_PENDING if the interrupt is not for the UVM driver -+ // -+ if (nv_uvm_event_interrupt() == RM_OK) -+ uvm_handled = TRUE; -+#endif -+ -+ rm_handled = rm_isr(nvl->isr_sp, nv, &need_to_run_bottom_half); -+ if (need_to_run_bottom_half) -+ { -+ tasklet_schedule(&nvl->tasklet); -+ } -+ -+ return IRQ_RETVAL(rm_handled || uvm_handled); -+} -+ -+static void -+nvidia_isr_bh( -+ unsigned long data -+) -+{ -+ nv_state_t *nv = (nv_state_t *) data; -+ nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv); -+ -+ NV_CHECK_PCI_CONFIG_SPACE(nvl->isr_bh_sp, nv, TRUE, FALSE, FALSE); -+ rm_isr_bh(nvl->isr_bh_sp, nv); -+} -+ -+static void -+nvidia_rc_timer( -+ unsigned long data -+) -+{ -+ nv_linux_state_t *nvl = (nv_linux_state_t *) data; -+ nv_state_t *nv = NV_STATE_PTR(nvl); -+ -+ NV_CHECK_PCI_CONFIG_SPACE(nvl->timer_sp, nv, TRUE, TRUE, FALSE); -+ -+ if (rm_run_rc_callback(nvl->timer_sp, nv) == RM_OK) -+ mod_timer(&nvl->rc_timer, jiffies + HZ); /* set another timeout in 1 second */ -+} -+ -+/* -+** nvidia_ctl_open -+** -+** nv control driver open entry point. Sessions are created here. -+*/ -+static int -+nvidia_ctl_open( -+ struct inode *inode, -+ struct file *file -+) -+{ -+ nv_linux_state_t *nvl = &nv_ctl_device; -+ nv_state_t *nv = NV_STATE_PTR(nvl); -+ nv_file_private_t *nvfp = NV_GET_FILE_PRIVATE(file); -+ static int count = 0; -+ -+ nv_printf(NV_DBG_INFO, "NVRM: nvidia_ctl_open\n"); -+ -+ down(&nvl->ldata_lock); -+ -+ /* save the nv away in file->private_data */ -+ nvfp->nvptr = nvl; -+ -+ if (NV_ATOMIC_READ(nvl->usage_count) == 0) -+ { -+ init_waitqueue_head(&nv_ctl_waitqueue); -+ -+ nv->flags |= (NV_FLAG_OPEN | NV_FLAG_CONTROL); -+ -+ if ((nv_acpi_init() < 0) && -+ (count++ < NV_MAX_RECURRING_WARNING_MESSAGES)) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: failed to register with the ACPI subsystem!\n"); -+ } -+ } -+ -+ NV_ATOMIC_INC(nvl->usage_count); -+ up(&nvl->ldata_lock); -+ -+ return 0; -+} -+ -+ -+/* -+** nvidia_ctl_close -+*/ -+static int -+nvidia_ctl_close( -+ struct inode *inode, -+ struct file *file -+) -+{ -+ nv_alloc_t *at, *next; -+ nv_linux_state_t *nvl = NV_GET_NVL_FROM_FILEP(file); -+ nv_state_t *nv = NV_STATE_PTR(nvl); -+ nv_file_private_t *nvfp = NV_GET_FILE_PRIVATE(file); -+ nv_stack_t *sp = nvfp->sp; -+ static int count = 0; -+ unsigned int i; -+ -+ nv_printf(NV_DBG_INFO, "NVRM: nvidia_ctl_close\n"); -+ -+ down(&nvl->ldata_lock); -+ if (NV_ATOMIC_DEC_AND_TEST(nvl->usage_count)) -+ { -+ nv->flags &= ~NV_FLAG_OPEN; -+ -+ if ((nv_acpi_uninit() < 0) && -+ (count++ < NV_MAX_RECURRING_WARNING_MESSAGES)) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: failed to unregister from the ACPI subsystem!\n"); -+ } -+ } -+ up(&nvl->ldata_lock); -+ -+ rm_free_unused_clients(sp, nv, nvfp); -+ -+ if (nvfp->free_list != NULL) -+ { -+ at = nvfp->free_list; -+ while (at != NULL) -+ { -+ next = at->next; -+ if (at->pid == os_get_current_process()) -+ NV_PRINT_AT(NV_DBG_MEMINFO, at); -+ nv_free_pages(nv, at->num_pages, -+ NV_ALLOC_MAPPING_CONTIG(at->flags), -+ NV_ALLOC_MAPPING(at->flags), -+ (void *)at); -+ at = next; -+ } -+ } -+ -+ for (i = 0; i < NV_FOPS_STACK_INDEX_COUNT; ++i) -+ { -+ NV_KMEM_CACHE_FREE_STACK(nvfp->fops_sp[i]); -+ } -+ -+ nv_free_file_private(nvfp); -+ NV_SET_FILE_PRIVATE(file, NULL); -+ -+ NV_KMEM_CACHE_FREE_STACK(sp); -+ -+ return 0; -+} -+ -+ -+void NV_API_CALL nv_set_dma_address_size( -+ nv_state_t *nv, -+ NvU32 phys_addr_bits -+) -+{ -+ nv_linux_state_t *nvl; -+ -+ nvl = NV_GET_NVL_FROM_NV_STATE(nv); -+ nvl->dev->dma_mask = (((u64)1) << phys_addr_bits) - 1; -+} -+ -+#if defined(NV_VMAP_PRESENT) -+static unsigned long -+nv_map_guest_pages(nv_alloc_t *at, -+ NvU64 address, -+ NvU32 page_count, -+ NvU32 page_idx) -+{ -+ struct page **pages; -+ NvU32 j; -+ unsigned long virt_addr; -+ -+ NV_KMALLOC(pages, sizeof(struct page *) * page_count); -+ if (pages == NULL) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: failed to allocate vmap() page descriptor table!\n"); -+ return 0; -+ } -+ -+ for (j = 0; j < page_count; j++) -+ { -+ pages[j] = NV_GET_PAGE_STRUCT(at->page_table[page_idx+j]->phys_addr); -+ } -+ -+ NV_VMAP(virt_addr, pages, page_count, NV_ALLOC_MAPPING_CACHED(at->flags)); -+ NV_KFREE(pages, sizeof(struct page *) * page_count); -+ -+ return virt_addr; -+} -+#endif -+ -+RM_STATUS NV_API_CALL -+nv_alias_pages( -+ nv_state_t *nv, -+ NvU32 page_cnt, -+ NvU32 contiguous, -+ NvU32 cache_type, -+ NvU64 guest_id, -+ NvU64 *pte_array, -+ void **priv_data -+) -+{ -+ nv_alloc_t *at; -+ nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv); -+ NvU32 i=0; -+ nv_pte_t *page_ptr = NULL; -+ -+ page_cnt = RM_PAGES_TO_OS_PAGES(page_cnt); -+ at = nvos_create_alloc(nvl->dev, page_cnt); -+ -+ if (at == NULL) -+ { -+ return RM_ERR_NO_FREE_MEM; -+ } -+ -+ at->flags = nv_alloc_init_flags(cache_type, contiguous, 0); -+ at->flags |= NV_ALLOC_TYPE_GUEST; -+ -+ at->order = nv_calc_order(at->num_pages * PAGE_SIZE); -+ -+ for (i=0; i < at->num_pages; ++i) -+ { -+ page_ptr = at->page_table[i]; -+ -+ if (contiguous && i>0) -+ { -+ page_ptr->dma_addr = pte_array[0] + (i << PAGE_SHIFT); -+ } -+ else -+ { -+ page_ptr->dma_addr = pte_array[i]; -+ } -+ -+ page_ptr->phys_addr = page_ptr->dma_addr; -+ -+ /* aliased pages will be mapped on demand. */ -+ page_ptr->virt_addr = 0x0; -+ } -+ -+ at->guest_id = guest_id; -+ *priv_data = at; -+ NV_ATOMIC_INC(at->usage_count); -+ -+ NV_PRINT_AT(NV_DBG_MEMINFO, at); -+ -+ return RM_OK; -+} -+ -+void* NV_API_CALL nv_alloc_kernel_mapping( -+ nv_state_t *nv, -+ void *pAllocPrivate, -+ NvU64 pageIndex, -+ NvU32 pageOffset, -+ NvU64 size, -+ void **pPrivate -+) -+{ -+ nv_alloc_t *at = pAllocPrivate; -+#if defined(NV_VMAP_PRESENT) -+ NvU32 j, page_count; -+ unsigned long virt_addr; -+ struct page **pages; -+#endif -+ -+ if (((size + pageOffset) <= PAGE_SIZE) && -+ !NV_ALLOC_MAPPING_GUEST(at->flags) && !NV_ALLOC_MAPPING_ALIASED(at->flags)) -+ { -+ *pPrivate = NULL; -+ return (void *)(at->page_table[pageIndex]->virt_addr + pageOffset); -+ } -+ else -+ { -+#if defined(NV_VMAP_PRESENT) -+ size += pageOffset; -+ page_count = (size >> PAGE_SHIFT) + ((size & ~NV_PAGE_MASK) ? 1 : 0); -+ -+ if (NV_ALLOC_MAPPING_GUEST(at->flags)) -+ { -+ virt_addr = nv_map_guest_pages(at, -+ nv->bars[NV_GPU_BAR_INDEX_REGS].address, -+ page_count, pageIndex); -+ } -+ else -+ { -+ NV_KMALLOC(pages, sizeof(struct page *) * page_count); -+ if (pages == NULL) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: failed to allocate vmap() page descriptor table!\n"); -+ return NULL; -+ } -+ -+ for (j = 0; j < page_count; j++) -+ pages[j] = NV_GET_PAGE_STRUCT(at->page_table[pageIndex+j]->phys_addr); -+ -+ NV_VMAP(virt_addr, pages, page_count, NV_ALLOC_MAPPING_CACHED(at->flags)); -+ NV_KFREE(pages, sizeof(struct page *) * page_count); -+ } -+ -+ if (virt_addr == 0) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to map pages!\n"); -+ return NULL; -+ } -+ -+ *pPrivate = (void *)(NvUPtr)page_count; -+ return (void *)(virt_addr + pageOffset); -+#else -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: This version of the Linux kernel does not provide the vmap()\n" -+ "NVRM: kernel interface. If you see this message, please update\n" -+ "NVRM: your kernel to Linux 2.4.22 or install a distribution kernel\n" -+ "NVRM: that supports the vmap() kernel interface.\n"); -+#endif -+ } -+ -+ return NULL; -+} -+ -+RM_STATUS NV_API_CALL nv_free_kernel_mapping( -+ nv_state_t *nv, -+ void *pAllocPrivate, -+ void *address, -+ void *pPrivate -+) -+{ -+#if defined(NV_VMAP_PRESENT) -+ nv_alloc_t *at = pAllocPrivate; -+ unsigned long virt_addr; -+ NvU32 page_count; -+ -+ virt_addr = ((NvUPtr)address & NV_PAGE_MASK); -+ page_count = (NvUPtr)pPrivate; -+ -+ if (NV_ALLOC_MAPPING_GUEST(at->flags)) -+ { -+ NV_IOUNMAP((void *)virt_addr, (page_count * PAGE_SIZE)); -+ } -+ else if (pPrivate != NULL) -+ { -+ NV_VUNMAP(virt_addr, page_count); -+ } -+#endif -+ return RM_OK; -+} -+ -+RM_STATUS NV_API_CALL nv_alloc_pages( -+ nv_state_t *nv, -+ NvU32 page_count, -+ NvBool contiguous, -+ NvU32 cache_type, -+ NvBool zeroed, -+ NvU64 *pte_array, -+ void **priv_data -+) -+{ -+ nv_alloc_t *at; -+ RM_STATUS status = RM_ERR_NO_FREE_MEM; -+ nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv); -+ NvU32 i, memory_type; -+ -+ nv_printf(NV_DBG_MEMINFO, "NVRM: VM: nv_alloc_pages: %d pages\n", page_count); -+ nv_printf(NV_DBG_MEMINFO, "NVRM: VM: contig %d cache_type %d\n", -+ contiguous, cache_type); -+ -+ memory_type = NV_MEMORY_TYPE_SYSTEM; -+ -+#if !defined(NV_VMWARE) -+ if (nv_encode_caching(NULL, cache_type, memory_type)) -+ return RM_ERR_NOT_SUPPORTED; -+#endif -+ -+ page_count = RM_PAGES_TO_OS_PAGES(page_count); -+ at = nvos_create_alloc(nvl->dev, page_count); -+ if (at == NULL) -+ return RM_ERR_NO_FREE_MEM; -+ -+ at->flags = nv_alloc_init_flags(cache_type, contiguous, zeroed); -+ -+ if (NV_ALLOC_MAPPING_CONTIG(at->flags)) -+ status = nv_alloc_contig_pages(nv, at); -+ else -+ status = nv_alloc_system_pages(nv, at); -+ -+ if (status != RM_OK) -+ goto failed; -+ -+ for (i = 0; i < ((contiguous) ? 1 : page_count); i++) -+ pte_array[i] = at->page_table[i]->dma_addr; -+ -+ *priv_data = at; -+ NV_ATOMIC_INC(at->usage_count); -+ -+ NV_PRINT_AT(NV_DBG_MEMINFO, at); -+ -+ return RM_OK; -+ -+failed: -+ nvos_free_alloc(at); -+ -+ return status; -+} -+ -+RM_STATUS NV_API_CALL nv_free_pages( -+ nv_state_t *nv, -+ NvU32 page_count, -+ NvBool contiguous, -+ NvU32 cache_type, -+ void *priv_data -+) -+{ -+ RM_STATUS rmStatus = RM_OK; -+ nv_alloc_t *at = priv_data; -+ -+ page_count = RM_PAGES_TO_OS_PAGES(page_count); -+ nv_printf(NV_DBG_MEMINFO, "NVRM: VM: nv_free_pages: 0x%x\n", page_count); -+ -+ NV_PRINT_AT(NV_DBG_MEMINFO, at); -+ -+ /* -+ * If the 'at' usage count doesn't drop to zero here, not all of -+ * the user mappings have been torn down in time - we can't -+ * safely free the memory. We report success back to the RM, but -+ * defer the actual free operation until later. -+ * -+ * This is described in greater detail in the comments above the -+ * nvidia_vma_(open|release)() callbacks in nv-mmap.c. -+ */ -+ if (!NV_ATOMIC_DEC_AND_TEST(at->usage_count)) -+ return RM_OK; -+ -+ if (!NV_ALLOC_MAPPING_GUEST(at->flags)) -+ { -+ if (NV_ALLOC_MAPPING_CONTIG(at->flags)) -+ nv_free_contig_pages(nv, at); -+ else -+ nv_free_system_pages(nv, at); -+ } -+ -+ nvos_free_alloc(at); -+ -+ return rmStatus; -+} -+ -+static void nv_lock_init_locks -+( -+ nv_state_t *nv -+) -+{ -+ nv_linux_state_t *nvl; -+ nvl = NV_GET_NVL_FROM_NV_STATE(nv); -+ -+ NV_INIT_MUTEX(&nvl->ldata_lock); -+ -+ NV_ATOMIC_SET(nvl->usage_count, 0); -+} -+ -+void NV_API_CALL nv_post_event( -+ nv_state_t *nv, -+ nv_event_t *event, -+ NvU32 handle, -+ NvU32 index, -+ NvBool data_valid -+) -+{ -+ nv_file_private_t *nvfp = event->file; -+ unsigned long eflags; -+ nvidia_event_t *nvet; -+ -+ NV_SPIN_LOCK_IRQSAVE(&nvfp->fp_lock, eflags); -+ -+ if (data_valid) -+ { -+ NV_KMALLOC_ATOMIC(nvet, sizeof(nvidia_event_t)); -+ if (nvet == NULL) -+ { -+ NV_SPIN_UNLOCK_IRQRESTORE(&nvfp->fp_lock, eflags); -+ return; -+ } -+ -+ if (nvfp->event_tail != NULL) -+ nvfp->event_tail->next = nvet; -+ if (nvfp->event_head == NULL) -+ nvfp->event_head = nvet; -+ nvfp->event_tail = nvet; -+ nvet->next = NULL; -+ -+ nvet->event = *event; -+ nvet->event.hObject = handle; -+ nvet->event.index = index; -+ } -+ -+ nvfp->event_pending = TRUE; -+ wake_up_interruptible(&nvfp->waitqueue); -+ -+ NV_SPIN_UNLOCK_IRQRESTORE(&nvfp->fp_lock, eflags); -+} -+ -+int NV_API_CALL nv_get_event( -+ nv_state_t *nv, -+ void *file, -+ nv_event_t *event, -+ NvU32 *pending -+) -+{ -+ nv_file_private_t *nvfp = file; -+ nvidia_event_t *nvet; -+ unsigned long eflags; -+ -+ NV_SPIN_LOCK_IRQSAVE(&nvfp->fp_lock, eflags); -+ -+ nvet = nvfp->event_head; -+ if (nvet == NULL) -+ { -+ NV_SPIN_UNLOCK_IRQRESTORE(&nvfp->fp_lock, eflags); -+ return RM_ERROR; -+ } -+ -+ *event = nvet->event; -+ -+ if (nvfp->event_tail == nvet) -+ nvfp->event_tail = NULL; -+ nvfp->event_head = nvet->next; -+ -+ *pending = (nvfp->event_head != NULL); -+ -+ NV_SPIN_UNLOCK_IRQRESTORE(&nvfp->fp_lock, eflags); -+ -+ NV_KFREE(nvet, sizeof(nvidia_event_t)); -+ -+ return RM_OK; -+} -+ -+int NV_API_CALL nv_start_rc_timer( -+ nv_state_t *nv -+) -+{ -+ nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv); -+ -+ if (nv->rc_timer_enabled) -+ return -1; -+ -+ nv_printf(NV_DBG_INFO, "NVRM: initializing rc timer\n"); -+ init_timer(&nvl->rc_timer); -+ nvl->rc_timer.function = nvidia_rc_timer; -+ nvl->rc_timer.data = (unsigned long) nvl; -+ nv->rc_timer_enabled = 1; -+ mod_timer(&nvl->rc_timer, jiffies + HZ); /* set our timeout for 1 second */ -+ nv_printf(NV_DBG_INFO, "NVRM: rc timer initialized\n"); -+ -+ return 0; -+} -+ -+int NV_API_CALL nv_stop_rc_timer( -+ nv_state_t *nv -+) -+{ -+ nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv); -+ -+ if (!nv->rc_timer_enabled) -+ return -1; -+ -+ nv_printf(NV_DBG_INFO, "NVRM: stopping rc timer\n"); -+ nv->rc_timer_enabled = 0; -+ del_timer_sync(&nvl->rc_timer); -+ nv_printf(NV_DBG_INFO, "NVRM: rc timer stopped\n"); -+ -+ return 0; -+} -+ -+static void -+nvos_validate_assigned_gpus(struct pci_dev *dev) -+{ -+ NvU32 i; -+ -+ if (NV_IS_ASSIGN_GPU_PCI_INFO_SPECIFIED()) -+ { -+ for (i = 0; i < nv_assign_gpu_count; i++) -+ { -+ if ((nv_assign_gpu_pci_info[i].domain == NV_PCI_DOMAIN_NUMBER(dev)) && -+ (nv_assign_gpu_pci_info[i].bus == NV_PCI_BUS_NUMBER(dev)) && -+ (nv_assign_gpu_pci_info[i].slot == NV_PCI_SLOT_NUMBER(dev))) -+ { -+ nv_assign_gpu_pci_info[i].valid = NV_TRUE; -+ return; -+ } -+ } -+ } -+} -+ -+/* make sure the pci_driver called probe for all of our devices. -+ * we've seen cases where rivafb claims the device first and our driver -+ * doesn't get called. -+ */ -+static int -+nvos_count_devices(nv_stack_t *sp) -+{ -+ struct pci_dev *dev; -+ int count = 0; -+ -+ dev = NV_PCI_GET_CLASS(PCI_CLASS_DISPLAY_VGA << 8, NULL); -+ while (dev) -+ { -+ if ((dev->vendor == 0x10de) && (dev->device >= 0x20) && -+ !rm_is_legacy_device(sp, dev->device, TRUE)) -+ { -+ count++; -+ nvos_validate_assigned_gpus(dev); -+ } -+ dev = NV_PCI_GET_CLASS(PCI_CLASS_DISPLAY_VGA << 8, dev); -+ } -+ -+ dev = NV_PCI_GET_CLASS(PCI_CLASS_DISPLAY_3D << 8, NULL); -+ while (dev) -+ { -+ if ((dev->vendor == 0x10de) && (dev->device >= 0x20) && -+ !rm_is_legacy_device(sp, dev->device, TRUE)) -+ { -+ count++; -+ nvos_validate_assigned_gpus(dev); -+ } -+ dev = NV_PCI_GET_CLASS(PCI_CLASS_DISPLAY_3D << 8, dev); -+ } -+ -+ dev = NV_PCI_GET_CLASS(PCI_CLASS_MULTIMEDIA_OTHER << 8, NULL); -+ while (dev) -+ { -+ if ((dev->vendor == 0x10de) && (dev->device == 0x0e00)) -+ count++; -+ dev = NV_PCI_GET_CLASS(PCI_CLASS_MULTIMEDIA_OTHER << 8, dev); -+ } -+ -+ if (NV_IS_ASSIGN_GPU_PCI_INFO_SPECIFIED()) -+ { -+ NvU32 i; -+ -+ for (i = 0; i < nv_assign_gpu_count; i++) -+ { -+ if (nv_assign_gpu_pci_info[i].valid == NV_TRUE) -+ count++; -+ } -+ } -+ -+ return count; -+} -+ -+/* find nvidia devices and set initial state */ -+static int -+nvidia_probe -+( -+ struct pci_dev *dev, -+ const struct pci_device_id *id_table -+) -+{ -+ nv_state_t *nv; -+ nv_linux_state_t *nvl = NULL; -+ unsigned int i, j; -+ int flags = 0; -+ nv_stack_t *sp = NULL; -+ -+ if (NV_IS_SMU_DEVICE(dev)) -+ { -+ return nvidia_smu_probe(dev); -+ } -+ -+ nv_printf(NV_DBG_SETUP, "NVRM: probing 0x%x 0x%x, class 0x%x\n", -+ dev->vendor, dev->device, dev->class); -+ -+ if ((dev->class == (PCI_CLASS_MULTIMEDIA_OTHER << 8)) && -+ (dev->device == 0x0e00)) -+ { -+ flags = NV_FLAG_GVI; -+ } -+ -+ NV_KMEM_CACHE_ALLOC_STACK(sp); -+ if (sp == NULL) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate stack!\n"); -+ return -1; -+ } -+ -+ if (!(flags & NV_FLAG_GVI)) -+ { -+ if ((dev->vendor != 0x10de) || (dev->device < 0x20) || -+ ((dev->class != (PCI_CLASS_DISPLAY_VGA << 8)) && -+ (dev->class != (PCI_CLASS_DISPLAY_3D << 8))) || -+ rm_is_legacy_device(sp, dev->device, FALSE)) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: ignoring the legacy GPU %04x:%02x:%02x.%x\n", -+ NV_PCI_DOMAIN_NUMBER(dev), NV_PCI_BUS_NUMBER(dev), NV_PCI_SLOT_NUMBER(dev), -+ PCI_FUNC(dev->devfn)); -+ goto failed; -+ } -+ } -+ -+ if (NV_IS_ASSIGN_GPU_PCI_INFO_SPECIFIED()) -+ { -+ for (i = 0; i < nv_assign_gpu_count; i++) -+ { -+ if (((nv_assign_gpu_pci_info[i].domain == NV_PCI_DOMAIN_NUMBER(dev)) && -+ (nv_assign_gpu_pci_info[i].bus == NV_PCI_BUS_NUMBER(dev)) && -+ (nv_assign_gpu_pci_info[i].slot == NV_PCI_SLOT_NUMBER(dev))) && -+ (nv_assign_gpu_pci_info[i].valid)) -+ break; -+ } -+ -+ if (i == nv_assign_gpu_count) -+ { -+ goto failed; -+ } -+ } -+ -+ num_probed_nv_devices++; -+ -+ if (pci_enable_device(dev) != 0) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: pci_enable_device failed, aborting\n"); -+ goto failed; -+ } -+ -+ if (dev->irq == 0) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: Can't find an IRQ for your NVIDIA card!\n"); -+ nv_printf(NV_DBG_ERRORS, "NVRM: Please check your BIOS settings.\n"); -+ nv_printf(NV_DBG_ERRORS, "NVRM: [Plug & Play OS] should be set to NO\n"); -+ nv_printf(NV_DBG_ERRORS, "NVRM: [Assign IRQ to VGA] should be set to YES \n"); -+ goto failed; -+ } -+ -+ for (i = 0; i < (NV_GPU_NUM_BARS - 1); i++) -+ { -+ if (NV_PCI_RESOURCE_VALID(dev, i)) -+ { -+#if defined(NV_PCI_MAX_MMIO_BITS_SUPPORTED) -+ if ((NV_PCI_RESOURCE_FLAGS(dev, i) & PCI_BASE_ADDRESS_MEM_TYPE_64) && -+ ((NV_PCI_RESOURCE_START(dev, i) >> NV_PCI_MAX_MMIO_BITS_SUPPORTED))) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: This is a 64-bit BAR mapped above %dGB by the system\n" -+ "NVRM: BIOS or the %s kernel. This PCI I/O region assigned\n" -+ "NVRM: to your NVIDIA device is not supported by the kernel.\n" -+ "NVRM: BAR%d is %dM @ 0x%llx (PCI:%04x:%02x:%02x.%x)\n", -+ (1 << (NV_PCI_MAX_MMIO_BITS_SUPPORTED - 30)), -+ NV_KERNEL_NAME, i, -+ (NV_PCI_RESOURCE_SIZE(dev, i) >> 20), -+ (NvU64)NV_PCI_RESOURCE_START(dev, i), -+ NV_PCI_DOMAIN_NUMBER(dev), -+ NV_PCI_BUS_NUMBER(dev), NV_PCI_SLOT_NUMBER(dev), -+ PCI_FUNC(dev->devfn)); -+ goto failed; -+ } -+#endif -+#if !defined(NV_VMWARE) -+ if ((NV_PCI_RESOURCE_FLAGS(dev, i) & PCI_BASE_ADDRESS_MEM_TYPE_64) && -+ ((NV_PCI_RESOURCE_START(dev, i) >> PAGE_SHIFT) > 0xfffffULL)) -+ { -+ struct pci_dev *bridge = dev->bus->self; -+ NvU32 base_upper, limit_upper; -+ -+ pci_read_config_dword(bridge, PCI_PREF_BASE_UPPER32, -+ &base_upper); -+ pci_read_config_dword(bridge, PCI_PREF_LIMIT_UPPER32, -+ &limit_upper); -+ -+ if ((base_upper != 0) && (limit_upper != 0)) -+ continue; -+ -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: This is a 64-bit BAR mapped above 4GB by the system\n" -+ "NVRM: BIOS or the %s kernel, but the PCI bridge\n" -+ "NVRM: immediately upstream of this GPU does not define\n" -+ "NVRM: a matching prefetchable memory window.\n", -+ NV_KERNEL_NAME); -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: This may be due to a known Linux kernel bug. Please\n" -+ "NVRM: see the README section on 64-bit BARs for additional\n" -+ "NVRM: information.\n"); -+ goto failed; -+ } -+#endif -+ continue; -+ } -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: This PCI I/O region assigned to your NVIDIA device is invalid:\n" -+ "NVRM: BAR%d is %dM @ 0x%llx (PCI:%04x:%02x:%02x.%x)\n", i, -+ (NV_PCI_RESOURCE_SIZE(dev, i) >> 20), -+ (NvU64)NV_PCI_RESOURCE_START(dev, i), -+ NV_PCI_DOMAIN_NUMBER(dev), -+ NV_PCI_BUS_NUMBER(dev), NV_PCI_SLOT_NUMBER(dev), PCI_FUNC(dev->devfn)); -+#if defined(NVCPU_X86) -+ if ((NV_PCI_RESOURCE_FLAGS(dev, i) & PCI_BASE_ADDRESS_MEM_TYPE_64) && -+ ((NV_PCI_RESOURCE_START(dev, i) >> PAGE_SHIFT) > 0xfffffULL)) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: This is a 64-bit BAR mapped above 4GB by the system\n" -+ "NVRM: BIOS or the Linux kernel. The NVIDIA Linux/x86\n" -+ "NVRM: graphics driver and other system software components\n" -+ "NVRM: do not support this configuration.\n"); -+ } -+ else -+#endif -+ if (NV_PCI_RESOURCE_FLAGS(dev, i) & PCI_BASE_ADDRESS_MEM_TYPE_64) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: This is a 64-bit BAR, which some operating system\n" -+ "NVRM: kernels and other system software components are known\n" -+ "NVRM: to handle incorrectly. Please see the README section\n" -+ "NVRM: on 64-bit BARs for more information.\n"); -+ } -+ else -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: The system BIOS may have misconfigured your GPU.\n"); -+ } -+ goto failed; -+ } -+ -+ if (!request_mem_region(NV_PCI_RESOURCE_START(dev, NV_GPU_BAR_INDEX_REGS), -+ NV_PCI_RESOURCE_SIZE(dev, NV_GPU_BAR_INDEX_REGS), NV_DEV_NAME)) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: request_mem_region failed for %dM @ 0x%llx. This can\n" -+ "NVRM: occur when a driver such as rivatv is loaded and claims\n" -+ "NVRM: ownership of the device's registers.\n", -+ (NV_PCI_RESOURCE_SIZE(dev, NV_GPU_BAR_INDEX_REGS) >> 20), -+ (NvU64)NV_PCI_RESOURCE_START(dev, NV_GPU_BAR_INDEX_REGS)); -+ goto failed; -+ } -+ -+ NV_KMALLOC(nvl, sizeof(nv_linux_state_t)); -+ if (nvl == NULL) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate memory\n"); -+ goto err_not_supported; -+ } -+ -+ os_mem_set(nvl, 0, sizeof(nv_linux_state_t)); -+ -+ nv = NV_STATE_PTR(nvl); -+ -+ pci_set_drvdata(dev, (void *)nvl); -+ -+ /* default to 32-bit PCI bus address space */ -+ dev->dma_mask = 0xffffffffULL; -+ -+ nvl->dev = dev; -+ nv->pci_info.vendor_id = dev->vendor; -+ nv->pci_info.device_id = dev->device; -+ nv->subsystem_id = dev->subsystem_device; -+ nv->os_state = (void *) nvl; -+ nv->pci_info.domain = NV_PCI_DOMAIN_NUMBER(dev); -+ nv->pci_info.bus = NV_PCI_BUS_NUMBER(dev); -+ nv->pci_info.slot = NV_PCI_SLOT_NUMBER(dev); -+ nv->handle = dev; -+ nv->flags |= flags; -+ -+ if (NVOS_IS_VMWARE) -+ { -+ nvl->minor_num = num_nv_devices; -+ } -+ -+ nv_lock_init_locks(nv); -+ -+ for (i = 0, j = 0; i < NVRM_PCICFG_NUM_BARS && j < NV_GPU_NUM_BARS; i++) -+ { -+ if ((NV_PCI_RESOURCE_VALID(dev, i)) && -+ (NV_PCI_RESOURCE_FLAGS(dev, i) & PCI_BASE_ADDRESS_SPACE) -+ == PCI_BASE_ADDRESS_SPACE_MEMORY) -+ { -+ nv->bars[j].address = NV_PCI_RESOURCE_START(dev, i); -+ nv->bars[j].strapped_size = NV_PCI_RESOURCE_SIZE(dev, i); -+ nv->bars[j].size = nv->bars[j].strapped_size; -+ nv->bars[j].offset = NVRM_PCICFG_BAR_OFFSET(i); -+ j++; -+ } -+ } -+ nv->regs = &nv->bars[NV_GPU_BAR_INDEX_REGS]; -+ nv->fb = &nv->bars[NV_GPU_BAR_INDEX_FB]; -+ -+ nv->interrupt_line = dev->irq; -+ -+ pci_set_master(dev); -+ -+#if defined(CONFIG_VGA_ARB) -+#if defined(VGA_DEFAULT_DEVICE) -+ vga_tryget(VGA_DEFAULT_DEVICE, VGA_RSRC_LEGACY_MASK); -+#endif -+ vga_set_legacy_decoding(dev, VGA_RSRC_NONE); -+#endif -+ -+ if (NV_IS_GVI_DEVICE(nv)) -+ { -+ if (!rm_gvi_init_private_state(sp, nv)) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVGVI: rm_init_gvi_private_state() failed!\n"); -+ goto err_not_supported; -+ } -+ -+ if (rm_gvi_attach_device(sp, nv) != RM_OK) -+ { -+ rm_gvi_free_private_state(sp, nv); -+ goto err_not_supported; -+ } -+ } -+ else -+ { -+ NvU32 pmc_boot_0, pmc_boot_42; -+ RM_STATUS status; -+ -+ NV_CHECK_PCI_CONFIG_SPACE(sp, nv, FALSE, TRUE, NV_MAY_SLEEP()); -+ -+ if ((status = rm_is_supported_device(sp, nv, &pmc_boot_0, &pmc_boot_42)) != RM_OK) -+ { -+ if ((status != RM_ERR_NOT_SUPPORTED) || -+ !rm_is_legacy_arch(pmc_boot_0, pmc_boot_42)) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: The NVIDIA GPU %04x:%02x:%02x.%x (PCI ID: %04x:%04x)\n" -+ "NVRM: installed in this system is not supported by the %s\n" -+ "NVRM: NVIDIA %s driver release. Please see 'Appendix\n" -+ "NVRM: A - Supported NVIDIA GPU Products' in this release's\n" -+ "NVRM: README, available on the %s driver download page\n" -+ "NVRM: at www.nvidia.com.\n", -+ nv->pci_info.domain, nv->pci_info.bus, nv->pci_info.slot, -+ PCI_FUNC(dev->devfn), nv->pci_info.vendor_id, -+ nv->pci_info.device_id, NV_VERSION_STRING, NV_KERNEL_NAME, -+ NV_KERNEL_NAME); -+ } -+ goto err_not_supported; -+ } -+ -+ if (!rm_init_private_state(sp, nv)) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: rm_init_private_state() failed!\n"); -+ goto err_zero_dev; -+ } -+ } -+ -+ nv_printf(NV_DBG_INFO, -+ "NVRM: PCI:%04x:%02x:%02x.%x (%04x:%04x): BAR0 @ 0x%llx (%lluMB)\n", -+ nv->pci_info.domain, nv->pci_info.bus, nv->pci_info.slot, -+ PCI_FUNC(dev->devfn), nv->pci_info.vendor_id, nv->pci_info.device_id, -+ nv->regs->address, (nv->regs->size >> 20)); -+ nv_printf(NV_DBG_INFO, -+ "NVRM: PCI:%04x:%02x:%02x.%x (%04x:%04x): BAR1 @ 0x%llx (%lluMB)\n", -+ nv->pci_info.domain, nv->pci_info.bus, nv->pci_info.slot, -+ PCI_FUNC(dev->devfn), nv->pci_info.vendor_id, nv->pci_info.device_id, -+ nv->fb->address, (nv->fb->size >> 20)); -+ -+ num_nv_devices++; -+ -+ for (i = 0; i < NV_GPU_NUM_BARS; i++) -+ { -+ if (nv->bars[i].size != 0) -+ { -+ if (nv_user_map_register(nv->bars[i].address, -+ nv->bars[i].strapped_size) != 0) -+ { -+ nv_printf(NV_DBG_ERRORS, -+ "NVRM: failed to register usermap for BAR %u!\n", i); -+ for (j = 0; j < i; j++) -+ { -+ nv_user_map_unregister(nv->bars[j].address, -+ nv->bars[j].strapped_size); -+ } -+ goto err_zero_dev; -+ } -+ } -+ } -+ -+ /* -+ * The newly created nvl object is added to the nv_linux_devices global list -+ * only after all the initialization operations for that nvl object are -+ * completed, so as to protect against simultaneous lookup operations which -+ * may discover a partially initialized nvl object in the list -+ */ -+ LOCK_NV_LINUX_DEVICES(); -+ if (nv_linux_devices == NULL) -+ nv_linux_devices = nvl; -+ else -+ { -+ nv_linux_state_t *tnvl; -+ for (tnvl = nv_linux_devices; tnvl->next != NULL; tnvl = tnvl->next); -+ tnvl->next = nvl; -+ } -+ UNLOCK_NV_LINUX_DEVICES(); -+#if !defined(NV_VMWARE) -+ if (nvidia_frontend_add_device((void *)&nv_fops, nvl) != 0) -+ goto err_zero_dev; -+#endif -+ nv_procfs_add_gpu(nvl); -+ -+ NV_KMEM_CACHE_FREE_STACK(sp); -+ -+ return 0; -+ -+err_zero_dev: -+ rm_free_private_state(sp, nv); -+err_not_supported: -+ if (nvl != NULL) -+ { -+ NV_KFREE(nvl, sizeof(nv_linux_state_t)); -+ } -+ release_mem_region(NV_PCI_RESOURCE_START(dev, NV_GPU_BAR_INDEX_REGS), -+ NV_PCI_RESOURCE_SIZE(dev, NV_GPU_BAR_INDEX_REGS)); -+ NV_PCI_DISABLE_DEVICE(dev); -+ pci_set_drvdata(dev, NULL); -+failed: -+ NV_KMEM_CACHE_FREE_STACK(sp); -+ return -1; -+} -+ -+void nvidia_remove(struct pci_dev *dev) -+{ -+ nv_linux_state_t *nvl = NULL; -+ nv_state_t *nv; -+ nv_stack_t *sp = NULL; -+ NvU32 i; -+ -+ nv_printf(NV_DBG_SETUP, "NVRM: removing GPU %04x:%02x:%02x.%x\n", -+ NV_PCI_DOMAIN_NUMBER(dev), NV_PCI_BUS_NUMBER(dev), -+ NV_PCI_SLOT_NUMBER(dev), PCI_FUNC(dev->devfn)); -+ -+ if (NV_IS_SMU_DEVICE(dev)) -+ { -+ return; -+ } -+ -+ NV_KMEM_CACHE_ALLOC_STACK(sp); -+ if (sp == NULL) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: %s failed to allocate stack!\n", __FUNCTION__); -+ return; -+ } -+ -+ LOCK_NV_LINUX_DEVICES(); -+ nvl = pci_get_drvdata(dev); -+ if (!nvl || (nvl->dev != dev)) -+ { -+ goto done; -+ } -+ -+ nv = NV_STATE_PTR(nvl); -+ if (nvl == nv_linux_devices) -+ nv_linux_devices = nvl->next; -+ else -+ { -+ nv_linux_state_t *tnvl; -+ for (tnvl = nv_linux_devices; tnvl->next != nvl; tnvl = tnvl->next); -+ tnvl->next = nvl->next; -+ } -+ -+ /* Remove proc entry for this GPU */ -+ nv_procfs_remove_gpu(nvl); -+ -+ down(&nvl->ldata_lock); -+ UNLOCK_NV_LINUX_DEVICES(); -+ -+#if !defined(NV_VMWARE) -+ /* Update the frontend data structures */ -+ nvidia_frontend_remove_device((void *)&nv_fops, nvl); -+#endif -+ -+#if defined(NV_UVM_ENABLE) || defined(NV_UVM_NEXT_ENABLE) -+ if (!NV_IS_GVI_DEVICE(nv)) -+ { -+ NvU8 *uuid; -+ // Inform UVM before disabling adapter -+ if(rm_get_gpu_uuid_raw(sp, nv, &uuid, NULL) == RM_OK) -+ { -+ // this function cannot fail -+ nv_uvm_notify_stop_device(uuid); -+ // get_uuid allocates memory for this call free it here -+ os_free_mem(uuid); -+ } -+ } -+#endif -+ -+ if ((nv->flags & NV_FLAG_PERSISTENT_SW_STATE) || (nv->flags & NV_FLAG_OPEN)) -+ { -+ if (nv->flags & NV_FLAG_PERSISTENT_SW_STATE) -+ { -+ rm_disable_gpu_state_persistence(sp, nv); -+ } -+ NV_SHUTDOWN_ADAPTER(sp, nv, nvl); -+ NV_KMEM_CACHE_FREE_STACK(nvl->timer_sp); -+ NV_KMEM_CACHE_FREE_STACK(nvl->isr_bh_sp); -+ NV_KMEM_CACHE_FREE_STACK(nvl->pci_cfgchk_sp); -+ NV_KMEM_CACHE_FREE_STACK(nvl->isr_sp); -+ } -+ -+ num_probed_nv_devices--; -+ -+ pci_set_drvdata(dev, NULL); -+ -+ if (NV_IS_GVI_DEVICE(nv)) -+ { -+ NV_TASKQUEUE_FLUSH(); -+ rm_gvi_detach_device(sp, nv); -+ rm_gvi_free_private_state(sp, nv); -+ } -+ else -+ { -+ for (i = 0; i < NV_GPU_NUM_BARS; i++) -+ { -+ if (nv->bars[i].size != 0) -+ { -+ nv_user_map_unregister(nv->bars[i].address, -+ nv->bars[i].strapped_size); -+ } -+ } -+ rm_i2c_remove_adapters(sp, nv); -+ rm_free_private_state(sp, nv); -+ } -+ release_mem_region(NV_PCI_RESOURCE_START(dev, NV_GPU_BAR_INDEX_REGS), -+ NV_PCI_RESOURCE_SIZE(dev, NV_GPU_BAR_INDEX_REGS)); -+ NV_PCI_DISABLE_DEVICE(dev); -+ num_nv_devices--; -+ -+ NV_KFREE(nvl, sizeof(nv_linux_state_t)); -+ NV_KMEM_CACHE_FREE_STACK(sp); -+ return; -+ -+done: -+ UNLOCK_NV_LINUX_DEVICES(); -+ NV_KMEM_CACHE_FREE_STACK(sp); -+} -+ -+static int -+nvidia_smu_probe -+( -+ struct pci_dev *dev -+) -+{ -+ nv_smu_state_t *nv = &nv_smu_device; -+ -+ nv_printf(NV_DBG_SETUP, "NVRM: probing 0x%x 0x%x, class 0x%x\n", -+ dev->vendor, dev->device, dev->class); -+ -+ if ((dev->vendor != 0x10de) || -+ (dev->class != (PCI_CLASS_PROCESSOR_CO << 8)) || -+ (dev->device != NV_PCI_DEVICE_ID_SMU)) -+ { -+ nv_printf(NV_DBG_INFO, "NVRM: ignoring the SMU %04x:%02x:%02x.%x\n", -+ NV_PCI_DOMAIN_NUMBER(dev), NV_PCI_BUS_NUMBER(dev), -+ NV_PCI_SLOT_NUMBER(dev), PCI_FUNC(dev->devfn)); -+ goto failed; -+ } -+ -+ if (nv->handle != NULL) -+ { -+ nv_printf(NV_DBG_INFO, -+ "NVRM: More than one SMU device? Driver not yet designed to handle this case\n"); -+ goto failed; -+ } -+ -+ if (pci_enable_device(dev) != 0) -+ { -+ nv_printf(NV_DBG_INFO, -+ "NVRM: pci_enable_device for SMU device failed, aborting\n"); -+ goto failed; -+ } -+ -+ // validate BAR0 -+ if (!NV_PCI_RESOURCE_VALID(dev, 0)) -+ { -+ nv_printf(NV_DBG_INFO, -+ "NVRM: This PCI I/O region assigned to the SMU device is invalid:\n" -+ "NVRM: BAR0 is %dM @ 0x%08x (PCI:%04x:%02x:%02x.%x)\n", -+ NV_PCI_RESOURCE_SIZE(dev, 0) >> 20, NV_PCI_RESOURCE_START(dev, 0), -+ NV_PCI_DOMAIN_NUMBER(dev), NV_PCI_BUS_NUMBER(dev), -+ NV_PCI_SLOT_NUMBER(dev), PCI_FUNC(dev->devfn)); -+ goto failed; -+ } -+ -+ if (!request_mem_region(NV_PCI_RESOURCE_START(dev, 0), -+ NV_PCI_RESOURCE_SIZE(dev, 0), NV_DEV_NAME)) -+ { -+ nv_printf(NV_DBG_INFO, -+ "NVRM: request_mem_region failed for %dM @ 0x%08x.\n", -+ NV_PCI_RESOURCE_SIZE(dev, 0) >> 20, -+ NV_PCI_RESOURCE_START(dev, 0)); -+ -+ goto failed; -+ } -+ -+ pci_set_drvdata(dev, (void *)nv); -+ -+ /* default to 32-bit PCI bus address space */ -+ dev->dma_mask = 0xffffffffULL; -+ -+ nv->pci_info.vendor_id = dev->vendor; -+ nv->pci_info.device_id = dev->device; -+ nv->pci_info.domain = NV_PCI_DOMAIN_NUMBER(dev); -+ nv->pci_info.bus = NV_PCI_BUS_NUMBER(dev); -+ nv->pci_info.slot = NV_PCI_SLOT_NUMBER(dev); -+ nv->handle = dev; -+ -+ if ((NV_PCI_RESOURCE_VALID(dev, 0)) && -+ (NV_PCI_RESOURCE_FLAGS(dev, 0) & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY) -+ { -+ nv->bar0.address = NV_PCI_RESOURCE_START(dev, 0); -+ nv->bar0.size = NV_PCI_RESOURCE_SIZE(dev, 0); -+ nv->bar0.offset = NVRM_PCICFG_BAR_OFFSET(0); -+ } -+ -+ nv->regs = &nv->bar0; -+ -+ nv_printf(NV_DBG_INFO, "NVRM: %04x:%02x:%02x.%x %04x:%04x - 0x%08x [size=%dK]\n", -+ nv->pci_info.domain, nv->pci_info.bus, nv->pci_info.slot, -+ PCI_FUNC(dev->devfn), nv->pci_info.vendor_id, nv->pci_info.device_id, -+ nv->regs->address, nv->regs->size / (1024)); -+ -+ return 0; -+ -+failed: -+ return -1; -+} -+ -+int NV_API_CALL nv_no_incoherent_mappings(void) -+{ -+ return (nv_update_memory_types); -+} -+ -+#if defined(NV_PM_SUPPORT_DEVICE_DRIVER_MODEL) -+ -+static int -+nv_power_management( -+ struct pci_dev *dev, -+ u32 pci_state, -+ u32 power_state -+) -+{ -+ nv_state_t *nv; -+ nv_linux_state_t *lnv = NULL; -+ int status = RM_OK; -+ nv_stack_t *sp = NULL; -+ -+ nv_printf(NV_DBG_INFO, "NVRM: nv_power_management: %d\n", pci_state); -+ lnv = pci_get_drvdata(dev); -+ -+ if (!lnv || (lnv->dev != dev)) -+ { -+ nv_printf(NV_DBG_WARNINGS, "NVRM: PM: invalid device!\n"); -+ return -1; -+ } -+ -+ NV_KMEM_CACHE_ALLOC_STACK(sp); -+ if (sp == NULL) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate stack!\n"); -+ return -1; -+ } -+ -+ nv = NV_STATE_PTR(lnv); -+ NV_CHECK_PCI_CONFIG_SPACE(sp, nv, TRUE, TRUE, NV_MAY_SLEEP()); -+ -+ switch (pci_state) -+ { -+ case PCI_D3hot: -+ nv_printf(NV_DBG_INFO, "NVRM: ACPI: received suspend event\n"); -+ status = rm_power_management(sp, nv, 0, power_state); -+ tasklet_kill(&lnv->tasklet); -+ nv_disable_pat_support(); -+ break; -+ -+ case PCI_D0: -+ nv_printf(NV_DBG_INFO, "NVRM: ACPI: received resume event\n"); -+ nv_enable_pat_support(); -+ tasklet_init(&lnv->tasklet, nvidia_isr_bh, (NvUPtr)NV_STATE_PTR(lnv)); -+ status = rm_power_management(sp, nv, 0, power_state); -+ break; -+ -+ default: -+ nv_printf(NV_DBG_WARNINGS, "NVRM: PM: unsupported event: %d\n", pci_state); -+ status = -1; -+ } -+ -+ NV_KMEM_CACHE_FREE_STACK(sp); -+ -+ if (status != RM_OK) -+ nv_printf(NV_DBG_ERRORS, "NVRM: PM: failed event: %d\n", pci_state); -+ -+ return status; -+} -+ -+static int -+nvidia_suspend( -+ struct pci_dev *dev, -+ pm_message_t state -+) -+{ -+ int pci_state = -1; -+ u32 power_state; -+ nv_state_t *nv; -+ nv_linux_state_t *lnv = NULL; -+ -+ if (NV_IS_SMU_DEVICE(dev)) -+ { -+ return nvidia_smu_suspend(); -+ } -+ -+ lnv = pci_get_drvdata(dev); -+ -+ if (!lnv || (lnv->dev != dev)) -+ { -+ nv_printf(NV_DBG_WARNINGS, "NVRM: PM: invalid device!\n"); -+ return -1; -+ } -+ -+ nv = NV_STATE_PTR(lnv); -+ -+ if (NV_IS_GVI_DEVICE(nv)) -+ { -+ return nv_gvi_kern_suspend(dev, state); -+ } -+ -+#if !defined(NV_PM_MESSAGE_T_PRESENT) -+ pci_state = state; -+#elif defined(NV_PCI_CHOOSE_STATE_PRESENT) -+ pci_state = PCI_D3hot; -+#endif -+ -+ power_state = NV_PM_ACPI_STANDBY; -+ -+#if defined(NV_PM_MESSAGE_T_HAS_EVENT) -+ if (state.event == PM_EVENT_FREEZE) /* for hibernate */ -+ power_state = NV_PM_ACPI_HIBERNATE; -+#endif -+ -+ return nv_power_management(dev, pci_state, power_state); -+} -+ -+static int -+nvidia_smu_suspend(void) -+{ -+ nv_stack_t *sp = NULL; -+ -+ NV_KMEM_CACHE_ALLOC_STACK(sp); -+ if (sp == NULL) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate stack!\n"); -+ return RM_ERR_NO_FREE_MEM; -+ } -+ -+ rm_suspend_smu(sp); -+ -+ NV_KMEM_CACHE_FREE_STACK(sp); -+ -+ return 0; -+} -+ -+static int -+nvidia_resume( -+ struct pci_dev *dev -+) -+{ -+ nv_state_t *nv; -+ nv_linux_state_t *lnv = NULL; -+ -+ if (NV_IS_SMU_DEVICE(dev)) -+ { -+ return nvidia_smu_resume(); -+ } -+ -+ lnv = pci_get_drvdata(dev); -+ -+ if (!lnv || (lnv->dev != dev)) -+ { -+ nv_printf(NV_DBG_WARNINGS, "NVRM: PM: invalid device!\n"); -+ return -1; -+ } -+ -+ nv = NV_STATE_PTR(lnv); -+ -+ if (NV_IS_GVI_DEVICE(nv)) -+ { -+ return nv_gvi_kern_resume(dev); -+ } -+ -+ return nv_power_management(dev, PCI_D0, NV_PM_ACPI_RESUME); -+} -+ -+static int -+nvidia_smu_resume(void) -+{ -+ nv_stack_t *sp = NULL; -+ -+ NV_KMEM_CACHE_ALLOC_STACK(sp); -+ if (sp == NULL) -+ { -+ nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate stack!\n"); -+ return RM_ERR_NO_FREE_MEM; -+ } -+ -+ rm_resume_smu(sp); -+ -+ NV_KMEM_CACHE_FREE_STACK(sp); -+ -+ return 0; -+} -+ -+#endif /* defined(NV_PM_SUPPORT_DEVICE_DRIVER_MODEL) */ -+ -+void* NV_API_CALL nv_get_adapter_state( -+ NvU32 domain, -+ NvU8 bus, -+ NvU8 slot -+) -+{ -+ nv_linux_state_t *nvl; -+ -+ LOCK_NV_LINUX_DEVICES(); -+ for (nvl = nv_linux_devices; nvl != NULL; nvl = nvl->next) -+ { -+ nv_state_t *nv = NV_STATE_PTR(nvl); -+ if (nv->pci_info.domain == domain && nv->pci_info.bus == bus -+ && nv->pci_info.slot == slot) -+ { -+ UNLOCK_NV_LINUX_DEVICES(); -+ return (void *) nv; -+ } -+ } -+ UNLOCK_NV_LINUX_DEVICES(); -+ -+ if (NV_PCI_MATCH_CTL_DEVICE(domain, bus, slot)) -+ { -+ nv_state_t *nv = NV_STATE_PTR(&nv_ctl_device); -+ return (void *) nv; -+ } -+ -+ return NULL; -+} -+ -+void* NV_API_CALL nv_get_smu_state(void) -+{ -+ nv_smu_state_t *nv_smu = &nv_smu_device; -+ -+ if (nv_smu->handle == NULL) -+ { -+ return NULL; -+ } -+ -+ return nv_smu; -+} -+ -+RM_STATUS NV_API_CALL nv_log_error( -+ nv_state_t *nv, -+ NvU32 error_number, -+ const char *format, -+ va_list ap -+) -+{ -+ RM_STATUS status = RM_OK; -+#if defined(CONFIG_CRAY_XT) -+ nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv); -+ if (ap != NULL) -+ { -+ status = nvos_forward_error_to_cray(nvl->dev, error_number, -+ format, ap); -+ } -+#endif -+ return status; -+} -diff -urN kernel.orig/nv-drm.c kernel/nv-drm.c ---- kernel.orig/nv-drm.c 2014-05-27 22:59:51.000000000 +0400 -+++ kernel/nv-drm.c 2015-01-17 23:34:40.419585549 +0300 -@@ -18,6 +18,11 @@ - - #include - -+/* 3.18-rc0+ */ -+#ifndef drm_gem_object -+#include -+#endif -+ - extern nv_linux_state_t *nv_linux_devices; - - struct nv_gem_object { -@@ -124,6 +129,10 @@ - .gem_prime_vmap = nv_gem_prime_vmap, - .gem_prime_vunmap = nv_gem_prime_vunmap, - -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0) -+ .set_busid = drm_pci_set_busid, -+#endif -+ - .name = "nvidia-drm", - .desc = "NVIDIA DRM driver", - .date = "20130102", -diff -urN kernel.orig/nv-drm.c.orig kernel/nv-drm.c.orig ---- kernel.orig/nv-drm.c.orig 1970-01-01 03:00:00.000000000 +0300 -+++ kernel/nv-drm.c.orig 2014-05-27 22:59:51.000000000 +0400 -@@ -0,0 +1,227 @@ -+/* _NVRM_COPYRIGHT_BEGIN_ -+ * -+ * Copyright 2013 by NVIDIA Corporation. All rights reserved. All -+ * information contained herein is proprietary and confidential to NVIDIA -+ * Corporation. Any use, reproduction, or disclosure without the written -+ * permission of NVIDIA Corporation is prohibited. -+ * -+ * _NVRM_COPYRIGHT_END_ -+ */ -+ -+#define __NO_VERSION__ -+ -+#include "nv-misc.h" -+#include "os-interface.h" -+#include "nv-linux.h" -+ -+#if defined(NV_DRM_AVAILABLE) -+ -+#include -+ -+extern nv_linux_state_t *nv_linux_devices; -+ -+struct nv_gem_object { -+ struct drm_gem_object base; -+ struct page **pages; -+}; -+ -+static int nv_drm_load( -+ struct drm_device *dev, -+ unsigned long flags -+) -+{ -+ nv_linux_state_t *nvl; -+ -+ for (nvl = nv_linux_devices; nvl != NULL; nvl = nvl->next) -+ { -+ if (nvl->dev == dev->pdev) -+ { -+ nvl->drm = dev; -+ return 0; -+ } -+ } -+ -+ return -ENODEV; -+} -+ -+static int nv_drm_unload( -+ struct drm_device *dev -+) -+{ -+ nv_linux_state_t *nvl; -+ -+ for (nvl = nv_linux_devices; nvl != NULL; nvl = nvl->next) -+ { -+ if (nvl->dev == dev->pdev) -+ { -+ BUG_ON(nvl->drm != dev); -+ nvl->drm = NULL; -+ return 0; -+ } -+ } -+ -+ return -ENODEV; -+} -+ -+static void nv_gem_free( -+ struct drm_gem_object *obj -+) -+{ -+ struct nv_gem_object *nv_obj = container_of(obj, struct nv_gem_object, base); -+ NV_KFREE(nv_obj, sizeof(*nv_obj)); -+} -+ -+static struct sg_table* nv_gem_prime_get_sg_table( -+ struct drm_gem_object *obj -+) -+{ -+ struct nv_gem_object *nv_obj = container_of(obj, struct nv_gem_object, base); -+ int page_count = obj->size >> PAGE_SHIFT; -+ -+ return drm_prime_pages_to_sg(nv_obj->pages, page_count); -+} -+ -+static void* nv_gem_prime_vmap( -+ struct drm_gem_object *obj -+) -+{ -+ struct nv_gem_object *nv_obj = container_of(obj, struct nv_gem_object, base); -+ int page_count = obj->size >> PAGE_SHIFT; -+ -+ return vmap(nv_obj->pages, page_count, VM_USERMAP, PAGE_KERNEL); -+} -+ -+static void nv_gem_prime_vunmap( -+ struct drm_gem_object *obj, -+ void *virtual -+) -+{ -+ vunmap(virtual); -+} -+ -+static const struct file_operations nv_drm_fops = { -+ .owner = THIS_MODULE, -+ .open = drm_open, -+ .release = drm_release, -+ .unlocked_ioctl = drm_ioctl, -+ .mmap = drm_gem_mmap, -+ .poll = drm_poll, -+ .read = drm_read, -+ .llseek = noop_llseek, -+}; -+ -+static struct drm_driver nv_drm_driver = { -+ .driver_features = DRIVER_GEM | DRIVER_PRIME, -+ .load = nv_drm_load, -+ .unload = nv_drm_unload, -+ .fops = &nv_drm_fops, -+ -+ .gem_free_object = nv_gem_free, -+ -+ .prime_handle_to_fd = drm_gem_prime_handle_to_fd, -+ .gem_prime_export = drm_gem_prime_export, -+ .gem_prime_get_sg_table = nv_gem_prime_get_sg_table, -+ .gem_prime_vmap = nv_gem_prime_vmap, -+ .gem_prime_vunmap = nv_gem_prime_vunmap, -+ -+ .name = "nvidia-drm", -+ .desc = "NVIDIA DRM driver", -+ .date = "20130102", -+ .major = 0, -+ .minor = 0, -+ .patchlevel = 0, -+}; -+#endif /* defined(NV_DRM_AVAILABLE) */ -+ -+int __init nv_drm_init( -+ struct pci_driver *pci_driver -+) -+{ -+ int ret = 0; -+#if defined(NV_DRM_AVAILABLE) -+ ret = drm_pci_init(&nv_drm_driver, pci_driver); -+#endif -+ return ret; -+} -+ -+void nv_drm_exit( -+ struct pci_driver *pci_driver -+) -+{ -+#if defined(NV_DRM_AVAILABLE) -+ drm_pci_exit(&nv_drm_driver, pci_driver); -+#endif -+} -+ -+RM_STATUS NV_API_CALL nv_alloc_os_descriptor_handle( -+ nv_state_t *nv, -+ NvS32 drm_fd, -+ void *private, -+ NvU64 page_count, -+ NvU32 *handle -+) -+{ -+ RM_STATUS status = RM_ERR_NOT_SUPPORTED; -+ -+#if defined(NV_DRM_AVAILABLE) -+ nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv); -+ struct page **pages = private; -+ struct file *drmf; -+ struct drm_file *file_priv; -+ struct nv_gem_object *nv_obj = NULL; -+ size_t size = page_count << PAGE_SHIFT; -+ int ret; -+ -+ if (drm_fd < 0) -+ { -+ return RM_ERR_INVALID_ARGUMENT; -+ } -+ -+ drmf = fget((unsigned int)drm_fd); -+ if (drmf == NULL) -+ { -+ return RM_ERR_INVALID_ARGUMENT; -+ } -+ -+ if (drmf->f_op != &nv_drm_fops) -+ { -+ status = RM_ERR_INVALID_ARGUMENT; -+ goto done; -+ } -+ -+ file_priv = drmf->private_data; -+ -+ NV_KMALLOC(nv_obj, sizeof(*nv_obj)); -+ if (!nv_obj) -+ { -+ status = RM_ERR_INSUFFICIENT_RESOURCES; -+ goto done; -+ } -+ -+ memset(&nv_obj->base, 0, sizeof(nv_obj->base)); -+ nv_obj->pages = pages; -+ -+ drm_gem_private_object_init(nvl->drm, &nv_obj->base, size); -+ -+ ret = drm_gem_handle_create(file_priv, &nv_obj->base, handle); -+ if (ret) -+ { -+ status = RM_ERR_OPERATING_SYSTEM; -+ goto done; -+ } -+ -+ drm_gem_object_unreference_unlocked(&nv_obj->base); -+ -+ status = RM_OK; -+ -+done: -+ if (status != RM_OK) -+ { -+ NV_KFREE(nv_obj, sizeof(*nv_obj)); -+ } -+ -+ fput(drmf); -+#endif -+ -+ return status; -+} -diff -urN kernel.orig/nv-frontend.c kernel/nv-frontend.c ---- kernel.orig/nv-frontend.c 2014-05-27 22:59:52.000000000 +0400 -+++ kernel/nv-frontend.c 2015-01-17 23:33:57.946450351 +0300 -@@ -327,7 +327,7 @@ - unsigned long i_arg - ) - { -- return nvidia_frontend_ioctl(file->f_dentry->d_inode, file, cmd, i_arg); -+ return nvidia_frontend_ioctl(file->f_path.dentry->d_inode, file, cmd, i_arg); - } - - long nvidia_frontend_compat_ioctl( -@@ -336,7 +336,7 @@ - unsigned long i_arg - ) - { -- return nvidia_frontend_ioctl(file->f_dentry->d_inode, file, cmd, i_arg); -+ return nvidia_frontend_ioctl(file->f_path.dentry->d_inode, file, cmd, i_arg); - } - - int nvidia_frontend_mmap( diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-340.65-3.18.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-340.65-3.18.patch deleted file mode 100644 index f2c8f23..0000000 --- a/x11-drivers/nvidia-drivers/files/nvidia-drivers-340.65-3.18.patch +++ /dev/null @@ -1,48 +0,0 @@ ---- kernel/nv-drm.c~ 2014-11-08 00:57:53.000000000 +0100 -+++ kernel/nv-drm.c 2014-11-13 21:03:37.589650873 +0100 -@@ -128,6 +128,10 @@ static struct drm_driver nv_drm_driver = - .gem_prime_vmap = nv_gem_prime_vmap, - .gem_prime_vunmap = nv_gem_prime_vunmap, - -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0) -+ .set_busid = drm_pci_set_busid, -+#endif -+ - .name = "nvidia-drm", - .desc = "NVIDIA DRM driver", - .date = "20130102", -diff --git a/nv-frontend.c~ b/nv-frontend.c -index c8c8af1..00f0973 100644 ---- kernel/nv-frontend.c~ -+++ kernel/nv-frontend.c -@@ -327,7 +327,7 @@ long nvidia_frontend_unlocked_ioctl( - unsigned long i_arg - ) - { -- return nvidia_frontend_ioctl(file->f_dentry->d_inode, file, cmd, i_arg); -+ return nvidia_frontend_ioctl(file->f_path.dentry->d_inode, file, cmd, i_arg); - } - - long nvidia_frontend_compat_ioctl( -@@ -336,7 +336,7 @@ long nvidia_frontend_compat_ioctl( - unsigned long i_arg - ) - { -- return nvidia_frontend_ioctl(file->f_dentry->d_inode, file, cmd, i_arg); -+ return nvidia_frontend_ioctl(file->f_path.dentry->d_inode, file, cmd, i_arg); - } - - int nvidia_frontend_mmap( -diff --git a/nv.c~ b/nv.c -index 6b31000..3db114e 100644 ---- kernel/nv.c~ -+++ kernel/nv.c -@@ -1796,7 +1796,7 @@ nvidia_unlocked_ioctl( - unsigned long i_arg - ) - { -- return nvidia_ioctl(file->f_dentry->d_inode, file, cmd, i_arg); -+ return nvidia_ioctl(file->f_path.dentry->d_inode, file, cmd, i_arg); - } - - /* diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-340.76-nv-pat.c.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-340.76-nv-pat.c.patch deleted file mode 100644 index b0913b3..0000000 --- a/x11-drivers/nvidia-drivers/files/nvidia-drivers-340.76-nv-pat.c.patch +++ /dev/null @@ -1,29 +0,0 @@ -diff -urN kernel.orig/nv-pat.c kernel/nv-pat.c ---- kernel.orig/nv-pat.c 2015-01-22 22:01:16.000000000 +0300 -+++ kernel/nv-pat.c 2015-06-19 13:46:17.360300340 +0300 -@@ -35,8 +35,13 @@ - unsigned long cr0 = read_cr0(); - write_cr0(((cr0 & (0xdfffffff)) | 0x40000000)); - wbinvd(); -+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 20, 0) - *cr4 = read_cr4(); - if (*cr4 & 0x80) write_cr4(*cr4 & ~0x80); -+#else -+ *cr4 = __read_cr4(); -+ if (*cr4 & 0x80) __write_cr4(*cr4 & ~0x80); -+#endif - __flush_tlb(); - } - -@@ -46,7 +51,11 @@ - wbinvd(); - __flush_tlb(); - write_cr0((cr0 & 0x9fffffff)); -+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 20, 0) - if (cr4 & 0x80) write_cr4(cr4); -+#else -+ if (cr4 & 0x80) __write_cr4(cr4); -+#endif - } - - static int nv_determine_pat_mode(void) diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-settings.desktop b/x11-drivers/nvidia-drivers/files/nvidia-drivers-settings.desktop deleted file mode 100644 index 773a5af..0000000 --- a/x11-drivers/nvidia-drivers/files/nvidia-drivers-settings.desktop +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -Type=Application -Name=NVIDIA X Server Settings -Comment=Configure NVIDIA X Server Settings -Exec=/opt/bin/nvidia-settings -Icon=nvidia-drivers-settings -Categories=System;Settings; diff --git a/x11-drivers/nvidia-drivers/files/nvidia-persistenced.conf b/x11-drivers/nvidia-drivers/files/nvidia-persistenced.conf deleted file mode 100644 index 637ac1a..0000000 --- a/x11-drivers/nvidia-drivers/files/nvidia-persistenced.conf +++ /dev/null @@ -1,8 +0,0 @@ -# run-time configuration file for /etc/init.d/nvidia-persistenced - -# NVPD_USER: The user nvidia-persistenced is intended to run for -NVPD_USER="" - -# ARGS: Additional arguments to set the default persistence mode -# (see nvidia-persistenced(1)) -ARGS="" diff --git a/x11-drivers/nvidia-drivers/files/nvidia-persistenced.init b/x11-drivers/nvidia-drivers/files/nvidia-persistenced.init deleted file mode 100755 index e712514..0000000 --- a/x11-drivers/nvidia-drivers/files/nvidia-persistenced.init +++ /dev/null @@ -1,25 +0,0 @@ -#!/sbin/runscript -# Copyright 1999-2014 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/x11-drivers/nvidia-drivers/files/nvidia-persistenced.init,v 1.2 2014/09/19 22:09:28 jer Exp $ - -pidfile="/var/run/nvidia-persistenced/nvidia-persistenced.pid" - -start() { - if ! [ "${NVPD_USER}x" = x ]; then - ebegin "Starting nvidia-persistenced for ${NVPD_USER}" - NVPD_USER_ARG="--user ${NVPD_USER}" - else - ebegin "Starting nvidia-persistenced" - fi - start-stop-daemon --start --quiet --pidfile ${pidfile} \ - --background --exec /opt/bin/nvidia-persistenced \ - -- ${NVPD_USER_ARG} ${ARGS} - eend $? -} - -stop() { - ebegin "Stopping nvidia-persistenced" - start-stop-daemon --stop --quiet --pidfile ${pidfile} - eend $? -} diff --git a/x11-drivers/nvidia-drivers/files/nvidia-smi.init b/x11-drivers/nvidia-drivers/files/nvidia-smi.init deleted file mode 100644 index 71bbc6d..0000000 --- a/x11-drivers/nvidia-drivers/files/nvidia-smi.init +++ /dev/null @@ -1,25 +0,0 @@ -#!/sbin/runscript -# Copyright 1999-2013 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/x11-drivers/nvidia-drivers/files/nvidia-smi.init,v 1.2 2013/05/09 16:32:00 jer Exp $ - -pidfile="/run/nvidia-smi.pid" - -depend() { - after modules -} - -start() { - ebegin "Starting NVIDIA System Management Interface" - rm -f ${pidfile} - start-stop-daemon --start --quiet --pidfile ${pidfile} \ - --make-pidfile --background --exec /opt/bin/nvidia-smi -- \ - -q -l 300 - eend $? -} - -stop() { - ebegin "Stopping NVIDIA System Management Interface" - start-stop-daemon --stop --quiet --pidfile ${pidfile} - eend $? -} diff --git a/x11-drivers/nvidia-drivers/files/nvidia-udev.sh b/x11-drivers/nvidia-drivers/files/nvidia-udev.sh deleted file mode 100644 index 9487b08..0000000 --- a/x11-drivers/nvidia-drivers/files/nvidia-udev.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -if [ $# -ne 1 ]; then - echo "Invalid args" >&2 - exit 1 -fi - -case $1 in - add|ADD) - /opt/bin/nvidia-smi > /dev/null - ;; - remove|REMOVE) - rm -f /dev/nvidia* - ;; -esac - -exit 0 diff --git a/x11-drivers/nvidia-drivers/files/nvidia-uvm.conf b/x11-drivers/nvidia-drivers/files/nvidia-uvm.conf deleted file mode 100644 index 222c5ba..0000000 --- a/x11-drivers/nvidia-drivers/files/nvidia-uvm.conf +++ /dev/null @@ -1,3 +0,0 @@ -# Nvidia UVM support - -remove nvidia modprobe -r --ignore-remove nvidia-uvm nvidia diff --git a/x11-drivers/nvidia-drivers/files/nvidia.udev-rule b/x11-drivers/nvidia-drivers/files/nvidia.udev-rule deleted file mode 100644 index 2eb30bb..0000000 --- a/x11-drivers/nvidia-drivers/files/nvidia.udev-rule +++ /dev/null @@ -1,6 +0,0 @@ -ACTION=="add", DEVPATH=="/module/nvidia", SUBSYSTEM=="module", RUN+="nvidia-udev.sh $env{ACTION}" -# Previously the ACTION was "add|remove" but one user on bug #376527 had a -# problem until he recompiled udev-171-r5, which is one of the versions I -# tested with and it was fine. I'm breaking the rules out just to be safe -# so someone else doesn't have an issue -ACTION=="remove", DEVPATH=="/module/nvidia", SUBSYSTEM=="module", RUN+="nvidia-udev.sh $env{ACTION}" diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-337.25.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-337.25.ebuild deleted file mode 100644 index 46f7025..0000000 --- a/x11-drivers/nvidia-drivers/nvidia-drivers-337.25.ebuild +++ /dev/null @@ -1,487 +0,0 @@ -# Copyright 1999-2014 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/x11-drivers/nvidia-drivers/nvidia-drivers-340.65.ebuild,v 1.2 2014/12/12 09:45:25 jer Exp $ - -EAPI=5 - -inherit eutils flag-o-matic linux-info linux-mod multilib nvidia-driver \ - portability toolchain-funcs unpacker user udev - -NV_URI="http://us.download.nvidia.com/XFree86/" -X86_NV_PACKAGE="NVIDIA-Linux-x86-${PV}" -AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}" -X86_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86-${PV}" -AMD64_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86_64-${PV}" - -DESCRIPTION="NVIDIA Accelerated Graphics Driver" -HOMEPAGE="http://www.nvidia.com/" -SRC_URI=" - amd64-fbsd? ( ${NV_URI}FreeBSD-x86_64/${PV}/${AMD64_FBSD_NV_PACKAGE}.tar.gz ) - amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run ) - x86-fbsd? ( ${NV_URI}FreeBSD-x86/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz ) - x86? ( ${NV_URI}Linux-x86/${PV}/${X86_NV_PACKAGE}.run ) -" - -LICENSE="GPL-2 NVIDIA-r2" -SLOT="0" -KEYWORDS="-* amd64 x86 ~amd64-fbsd ~x86-fbsd" -IUSE="acpi multilib kernel_FreeBSD kernel_linux pax_kernel +tools +X uvm" -RESTRICT="bindist mirror strip" -EMULTILIB_PKG="true" - -COMMON=" - app-eselect/eselect-opencl - kernel_linux? ( >=sys-libs/glibc-2.6.1 ) - X? ( - >=app-eselect/eselect-opengl-1.0.9 - ) -" -DEPEND=" - ${COMMON} - app-arch/xz-utils - kernel_linux? ( virtual/linux-sources ) -" -RDEPEND=" - ${COMMON} - acpi? ( sys-power/acpid ) - tools? ( - dev-libs/atk - dev-libs/glib - x11-libs/gdk-pixbuf - >=x11-libs/gtk+-2.4:2 - x11-libs/libX11 - x11-libs/libXext - x11-libs/pango[X] - ) - X? ( - =x11-libs/libvdpau-0.3-r1 - multilib? ( - || ( - ( - >=x11-libs/libX11-1.6.2[abi_x86_32] - >=x11-libs/libXext-1.3.2[abi_x86_32] - ) - app-emulation/emul-linux-x86-xlibs - ) - ) - ) -" - -REQUIRED_USE="tools? ( X )" - -QA_PREBUILT="opt/* usr/lib*" - -S=${WORKDIR}/ - -pkg_pretend() { - - if use amd64 && has_multilib_profile && \ - [ "${DEFAULT_ABI}" != "amd64" ]; then - eerror "This ebuild doesn't currently support changing your default ABI" - die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}" - fi - - if use kernel_linux && kernel_is ge 3 18 ; then - ewarn "Gentoo supports kernels which are supported by NVIDIA" - ewarn "which are limited to the following kernels:" - ewarn " userspace driver config lib - donvidia ${NV_OBJ}/libnvidia-cfg.so ${NV_SOVER} - - # NVIDIA framebuffer capture library - donvidia ${NV_OBJ}/libnvidia-fbc.so ${NV_SOVER} - - # NVIDIA video encode/decode <-> CUDA - if use kernel_linux; then - donvidia ${NV_OBJ}/libnvcuvid.so ${NV_SOVER} - donvidia ${NV_OBJ}/libnvidia-encode.so ${NV_SOVER} - fi - - if use X; then - # Xorg DDX driver - insinto /usr/$(get_libdir)/xorg/modules/drivers - doins ${NV_X11}/nvidia_drv.so - - # Xorg GLX driver - donvidia ${NV_X11}/libglx.so ${NV_SOVER} \ - /usr/$(get_libdir)/opengl/nvidia/extensions - fi - - # OpenCL ICD for NVIDIA - if use kernel_linux; then - insinto /etc/OpenCL/vendors - doins ${NV_OBJ}/nvidia.icd - fi - - # Documentation - dohtml ${NV_DOC}/html/* - if use kernel_FreeBSD; then - dodoc "${NV_DOC}/README" - use X && doman "${NV_MAN}/nvidia-xconfig.1" - use tools && doman "${NV_MAN}/nvidia-settings.1" - else - # Docs - newdoc "${NV_DOC}/README.txt" README - dodoc "${NV_DOC}/NVIDIA_Changelog" - doman "${NV_MAN}/nvidia-smi.1.gz" - use X && doman "${NV_MAN}/nvidia-xconfig.1.gz" - use tools && doman "${NV_MAN}/nvidia-settings.1.gz" - doman "${NV_MAN}/nvidia-cuda-mps-control.1.gz" - fi - - # Helper Apps - exeinto /opt/bin/ - - if use X; then - doexe ${NV_OBJ}/nvidia-xconfig - fi - - if use kernel_linux ; then - doexe ${NV_OBJ}/nvidia-cuda-mps-control - doexe ${NV_OBJ}/nvidia-cuda-mps-server - doexe ${NV_OBJ}/nvidia-debugdump - doexe ${NV_OBJ}/nvidia-persistenced - doexe ${NV_OBJ}/nvidia-smi - - # install nvidia-modprobe setuid and symlink in /usr/bin (bug #505092) - doexe ${NV_OBJ}/nvidia-modprobe - fowners root:video /opt/bin/nvidia-modprobe - fperms 4710 /opt/bin/nvidia-modprobe - dosym /{opt,usr}/bin/nvidia-modprobe - - doman nvidia-cuda-mps-control.1.gz - doman nvidia-modprobe.1.gz - doman nvidia-persistenced.1.gz - newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi - newconfd "${FILESDIR}/nvidia-persistenced.conf" nvidia-persistenced - newinitd "${FILESDIR}/nvidia-persistenced.init" nvidia-persistenced - fi - - if use tools; then - doexe ${NV_OBJ}/nvidia-settings - insinto /usr/share/nvidia/ - doins nvidia-application-profiles-${PV}-key-documentation - insinto /etc/nvidia - newins nvidia-application-profiles-${PV}-rc nvidia-application-profiles-rc - fi - - exeinto /usr/bin/ - doexe ${NV_OBJ}/nvidia-bug-report.sh - - # Desktop entries for nvidia-settings - if use tools ; then - # There is no icon in the FreeBSD tarball. - use kernel_FreeBSD || newicon ${NV_OBJ}/nvidia-settings.png ${PN}-settings.png - domenu "${FILESDIR}"/${PN}-settings.desktop - exeinto /etc/X11/xinit/xinitrc.d - doexe "${FILESDIR}"/95-nvidia-settings - fi - - #doenvd "${FILESDIR}"/50nvidia-prelink-blacklist - - if has_multilib_profile && use multilib ; then - local OABI=${ABI} - for ABI in $(get_install_abis) ; do - src_install-libs - done - ABI=${OABI} - unset OABI - else - src_install-libs - fi - - is_final_abi || die "failed to iterate through all ABIs" - - readme.gentoo_create_doc -} - -src_install-libs() { - local inslibdir=$(get_libdir) - local GL_ROOT="/usr/$(get_libdir)/opengl/nvidia/lib" - local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia" - local libdir=${NV_OBJ} - - if use kernel_linux && has_multilib_profile && \ - [[ ${ABI} == "x86" ]] ; then - libdir=${NV_OBJ}/32 - fi - - if use X; then - # The GLX libraries - donvidia ${libdir}/libEGL.so ${NV_SOVER} ${GL_ROOT} - donvidia ${libdir}/libGL.so ${NV_SOVER} ${GL_ROOT} - donvidia ${libdir}/libGLESv1_CM.so ${NV_SOVER} ${GL_ROOT} - donvidia ${libdir}/libnvidia-eglcore.so ${NV_SOVER} - donvidia ${libdir}/libnvidia-glcore.so ${NV_SOVER} - donvidia ${libdir}/libnvidia-glsi.so ${NV_SOVER} - donvidia ${libdir}/libnvidia-ifr.so ${NV_SOVER} - if use kernel_FreeBSD; then - donvidia ${libdir}/libnvidia-tls.so ${NV_SOVER} - else - donvidia ${libdir}/tls/libnvidia-tls.so ${NV_SOVER} - fi - - # VDPAU - donvidia ${libdir}/libvdpau_nvidia.so ${NV_SOVER} - - # GLES v2 libraries - insinto ${GL_ROOT} - doexe ${libdir}/libGLESv2.so.${PV} - dosym libGLESv2.so.${PV} ${GL_ROOT}/libGLESv2.so.2 - dosym libGLESv2.so.2 ${GL_ROOT}/libGLESv2.so - fi - - # NVIDIA monitoring library - if use kernel_linux ; then - donvidia ${libdir}/libnvidia-ml.so ${NV_SOVER} - fi - - # CUDA & OpenCL - if use kernel_linux; then - donvidia ${libdir}/libcuda.so ${NV_SOVER} - donvidia ${libdir}/libnvidia-compiler.so ${NV_SOVER} - donvidia ${libdir}/libOpenCL.so 1.0.0 ${CL_ROOT} - donvidia ${libdir}/libnvidia-opencl.so ${NV_SOVER} - fi -} - -pkg_preinst() { - if use kernel_linux; then - linux-mod_pkg_preinst - - local videogroup="$(egetent group video | cut -d ':' -f 3)" - if [ -z "${videogroup}" ]; then - eerror "Failed to determine the video group gid" - die "Failed to determine the video group gid" - else - sed -i \ - -e "s:PACKAGE:${PF}:g" \ - -e "s:VIDEOGID:${videogroup}:" \ - "${D}"/etc/modprobe.d/nvidia.conf || die - fi - fi - - # Clean the dynamic libGL stuff's home to ensure - # we dont have stale libs floating around - if [ -d "${ROOT}"/usr/lib/opengl/nvidia ] ; then - rm -rf "${ROOT}"/usr/lib/opengl/nvidia/* - fi - # Make sure we nuke the old nvidia-glx's env.d file - if [ -e "${ROOT}"/etc/env.d/09nvidia ] ; then - rm -f "${ROOT}"/etc/env.d/09nvidia - fi -} - -pkg_postinst() { - use kernel_linux && linux-mod_pkg_postinst - - # Switch to the nvidia implementation - use X && "${ROOT}"/usr/bin/eselect opengl set --use-old nvidia - "${ROOT}"/usr/bin/eselect opencl set --use-old nvidia - - readme.gentoo_print_elog - - if ! use X; then - elog "You have elected to not install the X.org driver. Along with" - elog "this the OpenGL libraries and VDPAU libraries were not" - elog "installed. Additionally, once the driver is loaded your card" - elog "and fan will run at max speed which may not be desirable." - elog "Use the 'nvidia-smi' init script to have your card and fan" - elog "speed scale appropriately." - elog - fi - if ! use tools; then - elog "USE=tools controls whether the nvidia-settings application" - elog "is installed. If you would like to use it, enable that" - elog "flag and re-emerge this ebuild. Optionally you can install" - elog "media-video/nvidia-settings" - elog - fi -} - -pkg_prerm() { - use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11 -} - -pkg_postrm() { - use kernel_linux && linux-mod_pkg_postrm - use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11 -} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-340.65.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-340.65.ebuild deleted file mode 100644 index e3ddaba..0000000 --- a/x11-drivers/nvidia-drivers/nvidia-drivers-340.65.ebuild +++ /dev/null @@ -1,486 +0,0 @@ -# Copyright 1999-2014 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/x11-drivers/nvidia-drivers/nvidia-drivers-340.65.ebuild,v 1.2 2014/12/12 09:45:25 jer Exp $ - -EAPI=5 - -inherit eutils flag-o-matic linux-info linux-mod multilib nvidia-driver \ - portability toolchain-funcs unpacker user udev - -NV_URI="http://us.download.nvidia.com/XFree86/" -X86_NV_PACKAGE="NVIDIA-Linux-x86-${PV}" -AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}" -X86_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86-${PV}" -AMD64_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86_64-${PV}" - -DESCRIPTION="NVIDIA Accelerated Graphics Driver" -HOMEPAGE="http://www.nvidia.com/" -SRC_URI=" - amd64-fbsd? ( ${NV_URI}FreeBSD-x86_64/${PV}/${AMD64_FBSD_NV_PACKAGE}.tar.gz ) - amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run ) - x86-fbsd? ( ${NV_URI}FreeBSD-x86/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz ) - x86? ( ${NV_URI}Linux-x86/${PV}/${X86_NV_PACKAGE}.run ) -" - -LICENSE="GPL-2 NVIDIA-r2" -SLOT="0" -KEYWORDS="-* amd64 x86 ~amd64-fbsd ~x86-fbsd" -IUSE="acpi multilib kernel_FreeBSD kernel_linux pax_kernel +tools +X uvm" -RESTRICT="bindist mirror strip" -EMULTILIB_PKG="true" - -COMMON=" - app-eselect/eselect-opencl - kernel_linux? ( >=sys-libs/glibc-2.6.1 ) - X? ( - >=app-eselect/eselect-opengl-1.0.9 - ) -" -DEPEND=" - ${COMMON} - app-arch/xz-utils - kernel_linux? ( virtual/linux-sources ) -" -RDEPEND=" - ${COMMON} - acpi? ( sys-power/acpid ) - tools? ( - dev-libs/atk - dev-libs/glib - x11-libs/gdk-pixbuf - >=x11-libs/gtk+-2.4:2 - x11-libs/libX11 - x11-libs/libXext - x11-libs/pango[X] - ) - X? ( - =x11-libs/libvdpau-0.3-r1 - multilib? ( - || ( - ( - >=x11-libs/libX11-1.6.2[abi_x86_32] - >=x11-libs/libXext-1.3.2[abi_x86_32] - ) - app-emulation/emul-linux-x86-xlibs - ) - ) - ) -" - -REQUIRED_USE="tools? ( X )" - -QA_PREBUILT="opt/* usr/lib*" - -S=${WORKDIR}/ - -pkg_pretend() { - - if use amd64 && has_multilib_profile && \ - [ "${DEFAULT_ABI}" != "amd64" ]; then - eerror "This ebuild doesn't currently support changing your default ABI" - die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}" - fi - - if use kernel_linux && kernel_is ge 3 18 ; then - ewarn "Gentoo supports kernels which are supported by NVIDIA" - ewarn "which are limited to the following kernels:" - ewarn " userspace driver config lib - donvidia ${NV_OBJ}/libnvidia-cfg.so ${NV_SOVER} - - # NVIDIA framebuffer capture library - donvidia ${NV_OBJ}/libnvidia-fbc.so ${NV_SOVER} - - # NVIDIA video encode/decode <-> CUDA - if use kernel_linux; then - donvidia ${NV_OBJ}/libnvcuvid.so ${NV_SOVER} - donvidia ${NV_OBJ}/libnvidia-encode.so ${NV_SOVER} - fi - - if use X; then - # Xorg DDX driver - insinto /usr/$(get_libdir)/xorg/modules/drivers - doins ${NV_X11}/nvidia_drv.so - - # Xorg GLX driver - donvidia ${NV_X11}/libglx.so ${NV_SOVER} \ - /usr/$(get_libdir)/opengl/nvidia/extensions - fi - - # OpenCL ICD for NVIDIA - if use kernel_linux; then - insinto /etc/OpenCL/vendors - doins ${NV_OBJ}/nvidia.icd - fi - - # Documentation - dohtml ${NV_DOC}/html/* - if use kernel_FreeBSD; then - dodoc "${NV_DOC}/README" - use X && doman "${NV_MAN}/nvidia-xconfig.1" - use tools && doman "${NV_MAN}/nvidia-settings.1" - else - # Docs - newdoc "${NV_DOC}/README.txt" README - dodoc "${NV_DOC}/NVIDIA_Changelog" - doman "${NV_MAN}/nvidia-smi.1.gz" - use X && doman "${NV_MAN}/nvidia-xconfig.1.gz" - use tools && doman "${NV_MAN}/nvidia-settings.1.gz" - doman "${NV_MAN}/nvidia-cuda-mps-control.1.gz" - fi - - # Helper Apps - exeinto /opt/bin/ - - if use X; then - doexe ${NV_OBJ}/nvidia-xconfig - fi - - if use kernel_linux ; then - doexe ${NV_OBJ}/nvidia-cuda-mps-control - doexe ${NV_OBJ}/nvidia-cuda-mps-server - doexe ${NV_OBJ}/nvidia-debugdump - doexe ${NV_OBJ}/nvidia-persistenced - doexe ${NV_OBJ}/nvidia-smi - - # install nvidia-modprobe setuid and symlink in /usr/bin (bug #505092) - doexe ${NV_OBJ}/nvidia-modprobe - fowners root:video /opt/bin/nvidia-modprobe - fperms 4710 /opt/bin/nvidia-modprobe - dosym /{opt,usr}/bin/nvidia-modprobe - - doman nvidia-cuda-mps-control.1.gz - doman nvidia-modprobe.1.gz - doman nvidia-persistenced.1.gz - newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi - newconfd "${FILESDIR}/nvidia-persistenced.conf" nvidia-persistenced - newinitd "${FILESDIR}/nvidia-persistenced.init" nvidia-persistenced - fi - - if use tools; then - doexe ${NV_OBJ}/nvidia-settings - insinto /usr/share/nvidia/ - doins nvidia-application-profiles-${PV}-key-documentation - insinto /etc/nvidia - newins nvidia-application-profiles-${PV}-rc nvidia-application-profiles-rc - fi - - exeinto /usr/bin/ - doexe ${NV_OBJ}/nvidia-bug-report.sh - - # Desktop entries for nvidia-settings - if use tools ; then - # There is no icon in the FreeBSD tarball. - use kernel_FreeBSD || newicon ${NV_OBJ}/nvidia-settings.png ${PN}-settings.png - domenu "${FILESDIR}"/${PN}-settings.desktop - exeinto /etc/X11/xinit/xinitrc.d - doexe "${FILESDIR}"/95-nvidia-settings - fi - - #doenvd "${FILESDIR}"/50nvidia-prelink-blacklist - - if has_multilib_profile && use multilib ; then - local OABI=${ABI} - for ABI in $(get_install_abis) ; do - src_install-libs - done - ABI=${OABI} - unset OABI - else - src_install-libs - fi - - is_final_abi || die "failed to iterate through all ABIs" - - readme.gentoo_create_doc -} - -src_install-libs() { - local inslibdir=$(get_libdir) - local GL_ROOT="/usr/$(get_libdir)/opengl/nvidia/lib" - local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia" - local libdir=${NV_OBJ} - - if use kernel_linux && has_multilib_profile && \ - [[ ${ABI} == "x86" ]] ; then - libdir=${NV_OBJ}/32 - fi - - if use X; then - # The GLX libraries - donvidia ${libdir}/libEGL.so ${NV_SOVER} ${GL_ROOT} - donvidia ${libdir}/libGL.so ${NV_SOVER} ${GL_ROOT} - donvidia ${libdir}/libGLESv1_CM.so ${NV_SOVER} ${GL_ROOT} - donvidia ${libdir}/libnvidia-eglcore.so ${NV_SOVER} - donvidia ${libdir}/libnvidia-glcore.so ${NV_SOVER} - donvidia ${libdir}/libnvidia-glsi.so ${NV_SOVER} - donvidia ${libdir}/libnvidia-ifr.so ${NV_SOVER} - if use kernel_FreeBSD; then - donvidia ${libdir}/libnvidia-tls.so ${NV_SOVER} - else - donvidia ${libdir}/tls/libnvidia-tls.so ${NV_SOVER} - fi - - # VDPAU - donvidia ${libdir}/libvdpau_nvidia.so ${NV_SOVER} - - # GLES v2 libraries - insinto ${GL_ROOT} - doexe ${libdir}/libGLESv2.so.${PV} - dosym libGLESv2.so.${PV} ${GL_ROOT}/libGLESv2.so.2 - dosym libGLESv2.so.2 ${GL_ROOT}/libGLESv2.so - fi - - # NVIDIA monitoring library - if use kernel_linux ; then - donvidia ${libdir}/libnvidia-ml.so ${NV_SOVER} - fi - - # CUDA & OpenCL - if use kernel_linux; then - donvidia ${libdir}/libcuda.so ${NV_SOVER} - donvidia ${libdir}/libnvidia-compiler.so ${NV_SOVER} - donvidia ${libdir}/libOpenCL.so 1.0.0 ${CL_ROOT} - donvidia ${libdir}/libnvidia-opencl.so ${NV_SOVER} - fi -} - -pkg_preinst() { - if use kernel_linux; then - linux-mod_pkg_preinst - - local videogroup="$(egetent group video | cut -d ':' -f 3)" - if [ -z "${videogroup}" ]; then - eerror "Failed to determine the video group gid" - die "Failed to determine the video group gid" - else - sed -i \ - -e "s:PACKAGE:${PF}:g" \ - -e "s:VIDEOGID:${videogroup}:" \ - "${D}"/etc/modprobe.d/nvidia.conf || die - fi - fi - - # Clean the dynamic libGL stuff's home to ensure - # we dont have stale libs floating around - if [ -d "${ROOT}"/usr/lib/opengl/nvidia ] ; then - rm -rf "${ROOT}"/usr/lib/opengl/nvidia/* - fi - # Make sure we nuke the old nvidia-glx's env.d file - if [ -e "${ROOT}"/etc/env.d/09nvidia ] ; then - rm -f "${ROOT}"/etc/env.d/09nvidia - fi -} - -pkg_postinst() { - use kernel_linux && linux-mod_pkg_postinst - - # Switch to the nvidia implementation - use X && "${ROOT}"/usr/bin/eselect opengl set --use-old nvidia - "${ROOT}"/usr/bin/eselect opencl set --use-old nvidia - - readme.gentoo_print_elog - - if ! use X; then - elog "You have elected to not install the X.org driver. Along with" - elog "this the OpenGL libraries and VDPAU libraries were not" - elog "installed. Additionally, once the driver is loaded your card" - elog "and fan will run at max speed which may not be desirable." - elog "Use the 'nvidia-smi' init script to have your card and fan" - elog "speed scale appropriately." - elog - fi - if ! use tools; then - elog "USE=tools controls whether the nvidia-settings application" - elog "is installed. If you would like to use it, enable that" - elog "flag and re-emerge this ebuild. Optionally you can install" - elog "media-video/nvidia-settings" - elog - fi -} - -pkg_prerm() { - use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11 -} - -pkg_postrm() { - use kernel_linux && linux-mod_pkg_postrm - use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11 -} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-340.76.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-340.76.ebuild deleted file mode 100644 index 838848d..0000000 --- a/x11-drivers/nvidia-drivers/nvidia-drivers-340.76.ebuild +++ /dev/null @@ -1,480 +0,0 @@ -# Copyright 1999-2015 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/x11-drivers/nvidia-drivers/nvidia-drivers-340.76.ebuild,v 1.7 2015/05/30 12:30:31 jer Exp $ - -EAPI=5 - -inherit eutils flag-o-matic linux-info linux-mod multilib nvidia-driver \ - portability toolchain-funcs unpacker user udev - -NV_URI="http://us.download.nvidia.com/XFree86/" -X86_NV_PACKAGE="NVIDIA-Linux-x86-${PV}" -AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}" -X86_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86-${PV}" -AMD64_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86_64-${PV}" - -DESCRIPTION="NVIDIA Accelerated Graphics Driver" -HOMEPAGE="http://www.nvidia.com/" -SRC_URI=" - amd64-fbsd? ( ${NV_URI}FreeBSD-x86_64/${PV}/${AMD64_FBSD_NV_PACKAGE}.tar.gz ) - amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run ) - x86-fbsd? ( ${NV_URI}FreeBSD-x86/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz ) - x86? ( ${NV_URI}Linux-x86/${PV}/${X86_NV_PACKAGE}.run ) -" - -LICENSE="GPL-2 NVIDIA-r2" -SLOT="0" -KEYWORDS="-* amd64 x86 ~amd64-fbsd ~x86-fbsd" -IUSE="acpi multilib kernel_FreeBSD kernel_linux pax_kernel +tools +X uvm" -RESTRICT="bindist mirror strip" -EMULTILIB_PKG="true" - -COMMON=" - app-eselect/eselect-opencl - kernel_linux? ( >=sys-libs/glibc-2.6.1 ) - X? ( - >=app-eselect/eselect-opengl-1.0.9 - ) -" -DEPEND=" - ${COMMON} - app-arch/xz-utils - kernel_linux? ( virtual/linux-sources ) -" -RDEPEND=" - ${COMMON} - acpi? ( sys-power/acpid ) - tools? ( - dev-libs/atk - dev-libs/glib:2 - x11-libs/gdk-pixbuf - >=x11-libs/gtk+-2.4:2 - x11-libs/libX11 - x11-libs/libXext - x11-libs/pango[X] - ) - X? ( - =x11-libs/libvdpau-0.3-r1 - multilib? ( - >=x11-libs/libX11-1.6.2[abi_x86_32] - >=x11-libs/libXext-1.3.2[abi_x86_32] - ) - ) -" - -REQUIRED_USE="tools? ( X )" - -QA_PREBUILT="opt/* usr/lib*" - -S=${WORKDIR}/ - -pkg_pretend() { - - if use amd64 && has_multilib_profile && \ - [ "${DEFAULT_ABI}" != "amd64" ]; then - eerror "This ebuild doesn't currently support changing your default ABI" - die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}" - fi - - if use kernel_linux && kernel_is ge 3 18 ; then - ewarn "Gentoo supports kernels which are supported by NVIDIA" - ewarn "which are limited to the following kernels:" - ewarn " userspace driver config lib - donvidia ${NV_OBJ}/libnvidia-cfg.so ${NV_SOVER} - - # NVIDIA framebuffer capture library - donvidia ${NV_OBJ}/libnvidia-fbc.so ${NV_SOVER} - - # NVIDIA video encode/decode <-> CUDA - if use kernel_linux; then - donvidia ${NV_OBJ}/libnvcuvid.so ${NV_SOVER} - donvidia ${NV_OBJ}/libnvidia-encode.so ${NV_SOVER} - fi - - if use X; then - # Xorg DDX driver - insinto /usr/$(get_libdir)/xorg/modules/drivers - doins ${NV_X11}/nvidia_drv.so - - # Xorg GLX driver - donvidia ${NV_X11}/libglx.so ${NV_SOVER} \ - /usr/$(get_libdir)/opengl/nvidia/extensions - fi - - # OpenCL ICD for NVIDIA - if use kernel_linux; then - insinto /etc/OpenCL/vendors - doins ${NV_OBJ}/nvidia.icd - fi - - # Documentation - dohtml ${NV_DOC}/html/* - if use kernel_FreeBSD; then - dodoc "${NV_DOC}/README" - use X && doman "${NV_MAN}/nvidia-xconfig.1" - use tools && doman "${NV_MAN}/nvidia-settings.1" - else - # Docs - newdoc "${NV_DOC}/README.txt" README - dodoc "${NV_DOC}/NVIDIA_Changelog" - doman "${NV_MAN}/nvidia-smi.1.gz" - use X && doman "${NV_MAN}/nvidia-xconfig.1.gz" - use tools && doman "${NV_MAN}/nvidia-settings.1.gz" - doman "${NV_MAN}/nvidia-cuda-mps-control.1.gz" - fi - - # Helper Apps - exeinto /opt/bin/ - - if use X; then - doexe ${NV_OBJ}/nvidia-xconfig - fi - - if use kernel_linux ; then - doexe ${NV_OBJ}/nvidia-cuda-mps-control - doexe ${NV_OBJ}/nvidia-cuda-mps-server - doexe ${NV_OBJ}/nvidia-debugdump - doexe ${NV_OBJ}/nvidia-persistenced - doexe ${NV_OBJ}/nvidia-smi - - # install nvidia-modprobe setuid and symlink in /usr/bin (bug #505092) - doexe ${NV_OBJ}/nvidia-modprobe - fowners root:video /opt/bin/nvidia-modprobe - fperms 4710 /opt/bin/nvidia-modprobe - dosym /{opt,usr}/bin/nvidia-modprobe - - doman nvidia-cuda-mps-control.1.gz - doman nvidia-modprobe.1.gz - doman nvidia-persistenced.1.gz - newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi - newconfd "${FILESDIR}/nvidia-persistenced.conf" nvidia-persistenced - newinitd "${FILESDIR}/nvidia-persistenced.init" nvidia-persistenced - fi - - if use tools; then - doexe ${NV_OBJ}/nvidia-settings - insinto /usr/share/nvidia/ - doins nvidia-application-profiles-${PV}-key-documentation - insinto /etc/nvidia - newins nvidia-application-profiles-${PV}-rc nvidia-application-profiles-rc - fi - - dobin ${NV_OBJ}/nvidia-bug-report.sh - - # Desktop entries for nvidia-settings - if use tools ; then - # There is no icon in the FreeBSD tarball. - use kernel_FreeBSD || newicon ${NV_OBJ}/nvidia-settings.png ${PN}-settings.png - domenu "${FILESDIR}"/${PN}-settings.desktop - exeinto /etc/X11/xinit/xinitrc.d - doexe "${FILESDIR}"/95-nvidia-settings - fi - - #doenvd "${FILESDIR}"/50nvidia-prelink-blacklist - - if has_multilib_profile && use multilib ; then - local OABI=${ABI} - for ABI in $(get_install_abis) ; do - src_install-libs - done - ABI=${OABI} - unset OABI - else - src_install-libs - fi - - is_final_abi || die "failed to iterate through all ABIs" - - readme.gentoo_create_doc -} - -src_install-libs() { - local inslibdir=$(get_libdir) - local GL_ROOT="/usr/$(get_libdir)/opengl/nvidia/lib" - local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia" - local libdir=${NV_OBJ} - - if use kernel_linux && has_multilib_profile && \ - [[ ${ABI} == "x86" ]] ; then - libdir=${NV_OBJ}/32 - fi - - if use X; then - # The GLX libraries - donvidia ${libdir}/libEGL.so ${NV_SOVER} ${GL_ROOT} - donvidia ${libdir}/libGL.so ${NV_SOVER} ${GL_ROOT} - donvidia ${libdir}/libGLESv1_CM.so ${NV_SOVER} ${GL_ROOT} - donvidia ${libdir}/libnvidia-eglcore.so ${NV_SOVER} - donvidia ${libdir}/libnvidia-glcore.so ${NV_SOVER} - donvidia ${libdir}/libnvidia-glsi.so ${NV_SOVER} - donvidia ${libdir}/libnvidia-ifr.so ${NV_SOVER} - if use kernel_FreeBSD; then - donvidia ${libdir}/libnvidia-tls.so ${NV_SOVER} - else - donvidia ${libdir}/tls/libnvidia-tls.so ${NV_SOVER} - fi - - # VDPAU - donvidia ${libdir}/libvdpau_nvidia.so ${NV_SOVER} - - # GLES v2 libraries - insinto ${GL_ROOT} - doexe ${libdir}/libGLESv2.so.${PV} - dosym libGLESv2.so.${PV} ${GL_ROOT}/libGLESv2.so.2 - dosym libGLESv2.so.2 ${GL_ROOT}/libGLESv2.so - fi - - # NVIDIA monitoring library - if use kernel_linux ; then - donvidia ${libdir}/libnvidia-ml.so ${NV_SOVER} - fi - - # CUDA & OpenCL - if use kernel_linux; then - donvidia ${libdir}/libcuda.so ${NV_SOVER} - donvidia ${libdir}/libnvidia-compiler.so ${NV_SOVER} - donvidia ${libdir}/libOpenCL.so 1.0.0 ${CL_ROOT} - donvidia ${libdir}/libnvidia-opencl.so ${NV_SOVER} - fi -} - -pkg_preinst() { - if use kernel_linux; then - linux-mod_pkg_preinst - - local videogroup="$(egetent group video | cut -d ':' -f 3)" - if [ -z "${videogroup}" ]; then - eerror "Failed to determine the video group gid" - die "Failed to determine the video group gid" - else - sed -i \ - -e "s:PACKAGE:${PF}:g" \ - -e "s:VIDEOGID:${videogroup}:" \ - "${D}"/etc/modprobe.d/nvidia.conf || die - fi - fi - - # Clean the dynamic libGL stuff's home to ensure - # we dont have stale libs floating around - if [ -d "${ROOT}"/usr/lib/opengl/nvidia ] ; then - rm -rf "${ROOT}"/usr/lib/opengl/nvidia/* - fi - # Make sure we nuke the old nvidia-glx's env.d file - if [ -e "${ROOT}"/etc/env.d/09nvidia ] ; then - rm -f "${ROOT}"/etc/env.d/09nvidia - fi -} - -pkg_postinst() { - use kernel_linux && linux-mod_pkg_postinst - - # Switch to the nvidia implementation - use X && "${ROOT}"/usr/bin/eselect opengl set --use-old nvidia - "${ROOT}"/usr/bin/eselect opencl set --use-old nvidia - - readme.gentoo_print_elog - - if ! use X; then - elog "You have elected to not install the X.org driver. Along with" - elog "this the OpenGL libraries and VDPAU libraries were not" - elog "installed. Additionally, once the driver is loaded your card" - elog "and fan will run at max speed which may not be desirable." - elog "Use the 'nvidia-smi' init script to have your card and fan" - elog "speed scale appropriately." - elog - fi - if ! use tools; then - elog "USE=tools controls whether the nvidia-settings application" - elog "is installed. If you would like to use it, enable that" - elog "flag and re-emerge this ebuild. Optionally you can install" - elog "media-video/nvidia-settings" - elog - fi -} - -pkg_prerm() { - use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11 -} - -pkg_postrm() { - use kernel_linux && linux-mod_pkg_postrm - use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11 -}