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
Kirill Smelkov
linux
Commits
9ae27c57
Commit
9ae27c57
authored
Jun 04, 2003
by
Russell King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ARM] Move dma_alloc_coherent() to consistent.c
parent
c0f1e790
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
18 deletions
+31
-18
arch/arm/mm/consistent.c
arch/arm/mm/consistent.c
+27
-8
include/asm-arm/dma-mapping.h
include/asm-arm/dma-mapping.h
+4
-10
No files found.
arch/arm/mm/consistent.c
View file @
9ae27c57
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
* DMA uncached mapping support.
* DMA uncached mapping support.
*/
*/
#include <linux/config.h>
#include <linux/config.h>
#include <linux/
types
.h>
#include <linux/
module
.h>
#include <linux/mm.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/string.h>
...
@@ -145,6 +145,7 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle,
...
@@ -145,6 +145,7 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle,
struct
vm_region
*
c
;
struct
vm_region
*
c
;
unsigned
long
order
,
flags
;
unsigned
long
order
,
flags
;
void
*
ret
=
NULL
;
void
*
ret
=
NULL
;
int
res
;
if
(
!
consistent_pte
)
{
if
(
!
consistent_pte
)
{
printk
(
KERN_ERR
"consistent_alloc: not initialised
\n
"
);
printk
(
KERN_ERR
"consistent_alloc: not initialised
\n
"
);
...
@@ -177,14 +178,19 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle,
...
@@ -177,14 +178,19 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle,
if
(
!
c
)
if
(
!
c
)
goto
no_remap
;
goto
no_remap
;
spin_lock_irqsave
(
&
consistent_lock
,
flags
);
vm_region_dump
(
&
consistent_head
,
"before alloc"
);
/*
/*
* Attempt to allocate a virtual address in the
* Attempt to allocate a virtual address in the
* consistent mapping region.
* consistent mapping region.
*/
*/
if
(
!
vm_region_alloc
(
&
consistent_head
,
c
,
size
))
{
spin_lock_irqsave
(
&
consistent_lock
,
flags
);
vm_region_dump
(
&
consistent_head
,
"before alloc"
);
res
=
vm_region_alloc
(
&
consistent_head
,
c
,
size
);
vm_region_dump
(
&
consistent_head
,
"after alloc"
);
spin_unlock_irqrestore
(
&
consistent_lock
,
flags
);
if
(
!
res
)
{
pte_t
*
pte
=
consistent_pte
+
CONSISTENT_OFFSET
(
c
->
vm_start
);
pte_t
*
pte
=
consistent_pte
+
CONSISTENT_OFFSET
(
c
->
vm_start
);
struct
page
*
end
=
page
+
(
1
<<
order
);
struct
page
*
end
=
page
+
(
1
<<
order
);
pgprot_t
prot
=
__pgprot
(
L_PTE_PRESENT
|
L_PTE_YOUNG
|
pgprot_t
prot
=
__pgprot
(
L_PTE_PRESENT
|
L_PTE_YOUNG
|
...
@@ -218,9 +224,6 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle,
...
@@ -218,9 +224,6 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle,
ret
=
(
void
*
)
c
->
vm_start
;
ret
=
(
void
*
)
c
->
vm_start
;
}
}
vm_region_dump
(
&
consistent_head
,
"after alloc"
);
spin_unlock_irqrestore
(
&
consistent_lock
,
flags
);
no_remap:
no_remap:
if
(
ret
==
NULL
)
{
if
(
ret
==
NULL
)
{
kfree
(
c
);
kfree
(
c
);
...
@@ -230,6 +233,22 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle,
...
@@ -230,6 +233,22 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle,
return
ret
;
return
ret
;
}
}
/*
* Since we have the DMA mask available to us here, we could try to do
* a normal allocation, and only fall back to a "DMA" allocation if the
* resulting bus address does not satisfy the dma_mask requirements.
*/
void
*
dma_alloc_coherent
(
struct
device
*
dev
,
size_t
size
,
dma_addr_t
*
handle
,
int
gfp
)
{
if
(
dev
==
NULL
||
*
dev
->
dma_mask
!=
0xffffffff
)
gfp
|=
GFP_DMA
;
return
consistent_alloc
(
gfp
,
size
,
handle
,
0
);
}
EXPORT_SYMBOL
(
dma_alloc_coherent
);
/*
/*
* free a page as defined by the above mapping.
* free a page as defined by the above mapping.
*/
*/
...
...
include/asm-arm/dma-mapping.h
View file @
9ae27c57
...
@@ -42,12 +42,12 @@ extern struct bus_type sa1111_bus_type;
...
@@ -42,12 +42,12 @@ extern struct bus_type sa1111_bus_type;
/*
/*
* Return whether the given device DMA address mask can be supported
* Return whether the given device DMA address mask can be supported
* properly. For example, if your device can only drive the low 24-bits
* properly. For example, if your device can only drive the low 24-bits
* during
PCI
bus mastering, then you would pass 0x00ffffff as the mask
* during bus mastering, then you would pass 0x00ffffff as the mask
* to this function.
* to this function.
*/
*/
static
inline
int
dma_supported
(
struct
device
*
dev
,
u64
mask
)
static
inline
int
dma_supported
(
struct
device
*
dev
,
u64
mask
)
{
{
return
1
;
return
dev
->
dma_mask
&&
*
dev
->
dma_mask
!=
0
;
}
}
static
inline
int
dma_set_mask
(
struct
device
*
dev
,
u64
dma_mask
)
static
inline
int
dma_set_mask
(
struct
device
*
dev
,
u64
dma_mask
)
...
@@ -81,14 +81,8 @@ static inline int dma_is_consistent(dma_addr_t handle)
...
@@ -81,14 +81,8 @@ static inline int dma_is_consistent(dma_addr_t handle)
* return the CPU-viewed address, and sets @handle to be the
* return the CPU-viewed address, and sets @handle to be the
* device-viewed address.
* device-viewed address.
*/
*/
static
inline
void
*
extern
void
*
dma_alloc_coherent
(
struct
device
*
dev
,
size_t
size
,
dma_addr_t
*
handle
,
int
gfp
)
dma_alloc_coherent
(
struct
device
*
dev
,
size_t
size
,
dma_addr_t
*
handle
,
int
gfp
);
{
if
(
dev
==
NULL
||
dmadev_is_sa1111
(
dev
)
||
*
dev
->
dma_mask
!=
0xffffffff
)
gfp
|=
GFP_DMA
;
return
consistent_alloc
(
gfp
,
size
,
handle
,
0
);
}
/**
/**
* dma_free_coherent - free memory allocated by dma_alloc_coherent
* dma_free_coherent - free memory allocated by dma_alloc_coherent
...
...
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