Click here to close now.

Welcome!

Linux Authors: Pat Romanski, Liz McMillan, Carmen Gonzalez, JP Morgenthal, AppDynamics Blog

Related Topics: Linux

Linux: Article

How to make an Nvidia GeForce work with a Linux 2.5 kernel

The Nvidia accelerated driver is not an official part of the kernel source tree. How to make it part of yours.

(LinuxWorld) -- If you have an Nvidia GeForce card and you're using it to play games under Linux, then you must be using the Nvidia Linux drivers for your card. (See resources for links to previous columns covering these drivers.) Playing games like Unreal Tournament and Quake 3 is nothing like living dangerously, unless you're playing them at work and your boss happens to drop by. If you really want to live dangerously, however, you should try playing them with a kernel from the latest development branch, 2.5.

You probably can't, because the Nvidia accelerated driver won't compile with the latest 2.5 kernels. At least, not until you follow the tips in this column. (Although I make no guarantees -- what works on my system may not work on yours.)

Kernel tree tangent

In case you're reasonably new to Linux, here's how the kernels progress. The latest version 2.0.x kernel (currently at 2.0.39 as of this writing) is the oldest but theoretically the most stable Linux kernel available. Naturally, it lacks some of the features and hardware support available in later kernels. The 2.2.x branch (the latest of which is currently 2.2.20) is also extremely stable but it, too, lacks features and hardware support you can find in later kernels. The most recent stable branch is 2.4.x, of which 2.4.17 is the latest. Some folks do not consider 2.4 to be as stable a branch of kernels as the previous stable branches, but with a few exceptions the 2.4 kernels have been working extremely well for my limited needs.

You probably noticed by now the second numbers in all stable branches are even numbers, such as 2.0, 2.2, and 2.4. The even number tells you that you are using what is considered a stable kernel. The odd numbers in between tell you the kernel is still in development. For example, the development branch 2.1.x existed long before the first 2.2.x kernel was released. (Coincidentally, the first number, 2, is even, but that has no meaning. It will change when Linux gets to version 3.0.)

Version 2.5 is the latest development branch. Here's the problem. There are many significant changes scheduled for the 2.6 release of the Linux kernel, and these changes are being merged in to 2.5 little by little. Many of them are under the hood changes that most people won't know are there. However, kernel developers are keenly aware of these changes, because the changes break a lot of the existing kernel code. Someone eventually finds these problems, fixes them, and submits a patch for the 2.5 source code branch.

Nvidia offers its accelerated driver as a combination of source code and binary code. The 2.5 branch broke the source code portion of the Nvidia driver. Actually, the latest 2.4 kernels also broke the Nvidia driver, but not to the same extent as 2.5.

The Nvidia code is fixable. However, the Nvidia accelerated driver is not an official part of the kernel source tree. It isn't even licensed under the GPL. You may not submit a patch to the kernel to fix this driver because the Linux kernel developers don't manage it.

Tweaking Nvidia's nose

What you can do, however, is post a patch on the kernel development list so others can apply and use the patch if they wish. You can publish the patch in an article, like this one.

Does this violate the Nvidia license? I have no idea. This author wagers Nvidia isn't likely to be bent out of shape by a patch that allows more Linux users to purchase and use Nvidia-based display cards.

