# Patch for ati-drivers and mm-sources

## intgr

Just in case anyone else is trying to install ati-drivers on mm-sources and failing due to a missing constant called VM_SHM, this quick and dirty hack ought to fix it:

```

--- firegl_public.c.orig        2006-07-13 01:54:25.000000000 +0300

+++ firegl_public.c     2006-07-13 01:54:48.000000000 +0300

@@ -54,6 +54,10 @@

 #endif

 #endif /* LINUX_VERSION_CODE */

+#ifndef VM_SHM

+#define VM_SHM 0x00000000

+#endif

+

 /* The dirty-page-tracking patch included in NLD 9 SMP kernels defines

  * a static inline function that uses a GPL-only symbol in a header

  * file. Therefore any non-GPL module built against such a kernel

```

And add the following line to the end of the src_unpack function of ati-drivers ebuild:

```

epatch "/path/to/vm_shm.patch"

```

I'm personally using this with ati-drivers-8.25.18 and mm-sources-2.6.17-r6

The patch should be pretty safe since the VM_SHM flag had already been deprecated from recent kernels, from include/linux/mm.h:

```

#define VM_SHM      0x00000000   /* Means nothing: delete it later */

```

In case you're having problems with this, don't hesistate to ask.  :Smile: 

----------

## wizatdiz

This is interesting, I will have to give it a try.  I have been just adding VM_SHM back into mm.h to get it to work.  When you move on to mm-sources-2.6.18* you will find that they have pulled UTS_RELEASE from version.h as well.  Again, I just added it back so it look like this:

```
#define UTS_RELEASE "2.6.18-rc1-mm1"

#define LINUX_VERSION_CODE 132626

#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
```

Not sure if the kernel will compile after the edit to version.h but, ati-drivers will emerge and work fine.  If you come up with a similar patch to address this, please post it.  It would be nice to just setup an overlay for the ati-drivers and not have to manually edit the kernel source.

----------

## intgr

Sure, I'll give it a shot once mm-sources-2.6.18* compiles with reiser4 - apparently it's broken currently.

----------

## wizatdiz

I'm on reiser4 as well.  I have had no problems over the past 4 days with this:

```
Use do_sync_read() instead of generic_file_read()

Signed-off-by: Edward Shishkin <edward@namesys.com>

---

 linux-2.6.18-rc1-mm1/fs/reiser4/plugin/file/cryptcompress.c |    2 +-

 linux-2.6.18-rc1-mm1/fs/reiser4/plugin/object.c             |    1 +

 2 files changed, 2 insertions(+), 1 deletion(-)

Index: linux-2.6.18-rc1-mm1/fs/reiser4/plugin/file/cryptcompress.c

===================================================================

--- linux-2.6.18-rc1-mm1/fs/reiser4/plugin/file/cryptcompress.c.orig

+++ linux-2.6.18-rc1-mm1/fs/reiser4/plugin/file/cryptcompress.c

@@ -2883,7 +2883,7 @@

    down_read(&info->lock);

    LOCK_CNT_INC(inode_sem_r);

 

-   result = generic_file_read(file, buf, size, off);

+   result = do_sync_read(file, buf, size, off);

 

    up_read(&info->lock);

    LOCK_CNT_DEC(inode_sem_r);

Index: linux-2.6.18-rc1-mm1/fs/reiser4/plugin/object.c

===================================================================

--- linux-2.6.18-rc1-mm1/fs/reiser4/plugin/object.c.orig

+++ linux-2.6.18-rc1-mm1/fs/reiser4/plugin/object.c

@@ -305,6 +305,7 @@

          .llseek = generic_file_llseek,

          .read = read_cryptcompress,

          .write = write_cryptcompress,

+         .aio_read = generic_file_aio_read,

          .mmap = mmap_cryptcompress,

          .release = release_cryptcompress,

          .fsync = sync_common,

```

----------

## intgr

Thanks, that got me past reiser4, and after applying [1] as well, the kernel seems to compile.

The UTS_RELEASE constant has apparently been moved from <linux/version.h> to <linux/utsrelease.h>, and here's the new patch to ati-drivers:

```

--- firegl_public.c.orig   2006-07-14 07:44:52.000000000 +0300

+++ firegl_public.c   2006-07-14 07:46:25.000000000 +0300

@@ -54,6 +54,14 @@

 #endif

 #endif /* LINUX_VERSION_CODE */

 

+#ifndef UTS_RELEASE

+#include <linux/utsrelease.h>

+#endif

+

+#ifndef VM_SHM

+#define VM_SHM 0

+#endif

+

 /* The dirty-page-tracking patch included in NLD 9 SMP kernels defines

  * a static inline function that uses a GPL-only symbol in a header

  * file. Therefore any non-GPL module built against such a kernel

```

Have fun!

----------

## wizatdiz

You have to love Gentoo for what you learn.  Thanks for the tip and the patch.  I created an overlay and added your patch (mm-fix.patch) into the files folder.  I added this line to the overlay ebuild at the end of the src_unpack() section:

```
epatch ${FILESDIR}/mm-fix.patch
```

ati-drivers-8.26.18-r1 installed fine against mm-sources-2.6.18-rc1-mm2.

----------

## intgr

 *wizatdiz wrote:*   

> I created an overlay and added your patch (mm-fix.patch) into the files folder.

 

Where can that overlay be found?

----------

## wizatdiz

If I had a place to host it, I would.  You can recreate it by doing:

```
mkdir -p /usr/local/portage/x11-drivers/ati-drivers/files

cd /usr/local/portage/x11-drivers/ati-drivers/

nano files/mm-fix.patch

(paste your patch here)

cp /usr/portage/x11-drivers/ati-drivers/ati-drivers-8.26.18-r1.ebuild .

nano ati-drivers-8.26.18-r1.ebuild

(add epatch ${FILESDIR}/mm-fix.patch to line 150)

ebuild ati-drivers-8.26.18-r1.ebuild digest
```

If you don't have this in your make.conf, you will need to add it:

```
PORTDIR_OVERLAY="/usr/local/portage"

```

----------

