From fa06a6df65b7bf77c112aa3f83b3b62bf7790712 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pali=20Roh=C3=A1r?= Date: Wed, 29 Mar 2023 21:25:52 +0200 Subject: [PATCH] arm: mvebu: spl: Do not hardcode SATA block size to 512 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Find SATA block device by blk_get_devnum_by_uclass_id() function and read from it the real block size of the SATA disk. Signed-off-by: Pali Rohár --- arch/arm/mach-mvebu/spl.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c index 6b8c72a71d..379daa88a4 100644 --- a/arch/arm/mach-mvebu/spl.c +++ b/arch/arm/mach-mvebu/spl.c @@ -208,10 +208,15 @@ int spl_parse_board_header(struct spl_image_info *spl_image, /* * For SATA srcaddr is specified in number of sectors. - * This expects that sector size is 512 bytes. + * Retrieve block size of the first SCSI device (same + * code used by the spl_sata_load_image_raw() function) + * or fallback to default sector size of 512 bytes. */ - if (IS_ENABLED(CONFIG_SPL_SATA) && mhdr->blockid == IBR_HDR_SATA_ID) - spl_image->offset *= 512; + if (IS_ENABLED(CONFIG_SPL_SATA) && mhdr->blockid == IBR_HDR_SATA_ID) { + struct blk_desc *blk_dev = blk_get_devnum_by_uclass_id(UCLASS_SCSI, 0); + unsigned long blksz = blk_dev ? blk_dev->blksz : 512; + spl_image->offset *= blksz; + } if (spl_image->offset % 4 != 0) { printf("ERROR: Wrong srcaddr (0x%08x) in kwbimage\n", -- 2.39.5