All of lore.kernel.org
 help / color / mirror / Atom feed
* DRM changes
@ 2009-03-09 21:49 Stephane Marchesin
       [not found] ` <6a89f9d50903091449w47c8a79ak37124972b91a6fde-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Stephane Marchesin @ 2009-03-09 21:49 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Hi,

As part of aiming at upstreaming our code, I suppose we have to
discuss the DRM situation a little. In order to aim for merging, I
think we'd better be working on a linux kernel tree layout. And
considering we're technically the only ones still working in drm.git,
it doesn't really make sense to keep doing that for the sake of
sharing code with other drivers.

As we discussed on irc, there would be multiple changes related to this:
- we move to a linux kernel-like tree, that should make it easier when
upstreaming the code.
- this new tree is hosted in freedekstop.org in the nouveau/ git so we
don't need additional accounts for everyone all around and people can
keep pushing things (even better, all nouveau people can push to the
drm, which used to require mesa rights before)
- we keep a(some) branch(es) in the tree for backwards compat with
older kernels. Either in the form of separate kernel versions
including nouveau, or in the form of an out-of-tree-compilable
drm/nouveau module.

So, does that plan sound sane? Do you have better plans?

Stephane

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: DRM changes
       [not found] ` <6a89f9d50903091449w47c8a79ak37124972b91a6fde-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2009-03-09 22:23   ` Maarten Maathuis
       [not found]     ` <6d4bc9fc0903091523n4eff7715oe5249ebb799e298-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2009-03-12 19:21   ` Peter Hjalmarsson
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Maarten Maathuis @ 2009-03-09 22:23 UTC (permalink / raw)
  To: Stephane Marchesin; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Questions:

A tree based on what? (linus, drm-next, etc)

What happens to shared-core?

Opinions (assuming this happens):

I'd do a branch for each kernel version (or less if needed), and let
people who care cherry-pick fixes.

Maarten.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: DRM changes
       [not found]     ` <6d4bc9fc0903091523n4eff7715oe5249ebb799e298-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2009-03-10  8:03       ` Stephane Marchesin
  0 siblings, 0 replies; 11+ messages in thread
From: Stephane Marchesin @ 2009-03-10  8:03 UTC (permalink / raw)
  To: Maarten Maathuis; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Mon, Mar 9, 2009 at 23:23, Maarten Maathuis <madman2003-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Questions:
>
> A tree based on what? (linus, drm-next, etc)
>

I would follow drm-next, but I don't think it is very relevant at this
point, since anyway drm-next periodically merges to linus. If there
are reasons to choose one over the other, I'm interested in hearing
them.

> What happens to shared-core?

It will probably meet its creator.

>
> Opinions (assuming this happens):
>
> I'd do a branch for each kernel version (or less if needed), and let
> people who care cherry-pick fixes.
>

Yeah that's what I initially thought, but Pekka said you could also
get an out-of-tree build from a full kernel tree. So that's the two
paths to explore.

Stephane

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: DRM changes
       [not found] ` <6a89f9d50903091449w47c8a79ak37124972b91a6fde-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2009-03-09 22:23   ` Maarten Maathuis
@ 2009-03-12 19:21   ` Peter Hjalmarsson
       [not found]     ` <1236885714.21828.6.camel-eMQg5G+HfYU7zld1fzGs+w@public.gmane.org>
  2009-03-20 23:48   ` Building rawhide+darktama on 2.6.24 (Re: DRM changes) Pekka Paalanen
  2009-03-31 18:17   ` DRM changes Pekka Paalanen
  3 siblings, 1 reply; 11+ messages in thread
From: Peter Hjalmarsson @ 2009-03-12 19:21 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

mån 2009-03-09 klockan 22:49 +0100 skrev Stephane Marchesin:
> Hi,
> 
> So, does that plan sound sane? Do you have better plans?
> 
> Stephane

I must say that for me it does not give that big problems, since I
already are using my own hem-brewed kernel. But I think it will be
harder getting testers if they need to not just compile som modules for
their kernel, but also try to configure the beast on their own.

Just my 2-cents.


_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: DRM changes
       [not found]     ` <1236885714.21828.6.camel-eMQg5G+HfYU7zld1fzGs+w@public.gmane.org>
@ 2009-03-14 11:18       ` Renato Caldas
       [not found]         ` <1caff7430903140418k434fc82es7927d7015026cea3-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Renato Caldas @ 2009-03-14 11:18 UTC (permalink / raw)
  To: Peter Hjalmarsson; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Thu, Mar 12, 2009 at 7:21 PM, Peter Hjalmarsson <xake-ca8b1Tj3MiseIZ0/mPfg9Q@public.gmane.org> wrote:
> mån 2009-03-09 klockan 22:49 +0100 skrev Stephane Marchesin:
>> Hi,
>>
>> So, does that plan sound sane? Do you have better plans?
>>
>> Stephane
>
> I must say that for me it does not give that big problems, since I
> already are using my own hem-brewed kernel. But I think it will be
> harder getting testers if they need to not just compile som modules for
> their kernel, but also try to configure the beast on their own.

Lets face it, users who can't configure their own kernel will probably
turn out to be bad testers. And besides, configuring a kernel is not
that hard, and users can just copy their distro's configuration and
only tweak the drm related parts. No show stoppers here.

Cheers,
  Renato

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: DRM changes
       [not found]         ` <1caff7430903140418k434fc82es7927d7015026cea3-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2009-03-14 15:03           ` Peter Hjalmarsson
       [not found]             ` <1237043038.5825.11.camel-eMQg5G+HfYU7zld1fzGs+w@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Hjalmarsson @ 2009-03-14 15:03 UTC (permalink / raw)
  To: Renato Caldas; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

lör 2009-03-14 klockan 11:18 +0000 skrev Renato Caldas:
> On Thu, Mar 12, 2009 at 7:21 PM, Peter Hjalmarsson <xake@rymdraket.net> wrote:
> > mån 2009-03-09 klockan 22:49 +0100 skrev Stephane Marchesin:
> >> Hi,
> >>
> >> So, does that plan sound sane? Do you have better plans?
> >>
> >> Stephane
> >
> > I must say that for me it does not give that big problems, since I
> > already are using my own hem-brewed kernel. But I think it will be
> > harder getting testers if they need to not just compile som modules for
> > their kernel, but also try to configure the beast on their own.
> 
> Lets face it, users who can't configure their own kernel will probably
> turn out to be bad testers. And besides, configuring a kernel is not
> that hard, and users can just copy their distro's configuration and
> only tweak the drm related parts. No show stoppers here.
> 
> Cheers,
>   Renato

I know many who are good enought to be good testers and are programmers
but could care less about having to update their kernel, patch it and/or
reconfigure it every time someone finds a security-related bug or broken
feature and WANT someone (i.e. the distribution) to do that work for
them. They just want to use their computer to what they want: code
programs, not spend time on their configuration if they do not have to.

Even if they can copy the configuration from their distribution, the
question is if they want to spend time on tracking the kernel, patch it
and so on if they had to. 

I do not know if I have hadthe time to do that if it was not for having
a good working configuration and having gentoo tracking and patching it
for me. 
And with the current development-speed of nouveau: do we want testers
that only update when they have that amount of time, it would take long
time to bisect those historys if/when something breaks.
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Building rawhide+darktama on 2.6.24 (Re:  DRM changes)
       [not found] ` <6a89f9d50903091449w47c8a79ak37124972b91a6fde-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2009-03-09 22:23   ` Maarten Maathuis
  2009-03-12 19:21   ` Peter Hjalmarsson
@ 2009-03-20 23:48   ` Pekka Paalanen
  2009-03-31 18:17   ` DRM changes Pekka Paalanen
  3 siblings, 0 replies; 11+ messages in thread
