Support DMA mapping of all kernel "unmapped" virtual address segments
to the corresponding physical addresses for 32- and 64-bit architectures.
Signed-off-by: David VomLehn <dvomlehn@xxxxxxxxx>
---
The current virt_to_phys function does not map KSEG1 address to the correct
physical address, nor will it map most of the XKPHYS addresses correctly. This
patch addresses this problem.
Unfortunately, I don't have access to a 64-bit system, so I need to ask for
someone to perform additional verification. Any volunteers?
addrspace.h | 18 +++++++++++-------
io.h | 2 +-
2 files changed, 12 insertions(+), 8 deletions(-)
Index: linux/include/asm-mips/addrspace.h
===================================================================
--- linux.orig/include/asm-mips/addrspace.h
+++ linux/include/asm-mips/addrspace.h
@@ -75,6 +75,12 @@
#define CKSEG2ADDR(a) (CPHYSADDR(a) | CKSEG2)
#define CKSEG3ADDR(a) (CPHYSADDR(a) | CKSEG3)
+/*
+ * The ultimate limited of the 64-bit MIPS architecture: 2 bits for selecting
+ * the region, 3 bits for the CCA mode. This leaves 59 bits of which the
+ * R8000 implements most with its 48-bit physical address space.
+ */
+#define TO_PHYS_MASK _CONST64_(0x07ffffffffffffff) /* 2^59 - 1 */
#else
#define CKSEG0ADDR(a) (CPHYSADDR(a) | KSEG0)
@@ -106,6 +112,11 @@
#define CKSEG2 0xc0000000
#define CKSEG3 0xe0000000
+/*
+ * The ultimate limit of the 32-bit MIPS architecture. 3 bits for selecting
+ * the region, leaving 29 bits for the physical address spaces
+ */
+#define TO_PHYS_MASK 0x1fffffffl /* 2^29 - 1 */
#endif
/*
@@ -129,13 +140,6 @@
#define PHYS_TO_XKPHYS(cm, a) (_CONST64_(0x8000000000000000) | \
((cm)<<59) | (a))
-/*
- * The ultimate limited of the 64-bit MIPS architecture: 2 bits for selecting
- * the region, 3 bits for the CCA mode. This leaves 59 bits of which the
- * R8000 implements most with its 48-bit physical address space.
- */
-#define TO_PHYS_MASK _CONST64_(0x07ffffffffffffff) /* 2^^59 - 1 */
-
#ifndef CONFIG_CPU_R8000
/*
Index: linux/include/asm-mips/io.h
===================================================================
--- linux.orig/include/asm-mips/io.h
+++ linux/include/asm-mips/io.h
@@ -118,7 +118,7 @@ static inline void set_io_port_base(unsi
*/
static inline unsigned long virt_to_phys(volatile const void *address)
{
- return (unsigned long)address - PAGE_OFFSET + PHYS_OFFSET;
+ return (unsigned long)address & TO_PHYS_MASK;
}
/*
- - - - - Cisco - - - - -
This e-mail and any attachments may contain information which is confidential,
proprietary, privileged or otherwise protected by law. The information is solely
intended for the named addressee (or a person responsible for delivering it to
the addressee). If you are not the intended recipient of this message, you are
not authorized to read, print, retain, copy or disseminate this message or any
part of it. If you have received this e-mail in error, please notify the sender
immediately by return e-mail and delete it from your computer.