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
2ccb567a
Commit
2ccb567a
authored
Mar 29, 2004
by
Russell King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ARM] Move kmalloc() and spinlocks into vm_region_alloc()
parent
8e645822
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
30 deletions
+25
-30
arch/arm/mm/consistent.c
arch/arm/mm/consistent.c
+25
-30
No files found.
arch/arm/mm/consistent.c
View file @
2ccb567a
...
...
@@ -76,19 +76,27 @@ static struct vm_region consistent_head = {
.
vm_end
=
CONSISTENT_END
,
};
static
int
vm_region_alloc
(
struct
vm_region
*
head
,
struct
vm_region
*
new
,
size_t
size
)
static
struct
vm_region
*
vm_region_alloc
(
struct
vm_region
*
head
,
size_t
size
,
int
gfp
)
{
unsigned
long
addr
=
head
->
vm_start
,
end
=
head
->
vm_end
-
size
;
struct
vm_region
*
c
;
unsigned
long
flags
;
struct
vm_region
*
c
,
*
new
;
new
=
kmalloc
(
sizeof
(
struct
vm_region
),
gfp
);
if
(
!
new
)
goto
out
;
spin_lock_irqsave
(
&
consistent_lock
,
flags
);
list_for_each_entry
(
c
,
&
head
->
vm_list
,
vm_list
)
{
if
((
addr
+
size
)
<
addr
)
goto
out
;
goto
nospc
;
if
((
addr
+
size
)
<=
c
->
vm_start
)
goto
found
;
addr
=
c
->
vm_end
;
if
(
addr
>
end
)
goto
out
;
goto
nospc
;
}
found:
...
...
@@ -99,10 +107,14 @@ static int vm_region_alloc(struct vm_region *head, struct vm_region *new, size_t
new
->
vm_start
=
addr
;
new
->
vm_end
=
addr
+
size
;
return
0
;
spin_unlock_irqrestore
(
&
consistent_lock
,
flags
);
return
new
;
nospc:
spin_unlock_irqrestore
(
&
consistent_lock
,
flags
);
kfree
(
new
);
out:
return
-
ENOMEM
;
return
NULL
;
}
static
struct
vm_region
*
vm_region_find
(
struct
vm_region
*
head
,
unsigned
long
addr
)
...
...
@@ -154,25 +166,11 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle,
}
/*
* Our housekeeping doesn't need to come from DMA,
* but it must not come from highmem.
*/
c
=
kmalloc
(
sizeof
(
struct
vm_region
),
gfp
&
~
(
__GFP_DMA
|
__GFP_HIGHMEM
));
if
(
!
c
)
goto
no_remap
;
/*
* Attempt to allocate a virtual address in the
* consistent mapping region.
* Allocate a virtual address in the consistent mapping region.
*/
spin_lock_irqsave
(
&
consistent_lock
,
flags
);
res
=
vm_region_alloc
(
&
consistent_head
,
c
,
size
);
spin_unlock_irqrestore
(
&
consistent_lock
,
flags
);
if
(
!
res
)
{
c
=
vm_region_alloc
(
&
consistent_head
,
size
,
gfp
&
~
(
__GFP_DMA
|
__GFP_HIGHMEM
));
if
(
c
)
{
pte_t
*
pte
=
consistent_pte
+
CONSISTENT_OFFSET
(
c
->
vm_start
);
struct
page
*
end
=
page
+
(
1
<<
order
);
pgprot_t
prot
=
__pgprot
(
L_PTE_PRESENT
|
L_PTE_YOUNG
|
...
...
@@ -203,16 +201,13 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle,
page
++
;
}
ret
=
(
void
*
)
c
->
vm_start
;
ret
urn
(
void
*
)
c
->
vm_start
;
}
no_remap:
if
(
ret
==
NULL
)
{
kfree
(
c
);
if
(
page
)
__free_pages
(
page
,
order
);
}
no_page:
return
ret
;
return
NULL
;
}
EXPORT_SYMBOL
(
consistent_alloc
);
...
...
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