From: Pekka Paalanen @ 2009-03-20 23:48 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: dri-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Ben Skeggs

[-- Attachment #1: Type: text/plain, Size: 3999 bytes --]

On Mon, 9 Mar 2009 22:49:32 +0100
Stephane Marchesin <marchesin-YynmYXH4S6491FlJP1ih0VAUjnlXr6A1@public.gmane.org> wrote:

> As we discussed on irc, there would be multiple changes related to this:
> - we move to a linux kernel-like tree, that should make it easier when
> upstreaming the code.
> - this new tree is hosted in freedekstop.org in the nouveau/ git so we
> don't need additional accounts for everyone all around and people can
> keep pushing things (even better, all nouveau people can push to the
> drm, which used to require mesa rights before)
> - we keep a(some) branch(es) in the tree for backwards compat with
> older kernels. Either in the form of separate kernel versions
> including nouveau, or in the form of an out-of-tree-compilable
> drm/nouveau module.

Hi,

I took airlied's drm-rawhide kernel tree, applied darktama's patch
that adds Nouveau, wrote/copied my own compat-patches on top of that,
and compiled the DRM modules (drm.ko and nouveau.ko) against my
currently running kernel 2.6.24.

It works, with the caveat that I needed a tiny patch to 2.6.24 in
addition to reconfiguring it. The details will follow. I've been
running Nouveau for two hours now without any hickups.

I'm CC'ing also dri-devel@ just in case people working on other
drivers might be interested in offering a "drm.git-like" version
of their drivers for people with older, custom or otherwise
not-this-driver's-development-tree kernels. And because my
compat patches probably suck.

Feel free to drop the dri-devel@ CC when you discuss Nouveau-only
matters.


This raises some questions for Nouveau:
- like marcheu proposed, shall Nouveau DRM move into a kernel tree?
- do we abandon drm.git kernel directories completely?
- is the out-of-tree DRM build sketched below feasible for users?
- how do we maintain and distribute the compat patches and DRM code?

I'd expect the compat patches would be maintained by whoever happens
to run older kernels. Developers do not consider compat patching.


Building DRM out-of-tree for 2.6.24:

Prepare the "upstream" DRM and Nouveau code:

- Get airlied's linux kernel tree, the drm-rawhide branch:
http://git.kernel.org/?p=linux/kernel/git/airlied/drm-2.6.git;a=shortlog;h=drm-rawhide
(the version I used is probably a week old now)

- Get darktama's nouveau patch and apply it on drm-rawhide:
http://cvs.fedoraproject.org/viewvc/rpms/kernel/devel/drm-nouveau.patch?revision=1.25&view=markup
(this is probably outdated by now)

- apply the included nouveau-drm-compat-24.patch
This patch is combined from the individual patches listed in its
description, diffstat is included.

- run 'make clean' unless your tree is already clean.


Prepare your 2.6.24 kernel:

- apply the included kernel-compat-24.patch to export shmem_file_setup()

- configure the following as modules:
	CONFIG_DRM
	CONFIG_FB
	CONFIG_BACKLIGHT_CLASS_DEVICE
	CONFIG_FB_SAVAGE
The savage driver is abused to get FB_CFB_FILLRECT, FB_CFB_COPYAREA and
FB_CFB_IMAGEBLIT enabled, since they do not have menuconfig entries.
If you actually have a Savage card in your computer, maybe you should
pick another fb driver.

- build and install as usual, remove the drm.ko generated.


Building the DRM and Nouveau modules as external modules
using the 2.6.24 kernel tree:

- save the included mkbuild-nouveau.bash script

- edit the script, and fix the paths to the 2.6.24 and the
drm-rawhide kernel trees

- create a new empty directory and cd into it

- run '../mkbuild-nouveau.bash init', it should not whine
about anything, just print good stuff.

- run '../mkbuild-nouveau.bash build', it should build drm.ko and
nouveau.ko. These are probably created in the drm-rawhide kernel
tree.

- find the kernel modules, and load these:
	fb.ko
	drm.ko
	backlight.ko
	cfbcopyarea.ko
	cfbfillrect.ko
	cfbimgblt.ko
	nouveau.ko
Now the Nouveau DDX should run just fine using the new DRM modules.


Ben, I still don't see any comment from you on this thread :-)

-- 
Pekka Paalanen
http://www.iki.fi/pq/

[-- Attachment #2: mkbuild-nouveau.bash --]
[-- Type: text/plain, Size: 2057 bytes --]

#!/bin/bash

# 395e0ddc44005ced5e4fed9bfc2e4bdf63d37627 shmem_file_setup export

# Use e.g. CONFIG_FB_SAVAGE to get FB_CFB_FILLRECT, FB_CFB_COPYAREA
# and FB_CFB_IMAGEBLIT.

# cd into an empty directory, and call this script from there.

# Path to the kernel tree, from which DRM is built.
NKDIR="/home/pq/linux/linux-2.6-torvalds"

# Path to the configured kernel tree you normally use
KDIR="$(readlink -f /lib/modules/`uname -r`/source)"

# All resulting files *should* be written to OUTDIR, but it seems
# the external module directory does not honour that. I.e. the
# the external modules are built into DRMDIR.

DRMDIR="$NKDIR/drivers/gpu/drm"
OUTDIR="$(pwd)"
NEWCONFIG="$OUTDIR/.config"

# --- nothing configurable below this line ---

CMD="$1"

function config_check_ym {
	OPTION="$1"
	grep -q -e "CONFIG_$OPTION=[ym]" "$NEWCONFIG" && return 0
	echo "Option CONFIG_$OPTION is not set in your kernel config."
	return 1
}

function config_require {
	local FAIL=0
	for REQ in "$@"; do
		config_check_ym "$REQ" || FAIL=1
	done
	return $FAIL
}

function die {
	echo "$@"
	exit 1
}

function kmake {
	make -C "$KDIR" O="$OUTDIR" "$@"
}

function kmake_drm {
	kmake M="$DRMDIR" EXTRA_CFLAGS="-I$NKDIR/include/drm" "$@"
}

echo "KDIR     $KDIR"
echo "DRMDIR   $DRMDIR"
echo "OUTDIR   $OUTDIR"
echo ""

REQCFG="DRM FB BACKLIGHT_CLASS_DEVICE FB_CFB_FILLRECT FB_CFB_COPYAREA FB_CFB_IMAGEBLIT"

case "$CMD" in
	init)
		cp "$KDIR/.config" "$NEWCONFIG"
		cp -a "$KDIR/scripts" "$OUTDIR/scripts"
		kmake silentoldconfig
		#echo -e "\nCONFIG_DRM_NOUVEAU=m" >> "$NEWCONFIG"
		config_require $REQCFG || \
			die "Please, fix you kernel config to have: $REQCFG"
		;;
	build)
		kmake_drm drm.ko || \
			die "making drm.ko failed"
		kmake_drm nouveau/nouveau.ko || \
			die "making nouveau.ko failed"
		;;
	clean)
		kmake_drm clean
		;;
	*)
		echo "Unknown command: '$CMD'"
		echo "Supported commands: init build clean"
		echo "Please edit the script to configure it."
		exit 1
esac


