Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp797097imm; Mon, 21 May 2018 14:39:26 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrCsurahyKMlRZ9WHrUorkodiMek/BNV5HA/HX4dA0vlONKEol4FoPVLtHnXPpwcFR+gFSC X-Received: by 2002:a63:3706:: with SMTP id e6-v6mr16905858pga.281.1526938765985; Mon, 21 May 2018 14:39:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526938765; cv=none; d=google.com; s=arc-20160816; b=ZHXqkVVhVfpixwO+uhicf7+PvhPN4mHwM6bCzHqVBXj13bTY6mya7nAmYqYs4So17n yJaKxChnhptuMQSDBSRM/mhkCvQ+1huYMQ0jYlVMn69VnJt2dQgqaEUCOe/eWWcZ5o7w swo9Uf2c21CsE39dEUsjIOpk+YnJ+stvTcXBgMKz6ib+wSej2nXVcUb9cyXUHLNYWtB/ Vdg+4EMrzlcV+K35IYOKL0cYER1y0crgInHzKtCdHrBcBwbKDhr/+D7KHgqx3h9v9ES3 ywLaKt5w3wpDtJUm6oCdA2o4+PcTYyVhWr+8UHTc7VZw2R0PfcrGDEN+cwLWOZxSIkz0 2VRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=ho7WNhAttsyir9kyQSAPCrJ8tv39cc/QTuo/eu/qTKw=; b=iRPnSCqb4K4w5GZ7nVMqQX+7Qw/ZgiiCYKwBwT2oViQNWPoVk4kEXIRrlGMRrTOerw xcZ3UAfV/LiVbR3pAQEM+TDvYqmKgJPZeAieXGafvCiMj9vFOyiBD4lpBQax4UEZHQdp DchvblSdNniHbw0J4m7V6oNR9CF5Lo3sWmK29aA5rbWhYV6Zu5v01finyxHAcH5QPmm7 /ahuPrg9TkeFNXU2xETjuIICSoeFTmUw9/rthyMEU8NRVS8VRkJ1gys47litwxgS/TK2 T5dQdNgaPAXQJ3+y0wG8TLvT1zt3bqhdtJbtKV6Dx4+1pZuRyX7gc3TsUsK2NSjoBZES auFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UxGdQhCA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 8-v6si15257890plc.444.2018.05.21.14.39.11; Mon, 21 May 2018 14:39:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UxGdQhCA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754384AbeEUVZC (ORCPT + 99 others); Mon, 21 May 2018 17:25:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:39788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932321AbeEUVYy (ORCPT ); Mon, 21 May 2018 17:24:54 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3C9F920853; Mon, 21 May 2018 21:24:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526937893; bh=EnQ5sweph7w6LIaPAGRVAXhJaOywQJFK6XmUcw15Hmg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UxGdQhCAURcO+djLZvKLNW9gcB71xkbMVSjEzFQD4D9vDwOP6fhQCYFgxvagt2gs4 a8uPKaCM0cbuaiD52ICPkKgRdmkYBVwPwEEPbuKm/iQ8uYRcwOscoXyS8WEDjO65gc QkaHyUFJtZfWSisaZv+au3x5KAyPBipYcQej8ruI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Packham , Boris Brezillon , Miquel Raynal Subject: [PATCH 4.16 032/110] mtd: rawnand: marvell: Fix read logic for layouts with ->nchunks > 2 Date: Mon, 21 May 2018 23:11:29 +0200 Message-Id: <20180521210506.599322824@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180521210503.823249477@linuxfoundation.org> References: <20180521210503.823249477@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Boris Brezillon commit 90d617633368ab97a2c7571c6e66dad54f39228d upstream. The code is doing monolithic reads for all chunks except the last one which is wrong since a monolithic read will issue the READ0+ADDRS+READ_START sequence. It not only takes longer because it forces the NAND chip to reload the page content into its internal cache, but by doing that we also reset the column pointer to 0, which means we'll always read the first chunk instead of moving to the next one. Rework the code to do a monolithic read only for the first chunk, then switch to naked reads for all intermediate chunks and finally issue a last naked read for the last chunk. Fixes: 02f26ecf8c77 mtd: nand: add reworked Marvell NAND controller driver Cc: stable@vger.kernel.org Reported-by: Chris Packham Signed-off-by: Boris Brezillon Tested-by: Chris Packham Acked-by: Miquel Raynal Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/marvell_nand.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/mtd/nand/marvell_nand.c +++ b/drivers/mtd/nand/marvell_nand.c @@ -1190,11 +1190,13 @@ static void marvell_nfc_hw_ecc_bch_read_ NDCB0_CMD2(NAND_CMD_READSTART); /* - * Trigger the naked read operation only on the last chunk. - * Otherwise, use monolithic read. + * Trigger the monolithic read on the first chunk, then naked read on + * intermediate chunks and finally a last naked read on the last chunk. */ - if (lt->nchunks == 1 || (chunk < lt->nchunks - 1)) + if (chunk == 0) nfc_op.ndcb[0] |= NDCB0_CMD_XTYPE(XTYPE_MONOLITHIC_RW); + else if (chunk < lt->nchunks - 1) + nfc_op.ndcb[0] |= NDCB0_CMD_XTYPE(XTYPE_NAKED_RW); else nfc_op.ndcb[0] |= NDCB0_CMD_XTYPE(XTYPE_LAST_NAKED_RW);