I wrote my own patches to the Nvidia source code to get it to compile under the latest 2.4 kernels and 2.5 kernels. I must admit Martin Huenniger did a much better job with the patch he submitted to the kernel mailing list. It is more complete than mine is, and it compiles for both the latest 2.4 and 2.5 kernels. (I haven't tried it with the latest 2.5 branch yet, but Martin claims it works). The patch below is therefore a modification of Martin's version (I fixed one minor error in his patch).

The patch is against the 2314 version of the Nvidia kernel driver. Here's how to apply it. The easiest way is to boot to the version of the kernel for which you want to create this driver. Save the patch text below to a file called nvidia.patch and place that file in the directory right above your NVIDIA 2314 kernel source directory. Change to the NVIDIA kernel source directory and enter the command cat ../nvidia.patch | patch -p1 --dry-run. If everything looks like it worked, do it again without the --dry-run switch. Then run make clean and make install.

If it's going to work at all, you should be able to see the NVdriver module in the list of installed modules (use the command lsmod to get a list of installed modules). In some cases, you may have to install the module yourself with the command modprobe NVdriver, and then check with lsmod to see if it worked.

Finally, it is possible the patch below won't work at all for you if something about the white space (spaces and tabs) is changed by publishing it on LinuxWorld or by your browser. I'll place a gzipped version of the patch in the downloads section of www.varlinux.org just in case you have problems. Enjoy, and let me know how or if it works for you. (Editor's note: Readers can also find a text-only version of the following at http://www.linuxworld.com/site-stories/2002/0222.nvidiacode.txt.)

diff -Nru NVIDIA_kernel-1.0-2314/nv.c NVIDIA_kernel-1.0-2314.new/nv.c
--- NVIDIA_kernel-1.0-2314/nv.c  Fri Nov 30 20:11:06 2001
+++ NVIDIA_kernel-1.0-2314.new/nv.c Wed Feb 20 11:54:56 2002
@@ -50,6 +50,13 @@
#include 
#endif

+/* Since 2.5.x this is needed for the coorect lookup of the page table entry */ + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) +#include +#include +#endif + #include #include // pte bit definitions #include // cli(), *_flags @@ -1146,11 +1153,23 @@

/* for control device, just jump to its open routine */ /* after setting up the private data */ + + /* I don't really know the correct kernel version since when it changed */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) if (NV_DEVICE_IS_CONTROL_DEVICE(inode->i_rdev)) return nv_kern_ctl_open(inode, file); +#else + if (NV_DEVICE_IS_CONTROL_DEVICE(kdev_val(inode->i_rdev))) + return nv_kern_ctl_open(inode, file); +#endif

/* what device are we talking about? */ - devnum = NV_DEVICE_NUMBER(inode->i_rdev); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) + devnum = NV_DEVICE_NUMBER(inode->i_rdev); +#else + devnum = NV_DEVICE_NUMBER(kdev_val(inode->i_rdev)); +#endif if (devnum >= NV_MAX_DEVICES) { rc = -ENODEV; @@ -1257,8 +1276,14 @@

/* for control device, just jump to its open routine */ /* after setting up the private data */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) if (NV_DEVICE_IS_CONTROL_DEVICE(inode->i_rdev)) return nv_kern_ctl_close(inode, file); +#else + if(NV_DEVICE_IS_CONTROL_DEVICE(kdev_val(inode->i_rdev))) + return nv_kern_ctl_close(inode, file); +#endif

NV_DMSG(nv, "close");

@@ -1383,11 +1408,21 @@ #if defined(IA64) vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); #endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) if (remap_page_range(vma->vm_start, (u32) (nv->reg_physical_address) + LINUX_VMA_OFFS(vma) - NV_MMAP_REG_OFFSET, vma->vm_end - vma->vm_start, vma->vm_page_prot)) return -EAGAIN; +#else + if (remap_page_range(vma, + vma->vm_start, + (u32) (nv->reg_physical_address) + LINUX_VMA_OFFS(vma) - NV_MMAP_REG_OFFSET, + vma->vm_end - vma->vm_start, + vma->vm_page_prot)) + return -EAGAIN; +#endif

/* mark it as IO so that we don't dump it on core dump */ vma->vm_flags |= VM_IO; @@ -1400,11 +1435,21 @@ #if defined(IA64) vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); #endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) if (remap_page_range(vma->vm_start, (u32) (nv->fb_physical_address) + LINUX_VMA_OFFS(vma) - NV_MMAP_FB_OFFSET, vma->vm_end - vma->vm_start, vma->vm_page_prot)) return -EAGAIN; +#else + if (remap_page_range(vma, + vma->vm_start, + (u32) (nv->fb_physical_address) + LINUX_VMA_OFFS(vma) - NV_MMAP_FB_OFFSET, + vma->vm_end - vma->vm_start, + vma->vm_page_prot)) + return -EAGAIN; +#endif