[-- Attachment #3: nouveau-drm-compat-24.patch --]
[-- Type: text/plain, Size: 27454 bytes --]

Individual patches:

eae74f67e610b122b83344160fe6824f4d1fb157 nouveau compat: fix nouveau_backlight.c
643a6631225572577bb978bf680a8e62494cdb72 nouveau compat: fix nouveau_bo.c
d50c7807a9632f4b000880dd336f33d9d75bd86b nouveau compat: fix nouveau_sgdma.c
b721c48a61ad772aa35677a7a317838174dc388e nouveau compat: fix nouveau_object.c
9d1a9ea342b66bc890445f7ac1c1a3252daf0c48 nouveau compat: fix nouveau_state.c
4a5584e5dacbbab61f603b7f0aeac15373ee2c64 drm: hardwire nouveau to be built as a module
97f0b94f347584587d596a9c1d69995787d71682 drm: fix printf fmt in drm_bo.c
d0841aeb4a16b5da475665325c99462e6d17735f drm compat: fix drm_page_alloc.c
c1f22a2e71c37eaabe69998f65edc6e6abffd32c drm: functions in drm_compat.h must be static
560683d84115ff7bec3244c17feec866716eead9 drm compat: fix drm_bo_move.c
5d9c1ffc5458657fd9ef32b1b93081bca41cf595 drm compat: fix drm_ttm.c
3f5598aff86054e7b371c0cdb8549fb0ed8d2333 drm compat: fix drm_crtc_helper.c
e5e671c53fa493c1fa15960ba3480f877e6ef2f2 drm compat: fix drm_sysfs.c
68f6da44fe096291e5a0deb023e122a635a9fa37 drm: drm_compat.c needs drm_compat.h included
b3ecc3eed2c1e8e9d1470148e13bd330dc83eb4f drm compat: fix ati_pcigart.c
747bc5fd7fbe4934f5216058264b08ebb37f2d49 drm compat: fix drm_agpsupport.c
4ffe8e87f3525aac2f1bea0cf2987e67a3d3fe22 drm compat: fix drm_vm.c
d0314bca55ac5c267210fa7174db4520f1930fee drm compat: fix drm_memory.c
bad5327061659deb0022ef0e077aea23fdbcf98f drm compat: fix drm_fops.c
3c6581e9dbae013d2b5f475d57d02cdaf6a64319 drm compat: fix drm_gem.c
08d9dc3bd1f46e84bf5e1f541c4e823dfe984c95 drm compat: drm_compat.h needs version.h
d13a7913ec92cfc70294f6882bad58fcd5ddd2dc drm: add drm_compat.[ch]

 drivers/gpu/drm/Makefile                    |    3 +-
 drivers/gpu/drm/ati_pcigart.c               |    1 +
 drivers/gpu/drm/drm_agpsupport.c            |    1 +
 drivers/gpu/drm/drm_bo.c                    |    4 +-
 drivers/gpu/drm/drm_bo_move.c               |    3 +-
 drivers/gpu/drm/drm_compat.c                |  267 +++++++++++++++++++++++++
 drivers/gpu/drm/drm_compat.h                |  289 +++++++++++++++++++++++++++
 drivers/gpu/drm/drm_crtc_helper.c           |    1 +
 drivers/gpu/drm/drm_fops.c                  |    1 +
 drivers/gpu/drm/drm_gem.c                   |    1 +
 drivers/gpu/drm/drm_memory.c                |    1 +
 drivers/gpu/drm/drm_page_alloc.c            |    1 +
 drivers/gpu/drm/drm_sysfs.c                 |    1 +
 drivers/gpu/drm/drm_ttm.c                   |    1 +
 drivers/gpu/drm/drm_vm.c                    |    3 +-
 drivers/gpu/drm/nouveau/Makefile            |    2 +-
 drivers/gpu/drm/nouveau/nouveau_backlight.c |    5 +
 drivers/gpu/drm/nouveau/nouveau_bo.c        |    1 +
 drivers/gpu/drm/nouveau/nouveau_object.c    |    1 +
 drivers/gpu/drm/nouveau/nouveau_sgdma.c     |    1 +
 drivers/gpu/drm/nouveau/nouveau_state.c     |    5 +
 21 files changed, 587 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 97aa0c8..6a937dd 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -12,6 +12,7 @@ drm-y       :=	drm_auth.o drm_bufs.o drm_cache.o \
 		drm_sysfs.o drm_hashtab.o drm_sman.o drm_mm.o \
 		drm_crtc.o drm_crtc_helper.o drm_modes.o drm_edid.o \
 		drm_info.o drm_debugfs.o \
+		drm_compat.o \
 		drm_fence.o drm_bo.o drm_ttm.o drm_bo_move.o drm_page_alloc.o
 
 drm-$(CONFIG_COMPAT) += drm_ioc32.o
@@ -27,5 +28,5 @@ obj-$(CONFIG_DRM_I915)  += i915/
 obj-$(CONFIG_DRM_SIS)   += sis/
 obj-$(CONFIG_DRM_SAVAGE)+= savage/
 obj-$(CONFIG_DRM_VIA)	+=via/
-obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
+obj-m +=nouveau/
 
diff --git a/drivers/gpu/drm/ati_pcigart.c b/drivers/gpu/drm/ati_pcigart.c
index e7dc671..597f4ef 100644
--- a/drivers/gpu/drm/ati_pcigart.c
+++ b/drivers/gpu/drm/ati_pcigart.c
@@ -32,6 +32,7 @@
  */
 
 #include "drmP.h"
+#include "drm_compat.h"
 
 # define ATI_PCIGART_PAGE_SIZE		4096	/**< PCI GART page size */
 # define ATI_PCIGART_PAGE_MASK		(~(ATI_PCIGART_PAGE_SIZE-1))
diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
index 851f4c3..a7bc525 100644
--- a/drivers/gpu/drm/drm_agpsupport.c
+++ b/drivers/gpu/drm/drm_agpsupport.c
@@ -32,6 +32,7 @@
  */
 
 #include "drmP.h"
+#include "drm_compat.h"
 #include <linux/module.h>
 
 #if __OS_HAS_AGP
diff --git a/drivers/gpu/drm/drm_bo.c b/drivers/gpu/drm/drm_bo.c
index 371db56..19b50fc 100644
--- a/drivers/gpu/drm/drm_bo.c
+++ b/drivers/gpu/drm/drm_bo.c
@@ -511,7 +511,7 @@ static void drm_bo_delayed_delete(struct drm_device *dev, int remove_all)
 		entry = list_entry(list, struct drm_buffer_object, ddestroy);
 
 		nentry = NULL;
-		DRM_DEBUG("bo is %p, %d\n", entry, entry->num_pages);
+		DRM_DEBUG("bo is %p, %lu\n", entry, entry->num_pages);
 		if (next != &bm->ddestroy) {
 			nentry = list_entry(next, struct drm_buffer_object,
 					    ddestroy);
@@ -1265,7 +1265,7 @@ static int drm_buffer_object_validate(struct drm_buffer_object *bo,
 					 move_unfenced);
 		if (ret) {
 			if (ret != -EAGAIN)
-				DRM_ERROR("Failed moving buffer. %p %d %llx %llx\n", bo, bo->num_pages, bo->mem.proposed_flags, bo->mem.flags );
+				DRM_ERROR("Failed moving buffer. %p %lu %llx %llx\n", bo, bo->num_pages, bo->mem.proposed_flags, bo->mem.flags );
 			if (ret == -ENOMEM)
 				DRM_ERROR("Out of aperture space or "
 					  "DRM memory quota.\n");
diff --git a/drivers/gpu/drm/drm_bo_move.c b/drivers/gpu/drm/drm_bo_move.c
index abeab6a..fe9d635 100644
--- a/drivers/gpu/drm/drm_bo_move.c
+++ b/drivers/gpu/drm/drm_bo_move.c
@@ -29,8 +29,9 @@
  */
 
 #include "drmP.h"
+#include "drm_compat.h"
 
-#if defined(CONFIG_X86)
+#if defined(CONFIG_X86) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
 #include <asm/pat.h>
 #endif
 
diff --git a/drivers/gpu/drm/drm_compat.c b/drivers/gpu/drm/drm_compat.c
new file mode 100644
index 0000000..9b8a3e8
--- /dev/null
+++ b/drivers/gpu/drm/drm_compat.c
@@ -0,0 +1,267 @@
+/**************************************************************************
+ *
+ * This kernel module is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ **************************************************************************/
+/*
+ * This code provides access to unexported mm kernel features. It is necessary
+ * to use the new DRM memory manager code with kernels that don't support it
+ * directly.
+ *
+ * Authors: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
+ *          Linux kernel mm subsystem authors.
+ *          (Most code taken from there).
+ */
+
+#include "drmP.h"
+#include "drm_compat.h"
+
+#ifdef DRM_IDR_COMPAT_FN
+/* only called when idp->lock is held */
+static void __free_layer(struct idr *idp, struct idr_layer *p)
+{
+	p->ary[0] = idp->id_free;
+	idp->id_free = p;
+	idp->id_free_cnt++;
+}
+
+static void free_layer(struct idr *idp, struct idr_layer *p)
+{
+	unsigned long flags;
+
+	/*
+	 * Depends on the return element being zeroed.
+	 */
+	spin_lock_irqsave(&idp->lock, flags);
+	__free_layer(idp, p);
+	spin_unlock_irqrestore(&idp->lock, flags);
+}
+
+/**
+ * idr_for_each - iterate through all stored pointers
+ * @idp: idr handle
+ * @fn: function to be called for each pointer
+ * @data: data passed back to callback function
+ *
+ * Iterate over the pointers registered with the given idr.  The
+ * callback function will be called for each pointer currently
+ * registered, passing the id, the pointer and the data pointer passed
+ * to this function.  It is not safe to modify the idr tree while in
+ * the callback, so functions such as idr_get_new and idr_remove are
+ * not allowed.
+ *
+ * We check the return of @fn each time. If it returns anything other
+ * than 0, we break out and return that value.
+ *
+* The caller must serialize idr_find() vs idr_get_new() and idr_remove().
+ */
+int idr_for_each(struct idr *idp,
+		 int (*fn)(int id, void *p, void *data), void *data)
+{
+	int n, id, max, error = 0;
+	struct idr_layer *p;
+	struct idr_layer *pa[MAX_LEVEL];
+	struct idr_layer **paa = &pa[0];
+
+	n = idp->layers * IDR_BITS;
+	p = idp->top;
+	max = 1 << n;
+
+	id = 0;
+	while (id < max) {
+		while (n > 0 && p) {
+			n -= IDR_BITS;
+			*paa++ = p;
+			p = p->ary[(id >> n) & IDR_MASK];
+		}
+
+		if (p) {
+			error = fn(id, (void *)p, data);
+			if (error)
+				break;
+		}
+
+		id += 1 << n;
+		while (n < fls(id)) {
+			n += IDR_BITS;
+			p = *--paa;
+		}
+	}
+
+	return error;
+}
+EXPORT_SYMBOL(idr_for_each);
+
+/**
+ * idr_remove_all - remove all ids from the given idr tree
+ * @idp: idr handle
+ *
+ * idr_destroy() only frees up unused, cached idp_layers, but this
+ * function will remove all id mappings and leave all idp_layers
+ * unused.
+ *
+ * A typical clean-up sequence for objects stored in an idr tree, will
+ * use idr_for_each() to free all objects, if necessay, then
+ * idr_remove_all() to remove all ids, and idr_destroy() to free
+ * up the cached idr_layers.
+ */
+void idr_remove_all(struct idr *idp)
+{
+       int n, id, max, error = 0;
+       struct idr_layer *p;
+       struct idr_layer *pa[MAX_LEVEL];
+       struct idr_layer **paa = &pa[0];
+
+       n = idp->layers * IDR_BITS;
+       p = idp->top;
+       max = 1 << n;
+
+       id = 0;
+       while (id < max && !error) {
+               while (n > IDR_BITS && p) {
+                       n -= IDR_BITS;
+                       *paa++ = p;
+                       p = p->ary[(id >> n) & IDR_MASK];
+               }
+
+               id += 1 << n;
+               while (n < fls(id)) {
+                       if (p) {
+                               memset(p, 0, sizeof *p);
+                               free_layer(idp, p);
+                       }
+                       n += IDR_BITS;
+                       p = *--paa;
+               }
+       }
+       idp->top = NULL;
+       idp->layers = 0;
+}
+EXPORT_SYMBOL(idr_remove_all);
+
+#endif /* DRM_IDR_COMPAT_FN */
+
+
+#ifdef DRM_NO_FAULT
+unsigned long drm_bo_vm_nopfn(struct vm_area_struct *vma,
+			      unsigned long address)
+{
+	struct drm_buffer_object *bo = (struct drm_buffer_object *) vma->vm_private_data;
+	unsigned long page_offset;
+	struct page *page = NULL;
+	struct drm_ttm *ttm;
+	struct drm_device *dev;
+	unsigned long pfn;
+	int err;
+	unsigned long bus_base;
+	unsigned long bus_offset;
+	unsigned long bus_size;
+	unsigned long ret = NOPFN_REFAULT;
+
+	if (address > vma->vm_end)
+		return NOPFN_SIGBUS;
+
+	dev = bo->dev;
+	err = drm_bo_read_lock(&dev->bm.bm_lock, 1);
+	if (err)
+		return NOPFN_REFAULT;
+
+	err = mutex_lock_interruptible(&bo->mutex);
+	if (err) {
+		drm_bo_read_unlock(&dev->bm.bm_lock);
+		return NOPFN_REFAULT;
+	}
+
+	err = drm_bo_wait(bo, 0, 1, 0, 1);
+	if (err) {
+		ret = (err != -EAGAIN) ? NOPFN_SIGBUS : NOPFN_REFAULT;
+		bo->priv_flags &= ~_DRM_BO_FLAG_UNLOCKED;
+		goto out_unlock;
+	}
+
+	bo->priv_flags &= ~_DRM_BO_FLAG_UNLOCKED;
+
+	/*
+	 * If buffer happens to be in a non-mappable location,
+	 * move it to a mappable.
+	 */
+
+	if (!(bo->mem.flags & DRM_BO_FLAG_MAPPABLE)) {
+		uint32_t new_flags = bo->mem.proposed_flags |
+			DRM_BO_FLAG_MAPPABLE |
+			DRM_BO_FLAG_FORCE_MAPPABLE;
+		err = drm_bo_move_buffer(bo, new_flags, 0, 0);
+		if (err) {
+			ret = (err != -EAGAIN) ? NOPFN_SIGBUS : NOPFN_REFAULT;
+			goto out_unlock;
+		}
+	}
+
+	err = drm_bo_pci_offset(dev, &bo->mem, &bus_base, &bus_offset,
+				&bus_size);
+
+	if (err) {
+		ret = NOPFN_SIGBUS;
+		goto out_unlock;
+	}
+
+	page_offset = (address - vma->vm_start) >> PAGE_SHIFT;
+
+	if (bus_size) {
+		struct drm_mem_type_manager *man = &dev->bm.man[bo->mem.mem_type];
+
+		pfn = ((bus_base + bus_offset) >> PAGE_SHIFT) + page_offset;
+		vma->vm_page_prot = drm_io_prot(man->drm_bus_maptype, vma);
+	} else {
+		ttm = bo->ttm;
+
+		drm_ttm_fixup_caching(ttm);
+		page = drm_ttm_get_page(ttm, page_offset);
+		if (!page) {
+			ret = NOPFN_OOM;
+			goto out_unlock;
+		}
+		pfn = page_to_pfn(page);
+		vma->vm_page_prot = (bo->mem.flags & DRM_BO_FLAG_CACHED) ?
+			vm_get_page_prot(vma->vm_flags) :
+			drm_io_prot(_DRM_TTM, vma);
+	}
+
+	err = vm_insert_pfn(vma, address, pfn);
+	if (err) {
+		ret = (err != -EAGAIN) ? NOPFN_OOM : NOPFN_REFAULT;
+		goto out_unlock;
+	}
+out_unlock:
+	BUG_ON(bo->priv_flags & _DRM_BO_FLAG_UNLOCKED);
+	mutex_unlock(&bo->mutex);
+	drm_bo_read_unlock(&dev->bm.bm_lock);
+	return ret;
+}
+#endif
+
+#ifdef DRM_COMPAT_NEEDS_DEV_SET_NAME
+int dev_set_name(struct device *dev, const char *fmt, ...)
+{
+        va_list vargs;
+        char *s;
+        va_start(vargs, fmt);
+        vsnprintf(dev->bus_id, sizeof(dev->bus_id), fmt, vargs);
+        va_end(vargs);
+        while ((s = strchr(dev->bus_id, '/')))
+                *s = '!';
+        return 0;
+}
+#endif
diff --git a/drivers/gpu/drm/drm_compat.h b/drivers/gpu/drm/drm_compat.h
new file mode 100644
index 0000000..01a7671
--- /dev/null
+++ b/drivers/gpu/drm/drm_compat.h
@@ -0,0 +1,289 @@
+/**
+ * \file drm_compat.h
+ * Backward compatability definitions for Direct Rendering Manager
+ *
+ * \author Rickard E. (Rik) Faith <faith-jCdQPDEk3idBDgjK7y7TUQ@public.gmane.org>
+ * \author Gareth Hughes <gareth-jCdQPDEk3idBDgjK7y7TUQ@public.gmane.org>
+ */
+
+/*
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _DRM_COMPAT_H_
+#define _DRM_COMPAT_H_
+
+#include <linux/version.h>
+
+#ifndef minor
+#define minor(x) MINOR((x))
+#endif
+
+#ifndef MODULE_LICENSE
+#define MODULE_LICENSE(x)
+#endif
+
+#ifndef preempt_disable
+#define preempt_disable()
+#define preempt_enable()
+#endif
+
+#ifndef pte_offset_map
+#define pte_offset_map pte_offset
+#define pte_unmap(pte)
+#endif
+
+#ifndef module_param
+#define module_param(name, type, perm)
+#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
+#define current_euid() (current->euid)
+#else
+#include <linux/cred.h>
+#endif
+
+#ifndef list_for_each_safe
+#define list_for_each_safe(pos, n, head)				\
+	for (pos = (head)->next, n = pos->next; pos != (head);		\
+		pos = n, n = pos->next)
+#endif
+
+#ifndef list_for_each_entry
+#define list_for_each_entry(pos, head, member)				\
+       for (pos = list_entry((head)->next, typeof(*pos), member),	\
+                    prefetch(pos->member.next);				\
+            &pos->member != (head);					\
+            pos = list_entry(pos->member.next, typeof(*pos), member),	\
+                    prefetch(pos->member.next))
+#endif
+
+#ifndef list_for_each_entry_safe
+#define list_for_each_entry_safe(pos, n, head, member)                  \
+        for (pos = list_entry((head)->next, typeof(*pos), member),      \
+                n = list_entry(pos->member.next, typeof(*pos), member); \
+             &pos->member != (head);                                    \
+             pos = n, n = list_entry(n->member.next, typeof(*n), member))
+#endif
+
+#ifndef __user
+#define __user
+#endif
+
+#if !defined(__put_page)
+#define __put_page(p)           atomic_dec(&(p)->count)
+#endif
+
+#if !defined(__GFP_COMP)
+#define __GFP_COMP 0
+#endif
+
+#if !defined(IRQF_SHARED)
+#define IRQF_SHARED SA_SHIRQ
+#endif
+
+#ifndef DEFINE_SPINLOCK
+#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
+#endif
+
+/* old architectures */
+#ifdef __AMD64__
+#define __x86_64__
+#endif
+
+/* sysfs __ATTR macro */
+#ifndef __ATTR
+#define __ATTR(_name,_mode,_show,_store) { \
+        .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE },     \
+        .show   = _show,                                        \
+        .store  = _store,                                       \
+}
+#endif
+
+#ifndef list_for_each_entry_safe_reverse
+#define list_for_each_entry_safe_reverse(pos, n, head, member)          \
+        for (pos = list_entry((head)->prev, typeof(*pos), member),      \
+                n = list_entry(pos->member.prev, typeof(*pos), member); \
+             &pos->member != (head);                                    \
+             pos = n, n = list_entry(n->member.prev, typeof(*n), member))
+#endif
+
+#include <linux/mm.h>
+#include <asm/page.h>
+
+/*
+ * Flush relevant caches and clear a VMA structure so that page references
+ * will cause a page fault. Don't flush tlbs.
+ */
+
+extern void drm_clear_vma(struct vm_area_struct *vma,
+			  unsigned long addr, unsigned long end);
+
+/*
+ * Return the PTE protection map entries for the VMA flags given by
+ * flags. This is a functional interface to the kernel's protection map.
+ */
+
+extern pgprot_t vm_get_page_prot(unsigned long vm_flags);
+
+#ifndef GFP_DMA32
+#define GFP_DMA32 GFP_KERNEL
+#endif
+#ifndef __GFP_DMA32
+#define __GFP_DMA32 GFP_KERNEL
+#endif
+
+/* fixme when functions are upstreamed - upstreamed for 2.6.23 */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23))
+#define DRM_IDR_COMPAT_FN
+#define DRM_NO_FAULT
+extern unsigned long drm_bo_vm_nopfn(struct vm_area_struct *vma,
+				     unsigned long address);
+#endif
+#ifdef DRM_IDR_COMPAT_FN
+int idr_for_each(struct idr *idp,
+		 int (*fn)(int id, void *p, void *data), void *data);
+void idr_remove_all(struct idr *idp);
+#endif
+
+
+#if !defined(flush_agp_mappings)
+#define flush_agp_mappings() do {} while(0)
+#endif
+
+#ifndef DMA_BIT_MASK
+#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : (1ULL<<(n)) - 1)
+#endif
+
+#ifndef VM_CAN_NONLINEAR
+#define DRM_VM_NOPAGE 1
+#endif
+
+#ifdef DRM_VM_NOPAGE
+
+extern struct page *drm_vm_nopage(struct vm_area_struct *vma,
+				  unsigned long address, int *type);
+
+extern struct page *drm_vm_shm_nopage(struct vm_area_struct *vma,
+				      unsigned long address, int *type);
+
+extern struct page *drm_vm_dma_nopage(struct vm_area_struct *vma,
+				      unsigned long address, int *type);
+
+extern struct page *drm_vm_sg_nopage(struct vm_area_struct *vma,
+				     unsigned long address, int *type);
+#endif
+
+#ifndef OS_HAS_GEM
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
+#define OS_HAS_GEM 1
+#else
+#define OS_HAS_GEM 0
+#endif
+#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
+#define set_page_locked SetPageLocked
+#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
+/*
+ * The kernel provides __set_page_locked, which uses the non-atomic
+ * __set_bit function. Let's use the atomic set_bit just in case.
+ */
+static inline void set_page_locked(struct page *page)
+{
+	set_bit(PG_locked, &page->flags);
+}
+#endif
+
+#ifndef VM_NORESERVE
+/* Just ignore this flag, if it is not available in kernel. */
+#define VM_NORESERVE 0
+#endif
+
+#ifndef _PAGE_CACHE_WC
+/* Just ignore this flag, if it is not available in kernel. */
+#define _PAGE_CACHE_WC 0
+#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25))
+static inline void agp_flush_chipset(struct agp_bridge_data *bridge)
+{
+	/* This should break only Intel stuff. */
+	(void)bridge;
+}
+
+static inline int set_memory_uc(unsigned long addr, int numpages)
+{
+	(void)addr, (void)numpages;
+	return 0;
+}
+
+static inline int set_memory_wb(unsigned long addr, int numpages)
+{
+	(void)addr, (void)numpages;
+	return 0;
+}
+
+static inline int set_memory_wc(unsigned long addr, int numpages)
+{
+	(void)addr, (void)numpages;
+	return 0;
+}
+#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26))
+static inline void __iomem *ioremap_wc(unsigned long phys_addr,
+						unsigned long size)
+{
+	return ioremap(phys_addr, size);
+}
+
+#define VM_MIXEDMAP VM_PFNMAP
+static inline int vm_insert_mixed(struct vm_area_struct *vma,
+				unsigned long addr, unsigned long pfn)
+{
+	return vm_insert_pfn(vma, addr, pfn);
+}
+
+#define DRM_COMPAT_NEEDS_DEV_SET_NAME 1
+int dev_set_name(struct device *dev, const char *fmt, ...);
+#endif
+
+#ifndef WARN
+#define WARN(condition, format...) WARN_ON(condition)
+#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
+#define dma_mapping_error(dev, addr) dma_mapping_error(addr)
+#define pci_dma_mapping_error(dev, addr) pci_dma_mapping_error(addr)
+#endif
+
+#ifndef upper_32_bits
+#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
+#endif
+#ifndef lower_32_bits
+#define lower_32_bits(n) ((u32)(n))
+#endif
+
+#endif
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index 3b78927..d30087c 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -30,6 +30,7 @@
  */
 
 #include "drmP.h"
