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
8a7bcf0d
Commit
8a7bcf0d
authored
Nov 11, 2007
by
Paul Mundt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sh: Add SH-5 support to the consistent DMA impl.
Signed-off-by:
Paul Mundt
<
lethal@linux-sh.org
>
parent
b613881e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
20 deletions
+30
-20
arch/sh/mm/consistent.c
arch/sh/mm/consistent.c
+28
-18
include/asm-sh/dma-mapping.h
include/asm-sh/dma-mapping.h
+2
-2
No files found.
arch/sh/mm/consistent.c
View file @
8a7bcf0d
/*
/*
* arch/sh/mm/consistent.c
* arch/sh/mm/consistent.c
*
*
* Copyright (C) 2004 Paul Mundt
* Copyright (C) 2004
- 2007
Paul Mundt
*
*
* This file is subject to the terms and conditions of the GNU General Public
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* License. See the file "COPYING" in the main directory of this archive
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
void
*
consistent_alloc
(
gfp_t
gfp
,
size_t
size
,
dma_addr_t
*
handle
)
void
*
consistent_alloc
(
gfp_t
gfp
,
size_t
size
,
dma_addr_t
*
handle
)
{
{
struct
page
*
page
,
*
end
,
*
free
;
struct
page
*
page
,
*
end
,
*
free
;
void
*
ret
;
void
*
ret
,
*
vp
;
int
order
;
int
order
;
size
=
PAGE_ALIGN
(
size
);
size
=
PAGE_ALIGN
(
size
);
...
@@ -28,13 +28,20 @@ void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *handle)
...
@@ -28,13 +28,20 @@ void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *handle)
split_page
(
page
,
order
);
split_page
(
page
,
order
);
ret
=
page_address
(
page
);
ret
=
page_address
(
page
);
memset
(
ret
,
0
,
size
);
*
handle
=
virt_to_phys
(
ret
);
*
handle
=
virt_to_phys
(
ret
);
vp
=
ioremap_nocache
(
*
handle
,
size
);
if
(
!
vp
)
{
free_pages
((
unsigned
long
)
ret
,
order
);
return
NULL
;
}
memset
(
vp
,
0
,
size
);
/*
/*
* We must flush the cache before we pass it on to the device
* We must flush the cache before we pass it on to the device
*/
*/
__flush_purge_region
(
ret
,
size
);
dma_cache_sync
(
NULL
,
ret
,
size
,
DMA_BIDIRECTIONAL
);
page
=
virt_to_page
(
ret
);
page
=
virt_to_page
(
ret
);
free
=
page
+
(
size
>>
PAGE_SHIFT
);
free
=
page
+
(
size
>>
PAGE_SHIFT
);
...
@@ -47,24 +54,31 @@ void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *handle)
...
@@ -47,24 +54,31 @@ void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *handle)
}
}
}
}
return
P2SEGADDR
(
ret
)
;
return
vp
;
}
}
EXPORT_SYMBOL
(
consistent_alloc
);
void
consistent_free
(
void
*
vaddr
,
size_t
size
)
void
consistent_free
(
void
*
vaddr
,
size_t
size
,
dma_addr_t
dma_handle
)
{
{
unsigned
long
addr
=
P1SEGADDR
((
unsigned
long
)
vaddr
);
struct
page
*
page
;
struct
page
*
page
=
virt_to_page
(
addr
);
unsigned
long
addr
;
int
num_pages
=
(
size
+
PAGE_SIZE
-
1
)
>>
PAGE_SHIFT
;
int
i
;
for
(
i
=
0
;
i
<
num_pages
;
i
++
)
{
addr
=
(
unsigned
long
)
phys_to_virt
((
unsigned
long
)
dma_handle
);
__free_page
((
page
+
i
));
page
=
virt_to_page
(
addr
);
}
free_pages
(
addr
,
get_order
(
size
));
iounmap
(
vaddr
);
}
}
EXPORT_SYMBOL
(
consistent_free
);
void
consistent_sync
(
void
*
vaddr
,
size_t
size
,
int
direction
)
void
consistent_sync
(
void
*
vaddr
,
size_t
size
,
int
direction
)
{
{
void
*
p1addr
=
(
void
*
)
P1SEGADDR
((
unsigned
long
)
vaddr
);
#ifdef CONFIG_CPU_SH5
void
*
p1addr
=
vaddr
;
#else
void
*
p1addr
=
(
void
*
)
P1SEGADDR
((
unsigned
long
)
vaddr
);
#endif
switch
(
direction
)
{
switch
(
direction
)
{
case
DMA_FROM_DEVICE
:
/* invalidate only */
case
DMA_FROM_DEVICE
:
/* invalidate only */
...
@@ -80,8 +94,4 @@ void consistent_sync(void *vaddr, size_t size, int direction)
...
@@ -80,8 +94,4 @@ void consistent_sync(void *vaddr, size_t size, int direction)
BUG
();
BUG
();
}
}
}
}
EXPORT_SYMBOL
(
consistent_alloc
);
EXPORT_SYMBOL
(
consistent_free
);
EXPORT_SYMBOL
(
consistent_sync
);
EXPORT_SYMBOL
(
consistent_sync
);
include/asm-sh/dma-mapping.h
View file @
8a7bcf0d
...
@@ -10,7 +10,7 @@ extern struct bus_type pci_bus_type;
...
@@ -10,7 +10,7 @@ extern struct bus_type pci_bus_type;
/* arch/sh/mm/consistent.c */
/* arch/sh/mm/consistent.c */
extern
void
*
consistent_alloc
(
gfp_t
gfp
,
size_t
size
,
dma_addr_t
*
handle
);
extern
void
*
consistent_alloc
(
gfp_t
gfp
,
size_t
size
,
dma_addr_t
*
handle
);
extern
void
consistent_free
(
void
*
vaddr
,
size_t
size
);
extern
void
consistent_free
(
void
*
vaddr
,
size_t
size
,
dma_addr_t
handle
);
extern
void
consistent_sync
(
void
*
vaddr
,
size_t
size
,
int
direction
);
extern
void
consistent_sync
(
void
*
vaddr
,
size_t
size
,
int
direction
);
#define dma_supported(dev, mask) (1)
#define dma_supported(dev, mask) (1)
...
@@ -50,7 +50,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,
...
@@ -50,7 +50,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,
return
;
return
;
}
}
consistent_free
(
vaddr
,
size
);
consistent_free
(
vaddr
,
size
,
dma_handle
);
}
}
#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
...
...
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