]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
lib: sparse: allocate FASTBOOT_MAX_BLK_WRITE instead of small number
authorMattijs Korpershoek <mkorpershoek@baylibre.com>
Fri, 7 Jul 2023 08:13:34 +0000 (10:13 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 25 Jul 2023 16:44:46 +0000 (12:44 -0400)
Commit 62649165cb02 ("lib: sparse: Make CHUNK_TYPE_RAW buffer aligned")
fixed cache alignment for systems with a D-CACHE.

However it introduced some performance regressions [1] on system
flashing huge images, such as Android.

On AM62x SK EVM, we also observe such performance penalty:
Sending sparse 'super' 1/2 (768793 KB)             OKAY [ 23.954s]
Writing 'super'                                    OKAY [ 75.926s]
Sending sparse 'super' 2/2 (629819 KB)             OKAY [ 19.641s]
Writing 'super'                                    OKAY [ 62.849s]
Finished. Total time: 182.474s

The reason for this is that we use an arbitrary small buffer
(info->blksz * 100) for transferring.

Fix it by using a bigger buffer (info->blksz * FASTBOOT_MAX_BLK_WRITE)
as suggested in the original's patch review [2].

With this patch, performance impact is mitigated:
Sending sparse 'super' 1/2 (768793 KB)             OKAY [ 23.912s]
Writing 'super'                                    OKAY [ 15.780s]
Sending sparse 'super' 2/2 (629819 KB)             OKAY [ 19.581s]
Writing 'super'                                    OKAY [ 17.192s]
Finished. Total time: 76.569s

[1] https://lore.kernel.org/r/20221118121323.4009193-1-gary.bisson@boundarydevices.com
[2] https://lore.kernel.org/r/all/43e4c17c-4483-ec8e-f843-9b4c5569bd18@seco.com/

Fixes: 62649165cb02 ("lib: sparse: Make CHUNK_TYPE_RAW buffer aligned")
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
drivers/fastboot/fb_mmc.c
include/image-sparse.h
lib/image-sparse.c

index 9d25c402028a6dba18cd3c44a3e1cacf22b18a30..060918e49109424e45dc7d38b8cb4bb99cb1fc0b 100644 (file)
@@ -19,8 +19,6 @@
 #include <linux/compat.h>
 #include <android_image.h>
 
-#define FASTBOOT_MAX_BLK_WRITE 16384
-
 #define BOOT_PARTITION_NAME "boot"
 
 struct fb_mmc_sparse {
index 0572dbd0a2832cfd1473b2497f764d340dfa6eba..282a0b256498cf86eb7fec85882f24c15ed6d0dc 100644 (file)
@@ -7,6 +7,8 @@
 #include <part.h>
 #include <sparse_format.h>
 
+#define FASTBOOT_MAX_BLK_WRITE 16384
+
 #define ROUNDUP(x, y)  (((x) + ((y) - 1)) & ~((y) - 1))
 
 struct sparse_storage {
index 5ec0f94ab3eb6a27ff172b8585b46d1183b91450..8f8a67e158044d37909822252f67c4a1f716ecd1 100644 (file)
@@ -55,7 +55,8 @@ static lbaint_t write_sparse_chunk_raw(struct sparse_storage *info,
                                       void *data,
                                       char *response)
 {
-       lbaint_t n = blkcnt, write_blks, blks = 0, aligned_buf_blks = 100;
+       lbaint_t n = blkcnt, write_blks, blks = 0;
+       lbaint_t aligned_buf_blks = FASTBOOT_MAX_BLK_WRITE;
        uint32_t *aligned_buf = NULL;
 
        if (CONFIG_IS_ENABLED(SYS_DCACHE_OFF)) {