+#include "drm_compat.h"
 #include "drm_crtc.h"
 #include "drm_crtc_helper.h"
 
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 4f1a405..1b6089b 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -35,6 +35,7 @@
  */
 
 #include "drmP.h"
+#include "drm_compat.h"
 #include <linux/poll.h>
 #include <linux/smp_lock.h>
 
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 2e4e667..61403f1 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -35,6 +35,7 @@
 #include <linux/mman.h>
 #include <linux/pagemap.h>
 #include "drmP.h"
+#include "drm_compat.h"
 
 /** @file drm_gem.c
  *
diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
index 4942f9d..19ee7ab 100644
--- a/drivers/gpu/drm/drm_memory.c
+++ b/drivers/gpu/drm/drm_memory.c
@@ -35,6 +35,7 @@
 
 #include <linux/highmem.h>
 #include "drmP.h"
+#include "drm_compat.h"
 
 
 static struct {
diff --git a/drivers/gpu/drm/drm_page_alloc.c b/drivers/gpu/drm/drm_page_alloc.c
index fad6ae3..83d63d8 100644
--- a/drivers/gpu/drm/drm_page_alloc.c
+++ b/drivers/gpu/drm/drm_page_alloc.c
@@ -32,6 +32,7 @@
  */
 
 #include "drmP.h"