// mark it as IO so that we don't dump it on core dump vma->vm_flags |= VM_IO; @@ -1435,8 +1480,14 @@ while (pages--) { page = (unsigned long) at->page_table[i++]; + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) if (remap_page_range(start, page, PAGE_SIZE, PAGE_SHARED)) return -EAGAIN; +#else + if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) + return -EAGAIN; +#endif start += PAGE_SIZE; pos += PAGE_SIZE; } @@ -2298,7 +2349,11 @@ if (pmd_none(*pg_mid_dir)) goto failed;

+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) pg_table = pte_offset(pg_mid_dir, address); +#else + pg_table = pte_offset_map(pg_mid_dir, address); +#endif if (!pte_present(*pg_table)) goto failed;

diff -Nru NVIDIA_kernel-1.0-2314/os-interface.c NVIDIA_kernel-1.0-2314.new/os-interface.c --- NVIDIA_kernel-1.0-2314/os-interface.c Fri Nov 30 20:11:06 2001 +++ NVIDIA_kernel-1.0-2314.new/os-interface.c Wed Feb 20 11:52:23 2002 @@ -1445,9 +1445,15 @@

uaddr = *priv;

- /* finally, let's do it! */ - err = remap_page_range( (size_t) uaddr, (size_t) paddr, size_bytes, - PAGE_SHARED); + /* finally, let's do it! */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) + err = remap_page_range( (size_t) uaddr, (size_t) paddr, size_bytes, + PAGE_SHARED); +#else + err = remap_page_range( kaddr, (size_t) uaddr, (size_t) paddr, size_bytes, + PAGE_SHARED); +#endif

