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 45BEFC433FE for ; Sun, 20 Nov 2022 09:57:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8096B80F1E; Sun, 20 Nov 2022 10:57:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="OvvQXYh0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 24252851A9; Sun, 20 Nov 2022 10:57:16 +0100 (CET) Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 096C985071 for ; Sun, 20 Nov 2022 10:57:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=dario.binacchi@amarulasolutions.com Received: by mail-ed1-x534.google.com with SMTP id h23so4702682edj.1 for ; Sun, 20 Nov 2022 01:57:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qwiqRmDYG/v1J6ZWPvuqmCb2qeHk/mpL4pTuFpADnfo=; b=OvvQXYh0oHdah3kjbN6gX/yVuVyTJ5u0DpGFntmHSiy8H+2MZLeGp6NdFUOLHppkM7 4+2y5ll8zHHwLIfln6gIGweqSyOgPU1IxekPHnp4ZWdcVPtIQi1srXNlOr2e57v5XEUv twQ5fuDu5JuE/lM2l26Q1/wvfYPwUuyu7oraE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qwiqRmDYG/v1J6ZWPvuqmCb2qeHk/mpL4pTuFpADnfo=; b=PWfvaGTs21m369NtOpmuZaoJ6bZU3HwGlOw0pGcVP2MXaU2bF5CdmtR1kwabwnedYQ q3EZEdLN4VMpEFHEcefEy5Sv+57ix+7tUoewRiQNoTJRGIAdMKTaF3UTrGMxTfKlp8qV d0sMcH1/bZSYgrhOzBLhLrmINrmcmkCHZmY55+ycYakS4WUmeM4eLbvjPQ6icmryi5Tl bscYHV5WwmMXx5j0R5QFSEfeH77zBf5CmO8e0Ftg9QdREs9RQ9Skkmm45DnMOHfRUkD0 XbRoulieUGhFQkUpawAbEdhkCYPtSyXGUzbZ74aytqe2SB0lsgWkTpWQQRtt3Tdp3q2r BHTw== X-Gm-Message-State: ANoB5pm8ked6BZWeCZvXtgNKsKhKucbKsEjf1CNIwv4qF0skVoC+FsUM 3Tcq9ftzzn/mzwVdBDA5HNsoL1oZukKOmg== X-Google-Smtp-Source: AA0mqf7JU9DsfIPYzRqnC6Llf9LB3zV0JiA/rmuiRnvKrEvenuVd8VzyLNI9wRWvHOaXg7dJRFiJ6w== X-Received: by 2002:a05:6402:1a2e:b0:461:2915:e41d with SMTP id be14-20020a0564021a2e00b004612915e41dmr11873836edb.184.1668938233380; Sun, 20 Nov 2022 01:57:13 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-79-40-103-33.business.telecomitalia.it. [79.40.103.33]) by smtp.gmail.com with ESMTPSA id la19-20020a170907781300b007b29eb8a4dbsm3850728ejc.13.2022.11.20.01.57.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Nov 2022 01:57:12 -0800 (PST) From: Dario Binacchi To: u-boot@lists.denx.de Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Michael Trimarchi Subject: [PATCH] mtd: nand: mxs_nand_spl: don't read useless pages Date: Sun, 20 Nov 2022 10:57:04 +0100 Message-Id: <20221120095705.3019295-1-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 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.6 at phobos.denx.de X-Virus-Status: Clean The patch prevents pages beyond the last from being unnecessarily read. This occurs when the last page to be read is not the last page of the last block. Before this change we would have read all the pages up to the end of the last block. Suggested-by: Michael Trimarchi Co-developed-by: Michael Trimarchi Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- drivers/mtd/nand/raw/mxs_nand_spl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c b/drivers/mtd/nand/raw/mxs_nand_spl.c index ef03b7789dd9..300662994cf2 100644 --- a/drivers/mtd/nand/raw/mxs_nand_spl.c +++ b/drivers/mtd/nand/raw/mxs_nand_spl.c @@ -257,7 +257,7 @@ int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst) while (block <= lastblock && size > 0) { if (!is_badblock(mtd, mtd->erasesize * block, 1)) { /* Skip bad blocks */ - while (page < nand_page_per_block) { + while (page < nand_page_per_block && size) { int curr_page = nand_page_per_block * block + page; if (mxs_read_page_ecc(mtd, page_buf, curr_page) < 0) { -- 2.32.0