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
3b2c9b83
Commit
3b2c9b83
authored
Apr 07, 2002
by
Russell King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix page_to_phys() and convert virt_to_bus()/virt_to_phys() to
page_to_bus()/page_to_phys() in consistent.c
parent
84d00883
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
36 deletions
+39
-36
arch/arm/mm/consistent.c
arch/arm/mm/consistent.c
+25
-32
include/asm-arm/io.h
include/asm-arm/io.h
+14
-4
No files found.
arch/arm/mm/consistent.c
View file @
3b2c9b83
...
...
@@ -25,10 +25,12 @@
/*
* This allocates one page of cache-coherent memory space and returns
* both the virtual and a "dma" address to that space. It is not clear
* whether this could be called from an interrupt context or not. For
* now, we expressly forbid it, especially as some of the stuff we do
* here is not interrupt context safe.
* both the virtual and a "dma" address to that space.
*
* We should allow this function to be called from interrupt context.
* However, we call ioremap, which needs to fiddle around with various
* things (like the vmlist_lock, and allocating page tables). These
* things aren't interrupt safe (yet).
*
* Note that this does *not* zero the allocated area!
*/
...
...
@@ -36,8 +38,9 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle)
{
struct
page
*
page
,
*
end
,
*
free
;
unsigned
long
order
;
void
*
ret
,
*
virt
;
void
*
ret
;
/* FIXME */
if
(
in_interrupt
())
BUG
();
...
...
@@ -48,22 +51,22 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle)
if
(
!
page
)
goto
no_page
;
/*
* We could do with a page_to_phys and page_to_bus here.
*/
virt
=
page_address
(
page
);
*
dma_handle
=
virt_to_bus
(
virt
);
ret
=
__ioremap
(
virt_to_phys
(
virt
),
size
,
0
);
*
dma_handle
=
page_to_bus
(
page
);
ret
=
__ioremap
(
page_to_phys
(
page
),
size
,
0
);
if
(
!
ret
)
goto
no_remap
;
#if 0 /* ioremap_does_flush_cache_all */
/*
* we need to ensure that there are no cachelines in use, or
* worse dirty in this area. Really, we don't need to do
* this since __ioremap does a flush_cache_all() anyway. --rmk
*/
invalidate_dcache_range(virt, virt + size);
{
void *virt = page_address(page);
/*
* we need to ensure that there are no cachelines in use, or
* worse dirty in this area. Really, we don't need to do
* this since __ioremap does a flush_cache_all() anyway. --rmk
*/
invalidate_dcache_range(virt, virt + size);
}
#endif
/*
...
...
@@ -72,7 +75,6 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle)
* We also mark the pages in use as reserved so that
* remap_page_range works.
*/
page
=
virt_to_page
(
virt
);
free
=
page
+
(
size
>>
PAGE_SHIFT
);
end
=
page
+
(
1
<<
order
);
...
...
@@ -93,18 +95,12 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle)
void
*
pci_alloc_consistent
(
struct
pci_dev
*
hwdev
,
size_t
size
,
dma_addr_t
*
handle
)
{
void
*
__ret
;
int
__gfp
=
GFP_KERNEL
;
int
gfp
=
GFP_KERNEL
;
#ifdef CONFIG_PCI
if
((
hwdev
)
==
NULL
||
(
hwdev
)
->
dma_mask
!=
0xffffffff
)
#endif
__gfp
|=
GFP_DMA
;
if
(
hwdev
==
NULL
||
hwdev
->
dma_mask
!=
0xffffffff
)
gfp
|=
GFP_DMA
;
__ret
=
consistent_alloc
(
__gfp
,
(
size
),
(
handle
));
return
__ret
;
return
consistent_alloc
(
gfp
,
size
,
handle
);
}
/*
...
...
@@ -114,19 +110,16 @@ void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *handl
void
consistent_free
(
void
*
vaddr
,
size_t
size
,
dma_addr_t
handle
)
{
struct
page
*
page
,
*
end
;
void
*
virt
;
if
(
in_interrupt
())
BUG
();
virt
=
bus_to_virt
(
handle
);
/*
* More messing around with the MM internals. This is
* sick, but then so is remap_page_range().
*/
size
=
PAGE_ALIGN
(
size
);
page
=
virt_to_page
(
virt
);
page
=
virt_to_page
(
bus_to_virt
(
handle
)
);
end
=
page
+
(
size
>>
PAGE_SHIFT
);
for
(;
page
<
end
;
page
++
)
...
...
include/asm-arm/io.h
View file @
3b2c9b83
...
...
@@ -22,6 +22,7 @@
#ifdef __KERNEL__
#include <linux/config.h>
#include <linux/types.h>
#include <asm/byteorder.h>
#include <asm/memory.h>
...
...
@@ -269,13 +270,22 @@ extern void consistent_free(void *vaddr, size_t size, dma_addr_t handle);
extern
void
consistent_sync
(
void
*
vaddr
,
size_t
size
,
int
rw
);
/*
*
FIXME: I'm sure these will need to be changed for DISCONTIG
*
Change "struct page" to physical address.
*/
#ifdef CONFIG_DISCONTIG
#define page_to_phys(page) \
((((page) - page_zone(page)->zone_mem_map) << PAGE_SHIFT) \
+ page_zone(page)->zone_start_paddr)
#else
#define page_to_phys(page) \
(PHYS_OFFSET + (((page) - mem_map) << PAGE_SHIFT))
#endif
/*
*
Change "struct page" to physical address
.
*
We should really eliminate virt_to_bus() here - it's depreciated
.
*/
#define page_to_
phys(page) (PHYS_OFFSET + ((page - mem_map) << PAGE_SHIFT))
#define page_to_bus(page) (PHYS_OFFSET + ((page - mem_map) << PAGE_SHIFT
))
#define page_to_
bus(page) \
(virt_to_bus(page_address(page)
))
/*
* can the hardware map this into one segment or not, given no other
...
...
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