Skip to contentSkip to conversation

lib: utils/serial: Ensure proper allocation of PMP entries for uart8250

PATCH New Yu Chien Peter Lin 2 participants 2 messages Sep 25, 2023 – Oct 6, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: utils/serial: Ensure proper allocation of PMP entries for uart8250

The added memory region should start from the base address. Otherwise, the range will be shifted by reg_offset and not able to merge consecutive NAPOT regions in the root domain, resulting in wasted PMP entries.

Fixes e8bc1621 ("lib: utils/serial: Add shared regions for

serial drivers")

---
 lib/utils/serial/uart8250.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
lib/utils/serial/uart8250.c +1 -2
index 4d158d3..1fe053f 100644
@@ -135,8 +135,7 @@ int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift,
 
 	sbi_console_set_device(&uart8250_console);
 
-	return sbi_domain_root_add_memrange(base + reg_offset, PAGE_SIZE,
-					    PAGE_SIZE,
+	return sbi_domain_root_add_memrange(base, PAGE_SIZE, PAGE_SIZE,
 					    (SBI_DOMAIN_MEMREGION_MMIO |
 					    SBI_DOMAIN_MEMREGION_SHARED_SURW_MRW));
 }
Signature · 1 line
2.34.1
Applied
#1 lore raw

PATCH 1/1 lib: utils/serial: Ensure proper allocation of PMP entries for uart8250

Quoted 10 lines · On Mon, Sep 25, 2023 at 5:56?PM Yu Chien Peter Lin <[email protected]>…

The added memory region should start from the base address. Otherwise, the range will be shifted by reg_offset and not able to merge consecutive NAPOT regions in the root domain, resulting in wasted PMP entries.

Fixes e8bc1621 ("lib: utils/serial: Add shared regions for

serial drivers")

Looks good to me.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 26 lines
---
 lib/utils/serial/uart8250.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
lib/utils/serial/uart8250.c +1 -3
index 4d158d3..1fe053f 100644
@@ -135,8 +135,7 @@ int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift,
 
        sbi_console_set_device(&uart8250_console);
 
-       return sbi_domain_root_add_memrange(base + reg_offset, PAGE_SIZE,
-                                           PAGE_SIZE,
+       return sbi_domain_root_add_memrange(base, PAGE_SIZE, PAGE_SIZE,
                                            (SBI_DOMAIN_MEMREGION_MMIO |
                                            SBI_DOMAIN_MEMREGION_SHARED_SURW_MRW));
 }
--

2.34.1

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi