From patchwork Mon Jul 18 07:37:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Palacios X-Patchwork-Id: 649358 X-Patchwork-Delegate: scottwood@freescale.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3rtFQR6k3dz9s5J for ; Mon, 18 Jul 2016 17:38:06 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4E25F4BED0; Mon, 18 Jul 2016 09:38:03 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kYjl6zoYC1K4; Mon, 18 Jul 2016 09:38:02 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 29ACD4BB3B; Mon, 18 Jul 2016 09:38:02 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7AFBC4BB3B for ; Mon, 18 Jul 2016 09:37:59 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6yih-TlWAwpX for ; Mon, 18 Jul 2016 09:37:59 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail1.bemta8.messagelabs.com (mail1.bemta8.messagelabs.com [216.82.243.208]) by theia.denx.de (Postfix) with ESMTP id 0DB8E4BB1A for ; Mon, 18 Jul 2016 09:37:56 +0200 (CEST) Received: from [216.82.241.132] by server-16.bemta-8.messagelabs.com id 00/98-20243-3578C875; Mon, 18 Jul 2016 07:37:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrDIsWRWlGSWpSXmKPExsXi5LtOQDe4vSf c4Ow/PouuvkVsFt+2bGO0eLu3k92B2ePqr5PsHrMbLrJ4nL2zgzGAOYo1My8pvyKBNaNh6SLG gtVcFT+2GDYwXuXoYuTiEBJYxSjx8s9idghnA6PExM0nmbsYOTnYBAwkplyfxgJiiwhISbzs3 AgWZxZwk9i4+CobiC0s4CtxecdZ1i5GDg4WAVWJxffyQMK8Au4SnXs/sYOEJQTkJBa894EIC0 qcnPmEBWKKhMTBFy/AJgoBdc77vIkVxJYQUJA4u+cvE4RtInHx6m42CNtQ4vusbywQtrTE3r6 FzBMYBWYhGTsLydgFjEyrGDWKU4vKUot0DU31kooy0zNKchMzc3QNDSz0clOLixPTU3MSk4r1 kvNzNzECQ7WegYFxB+OB5+6HGCU5mJREeZsUesKF+JLyUyozEosz4otKc1KLDzHKcHAoSfDub AXKCRalpqdWpGXmAKMGJi3BwaMkwvsDJM1bXJCYW5yZDpE6xagoJc4r0gaUEABJZJTmwbXBIv USo6yUMC8jAwODEE9BalFuZgmq/CtGcQ5GJWFeNpApPJl5JXDTXwEtZgJabKDaDbK4JBEhJdX AaP321T8LG/WTz3P/R544XPhP2FShd6NU0L2KyOmmOmrBRXkm0omc80VNOnLn27/rv8D7/yCT bgqz+xmJ4CssjUvNxF8VapYlXRS2szzRP+N56sLT3MKXzOt05+5xPq395PWOJXlObBUbTK93G arYZNjMdCw695/Rzyun8ab9Zp+QetW9enFKLMUZiYZazEXFiQCOi5zDzwIAAA== X-Env-Sender: Hector.Palacios@digi.com X-Msg-Ref: server-7.tower-45.messagelabs.com!1468827475!33262700!1 X-Originating-IP: [66.77.174.16] X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18943 invoked from network); 18 Jul 2016 07:37:55 -0000 Received: from owa.digi.com (HELO MCL-VMS-XCH01.digi.com) (66.77.174.16) by server-7.tower-45.messagelabs.com with SMTP; 18 Jul 2016 07:37:55 -0000 Received: from DOR-SMS-XCH01.digi.com (10.49.8.99) by MCL-VMS-XCH01.digi.com (10.5.8.49) with Microsoft SMTP Server (TLS) id 14.3.279.2; Mon, 18 Jul 2016 02:37:51 -0500 Received: from log-cln-hpalacio.digi.com (10.101.2.202) by dor-sms-xch01.digi.com (10.49.8.99) with Microsoft SMTP Server (TLS) id 14.3.279.2; Mon, 18 Jul 2016 09:37:48 +0200 From: Hector Palacios To: Date: Mon, 18 Jul 2016 09:37:41 +0200 Message-ID: <1468827461-4885-1-git-send-email-hector.palacios@digi.com> X-Mailer: git-send-email 2.7.3 MIME-Version: 1.0 X-Originating-IP: [10.101.2.202] X-KSE-AntiSpam-Interceptor-Info: protection disabled X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean Cc: oss@buserror.net, hector.palacios@digi.com Subject: [U-Boot] [PATCH v2 1/1] mtd: nand: fix bug writing 1 byte less than page size X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 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" nand_do_write_ops() determines if it is writing a partial page with the formula: part_pagewr = (column || writelen < (mtd->writesize - 1)) When 'writelen' is exactly 1 byte less than the NAND page size the formula equates to zero, so the code doesn't process it as a partial write, although it should. As a consequence the function remains in the while(1) loop with 'writelen' becoming 0xffffffff and iterating until the watchdog timeout triggers. To reproduce the issue on a NAND with 2K page (0x800): => nand erase.part => nand write $loadaddr 7ff Signed-off-by: Hector Palacios --- Changes in v2 - v1 was wronly generated over U-Boot v2015.04 drivers/mtd/nand/nand_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 689716753ae6..8280288a5ea1 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2411,7 +2411,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, int cached = writelen > bytes && page != blockmask; uint8_t *wbuf = buf; int use_bufpoi; - int part_pagewr = (column || writelen < (mtd->writesize - 1)); + int part_pagewr = (column || writelen < mtd->writesize); if (part_pagewr) use_bufpoi = 1;