if (err != 0) { @@ -1473,9 +1479,14 @@

uaddr = *priv;

- /* finally, let's do it! */ - err = remap_page_range( (size_t) uaddr, (size_t) start, size_bytes, + /* finally, let's do it! */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) + err = remap_page_range( (size_t) uaddr, (size_t) start, size_bytes, + PAGE_SHARED); +#else + err = remap_page_range( *priv, (size_t) uaddr, (size_t) start, size_bytes, PAGE_SHARED); +#endif

if (err != 0) { @@ -2027,13 +2038,25 @@

agp_addr = agpinfo.aper_base + (agp_data->offset << PAGE_SHIFT);

+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) err = remap_page_range(vma->vm_start, (size_t) agp_addr, agp_data->num_pages << PAGE_SHIFT, #if defined(IA64) vma->vm_page_prot); #else PAGE_SHARED); -#endif +#endif /* IA64 */ + +#else + err = remap_page_range(vma, + vma->vm_start, (size_t) agp_addr, + agp_data->num_pages << PAGE_SHIFT, +#if defined(IA64) + vma->vm_page_prot); +#else + PAGE_SHARED); +#endif /* IA64 */ +#endif /* LINUX_VERSION_CODE */

if (err) { printk(KERN_ERR "NVRM: AGPGART: unable to remap %lu pages\n",

One final question

As much as I like my GeForce 3 card, I am under the impression ATI is more amenable to open source development. I also heard the ATI Radeon 8500 is a killer display card, often beating the best GeForce cards in terms of quality and speed. If it is true the ATI drivers are open source (or closer to being open source than Nvidia's), it may be worth the switch at some point.

Are there any ATI users out there who can confirm or refute the above claims? Are you happy with your card? Did you have any trouble getting it working under Linux? Can you play accelerated 3D games in Linux with this card? Drop me a line, and I'll pass along any interesting information you share.

More Stories By Nicholas Petreley

Nicholas Petreley is a computer consultant and author in Asheville, NC.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


@ThingsExpo Stories
With major technology companies and startups seriously embracing IoT strategies, now is the perfect time to attend @ThingsExpo in Silicon Valley. Learn what is going on, contribute to the discussions, and ensure that your enterprise is as "IoT-Ready" as it can be! Internet of @ThingsExpo, taking place Nov 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 17th Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal an...
P2P RTC will impact the landscape of communications, shifting from traditional telephony style communications models to OTT (Over-The-Top) cloud assisted & PaaS (Platform as a Service) communication services. The P2P shift will impact many areas of our lives, from mobile communication, human interactive web services, RTC and telephony infrastructure, user federation, security and privacy implications, business costs, and scalability. In his session at @ThingsExpo, Robin Raymond, Chief Architect at Hookflash, will walk through the shifting landscape of traditional telephone and voice services ...
The 17th International Cloud Expo has announced that its Call for Papers is open. 17th International Cloud Expo, to be held November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, brings together Cloud Computing, APM, APIs, Microservices, Security, Big Data, Internet of Things, DevOps and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding business opportunity. Submit your speaking proposal today!
Explosive growth in connected devices. Enormous amounts of data for collection and analysis. Critical use of data for split-second decision making and actionable information. All three are factors in making the Internet of Things a reality. Yet, any one factor would have an IT organization pondering its infrastructure strategy. How should your organization enhance its IT framework to enable an Internet of Things implementation? In his session at Internet of @ThingsExpo, James Kirkland, Chief Architect for the Internet of Things and Intelligent Systems at Red Hat, described how to revolutioniz...
All major researchers estimate there will be tens of billions devices - computers, smartphones, tablets, and sensors - connected to the Internet by 2020. This number will continue to grow at a rapid pace for the next several decades. With major technology companies and startups seriously embracing IoT strategies, now is the perfect time to attend @ThingsExpo, June 9-11, 2015, at the Javits Center in New York City. Learn what is going on, contribute to the discussions, and ensure that your enterprise is as "IoT-Ready" as it can be
The security devil is always in the details of the attack: the ones you've endured, the ones you prepare yourself to fend off, and the ones that, you fear, will catch you completely unaware and defenseless. The Internet of Things (IoT) is nothing if not an endless proliferation of details. It's the vision of a world in which continuous Internet connectivity and addressability is embedded into a growing range of human artifacts, into the natural world, and even into our smartphones, appliances, and physical persons. In the IoT vision, every new "thing" - sensor, actuator, data source, data con...
Container frameworks, such as Docker, provide a variety of benefits, including density of deployment across infrastructure, convenience for application developers to push updates with low operational hand-holding, and a fairly well-defined deployment workflow that can be orchestrated. Container frameworks also enable a DevOps approach to application development by cleanly separating concerns between operations and development teams. But running multi-container, multi-server apps with containers is very hard. You have to learn five new and different technologies and best practices (libswarm, sy...
SYS-CON Events announced today that DragonGlass, an enterprise search platform, will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. After eleven years of designing and building custom applications, OpenCrowd has launched DragonGlass, a cloud-based platform that enables the development of search-based applications. These are a new breed of applications that utilize a search index as their backbone for data retrieval. They can easily adapt to new data sets and provide access to both structured and unstruc...
There's Big Data, then there's really Big Data from the Internet of Things. IoT is evolving to include many data possibilities like new types of event, log and network data. The volumes are enormous, generating tens of billions of logs per day, which raise data challenges. Early IoT deployments are relying heavily on both the cloud and managed service providers to navigate these challenges. In her session at Big Data Expo®, Hannah Smalltree, Director at Treasure Data, discussed how IoT, Big Data and deployments are processing massive data volumes from wearables, utilities and other machines...
Buzzword alert: Microservices and IoT at a DevOps conference? What could possibly go wrong? In this Power Panel at DevOps Summit, moderated by Jason Bloomberg, the leading expert on architecting agility for the enterprise and president of Intellyx, panelists will peel away the buzz and discuss the important architectural principles behind implementing IoT solutions for the enterprise. As remote IoT devices and sensors become increasingly intelligent, they become part of our distributed cloud environment, and we must architect and code accordingly. At the very least, you'll have no problem fil...
SYS-CON Events announced today that MetraTech, now part of Ericsson, has been named “Silver Sponsor” of SYS-CON's 16th International Cloud Expo®, which will take place on June 9–11, 2015, at the Javits Center in New York, NY. Ericsson is the driving force behind the Networked Society- a world leader in communications infrastructure, software and services. Some 40% of the world’s mobile traffic runs through networks Ericsson has supplied, serving more than 2.5 billion subscribers.
The 4th International Internet of @ThingsExpo, co-located with the 17th International Cloud Expo - to be held November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA - announces that its Call for Papers is open. The Internet of Things (IoT) is the biggest idea since the creation of the Worldwide Web more than 20 years ago.
The worldwide cellular network will be the backbone of the future IoT, and the telecom industry is clamoring to get on board as more than just a data pipe. In his session at @ThingsExpo, Evan McGee, CTO of Ring Plus, Inc., discussed what service operators can offer that would benefit IoT entrepreneurs, inventors, and consumers. Evan McGee is the CTO of RingPlus, a leading innovative U.S. MVNO and wireless enabler. His focus is on combining web technologies with traditional telecom to create a new breed of unified communication that is easily accessible to the general consumer. With over a de...
Disruptive macro trends in technology are impacting and dramatically changing the "art of the possible" relative to supply chain management practices through the innovative use of IoT, cloud, machine learning and Big Data to enable connected ecosystems of engagement. Enterprise informatics can now move beyond point solutions that merely monitor the past and implement integrated enterprise fabrics that enable end-to-end supply chain visibility to improve customer service delivery and optimize supplier management. Learn about enterprise architecture strategies for designing connected systems tha...
Cloud is not a commodity. And no matter what you call it, computing doesn’t come out of the sky. It comes from physical hardware inside brick and mortar facilities connected by hundreds of miles of networking cable. And no two clouds are built the same way. SoftLayer gives you the highest performing cloud infrastructure available. One platform that takes data centers around the world that are full of the widest range of cloud computing options, and then integrates and automates everything. Join SoftLayer on June 9 at 16th Cloud Expo to learn about IBM Cloud's SoftLayer platform, explore se...
SYS-CON Media announced today that 9 out of 10 " most read" DevOps articles are published by @DevOpsSummit Blog. Launched in October 2014, @DevOpsSummit Blog offers top articles, news stories, and blog posts from the world's well-known experts and guarantees better exposure for its authors than any other publication. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to wait for long development cycles that produce softw...
15th Cloud Expo, which took place Nov. 4-6, 2014, at the Santa Clara Convention Center in Santa Clara, CA, expanded the conference content of @ThingsExpo, Big Data Expo, and DevOps Summit to include two developer events. IBM held a Bluemix Developer Playground on November 5 and ElasticBox held a Hackathon on November 6. Both events took place on the expo floor. The Bluemix Developer Playground, for developers of all levels, highlighted the ease of use of Bluemix, its services and functionality and provide short-term introductory projects that developers can complete between sessions.
From telemedicine to smart cars, digital homes and industrial monitoring, the explosive growth of IoT has created exciting new business opportunities for real time calls and messaging. In his session at @ThingsExpo, Ivelin Ivanov, CEO and Co-Founder of Telestax, shared some of the new revenue sources that IoT created for Restcomm – the open source telephony platform from Telestax. Ivelin Ivanov is a technology entrepreneur who founded Mobicents, an Open Source VoIP Platform, to help create, deploy, and manage applications integrating voice, video and data. He is the co-founder of TeleStax, a...
The Internet of Things (IoT) promises to evolve the way the world does business; however, understanding how to apply it to your company can be a mystery. Most people struggle with understanding the potential business uses or tend to get caught up in the technology, resulting in solutions that fail to meet even minimum business goals. In his session at @ThingsExpo, Jesse Shiah, CEO / President / Co-Founder of AgilePoint Inc., showed what is needed to leverage the IoT to transform your business. He discussed opportunities and challenges ahead for the IoT from a market and technical point of vie...
Grow your business with enterprise wearable apps using SAP Platforms and Google Glass. SAP and Google just launched the SAP and Google Glass Challenge, an opportunity for you to innovate and develop the best Enterprise Wearable App using SAP Platforms and Google Glass and gain valuable market exposure. In his session at @ThingsExpo, Brian McPhail, Senior Director of Business Development, ISVs & Digital Commerce at SAP, outlined the timeline of the SAP Google Glass Challenge and the opportunity for developers, start-ups, and companies of all sizes to engage with SAP today.