+#include "drm_compat.h"
 #include <asm/agp.h>
 
 #include "drm_page_alloc.h"
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index f7510a8..bd9d57d 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -18,6 +18,7 @@
 
 #include "drm_core.h"
 #include "drmP.h"
+#include "drm_compat.h"
 
 #define to_drm_minor(d) container_of(d, struct drm_minor, kdev)
 #define to_drm_connector(d) container_of(d, struct drm_connector, kdev)
diff --git a/drivers/gpu/drm/drm_ttm.c b/drivers/gpu/drm/drm_ttm.c
index ec5f140..cfc829b 100644
--- a/drivers/gpu/drm/drm_ttm.c
+++ b/drivers/gpu/drm/drm_ttm.c
@@ -29,6 +29,7 @@
  */
 
 #include "drmP.h"
+#include "drm_compat.h"
 #include <asm/agp.h>
 
 /**
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 9443402..26caec9 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -34,10 +34,11 @@
  */
 
 #include "drmP.h"
+#include "drm_compat.h"
 #if defined(__ia64__)
 #include <linux/efi.h>
 #endif
-#if defined(CONFIG_X86)
+#if defined(CONFIG_X86) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
 #include <asm/pat.h>
 #endif
 
diff --git a/drivers/gpu/drm/nouveau/Makefile b/drivers/gpu/drm/nouveau/Makefile
index 12af41b..4bb91c6 100644
--- a/drivers/gpu/drm/nouveau/Makefile
+++ b/drivers/gpu/drm/nouveau/Makefile
@@ -21,4 +21,4 @@ nouveau-y := nouveau_drv.o nouveau_state.o nouveau_fifo.o nouveau_mem.o \
 
 nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o
 
