* [PATCH] sh: P4 ioremap pass-through
@ 2008-11-25 12:57 Magnus Damm
2008-11-25 13:18 ` Paul Mundt
0 siblings, 1 reply; 2+ messages in thread
From: Magnus Damm @ 2008-11-25 12:57 UTC (permalink / raw)
To: linux-sh
From: Magnus Damm <damm@igel.co.jp>
This patch adds a pass-through case when ioremapping P4 addresses.
Addresses passed to ioremap() should be physical addresses, so the
best option is usually to convert the virtual address to a physical
address before calling ioremap. This will give you a virtual address
in P2 which matches the physical address and this works well for
most internal hardware blocks on the SuperH architecture.
However, some hardware blocks must be accessed through P4. Converting
the P4 address to a physical and then back to a P2 does not work. One
example of this is the sh7722 TMU block, it must be accessed through P4.
Without this patch P4 addresses will be mapped using PTEs which
requires the page allocator to be up and running.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
---
arch/sh/include/asm/addrspace.h | 11 +++++++++++
arch/sh/include/asm/io.h | 4 ++++
arch/sh/mm/fault_32.c | 11 -----------
arch/sh/mm/ioremap_32.c | 3 ++-
4 files changed, 17 insertions(+), 12 deletions(-)
--- 0001/arch/sh/include/asm/addrspace.h
+++ work/arch/sh/include/asm/addrspace.h 2008-11-25 19:55:39.000000000 +0900
@@ -49,5 +49,16 @@
/* Check if an address can be reached in 29 bits */
#define IS_29BIT(a) (((unsigned long)(a)) < 0x20000000)
+#ifdef CONFIG_SH_STORE_QUEUES
+/*
+ * This is a special case for the SH-4 store queues, as pages for this
+ * space still need to be faulted in before it's possible to flush the
+ * store queue cache for writeout to the remapped region.
+ */
+#define P3_ADDR_MAX (P4SEG_STORE_QUE + 0x04000000)
+#else
+#define P3_ADDR_MAX P4SEG
+#endif
+
#endif /* __KERNEL__ */
#endif /* __ASM_SH_ADDRSPACE_H */
--- 0001/arch/sh/include/asm/io.h
+++ work/arch/sh/include/asm/io.h 2008-11-25 19:55:39.000000000 +0900
@@ -260,6 +260,10 @@ __ioremap_mode(unsigned long offset, uns
return (void __iomem *)P2SEGADDR(offset);
}
+
+ /* P4 above the store queues are always mapped. */
+ if (unlikely(offset >= P3_ADDR_MAX))
+ return (void __iomem *)P4SEGADDR(offset);
#endif
return __ioremap(offset, size, flags);
--- 0001/arch/sh/mm/fault_32.c
+++ work/arch/sh/mm/fault_32.c 2008-11-25 19:55:39.000000000 +0900
@@ -265,17 +265,6 @@ static inline int notify_page_fault(stru
return ret;
}
-#ifdef CONFIG_SH_STORE_QUEUES
-/*
- * This is a special case for the SH-4 store queues, as pages for this
- * space still need to be faulted in before it's possible to flush the
- * store queue cache for writeout to the remapped region.
- */
-#define P3_ADDR_MAX (P4SEG_STORE_QUE + 0x04000000)
-#else
-#define P3_ADDR_MAX P4SEG
-#endif
-
/*
* Called with interrupts disabled.
*/
--- 0001/arch/sh/mm/ioremap_32.c
+++ work/arch/sh/mm/ioremap_32.c 2008-11-25 19:56:06.000000000 +0900
@@ -116,9 +116,10 @@ EXPORT_SYMBOL(__ioremap);
void __iounmap(void __iomem *addr)
{
unsigned long vaddr = (unsigned long __force)addr;
+ unsigned long seg = PXSEG(vaddr);
struct vm_struct *p;
- if (PXSEG(vaddr) < P3SEG || is_pci_memaddr(vaddr))
+ if (seg < P3SEG || seg >= P3_ADDR_MAX || is_pci_memaddr(vaddr))
return;
#ifdef CONFIG_32BIT
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] sh: P4 ioremap pass-through
2008-11-25 12:57 [PATCH] sh: P4 ioremap pass-through Magnus Damm
@ 2008-11-25 13:18 ` Paul Mundt
0 siblings, 0 replies; 2+ messages in thread
From: Paul Mundt @ 2008-11-25 13:18 UTC (permalink / raw)
To: linux-sh
On Tue, Nov 25, 2008 at 09:57:29PM +0900, Magnus Damm wrote:
> From: Magnus Damm <damm@igel.co.jp>
>
> This patch adds a pass-through case when ioremapping P4 addresses.
>
> Addresses passed to ioremap() should be physical addresses, so the
> best option is usually to convert the virtual address to a physical
> address before calling ioremap. This will give you a virtual address
> in P2 which matches the physical address and this works well for
> most internal hardware blocks on the SuperH architecture.
>
> However, some hardware blocks must be accessed through P4. Converting
> the P4 address to a physical and then back to a P2 does not work. One
> example of this is the sh7722 TMU block, it must be accessed through P4.
>
> Without this patch P4 addresses will be mapped using PTEs which
> requires the page allocator to be up and running.
>
> Signed-off-by: Magnus Damm <damm@igel.co.jp>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-11-25 13:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-25 12:57 [PATCH] sh: P4 ioremap pass-through Magnus Damm
2008-11-25 13:18 ` Paul Mundt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox