lib: utils/serial: Ensure proper allocation of PMP entries for uart8250
authorYu Chien Peter Lin <peterlin@andestech.com>
Mon, 25 Sep 2023 12:24:26 +0000 (20:24 +0800)
committerAnup Patel <anup@brainfault.org>
Fri, 6 Oct 2023 11:23:25 +0000 (16:53 +0530)
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")

Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
lib/utils/serial/uart8250.c

index 4d158d3b8391d6527749ad224cdeef2b5a005f5a..1fe053f860e56e7a447259dadb649734ff5016b0 100644 (file)
@@ -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));
 }