From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7CF5BC6FD18 for ; Wed, 29 Mar 2023 19:28:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2A95B85E3B; Wed, 29 Mar 2023 21:28:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="mxAlvCDd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9CFBC85D74; Wed, 29 Mar 2023 21:28:17 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 53E7D85D1E for ; Wed, 29 Mar 2023 21:28:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E0E4761E0D; Wed, 29 Mar 2023 19:28:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C7FEC433EF; Wed, 29 Mar 2023 19:28:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680118084; bh=VhR21XAiqvFRXnGCd3As41QLE7wDqhmLUmOgNVAlaIU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mxAlvCDd5cW30J+l+YH7gD5jGM8xXx/krE4Ja08GXY6OW5hvEV6kQlFjCzG/KgMHn /60UHb6WfawG1cpKkU3Wp7CxCaIOqBJ+3rotwXxhCrz3Ugfj7De5X8TIAs3MhT20Ly VL9Ix2PXtqVM4AUleRgjFiyUNhWg8Dx7++aopuWFJchj9YO8rpsGftJDeniqbw+NpK rnevrie6R09aAoichppXwc7U7ZvkMq6TLDHkf0HP5CpvpdN2UvgNCOD3CMdTDAZYfR Ttf6iyCnlxGeWFXp1fRvlNxzxBLd7QUcvLvHQjSuPU72nql4JtawoL0ZR1byZu21wC IGaRyOUw3t0Sg== Received: by pali.im (Postfix) id B30D165A; Wed, 29 Mar 2023 21:28:01 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Martin Rowe , Tony Dinh , Stefan Roese , Chris Packham , Baruch Siach Cc: u-boot@lists.denx.de Subject: [PATCH u-boot-mvebu 1/7] arm: mvebu: spl: Do not hardcode SATA block size to 512 Date: Wed, 29 Mar 2023 21:25:52 +0200 Message-Id: <20230329192558.12417-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230329192558.12417-1-pali@kernel.org> References: <20230329192558.12417-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean 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 6b8c72a71dab..379daa88a4d8 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.20.1