public inbox for linux-riscv@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH RESEND v1] riscv: mm: call best_map_size many times during linear-mapping
@ 2022-11-28  2:36 panqinglin2020
  2022-12-09 21:54 ` Palmer Dabbelt
  2022-12-09 22:00 ` patchwork-bot+linux-riscv
  0 siblings, 2 replies; 3+ messages in thread
From: panqinglin2020 @ 2022-11-28  2:36 UTC (permalink / raw)
  To: palmer, linux-riscv; +Cc: Qinglin Pan, Andrew Jones, Alexandre Ghiti

From: Qinglin Pan <panqinglin2020@iscas.ac.cn>

Modify the best_map_size function to give map_size many times instead
of only once, so a memory region can be mapped by both PMD_SIZE and
PAGE_SIZE.

Signed-off-by: Qinglin Pan <panqinglin2020@iscas.ac.cn>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com>

---
 arch/riscv/mm/init.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index b56a0a75533f..1b76d3fe4e26 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -673,10 +673,11 @@ void __init create_pgd_mapping(pgd_t *pgdp,
 static uintptr_t __init best_map_size(phys_addr_t base, phys_addr_t size)
 {
 	/* Upgrade to PMD_SIZE mappings whenever possible */
-	if ((base & (PMD_SIZE - 1)) || (size & (PMD_SIZE - 1)))
-		return PAGE_SIZE;
+	base &= PMD_SIZE - 1;
+	if (!base && size >= PMD_SIZE)
+		return PMD_SIZE;
 
-	return PMD_SIZE;
+	return PAGE_SIZE;
 }
 
 #ifdef CONFIG_XIP_KERNEL
@@ -1111,9 +1112,9 @@ static void __init setup_vm_final(void)
 		if (end >= __pa(PAGE_OFFSET) + memory_limit)
 			end = __pa(PAGE_OFFSET) + memory_limit;
 
-		map_size = best_map_size(start, end - start);
 		for (pa = start; pa < end; pa += map_size) {
 			va = (uintptr_t)__va(pa);
+			map_size = best_map_size(pa, end - pa);
 
 			create_pgd_mapping(swapper_pg_dir, va, pa, map_size,
 					   pgprot_from_va(va));
-- 
2.35.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH RESEND v1] riscv: mm: call best_map_size many times during linear-mapping
  2022-11-28  2:36 [PATCH RESEND v1] riscv: mm: call best_map_size many times during linear-mapping panqinglin2020
@ 2022-12-09 21:54 ` Palmer Dabbelt
  2022-12-09 22:00 ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 3+ messages in thread
From: Palmer Dabbelt @ 2022-12-09 21:54 UTC (permalink / raw)
  To: panqinglin2020, linux-riscv, Palmer Dabbelt; +Cc: Alexandre Ghiti, Andrew Jones

On Mon, 28 Nov 2022 10:36:43 +0800, panqinglin2020@iscas.ac.cn wrote:
> From: Qinglin Pan <panqinglin2020@iscas.ac.cn>
> 
> Modify the best_map_size function to give map_size many times instead
> of only once, so a memory region can be mapped by both PMD_SIZE and
> PAGE_SIZE.
> 
> 
> [...]

Applied, thanks!

[1/1] riscv: mm: call best_map_size many times during linear-mapping
      https://git.kernel.org/palmer/c/6ff8ca3f93d3

Best regards,
-- 
Palmer Dabbelt <palmer@rivosinc.com>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH RESEND v1] riscv: mm: call best_map_size many times during linear-mapping
  2022-11-28  2:36 [PATCH RESEND v1] riscv: mm: call best_map_size many times during linear-mapping panqinglin2020
  2022-12-09 21:54 ` Palmer Dabbelt
@ 2022-12-09 22:00 ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+linux-riscv @ 2022-12-09 22:00 UTC (permalink / raw)
  To: Qinglin Pan; +Cc: linux-riscv, palmer, ajones, alexghiti

Hello:

This patch was applied to riscv/linux.git (for-next)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Mon, 28 Nov 2022 10:36:43 +0800 you wrote:
> From: Qinglin Pan <panqinglin2020@iscas.ac.cn>
> 
> Modify the best_map_size function to give map_size many times instead
> of only once, so a memory region can be mapped by both PMD_SIZE and
> PAGE_SIZE.
> 
> Signed-off-by: Qinglin Pan <panqinglin2020@iscas.ac.cn>
> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> 
> [...]

Here is the summary with links:
  - [RESEND,v1] riscv: mm: call best_map_size many times during linear-mapping
    https://git.kernel.org/riscv/c/6ff8ca3f93d3

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2022-12-09 22:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-28  2:36 [PATCH RESEND v1] riscv: mm: call best_map_size many times during linear-mapping panqinglin2020
2022-12-09 21:54 ` Palmer Dabbelt
2022-12-09 22:00 ` patchwork-bot+linux-riscv

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