part_get_info() calls find_valid_gpt() -> alloc_read_gpt_entries(),
which re-reads the entire GPT partition entry array from disk on
every call once per partition while looking up each partition
during boot.

This happens because blkcache_fill() skips caching reads larger than
max_blocks_per_entry (default: 8 blocks/4KiB), and the GPT entry
array is bigger than that, so it never gets cached and every call
triggers a fresh eMMC read.

Raise the per-entry block-cache limit to cover the full GPT table
(computed from CONFIG_EFI_PARTITION_ENTRIES_NUMBERS) so it is cached
after the first read, turning subsequent GPT entry reads into cache
hits and avoiding redundant eMMC accesses.

Improves boot time by ~800ms on eMMC based devices.

Signed-off-by: Aswin Murugan <[email protected]>
---
 arch/arm/mach-snapdragon/board.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c
index 80bf510d31f..223137b1198 100644
--- a/arch/arm/mach-snapdragon/board.c
+++ b/arch/arm/mach-snapdragon/board.c
@@ -11,16 +11,19 @@
 #define pr_fmt(fmt) "QCOM: " fmt
 
 #include <asm/psci.h>
+#include <blk.h>
 #include <dm/ofnode.h>
 #include <env.h>
 #include <fdt_support.h>
 #include <init.h>
 #include <linux/arm-smccc.h>
 #include <linux/errno.h>
+#include <linux/kernel.h>
 #include <linux/psci.h>
 #include <linux/sizes.h>
 #include <lmb.h>
 #include <malloc.h>
+#include <part.h>
 #include <soc/qcom/smem.h>
 #include <sort.h>
 #include <time.h>
@@ -30,6 +33,12 @@
 enum qcom_boot_source qcom_boot_source __section(".data") = 0;
 enum qcom_memmap_source qcom_memmap_source __section(".data") = 0;
 
+/* Number of 512-byte blocks needed to hold the full GPT entry array (entries 
* entry size) */
+#define GPT_PTE_SECTOR_SIZE    512
+#define GPT_PTE_BLOCKS \
+       DIV_ROUND_UP(CONFIG_EFI_PARTITION_ENTRIES_NUMBERS * GPT_ENTRY_SIZE, \
+                    GPT_PTE_SECTOR_SIZE)
+
 #if CONFIG_IS_ENABLED(SYSRESET_PSCI)
 static void show_psci_version(void)
 {
@@ -153,6 +162,15 @@ int board_init(void)
 {
 #if CONFIG_IS_ENABLED(SYSRESET_PSCI)
        show_psci_version();
+#endif
+       /*
+        * Default cache only covers 8 blocks, too small for the GPT
+        * partition-entry array, so it's never cached and gets re-read
+        * and CRC-checked on every part_get_info() call. Raise the limit
+        * to cache it after the first read.
+        */
+#if CONFIG_IS_ENABLED(BLOCK_CACHE)
+       blkcache_configure(GPT_PTE_BLOCKS, 32);
 #endif
        qcom_board_init();
        return 0;
-- 
2.34.1

Reply via email to