-obj-$(CONFIG_DRM_NOUVEAU)+= nouveau.o
+obj-m += nouveau.o
diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
index 3fc521e..865440f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
+++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
@@ -31,6 +31,7 @@
  */
 
 #include <linux/backlight.h>
+#include <linux/version.h>
 
 #include "drmP.h"
 #include "nouveau_drv.h"
@@ -60,7 +61,9 @@ static int nv40_set_intensity(struct backlight_device *bd)
 }
 
 static struct backlight_ops nv40_bl_ops = {
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
 	.options = BL_CORE_SUSPENDRESUME,
+#endif
 	.get_brightness = nv40_get_intensity,
 	.update_status = nv40_set_intensity,
 };
@@ -85,7 +88,9 @@ static int nv50_set_intensity(struct backlight_device *bd)
 }
 
 static struct backlight_ops nv50_bl_ops = {
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
 	.options = BL_CORE_SUSPENDRESUME,
+#endif
 	.get_brightness = nv50_get_intensity,
 	.update_status = nv50_set_intensity,
 };
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index dc52670..30f45d4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -31,6 +31,7 @@
 #include "nouveau_drm.h"
 #include "nouveau_drv.h"
 #include "nouveau_dma.h"
+#include "../drm_compat.h"
 
 static struct drm_ttm_backend *
 nouveau_bo_create_ttm_backend_entry(struct drm_device * dev)
diff --git a/drivers/gpu/drm/nouveau/nouveau_object.c b/drivers/gpu/drm/nouveau/nouveau_object.c
index 068797b..b74e94f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_object.c
+++ b/drivers/gpu/drm/nouveau/nouveau_object.c
@@ -34,6 +34,7 @@
 #include "drm.h"
 #include "nouveau_drv.h"
 #include "nouveau_drm.h"
