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
30718727
Commit
30718727
authored
Dec 30, 2002
by
Linus Torvalds
Browse files
Options
Browse Files
Download
Plain Diff
Merge
bk://linux-dj.bkbits.net/agpgart
into home.transmeta.com:/home/torvalds/v2.5/linux
parents
1ae71dcb
6c9ac65b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
134 additions
and
160 deletions
+134
-160
drivers/char/agp/backend.c
drivers/char/agp/backend.c
+3
-7
drivers/char/agp/frontend.c
drivers/char/agp/frontend.c
+131
-153
No files found.
drivers/char/agp/backend.c
View file @
30718727
...
@@ -49,13 +49,10 @@ int agp_backend_acquire(void)
...
@@ -49,13 +49,10 @@ int agp_backend_acquire(void)
if
(
agp_bridge
.
type
==
NOT_SUPPORTED
)
if
(
agp_bridge
.
type
==
NOT_SUPPORTED
)
return
-
EINVAL
;
return
-
EINVAL
;
atomic_inc
(
&
agp_bridge
.
agp_in_use
);
if
(
atomic_read
(
&
agp_bridge
.
agp_in_use
)
!=
0
)
if
(
atomic_read
(
&
agp_bridge
.
agp_in_use
)
!=
1
)
{
atomic_dec
(
&
agp_bridge
.
agp_in_use
);
return
-
EBUSY
;
return
-
EBUSY
;
}
MOD_INC_USE_COUNT
;
atomic_inc
(
&
agp_bridge
.
agp_in_use
)
;
return
0
;
return
0
;
}
}
...
@@ -65,7 +62,6 @@ void agp_backend_release(void)
...
@@ -65,7 +62,6 @@ void agp_backend_release(void)
return
;
return
;
atomic_dec
(
&
agp_bridge
.
agp_in_use
);
atomic_dec
(
&
agp_bridge
.
agp_in_use
);
MOD_DEC_USE_COUNT
;
}
}
struct
agp_max_table
{
struct
agp_max_table
{
...
...
drivers/char/agp/frontend.c
View file @
30718727
...
@@ -43,15 +43,14 @@ static agp_memory *agp_find_mem_by_key(int key)
...
@@ -43,15 +43,14 @@ static agp_memory *agp_find_mem_by_key(int key)
{
{
agp_memory
*
curr
;
agp_memory
*
curr
;
if
(
agp_fe
.
current_controller
==
NULL
)
{
if
(
agp_fe
.
current_controller
==
NULL
)
return
NULL
;
return
NULL
;
}
curr
=
agp_fe
.
current_controller
->
pool
;
curr
=
agp_fe
.
current_controller
->
pool
;
while
(
curr
!=
NULL
)
{
while
(
curr
!=
NULL
)
{
if
(
curr
->
key
==
key
)
{
if
(
curr
->
key
==
key
)
return
curr
;
return
curr
;
}
curr
=
curr
->
next
;
curr
=
curr
->
next
;
}
}
...
@@ -71,14 +70,14 @@ static void agp_remove_from_pool(agp_memory * temp)
...
@@ -71,14 +70,14 @@ static void agp_remove_from_pool(agp_memory * temp)
if
(
prev
!=
NULL
)
{
if
(
prev
!=
NULL
)
{
prev
->
next
=
next
;
prev
->
next
=
next
;
if
(
next
!=
NULL
)
{
if
(
next
!=
NULL
)
next
->
prev
=
prev
;
next
->
prev
=
prev
;
}
}
else
{
}
else
{
/* This is the first item on the list */
/* This is the first item on the list */
if
(
next
!=
NULL
)
{
if
(
next
!=
NULL
)
next
->
prev
=
NULL
;
next
->
prev
=
NULL
;
}
agp_fe
.
current_controller
->
pool
=
next
;
agp_fe
.
current_controller
->
pool
=
next
;
}
}
}
}
...
@@ -116,9 +115,8 @@ static agp_segment_priv *agp_find_seg_in_client(const agp_client * client,
...
@@ -116,9 +115,8 @@ static agp_segment_priv *agp_find_seg_in_client(const agp_client * client,
static
void
agp_remove_seg_from_client
(
agp_client
*
client
)
static
void
agp_remove_seg_from_client
(
agp_client
*
client
)
{
{
if
(
client
->
segments
!=
NULL
)
{
if
(
client
->
segments
!=
NULL
)
{
if
(
*
(
client
->
segments
)
!=
NULL
)
{
if
(
*
(
client
->
segments
)
!=
NULL
)
kfree
(
*
(
client
->
segments
));
kfree
(
*
(
client
->
segments
));
}
kfree
(
client
->
segments
);
kfree
(
client
->
segments
);
}
}
}
}
...
@@ -130,9 +128,9 @@ static void agp_add_seg_to_client(agp_client * client,
...
@@ -130,9 +128,9 @@ static void agp_add_seg_to_client(agp_client * client,
prev_seg
=
client
->
segments
;
prev_seg
=
client
->
segments
;
if
(
prev_seg
!=
NULL
)
{
if
(
prev_seg
!=
NULL
)
agp_remove_seg_from_client
(
client
);
agp_remove_seg_from_client
(
client
);
}
client
->
num_segments
=
num_segments
;
client
->
num_segments
=
num_segments
;
client
->
segments
=
seg
;
client
->
segments
=
seg
;
}
}
...
@@ -175,8 +173,7 @@ static int agp_create_segment(agp_client * client, agp_region * region)
...
@@ -175,8 +173,7 @@ static int agp_create_segment(agp_client * client, agp_region * region)
agp_segment
*
user_seg
;
agp_segment
*
user_seg
;
int
i
;
int
i
;
seg
=
kmalloc
((
sizeof
(
agp_segment_priv
)
*
region
->
seg_count
),
seg
=
kmalloc
((
sizeof
(
agp_segment_priv
)
*
region
->
seg_count
),
GFP_KERNEL
);
GFP_KERNEL
);
if
(
seg
==
NULL
)
{
if
(
seg
==
NULL
)
{
kfree
(
region
->
seg_list
);
kfree
(
region
->
seg_list
);
return
-
ENOMEM
;
return
-
ENOMEM
;
...
@@ -227,9 +224,8 @@ agp_file_private *agp_find_private(pid_t pid)
...
@@ -227,9 +224,8 @@ agp_file_private *agp_find_private(pid_t pid)
curr
=
agp_fe
.
file_priv_list
;
curr
=
agp_fe
.
file_priv_list
;
while
(
curr
!=
NULL
)
{
while
(
curr
!=
NULL
)
{
if
(
curr
->
my_pid
==
pid
)
{
if
(
curr
->
my_pid
==
pid
)
return
curr
;
return
curr
;
}
curr
=
curr
->
next
;
curr
=
curr
->
next
;
}
}
...
@@ -242,9 +238,8 @@ void agp_insert_file_private(agp_file_private * priv)
...
@@ -242,9 +238,8 @@ void agp_insert_file_private(agp_file_private * priv)
prev
=
agp_fe
.
file_priv_list
;
prev
=
agp_fe
.
file_priv_list
;
if
(
prev
!=
NULL
)
{
if
(
prev
!=
NULL
)
prev
->
prev
=
priv
;
prev
->
prev
=
priv
;
}
priv
->
next
=
prev
;
priv
->
next
=
prev
;
agp_fe
.
file_priv_list
=
priv
;
agp_fe
.
file_priv_list
=
priv
;
}
}
...
@@ -260,13 +255,13 @@ void agp_remove_file_private(agp_file_private * priv)
...
@@ -260,13 +255,13 @@ void agp_remove_file_private(agp_file_private * priv)
if
(
prev
!=
NULL
)
{
if
(
prev
!=
NULL
)
{
prev
->
next
=
next
;
prev
->
next
=
next
;
if
(
next
!=
NULL
)
{
if
(
next
!=
NULL
)
next
->
prev
=
prev
;
next
->
prev
=
prev
;
}
}
else
{
}
else
{
if
(
next
!=
NULL
)
{
if
(
next
!=
NULL
)
next
->
prev
=
NULL
;
next
->
prev
=
NULL
;
}
agp_fe
.
file_priv_list
=
next
;
agp_fe
.
file_priv_list
=
next
;
}
}
}
}
...
@@ -289,9 +284,9 @@ static agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type)
...
@@ -289,9 +284,9 @@ static agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type)
memory
=
agp_allocate_memory
(
pg_count
,
type
);
memory
=
agp_allocate_memory
(
pg_count
,
type
);
printk
(
KERN_DEBUG
"agp_allocate_memory: %p
\n
"
,
memory
);
printk
(
KERN_DEBUG
"agp_allocate_memory: %p
\n
"
,
memory
);
if
(
memory
==
NULL
)
{
if
(
memory
==
NULL
)
return
NULL
;
return
NULL
;
}
agp_insert_into_pool
(
memory
);
agp_insert_into_pool
(
memory
);
return
memory
;
return
memory
;
}
}
...
@@ -308,9 +303,8 @@ static agp_controller *agp_find_controller_by_pid(pid_t id)
...
@@ -308,9 +303,8 @@ static agp_controller *agp_find_controller_by_pid(pid_t id)
controller
=
agp_fe
.
controllers
;
controller
=
agp_fe
.
controllers
;
while
(
controller
!=
NULL
)
{
while
(
controller
!=
NULL
)
{
if
(
controller
->
pid
==
id
)
{
if
(
controller
->
pid
==
id
)
return
controller
;
return
controller
;
}
controller
=
controller
->
next
;
controller
=
controller
->
next
;
}
}
...
@@ -323,9 +317,9 @@ static agp_controller *agp_create_controller(pid_t id)
...
@@ -323,9 +317,9 @@ static agp_controller *agp_create_controller(pid_t id)
controller
=
kmalloc
(
sizeof
(
agp_controller
),
GFP_KERNEL
);
controller
=
kmalloc
(
sizeof
(
agp_controller
),
GFP_KERNEL
);
if
(
controller
==
NULL
)
{
if
(
controller
==
NULL
)
return
NULL
;
return
NULL
;
}
memset
(
controller
,
0
,
sizeof
(
agp_controller
));
memset
(
controller
,
0
,
sizeof
(
agp_controller
));
controller
->
pid
=
id
;
controller
->
pid
=
id
;
...
@@ -339,9 +333,9 @@ static int agp_insert_controller(agp_controller * controller)
...
@@ -339,9 +333,9 @@ static int agp_insert_controller(agp_controller * controller)
prev_controller
=
agp_fe
.
controllers
;
prev_controller
=
agp_fe
.
controllers
;
controller
->
next
=
prev_controller
;
controller
->
next
=
prev_controller
;
if
(
prev_controller
!=
NULL
)
{
if
(
prev_controller
!=
NULL
)
prev_controller
->
prev
=
controller
;
prev_controller
->
prev
=
controller
;
}
agp_fe
.
controllers
=
controller
;
agp_fe
.
controllers
=
controller
;
return
0
;
return
0
;
...
@@ -394,13 +388,13 @@ static int agp_remove_controller(agp_controller * controller)
...
@@ -394,13 +388,13 @@ static int agp_remove_controller(agp_controller * controller)
if
(
prev_controller
!=
NULL
)
{
if
(
prev_controller
!=
NULL
)
{
prev_controller
->
next
=
next_controller
;
prev_controller
->
next
=
next_controller
;
if
(
next_controller
!=
NULL
)
{
if
(
next_controller
!=
NULL
)
next_controller
->
prev
=
prev_controller
;
next_controller
->
prev
=
prev_controller
;
}
}
else
{
}
else
{
if
(
next_controller
!=
NULL
)
{
if
(
next_controller
!=
NULL
)
next_controller
->
prev
=
NULL
;
next_controller
->
prev
=
NULL
;
}
agp_fe
.
controllers
=
next_controller
;
agp_fe
.
controllers
=
next_controller
;
}
}
...
@@ -450,9 +444,9 @@ static void agp_controller_release_current(agp_controller * controller,
...
@@ -450,9 +444,9 @@ static void agp_controller_release_current(agp_controller * controller,
priv
=
agp_find_private
(
clients
->
pid
);
priv
=
agp_find_private
(
clients
->
pid
);
if
(
priv
!=
NULL
)
{
if
(
priv
!=
NULL
)
clear_bit
(
AGP_FF_IS_VALID
,
&
priv
->
access_flags
);
clear_bit
(
AGP_FF_IS_VALID
,
&
priv
->
access_flags
);
}
clients
=
clients
->
next
;
clients
=
clients
->
next
;
}
}
...
@@ -471,15 +465,14 @@ static agp_client *agp_find_client_in_controller(agp_controller * controller,
...
@@ -471,15 +465,14 @@ static agp_client *agp_find_client_in_controller(agp_controller * controller,
{
{
agp_client
*
client
;
agp_client
*
client
;
if
(
controller
==
NULL
)
{
if
(
controller
==
NULL
)
return
NULL
;
return
NULL
;
}
client
=
controller
->
clients
;
client
=
controller
->
clients
;
while
(
client
!=
NULL
)
{
while
(
client
!=
NULL
)
{
if
(
client
->
pid
==
id
)
{
if
(
client
->
pid
==
id
)
return
client
;
return
client
;
}
client
=
client
->
next
;
client
=
client
->
next
;
}
}
...
@@ -493,9 +486,8 @@ static agp_controller *agp_find_controller_for_client(pid_t id)
...
@@ -493,9 +486,8 @@ static agp_controller *agp_find_controller_for_client(pid_t id)
controller
=
agp_fe
.
controllers
;
controller
=
agp_fe
.
controllers
;
while
(
controller
!=
NULL
)
{
while
(
controller
!=
NULL
)
{
if
((
agp_find_client_in_controller
(
controller
,
id
))
!=
NULL
)
{
if
((
agp_find_client_in_controller
(
controller
,
id
))
!=
NULL
)
return
controller
;
return
controller
;
}
controller
=
controller
->
next
;
controller
=
controller
->
next
;
}
}
...
@@ -506,9 +498,9 @@ static agp_client *agp_find_client_by_pid(pid_t id)
...
@@ -506,9 +498,9 @@ static agp_client *agp_find_client_by_pid(pid_t id)
{
{
agp_client
*
temp
;
agp_client
*
temp
;
if
(
agp_fe
.
current_controller
==
NULL
)
{
if
(
agp_fe
.
current_controller
==
NULL
)
return
NULL
;
return
NULL
;
}
temp
=
agp_find_client_in_controller
(
agp_fe
.
current_controller
,
id
);
temp
=
agp_find_client_in_controller
(
agp_fe
.
current_controller
,
id
);
return
temp
;
return
temp
;
}
}
...
@@ -520,9 +512,9 @@ static void agp_insert_client(agp_client * client)
...
@@ -520,9 +512,9 @@ static void agp_insert_client(agp_client * client)
prev_client
=
agp_fe
.
current_controller
->
clients
;
prev_client
=
agp_fe
.
current_controller
->
clients
;
client
->
next
=
prev_client
;
client
->
next
=
prev_client
;
if
(
prev_client
!=
NULL
)
{
if
(
prev_client
!=
NULL
)
prev_client
->
prev
=
client
;
prev_client
->
prev
=
client
;
}
agp_fe
.
current_controller
->
clients
=
client
;
agp_fe
.
current_controller
->
clients
=
client
;
agp_fe
.
current_controller
->
num_clients
++
;
agp_fe
.
current_controller
->
num_clients
++
;
}
}
...
@@ -533,9 +525,9 @@ static agp_client *agp_create_client(pid_t id)
...
@@ -533,9 +525,9 @@ static agp_client *agp_create_client(pid_t id)
new_client
=
kmalloc
(
sizeof
(
agp_client
),
GFP_KERNEL
);
new_client
=
kmalloc
(
sizeof
(
agp_client
),
GFP_KERNEL
);
if
(
new_client
==
NULL
)
{
if
(
new_client
==
NULL
)
return
NULL
;
return
NULL
;
}
memset
(
new_client
,
0
,
sizeof
(
agp_client
));
memset
(
new_client
,
0
,
sizeof
(
agp_client
));
new_client
->
pid
=
id
;
new_client
->
pid
=
id
;
agp_insert_client
(
new_client
);
agp_insert_client
(
new_client
);
...
@@ -550,27 +542,24 @@ static int agp_remove_client(pid_t id)
...
@@ -550,27 +542,24 @@ static int agp_remove_client(pid_t id)
agp_controller
*
controller
;
agp_controller
*
controller
;
controller
=
agp_find_controller_for_client
(
id
);
controller
=
agp_find_controller_for_client
(
id
);
if
(
controller
==
NULL
)
if
(
controller
==
NULL
)
{
return
-
EINVAL
;
return
-
EINVAL
;
}
client
=
agp_find_client_in_controller
(
controller
,
id
);
if
(
client
==
NULL
)
{
client
=
agp_find_client_in_controller
(
controller
,
id
);
if
(
client
==
NULL
)
return
-
EINVAL
;
return
-
EINVAL
;
}
prev_client
=
client
->
prev
;
prev_client
=
client
->
prev
;
next_client
=
client
->
next
;
next_client
=
client
->
next
;
if
(
prev_client
!=
NULL
)
{
if
(
prev_client
!=
NULL
)
{
prev_client
->
next
=
next_client
;
prev_client
->
next
=
next_client
;
if
(
next_client
!=
NULL
)
{
if
(
next_client
!=
NULL
)
next_client
->
prev
=
prev_client
;
next_client
->
prev
=
prev_client
;
}
}
else
{
}
else
{
if
(
next_client
!=
NULL
)
{
if
(
next_client
!=
NULL
)
next_client
->
prev
=
NULL
;
next_client
->
prev
=
NULL
;
}
controller
->
clients
=
next_client
;
controller
->
clients
=
next_client
;
}
}
...
@@ -595,14 +584,12 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma)
...
@@ -595,14 +584,12 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma)
AGP_LOCK
();
AGP_LOCK
();
if
(
agp_fe
.
backend_acquired
!=
TRUE
)
{
if
(
agp_fe
.
backend_acquired
!=
TRUE
)
AGP_UNLOCK
();
goto
out_eperm
;
return
-
EPERM
;
}
if
(
!
(
test_bit
(
AGP_FF_IS_VALID
,
&
priv
->
access_flags
)))
if
(
!
(
test_bit
(
AGP_FF_IS_VALID
,
&
priv
->
access_flags
)))
{
goto
out_eperm
;
AGP_UNLOCK
();
return
-
EPERM
;
}
agp_copy_info
(
&
kerninfo
);
agp_copy_info
(
&
kerninfo
);
size
=
vma
->
vm_end
-
vma
->
vm_start
;
size
=
vma
->
vm_end
-
vma
->
vm_start
;
current_size
=
kerninfo
.
aper_size
;
current_size
=
kerninfo
.
aper_size
;
...
@@ -610,45 +597,48 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma)
...
@@ -610,45 +597,48 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma)
offset
=
vma
->
vm_pgoff
<<
PAGE_SHIFT
;
offset
=
vma
->
vm_pgoff
<<
PAGE_SHIFT
;
if
(
test_bit
(
AGP_FF_IS_CLIENT
,
&
priv
->
access_flags
))
{
if
(
test_bit
(
AGP_FF_IS_CLIENT
,
&
priv
->
access_flags
))
{
if
((
size
+
offset
)
>
current_size
)
{
if
((
size
+
offset
)
>
current_size
)
AGP_UNLOCK
();
goto
out_inval
;
return
-
EINVAL
;
}
client
=
agp_find_client_by_pid
(
current
->
pid
);
client
=
agp_find_client_by_pid
(
current
->
pid
);
if
(
client
==
NULL
)
{
if
(
client
==
NULL
)
AGP_UNLOCK
();
goto
out_eperm
;
return
-
EPERM
;
}
if
(
!
agp_find_seg_in_client
(
client
,
offset
,
size
,
vma
->
vm_page_prot
))
if
(
!
agp_find_seg_in_client
(
client
,
offset
,
goto
out_inval
;
size
,
vma
->
vm_page_prot
))
{
AGP_UNLOCK
();
if
(
remap_page_range
(
vma
,
vma
->
vm_start
,
(
kerninfo
.
aper_base
+
offset
),
return
-
EINVAL
;
}
if
(
remap_page_range
(
vma
,
vma
->
vm_start
,
(
kerninfo
.
aper_base
+
offset
),
size
,
vma
->
vm_page_prot
))
{
size
,
vma
->
vm_page_prot
))
{
AGP_UNLOCK
();
goto
out_again
;
return
-
EAGAIN
;
}
}
AGP_UNLOCK
();
AGP_UNLOCK
();
return
0
;
return
0
;
}
}
if
(
test_bit
(
AGP_FF_IS_CONTROLLER
,
&
priv
->
access_flags
))
{
if
(
test_bit
(
AGP_FF_IS_CONTROLLER
,
&
priv
->
access_flags
))
{
if
(
size
!=
current_size
)
{
if
(
size
!=
current_size
)
AGP_UNLOCK
();
goto
out_inval
;
return
-
EINVAL
;
}
if
(
remap_page_range
(
vma
,
vma
->
vm_start
,
kerninfo
.
aper_base
,
if
(
remap_page_range
(
vma
,
vma
->
vm_start
,
kerninfo
.
aper_base
,
size
,
vma
->
vm_page_prot
))
{
size
,
vma
->
vm_page_prot
))
{
AGP_UNLOCK
();
goto
out_again
;
return
-
EAGAIN
;
}
}
AGP_UNLOCK
();
AGP_UNLOCK
();
return
0
;
return
0
;
}
}
out_eperm:
AGP_UNLOCK
();
AGP_UNLOCK
();
return
-
EPERM
;
return
-
EPERM
;
out_inval:
AGP_UNLOCK
();
return
-
EINVAL
;
out_again:
AGP_UNLOCK
();
return
-
EAGAIN
;
}
}
static
int
agp_release
(
struct
inode
*
inode
,
struct
file
*
file
)
static
int
agp_release
(
struct
inode
*
inode
,
struct
file
*
file
)
...
@@ -751,9 +741,9 @@ static int agpioc_info_wrap(agp_file_private * priv, unsigned long arg)
...
@@ -751,9 +741,9 @@ static int agpioc_info_wrap(agp_file_private * priv, unsigned long arg)
userinfo
.
pg_total
=
userinfo
.
pg_system
=
kerninfo
.
max_memory
;
userinfo
.
pg_total
=
userinfo
.
pg_system
=
kerninfo
.
max_memory
;
userinfo
.
pg_used
=
kerninfo
.
current_memory
;
userinfo
.
pg_used
=
kerninfo
.
current_memory
;
if
(
copy_to_user
((
void
*
)
arg
,
&
userinfo
,
sizeof
(
agp_info
)))
{
if
(
copy_to_user
((
void
*
)
arg
,
&
userinfo
,
sizeof
(
agp_info
)))
return
-
EFAULT
;
return
-
EFAULT
;
}
return
0
;
return
0
;
}
}
...
@@ -818,10 +808,9 @@ static int agpioc_reserve_wrap(agp_file_private * priv, unsigned long arg)
...
@@ -818,10 +808,9 @@ static int agpioc_reserve_wrap(agp_file_private * priv, unsigned long arg)
agp_client
*
client
;
agp_client
*
client
;
agp_file_private
*
client_priv
;
agp_file_private
*
client_priv
;
if
(
copy_from_user
(
&
reserve
,
(
void
*
)
arg
,
sizeof
(
agp_region
)))
if
(
copy_from_user
(
&
reserve
,
(
void
*
)
arg
,
sizeof
(
agp_region
)))
{
return
-
EFAULT
;
return
-
EFAULT
;
}
if
((
unsigned
)
reserve
.
seg_count
>=
~
0U
/
sizeof
(
agp_segment
))
if
((
unsigned
)
reserve
.
seg_count
>=
~
0U
/
sizeof
(
agp_segment
))
return
-
EFAULT
;
return
-
EFAULT
;
...
@@ -851,9 +840,9 @@ static int agpioc_reserve_wrap(agp_file_private * priv, unsigned long arg)
...
@@ -851,9 +840,9 @@ static int agpioc_reserve_wrap(agp_file_private * priv, unsigned long arg)
segment
=
kmalloc
((
sizeof
(
agp_segment
)
*
reserve
.
seg_count
),
segment
=
kmalloc
((
sizeof
(
agp_segment
)
*
reserve
.
seg_count
),
GFP_KERNEL
);
GFP_KERNEL
);
if
(
segment
==
NULL
)
{
if
(
segment
==
NULL
)
return
-
ENOMEM
;
return
-
ENOMEM
;
}
if
(
copy_from_user
(
segment
,
(
void
*
)
reserve
.
seg_list
,
if
(
copy_from_user
(
segment
,
(
void
*
)
reserve
.
seg_list
,
sizeof
(
agp_segment
)
*
reserve
.
seg_count
))
{
sizeof
(
agp_segment
)
*
reserve
.
seg_count
))
{
kfree
(
segment
);
kfree
(
segment
);
...
@@ -897,14 +886,14 @@ static int agpioc_allocate_wrap(agp_file_private * priv, unsigned long arg)
...
@@ -897,14 +886,14 @@ static int agpioc_allocate_wrap(agp_file_private * priv, unsigned long arg)
agp_memory
*
memory
;
agp_memory
*
memory
;
agp_allocate
alloc
;
agp_allocate
alloc
;
if
(
copy_from_user
(
&
alloc
,
(
void
*
)
arg
,
sizeof
(
agp_allocate
)))
{
if
(
copy_from_user
(
&
alloc
,
(
void
*
)
arg
,
sizeof
(
agp_allocate
)))
return
-
EFAULT
;
return
-
EFAULT
;
}
memory
=
agp_allocate_memory_wrap
(
alloc
.
pg_count
,
alloc
.
type
);
memory
=
agp_allocate_memory_wrap
(
alloc
.
pg_count
,
alloc
.
type
);
if
(
memory
==
NULL
)
{
if
(
memory
==
NULL
)
return
-
ENOMEM
;
return
-
ENOMEM
;
}
alloc
.
key
=
memory
->
key
;
alloc
.
key
=
memory
->
key
;
alloc
.
physical
=
memory
->
physical
;
alloc
.
physical
=
memory
->
physical
;
...
@@ -921,9 +910,9 @@ static int agpioc_deallocate_wrap(agp_file_private * priv, unsigned long arg)
...
@@ -921,9 +910,9 @@ static int agpioc_deallocate_wrap(agp_file_private * priv, unsigned long arg)
memory
=
agp_find_mem_by_key
((
int
)
arg
);
memory
=
agp_find_mem_by_key
((
int
)
arg
);
if
(
memory
==
NULL
)
{
if
(
memory
==
NULL
)
return
-
EINVAL
;
return
-
EINVAL
;
}
agp_free_memory_wrap
(
memory
);
agp_free_memory_wrap
(
memory
);
return
0
;
return
0
;
}
}
...
@@ -933,14 +922,14 @@ static int agpioc_bind_wrap(agp_file_private * priv, unsigned long arg)
...
@@ -933,14 +922,14 @@ static int agpioc_bind_wrap(agp_file_private * priv, unsigned long arg)
agp_bind
bind_info
;
agp_bind
bind_info
;
agp_memory
*
memory
;
agp_memory
*
memory
;
if
(
copy_from_user
(
&
bind_info
,
(
void
*
)
arg
,
sizeof
(
agp_bind
)))
{
if
(
copy_from_user
(
&
bind_info
,
(
void
*
)
arg
,
sizeof
(
agp_bind
)))
return
-
EFAULT
;
return
-
EFAULT
;
}
memory
=
agp_find_mem_by_key
(
bind_info
.
key
);
memory
=
agp_find_mem_by_key
(
bind_info
.
key
);
if
(
memory
==
NULL
)
{
if
(
memory
==
NULL
)
return
-
EINVAL
;
return
-
EINVAL
;
}
return
agp_bind_memory
(
memory
,
bind_info
.
pg_start
);
return
agp_bind_memory
(
memory
,
bind_info
.
pg_start
);
}
}
...
@@ -949,14 +938,14 @@ static int agpioc_unbind_wrap(agp_file_private * priv, unsigned long arg)
...
@@ -949,14 +938,14 @@ static int agpioc_unbind_wrap(agp_file_private * priv, unsigned long arg)
agp_memory
*
memory
;
agp_memory
*
memory
;
agp_unbind
unbind
;
agp_unbind
unbind
;
if
(
copy_from_user
(
&
unbind
,
(
void
*
)
arg
,
sizeof
(
agp_unbind
)))
{
if
(
copy_from_user
(
&
unbind
,
(
void
*
)
arg
,
sizeof
(
agp_unbind
)))
return
-
EFAULT
;
return
-
EFAULT
;
}
memory
=
agp_find_mem_by_key
(
unbind
.
key
);
memory
=
agp_find_mem_by_key
(
unbind
.
key
);
if
(
memory
==
NULL
)
{
if
(
memory
==
NULL
)
return
-
EINVAL
;
return
-
EINVAL
;
}
return
agp_unbind_memory
(
memory
);
return
agp_unbind_memory
(
memory
);
}
}
...
@@ -979,8 +968,7 @@ static int agp_ioctl(struct inode *inode, struct file *file,
...
@@ -979,8 +968,7 @@ static int agp_ioctl(struct inode *inode, struct file *file,
goto
ioctl_out
;
goto
ioctl_out
;
}
}
if
(
cmd
!=
AGPIOC_ACQUIRE
)
{
if
(
cmd
!=
AGPIOC_ACQUIRE
)
{
if
(
!
(
test_bit
(
AGP_FF_IS_CONTROLLER
,
if
(
!
(
test_bit
(
AGP_FF_IS_CONTROLLER
,
&
curr_priv
->
access_flags
)))
{
&
curr_priv
->
access_flags
)))
{
ret_val
=
-
EPERM
;
ret_val
=
-
EPERM
;
goto
ioctl_out
;
goto
ioctl_out
;
}
}
...
@@ -992,59 +980,49 @@ static int agp_ioctl(struct inode *inode, struct file *file,
...
@@ -992,59 +980,49 @@ static int agp_ioctl(struct inode *inode, struct file *file,
goto
ioctl_out
;
goto
ioctl_out
;
}
}
}
}
switch
(
cmd
)
{
switch
(
cmd
)
{
case
AGPIOC_INFO
:
case
AGPIOC_INFO
:
{
ret_val
=
agpioc_info_wrap
(
curr_priv
,
arg
);
ret_val
=
agpioc_info_wrap
(
curr_priv
,
arg
);
break
;
goto
ioctl_out
;
}
case
AGPIOC_ACQUIRE
:
case
AGPIOC_ACQUIRE
:
{
ret_val
=
agpioc_acquire_wrap
(
curr_priv
,
arg
);
ret_val
=
agpioc_acquire_wrap
(
curr_priv
,
arg
);
break
;
goto
ioctl_out
;
}
case
AGPIOC_RELEASE
:
case
AGPIOC_RELEASE
:
{
ret_val
=
agpioc_release_wrap
(
curr_priv
,
arg
);
ret_val
=
agpioc_release_wrap
(
curr_priv
,
arg
);
break
;
goto
ioctl_out
;
}
case
AGPIOC_SETUP
:
case
AGPIOC_SETUP
:
{
ret_val
=
agpioc_setup_wrap
(
curr_priv
,
arg
);
ret_val
=
agpioc_setup_wrap
(
curr_priv
,
arg
);
break
;
goto
ioctl_out
;
}
case
AGPIOC_RESERVE
:
case
AGPIOC_RESERVE
:
{
ret_val
=
agpioc_reserve_wrap
(
curr_priv
,
arg
);
ret_val
=
agpioc_reserve_wrap
(
curr_priv
,
arg
);
break
;
goto
ioctl_out
;
}
case
AGPIOC_PROTECT
:
case
AGPIOC_PROTECT
:
{
ret_val
=
agpioc_protect_wrap
(
curr_priv
,
arg
);
ret_val
=
agpioc_protect_wrap
(
curr_priv
,
arg
);
break
;
goto
ioctl_out
;
}
case
AGPIOC_ALLOCATE
:
case
AGPIOC_ALLOCATE
:
{
ret_val
=
agpioc_allocate_wrap
(
curr_priv
,
arg
);
ret_val
=
agpioc_allocate_wrap
(
curr_priv
,
arg
);
break
;
goto
ioctl_out
;
}
case
AGPIOC_DEALLOCATE
:
case
AGPIOC_DEALLOCATE
:
{
ret_val
=
agpioc_deallocate_wrap
(
curr_priv
,
arg
);
ret_val
=
agpioc_deallocate_wrap
(
curr_priv
,
arg
);
break
;
goto
ioctl_out
;
}
case
AGPIOC_BIND
:
case
AGPIOC_BIND
:
{
ret_val
=
agpioc_bind_wrap
(
curr_priv
,
arg
);
ret_val
=
agpioc_bind_wrap
(
curr_priv
,
arg
);
break
;
goto
ioctl_out
;
}
case
AGPIOC_UNBIND
:
case
AGPIOC_UNBIND
:
{
ret_val
=
agpioc_unbind_wrap
(
curr_priv
,
arg
);
ret_val
=
agpioc_unbind_wrap
(
curr_priv
,
arg
);
break
;
goto
ioctl_out
;
}
}
}
ioctl_out:
ioctl_out:
AGP_UNLOCK
();
AGP_UNLOCK
();
return
ret_val
;
return
ret_val
;
...
...
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