Click here to close now.

Welcome!

Linux Authors: Elizabeth White, Pat Romanski, Carmen Gonzalez, Roger Strukhoff, Gregor Petri

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
One of the biggest impacts of the Internet of Things is and will continue to be on data; specifically data volume, management and usage. Companies are scrambling to adapt to this new and unpredictable data reality with legacy infrastructure that cannot handle the speed and volume of data. In his session at @ThingsExpo, Don DeLoach, CEO and president of Infobright, will discuss how companies need to rethink their data infrastructure to participate in the IoT, including: Data storage: Understanding the kinds of data: structured, unstructured, big/small? Analytics: What kinds and how responsiv...
Since 2008 and for the first time in history, more than half of humans live in urban areas, urging cities to become “smart.” Today, cities can leverage the wide availability of smartphones combined with new technologies such as Beacons or NFC to connect their urban furniture and environment to create citizen-first services that improve transportation, way-finding and information delivery. In her session at @ThingsExpo, Laetitia Gazel-Anthoine, CEO of Connecthings, will focus on successful use cases.
The Workspace-as-a-Service (WaaS) market will grow to $6.4B by 2018. In his session at 16th Cloud Expo, Seth Bostock, CEO of IndependenceIT, will begin by walking the audience through the evolution of Workspace as-a-Service, where it is now vs. where it going. To look beyond the desktop we must understand exactly what WaaS is, who the users are, and where it is going in the future. IT departments, ISVs and service providers must look to workflow and automation capabilities to adapt to growing demand and the rapidly changing workspace model.
Sensor-enabled things are becoming more commonplace, precursors to a larger and more complex framework that most consider the ultimate promise of the IoT: things connecting, interacting, sharing, storing, and over time perhaps learning and predicting based on habits, behaviors, location, preferences, purchases and more. In his session at @ThingsExpo, Tom Wesselman, Director of Communications Ecosystem Architecture at Plantronics, will examine the still nascent IoT as it is coalescing, including what it is today, what it might ultimately be, the role of wearable tech, and technology gaps stil...
Almost everyone sees the potential of Internet of Things but how can businesses truly unlock that potential. The key will be in the ability to discover business insight in the midst of an ocean of Big Data generated from billions of embedded devices via Systems of Discover. Businesses will also need to ensure that they can sustain that insight by leveraging the cloud for global reach, scale and elasticity.
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...
IoT is still a vague buzzword for many people. In his session at @ThingsExpo, Mike Kavis, Vice President & Principal Cloud Architect at Cloud Technology Partners, discussed the business value of IoT that goes far beyond the general public's perception that IoT is all about wearables and home consumer services. He also discussed how IoT is perceived by investors and how venture capitalist access this space. Other topics discussed were barriers to success, what is new, what is old, and what the future may hold. Mike Kavis is Vice President & Principal Cloud Architect at Cloud Technology Pa...
Hadoop as a Service (as offered by handful of niche vendors now) is a cloud computing solution that makes medium and large-scale data processing accessible, easy, fast and inexpensive. In his session at Big Data Expo, Kumar Ramamurthy, Vice President and Chief Technologist, EIM & Big Data, at Virtusa, will discuss how this is achieved by eliminating the operational challenges of running Hadoop, so one can focus on business growth. The fragmented Hadoop distribution world and various PaaS solutions that provide a Hadoop flavor either make choices for customers very flexible in the name of opti...
The true value of the Internet of Things (IoT) lies not just in the data, but through the services that protect the data, perform the analysis and present findings in a usable way. With many IoT elements rooted in traditional IT components, Big Data and IoT isn’t just a play for enterprise. In fact, the IoT presents SMBs with the prospect of launching entirely new activities and exploring innovative areas. CompTIA research identifies several areas where IoT is expected to have the greatest impact.
Advanced Persistent Threats (APTs) are increasing at an unprecedented rate. The threat landscape of today is drastically different than just a few years ago. Attacks are much more organized and sophisticated. They are harder to detect and even harder to anticipate. In the foreseeable future it's going to get a whole lot harder. Everything you know today will change. Keeping up with this changing landscape is already a daunting task. Your organization needs to use the latest tools, methods and expertise to guard against those threats. But will that be enough? In the foreseeable future attacks w...
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...
Dale Kim is the Director of Industry Solutions at MapR. His background includes a variety of technical and management roles at information technology companies. While his experience includes work with relational databases, much of his career pertains to non-relational data in the areas of search, content management, and NoSQL, and includes senior roles in technical marketing, sales engineering, and support engineering. Dale holds an MBA from Santa Clara University, and a BA in Computer Science from the University of California, Berkeley.
Wearable devices have come of age. The primary applications of wearables so far have been "the Quantified Self" or the tracking of one's fitness and health status. We propose the evolution of wearables into social and emotional communication devices. Our BE(tm) sensor uses light to visualize the skin conductance response. Our sensors are very inexpensive and can be massively distributed to audiences or groups of any size, in order to gauge reactions to performances, video, or any kind of presentation. In her session at @ThingsExpo, Jocelyn Scheirer, CEO & Founder of Bionolux, will discuss ho...
The cloud is now a fact of life but generating recurring revenues that are driven by solutions and services on a consumption model have been hard to implement, until now. In their session at 16th Cloud Expo, Ermanno Bonifazi, CEO & Founder of Solgenia, and Ian Khan, Global Strategic Positioning & Brand Manager at Solgenia, will discuss how a top European telco has leveraged the innovative recurring revenue generating capability of the consumption cloud to enable a unique cloud monetization model to drive results.
As organizations shift toward IT-as-a-service models, the need for managing and protecting data residing across physical, virtual, and now cloud environments grows with it. CommVault can ensure protection &E-Discovery of your data – whether in a private cloud, a Service Provider delivered public cloud, or a hybrid cloud environment – across the heterogeneous enterprise. In his session at 16th Cloud Expo, Randy De Meno, Chief Technologist - Windows Products and Microsoft Partnerships, will discuss how to cut costs, scale easily, and unleash insight with CommVault Simpana software, the only si...
Analytics is the foundation of smart data and now, with the ability to run Hadoop directly on smart storage systems like Cloudian HyperStore, enterprises will gain huge business advantages in terms of scalability, efficiency and cost savings as they move closer to realizing the potential of the Internet of Things. In his session at 16th Cloud Expo, Paul Turner, technology evangelist and CMO at Cloudian, Inc., will discuss the revolutionary notion that the storage world is transitioning from mere Big Data to smart data. He will argue that today’s hybrid cloud storage solutions, with commodity...
Cloud data governance was previously an avoided function when cloud deployments were relatively small. With the rapid adoption in public cloud – both rogue and sanctioned, it’s not uncommon to find regulated data dumped into public cloud and unprotected. This is why enterprises and cloud providers alike need to embrace a cloud data governance function and map policies, processes and technology controls accordingly. In her session at 15th Cloud Expo, Evelyn de Souza, Data Privacy and Compliance Strategy Leader at Cisco Systems, will focus on how to set up a cloud data governance program and s...
Every innovation or invention was originally a daydream. You like to imagine a “what-if” scenario. And with all the attention being paid to the so-called Internet of Things (IoT) you don’t have to stretch the imagination too much to see how this may impact commercial and homeowners insurance. We’re beyond the point of accepting this as a leap of faith. The groundwork is laid. Now it’s just a matter of time. We can thank the inventors of smart thermostats for developing a practical business application that everyone can relate to. Gone are the salad days of smart home apps, the early chalkb...
Roberto Medrano, Executive Vice President at SOA Software, had reached 30,000 page views on his home page - http://RobertoMedrano.SYS-CON.com/ - on the SYS-CON family of online magazines, which includes Cloud Computing Journal, Internet of Things Journal, Big Data Journal, and SOA World Magazine. He is a recognized executive in the information technology fields of SOA, internet security, governance, and compliance. He has extensive experience with both start-ups and large companies, having been involved at the beginning of four IT industries: EDA, Open Systems, Computer Security and now SOA.
The industrial software market has treated data with the mentality of “collect everything now, worry about how to use it later.” We now find ourselves buried in data, with the pervasive connectivity of the (Industrial) Internet of Things only piling on more numbers. There’s too much data and not enough information. In his session at @ThingsExpo, Bob Gates, Global Marketing Director, GE’s Intelligent Platforms business, to discuss how realizing the power of IoT, software developers are now focused on understanding how industrial data can create intelligence for industrial operations. Imagine ...