From patchwork Sun Nov 20 09:57:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2502 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 563573F1F2 for ; Sun, 20 Nov 2022 10:57:15 +0100 (CET) Received: by mail-ed1-f72.google.com with SMTP id m7-20020a056402430700b0045daff6ee5dsf4812339edc.10 for ; Sun, 20 Nov 2022 01:57:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668938235; cv=pass; d=google.com; s=arc-20160816; b=Flc7r0fMZCduhzpOA241hbAEYSwE97Z1IZIQhwQuc5j+ACPq4TUtnM2j99arGcKsRP J6CCYcpvRNQVQkMJIGmwLVJaaH2SQBqIu/EP4h20Kh/Zxy5t/2IPOLt1aGpZlr9RU8At jD139Bbx7wmSDxelbsG84by5u8WIG05pu2H9zH+wGmYZW3YU+FWEiyNUaD2JotDxYWqF n400nLmu5uicq6zYzn0jxy8sIGttDAD9MJGldALLMHlcEpR6yAVsqnxKkmcuRvVw3zpb Tz0snjg1xR2QGuHsvxfTmcsMdUK/hqxAMZaMcavhX3UEMuDiKyiFndw//Xax6zmOvxPx IR3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:message-id:date:subject:cc:to :from:dkim-signature; bh=jb/Q/C7S2QLQv5xvgDSckvPQKsW7nizjB3itTQXFKFY=; b=JA8rAVzEvyTey+prCIQ+JZOg8g9RAlJBomCxut8NCGO7+MIx8XIGzz1bBK0+7MLIG5 hMHhCWukarmC1UTplIuj7w2WqenTcQsF4ERpKHPF2jpD2n5+HZebOeSaWfOMjdMi0ICV 9lXc/jDmczZcm8YBe8HW8BaaNaronyno/amWDcqABK/hb7eWdUkO0Bj0BAvVm/rPWgoC 1t6oPkJ5ZzFvwTo/yZVUqV/UPLhzqrrz+n6PO9T4ZNcShEr62/zXWb9BkWEANsyn9moW x92FtRyCPEa/hJ4x6PuPlyGXu50a9atPcLpvy0G8DPqv2ipDqUZMDfwgxm6Ee0UchjRB 03eQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=OvvQXYh0; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :from:to:cc:subject:date:message-id:reply-to; bh=jb/Q/C7S2QLQv5xvgDSckvPQKsW7nizjB3itTQXFKFY=; b=CX5H7khpj/C1WQeObplhr0ABQv+e+yjk9j9gdSvCQv9C1Zf31ghUWKNnfwo1XBv0dA TB1FD9M8PfmKijZo9wiwFqgtdyZlgipB8jgCgcltVRQ2Q01rB1DDKOHdTDnzeeRcnFTc U42UMeGe7VJYcSvtYeFe65aP7pZuMUyG8wB/E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jb/Q/C7S2QLQv5xvgDSckvPQKsW7nizjB3itTQXFKFY=; b=bFV6L/a/kVn4tqlQhrAkxXT81VEZi4eYC2eyKtYwrPJsesjuduNt5FzXGm4NEAw8Mc j/vbB9vtgFBSCL/d1j0/pEKrk+dcv12x3HpInmQw6e37BNsqcqJ8JDmFw4HOHcLAD5Ng nTLYejpetZ8E8pw/I+moYN8Kb5UhIcXiuZDvdA4GQZ28uLzl5qCpnu3kfm1LooJuMamg s0Ps3cO39ms7evkifcx5xopcd1qboFl8Iwl0Xuda27obPfAPH5kM2OvKajLUttRBEVhz ssKxZS85U5JuKsNOc0/SAm+l5pj62unBMOf3n10Z9FYrathH5BJRZ672qapPDwzzOpjH vbHw== X-Gm-Message-State: ANoB5pnTs/6NSa97gFbkl2JKD+3S5w2d9RB/a+Gsz1b59DkxZ4tFmWf4 8R0sMb45LyB41HYW0j8owooqH2l8 X-Google-Smtp-Source: AA0mqf7uh/jFjHDJW2zSQtmmt//TOHclWxZzRN2YG2OqBjzeB/fOtQzeeJsNtBj351FL/OfKsCeKrw== X-Received: by 2002:aa7:c50d:0:b0:469:5c0c:55e8 with SMTP id o13-20020aa7c50d000000b004695c0c55e8mr3359750edq.165.1668938234902; Sun, 20 Nov 2022 01:57:14 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:268f:b0:461:bb4b:90b1 with SMTP id w15-20020a056402268f00b00461bb4b90b1ls6903315edd.1.-pod-prod-gmail; Sun, 20 Nov 2022 01:57:13 -0800 (PST) X-Received: by 2002:a05:6402:68c:b0:461:b506:6b8a with SMTP id f12-20020a056402068c00b00461b5066b8amr12108308edy.208.1668938233699; Sun, 20 Nov 2022 01:57:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668938233; cv=none; d=google.com; s=arc-20160816; b=jUMDWo1q6LHuRviHqwddaC+9OM6etZ0nYJ+Wm7fCNbApBRgljqVNm3UhzP5nWBjyHN 8L79Qs/VyKhjJ8Hyq+WKte2EpCm7q82cZou1pav9Ab6lpe92jCNNOtYyq6II2h34d91b s22D9ui4S6BYlwlq46EJuzSdw9qOq+huvj5rgl4gGgIeCxT76zCxMt0ubsxIwkIrOzKQ Jci0FxxotaEZs1SEzVJ51+cYnngFDToVB6XPP1Q7kaQYLswgkY7LGUk3X1S3cS6au6D5 MusnS2SfsFFGPiod2N9CPizawBQJRdEqlg5KzTwH+Lz0FigFMYaIRcEUnG/8Z3xEoO6X 7vhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=qwiqRmDYG/v1J6ZWPvuqmCb2qeHk/mpL4pTuFpADnfo=; b=Rh+e/faINIhgSzADSPuDxD84bQ4AgVSZVbfXpef1vXOxad3lXWDQCwVEDuFT/firFH RBkEn6wsxzQWNslWOM9hGo4ERhaU3Yrdh+eAlmnxYpROheA1BTwLWIemOHkf+uLwoBtw TBdt6tcatcnCKyzEBK2eFOf6cOHLkg5G+Nne8OobiU1gbcvioiqryhtL47VtJa2mPXwt 5QnNr3W+elXGnHGiZjGR7EixZOanJ+gxOHl3QIUtzCEJvzUAkjfuCjc9hidEIV0tyvRH tc1ogEaBl3gQIhtDghYu3g4jTNL7KJtcbiYoIrLIoNZTqCh/cvU7hGEw+KwyBPGLaeoY I+3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=OvvQXYh0; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id b6-20020a509f06000000b00461f5cdb5acsor3976972edf.53.2022.11.20.01.57.13 for (Google Transport Security); Sun, 20 Nov 2022 01:57:13 -0800 (PST) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; 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 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=OvvQXYh0; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 Acked-by: Michael Trimarchi --- 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) {