+#include "../drm_compat.h"
 
 /* NVidia uses context objects to drive drawing operations.
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
index 3be7235..b7861e9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
@@ -1,6 +1,7 @@
 #include "drmP.h"
 #include "nouveau_drv.h"
 #include <linux/pagemap.h>
+#include "../drm_compat.h"
 
 #define NV_CTXDMA_PAGE_SHIFT 12
 #define NV_CTXDMA_PAGE_SIZE  (1 << NV_CTXDMA_PAGE_SHIFT)
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c
index 2988664..91c393a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_state.c
+++ b/drivers/gpu/drm/nouveau/nouveau_state.c
@@ -23,7 +23,12 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include <linux/version.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
+#include <asm/byteorder.h>
+#else
 #include <linux/swab.h>
+#endif
 
 #include "drmP.h"
 #include "drm.h"

[-- Attachment #4: kernel-compat-24.patch --]
[-- Type: text/plain, Size: 303 bytes --]

--- mm/shmem-orig.c	2009-03-19 22:38:36.000000000 +0200
+++ mm/shmem.c	2009-03-19 22:52:05.000000000 +0200
@@ -2562,6 +2562,7 @@ put_memory:
 	shmem_unacct_size(flags, size);
 	return ERR_PTR(error);
 }
+EXPORT_SYMBOL_GPL(shmem_file_setup);
 
 /*
  * shmem_zero_setup - setup a shared anonymous mapping

[-- Attachment #5: Type: text/plain, Size: 181 bytes --]

_______________________________________________
Nouveau mailing list
Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: DRM changes
       [not found]             ` <1237043038.5825.11.camel-eMQg5G+HfYU7zld1fzGs+w@public.gmane.org>
@ 2009-03-25 13:14               ` Maarten Maathuis
  0 siblings, 0 replies; 11+ messages in thread
From: Maarten Maathuis @ 2009-03-25 13:14 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Is there a final verdict yet?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: DRM changes
       [not found] ` <6a89f9d50903091449w47c8a79ak37124972b91a6fde-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
                     ` (2 preceding siblings ...)
  2009-03-20 23:48   ` Building rawhide+darktama on 2.6.24 (Re: DRM changes) Pekka Paalanen
@ 2009-03-31 18:17   ` Pekka Paalanen
  3 siblings, 0 replies; 11+ messages in thread
From: Pekka Paalanen @ 2009-03-31 18:17 UTC (permalink / raw)
  To: Stephane Marchesin, nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	Dave Airlie

On Mon, 9 Mar 2009 22:49:32 +0100
Stephane Marchesin <marchesin-YynmYXH4S6491FlJP1ih0VAUjnlXr6A1@public.gmane.org> wrote:

> Hi,
> 
> As part of aiming at upstreaming our code, I suppose we have to
> discuss the DRM situation a little. In order to aim for merging, I
> think we'd better be working on a linux kernel tree layout. And
> considering we're technically the only ones still working in drm.git,
> it doesn't really make sense to keep doing that for the sake of
> sharing code with other drivers.
> 
> As we discussed on irc, there would be multiple changes related to this:
> - we move to a linux kernel-like tree, that should make it easier when
> upstreaming the code.
> - this new tree is hosted in freedekstop.org in the nouveau/ git so we
> don't need additional accounts for everyone all around and people can
> keep pushing things (even better, all nouveau people can push to the
> drm, which used to require mesa rights before)
> - we keep a(some) branch(es) in the tree for backwards compat with
> older kernels. Either in the form of separate kernel versions
> including nouveau, or in the form of an out-of-tree-compilable
> drm/nouveau module.
> 
> So, does that plan sound sane? Do you have better plans?

I had a discussion with darktama (Ben) about this.
Dave, there are questions specifically for you.
Marcheu, we need your verdict after Dave's comments.

Using a kernel tree would free Ben and others from backporting
things to drm.git. My "Building rawhide+darktama on 2.6.24"
experiment shows, that it is possible to reach practically the
same level of ease as drm.git offers to users. More on this later.
One major point here is to keep the Nouveau DRM development in
one place.

The downside is that BSD devels will probably get hurt. The
backporting work Ben and others are doing now will fall onto them.
Yet we cannot really stick to drm.git if we want upstream, since
de facto upstream is Linux. Someone has to do the porting and it's
pretty much a trade-off between helping BSDs or concentrating on
core development.

Why have a full kernel tree, and not just drivers/gpu/?
Because then it is easy to merge from upstream back to our tree.

My proposition follows:

Step 1: Nouveau development tree

This will be a complete kernel tree hosted at freedesktop.org.
Ben is ready to request it from fd.o. This tree will be free for all
developers to commit, adhering to kernel coding style. This is
NOT a tree that will be sent upstream, but all (future) patches
must be as upstream-quality as possible. This tree will
completely replace drm.git's shared-core and linux-core directories.

This tree is never rebased. Ever. Period. Upstream kernel
development will be marged back here, but we do not rebase.
Whatever gets pushed into the repo, stays there. This offers
a solid ground for devels to base their private work on.
Somewhat related, read also this:
http://sourceforge.net/mailarchive/message.php?msg_name=alpine.LFD.2.00.0903291409030.3994%40localhost.localdomain

The $1M question: which kernel tree will this be based on?
Ben tells me Dave's drm-next[1] gets rebased sometimes.

Dave, what are your plans on drm-next now after Linus'
comments? Are you able to offer a DRM kernel tree that will
not be rebased, and that we could use as the base?

Since this is not an upstreaming tree, it should not matter
too much when we pull updates from upstream, but we probably
need a policy for it.

Compatibility for older kernels can be implemented as a
branch in this tree, let's call it compat. Compat starts as a
fork of master, gets the basic compatibility patches from me,
and then we periodically just merge master into compat to keep
it up-to-date. If compatibility needs some fixes, they are just
committed into the branch. This keeps the main development and
backwards compat separate. I can maintain the compat stuff for
now, and I will also have personal interest as long as I use
2.6.24. The single compat branch will serve "all" old kernels
using #ifdefs. The compat branch is used with out-of-tree compiling.

There are several ways to offer the branches to users:
- cgit.fd.o can produce tar-balls of the complete tree, i.e. snapshots
- someone could set up an automatic snapshot service, that packages
only the drivers/gpu/ directory and other relevant files instead of
the full kernel tree
- users can clone the kernel tree without history, and still later
use git-fetch or git-pull to stay up-to-date. (See git-clone --depth)

It is possible to build drm.ko and nouveau.ko out-of-tree. This means
the modules are built from the Nouveau kernel tree sources, but
for (with) whatever kernel the user is already running (provided the
configuration supports Nouveau, and we have compat stuff for the
kernel version). The commands are a bit long,
but we can offer a script that nicely automates it, and also checks
the kernel config. I think we can get pretty close to how easy
drm.git is for building kernel modules. Currently there is one
nasty obstacle: some older kernels are missing
EXPORT_SYMBOL_GPL(shmem_file_setup), which means the user needs to
patch that in. Ben says we should be able to work around that in near
future.


Step 2: Nouveau upstreaming tree

Because the development tree is a development tree, and from the
kernel's perspective is a private tree, it will not be used for
upstreaming. As you know, accidents happen in development trees, and
the patches do not get reviewed before being pushed. A separate tree
is made for upstreaming.

This tree will live in kernel.org and have a dedicated maintainer,
who will cherry-pick patches from the Nouveau development tree for
upstreaming. The upstreaming tree is based on whatever Dave wants,
as the patches (or maybe pull-requests, when the practices have
stabilized) will be sent to Dave.

There is no need to create the upstreaming tree until Nouveau is
in the shape that it could start pushing for upstream. Hopefully
by then we have also found the maintainer (or two). Personally
I cannot promise to take this task, since I am not convinced I
have the time to do it well.

In the meanwhile, we should rehearse making upstream-quality
patches in the development tree.


Marcheu, what do you think about this? Let's give Ben the green light?
Dave, do you think the git use policy I described is feasible?

Comments, objections?
I have read the earlier comments on this thread and hope to have
answered all concerns.

A hint for kernel git trees: gitk -n 1000


Thanks.


[1] http://git.kernel.org/?p=linux/kernel/git/airlied/drm-2.6.git;a=summary

-- 
Pekka Paalanen
http://www.iki.fi/pq/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: DRM changes
       [not found] ` <49B7F19C.1080404-CC+yJ3UmIYqDUpFQwHEjaQ@public.gmane.org>
@ 2009-03-12 13:40   ` Alexey Dobriyan
  0 siblings, 0 replies; 11+ messages in thread
From: Alexey Dobriyan @ 2009-03-12 13:40 UTC (permalink / raw)
  To: Stuart Bennett; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Wed, Mar 11, 2009 at 05:15:08PM +0000, Stuart Bennett wrote:
> Stephane Marchesin wrote:
> > Hi,
> > 
> > As part of aiming at upstreaming our code, I suppose we have to
> > discuss the DRM situation a little. In order to aim for merging, I
> > think we'd better be working on a linux kernel tree layout. And
> > considering we're technically the only ones still working in drm.git,
> > it doesn't really make sense to keep doing that for the sake of
> > sharing code with other drivers.
> > 
> > As we discussed on irc, there would be multiple changes related to this:
> > - we move to a linux kernel-like tree, that should make it easier when
> > upstreaming the code.
> > - this new tree is hosted in freedekstop.org in the nouveau/ git so we
> > don't need additional accounts for everyone all around and people can
> > keep pushing things (even better, all nouveau people can push to the
> > drm, which used to require mesa rights before)
> > - we keep a(some) branch(es) in the tree for backwards compat with
> > older kernels. Either in the form of separate kernel versions
> > including nouveau, or in the form of an out-of-tree-compilable
> > drm/nouveau module.
> > 
> > So, does that plan sound sane? Do you have better plans?
> > 
> > Stephane
> 
> (apologies for the crappy mailman archive->email forgery)
> 
> I have reservations about a full Linux kernel tree, if that's the proposal.
> 
> Assuming it is a relatively important goal that people should test 
> Nouveau, then it makes sense to make it as easy as possible for them to 
> do so.  Certainly as long as Nouveau has not merged to the Linux kernel, 
> our repository is the only (non-packaged) source for those wishing to 
> test.  Post merge, some repository other than Linus' kernel is still 
> going to be the place to point people at for new development and fixes 
> which are not in a kernel.org stable release.
> 
> I'd suggest that a) requiring 0.5 - 1 hour to git clone the half-gig or 
> so of our new kernel-based tree (longer if the fd.o machinery is having 
> a bad day)

If user already has Linus's tree (or some tree based on it), then there is
no need to fetch most of it again.

> and b) needing people to then checkout some random branch in 
> order for it to work with their kernel ( c) would be rebuild their 
> kernel, if the out-of-tree compilable thing doesn't happen ), are all 
> barriers to testers that are not currently there.  Although my usage may 
> be atypical (or git outdated), the repository size issue also bites 
> developers; cold-cache git diff and git status on the linux kernel takes 
> a noticeable time,

You don't do just git-diff, you do git-diff drivers/gpu/drm/ .

> and gitk, even if regularly invoked, eats disk and 
> processor for ages on each execution.
> 
> If the goal of these changes is to have a more Linux kernel-like layout, 
> could we not just change drm/linux-core, or make a new repo, so that it 
> mirrored everything necessary under drivers/drm?  I believe airlied 
> suggested this ages ago, and it would make moving code from Linux to 
> Nouveau or the other way round simpler.  Admittedly this doesn't work if 
> for some reason your development demands changes elsewhere in the Linux 
> tree, but in that case you may well have already failed the back-compat 
> aspect.
> 
> As for branching and back-compat, I'd have thought it more useful to 
> keep compat on the main branch (again, helping testers), and split 
> specific kernel-merge-aimed branches off from that, as automating ifdef 
> removal on a branch ought to be easier than manually adding compat to a 
> bunch of branches, but I guess in some way the solutions here are all 
> equivalent, and it's just which branch you bless as being called master.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: DRM changes
@ 2009-03-11 17:15 Stuart Bennett
       [not found] ` <49B7F19C.1080404-CC+yJ3UmIYqDUpFQwHEjaQ@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Stuart Bennett @ 2009-03-11 17:15 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Stephane Marchesin wrote:
> Hi,
> 
> As part of aiming at upstreaming our code, I suppose we have to
> discuss the DRM situation a little. In order to aim for merging, I
> think we'd better be working on a linux kernel tree layout. And
> considering we're technically the only ones still working in drm.git,
> it doesn't really make sense to keep doing that for the sake of
> sharing code with other drivers.
> 
> As we discussed on irc, there would be multiple changes related to this:
> - we move to a linux kernel-like tree, that should make it easier when
> upstreaming the code.
> - this new tree is hosted in freedekstop.org in the nouveau/ git so we
> don't need additional accounts for everyone all around and people can
> keep pushing things (even better, all nouveau people can push to the
> drm, which used to require mesa rights before)
> - we keep a(some) branch(es) in the tree for backwards compat with
> older kernels. Either in the form of separate kernel versions
> including nouveau, or in the form of an out-of-tree-compilable
> drm/nouveau module.
> 
> So, does that plan sound sane? Do you have better plans?
> 
> Stephane

(apologies for the crappy mailman archive->email forgery)

I have reservations about a full Linux kernel tree, if that's the proposal.

Assuming it is a relatively important goal that people should test 
Nouveau, then it makes sense to make it as easy as possible for them to 
do so.  Certainly as long as Nouveau has not merged to the Linux kernel, 
our repository is the only (non-packaged) source for those wishing to 
test.  Post merge, some repository other than Linus' kernel is still 
going to be the place to point people at for new development and fixes 
which are not in a kernel.org stable release.

I'd suggest that a) requiring 0.5 - 1 hour to git clone the half-gig or 
so of our new kernel-based tree (longer if the fd.o machinery is having 
a bad day), and b) needing people to then checkout some random branch in 
order for it to work with their kernel ( c) would be rebuild their 
kernel, if the out-of-tree compilable thing doesn't happen ), are all 
barriers to testers that are not currently there.  Although my usage may 
be atypical (or git outdated), the repository size issue also bites 
developers; cold-cache git diff and git status on the linux kernel takes 
a noticeable time, and gitk, even if regularly invoked, eats disk and 
processor for ages on each execution.

If the goal of these changes is to have a more Linux kernel-like layout, 
could we not just change drm/linux-core, or make a new repo, so that it 
mirrored everything necessary under drivers/drm?  I believe airlied 
suggested this ages ago, and it would make moving code from Linux to 
Nouveau or the other way round simpler.  Admittedly this doesn't work if 
for some reason your development demands changes elsewhere in the Linux 
tree, but in that case you may well have already failed the back-compat 
aspect.

As for branching and back-compat, I'd have thought it more useful to 
keep compat on the main branch (again, helping testers), and split 
specific kernel-merge-aimed branches off from that, as automating ifdef 
removal on a branch ought to be easier than manually adding compat to a 
bunch of branches, but I guess in some way the solutions here are all 
equivalent, and it's just which branch you bless as being called master.

Stuart

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2009-03-31 18:17 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-09 21:49 DRM changes Stephane Marchesin
     [not found] ` <6a89f9d50903091449w47c8a79ak37124972b91a6fde-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-03-09 22:23   ` Maarten Maathuis
     [not found]     ` <6d4bc9fc0903091523n4eff7715oe5249ebb799e298-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-03-10  8:03       ` Stephane Marchesin
2009-03-12 19:21   ` Peter Hjalmarsson
     [not found]     ` <1236885714.21828.6.camel-eMQg5G+HfYU7zld1fzGs+w@public.gmane.org>
2009-03-14 11:18       ` Renato Caldas
     [not found]         ` <1caff7430903140418k434fc82es7927d7015026cea3-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-03-14 15:03           ` Peter Hjalmarsson
     [not found]             ` <1237043038.5825.11.camel-eMQg5G+HfYU7zld1fzGs+w@public.gmane.org>
2009-03-25 13:14               ` Maarten Maathuis
2009-03-20 23:48   ` Building rawhide+darktama on 2.6.24 (Re: DRM changes) Pekka Paalanen
2009-03-31 18:17   ` DRM changes Pekka Paalanen
2009-03-11 17:15 Stuart Bennett
     [not found] ` <49B7F19C.1080404-CC+yJ3UmIYqDUpFQwHEjaQ@public.gmane.org>
2009-03-12 13:40   ` Alexey Dobriyan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.