The actual architecture of the EFI part parser means the entire GPT partition table needs to be parsed for each part_info() callback.
Since the default part scan code will always scan up to 128 partitions for a block, and devices with an UFS chip with up to 8 LUNs are very common in the field, this means a complete GPT parsing and validation will be done up to 1024 times instead of 8 on such devices. The GPT parsing can be cached between each part_info() call speed up to 3x on the worse condition when the CPU i-cache and d-cache are disabled, like in the SPL. The new part API implementation does caching each time a correct GPT has been parsed and verified and will match the blk_desc and LBA to serve the cached data or force a re-parsing. In order to allow GPT manipulation, the new API is only called when scanning the partitions for a disk, all the calls will be called uncached. On the SM8650 QRD platform with a KIOXIA THGJFJT1E45BATPC configured with 8 LUNs, the scsi scan takes 0.2s with both CPU caches enabled, but when disabling both CPU caches it goes up to 4s to do the full scan of all 8 LUN partitions. With this change the scan takes only 0.18s with both CPU caches enabled running 1.1x times faster, and with both CPU caches disabled the full scan takes only 1.27s running 3x faster. While 20ms could look negligeable, it's still a 20ms gain in the boot flow and a non negligeable reduction in calculation and memory allocation since for each scan it would allocate and free the gpt_pte table up to 1024 times, now it would only do 8 allocations, reducing memory fragmentation. Signed-off-by: Neil Armstrong <neil.armstr...@linaro.org> --- Changes in v2: - add part_info_get_cached API - only use cache when called from part_info_get_cached - Link to v1: https://lore.kernel.org/all/20250327-u-boot-efi-part-cache-v1-1-be6b69c06...@linaro.org --- Neil Armstrong (3): part: add part_get_info_cached() API part: efi: add GPT PTE cache used with part_get_info_cached() API block: use part_get_info_cached() API when scanning partitions disk/part.c | 55 +++++++++++++++++----- disk/part_efi.c | 114 ++++++++++++++++++++++++++++++++++++++------- drivers/block/blk-uclass.c | 7 ++- include/part.h | 44 +++++++++++++++++ 4 files changed, 189 insertions(+), 31 deletions(-) --- base-commit: 5ca70325b64f760bf4190f206a0e88dda495e3d2 change-id: 20250408-topic-gpt-cache-11f770f42f1e Best regards, -- Neil Armstrong <neil.armstr...@linaro.org>