Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
43d8a5b8
Commit
43d8a5b8
authored
Nov 01, 2004
by
David Airlie
Browse files
Options
Browse Files
Download
Plain Diff
Merge bkbits.net:/repos/l/linux/linux-2.5
into bkbits.net:/repos/d/drm/drm-2.6
parents
f2ddba8c
7bb2e369
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
379 additions
and
338 deletions
+379
-338
drivers/char/drm/drmP.h
drivers/char/drm/drmP.h
+44
-7
drivers/char/drm/drm_drv.h
drivers/char/drm/drm_drv.h
+89
-97
drivers/char/drm/drm_irq.h
drivers/char/drm/drm_irq.h
+2
-2
drivers/char/drm/drm_memory.h
drivers/char/drm/drm_memory.h
+3
-17
drivers/char/drm/drm_memory_debug.h
drivers/char/drm/drm_memory_debug.h
+1
-1
drivers/char/drm/drm_os_linux.h
drivers/char/drm/drm_os_linux.h
+0
-5
drivers/char/drm/drm_proc.h
drivers/char/drm/drm_proc.h
+6
-14
drivers/char/drm/drm_stub.h
drivers/char/drm/drm_stub.h
+170
-132
drivers/char/drm/i915_mem.c
drivers/char/drm/i915_mem.c
+10
-10
drivers/char/drm/r128_state.c
drivers/char/drm/r128_state.c
+42
-42
drivers/char/drm/radeon_mem.c
drivers/char/drm/radeon_mem.c
+10
-10
drivers/char/drm/radeon_state.c
drivers/char/drm/radeon_state.c
+2
-1
No files found.
drivers/char/drm/drmP.h
View file @
43d8a5b8
...
@@ -34,6 +34,8 @@
...
@@ -34,6 +34,8 @@
#ifndef _DRM_P_H_
#ifndef _DRM_P_H_
#define _DRM_P_H_
#define _DRM_P_H_
/* If you want the memory alloc debug functionality, change define below */
/* #define DEBUG_MEMORY */
#ifdef __KERNEL__
#ifdef __KERNEL__
#ifdef __alpha__
#ifdef __alpha__
...
@@ -55,6 +57,7 @@
...
@@ -55,6 +57,7 @@
#include <linux/jiffies.h>
#include <linux/jiffies.h>
#include <linux/smp_lock.h>
/* For (un)lock_kernel */
#include <linux/smp_lock.h>
/* For (un)lock_kernel */
#include <linux/mm.h>
#include <linux/mm.h>
#include <linux/cdev.h>
#if defined(__alpha__) || defined(__powerpc__)
#if defined(__alpha__) || defined(__powerpc__)
#include <asm/pgtable.h>
/* For pte_wrprotect */
#include <asm/pgtable.h>
/* For pte_wrprotect */
#endif
#endif
...
@@ -693,12 +696,31 @@ typedef struct drm_device {
...
@@ -693,12 +696,31 @@ typedef struct drm_device {
drm_sigdata_t
sigdata
;
/**< For block_all_signals */
drm_sigdata_t
sigdata
;
/**< For block_all_signals */
sigset_t
sigmask
;
sigset_t
sigmask
;
struct
file_operations
*
fops
;
/**< file operations */
struct
proc_dir_entry
*
dev_root
;
/**< proc directory entry */
struct
drm_driver_fn
fn_tbl
;
struct
drm_driver_fn
fn_tbl
;
drm_local_map_t
*
agp_buffer_map
;
drm_local_map_t
*
agp_buffer_map
;
int
dev_priv_size
;
int
dev_priv_size
;
u32
driver_features
;
u32
driver_features
;
}
drm_device_t
;
}
drm_device_t
;
typedef
struct
drm_minor
{
enum
{
DRM_MINOR_FREE
=
0
,
DRM_MINOR_PRIMARY
,
}
type
;
drm_device_t
*
dev
;
struct
proc_dir_entry
*
dev_root
;
/**< proc directory entry */
}
drm_minor_t
;
typedef
struct
drm_global
{
unsigned
int
cards_limit
;
drm_minor_t
*
minors
;
struct
class_simple
*
drm_class
;
struct
proc_dir_entry
*
proc_root
;
}
drm_global_t
;
static
__inline__
int
drm_core_check_feature
(
struct
drm_device
*
dev
,
int
feature
)
static
__inline__
int
drm_core_check_feature
(
struct
drm_device
*
dev
,
int
feature
)
{
{
return
((
dev
->
driver_features
&
feature
)
?
1
:
0
);
return
((
dev
->
driver_features
&
feature
)
?
1
:
0
);
...
@@ -765,11 +787,9 @@ extern ssize_t DRM(read)(struct file *filp, char __user *buf, size_t count
...
@@ -765,11 +787,9 @@ extern ssize_t DRM(read)(struct file *filp, char __user *buf, size_t count
extern
void
DRM
(
mem_init
)(
void
);
extern
void
DRM
(
mem_init
)(
void
);
extern
int
DRM
(
mem_info
)(
char
*
buf
,
char
**
start
,
off_t
offset
,
extern
int
DRM
(
mem_info
)(
char
*
buf
,
char
**
start
,
off_t
offset
,
int
request
,
int
*
eof
,
void
*
data
);
int
request
,
int
*
eof
,
void
*
data
);
extern
void
*
DRM
(
alloc
)(
size_t
size
,
int
area
);
extern
void
*
DRM
(
calloc
)(
size_t
nmemb
,
size_t
size
,
int
area
);
extern
void
*
DRM
(
calloc
)(
size_t
nmemb
,
size_t
size
,
int
area
);
extern
void
*
DRM
(
realloc
)(
void
*
oldpt
,
size_t
oldsize
,
size_t
size
,
extern
void
*
DRM
(
realloc
)(
void
*
oldpt
,
size_t
oldsize
,
size_t
size
,
int
area
);
int
area
);
extern
void
DRM
(
free
)(
void
*
pt
,
size_t
size
,
int
area
);
extern
unsigned
long
DRM
(
alloc_pages
)(
int
order
,
int
area
);
extern
unsigned
long
DRM
(
alloc_pages
)(
int
order
,
int
area
);
extern
void
DRM
(
free_pages
)(
unsigned
long
address
,
int
order
,
extern
void
DRM
(
free_pages
)(
unsigned
long
address
,
int
order
,
int
area
);
int
area
);
...
@@ -921,13 +941,12 @@ extern int DRM(agp_bind_memory)(DRM_AGP_MEM *handle, off_t start);
...
@@ -921,13 +941,12 @@ extern int DRM(agp_bind_memory)(DRM_AGP_MEM *handle, off_t start);
extern
int
DRM
(
agp_unbind_memory
)(
DRM_AGP_MEM
*
handle
);
extern
int
DRM
(
agp_unbind_memory
)(
DRM_AGP_MEM
*
handle
);
/* Stub support (drm_stub.h) */
/* Stub support (drm_stub.h) */
int
DRM
(
stub_register
)(
const
char
*
name
,
extern
int
DRM
(
probe
)(
struct
pci_dev
*
pdev
,
const
struct
pci_device_id
*
ent
);
struct
file_operations
*
fops
,
extern
int
DRM
(
put_minor
)(
drm_device_t
*
dev
);
drm_device_t
*
dev
);
extern
drm_global_t
*
DRM
(
global
);
int
DRM
(
stub_unregister
)(
int
minor
);
/* Proc support (drm_proc.h) */
/* Proc support (drm_proc.h) */
extern
struct
proc_dir_entry
*
DRM
(
proc_init
)(
drm_device_t
*
dev
,
extern
int
DRM
(
proc_init
)(
drm_device_t
*
dev
,
int
minor
,
int
minor
,
struct
proc_dir_entry
*
root
,
struct
proc_dir_entry
*
root
,
struct
proc_dir_entry
**
dev_root
);
struct
proc_dir_entry
**
dev_root
);
...
@@ -984,6 +1003,24 @@ static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev, unsig
...
@@ -984,6 +1003,24 @@ static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev, unsig
static
__inline__
void
drm_core_dropmap
(
struct
drm_map
*
map
)
static
__inline__
void
drm_core_dropmap
(
struct
drm_map
*
map
)
{
{
}
}
#ifndef DEBUG_MEMORY
/** Wrapper around kmalloc() */
static
__inline__
void
*
DRM
(
alloc
)(
size_t
size
,
int
area
)
{
return
kmalloc
(
size
,
GFP_KERNEL
);
}
/** Wrapper around kfree() */
static
__inline__
void
DRM
(
free
)(
void
*
pt
,
size_t
size
,
int
area
)
{
kfree
(
pt
);
}
#else
extern
void
*
DRM
(
alloc
)(
size_t
size
,
int
area
);
extern
void
DRM
(
free
)(
void
*
pt
,
size_t
size
,
int
area
);
#endif
/*@}*/
/*@}*/
extern
unsigned
long
DRM
(
core_get_map_ofs
)(
drm_map_t
*
map
);
extern
unsigned
long
DRM
(
core_get_map_ofs
)(
drm_map_t
*
map
);
...
...
drivers/char/drm/drm_drv.h
View file @
43d8a5b8
...
@@ -74,10 +74,6 @@ __setup( DRIVER_NAME "=", DRM_OPTIONS_FUNC );
...
@@ -74,10 +74,6 @@ __setup( DRIVER_NAME "=", DRM_OPTIONS_FUNC );
#undef DRM_OPTIONS_FUNC
#undef DRM_OPTIONS_FUNC
#endif
#endif
#define MAX_DEVICES 4
static
drm_device_t
DRM
(
device
)[
MAX_DEVICES
];
static
int
DRM
(
numdevs
)
=
0
;
struct
file_operations
DRM
(
fops
)
=
{
struct
file_operations
DRM
(
fops
)
=
{
.
owner
=
THIS_MODULE
,
.
owner
=
THIS_MODULE
,
.
open
=
DRM
(
open
),
.
open
=
DRM
(
open
),
...
@@ -158,15 +154,6 @@ drm_ioctl_desc_t DRM(ioctls)[] = {
...
@@ -158,15 +154,6 @@ drm_ioctl_desc_t DRM(ioctls)[] = {
#define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( DRM(ioctls) )
#define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( DRM(ioctls) )
#ifdef MODULE
static
char
*
drm_opts
=
NULL
;
#endif
MODULE_AUTHOR
(
DRIVER_AUTHOR
);
MODULE_DESCRIPTION
(
DRIVER_DESC
);
MODULE_PARM
(
drm_opts
,
"s"
);
MODULE_LICENSE
(
"GPL and additional rights"
);
static
int
DRM
(
setup
)(
drm_device_t
*
dev
)
static
int
DRM
(
setup
)(
drm_device_t
*
dev
)
{
{
int
i
;
int
i
;
...
@@ -420,44 +407,19 @@ static struct pci_device_id DRM(pciidlist)[] = {
...
@@ -420,44 +407,19 @@ static struct pci_device_id DRM(pciidlist)[] = {
DRM
(
PCI_IDS
)
DRM
(
PCI_IDS
)
};
};
static
int
DRM
(
probe
)(
struct
pci_dev
*
pdev
)
int
DRM
(
fill_in_dev
)(
drm_device_t
*
dev
,
struct
pci_dev
*
pdev
,
const
struct
pci_device_id
*
ent
)
{
{
drm_device_t
*
dev
;
int
retcode
;
int
retcode
;
int
i
;
int
is_compat
=
0
;
DRM_DEBUG
(
"
\n
"
);
for
(
i
=
0
;
DRM
(
pciidlist
)[
i
].
vendor
!=
0
;
i
++
)
{
if
((
DRM
(
pciidlist
)[
i
].
vendor
==
pdev
->
vendor
)
&&
(
DRM
(
pciidlist
)[
i
].
device
==
pdev
->
device
))
{
is_compat
=
1
;
}
}
if
(
is_compat
==
0
)
return
-
ENODEV
;
if
(
DRM
(
numdevs
)
>=
MAX_DEVICES
)
return
-
ENODEV
;
if
((
retcode
=
pci_enable_device
(
pdev
)))
return
retcode
;
dev
=
&
(
DRM
(
device
)[
DRM
(
numdevs
)]);
memset
(
(
void
*
)
dev
,
0
,
sizeof
(
*
dev
)
);
dev
->
count_lock
=
SPIN_LOCK_UNLOCKED
;
dev
->
count_lock
=
SPIN_LOCK_UNLOCKED
;
init_timer
(
&
dev
->
timer
);
init_timer
(
&
dev
->
timer
);
sema_init
(
&
dev
->
struct_sem
,
1
);
sema_init
(
&
dev
->
struct_sem
,
1
);
sema_init
(
&
dev
->
ctxlist_sem
,
1
);
sema_init
(
&
dev
->
ctxlist_sem
,
1
);
if
((
dev
->
minor
=
DRM
(
stub_register
)(
DRIVER_NAME
,
&
DRM
(
fops
),
dev
))
<
0
)
return
-
EPERM
;
dev
->
device
=
MKDEV
(
DRM_MAJOR
,
dev
->
minor
);
dev
->
name
=
DRIVER_NAME
;
dev
->
name
=
DRIVER_NAME
;
dev
->
fops
=
&
DRM
(
fops
);
dev
->
pdev
=
pdev
;
dev
->
pdev
=
pdev
;
#ifdef __alpha__
#ifdef __alpha__
dev
->
hose
=
pdev
->
sysdata
;
dev
->
hose
=
pdev
->
sysdata
;
dev
->
pci_domain
=
dev
->
hose
->
bus
->
number
;
dev
->
pci_domain
=
dev
->
hose
->
bus
->
number
;
...
@@ -486,16 +448,15 @@ static int DRM(probe)(struct pci_dev *pdev)
...
@@ -486,16 +448,15 @@ static int DRM(probe)(struct pci_dev *pdev)
DRM
(
driver_register_fns
)(
dev
);
DRM
(
driver_register_fns
)(
dev
);
if
(
dev
->
fn_tbl
.
preinit
)
if
(
dev
->
fn_tbl
.
preinit
)
dev
->
fn_tbl
.
preinit
(
dev
);
if
((
retcode
=
dev
->
fn_tbl
.
preinit
(
dev
)))
goto
error_out_unreg
;
if
(
drm_core_has_AGP
(
dev
))
if
(
drm_core_has_AGP
(
dev
))
{
{
dev
->
agp
=
DRM
(
agp_init
)();
dev
->
agp
=
DRM
(
agp_init
)();
if
(
drm_core_check_feature
(
dev
,
DRIVER_REQUIRE_AGP
)
&&
(
dev
->
agp
==
NULL
))
{
if
(
drm_core_check_feature
(
dev
,
DRIVER_REQUIRE_AGP
)
&&
(
dev
->
agp
==
NULL
))
{
DRM_ERROR
(
"Cannot initialize the agpgart module.
\n
"
);
DRM_ERROR
(
"Cannot initialize the agpgart module.
\n
"
);
DRM
(
stub_unregister
)(
dev
->
minor
);
retcode
=
-
EINVAL
;
DRM
(
takedown
)(
dev
);
goto
error_out_unreg
;
return
-
EINVAL
;
}
}
if
(
drm_core_has_MTRR
(
dev
))
{
if
(
drm_core_has_MTRR
(
dev
))
{
if
(
dev
->
agp
)
if
(
dev
->
agp
)
...
@@ -509,13 +470,11 @@ static int DRM(probe)(struct pci_dev *pdev)
...
@@ -509,13 +470,11 @@ static int DRM(probe)(struct pci_dev *pdev)
retcode
=
DRM
(
ctxbitmap_init
)(
dev
);
retcode
=
DRM
(
ctxbitmap_init
)(
dev
);
if
(
retcode
)
{
if
(
retcode
)
{
DRM_ERROR
(
"Cannot allocate memory for context bitmap.
\n
"
);
DRM_ERROR
(
"Cannot allocate memory for context bitmap.
\n
"
);
DRM
(
stub_unregister
)(
dev
->
minor
);
goto
error_out_unreg
;
DRM
(
takedown
)(
dev
);
return
retcode
;
}
}
DRM
(
numdevs
)
++
;
/* no errors, mark it reserved */
dev
->
device
=
MKDEV
(
DRM_MAJOR
,
dev
->
minor
);
DRM_INFO
(
"Initialized %s %d.%d.%d %s on minor %d: %s
\n
"
,
DRM_INFO
(
"Initialized %s %d.%d.%d %s on minor %d: %s
\n
"
,
DRIVER_NAME
,
DRIVER_NAME
,
DRIVER_MAJOR
,
DRIVER_MAJOR
,
...
@@ -526,11 +485,21 @@ static int DRM(probe)(struct pci_dev *pdev)
...
@@ -526,11 +485,21 @@ static int DRM(probe)(struct pci_dev *pdev)
pci_pretty_name
(
pdev
));
pci_pretty_name
(
pdev
));
if
(
dev
->
fn_tbl
.
postinit
)
if
(
dev
->
fn_tbl
.
postinit
)
dev
->
fn_tbl
.
postinit
(
dev
);
if
((
retcode
=
dev
->
fn_tbl
.
postinit
(
dev
)))
goto
error_out_unreg
;
return
0
;
return
0
;
error_out_unreg:
DRM
(
takedown
)(
dev
);
return
retcode
;
}
}
#ifdef MODULE
static
char
*
drm_opts
=
NULL
;
#endif
MODULE_PARM
(
drm_opts
,
"s"
);
/**
/**
* Module initialization. Called via init_module at module load time, or via
* Module initialization. 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).
...
@@ -547,6 +516,8 @@ static int DRM(probe)(struct pci_dev *pdev)
...
@@ -547,6 +516,8 @@ static int DRM(probe)(struct pci_dev *pdev)
static
int
__init
drm_init
(
void
)
static
int
__init
drm_init
(
void
)
{
{
struct
pci_dev
*
pdev
=
NULL
;
struct
pci_dev
*
pdev
=
NULL
;
struct
pci_device_id
*
pid
;
int
i
;
DRM_DEBUG
(
"
\n
"
);
DRM_DEBUG
(
"
\n
"
);
...
@@ -556,8 +527,16 @@ static int __init drm_init( void )
...
@@ -556,8 +527,16 @@ static int __init drm_init( void )
DRM
(
mem_init
)();
DRM
(
mem_init
)();
while
((
pdev
=
pci_find_device
(
PCI_ANY_ID
,
PCI_ANY_ID
,
pdev
))
!=
NULL
)
{
for
(
i
=
0
;
DRM
(
pciidlist
)[
i
].
vendor
!=
0
;
i
++
)
{
DRM
(
probe
)(
pdev
);
pid
=
&
DRM
(
pciidlist
[
i
]);
pdev
=
NULL
;
/* pass back in pdev to account for multiple identical cards */
while
((
pdev
=
pci_get_subsys
(
pid
->
vendor
,
pid
->
device
,
pid
->
subvendor
,
pid
->
subdevice
,
pdev
))
!=
NULL
)
{
/* stealth mode requires a manual probe */
pci_dev_get
(
pdev
);
DRM
(
probe
)(
pdev
,
pid
);
}
}
}
return
0
;
return
0
;
}
}
...
@@ -569,52 +548,68 @@ static int __init drm_init( void )
...
@@ -569,52 +548,68 @@ static int __init drm_init( void )
*
*
* \sa drm_init().
* \sa drm_init().
*/
*/
static
void
__exit
drm_cleanup
(
void
)
static
void
__exit
drm_cleanup
(
drm_device_t
*
dev
)
{
{
drm_device_t
*
dev
;
int
i
;
DRM_DEBUG
(
"
\n
"
);
DRM_DEBUG
(
"
\n
"
);
for
(
i
=
DRM
(
numdevs
)
-
1
;
i
>=
0
;
i
--
)
{
if
(
!
dev
)
{
dev
=
&
(
DRM
(
device
)[
i
]);
DRM_ERROR
(
"cleanup called no dev
\n
"
);
if
(
DRM
(
stub_unregister
)(
dev
->
minor
)
)
{
return
;
DRM_ERROR
(
"Cannot unload module
\n
"
);
}
}
else
{
DRM_DEBUG
(
"minor %d unregistered
\n
"
,
dev
->
minor
);
if
(
i
==
0
)
{
DRM_INFO
(
"Module unloaded
\n
"
);
}
}
DRM
(
ctxbitmap_cleanup
)(
dev
);
DRM
(
takedown
)(
dev
);
if
(
drm_core_has_MTRR
(
dev
)
&&
drm_core_has_AGP
(
dev
)
&&
DRM
(
ctxbitmap_cleanup
)(
dev
);
dev
->
agp
&&
dev
->
agp
->
agp_mtrr
>=
0
)
{
int
retval
;
if
(
drm_core_has_MTRR
(
dev
)
&&
drm_core_has_AGP
(
dev
)
&&
retval
=
mtrr_del
(
dev
->
agp
->
agp_mtrr
,
dev
->
agp
&&
dev
->
agp
->
agp_mtrr
>=
0
)
{
int
retval
;
retval
=
mtrr_del
(
dev
->
agp
->
agp_mtrr
,
dev
->
agp
->
agp_info
.
aper_base
,
dev
->
agp
->
agp_info
.
aper_base
,
dev
->
agp
->
agp_info
.
aper_size
*
1024
*
1024
);
dev
->
agp
->
agp_info
.
aper_size
*
1024
*
1024
);
DRM_DEBUG
(
"mtrr_del=%d
\n
"
,
retval
);
DRM_DEBUG
(
"mtrr_del=%d
\n
"
,
retval
);
}
}
if
(
drm_core_has_AGP
(
dev
)
&&
dev
->
agp
)
{
DRM
(
agp_uninit
)();
DRM
(
free
)(
dev
->
agp
,
sizeof
(
*
dev
->
agp
),
DRM_MEM_AGPLISTS
);
dev
->
agp
=
NULL
;
}
DRM
(
takedown
)(
dev
);
if
(
dev
->
fn_tbl
.
postcleanup
)
dev
->
fn_tbl
.
postcleanup
(
dev
);
if
(
DRM
(
put_minor
)(
dev
)
)
DRM_ERROR
(
"Cannot unload module
\n
"
);
}
if
(
drm_core_has_AGP
(
dev
)
&&
dev
->
agp
)
{
DRM
(
agp_uninit
)();
DRM
(
free
)(
dev
->
agp
,
sizeof
(
*
dev
->
agp
),
DRM_MEM_AGPLISTS
);
dev
->
agp
=
NULL
;
}
if
(
dev
->
fn_tbl
.
postcleanup
)
static
void
__exit
drm_exit
(
void
)
dev
->
fn_tbl
.
postcleanup
(
dev
);
{
int
i
;
drm_device_t
*
dev
;
drm_minor_t
*
minor
;
DRM_DEBUG
(
"
\n
"
);
if
(
DRM
(
global
))
{
for
(
i
=
0
;
DRM
(
global
)
&&
(
i
<
DRM
(
global
)
->
cards_limit
);
i
++
)
{
minor
=
&
DRM
(
global
)
->
minors
[
i
];
dev
=
minor
->
dev
;
}
if
((
minor
->
type
==
DRM_MINOR_PRIMARY
)
&&
(
dev
->
fops
==
&
DRM
(
fops
)))
{
DRM
(
numdevs
)
=
0
;
/* release the pci driver */
if
(
dev
->
pdev
)
pci_dev_put
(
dev
->
pdev
);
drm_cleanup
(
dev
);
}
}
}
DRM_INFO
(
"Module unloaded
\n
"
);
}
}
module_init
(
drm_init
);
module_init
(
drm_init
);
module_exit
(
drm_
cleanup
);
module_exit
(
drm_
exit
);
/**
/**
...
@@ -674,19 +669,16 @@ int DRM(version)( struct inode *inode, struct file *filp,
...
@@ -674,19 +669,16 @@ int DRM(version)( struct inode *inode, struct file *filp,
int
DRM
(
open
)(
struct
inode
*
inode
,
struct
file
*
filp
)
int
DRM
(
open
)(
struct
inode
*
inode
,
struct
file
*
filp
)
{
{
drm_device_t
*
dev
=
NULL
;
drm_device_t
*
dev
=
NULL
;
int
minor
=
iminor
(
inode
);
int
retcode
=
0
;
int
retcode
=
0
;
int
i
;
for
(
i
=
0
;
i
<
DRM
(
numdevs
);
i
++
)
{
if
(
!
((
minor
>=
0
)
&&
(
minor
<
DRM
(
global
)
->
cards_limit
)))
if
(
iminor
(
inode
)
==
DRM
(
device
)[
i
].
minor
)
{
dev
=
&
(
DRM
(
device
)[
i
]);
break
;
}
}
if
(
!
dev
)
{
return
-
ENODEV
;
return
-
ENODEV
;
}
dev
=
DRM
(
global
)
->
minors
[
minor
].
dev
;
if
(
!
dev
)
return
-
ENODEV
;
retcode
=
DRM
(
open_helper
)(
inode
,
filp
,
dev
);
retcode
=
DRM
(
open_helper
)(
inode
,
filp
,
dev
);
if
(
!
retcode
)
{
if
(
!
retcode
)
{
atomic_inc
(
&
dev
->
counts
[
_DRM_STAT_OPENS
]
);
atomic_inc
(
&
dev
->
counts
[
_DRM_STAT_OPENS
]
);
...
...
drivers/char/drm/drm_irq.h
View file @
43d8a5b8
...
@@ -300,7 +300,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
...
@@ -300,7 +300,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
spin_unlock_irqrestore
(
&
dev
->
vbl_lock
,
irqflags
);
spin_unlock_irqrestore
(
&
dev
->
vbl_lock
,
irqflags
);
if
(
!
(
vbl_sig
=
DRM
_MALLOC
(
sizeof
(
drm_vbl_sig_t
)
)
)
)
{
if
(
!
(
vbl_sig
=
DRM
(
alloc
)(
sizeof
(
drm_vbl_sig_t
),
DRM_MEM_DRIVER
)
)
)
{
return
-
ENOMEM
;
return
-
ENOMEM
;
}
}
...
@@ -356,7 +356,7 @@ void DRM(vbl_send_signals)( drm_device_t *dev )
...
@@ -356,7 +356,7 @@ void DRM(vbl_send_signals)( drm_device_t *dev )
list_del
(
list
);
list_del
(
list
);
DRM
_FREE
(
vbl_sig
,
sizeof
(
*
vbl_sig
)
);
DRM
(
free
)(
vbl_sig
,
sizeof
(
*
vbl_sig
),
DRM_MEM_DRIVER
);
dev
->
vbl_pending
--
;
dev
->
vbl_pending
--
;
}
}
...
...
drivers/char/drm/drm_memory.h
View file @
43d8a5b8
...
@@ -39,10 +39,8 @@
...
@@ -39,10 +39,8 @@
/**
/**
* Cut down version of drm_memory_debug.h, which used to be called
* Cut down version of drm_memory_debug.h, which used to be called
* drm_memory.h. If you want the debug functionality, change 0 to 1
* drm_memory.h.
* below.
*/
*/
#define DEBUG_MEMORY 0
#if __OS_HAS_AGP
#if __OS_HAS_AGP
...
@@ -197,7 +195,7 @@ static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *d
...
@@ -197,7 +195,7 @@ static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *d
}
}
#if DEBUG_MEMORY
#if
def
DEBUG_MEMORY
#include "drm_memory_debug.h"
#include "drm_memory_debug.h"
#else
#else
...
@@ -226,13 +224,7 @@ int DRM(mem_info)(char *buf, char **start, off_t offset,
...
@@ -226,13 +224,7 @@ int DRM(mem_info)(char *buf, char **start, off_t offset,
}
}
/** Wrapper around kmalloc() */
/** Wrapper around kmalloc() */
void
*
DRM
(
alloc
)(
size_t
size
,
int
area
)
void
*
DRM
(
calloc
)(
size_t
nmemb
,
size_t
size
,
int
area
)
{
return
kmalloc
(
size
,
GFP_KERNEL
);
}
/** Wrapper around kmalloc() */
void
*
DRM
(
calloc
)(
size_t
size
,
size_t
nmemb
,
int
area
)
{
{
void
*
addr
;
void
*
addr
;
...
@@ -256,12 +248,6 @@ void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
...
@@ -256,12 +248,6 @@ void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
return
pt
;
return
pt
;
}
}
/** Wrapper around kfree() */
void
DRM
(
free
)(
void
*
pt
,
size_t
size
,
int
area
)
{
kfree
(
pt
);
}
/**
/**
* Allocate pages.
* Allocate pages.
*
*
...
...
drivers/char/drm/drm_memory_debug.h
View file @
43d8a5b8
...
@@ -167,7 +167,7 @@ void *DRM(alloc)(size_t size, int area)
...
@@ -167,7 +167,7 @@ void *DRM(alloc)(size_t size, int area)
return
pt
;
return
pt
;
}
}
void
*
DRM
(
calloc
)(
size_t
size
,
size_t
nmemb
,
int
area
)
void
*
DRM
(
calloc
)(
size_t
nmemb
,
size_t
size
,
int
area
)
{
{
void
*
addr
;
void
*
addr
;
...
...
drivers/char/drm/drm_os_linux.h
View file @
43d8a5b8
...
@@ -100,11 +100,6 @@ static __inline__ int mtrr_del (int reg, unsigned long base,
...
@@ -100,11 +100,6 @@ static __inline__ int mtrr_del (int reg, unsigned long base,
__put_user(val, uaddr)
__put_user(val, uaddr)
/** 'malloc' without the overhead of DRM(alloc)() */
#define DRM_MALLOC(x) kmalloc(x, GFP_KERNEL)
/** 'free' without the overhead of DRM(free)() */
#define DRM_FREE(x,size) kfree(x)
#define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) _priv = _filp->private_data
#define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) _priv = _filp->private_data
/**
/**
...
...
drivers/char/drm/drm_proc.h
View file @
43d8a5b8
...
@@ -86,25 +86,19 @@ struct drm_proc_list {
...
@@ -86,25 +86,19 @@ struct drm_proc_list {
* "/proc/dri/%minor%/", and each entry in proc_list as
* "/proc/dri/%minor%/", and each entry in proc_list as
* "/proc/dri/%minor%/%name%".
* "/proc/dri/%minor%/%name%".
*/
*/
struct
proc_dir_entry
*
DRM
(
proc_init
)(
drm_device_t
*
dev
,
int
minor
,
int
DRM
(
proc_init
)(
drm_device_t
*
dev
,
int
minor
,
struct
proc_dir_entry
*
root
,
struct
proc_dir_entry
*
root
,
struct
proc_dir_entry
**
dev_root
)
struct
proc_dir_entry
**
dev_root
)
{
{
struct
proc_dir_entry
*
ent
;
struct
proc_dir_entry
*
ent
;
int
i
,
j
;
int
i
,
j
;
char
name
[
64
];
char
name
[
64
];
if
(
!
minor
)
root
=
create_proc_entry
(
"dri"
,
S_IFDIR
,
NULL
);
if
(
!
root
)
{
DRM_ERROR
(
"Cannot create /proc/dri
\n
"
);
return
NULL
;
}
sprintf
(
name
,
"%d"
,
minor
);
sprintf
(
name
,
"%d"
,
minor
);
*
dev_root
=
create_proc_entry
(
name
,
S_IFDIR
,
root
);
*
dev_root
=
create_proc_entry
(
name
,
S_IFDIR
,
root
);
if
(
!*
dev_root
)
{
if
(
!*
dev_root
)
{
DRM_ERROR
(
"Cannot create /proc/dri/%s
\n
"
,
name
);
DRM_ERROR
(
"Cannot create /proc/dri/%s
\n
"
,
name
);
return
NULL
;
return
-
1
;
}
}
for
(
i
=
0
;
i
<
DRM_PROC_ENTRIES
;
i
++
)
{
for
(
i
=
0
;
i
<
DRM_PROC_ENTRIES
;
i
++
)
{
...
@@ -117,14 +111,13 @@ struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev, int minor,
...
@@ -117,14 +111,13 @@ struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev, int minor,
remove_proc_entry
(
DRM
(
proc_list
)[
i
].
name
,
remove_proc_entry
(
DRM
(
proc_list
)[
i
].
name
,
*
dev_root
);
*
dev_root
);
remove_proc_entry
(
name
,
root
);
remove_proc_entry
(
name
,
root
);
if
(
!
minor
)
remove_proc_entry
(
"dri"
,
NULL
);
return
-
1
;
return
NULL
;
}
}
ent
->
read_proc
=
DRM
(
proc_list
)[
i
].
f
;
ent
->
read_proc
=
DRM
(
proc_list
)[
i
].
f
;
ent
->
data
=
dev
;
ent
->
data
=
dev
;
}
}
return
root
;
return
0
;
}
}
...
@@ -150,7 +143,6 @@ int DRM(proc_cleanup)(int minor, struct proc_dir_entry *root,
...
@@ -150,7 +143,6 @@ int DRM(proc_cleanup)(int minor, struct proc_dir_entry *root,
remove_proc_entry
(
DRM
(
proc_list
)[
i
].
name
,
dev_root
);
remove_proc_entry
(
DRM
(
proc_list
)[
i
].
name
,
dev_root
);
sprintf
(
name
,
"%d"
,
minor
);
sprintf
(
name
,
"%d"
,
minor
);
remove_proc_entry
(
name
,
root
);
remove_proc_entry
(
name
,
root
);
if
(
!
minor
)
remove_proc_entry
(
"dri"
,
NULL
);
return
0
;
return
0
;
}
}
...
...
drivers/char/drm/drm_stub.h
View file @
43d8a5b8
...
@@ -33,25 +33,19 @@
...
@@ -33,25 +33,19 @@
#include "drmP.h"
#include "drmP.h"
#define DRM_STUB_MAXCARDS 16
/* Enough for one machine */
static
unsigned
int
cards_limit
=
16
;
/* Enough for one machine */
static
unsigned
int
debug
=
0
;
/* 1 to enable debug output */
static
struct
class_simple
*
drm_class
;
MODULE_AUTHOR
(
DRIVER_AUTHOR
);
MODULE_DESCRIPTION
(
DRIVER_DESC
);
MODULE_LICENSE
(
"GPL and additional rights"
);
MODULE_PARM_DESC
(
cards_limit
,
"Maximum number of graphics cards"
);
MODULE_PARM_DESC
(
debug
,
"Enable debug output"
);
/** Stub list. One for each minor. */
module_param
(
cards_limit
,
int
,
0444
);
static
struct
drm_stub_list
{
module_param
(
debug
,
int
,
0666
);
const
char
*
name
;
struct
file_operations
*
fops
;
/**< file operations */
struct
proc_dir_entry
*
dev_root
;
/**< proc directory entry */
}
*
DRM
(
stub_list
);
static
struct
proc_dir_entry
*
DRM
(
stub_root
);
drm_global_t
*
DRM
(
global
);
/** Stub information */
static
struct
drm_stub_info
{
int
(
*
info_register
)(
const
char
*
name
,
struct
file_operations
*
fops
,
drm_device_t
*
dev
);
int
(
*
info_unregister
)(
int
minor
);
}
DRM
(
stub_info
);
/**
/**
* File \c open operation.
* File \c open operation.
...
@@ -59,18 +53,27 @@ static struct drm_stub_info {
...
@@ -59,18 +53,27 @@ static struct drm_stub_info {
* \param inode device inode.
* \param inode device inode.
* \param filp file pointer.
* \param filp file pointer.
*
*
* Puts the d
rm_stub_list::
fops corresponding to the device minor number into
* Puts the d
ev->
fops corresponding to the device minor number into
* \p filp, call the \c open method, and restore the file operations.
* \p filp, call the \c open method, and restore the file operations.
*/
*/
static
int
DRM
(
stub_open
)
(
struct
inode
*
inode
,
struct
file
*
filp
)
static
int
stub_open
(
struct
inode
*
inode
,
struct
file
*
filp
)
{
{
int
minor
=
iminor
(
inode
);
drm_device_t
*
dev
=
NULL
;
int
err
=
-
ENODEV
;
int
minor
=
iminor
(
inode
);
int
err
=
-
ENODEV
;
struct
file_operations
*
old_fops
;
struct
file_operations
*
old_fops
;
DRM_DEBUG
(
"
\n
"
);
if
(
!
((
minor
>=
0
)
&&
(
minor
<
DRM
(
global
)
->
cards_limit
)))
return
-
ENODEV
;
if
(
!
DRM
(
stub_list
)
||
!
DRM
(
stub_list
)[
minor
].
fops
)
return
-
ENODEV
;
dev
=
DRM
(
global
)
->
minors
[
minor
].
dev
;
old_fops
=
filp
->
f_op
;
if
(
!
dev
)
filp
->
f_op
=
fops_get
(
DRM
(
stub_list
)[
minor
].
fops
);
return
-
ENODEV
;
old_fops
=
filp
->
f_op
;
filp
->
f_op
=
fops_get
(
dev
->
fops
);
if
(
filp
->
f_op
->
open
&&
(
err
=
filp
->
f_op
->
open
(
inode
,
filp
)))
{
if
(
filp
->
f_op
->
open
&&
(
err
=
filp
->
f_op
->
open
(
inode
,
filp
)))
{
fops_put
(
filp
->
f_op
);
fops_put
(
filp
->
f_op
);
filp
->
f_op
=
fops_get
(
old_fops
);
filp
->
f_op
=
fops_get
(
old_fops
);
...
@@ -83,48 +86,72 @@ static int DRM(stub_open)(struct inode *inode, struct file *filp)
...
@@ -83,48 +86,72 @@ static int DRM(stub_open)(struct inode *inode, struct file *filp)
/** File operations structure */
/** File operations structure */
static
struct
file_operations
DRM
(
stub_fops
)
=
{
static
struct
file_operations
DRM
(
stub_fops
)
=
{
.
owner
=
THIS_MODULE
,
.
owner
=
THIS_MODULE
,
.
open
=
DRM
(
stub_open
)
.
open
=
stub_open
};
};
/**
/**
* Get a device minor number.
* Get a device minor number.
*
*
* \param name driver name.
* \param pdev PCI device structure
* \param fops file operations.
* \param ent entry from the PCI ID table with device type flags
* \param dev DRM device.
* \return negative number on failure.
* \return minor number on success, or a negative number on failure.
*
*
* Allocate and initialize ::stub_list if one doesn't exist already. Search an
* Search an empty entry and initialize it to the given parameters, and
* empty entry and initialize it to the given parameters, and create the proc
* create the proc init entry via proc_init().
* init entry via proc_init().
*/
*/
static
int
DRM
(
stub_getminor
)(
const
char
*
name
,
struct
file_operations
*
fops
,
static
int
get_minor
(
struct
pci_dev
*
pdev
,
const
struct
pci_device_id
*
ent
)
drm_device_t
*
dev
)
{
{
int
i
;
struct
class_device
*
dev_class
;
drm_device_t
*
dev
;
int
ret
;
int
minor
;
drm_minor_t
*
minors
=
&
DRM
(
global
)
->
minors
[
0
];
if
(
!
DRM
(
stub_list
))
{
DRM_DEBUG
(
"
\n
"
);
DRM
(
stub_list
)
=
DRM
(
alloc
)(
sizeof
(
*
DRM
(
stub_list
))
*
DRM_STUB_MAXCARDS
,
DRM_MEM_STUB
);
for
(
minor
=
0
;
minor
<
DRM
(
global
)
->
cards_limit
;
minor
++
,
minors
++
)
{
if
(
!
DRM
(
stub_list
))
return
-
1
;
if
(
minors
->
type
==
DRM_MINOR_FREE
)
{
for
(
i
=
0
;
i
<
DRM_STUB_MAXCARDS
;
i
++
)
{
DRM
(
stub_list
)[
i
].
name
=
NULL
;
DRM_DEBUG
(
"assigning minor %d
\n
"
,
minor
);
DRM
(
stub_list
)[
i
].
fops
=
NULL
;
dev
=
DRM
(
calloc
)(
1
,
sizeof
(
*
dev
),
DRM_MEM_STUB
);
}
if
(
!
dev
)
}
return
-
ENOMEM
;
for
(
i
=
0
;
i
<
DRM_STUB_MAXCARDS
;
i
++
)
{
if
(
!
DRM
(
stub_list
)[
i
].
fops
)
{
*
minors
=
(
drm_minor_t
){.
dev
=
dev
,
.
type
=
DRM_MINOR_PRIMARY
};
DRM
(
stub_list
)[
i
].
name
=
name
;
dev
->
minor
=
minor
;
DRM
(
stub_list
)[
i
].
fops
=
fops
;
if
((
ret
=
DRM
(
fill_in_dev
)(
dev
,
pdev
,
ent
)))
{
DRM
(
stub_root
)
=
DRM
(
proc_init
)(
dev
,
i
,
DRM
(
stub_root
),
printk
(
KERN_ERR
"DRM: Fill_in_dev failed.
\n
"
);
&
DRM
(
stub_list
)[
i
]
goto
err_g1
;
.
dev_root
);
}
class_simple_device_add
(
drm_class
,
MKDEV
(
DRM_MAJOR
,
i
),
NULL
,
name
);
if
((
ret
=
DRM
(
proc_init
)(
dev
,
minor
,
DRM
(
global
)
->
proc_root
,
&
dev
->
dev_root
)))
{
return
i
;
printk
(
KERN_ERR
"DRM: Failed to initialize /proc/dri.
\n
"
);
goto
err_g1
;
}
pci_enable_device
(
pdev
);
dev_class
=
class_simple_device_add
(
DRM
(
global
)
->
drm_class
,
MKDEV
(
DRM_MAJOR
,
minor
),
&
pdev
->
dev
,
"card%d"
,
minor
);
if
(
IS_ERR
(
dev_class
))
{
printk
(
KERN_ERR
"DRM: Error class_simple_device_add.
\n
"
);
ret
=
PTR_ERR
(
dev_class
);
goto
err_g2
;
}
DRM_DEBUG
(
"new minor assigned %d
\n
"
,
minor
);
return
0
;
}
}
}
}
return
-
1
;
DRM_ERROR
(
"out of minors
\n
"
);
return
-
ENOMEM
;
err_g2:
DRM
(
proc_cleanup
)(
minor
,
DRM
(
global
)
->
proc_root
,
minors
->
dev_root
);
err_g1:
*
minors
=
(
drm_minor_t
){.
dev
=
NULL
,
.
type
=
DRM_MINOR_FREE
};
DRM
(
free
)(
dev
,
sizeof
(
*
dev
),
DRM_MEM_STUB
);
return
ret
;
}
}
/**
/**
* Put a device minor number.
* Put a device minor number.
...
@@ -136,101 +163,112 @@ static int DRM(stub_getminor)(const char *name, struct file_operations *fops,
...
@@ -136,101 +163,112 @@ static int DRM(stub_getminor)(const char *name, struct file_operations *fops,
* "drm" data, otherwise unregisters the "drm" data, frees the stub list and
* "drm" data, otherwise unregisters the "drm" data, frees the stub list and
* unregisters the character device.
* unregisters the character device.
*/
*/
static
int
DRM
(
stub_putminor
)(
int
minor
)
int
DRM
(
put_minor
)(
drm_device_t
*
dev
)
{
{
if
(
minor
<
0
||
minor
>=
DRM_STUB_MAXCARDS
)
return
-
1
;
drm_minor_t
*
minors
=
&
DRM
(
global
)
->
minors
[
dev
->
minor
];
DRM
(
stub_list
)[
minor
].
name
=
NULL
;
int
i
;
DRM
(
stub_list
)[
minor
].
fops
=
NULL
;
DRM
(
proc_cleanup
)(
minor
,
DRM
(
stub_root
),
DRM_DEBUG
(
"release minor %d
\n
"
,
dev
->
minor
);
DRM
(
stub_list
)[
minor
].
dev_root
);
if
(
minor
)
{
DRM
(
proc_cleanup
)(
dev
->
minor
,
DRM
(
global
)
->
proc_root
,
dev
->
dev_root
);
class_simple_device_remove
(
MKDEV
(
DRM_MAJOR
,
minor
));
class_simple_device_remove
(
MKDEV
(
DRM_MAJOR
,
dev
->
minor
));
inter_module_put
(
"drm"
);
}
else
{
*
minors
=
(
drm_minor_t
){.
dev
=
NULL
,
.
type
=
DRM_MINOR_FREE
};
inter_module_unregister
(
"drm"
);
DRM
(
free
)(
dev
,
sizeof
(
*
dev
),
DRM_MEM_STUB
);
DRM
(
free
)(
DRM
(
stub_list
),
sizeof
(
*
DRM
(
stub_list
))
*
DRM_STUB_MAXCARDS
,
/* if any device pointers are non-NULL we are not the last module */
DRM_MEM_STUB
);
for
(
i
=
0
;
i
<
DRM
(
global
)
->
cards_limit
;
i
++
)
{
unregister_chrdev
(
DRM_MAJOR
,
"drm"
);
if
(
DRM
(
global
)
->
minors
[
i
].
type
!=
DRM_MINOR_FREE
)
{
class_simple_device_remove
(
MKDEV
(
DRM_MAJOR
,
minor
));
DRM_DEBUG
(
"inter_module_put called
\n
"
);
class_simple_destroy
(
drm_class
);
inter_module_put
(
"drm"
);
return
0
;
}
}
}
DRM_DEBUG
(
"unregistering inter_module.
\n
"
);
inter_module_unregister
(
"drm"
);
remove_proc_entry
(
"dri"
,
NULL
);
class_simple_destroy
(
DRM
(
global
)
->
drm_class
);
unregister_chrdev
(
DRM_MAJOR
,
"drm"
);
DRM
(
free
)(
DRM
(
global
)
->
minors
,
sizeof
(
*
DRM
(
global
)
->
minors
)
*
DRM
(
global
)
->
cards_limit
,
DRM_MEM_STUB
);
DRM
(
free
)(
DRM
(
global
),
sizeof
(
*
DRM
(
global
)),
DRM_MEM_STUB
);
DRM
(
global
)
=
NULL
;
return
0
;
return
0
;
}
}
/**
/**
* Register.
* Register.
*
*
* \param name driver name.
* \param pdev - PCI device structure
* \param fops file operations
* \param ent entry from the PCI ID table with device type flags
* \param dev DRM device.
* \return zero on success or a negative number on failure.
* \return zero on success or a negative number on failure.
*
*
* Attempt to register the char device and get the foreign "drm" data. If
* Attempt to gets inter module "drm" information. If we are first
* successful then another module already registered so gets the stub info,
* then register the character device and inter module information.
* otherwise use this module stub info and make it available for other modules.
* Try and register, if we fail to register, backout previous work.
*
* Finally calls stub_info::info_register.
*/
*/
int
DRM
(
stub_register
)(
const
char
*
name
,
struct
file_operations
*
fops
,
int
DRM
(
probe
)(
struct
pci_dev
*
pdev
,
const
struct
pci_device_id
*
ent
)
drm_device_t
*
dev
)
{
{
struct
drm_stub_info
*
i
=
NULL
;
drm_global_t
*
global
;
int
ret1
;
int
ret
=
-
ENOMEM
;
int
ret2
;
DRM_DEBUG
(
"
\n
"
);
DRM_DEBUG
(
"
\n
"
);
ret1
=
register_chrdev
(
DRM_MAJOR
,
"drm"
,
&
DRM
(
stub_fops
));
if
(
!
ret1
)
{
/* use the inter_module_get to check - as if the same module
drm_class
=
class_simple_create
(
THIS_MODULE
,
"drm"
);
registers chrdev twice it succeeds */
if
(
IS_ERR
(
drm_class
))
{
global
=
(
drm_global_t
*
)
inter_module_get
(
"drm"
);
printk
(
KERN_ERR
"Error creating drm class.
\n
"
);
if
(
global
)
{
unregister_chrdev
(
DRM_MAJOR
,
"drm"
);
DRM
(
global
)
=
global
;
return
PTR_ERR
(
drm_class
);
global
=
NULL
;
}
else
{
DRM_DEBUG
(
"first probe
\n
"
);
global
=
DRM
(
calloc
)(
1
,
sizeof
(
*
global
),
DRM_MEM_STUB
);
if
(
!
global
)
return
-
ENOMEM
;
global
->
cards_limit
=
(
cards_limit
<
DRM_MAX_MINOR
+
1
?
cards_limit
:
DRM_MAX_MINOR
+
1
);
global
->
minors
=
DRM
(
calloc
)(
global
->
cards_limit
,
sizeof
(
*
global
->
minors
),
DRM_MEM_STUB
);
if
(
!
global
->
minors
)
goto
err_p1
;
if
(
register_chrdev
(
DRM_MAJOR
,
"drm"
,
&
DRM
(
stub_fops
)))
goto
err_p1
;
global
->
drm_class
=
class_simple_create
(
THIS_MODULE
,
"drm"
);
if
(
IS_ERR
(
global
->
drm_class
))
{
printk
(
KERN_ERR
"DRM: Error creating drm class.
\n
"
);
ret
=
PTR_ERR
(
global
->
drm_class
);
goto
err_p2
;
}
global
->
proc_root
=
create_proc_entry
(
"dri"
,
S_IFDIR
,
NULL
);
if
(
!
global
->
proc_root
)
{
DRM_ERROR
(
"Cannot create /proc/dri
\n
"
);
ret
=
-
1
;
goto
err_p3
;
}
}
}
else
if
(
ret1
==
-
EBUSY
)
i
=
(
struct
drm_stub_info
*
)
inter_module_get
(
"drm"
);
else
return
-
1
;
if
(
i
)
{
/* Already registered */
DRM
(
stub_info
).
info_register
=
i
->
info_register
;
DRM
(
stub_info
).
info_unregister
=
i
->
info_unregister
;
DRM_DEBUG
(
"already registered
\n
"
);
}
else
if
(
DRM
(
stub_info
).
info_register
!=
DRM
(
stub_getminor
))
{
DRM
(
stub_info
).
info_register
=
DRM
(
stub_getminor
);
DRM
(
stub_info
).
info_unregister
=
DRM
(
stub_putminor
);
DRM_DEBUG
(
"calling inter_module_register
\n
"
);
DRM_DEBUG
(
"calling inter_module_register
\n
"
);
inter_module_register
(
"drm"
,
THIS_MODULE
,
&
DRM
(
stub_info
));
inter_module_register
(
"drm"
,
THIS_MODULE
,
global
);
DRM
(
global
)
=
global
;
}
}
if
(
DRM
(
stub_info
).
info_register
)
{
if
((
ret
=
get_minor
(
pdev
,
ent
)))
{
ret2
=
DRM
(
stub_info
).
info_register
(
name
,
fops
,
dev
);
if
(
global
)
if
(
ret2
)
{
goto
err_p3
;
if
(
!
ret1
)
{
return
ret
;
unregister_chrdev
(
DRM_MAJOR
,
"drm"
);
class_simple_destroy
(
drm_class
);
}
if
(
!
i
)
inter_module_unregister
(
"drm"
);
}
return
ret2
;
}
}
return
-
1
;
return
0
;
}
err_p3:
class_simple_destroy
(
global
->
drm_class
);
/**
err_p2:
* Unregister.
unregister_chrdev
(
DRM_MAJOR
,
"drm"
);
*
DRM
(
free
)(
global
->
minors
,
sizeof
(
*
global
->
minors
)
*
global
->
cards_limit
,
DRM_MEM_STUB
);
* \param minor
err_p1:
*
DRM
(
free
)(
global
,
sizeof
(
*
global
),
DRM_MEM_STUB
);
* Calls drm_stub_info::unregister.
DRM
(
global
)
=
NULL
;
*/
return
ret
;
int
DRM
(
stub_unregister
)(
int
minor
)
{
DRM_DEBUG
(
"%d
\n
"
,
minor
);
if
(
DRM
(
stub_info
).
info_unregister
)
return
DRM
(
stub_info
).
info_unregister
(
minor
);
return
-
1
;
}
}
drivers/char/drm/i915_mem.c
View file @
43d8a5b8
...
@@ -75,7 +75,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
...
@@ -75,7 +75,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
{
{
/* Maybe cut off the start of an existing block */
/* Maybe cut off the start of an existing block */
if
(
start
>
p
->
start
)
{
if
(
start
>
p
->
start
)
{
struct
mem_block
*
newblock
=
DRM
_MALLOC
(
sizeof
(
*
newblock
)
);
struct
mem_block
*
newblock
=
DRM
(
alloc
)(
sizeof
(
*
newblock
),
DRM_MEM_BUFLISTS
);
if
(
!
newblock
)
if
(
!
newblock
)
goto
out
;
goto
out
;
newblock
->
start
=
start
;
newblock
->
start
=
start
;
...
@@ -91,7 +91,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
...
@@ -91,7 +91,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
/* Maybe cut off the end of an existing block */
/* Maybe cut off the end of an existing block */
if
(
size
<
p
->
size
)
{
if
(
size
<
p
->
size
)
{
struct
mem_block
*
newblock
=
DRM
_MALLOC
(
sizeof
(
*
newblock
)
);
struct
mem_block
*
newblock
=
DRM
(
alloc
)(
sizeof
(
*
newblock
),
DRM_MEM_BUFLISTS
);
if
(
!
newblock
)
if
(
!
newblock
)
goto
out
;
goto
out
;
newblock
->
start
=
start
+
size
;
newblock
->
start
=
start
+
size
;
...
@@ -148,7 +148,7 @@ static void free_block(struct mem_block *p)
...
@@ -148,7 +148,7 @@ static void free_block(struct mem_block *p)
p
->
size
+=
q
->
size
;
p
->
size
+=
q
->
size
;
p
->
next
=
q
->
next
;
p
->
next
=
q
->
next
;
p
->
next
->
prev
=
p
;
p
->
next
->
prev
=
p
;
DRM
_FREE
(
q
,
sizeof
(
*
q
)
);
DRM
(
free
)(
q
,
sizeof
(
*
q
),
DRM_MEM_BUFLISTS
);
}
}
if
(
p
->
prev
->
filp
==
NULL
)
{
if
(
p
->
prev
->
filp
==
NULL
)
{
...
@@ -156,7 +156,7 @@ static void free_block(struct mem_block *p)
...
@@ -156,7 +156,7 @@ static void free_block(struct mem_block *p)
q
->
size
+=
p
->
size
;
q
->
size
+=
p
->
size
;
q
->
next
=
p
->
next
;
q
->
next
=
p
->
next
;
q
->
next
->
prev
=
q
;
q
->
next
->
prev
=
q
;
DRM
_FREE
(
p
,
sizeof
(
*
q
)
);
DRM
(
free
)(
p
,
sizeof
(
*
q
),
DRM_MEM_BUFLISTS
);
}
}
}
}
...
@@ -164,14 +164,14 @@ static void free_block(struct mem_block *p)
...
@@ -164,14 +164,14 @@ static void free_block(struct mem_block *p)
*/
*/
static
int
init_heap
(
struct
mem_block
**
heap
,
int
start
,
int
size
)
static
int
init_heap
(
struct
mem_block
**
heap
,
int
start
,
int
size
)
{
{
struct
mem_block
*
blocks
=
DRM
_MALLOC
(
sizeof
(
*
blocks
)
);
struct
mem_block
*
blocks
=
DRM
(
alloc
)(
sizeof
(
*
blocks
),
DRM_MEM_BUFLISTS
);
if
(
!
blocks
)
if
(
!
blocks
)
return
-
ENOMEM
;
return
-
ENOMEM
;
*
heap
=
DRM
_MALLOC
(
sizeof
(
**
heap
)
);
*
heap
=
DRM
(
alloc
)(
sizeof
(
**
heap
),
DRM_MEM_BUFLISTS
);
if
(
!*
heap
)
{
if
(
!*
heap
)
{
DRM
_FREE
(
blocks
,
sizeof
(
*
blocks
)
);
DRM
(
free
)(
blocks
,
sizeof
(
*
blocks
),
DRM_MEM_BUFLISTS
);
return
-
ENOMEM
;
return
-
ENOMEM
;
}
}
...
@@ -211,7 +211,7 @@ void i915_mem_release(drm_device_t * dev, DRMFILE filp, struct mem_block *heap)
...
@@ -211,7 +211,7 @@ void i915_mem_release(drm_device_t * dev, DRMFILE filp, struct mem_block *heap)
p
->
size
+=
q
->
size
;
p
->
size
+=
q
->
size
;
p
->
next
=
q
->
next
;
p
->
next
=
q
->
next
;
p
->
next
->
prev
=
p
;
p
->
next
->
prev
=
p
;
DRM
_FREE
(
q
,
sizeof
(
*
q
)
);
DRM
(
free
)(
q
,
sizeof
(
*
q
),
DRM_MEM_BUFLISTS
);
}
}
}
}
}
}
...
@@ -228,10 +228,10 @@ void i915_mem_takedown(struct mem_block **heap)
...
@@ -228,10 +228,10 @@ void i915_mem_takedown(struct mem_block **heap)
for
(
p
=
(
*
heap
)
->
next
;
p
!=
*
heap
;)
{
for
(
p
=
(
*
heap
)
->
next
;
p
!=
*
heap
;)
{
struct
mem_block
*
q
=
p
;
struct
mem_block
*
q
=
p
;
p
=
p
->
next
;
p
=
p
->
next
;
DRM
_FREE
(
q
,
sizeof
(
*
q
)
);
DRM
(
free
)(
q
,
sizeof
(
*
q
),
DRM_MEM_BUFLISTS
);
}
}
DRM
_FREE
(
*
heap
,
sizeof
(
**
heap
)
);
DRM
(
free
)(
*
heap
,
sizeof
(
**
heap
),
DRM_MEM_BUFLISTS
);
*
heap
=
NULL
;
*
heap
=
NULL
;
}
}
...
...
drivers/char/drm/r128_state.c
View file @
43d8a5b8
...
@@ -926,24 +926,24 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
...
@@ -926,24 +926,24 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
buffer_size
=
depth
->
n
*
sizeof
(
u32
);
buffer_size
=
depth
->
n
*
sizeof
(
u32
);
buffer
=
DRM
_MALLOC
(
buffer_size
);
buffer
=
DRM
(
alloc
)(
buffer_size
,
DRM_MEM_BUFS
);
if
(
buffer
==
NULL
)
if
(
buffer
==
NULL
)
return
DRM_ERR
(
ENOMEM
);
return
DRM_ERR
(
ENOMEM
);
if
(
DRM_COPY_FROM_USER
(
buffer
,
depth
->
buffer
,
buffer_size
)
)
{
if
(
DRM_COPY_FROM_USER
(
buffer
,
depth
->
buffer
,
buffer_size
)
)
{
DRM
_FREE
(
buffer
,
buffer_size
);
DRM
(
free
)(
buffer
,
buffer_size
,
DRM_MEM_BUFS
);
return
DRM_ERR
(
EFAULT
);
return
DRM_ERR
(
EFAULT
);
}
}
mask_size
=
depth
->
n
*
sizeof
(
u8
);
mask_size
=
depth
->
n
*
sizeof
(
u8
);
if
(
depth
->
mask
)
{
if
(
depth
->
mask
)
{
mask
=
DRM
_MALLOC
(
mask_size
);
mask
=
DRM
(
alloc
)(
mask_size
,
DRM_MEM_BUFS
);
if
(
mask
==
NULL
)
{
if
(
mask
==
NULL
)
{
DRM
_FREE
(
buffer
,
buffer_size
);
DRM
(
free
)(
buffer
,
buffer_size
,
DRM_MEM_BUFS
);
return
DRM_ERR
(
ENOMEM
);
return
DRM_ERR
(
ENOMEM
);
}
}
if
(
DRM_COPY_FROM_USER
(
mask
,
depth
->
mask
,
mask_size
)
)
{
if
(
DRM_COPY_FROM_USER
(
mask
,
depth
->
mask
,
mask_size
)
)
{
DRM
_FREE
(
buffer
,
buffer_size
);
DRM
(
free
)(
buffer
,
buffer_size
,
DRM_MEM_BUFS
);
DRM
_FREE
(
mask
,
mask_size
);
DRM
(
free
)(
mask
,
mask_size
,
DRM_MEM_BUFS
);
return
DRM_ERR
(
EFAULT
);
return
DRM_ERR
(
EFAULT
);
}
}
...
@@ -970,7 +970,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
...
@@ -970,7 +970,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
}
}
DRM
_FREE
(
mask
,
mask_size
);
DRM
(
free
)(
mask
,
mask_size
,
DRM_MEM_BUFS
);
}
else
{
}
else
{
for
(
i
=
0
;
i
<
count
;
i
++
,
x
++
)
{
for
(
i
=
0
;
i
<
count
;
i
++
,
x
++
)
{
BEGIN_RING
(
6
);
BEGIN_RING
(
6
);
...
@@ -994,7 +994,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
...
@@ -994,7 +994,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
}
}
DRM
_FREE
(
buffer
,
buffer_size
);
DRM
(
free
)(
buffer
,
buffer_size
,
DRM_MEM_BUFS
);
return
0
;
return
0
;
}
}
...
@@ -1016,54 +1016,54 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
...
@@ -1016,54 +1016,54 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
xbuf_size
=
count
*
sizeof
(
*
x
);
xbuf_size
=
count
*
sizeof
(
*
x
);
ybuf_size
=
count
*
sizeof
(
*
y
);
ybuf_size
=
count
*
sizeof
(
*
y
);
x
=
DRM
_MALLOC
(
xbuf_size
);
x
=
DRM
(
alloc
)(
xbuf_size
,
DRM_MEM_BUFS
);
if
(
x
==
NULL
)
{
if
(
x
==
NULL
)
{
return
DRM_ERR
(
ENOMEM
);
return
DRM_ERR
(
ENOMEM
);
}
}
y
=
DRM
_MALLOC
(
ybuf_size
);
y
=
DRM
(
alloc
)(
ybuf_size
,
DRM_MEM_BUFS
);
if
(
y
==
NULL
)
{
if
(
y
==
NULL
)
{
DRM
_FREE
(
x
,
xbuf_size
);
DRM
(
free
)(
x
,
xbuf_size
,
DRM_MEM_BUFS
);
return
DRM_ERR
(
ENOMEM
);
return
DRM_ERR
(
ENOMEM
);
}
}
if
(
DRM_COPY_FROM_USER
(
x
,
depth
->
x
,
xbuf_size
)
)
{
if
(
DRM_COPY_FROM_USER
(
x
,
depth
->
x
,
xbuf_size
)
)
{
DRM
_FREE
(
x
,
xbuf_size
);
DRM
(
free
)(
x
,
xbuf_size
,
DRM_MEM_BUFS
);
DRM
_FREE
(
y
,
ybuf_size
);
DRM
(
free
)(
y
,
ybuf_size
,
DRM_MEM_BUFS
);
return
DRM_ERR
(
EFAULT
);
return
DRM_ERR
(
EFAULT
);
}
}
if
(
DRM_COPY_FROM_USER
(
y
,
depth
->
y
,
xbuf_size
)
)
{
if
(
DRM_COPY_FROM_USER
(
y
,
depth
->
y
,
xbuf_size
)
)
{
DRM
_FREE
(
x
,
xbuf_size
);
DRM
(
free
)(
x
,
xbuf_size
,
DRM_MEM_BUFS
);
DRM
_FREE
(
y
,
ybuf_size
);
DRM
(
free
)(
y
,
ybuf_size
,
DRM_MEM_BUFS
);
return
DRM_ERR
(
EFAULT
);
return
DRM_ERR
(
EFAULT
);
}
}
buffer_size
=
depth
->
n
*
sizeof
(
u32
);
buffer_size
=
depth
->
n
*
sizeof
(
u32
);
buffer
=
DRM
_MALLOC
(
buffer_size
);
buffer
=
DRM
(
alloc
)(
buffer_size
,
DRM_MEM_BUFS
);
if
(
buffer
==
NULL
)
{
if
(
buffer
==
NULL
)
{
DRM
_FREE
(
x
,
xbuf_size
);
DRM
(
free
)(
x
,
xbuf_size
,
DRM_MEM_BUFS
);
DRM
_FREE
(
y
,
ybuf_size
);
DRM
(
free
)(
y
,
ybuf_size
,
DRM_MEM_BUFS
);
return
DRM_ERR
(
ENOMEM
);
return
DRM_ERR
(
ENOMEM
);
}
}
if
(
DRM_COPY_FROM_USER
(
buffer
,
depth
->
buffer
,
buffer_size
)
)
{
if
(
DRM_COPY_FROM_USER
(
buffer
,
depth
->
buffer
,
buffer_size
)
)
{
DRM
_FREE
(
x
,
xbuf_size
);
DRM
(
free
)(
x
,
xbuf_size
,
DRM_MEM_BUFS
);
DRM
_FREE
(
y
,
ybuf_size
);
DRM
(
free
)(
y
,
ybuf_size
,
DRM_MEM_BUFS
);
DRM
_FREE
(
buffer
,
buffer_size
);
DRM
(
free
)(
buffer
,
buffer_size
,
DRM_MEM_BUFS
);
return
DRM_ERR
(
EFAULT
);
return
DRM_ERR
(
EFAULT
);
}
}
if
(
depth
->
mask
)
{
if
(
depth
->
mask
)
{
mask_size
=
depth
->
n
*
sizeof
(
u8
);
mask_size
=
depth
->
n
*
sizeof
(
u8
);
mask
=
DRM
_MALLOC
(
mask_size
);
mask
=
DRM
(
alloc
)(
mask_size
,
DRM_MEM_BUFS
);
if
(
mask
==
NULL
)
{
if
(
mask
==
NULL
)
{
DRM
_FREE
(
x
,
xbuf_size
);
DRM
(
free
)(
x
,
xbuf_size
,
DRM_MEM_BUFS
);
DRM
_FREE
(
y
,
ybuf_size
);
DRM
(
free
)(
y
,
ybuf_size
,
DRM_MEM_BUFS
);
DRM
_FREE
(
buffer
,
buffer_size
);
DRM
(
free
)(
buffer
,
buffer_size
,
DRM_MEM_BUFS
);
return
DRM_ERR
(
ENOMEM
);
return
DRM_ERR
(
ENOMEM
);
}
}
if
(
DRM_COPY_FROM_USER
(
mask
,
depth
->
mask
,
mask_size
)
)
{
if
(
DRM_COPY_FROM_USER
(
mask
,
depth
->
mask
,
mask_size
)
)
{
DRM
_FREE
(
x
,
xbuf_size
);
DRM
(
free
)(
x
,
xbuf_size
,
DRM_MEM_BUFS
);
DRM
_FREE
(
y
,
ybuf_size
);
DRM
(
free
)(
y
,
ybuf_size
,
DRM_MEM_BUFS
);
DRM
_FREE
(
buffer
,
buffer_size
);
DRM
(
free
)(
buffer
,
buffer_size
,
DRM_MEM_BUFS
);
DRM
_FREE
(
mask
,
mask_size
);
DRM
(
free
)(
mask
,
mask_size
,
DRM_MEM_BUFS
);
return
DRM_ERR
(
EFAULT
);
return
DRM_ERR
(
EFAULT
);
}
}
...
@@ -1090,7 +1090,7 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
...
@@ -1090,7 +1090,7 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
}
}
DRM
_FREE
(
mask
,
mask_size
);
DRM
(
free
)(
mask
,
mask_size
,
DRM_MEM_BUFS
);
}
else
{
}
else
{
for
(
i
=
0
;
i
<
count
;
i
++
)
{
for
(
i
=
0
;
i
<
count
;
i
++
)
{
BEGIN_RING
(
6
);
BEGIN_RING
(
6
);
...
@@ -1114,9 +1114,9 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
...
@@ -1114,9 +1114,9 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
}
}
DRM
_FREE
(
x
,
xbuf_size
);
DRM
(
free
)(
x
,
xbuf_size
,
DRM_MEM_BUFS
);
DRM
_FREE
(
y
,
ybuf_size
);
DRM
(
free
)(
y
,
ybuf_size
,
DRM_MEM_BUFS
);
DRM
_FREE
(
buffer
,
buffer_size
);
DRM
(
free
)(
buffer
,
buffer_size
,
DRM_MEM_BUFS
);
return
0
;
return
0
;
}
}
...
@@ -1184,23 +1184,23 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
...
@@ -1184,23 +1184,23 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
xbuf_size
=
count
*
sizeof
(
*
x
);
xbuf_size
=
count
*
sizeof
(
*
x
);
ybuf_size
=
count
*
sizeof
(
*
y
);
ybuf_size
=
count
*
sizeof
(
*
y
);
x
=
DRM
_MALLOC
(
xbuf_size
);
x
=
DRM
(
alloc
)(
xbuf_size
,
DRM_MEM_BUFS
);
if
(
x
==
NULL
)
{
if
(
x
==
NULL
)
{
return
DRM_ERR
(
ENOMEM
);
return
DRM_ERR
(
ENOMEM
);
}
}
y
=
DRM
_MALLOC
(
ybuf_size
);
y
=
DRM
(
alloc
)(
ybuf_size
,
DRM_MEM_BUFS
);
if
(
y
==
NULL
)
{
if
(
y
==
NULL
)
{
DRM
_FREE
(
x
,
xbuf_size
);
DRM
(
free
)(
x
,
xbuf_size
,
DRM_MEM_BUFS
);
return
DRM_ERR
(
ENOMEM
);
return
DRM_ERR
(
ENOMEM
);
}
}
if
(
DRM_COPY_FROM_USER
(
x
,
depth
->
x
,
xbuf_size
)
)
{
if
(
DRM_COPY_FROM_USER
(
x
,
depth
->
x
,
xbuf_size
)
)
{
DRM
_FREE
(
x
,
xbuf_size
);
DRM
(
free
)(
x
,
xbuf_size
,
DRM_MEM_BUFS
);
DRM
_FREE
(
y
,
ybuf_size
);
DRM
(
free
)(
y
,
ybuf_size
,
DRM_MEM_BUFS
);
return
DRM_ERR
(
EFAULT
);
return
DRM_ERR
(
EFAULT
);
}
}
if
(
DRM_COPY_FROM_USER
(
y
,
depth
->
y
,
ybuf_size
)
)
{
if
(
DRM_COPY_FROM_USER
(
y
,
depth
->
y
,
ybuf_size
)
)
{
DRM
_FREE
(
x
,
xbuf_size
);
DRM
(
free
)(
x
,
xbuf_size
,
DRM_MEM_BUFS
);
DRM
_FREE
(
y
,
ybuf_size
);
DRM
(
free
)(
y
,
ybuf_size
,
DRM_MEM_BUFS
);
return
DRM_ERR
(
EFAULT
);
return
DRM_ERR
(
EFAULT
);
}
}
...
@@ -1228,8 +1228,8 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
...
@@ -1228,8 +1228,8 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
ADVANCE_RING
();
ADVANCE_RING
();
}
}
DRM
_FREE
(
x
,
xbuf_size
);
DRM
(
free
)(
x
,
xbuf_size
,
DRM_MEM_BUFS
);
DRM
_FREE
(
y
,
ybuf_size
);
DRM
(
free
)(
y
,
ybuf_size
,
DRM_MEM_BUFS
);
return
0
;
return
0
;
}
}
...
...
drivers/char/drm/radeon_mem.c
View file @
43d8a5b8
...
@@ -44,7 +44,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
...
@@ -44,7 +44,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
{
{
/* Maybe cut off the start of an existing block */
/* Maybe cut off the start of an existing block */
if
(
start
>
p
->
start
)
{
if
(
start
>
p
->
start
)
{
struct
mem_block
*
newblock
=
DRM
_MALLOC
(
sizeof
(
*
newblock
)
);
struct
mem_block
*
newblock
=
DRM
(
alloc
)(
sizeof
(
*
newblock
),
DRM_MEM_BUFS
);
if
(
!
newblock
)
if
(
!
newblock
)
goto
out
;
goto
out
;
newblock
->
start
=
start
;
newblock
->
start
=
start
;
...
@@ -60,7 +60,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
...
@@ -60,7 +60,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
/* Maybe cut off the end of an existing block */
/* Maybe cut off the end of an existing block */
if
(
size
<
p
->
size
)
{
if
(
size
<
p
->
size
)
{
struct
mem_block
*
newblock
=
DRM
_MALLOC
(
sizeof
(
*
newblock
)
);
struct
mem_block
*
newblock
=
DRM
(
alloc
)(
sizeof
(
*
newblock
),
DRM_MEM_BUFS
);
if
(
!
newblock
)
if
(
!
newblock
)
goto
out
;
goto
out
;
newblock
->
start
=
start
+
size
;
newblock
->
start
=
start
+
size
;
...
@@ -118,7 +118,7 @@ static void free_block( struct mem_block *p )
...
@@ -118,7 +118,7 @@ static void free_block( struct mem_block *p )
p
->
size
+=
q
->
size
;
p
->
size
+=
q
->
size
;
p
->
next
=
q
->
next
;
p
->
next
=
q
->
next
;
p
->
next
->
prev
=
p
;
p
->
next
->
prev
=
p
;
DRM
_FREE
(
q
,
sizeof
(
*
q
)
);
DRM
(
free
)(
q
,
sizeof
(
*
q
),
DRM_MEM_BUFS
);
}
}
if
(
p
->
prev
->
filp
==
0
)
{
if
(
p
->
prev
->
filp
==
0
)
{
...
@@ -126,7 +126,7 @@ static void free_block( struct mem_block *p )
...
@@ -126,7 +126,7 @@ static void free_block( struct mem_block *p )
q
->
size
+=
p
->
size
;
q
->
size
+=
p
->
size
;
q
->
next
=
p
->
next
;
q
->
next
=
p
->
next
;
q
->
next
->
prev
=
q
;
q
->
next
->
prev
=
q
;
DRM
_FREE
(
p
,
sizeof
(
*
q
)
);
DRM
(
free
)(
p
,
sizeof
(
*
q
),
DRM_MEM_BUFS
);
}
}
}
}
...
@@ -134,14 +134,14 @@ static void free_block( struct mem_block *p )
...
@@ -134,14 +134,14 @@ static void free_block( struct mem_block *p )
*/
*/
static
int
init_heap
(
struct
mem_block
**
heap
,
int
start
,
int
size
)
static
int
init_heap
(
struct
mem_block
**
heap
,
int
start
,
int
size
)
{
{
struct
mem_block
*
blocks
=
DRM
_MALLOC
(
sizeof
(
*
blocks
)
);
struct
mem_block
*
blocks
=
DRM
(
alloc
)(
sizeof
(
*
blocks
),
DRM_MEM_BUFS
);
if
(
!
blocks
)
if
(
!
blocks
)
return
DRM_ERR
(
ENOMEM
);
return
DRM_ERR
(
ENOMEM
);
*
heap
=
DRM
_MALLOC
(
sizeof
(
**
heap
)
);
*
heap
=
DRM
(
alloc
)(
sizeof
(
**
heap
),
DRM_MEM_BUFS
);
if
(
!*
heap
)
{
if
(
!*
heap
)
{
DRM
_FREE
(
blocks
,
sizeof
(
*
blocks
)
);
DRM
(
free
)(
blocks
,
sizeof
(
*
blocks
),
DRM_MEM_BUFS
);
return
DRM_ERR
(
ENOMEM
);
return
DRM_ERR
(
ENOMEM
);
}
}
...
@@ -180,7 +180,7 @@ void radeon_mem_release( DRMFILE filp, struct mem_block *heap )
...
@@ -180,7 +180,7 @@ void radeon_mem_release( DRMFILE filp, struct mem_block *heap )
p
->
size
+=
q
->
size
;
p
->
size
+=
q
->
size
;
p
->
next
=
q
->
next
;
p
->
next
=
q
->
next
;
p
->
next
->
prev
=
p
;
p
->
next
->
prev
=
p
;
DRM
_FREE
(
q
,
sizeof
(
*
q
)
);
DRM
(
free
)(
q
,
sizeof
(
*
q
),
DRM_MEM_DRIVER
);
}
}
}
}
}
}
...
@@ -197,10 +197,10 @@ void radeon_mem_takedown( struct mem_block **heap )
...
@@ -197,10 +197,10 @@ void radeon_mem_takedown( struct mem_block **heap )
for
(
p
=
(
*
heap
)
->
next
;
p
!=
*
heap
;
)
{
for
(
p
=
(
*
heap
)
->
next
;
p
!=
*
heap
;
)
{
struct
mem_block
*
q
=
p
;
struct
mem_block
*
q
=
p
;
p
=
p
->
next
;
p
=
p
->
next
;
DRM
_FREE
(
q
,
sizeof
(
*
q
)
);
DRM
(
free
)(
q
,
sizeof
(
*
q
),
DRM_MEM_DRIVER
);
}
}
DRM
_FREE
(
*
heap
,
sizeof
(
**
heap
)
);
DRM
(
free
)(
*
heap
,
sizeof
(
**
heap
),
DRM_MEM_DRIVER
);
*
heap
=
NULL
;
*
heap
=
NULL
;
}
}
...
...
drivers/char/drm/radeon_state.c
View file @
43d8a5b8
...
@@ -1440,7 +1440,8 @@ static int radeon_cp_dispatch_texture( DRMFILE filp,
...
@@ -1440,7 +1440,8 @@ static int radeon_cp_dispatch_texture( DRMFILE filp,
}
}
if
(
!
buf
)
{
if
(
!
buf
)
{
DRM_DEBUG
(
"radeon_cp_dispatch_texture: EAGAIN
\n
"
);
DRM_DEBUG
(
"radeon_cp_dispatch_texture: EAGAIN
\n
"
);
DRM_COPY_TO_USER
(
tex
->
image
,
image
,
sizeof
(
*
image
)
);
if
(
DRM_COPY_TO_USER
(
tex
->
image
,
image
,
sizeof
(
*
image
)
))
return
DRM_ERR
(
EFAULT
);
return
DRM_ERR
(
EAGAIN
);
return
DRM_ERR
(
EAGAIN
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment