Click here to close now.




















Welcome!

Linux Containers Authors: Liz McMillan, Carmen Gonzalez, Elizabeth White, Bob Gourley, Yeshim Deniz

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 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
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.
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, November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Learn what is going on, contribute to the discussions, and ensure that your enterprise is as "IoT-Ready" as it can be.
Containers are not new, but renewed commitments to performance, flexibility, and agility have propelled them to the top of the agenda today. By working without the need for virtualization and its overhead, containers are seen as the perfect way to deploy apps and services across multiple clouds. Containers can handle anything from file types to operating systems and services, including microservices. What are microservices? Unlike what the name implies, microservices are not necessarily small, but are focused on specific tasks. The ability for developers to deploy multiple containers – thous...
The 3rd International WebRTC Summit, to be held Nov. 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA, announces that its Call for Papers is now open. Topics include all aspects of improving IT delivery by eliminating waste through automated business models leveraging cloud technologies. WebRTC Summit is co-located with 15th International Cloud Expo, 6th International Big Data Expo, 3rd International DevOps Summit and 2nd Internet of @ThingsExpo. WebRTC (Web-based Real-Time Communication) is an open source project supported by Google, Mozilla and Opera that aims to enable bro...
As more and more data is generated from a variety of connected devices, the need to get insights from this data and predict future behavior and trends is increasingly essential for businesses. Real-time stream processing is needed in a variety of different industries such as Manufacturing, Oil and Gas, Automobile, Finance, Online Retail, Smart Grids, and Healthcare. Azure Stream Analytics is a fully managed distributed stream computation service that provides low latency, scalable processing of streaming data in the cloud with an enterprise grade SLA. It features built-in integration with Azur...
With the proliferation of connected devices underpinning new Internet of Things systems, Brandon Schulz, Director of Luxoft IoT – Retail, will be looking at the transformation of the retail customer experience in brick and mortar stores in his session at @ThingsExpo. Questions he will address include: Will beacons drop to the wayside like QR codes, or be a proximity-based profit driver? How will the customer experience change in stores of all types when everything can be instrumented and analyzed? As an area of investment, how might a retail company move towards an innovation methodolo...
SYS-CON Events announced today that HPM Networks will exhibit at the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. For 20 years, HPM Networks has been integrating technology solutions that solve complex business challenges. HPM Networks has designed solutions for both SMB and enterprise customers throughout the San Francisco Bay Area.
SYS-CON Events announced today the Containers & Microservices Bootcamp, being held November 3-4, 2015, in conjunction with 17th Cloud Expo, @ThingsExpo, and @DevOpsSummit at the Santa Clara Convention Center in Santa Clara, CA. This is your chance to get started with the latest technology in the industry. Combined with real-world scenarios and use cases, the Containers and Microservices Bootcamp, led by Janakiram MSV, a Microsoft Regional Director, will include presentations as well as hands-on demos and comprehensive walkthroughs.
Contrary to mainstream media attention, the multiple possibilities of how consumer IoT will transform our everyday lives aren’t the only angle of this headline-gaining trend. There’s a huge opportunity for “industrial IoT” and “Smart Cities” to impact the world in the same capacity – especially during critical situations. For example, a community water dam that needs to release water can leverage embedded critical communications logic to alert the appropriate individuals, on the right device, as soon as they are needed to take action.
WebRTC services have already permeated corporate communications in the form of videoconferencing solutions. However, WebRTC has the potential of going beyond and catalyzing a new class of services providing more than calls with capabilities such as mass-scale real-time media broadcasting, enriched and augmented video, person-to-machine and machine-to-machine communications. In his session at @ThingsExpo, Luis Lopez, CEO of Kurento, will introduce the technologies required for implementing these ideas and some early experiments performed in the Kurento open source software community in areas ...
SYS-CON Events announced today that Pythian, a global IT services company specializing in helping companies leverage disruptive technologies to optimize revenue-generating systems, has been named “Bronze Sponsor” of SYS-CON's 17th Cloud Expo, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Founded in 1997, Pythian is a global IT services company that helps companies compete by adopting disruptive technologies such as cloud, Big Data, advanced analytics, and DevOps to advance innovation and increase agility. Specializing in designing, imple...
Consumer IoT applications provide data about the user that just doesn’t exist in traditional PC or mobile web applications. This rich data, or “context,” enables the highly personalized consumer experiences that characterize many consumer IoT apps. This same data is also providing brands with unprecedented insight into how their connected products are being used, while, at the same time, powering highly targeted engagement and marketing opportunities. In his session at @ThingsExpo, Nathan Treloar, President and COO of Bebaio, will explore examples of brands transforming their businesses by t...
In his session at @ThingsExpo, Lee Williams, a producer of the first smartphones and tablets, will talk about how he is now applying his experience in mobile technology to the design and development of the next generation of Environmental and Sustainability Services at ETwater. He will explain how M2M controllers work through wirelessly connected remote controls; and specifically delve into a retrofit option that reverse-engineers control codes of existing conventional controller systems so they don't have to be replaced and are instantly converted to become smart, connected devices.
With the Apple Watch making its way onto wrists all over the world, it’s only a matter of time before it becomes a staple in the workplace. In fact, Forrester reported that 68 percent of technology and business decision-makers characterize wearables as a top priority for 2015. Recognizing their business value early on, FinancialForce.com was the first to bring ERP to wearables, helping streamline communication across front and back office functions. In his session at @ThingsExpo, Kevin Roberts, GM of Platform at FinancialForce.com, will discuss the value of business applications on wearable ...
17th Cloud Expo, taking place Nov 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud strategy. Meanwhile, 94% of enterprises are using some form of XaaS – software, platform, and infrastructure as a service.
SYS-CON Events announced today that Micron Technology, Inc., a global leader in advanced semiconductor systems, will exhibit at the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Micron’s broad portfolio of high-performance memory technologies – including DRAM, NAND and NOR Flash – is the basis for solid state drives, modules, multichip packages and other system solutions. Backed by more than 35 years of technology leadership, Micron's memory solutions enable the world's most innovative computing, consumer,...
As more intelligent IoT applications shift into gear, they’re merging into the ever-increasing traffic flow of the Internet. It won’t be long before we experience bottlenecks, as IoT traffic peaks during rush hours. Organizations that are unprepared will find themselves by the side of the road unable to cross back into the fast lane. As billions of new devices begin to communicate and exchange data – will your infrastructure be scalable enough to handle this new interconnected world?
While many app developers are comfortable building apps for the smartphone, there is a whole new world out there. In his session at @ThingsExpo, Narayan Sainaney, Co-founder and CTO of Mojio, will discuss how the business case for connected car apps is growing and, with open platform companies having already done the heavy lifting, there really is no barrier to entry.
SYS-CON Events announced today that the "Second Containers & Microservices Expo" will take place November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Containers and microservices have become topics of intense interest throughout the cloud developer and enterprise IT communities.
Manufacturing connected IoT versions of traditional products requires more than multiple deep technology skills. It also requires a shift in mindset, to realize that connected, sensor-enabled “things” act more like services than what we usually think of as products. In his session at @ThingsExpo, David Friedman, CEO and co-founder of Ayla Networks, will discuss how when sensors start generating detailed real-world data about products and how they’re being used, smart manufacturers can use the data to create additional revenue streams, such as improved warranties or premium features. Or slash...