public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] nios2: change virt_to_phys to use physaddr_mask in global data
@ 2015-10-27  1:09 Thomas Chou
  2015-10-27  9:16 ` Marek Vasut
  2015-11-03  5:14 ` Thomas Chou
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Chou @ 2015-10-27  1:09 UTC (permalink / raw)
  To: u-boot

As virt_to_phys() is used a lot in DMA transfer, change it
to use physaddr_mask in global data. This will save an "if"
statement and get a little faster.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 arch/nios2/cpu/cpu.c                 | 1 +
 arch/nios2/include/asm/global_data.h | 1 +
 arch/nios2/include/asm/io.h          | 5 +----
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c
index 88c4e18..f6d5cd3 100644
--- a/arch/nios2/cpu/cpu.c
+++ b/arch/nios2/cpu/cpu.c
@@ -119,6 +119,7 @@ static int altera_nios2_probe(struct udevice *dev)
 		"altr,has-mmu", 0);
 	gd->arch.io_region_base = gd->arch.has_mmu ? 0xe0000000 : 0x80000000;
 	gd->arch.mem_region_base = gd->arch.has_mmu ? 0xc0000000 : 0x00000000;
+	gd->arch.physaddr_mask = gd->arch.has_mmu ? 0x1fffffff : 0x7fffffff;
 
 	return 0;
 }
diff --git a/arch/nios2/include/asm/global_data.h b/arch/nios2/include/asm/global_data.h
index 9f3bd00..9863fd9 100644
--- a/arch/nios2/include/asm/global_data.h
+++ b/arch/nios2/include/asm/global_data.h
@@ -19,6 +19,7 @@ struct arch_global_data {
 	int has_mmu;
 	u32 io_region_base;
 	u32 mem_region_base;
+	u32 physaddr_mask;
 };
 
 #include <asm-generic/global_data.h>
diff --git a/arch/nios2/include/asm/io.h b/arch/nios2/include/asm/io.h
index 007df8d..3443408 100644
--- a/arch/nios2/include/asm/io.h
+++ b/arch/nios2/include/asm/io.h
@@ -44,10 +44,7 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
 static inline phys_addr_t virt_to_phys(void * vaddr)
 {
 	DECLARE_GLOBAL_DATA_PTR;
-	if (gd->arch.has_mmu)
-		return (phys_addr_t)vaddr & 0x1fffffff;
-	else
-		return (phys_addr_t)vaddr & 0x7fffffff;
+	return (phys_addr_t)vaddr & gd->arch.physaddr_mask;
 }
 
 static inline void *ioremap(unsigned long physaddr, unsigned long size)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] nios2: change virt_to_phys to use physaddr_mask in global data
  2015-10-27  1:09 [U-Boot] [PATCH] nios2: change virt_to_phys to use physaddr_mask in global data Thomas Chou
@ 2015-10-27  9:16 ` Marek Vasut
  2015-11-03  5:14 ` Thomas Chou
  1 sibling, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2015-10-27  9:16 UTC (permalink / raw)
  To: u-boot

On Tuesday, October 27, 2015 at 02:09:57 AM, Thomas Chou wrote:
> As virt_to_phys() is used a lot in DMA transfer, change it
> to use physaddr_mask in global data. This will save an "if"
> statement and get a little faster.
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>

Makes sense.

Acked-by: Marek Vasut <marex@denx.de>

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] nios2: change virt_to_phys to use physaddr_mask in global data
  2015-10-27  1:09 [U-Boot] [PATCH] nios2: change virt_to_phys to use physaddr_mask in global data Thomas Chou
  2015-10-27  9:16 ` Marek Vasut
@ 2015-11-03  5:14 ` Thomas Chou
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Chou @ 2015-11-03  5:14 UTC (permalink / raw)
  To: u-boot



On 2015?10?27? 09:09, Thomas Chou wrote:
> As virt_to_phys() is used a lot in DMA transfer, change it
> to use physaddr_mask in global data. This will save an "if"
> statement and get a little faster.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>   arch/nios2/cpu/cpu.c                 | 1 +
>   arch/nios2/include/asm/global_data.h | 1 +
>   arch/nios2/include/asm/io.h          | 5 +----
>   3 files changed, 3 insertions(+), 4 deletions(-)
>

Applied to u-boot-nios.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-03  5:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-27  1:09 [U-Boot] [PATCH] nios2: change virt_to_phys to use physaddr_mask in global data Thomas Chou
2015-10-27  9:16 ` Marek Vasut
2015-11-03  5:14 ` Thomas Chou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox