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
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 @@
...
@@ -25,10 +25,12 @@
/*
/*
* This allocates one page of cache-coherent memory space and returns
* 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
* both the virtual and a "dma" address to that space.
* 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
* We should allow this function to be called from interrupt context.
* here is not interrupt context safe.
* 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!
* 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)
...
@@ -36,8 +38,9 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle)
{
{
struct
page
*
page
,
*
end
,
*
free
;
struct
page
*
page
,
*
end
,
*
free
;
unsigned
long
order
;
unsigned
long
order
;
void
*
ret
,
*
virt
;
void
*
ret
;
/* FIXME */
if
(
in_interrupt
())
if
(
in_interrupt
())
BUG
();
BUG
();
...
@@ -48,22 +51,22 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle)
...
@@ -48,22 +51,22 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle)
if
(
!
page
)
if
(
!
page
)
goto
no_page
;
goto
no_page
;
/*
*
dma_handle
=
page_to_bus
(
page
);
* We could do with a page_to_phys and page_to_bus here.
ret
=
__ioremap
(
page_to_phys
(
page
),
size
,
0
);
*/
virt
=
page_address
(
page
);
*
dma_handle
=
virt_to_bus
(
virt
);
ret
=
__ioremap
(
virt_to_phys
(
virt
),
size
,
0
);
if
(
!
ret
)
if
(
!
ret
)
goto
no_remap
;
goto
no_remap
;
#if 0 /* ioremap_does_flush_cache_all */
#if 0 /* ioremap_does_flush_cache_all */
/*
{
* we need to ensure that there are no cachelines in use, or
void *virt = page_address(page);
* worse dirty in this area. Really, we don't need to do
* this since __ioremap does a flush_cache_all() anyway. --rmk
/*
*/
* we need to ensure that there are no cachelines in use, or
invalidate_dcache_range(virt, virt + size);
* 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
#endif
/*
/*
...
@@ -72,7 +75,6 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle)
...
@@ -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
* We also mark the pages in use as reserved so that
* remap_page_range works.
* remap_page_range works.
*/
*/
page
=
virt_to_page
(
virt
);
free
=
page
+
(
size
>>
PAGE_SHIFT
);
free
=
page
+
(
size
>>
PAGE_SHIFT
);
end
=
page
+
(
1
<<
order
);
end
=
page
+
(
1
<<
order
);
...
@@ -93,18 +95,12 @@ void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle)
...
@@ -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
*
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
)
if
((
hwdev
)
==
NULL
||
gfp
|=
GFP_DMA
;
(
hwdev
)
->
dma_mask
!=
0xffffffff
)
#endif
__gfp
|=
GFP_DMA
;
__ret
=
consistent_alloc
(
__gfp
,
(
size
),
return
consistent_alloc
(
gfp
,
size
,
handle
);
(
handle
));
return
__ret
;
}
}
/*
/*
...
@@ -114,19 +110,16 @@ void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *handl
...
@@ -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
)
void
consistent_free
(
void
*
vaddr
,
size_t
size
,
dma_addr_t
handle
)
{
{
struct
page
*
page
,
*
end
;
struct
page
*
page
,
*
end
;
void
*
virt
;
if
(
in_interrupt
())
if
(
in_interrupt
())
BUG
();
BUG
();
virt
=
bus_to_virt
(
handle
);
/*
/*
* More messing around with the MM internals. This is
* More messing around with the MM internals. This is
* sick, but then so is remap_page_range().
* sick, but then so is remap_page_range().
*/
*/
size
=
PAGE_ALIGN
(
size
);
size
=
PAGE_ALIGN
(
size
);
page
=
virt_to_page
(
virt
);
page
=
virt_to_page
(
bus_to_virt
(
handle
)
);
end
=
page
+
(
size
>>
PAGE_SHIFT
);
end
=
page
+
(
size
>>
PAGE_SHIFT
);
for
(;
page
<
end
;
page
++
)
for
(;
page
<
end
;
page
++
)
...
...
include/asm-arm/io.h
View file @
3b2c9b83
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#ifdef __KERNEL__
#ifdef __KERNEL__
#include <linux/config.h>
#include <linux/types.h>
#include <linux/types.h>
#include <asm/byteorder.h>
#include <asm/byteorder.h>
#include <asm/memory.h>
#include <asm/memory.h>
...
@@ -269,13 +270,22 @@ extern void consistent_free(void *vaddr, size_t size, dma_addr_t handle);
...
@@ -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
);
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) \
#define page_to_bus(page) (PHYS_OFFSET + ((page - mem_map) << PAGE_SHIFT
))
(virt_to_bus(page_address(page)
))
/*
/*
* can the hardware map this into one segment or not, given no other
* 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