diff mbox series

[v6,25/25] spl: fat: Add option to disable DMA alignment

Message ID 20231106022603.3405551-26-seanga2@gmail.com
State Superseded
Delegated to: Tom Rini
Headers show
Series spl: Use common function for loading/parsing images | expand

Commit Message

Sean Anderson Nov. 6, 2023, 2:26 a.m. UTC
If we don't DMA-align buffers we pass to FAT, it will align them itself.
This behaviour likely should be deprecated in favor of
CONFIG_BOUNCE_BUFFER, but that's a task for another series. For the
meantime, don't bother aligning the buffer unless we had been doing so in
the past.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

Changes in v6:
- New

 common/spl/Kconfig      | 18 ++++++++++++++++--
 common/spl/spl_blk_fs.c |  5 ++++-
 common/spl/spl_fat.c    |  5 ++++-
 3 files changed, 24 insertions(+), 4 deletions(-)

Comments

Simon Glass Nov. 8, 2023, 4:24 a.m. UTC | #1
On Sun, 5 Nov 2023 at 19:26, Sean Anderson <seanga2@gmail.com> wrote:
>
> If we don't DMA-align buffers we pass to FAT, it will align them itself.
> This behaviour likely should be deprecated in favor of
> CONFIG_BOUNCE_BUFFER, but that's a task for another series. For the
> meantime, don't bother aligning the buffer unless we had been doing so in
> the past.
>
> Signed-off-by: Sean Anderson <seanga2@gmail.com>
> ---
>
> Changes in v6:
> - New
>
>  common/spl/Kconfig      | 18 ++++++++++++++++--
>  common/spl/spl_blk_fs.c |  5 ++++-
>  common/spl/spl_fat.c    |  5 ++++-
>  3 files changed, 24 insertions(+), 4 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index b93526904eb..fc284a5bffc 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -694,13 +694,28 @@  config SPL_FS_SQUASHFS
 config SPL_FS_FAT
 	bool "Support FAT filesystems"
 	select FS_FAT
-	select SPL_LOAD_BLOCK
 	help
 	  Enable support for FAT and VFAT filesystems with SPL. This
 	  permits U-Boot (or Linux in Falcon mode) to be loaded from a FAT
 	  filesystem from within SPL. Support for the underlying block
 	  device (e.g. MMC or USB) must be enabled separately.
 
+config SPL_FS_FAT_DMA_ALIGN
+	bool "Use DMA-aligned buffers with FAT"
+	depends on SPL_FS_FAT
+	select SPL_LOAD_BLOCK
+	default y if SPL_LOAD_FIT
+	help
+	  The FAT filesystem driver tries to ensure that the reads it issues to
+	  the block subsystem use DMA-aligned buffers. If the supplied buffer is
+	  not DMA-aligned, the FAT driver will use a bounce-buffer and read
+	  block-by-block. This is separate from the bounce-buffer used by the
+	  block subsystem (CONFIG_BOUNCE_BUFFER).
+
+	  Enable this config to align buffers passed to the FAT filesystem
+	  driver. This will speed up reads, but will increase the size of U-Boot
+	  by around 60 bytes.
+
 config SPL_FS_LOAD_PAYLOAD_NAME
 	string "File to load for U-Boot from the filesystem"
 	depends on SPL_FS_EXT4 || SPL_FS_FAT || SPL_FS_SQUASHFS || SPL_SEMIHOSTING
@@ -1282,7 +1297,6 @@  config SPL_NVME
 	depends on BLK
 	select FS_LOADER
 	select SPL_BLK_FS
-	select SPL_LOAD_BLOCK
 	help
 	  This option enables support for NVM Express devices.
 	  It supports basic functions of NVMe (read/write).
diff --git a/common/spl/spl_blk_fs.c b/common/spl/spl_blk_fs.c
index ac267ab979b..04eac6f306b 100644
--- a/common/spl/spl_blk_fs.c
+++ b/common/spl/spl_blk_fs.c
@@ -82,7 +82,10 @@  int spl_blk_load_image(struct spl_image_info *spl_image,
 	}
 
 	load.read = spl_fit_read;
-	spl_set_bl_len(&load, ARCH_DMA_MINALIGN);
+	if (IS_ENABLED(CONFIG_SPL_FS_FAT_DMA_ALIGN))
+		spl_set_bl_len(&load, ARCH_DMA_MINALIGN);
+	else
+		spl_set_bl_len(&load, 1);
 	load.priv = &dev;
 	return spl_load(spl_image, bootdev, &load, filesize, 0);
 }
diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
index 569f2b32928..a52f9e178e6 100644
--- a/common/spl/spl_fat.c
+++ b/common/spl/spl_fat.c
@@ -86,7 +86,10 @@  int spl_load_image_fat(struct spl_image_info *spl_image,
 	}
 
 	load.read = spl_fit_read;
-	spl_set_bl_len(&load, ARCH_DMA_MINALIGN);
+	if (IS_ENABLED(CONFIG_SPL_FS_FAT_DMA_ALIGN))
+		spl_set_bl_len(&load, ARCH_DMA_MINALIGN);
+	else
+		spl_set_bl_len(&load, 1);
 	load.priv = (void *)filename;
 	err = spl_load(spl_image, bootdev, &load, size, 0);