Sync with Linux 2.4.0-test11-pre5 Provide backward compatibility tested

against 2.2.18pre21
As usual, since all 2.4.0-test* kernels set LINUX_VERSION_CODE to the same
    value, if you are running a 2.4.0-test kernel, you MUST be running
    2.4.0-test11-pre4 or later (although anything after 2.4.0-test11-pre1
    should work fine -- I tested with pre4/pre5). I expect 2.2.x support to
    continue to work for all recent kernels, but I tested with 2.2.18pre21
    -- we use the old intermodule symbol communication for 2.2.x kernels,
    so they should all continue to work.
main
Rik Faith 2000-11-15 15:47:51 +00:00
parent 0636342ef8
commit 679531e166
22 changed files with 291 additions and 234 deletions

View File

@ -59,15 +59,6 @@
#include <asm/io.h> #include <asm/io.h>
#include <asm/mman.h> #include <asm/mman.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#ifndef copy_to_user_ret
#define copy_to_user_ret(to,from,n,retval) ({ if (copy_to_user(to,from,n)) return retval; })
#endif
#ifndef copy_from_user_ret
#define copy_from_user_ret(to,from,n,retval) ({ if (copy_from_user(to,from,n)) return retval; })
#endif
#ifdef CONFIG_MTRR #ifdef CONFIG_MTRR
#include <asm/mtrr.h> #include <asm/mtrr.h>
#endif #endif
@ -519,19 +510,6 @@ typedef struct drm_agp_head {
unsigned long base; unsigned long base;
int agp_mtrr; int agp_mtrr;
} drm_agp_head_t; } drm_agp_head_t;
typedef struct {
void (*free_memory)(agp_memory *);
agp_memory *(*allocate_memory)(size_t, u32);
int (*bind_memory)(agp_memory *, off_t);
int (*unbind_memory)(agp_memory *);
void (*enable)(u32);
int (*acquire)(void);
void (*release)(void);
void (*copy_info)(agp_kern_info *);
} drm_agp_func_t;
extern drm_agp_func_t drm_agp;
#endif #endif
typedef struct drm_sigdata { typedef struct drm_sigdata {
@ -833,6 +811,7 @@ extern drm_agp_head_t *drm_agp_init(void);
extern void drm_agp_uninit(void); extern void drm_agp_uninit(void);
extern int drm_agp_acquire(struct inode *inode, struct file *filp, extern int drm_agp_acquire(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern void _drm_agp_release(void);
extern int drm_agp_release(struct inode *inode, struct file *filp, extern int drm_agp_release(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int drm_agp_enable(struct inode *inode, struct file *filp, extern int drm_agp_enable(struct inode *inode, struct file *filp,
@ -847,6 +826,10 @@ extern int drm_agp_unbind(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int drm_agp_bind(struct inode *inode, struct file *filp, extern int drm_agp_bind(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern agp_memory *drm_agp_allocate_memory(size_t pages, u32 type);
extern int drm_agp_free_memory(agp_memory *handle);
extern int drm_agp_bind_memory(agp_memory *handle, off_t start);
extern int drm_agp_unbind_memory(agp_memory *handle);
#endif #endif
#endif #endif
#endif #endif

View File

@ -255,8 +255,7 @@ static int i810_takedown(drm_device_t *dev)
} }
dev->agp->memory = NULL; dev->agp->memory = NULL;
if (dev->agp->acquired && drm_agp.release) if (dev->agp->acquired) _drm_agp_release();
(*drm_agp.release)();
dev->agp->acquired = 0; dev->agp->acquired = 0;
dev->agp->enabled = 0; dev->agp->enabled = 0;
@ -338,7 +337,7 @@ static int i810_takedown(drm_device_t *dev)
/* i810_init is called via init_module at module load time, or via /* i810_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */ * linux/init/main.c (this is not currently supported). */
static int i810_init(void) static int __init i810_init(void)
{ {
int retcode; int retcode;
drm_device_t *dev = &i810_device; drm_device_t *dev = &i810_device;
@ -397,7 +396,7 @@ static int i810_init(void)
/* i810_cleanup is called via cleanup_module at module unload time. */ /* i810_cleanup is called via cleanup_module at module unload time. */
static void i810_cleanup(void) static void __exit i810_cleanup(void)
{ {
drm_device_t *dev = &i810_device; drm_device_t *dev = &i810_device;

View File

@ -255,8 +255,7 @@ static int mga_takedown(drm_device_t *dev)
} }
dev->agp->memory = NULL; dev->agp->memory = NULL;
if (dev->agp->acquired && drm_agp.release) if (dev->agp->acquired) _drm_agp_release();
(*drm_agp.release)();
dev->agp->acquired = 0; dev->agp->acquired = 0;
dev->agp->enabled = 0; dev->agp->enabled = 0;
@ -338,7 +337,7 @@ static int mga_takedown(drm_device_t *dev)
/* mga_init is called via init_module at module load time, or via /* mga_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */ * linux/init/main.c (this is not currently supported). */
static int mga_init(void) static int __init mga_init(void)
{ {
int retcode; int retcode;
drm_device_t *dev = &mga_device; drm_device_t *dev = &mga_device;
@ -398,7 +397,7 @@ static int mga_init(void)
/* mga_cleanup is called via cleanup_module at module unload time. */ /* mga_cleanup is called via cleanup_module at module unload time. */
static void mga_cleanup(void) static void __exit mga_cleanup(void)
{ {
drm_device_t *dev = &mga_device; drm_device_t *dev = &mga_device;

View File

@ -252,8 +252,7 @@ static int r128_takedown(drm_device_t *dev)
} }
dev->agp->memory = NULL; dev->agp->memory = NULL;
if (dev->agp->acquired && drm_agp.release) if (dev->agp->acquired) _drm_agp_release();
(*drm_agp.release)();
dev->agp->acquired = 0; dev->agp->acquired = 0;
dev->agp->enabled = 0; dev->agp->enabled = 0;
@ -323,7 +322,7 @@ static int r128_takedown(drm_device_t *dev)
/* r128_init is called via init_module at module load time, or via /* r128_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */ * linux/init/main.c (this is not currently supported). */
static int r128_init(void) static int __init r128_init(void)
{ {
int retcode; int retcode;
drm_device_t *dev = &r128_device; drm_device_t *dev = &r128_device;
@ -387,7 +386,7 @@ static int r128_init(void)
/* r128_cleanup is called via cleanup_module at module unload time. */ /* r128_cleanup is called via cleanup_module at module unload time. */
static void r128_cleanup(void) static void __exit r128_cleanup(void)
{ {
drm_device_t *dev = &r128_device; drm_device_t *dev = &r128_device;

View File

@ -250,7 +250,7 @@ static int sis_takedown(drm_device_t *dev)
drm_free(temp, sizeof(*temp), DRM_MEM_AGPLISTS); drm_free(temp, sizeof(*temp), DRM_MEM_AGPLISTS);
temp = temp_next; temp = temp_next;
} }
if (dev->agp->acquired) (*drm_agp.release)(); if (dev->agp->acquired) _drm_agp_release();
} }
#endif #endif
/* Clear vma list (only built for debugging) */ /* Clear vma list (only built for debugging) */
@ -394,17 +394,16 @@ int sis_version(struct inode *inode, struct file *filp, unsigned int cmd,
drm_version_t version; drm_version_t version;
int len; int len;
copy_from_user_ret(&version, if (copy_from_user(&version, (drm_version_t *)arg, sizeof(version)))
(drm_version_t *)arg, return -EFAULT;
sizeof(version),
-EFAULT);
#define DRM_COPY(name,value) \ #define DRM_COPY(name,value) \
len = strlen(value); \ len = strlen(value); \
if (len > name##_len) len = name##_len; \ if (len > name##_len) len = name##_len; \
name##_len = strlen(value); \ name##_len = strlen(value); \
if (len && name) { \ if (len && name) { \
copy_to_user_ret(name, value, len, -EFAULT); \ if (copy_to_user(name, value, len)) \
return -EFAULT; \
} }
version.version_major = SIS_MAJOR; version.version_major = SIS_MAJOR;
@ -415,10 +414,8 @@ int sis_version(struct inode *inode, struct file *filp, unsigned int cmd,
DRM_COPY(version.date, SIS_DATE); DRM_COPY(version.date, SIS_DATE);
DRM_COPY(version.desc, SIS_DESC); DRM_COPY(version.desc, SIS_DESC);
copy_to_user_ret((drm_version_t *)arg, if (copy_to_user((drm_version_t *)arg, &version, sizeof(version)))
&version, return -EFAULT;
sizeof(version),
-EFAULT);
return 0; return 0;
} }
@ -533,7 +530,8 @@ int sis_lock(struct inode *inode, struct file *filp, unsigned int cmd,
dev->lck_start = start = get_cycles(); dev->lck_start = start = get_cycles();
#endif #endif
copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
return -EFAULT;
if (lock.context == DRM_KERNEL_CONTEXT) { if (lock.context == DRM_KERNEL_CONTEXT) {
DRM_ERROR("Process %d using kernel context %d\n", DRM_ERROR("Process %d using kernel context %d\n",
@ -667,7 +665,8 @@ int sis_unlock(struct inode *inode, struct file *filp, unsigned int cmd,
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
drm_lock_t lock; drm_lock_t lock;
copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
return -EFAULT;
if (lock.context == DRM_KERNEL_CONTEXT) { if (lock.context == DRM_KERNEL_CONTEXT) {
DRM_ERROR("Process %d using kernel context %d\n", DRM_ERROR("Process %d using kernel context %d\n",

View File

@ -235,7 +235,7 @@ static int tdfx_takedown(drm_device_t *dev)
drm_free(temp, sizeof(*temp), DRM_MEM_AGPLISTS); drm_free(temp, sizeof(*temp), DRM_MEM_AGPLISTS);
temp = temp_next; temp = temp_next;
} }
if (dev->agp->acquired) (*drm_agp.release)(); if (dev->agp->acquired) _drm_agp_release();
} }
#endif #endif
/* Clear vma list (only built for debugging) */ /* Clear vma list (only built for debugging) */
@ -298,7 +298,7 @@ static int tdfx_takedown(drm_device_t *dev)
/* tdfx_init is called via init_module at module load time, or via /* tdfx_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */ * linux/init/main.c (this is not currently supported). */
static int tdfx_init(void) static int __init tdfx_init(void)
{ {
int retcode; int retcode;
drm_device_t *dev = &tdfx_device; drm_device_t *dev = &tdfx_device;
@ -346,7 +346,7 @@ static int tdfx_init(void)
/* tdfx_cleanup is called via cleanup_module at module unload time. */ /* tdfx_cleanup is called via cleanup_module at module unload time. */
static void tdfx_cleanup(void) static void __exit tdfx_cleanup(void)
{ {
drm_device_t *dev = &tdfx_device; drm_device_t *dev = &tdfx_device;

115
linux/agpsupport-pre24.h Normal file
View File

@ -0,0 +1,115 @@
/* agpsupport-pre24.h -- Support for pre-2.4.0 kernels -*- linux-c -*-
* Created: Mon Nov 13 10:54:15 2000 by faith@valinux.com
*
* 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
* PRECISION INSIGHT 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.
*
* Author: Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
#ifndef _AGPSUPPORT_PRE24_H_
#define _AGPSUPPORT_PRE24_H_
typedef struct {
void (*free_memory)(agp_memory *);
agp_memory *(*allocate_memory)(size_t, u32);
int (*bind_memory)(agp_memory *, off_t);
int (*unbind_memory)(agp_memory *);
void (*enable)(u32);
int (*acquire)(void);
void (*release)(void);
void (*copy_info)(agp_kern_info *);
} drm_agp_t;
static drm_agp_t drm_agp_struct = {
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
/* The C standard says that 'void *' is not guaranteed to hold a function
pointer, so we use this union to define a generic pointer that is
guaranteed to hold any of the function pointers we care about. */
typedef union {
void (*free_memory)(agp_memory *);
agp_memory *(*allocate_memory)(size_t, u32);
int (*bind_memory)(agp_memory *, off_t);
int (*unbind_memory)(agp_memory *);
void (*enable)(u32);
int (*acquire)(void);
void (*release)(void);
void (*copy_info)(agp_kern_info *);
unsigned long address;
} drm_agp_func_u;
typedef struct drm_agp_fill {
const char *name;
drm_agp_func_u *f;
} drm_agp_fill_t;
static drm_agp_fill_t drm_agp_fill[] = {
{ __MODULE_STRING(agp_free_memory),
(drm_agp_func_u *)&drm_agp_struct.free_memory },
{ __MODULE_STRING(agp_allocate_memory),
(drm_agp_func_u *)&drm_agp_struct.allocate_memory },
{ __MODULE_STRING(agp_bind_memory),
(drm_agp_func_u *)&drm_agp_struct.bind_memory },
{ __MODULE_STRING(agp_unbind_memory),
(drm_agp_func_u *)&drm_agp_struct.unbind_memory },
{ __MODULE_STRING(agp_enable),
(drm_agp_func_u *)&drm_agp_struct.enable },
{ __MODULE_STRING(agp_backend_acquire),
(drm_agp_func_u *)&drm_agp_struct.acquire },
{ __MODULE_STRING(agp_backend_release),
(drm_agp_func_u *)&drm_agp_struct.release },
{ __MODULE_STRING(agp_copy_info),
(drm_agp_func_u *)&drm_agp_struct.copy_info },
{ NULL, NULL }
};
#define DRM_AGP_GET _drm_agp_get()
#define DRM_AGP_PUT _drm_agp_put()
static drm_agp_t *_drm_agp_get(void)
{
drm_agp_fill_t *fill;
int agp_available = 1;
for (fill = &drm_agp_fill[0]; fill->name; fill++) {
char *n = (char *)fill->name;
*fill->f = (drm_agp_func_u)get_module_symbol(NULL, n);
DRM_DEBUG("%s resolves to 0x%08lx\n", n, (*fill->f).address);
if (!(*fill->f).address) agp_available = 0;
}
return &drm_agp_struct;
}
static void _drm_agp_put(void)
{
drm_agp_fill_t *fill;
for (fill = &drm_agp_fill[0]; fill->name; fill++) {
#if LINUX_VERSION_CODE >= 0x020400
if ((*fill->f).address) put_module_symbol((*fill->f).address);
#endif
(*fill->f).address = 0;
}
}
#endif

View File

@ -31,48 +31,14 @@
#define __NO_VERSION__ #define __NO_VERSION__
#include "drmP.h" #include "drmP.h"
#include <linux/module.h> #include <linux/module.h>
#if LINUX_VERSION_CODE < 0x020400
#include "agpsupport-pre24.h"
#else
#define DRM_AGP_GET (drm_agp_t *)inter_module_get("drm_agp")
#define DRM_AGP_PUT inter_module_put("drm_agp")
#endif
drm_agp_func_t drm_agp = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; static const drm_agp_t *drm_agp = NULL;
/* The C standard says that 'void *' is not guaranteed to hold a function
pointer, so we use this union to define a generic pointer that is
guaranteed to hold any of the function pointers we care about. */
typedef union {
void (*free_memory)(agp_memory *);
agp_memory *(*allocate_memory)(size_t, u32);
int (*bind_memory)(agp_memory *, off_t);
int (*unbind_memory)(agp_memory *);
void (*enable)(u32);
int (*acquire)(void);
void (*release)(void);
void (*copy_info)(agp_kern_info *);
unsigned long address;
} drm_agp_func_u;
typedef struct drm_agp_fill {
const char *name;
drm_agp_func_u *f;
} drm_agp_fill_t;
static drm_agp_fill_t drm_agp_fill[] = {
{ __MODULE_STRING(agp_free_memory),
(drm_agp_func_u *)&drm_agp.free_memory },
{ __MODULE_STRING(agp_allocate_memory),
(drm_agp_func_u *)&drm_agp.allocate_memory },
{ __MODULE_STRING(agp_bind_memory),
(drm_agp_func_u *)&drm_agp.bind_memory },
{ __MODULE_STRING(agp_unbind_memory),
(drm_agp_func_u *)&drm_agp.unbind_memory },
{ __MODULE_STRING(agp_enable),
(drm_agp_func_u *)&drm_agp.enable },
{ __MODULE_STRING(agp_backend_acquire),
(drm_agp_func_u *)&drm_agp.acquire },
{ __MODULE_STRING(agp_backend_release),
(drm_agp_func_u *)&drm_agp.release },
{ __MODULE_STRING(agp_copy_info),
(drm_agp_func_u *)&drm_agp.copy_info },
{ NULL, NULL }
};
int drm_agp_info(struct inode *inode, struct file *filp, unsigned int cmd, int drm_agp_info(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg) unsigned long arg)
@ -82,7 +48,7 @@ int drm_agp_info(struct inode *inode, struct file *filp, unsigned int cmd,
agp_kern_info *kern; agp_kern_info *kern;
drm_agp_info_t info; drm_agp_info_t info;
if (!dev->agp->acquired || !drm_agp.copy_info) return -EINVAL; if (!dev->agp->acquired || !drm_agp->copy_info) return -EINVAL;
kern = &dev->agp->agp_info; kern = &dev->agp->agp_info;
info.agp_version_major = kern->version.major; info.agp_version_major = kern->version.major;
@ -107,8 +73,8 @@ int drm_agp_acquire(struct inode *inode, struct file *filp, unsigned int cmd,
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
int retcode; int retcode;
if (dev->agp->acquired || !drm_agp.acquire) return -EINVAL; if (dev->agp->acquired || !drm_agp->acquire) return -EINVAL;
if ((retcode = (*drm_agp.acquire)())) return retcode; if ((retcode = drm_agp->acquire())) return retcode;
dev->agp->acquired = 1; dev->agp->acquired = 1;
return 0; return 0;
} }
@ -119,13 +85,18 @@ int drm_agp_release(struct inode *inode, struct file *filp, unsigned int cmd,
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
if (!dev->agp->acquired || !drm_agp.release) return -EINVAL; if (!dev->agp->acquired || !drm_agp->release) return -EINVAL;
(*drm_agp.release)(); drm_agp->release();
dev->agp->acquired = 0; dev->agp->acquired = 0;
return 0; return 0;
} }
void _drm_agp_release(void)
{
if (drm_agp->release) drm_agp->release();
}
int drm_agp_enable(struct inode *inode, struct file *filp, unsigned int cmd, int drm_agp_enable(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
@ -133,13 +104,13 @@ int drm_agp_enable(struct inode *inode, struct file *filp, unsigned int cmd,
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
drm_agp_mode_t mode; drm_agp_mode_t mode;
if (!dev->agp->acquired || !drm_agp.enable) return -EINVAL; if (!dev->agp->acquired || !drm_agp->enable) return -EINVAL;
if (copy_from_user(&mode, (drm_agp_mode_t *)arg, sizeof(mode))) if (copy_from_user(&mode, (drm_agp_mode_t *)arg, sizeof(mode)))
return -EFAULT; return -EFAULT;
dev->agp->mode = mode.mode; dev->agp->mode = mode.mode;
(*drm_agp.enable)(mode.mode); drm_agp->enable(mode.mode);
dev->agp->base = dev->agp->agp_info.aper_base; dev->agp->base = dev->agp->agp_info.aper_base;
dev->agp->enabled = 1; dev->agp->enabled = 1;
return 0; return 0;
@ -231,7 +202,7 @@ int drm_agp_bind(struct inode *inode, struct file *filp, unsigned int cmd,
int retcode; int retcode;
int page; int page;
if (!dev->agp->acquired || !drm_agp.bind_memory) return -EINVAL; if (!dev->agp->acquired || !drm_agp->bind_memory) return -EINVAL;
if (copy_from_user(&request, (drm_agp_binding_t *)arg, sizeof(request))) if (copy_from_user(&request, (drm_agp_binding_t *)arg, sizeof(request)))
return -EFAULT; return -EFAULT;
if (!(entry = drm_agp_lookup_entry(dev, request.handle))) if (!(entry = drm_agp_lookup_entry(dev, request.handle)))
@ -270,24 +241,14 @@ int drm_agp_free(struct inode *inode, struct file *filp, unsigned int cmd,
drm_agp_head_t *drm_agp_init(void) drm_agp_head_t *drm_agp_init(void)
{ {
drm_agp_fill_t *fill;
drm_agp_head_t *head = NULL; drm_agp_head_t *head = NULL;
int agp_available = 1;
for (fill = &drm_agp_fill[0]; fill->name; fill++) { drm_agp = DRM_AGP_GET;
char *n = (char *)fill->name; if (drm_agp) {
*fill->f = (drm_agp_func_u)get_module_symbol(NULL, n);
DRM_DEBUG("%s resolves to 0x%08lx\n", n, (*fill->f).address);
if (!(*fill->f).address) agp_available = 0;
}
DRM_DEBUG("agp_available = %d\n", agp_available);
if (agp_available) {
if (!(head = drm_alloc(sizeof(*head), DRM_MEM_AGPLISTS))) if (!(head = drm_alloc(sizeof(*head), DRM_MEM_AGPLISTS)))
return NULL; return NULL;
memset((void *)head, 0, sizeof(*head)); memset((void *)head, 0, sizeof(*head));
(*drm_agp.copy_info)(&head->agp_info); drm_agp->copy_info(&head->agp_info);
if (head->agp_info.chipset == NOT_SUPPORTED) { if (head->agp_info.chipset == NOT_SUPPORTED) {
drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS); drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS);
return NULL; return NULL;
@ -337,12 +298,31 @@ drm_agp_head_t *drm_agp_init(void)
void drm_agp_uninit(void) void drm_agp_uninit(void)
{ {
drm_agp_fill_t *fill; DRM_AGP_PUT;
drm_agp = NULL;
for (fill = &drm_agp_fill[0]; fill->name; fill++) { }
#if LINUX_VERSION_CODE >= 0x020400
if ((*fill->f).address) put_module_symbol((*fill->f).address); agp_memory *drm_agp_allocate_memory(size_t pages, u32 type)
#endif {
(*fill->f).address = 0; if (!drm_agp->allocate_memory) return NULL;
} return drm_agp->allocate_memory(pages, type);
}
int drm_agp_free_memory(agp_memory *handle)
{
if (!handle || !drm_agp->free_memory) return 0;
drm_agp->free_memory(handle);
return 1;
}
int drm_agp_bind_memory(agp_memory *handle, off_t start)
{
if (!handle || !drm_agp->bind_memory) return -EINVAL;
return drm_agp->bind_memory(handle, start);
}
int drm_agp_unbind_memory(agp_memory *handle)
{
if (!handle || !drm_agp->unbind_memory) return -EINVAL;
return drm_agp->unbind_memory(handle);
} }

View File

@ -38,4 +38,8 @@
#define block_all_signals(a,b,c) #define block_all_signals(a,b,c)
#define unblock_all_signals() #define unblock_all_signals()
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
#define __exit
#endif
#endif #endif

View File

@ -59,15 +59,6 @@
#include <asm/io.h> #include <asm/io.h>
#include <asm/mman.h> #include <asm/mman.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#ifndef copy_to_user_ret
#define copy_to_user_ret(to,from,n,retval) ({ if (copy_to_user(to,from,n)) return retval; })
#endif
#ifndef copy_from_user_ret
#define copy_from_user_ret(to,from,n,retval) ({ if (copy_from_user(to,from,n)) return retval; })
#endif
#ifdef CONFIG_MTRR #ifdef CONFIG_MTRR
#include <asm/mtrr.h> #include <asm/mtrr.h>
#endif #endif
@ -519,19 +510,6 @@ typedef struct drm_agp_head {
unsigned long base; unsigned long base;
int agp_mtrr; int agp_mtrr;
} drm_agp_head_t; } drm_agp_head_t;
typedef struct {
void (*free_memory)(agp_memory *);
agp_memory *(*allocate_memory)(size_t, u32);
int (*bind_memory)(agp_memory *, off_t);
int (*unbind_memory)(agp_memory *);
void (*enable)(u32);
int (*acquire)(void);
void (*release)(void);
void (*copy_info)(agp_kern_info *);
} drm_agp_func_t;
extern drm_agp_func_t drm_agp;
#endif #endif
typedef struct drm_sigdata { typedef struct drm_sigdata {
@ -833,6 +811,7 @@ extern drm_agp_head_t *drm_agp_init(void);
extern void drm_agp_uninit(void); extern void drm_agp_uninit(void);
extern int drm_agp_acquire(struct inode *inode, struct file *filp, extern int drm_agp_acquire(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern void _drm_agp_release(void);
extern int drm_agp_release(struct inode *inode, struct file *filp, extern int drm_agp_release(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int drm_agp_enable(struct inode *inode, struct file *filp, extern int drm_agp_enable(struct inode *inode, struct file *filp,
@ -847,6 +826,10 @@ extern int drm_agp_unbind(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int drm_agp_bind(struct inode *inode, struct file *filp, extern int drm_agp_bind(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern agp_memory *drm_agp_allocate_memory(size_t pages, u32 type);
extern int drm_agp_free_memory(agp_memory *handle);
extern int drm_agp_bind_memory(agp_memory *handle, off_t start);
extern int drm_agp_unbind_memory(agp_memory *handle);
#endif #endif
#endif #endif
#endif #endif

View File

@ -339,7 +339,7 @@ int gamma_find_devices(void)
/* gamma_init is called via init_module at module load time, or via /* gamma_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */ * linux/init/main.c (this is not currently supported). */
static int gamma_init(void) static int __init gamma_init(void)
{ {
int retcode; int retcode;
drm_device_t *dev = &gamma_device; drm_device_t *dev = &gamma_device;
@ -380,7 +380,7 @@ static int gamma_init(void)
/* gamma_cleanup is called via cleanup_module at module unload time. */ /* gamma_cleanup is called via cleanup_module at module unload time. */
static void gamma_cleanup(void) static void __exit gamma_cleanup(void)
{ {
drm_device_t *dev = &gamma_device; drm_device_t *dev = &gamma_device;

View File

@ -255,8 +255,7 @@ static int i810_takedown(drm_device_t *dev)
} }
dev->agp->memory = NULL; dev->agp->memory = NULL;
if (dev->agp->acquired && drm_agp.release) if (dev->agp->acquired) _drm_agp_release();
(*drm_agp.release)();
dev->agp->acquired = 0; dev->agp->acquired = 0;
dev->agp->enabled = 0; dev->agp->enabled = 0;
@ -338,7 +337,7 @@ static int i810_takedown(drm_device_t *dev)
/* i810_init is called via init_module at module load time, or via /* i810_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */ * linux/init/main.c (this is not currently supported). */
static int i810_init(void) static int __init i810_init(void)
{ {
int retcode; int retcode;
drm_device_t *dev = &i810_device; drm_device_t *dev = &i810_device;
@ -397,7 +396,7 @@ static int i810_init(void)
/* i810_cleanup is called via cleanup_module at module unload time. */ /* i810_cleanup is called via cleanup_module at module unload time. */
static void i810_cleanup(void) static void __exit i810_cleanup(void)
{ {
drm_device_t *dev = &i810_device; drm_device_t *dev = &i810_device;

View File

@ -352,16 +352,13 @@ agp_memory *drm_alloc_agp(int pages, u32 type)
return NULL; return NULL;
} }
if (drm_agp.allocate_memory) { if ((handle = drm_agp_allocate_memory(pages, type))) {
if ((handle = (*drm_agp.allocate_memory)(pages, spin_lock(&drm_mem_lock);
type))) { ++drm_mem_stats[DRM_MEM_TOTALAGP].succeed_count;
spin_lock(&drm_mem_lock); drm_mem_stats[DRM_MEM_TOTALAGP].bytes_allocated
++drm_mem_stats[DRM_MEM_TOTALAGP].succeed_count; += pages << PAGE_SHIFT;
drm_mem_stats[DRM_MEM_TOTALAGP].bytes_allocated spin_unlock(&drm_mem_lock);
+= pages << PAGE_SHIFT; return handle;
spin_unlock(&drm_mem_lock);
return handle;
}
} }
spin_lock(&drm_mem_lock); spin_lock(&drm_mem_lock);
++drm_mem_stats[DRM_MEM_TOTALAGP].fail_count; ++drm_mem_stats[DRM_MEM_TOTALAGP].fail_count;
@ -381,8 +378,7 @@ int drm_free_agp(agp_memory *handle, int pages)
return retval;; return retval;;
} }
if (drm_agp.free_memory) { if (drm_agp_free_memory(handle)) {
(*drm_agp.free_memory)(handle);
spin_lock(&drm_mem_lock); spin_lock(&drm_mem_lock);
free_count = ++drm_mem_stats[DRM_MEM_TOTALAGP].free_count; free_count = ++drm_mem_stats[DRM_MEM_TOTALAGP].free_count;
alloc_count = drm_mem_stats[DRM_MEM_TOTALAGP].succeed_count; alloc_count = drm_mem_stats[DRM_MEM_TOTALAGP].succeed_count;
@ -403,24 +399,19 @@ int drm_bind_agp(agp_memory *handle, unsigned int start)
{ {
int retcode = -EINVAL; int retcode = -EINVAL;
DRM_DEBUG("drm_bind_agp called\n");
if (!handle) { if (!handle) {
DRM_MEM_ERROR(DRM_MEM_BOUNDAGP, DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
"Attempt to bind NULL AGP handle\n"); "Attempt to bind NULL AGP handle\n");
return retcode; return retcode;
} }
DRM_DEBUG("drm_agp.bind_memory : %p\n", drm_agp.bind_memory); if (!(retcode = drm_agp_bind_memory(handle, start))) {
if (drm_agp.bind_memory) { spin_lock(&drm_mem_lock);
if (!(retcode = (*drm_agp.bind_memory)(handle, start))) { ++drm_mem_stats[DRM_MEM_BOUNDAGP].succeed_count;
spin_lock(&drm_mem_lock); drm_mem_stats[DRM_MEM_BOUNDAGP].bytes_allocated
++drm_mem_stats[DRM_MEM_BOUNDAGP].succeed_count; += handle->page_count << PAGE_SHIFT;
drm_mem_stats[DRM_MEM_BOUNDAGP].bytes_allocated spin_unlock(&drm_mem_lock);
+= handle->page_count << PAGE_SHIFT; return retcode;
spin_unlock(&drm_mem_lock);
DRM_DEBUG("drm_agp.bind_memory: retcode %d\n", retcode);
return retcode;
}
} }
spin_lock(&drm_mem_lock); spin_lock(&drm_mem_lock);
++drm_mem_stats[DRM_MEM_BOUNDAGP].fail_count; ++drm_mem_stats[DRM_MEM_BOUNDAGP].fail_count;
@ -440,20 +431,17 @@ int drm_unbind_agp(agp_memory *handle)
return retcode; return retcode;
} }
if (drm_agp.unbind_memory) { if ((retcode = drm_agp_unbind_memory(handle))) return retcode;
int c = handle->page_count; spin_lock(&drm_mem_lock);
if ((retcode = (*drm_agp.unbind_memory)(handle))) free_count = ++drm_mem_stats[DRM_MEM_BOUNDAGP].free_count;
return retcode; alloc_count = drm_mem_stats[DRM_MEM_BOUNDAGP].succeed_count;
spin_lock(&drm_mem_lock); drm_mem_stats[DRM_MEM_BOUNDAGP].bytes_freed
free_count = ++drm_mem_stats[DRM_MEM_BOUNDAGP].free_count; += handle->page_count << PAGE_SHIFT;
alloc_count = drm_mem_stats[DRM_MEM_BOUNDAGP].succeed_count; spin_unlock(&drm_mem_lock);
drm_mem_stats[DRM_MEM_BOUNDAGP].bytes_freed += c << PAGE_SHIFT; if (free_count > alloc_count) {
spin_unlock(&drm_mem_lock); DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
if (free_count > alloc_count) { "Excess frees: %d frees, %d allocs\n",
DRM_MEM_ERROR(DRM_MEM_BOUNDAGP, free_count, alloc_count);
"Excess frees: %d frees, %d allocs\n",
free_count, alloc_count);
}
} }
return retcode; return retcode;
} }

View File

@ -420,7 +420,6 @@ int mga_infobufs(struct inode *inode, struct file *filp, unsigned int cmd,
sizeof(dma->bufs[0] sizeof(dma->bufs[0]
.freelist.high_mark))) .freelist.high_mark)))
return -EFAULT; return -EFAULT;
++count; ++count;
} }
} }

View File

@ -255,8 +255,7 @@ static int mga_takedown(drm_device_t *dev)
} }
dev->agp->memory = NULL; dev->agp->memory = NULL;
if (dev->agp->acquired && drm_agp.release) if (dev->agp->acquired) _drm_agp_release();
(*drm_agp.release)();
dev->agp->acquired = 0; dev->agp->acquired = 0;
dev->agp->enabled = 0; dev->agp->enabled = 0;
@ -338,7 +337,7 @@ static int mga_takedown(drm_device_t *dev)
/* mga_init is called via init_module at module load time, or via /* mga_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */ * linux/init/main.c (this is not currently supported). */
static int mga_init(void) static int __init mga_init(void)
{ {
int retcode; int retcode;
drm_device_t *dev = &mga_device; drm_device_t *dev = &mga_device;
@ -398,7 +397,7 @@ static int mga_init(void)
/* mga_cleanup is called via cleanup_module at module unload time. */ /* mga_cleanup is called via cleanup_module at module unload time. */
static void mga_cleanup(void) static void __exit mga_cleanup(void)
{ {
drm_device_t *dev = &mga_device; drm_device_t *dev = &mga_device;

View File

@ -57,9 +57,9 @@ typedef struct drm_r128_init {
} drm_r128_init_t; } drm_r128_init_t;
typedef struct drm_r128_packet { typedef struct drm_r128_packet {
void *buffer; unsigned int *buffer;
int count; int count;
int flags; int flags;
} drm_r128_packet_t; } drm_r128_packet_t;
typedef enum drm_r128_prim { typedef enum drm_r128_prim {

View File

@ -252,8 +252,7 @@ static int r128_takedown(drm_device_t *dev)
} }
dev->agp->memory = NULL; dev->agp->memory = NULL;
if (dev->agp->acquired && drm_agp.release) if (dev->agp->acquired) _drm_agp_release();
(*drm_agp.release)();
dev->agp->acquired = 0; dev->agp->acquired = 0;
dev->agp->enabled = 0; dev->agp->enabled = 0;
@ -323,7 +322,7 @@ static int r128_takedown(drm_device_t *dev)
/* r128_init is called via init_module at module load time, or via /* r128_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */ * linux/init/main.c (this is not currently supported). */
static int r128_init(void) static int __init r128_init(void)
{ {
int retcode; int retcode;
drm_device_t *dev = &r128_device; drm_device_t *dev = &r128_device;
@ -387,7 +386,7 @@ static int r128_init(void)
/* r128_cleanup is called via cleanup_module at module unload time. */ /* r128_cleanup is called via cleanup_module at module unload time. */
static void r128_cleanup(void) static void __exit r128_cleanup(void)
{ {
drm_device_t *dev = &r128_device; drm_device_t *dev = &r128_device;

View File

@ -197,7 +197,7 @@ extern int r128_context_switch_complete(drm_device_t *dev, int new);
#define R128_MAX_USEC_TIMEOUT 100000 /* 100 ms */ #define R128_MAX_USEC_TIMEOUT 100000 /* 100 ms */
#define R128_BASE(reg) ((unsigned long)(dev_priv->mmio->handle)) #define R128_BASE(reg) ((u32)(dev_priv->mmio->handle))
#define R128_ADDR(reg) (R128_BASE(reg) + reg) #define R128_ADDR(reg) (R128_BASE(reg) + reg)
#define R128_DEREF(reg) *(__volatile__ int *)R128_ADDR(reg) #define R128_DEREF(reg) *(__volatile__ int *)R128_ADDR(reg)

View File

@ -106,19 +106,19 @@ int sis_resctx(struct inode *inode, struct file *filp, unsigned int cmd,
int i; int i;
DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS); DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS);
copy_from_user_ret(&res, (drm_ctx_res_t *)arg, sizeof(res), -EFAULT); if (copy_from_user(&res, (drm_ctx_res_t *)arg, sizeof(res)))
return -EFAULT;
if (res.count >= DRM_RESERVED_CONTEXTS) { if (res.count >= DRM_RESERVED_CONTEXTS) {
memset(&ctx, 0, sizeof(ctx)); memset(&ctx, 0, sizeof(ctx));
for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
ctx.handle = i; ctx.handle = i;
copy_to_user_ret(&res.contexts[i], if (copy_to_user(&res.contexts[i], &i, sizeof(i)))
&i, return -EFAULT;
sizeof(i),
-EFAULT);
} }
} }
res.count = DRM_RESERVED_CONTEXTS; res.count = DRM_RESERVED_CONTEXTS;
copy_to_user_ret((drm_ctx_res_t *)arg, &res, sizeof(res), -EFAULT); if (copy_to_user((drm_ctx_res_t *)arg, &res, sizeof(res)))
return -EFAULT;
return 0; return 0;
} }
@ -130,7 +130,8 @@ int sis_addctx(struct inode *inode, struct file *filp, unsigned int cmd,
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
drm_ctx_t ctx; drm_ctx_t ctx;
copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
return -EFAULT;
if ((ctx.handle = sis_alloc_queue(dev)) == DRM_KERNEL_CONTEXT) { if ((ctx.handle = sis_alloc_queue(dev)) == DRM_KERNEL_CONTEXT) {
/* Skip kernel's context and get a new one. */ /* Skip kernel's context and get a new one. */
ctx.handle = sis_alloc_queue(dev); ctx.handle = sis_alloc_queue(dev);
@ -145,7 +146,8 @@ int sis_addctx(struct inode *inode, struct file *filp, unsigned int cmd,
/* new added */ /* new added */
sis_init_context(ctx.handle); sis_init_context(ctx.handle);
copy_to_user_ret((drm_ctx_t *)arg, &ctx, sizeof(ctx), -EFAULT); if (copy_to_user((drm_ctx_t *)arg, &ctx, sizeof(ctx)))
return -EFAULT;
return 0; return 0;
} }
@ -154,7 +156,8 @@ int sis_modctx(struct inode *inode, struct file *filp, unsigned int cmd,
{ {
drm_ctx_t ctx; drm_ctx_t ctx;
copy_from_user_ret(&ctx, (drm_ctx_t*)arg, sizeof(ctx), -EFAULT); if (copy_from_user(&ctx, (drm_ctx_t*)arg, sizeof(ctx)))
return -EFAULT;
if (ctx.flags==_DRM_CONTEXT_PRESERVED) if (ctx.flags==_DRM_CONTEXT_PRESERVED)
sis_res_ctx.handle=ctx.handle; sis_res_ctx.handle=ctx.handle;
return 0; return 0;
@ -165,10 +168,12 @@ int sis_getctx(struct inode *inode, struct file *filp, unsigned int cmd,
{ {
drm_ctx_t ctx; drm_ctx_t ctx;
copy_from_user_ret(&ctx, (drm_ctx_t*)arg, sizeof(ctx), -EFAULT); if (copy_from_user(&ctx, (drm_ctx_t*)arg, sizeof(ctx)))
return -EFAULT;
/* This is 0, because we don't hanlde any context flags */ /* This is 0, because we don't hanlde any context flags */
ctx.flags = 0; ctx.flags = 0;
copy_to_user_ret((drm_ctx_t*)arg, &ctx, sizeof(ctx), -EFAULT); if (copy_to_user((drm_ctx_t*)arg, &ctx, sizeof(ctx)))
return -EFAULT;
return 0; return 0;
} }
@ -179,7 +184,8 @@ int sis_switchctx(struct inode *inode, struct file *filp, unsigned int cmd,
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
drm_ctx_t ctx; drm_ctx_t ctx;
copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
return -EFAULT;
DRM_DEBUG("%d\n", ctx.handle); DRM_DEBUG("%d\n", ctx.handle);
return sis_context_switch(dev, dev->last_context, ctx.handle); return sis_context_switch(dev, dev->last_context, ctx.handle);
} }
@ -191,7 +197,8 @@ int sis_newctx(struct inode *inode, struct file *filp, unsigned int cmd,
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
drm_ctx_t ctx; drm_ctx_t ctx;
copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
return -EFAULT;
DRM_DEBUG("%d\n", ctx.handle); DRM_DEBUG("%d\n", ctx.handle);
sis_context_switch_complete(dev, ctx.handle); sis_context_switch_complete(dev, ctx.handle);
@ -205,7 +212,8 @@ int sis_rmctx(struct inode *inode, struct file *filp, unsigned int cmd,
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
drm_ctx_t ctx; drm_ctx_t ctx;
copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
return -EFAULT;
DRM_DEBUG("%d\n", ctx.handle); DRM_DEBUG("%d\n", ctx.handle);
drm_ctxbitmap_free(dev, ctx.handle); drm_ctxbitmap_free(dev, ctx.handle);

View File

@ -250,7 +250,7 @@ static int sis_takedown(drm_device_t *dev)
drm_free(temp, sizeof(*temp), DRM_MEM_AGPLISTS); drm_free(temp, sizeof(*temp), DRM_MEM_AGPLISTS);
temp = temp_next; temp = temp_next;
} }
if (dev->agp->acquired) (*drm_agp.release)(); if (dev->agp->acquired) _drm_agp_release();
} }
#endif #endif
/* Clear vma list (only built for debugging) */ /* Clear vma list (only built for debugging) */
@ -394,17 +394,16 @@ int sis_version(struct inode *inode, struct file *filp, unsigned int cmd,
drm_version_t version; drm_version_t version;
int len; int len;
copy_from_user_ret(&version, if (copy_from_user(&version, (drm_version_t *)arg, sizeof(version)))
(drm_version_t *)arg, return -EFAULT;
sizeof(version),
-EFAULT);
#define DRM_COPY(name,value) \ #define DRM_COPY(name,value) \
len = strlen(value); \ len = strlen(value); \
if (len > name##_len) len = name##_len; \ if (len > name##_len) len = name##_len; \
name##_len = strlen(value); \ name##_len = strlen(value); \
if (len && name) { \ if (len && name) { \
copy_to_user_ret(name, value, len, -EFAULT); \ if (copy_to_user(name, value, len)) \
return -EFAULT; \
} }
version.version_major = SIS_MAJOR; version.version_major = SIS_MAJOR;
@ -415,10 +414,8 @@ int sis_version(struct inode *inode, struct file *filp, unsigned int cmd,
DRM_COPY(version.date, SIS_DATE); DRM_COPY(version.date, SIS_DATE);
DRM_COPY(version.desc, SIS_DESC); DRM_COPY(version.desc, SIS_DESC);
copy_to_user_ret((drm_version_t *)arg, if (copy_to_user((drm_version_t *)arg, &version, sizeof(version)))
&version, return -EFAULT;
sizeof(version),
-EFAULT);
return 0; return 0;
} }
@ -533,7 +530,8 @@ int sis_lock(struct inode *inode, struct file *filp, unsigned int cmd,
dev->lck_start = start = get_cycles(); dev->lck_start = start = get_cycles();
#endif #endif
copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
return -EFAULT;
if (lock.context == DRM_KERNEL_CONTEXT) { if (lock.context == DRM_KERNEL_CONTEXT) {
DRM_ERROR("Process %d using kernel context %d\n", DRM_ERROR("Process %d using kernel context %d\n",
@ -667,7 +665,8 @@ int sis_unlock(struct inode *inode, struct file *filp, unsigned int cmd,
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
drm_lock_t lock; drm_lock_t lock;
copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
return -EFAULT;
if (lock.context == DRM_KERNEL_CONTEXT) { if (lock.context == DRM_KERNEL_CONTEXT) {
DRM_ERROR("Process %d using kernel context %d\n", DRM_ERROR("Process %d using kernel context %d\n",

View File

@ -78,7 +78,8 @@ int sis_fb_alloc(struct inode *inode, struct file *filp, unsigned int cmd,
struct sis_memreq req; struct sis_memreq req;
int retval = 0; int retval = 0;
copy_from_user_ret(&fb, (drm_sis_mem_t *)arg, sizeof(fb), -EFAULT); if (copy_from_user(&fb, (drm_sis_mem_t *)arg, sizeof(fb)))
return -EFAULT;
req.size = fb.size; req.size = fb.size;
sis_malloc(&req); sis_malloc(&req);
@ -98,7 +99,7 @@ int sis_fb_alloc(struct inode *inode, struct file *filp, unsigned int cmd,
fb.free = 0; fb.free = 0;
} }
copy_to_user_ret((drm_sis_mem_t *)arg, &fb, sizeof(fb), -EFAULT); if (copy_to_user((drm_sis_mem_t *)arg, &fb, sizeof(fb))) return -EFAULT;
DRM_DEBUG("alloc fb, size = %d, offset = %ld\n", fb.size, req.offset); DRM_DEBUG("alloc fb, size = %d, offset = %ld\n", fb.size, req.offset);
@ -111,7 +112,8 @@ int sis_fb_free(struct inode *inode, struct file *filp, unsigned int cmd,
drm_sis_mem_t fb; drm_sis_mem_t fb;
int retval = 0; int retval = 0;
copy_from_user_ret(&fb, (drm_sis_mem_t *)arg, sizeof(fb), -EFAULT); if (copy_from_user(&fb, (drm_sis_mem_t *)arg, sizeof(fb)))
return -EFAULT;
if(!fb.free){ if(!fb.free){
return -1; return -1;
@ -152,7 +154,8 @@ int sis_agp_init(struct inode *inode, struct file *filp, unsigned int cmd,
{ {
drm_sis_agp_t agp; drm_sis_agp_t agp;
copy_from_user_ret(&agp, (drm_sis_agp_t *)arg, sizeof(agp), -EFAULT); if (copy_from_user(&agp, (drm_sis_agp_t *)arg, sizeof(agp)))
return -EFAULT;
AgpHeap = mmInit(agp.offset, agp.size); AgpHeap = mmInit(agp.offset, agp.size);
@ -171,7 +174,8 @@ int sis_agp_alloc(struct inode *inode, struct file *filp, unsigned int cmd,
if(!AgpHeap) if(!AgpHeap)
return -1; return -1;
copy_from_user_ret(&agp, (drm_sis_mem_t *)arg, sizeof(agp), -EFAULT); if (copy_from_user(&agp, (drm_sis_mem_t *)arg, sizeof(agp)))
return -EFAULT;
block = mmAllocMem(AgpHeap, agp.size, 0, 0); block = mmAllocMem(AgpHeap, agp.size, 0, 0);
if(block){ if(block){
@ -190,7 +194,7 @@ int sis_agp_alloc(struct inode *inode, struct file *filp, unsigned int cmd,
agp.free = 0; agp.free = 0;
} }
copy_to_user_ret((drm_sis_mem_t *)arg, &agp, sizeof(agp), -EFAULT); if (copy_to_user((drm_sis_mem_t *)arg, &agp, sizeof(agp))) return -EFAULT;
DRM_DEBUG("alloc agp, size = %d, offset = %d\n", agp.size, agp.offset); DRM_DEBUG("alloc agp, size = %d, offset = %d\n", agp.size, agp.offset);
@ -206,7 +210,8 @@ int sis_agp_free(struct inode *inode, struct file *filp, unsigned int cmd,
if(!AgpHeap) if(!AgpHeap)
return -1; return -1;
copy_from_user_ret(&agp, (drm_sis_mem_t *)arg, sizeof(agp), -EFAULT); if (copy_from_user(&agp, (drm_sis_mem_t *)arg, sizeof(agp)))
return -EFAULT;
if(!agp.free){ if(!agp.free){
return -1; return -1;

View File

@ -235,7 +235,7 @@ static int tdfx_takedown(drm_device_t *dev)
drm_free(temp, sizeof(*temp), DRM_MEM_AGPLISTS); drm_free(temp, sizeof(*temp), DRM_MEM_AGPLISTS);
temp = temp_next; temp = temp_next;
} }
if (dev->agp->acquired) (*drm_agp.release)(); if (dev->agp->acquired) _drm_agp_release();
} }
#endif #endif
/* Clear vma list (only built for debugging) */ /* Clear vma list (only built for debugging) */
@ -298,7 +298,7 @@ static int tdfx_takedown(drm_device_t *dev)
/* tdfx_init is called via init_module at module load time, or via /* tdfx_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */ * linux/init/main.c (this is not currently supported). */
static int tdfx_init(void) static int __init tdfx_init(void)
{ {
int retcode; int retcode;
drm_device_t *dev = &tdfx_device; drm_device_t *dev = &tdfx_device;
@ -346,7 +346,7 @@ static int tdfx_init(void)
/* tdfx_cleanup is called via cleanup_module at module unload time. */ /* tdfx_cleanup is called via cleanup_module at module unload time. */
static void tdfx_cleanup(void) static void __exit tdfx_cleanup(void)
{ {
drm_device_t *dev = &tdfx_device; drm_device_t *dev = &tdfx_device;