Click here to close now.


Linux Containers Authors: Don MacVittie, JP Morgenthal, Ken Simpson, Pat Romanski, Dana Gardner

Related Topics: Linux Containers

Linux Containers: 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 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

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

+/* 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/os-interface.c Fri Nov 30 20:11:06 2001 +++ 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
Today air travel is a minefield of delays, hassles and customer disappointment. Airlines struggle to revitalize the experience. GE and M2Mi will demonstrate practical examples of how IoT solutions are helping airlines bring back personalization, reduce trip time and improve reliability. In their session at @ThingsExpo, Shyam Varan Nath, Principal Architect with GE, and Dr. Sarah Cooper, M2Mi’s VP Business Development and Engineering, explored the IoT cloud-based platform technologies driving this change including privacy controls, data transparency and integration of real time context with p...
The Internet of Things (IoT) is growing rapidly by extending current technologies, products and networks. By 2020, Cisco estimates there will be 50 billion connected devices. Gartner has forecast revenues of over $300 billion, just to IoT suppliers. Now is the time to figure out how you’ll make money – not just create innovative products. With hundreds of new products and companies jumping into the IoT fray every month, there’s no shortage of innovation. Despite this, McKinsey/VisionMobile data shows "less than 10 percent of IoT developers are making enough to support a reasonably sized team....
Internet of @ThingsExpo, taking place June 7-9, 2016 at Javits Center, New York City and Nov 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with the 18th International @CloudExpo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world and ThingsExpo New York Call for Papers is now open.
With major technology companies and startups seriously embracing IoT strategies, now is the perfect time to attend @ThingsExpo 2016 in New York and 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 cha...
Just over a week ago I received a long and loud sustained applause for a presentation I delivered at this year’s Cloud Expo in Santa Clara. I was extremely pleased with the turnout and had some very good conversations with many of the attendees. Over the next few days I had many more meaningful conversations and was not only happy with the results but also learned a few new things. Here is everything I learned in those three days distilled into three short points.
DevOps is about increasing efficiency, but nothing is more inefficient than building the same application twice. However, this is a routine occurrence with enterprise applications that need both a rich desktop web interface and strong mobile support. With recent technological advances from Isomorphic Software and others, rich desktop and tuned mobile experiences can now be created with a single codebase – without compromising functionality, performance or usability. In his session at DevOps Summit, Charles Kendrick, CTO and Chief Architect at Isomorphic Software, demonstrated examples of com...
As organizations realize the scope of the Internet of Things, gaining key insights from Big Data, through the use of advanced analytics, becomes crucial. However, IoT also creates the need for petabyte scale storage of data from millions of devices. A new type of Storage is required which seamlessly integrates robust data analytics with massive scale. These storage systems will act as “smart systems” provide in-place analytics that speed discovery and enable businesses to quickly derive meaningful and actionable insights. In his session at @ThingsExpo, Paul Turner, Chief Marketing Officer at...
In his keynote at @ThingsExpo, Chris Matthieu, Director of IoT Engineering at Citrix and co-founder and CTO of Octoblu, focused on building an IoT platform and company. He provided a behind-the-scenes look at Octoblu’s platform, business, and pivots along the way (including the Citrix acquisition of Octoblu).
In his General Session at 17th Cloud Expo, Bruce Swann, Senior Product Marketing Manager for Adobe Campaign, explored the key ingredients of cross-channel marketing in a digital world. Learn how the Adobe Marketing Cloud can help marketers embrace opportunities for personalized, relevant and real-time customer engagement across offline (direct mail, point of sale, call center) and digital (email, website, SMS, mobile apps, social networks, connected objects).
The Internet of Everything is re-shaping technology trends–moving away from “request/response” architecture to an “always-on” Streaming Web where data is in constant motion and secure, reliable communication is an absolute necessity. As more and more THINGS go online, the challenges that developers will need to address will only increase exponentially. In his session at @ThingsExpo, Todd Greene, Founder & CEO of PubNub, exploreed the current state of IoT connectivity and review key trends and technology requirements that will drive the Internet of Things from hype to reality.
Two weeks ago (November 3-5), I attended the Cloud Expo Silicon Valley as a speaker, where I presented on the security and privacy due diligence requirements for cloud solutions. Cloud security is a topical issue for every CIO, CISO, and technology buyer. Decision-makers are always looking for insights on how to mitigate the security risks of implementing and using cloud solutions. Based on the presentation topics covered at the conference, as well as the general discussions heard between sessions, I wanted to share some of my observations on emerging trends. As cyber security serves as a fou...
Continuous processes around the development and deployment of applications are both impacted by -- and a benefit to -- the Internet of Things trend. To help better understand the relationship between DevOps and a plethora of new end-devices and data please welcome Gary Gruver, consultant, author and a former IT executive who has led many large-scale IT transformation projects, and John Jeremiah, Technology Evangelist at Hewlett Packard Enterprise (HPE), on Twitter at @j_jeremiah. The discussion is moderated by me, Dana Gardner, Principal Analyst at Interarbor Solutions.
Too often with compelling new technologies market participants become overly enamored with that attractiveness of the technology and neglect underlying business drivers. This tendency, what some call the “newest shiny object syndrome” is understandable given that virtually all of us are heavily engaged in technology. But it is also mistaken. Without concrete business cases driving its deployment, IoT, like many other technologies before it, will fade into obscurity.
With all the incredible momentum behind the Internet of Things (IoT) industry, it is easy to forget that not a single CEO wakes up and wonders if “my IoT is broken.” What they wonder is if they are making the right decisions to do all they can to increase revenue, decrease costs, and improve customer experience – effectively the same challenges they have always had in growing their business. The exciting thing about the IoT industry is now these decisions can be better, faster, and smarter. Now all corporate assets – people, objects, and spaces – can share information about themselves and thei...
The Internet of Things is clearly many things: data collection and analytics, wearables, Smart Grids and Smart Cities, the Industrial Internet, and more. Cool platforms like Arduino, Raspberry Pi, Intel's Galileo and Edison, and a diverse world of sensors are making the IoT a great toy box for developers in all these areas. In this Power Panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists discussed what things are the most important, which will have the most profound effect on the world, and what should we expect to see over the next couple of years.
Discussions of cloud computing have evolved in recent years from a focus on specific types of cloud, to a world of hybrid cloud, and to a world dominated by the APIs that make today's multi-cloud environments and hybrid clouds possible. In this Power Panel at 17th Cloud Expo, moderated by Conference Chair Roger Strukhoff, panelists addressed the importance of customers being able to use the specific technologies they need, through environments and ecosystems that expose their APIs to make true change and transformation possible.
Microservices are a very exciting architectural approach that many organizations are looking to as a way to accelerate innovation. Microservices promise to allow teams to move away from monolithic "ball of mud" systems, but the reality is that, in the vast majority of organizations, different projects and technologies will continue to be developed at different speeds. How to handle the dependencies between these disparate systems with different iteration cycles? Consider the "canoncial problem" in this scenario: microservice A (releases daily) depends on a couple of additions to backend B (re...
Growth hacking is common for startups to make unheard-of progress in building their business. Career Hacks can help Geek Girls and those who support them (yes, that's you too, Dad!) to excel in this typically male-dominated world. Get ready to learn the facts: Is there a bias against women in the tech / developer communities? Why are women 50% of the workforce, but hold only 24% of the STEM or IT positions? Some beginnings of what to do about it! In her Day 2 Keynote at 17th Cloud Expo, Sandy Carter, IBM General Manager Cloud Ecosystem and Developers, and a Social Business Evangelist, wil...
PubNub has announced the release of BLOCKS, a set of customizable microservices that give developers a simple way to add code and deploy features for realtime apps.PubNub BLOCKS executes business logic directly on the data streaming through PubNub’s network without splitting it off to an intermediary server controlled by the customer. This revolutionary approach streamlines app development, reduces endpoint-to-endpoint latency, and allows apps to better leverage the enormous scalability of PubNub’s Data Stream Network.
The cloud. Like a comic book superhero, there seems to be no problem it can’t fix or cost it can’t slash. Yet making the transition is not always easy and production environments are still largely on premise. Taking some practical and sensible steps to reduce risk can also help provide a basis for a successful cloud transition. A plethora of surveys from the likes of IDG and Gartner show that more than 70 percent of enterprises have deployed at least one or more cloud application or workload. Yet a closer inspection at the data reveals less than half of these cloud projects involve production...