Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4783758pxb; Mon, 15 Feb 2021 00:42:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyheusEa7B+kr+WAiq+nY8KJeG+Tx7WtNvWiODOZf7CPNPoCz/dMm6AYSCcujrA57/ruDiH X-Received: by 2002:a17:906:ccd6:: with SMTP id ot22mr925180ejb.165.1613378558234; Mon, 15 Feb 2021 00:42:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613378558; cv=none; d=google.com; s=arc-20160816; b=GBLH0C9VUa/834Vfz5GL/RtLTgGGrkq0kqk54l9juLyHp8XdVbiFLwqiDeL1HcTqMa JuWz73Lv+oiUyDdv5vYtBBArU6yO+fCcVAS1ZMu0qP6qglBrAKCMf23o2TCqkzeLiNyh 80/imwQ73eeKOeTydGMZqfrZbI0k2sZA/UfqNwpXL3sd/WCWeelJz7tI4eCK61OQrQnA whoV+Os4nMG8xIjaQzvaDN5QZFiaMNO56Iij0Tee+z4bgTQSZGCgrrlX3DugMV1TvTGi I2+9pT31GrxefYNowEZeTM9wnzdGgxTNrpMUJHa0sHWLs8ILa2iq1HbnLWJTo2S+yYF+ x8PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=Jgd0EopkSDkXktT2na3KmzUks/cltvLSZTUt/fZczCA=; b=udO1qIwBMHDjWwdfSBKUls1T4tIUMy0o2cGT/cTuKPwJ23f/Vq/KdZ0596gQfQGtgS 0hGmEKLN/GwjiZX5BrFTykA81xVGD6YOTqV1HyA9NvDRCNgFU6JVy8m0OhjKP+FgN4Xl dR40fstOgvkgtPb/nJTd6+0crGt1YTwOhOXiG90m7IEm9qSgQAyPVNuSo0gOajBP4UUT 2W+RH+rKLmoTM/1/3liQ5N9Iyx9wmAJ7SejksrTWTLw/Mml2fLhy+WPYrS8kSRuz23kK ZYFP6vB542tKDHG2Q9qg2c3T4w5wSHV/fr5bDkHl0gQalYCmAbKV7sacIV02ofx8cKiW WFOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si913172ejz.404.2021.02.15.00.42.15; Mon, 15 Feb 2021 00:42:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229976AbhBOIlt convert rfc822-to-8bit (ORCPT + 99 others); Mon, 15 Feb 2021 03:41:49 -0500 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:42015 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229931AbhBOIls (ORCPT ); Mon, 15 Feb 2021 03:41:48 -0500 X-Originating-IP: 90.89.99.36 Received: from xps13 (lfbn-tou-1-1536-36.w90-89.abo.wanadoo.fr [90.89.99.36]) (Authenticated sender: miquel.raynal@bootlin.com) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 42BA5E0005; Mon, 15 Feb 2021 08:40:56 +0000 (UTC) Date: Mon, 15 Feb 2021 09:40:55 +0100 From: Miquel Raynal To: Md Sadre Alam Cc: richard@nod.at, vigneshr@ti.com, boris.brezillon@collabora.com, mani@kernel.org, krzk@kernel.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, sricharan@codeaurora.org Subject: Re: [PATCH] mtd: rawnand: qcom: update last code word register Message-ID: <20210215094055.1c3847f8@xps13> In-Reply-To: <1613337451-8002-1-git-send-email-mdalam@codeaurora.org> References: <1613337451-8002-1-git-send-email-mdalam@codeaurora.org> Organization: Bootlin X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Md Sadre Alam wrote on Mon, 15 Feb 2021 02:47:31 +0530: > From QPIC version 2.0 onwards new register got added to > read last codeword. This change will add the READ_LOCATION_LAST_CW_n > register. > > For first three code word READ_LOCATION_n register will be > use.For last code word READ_LOCATION_LAST_CW_n register will be > use. > > Signed-off-by: Md Sadre Alam > --- > [V5] > * Added helper function to update location register value. Please don't forget the "v5" in the message object. > /* > @@ -1094,11 +1141,16 @@ static void config_nand_page_read(struct qcom_nand_controller *nandc) > * before reading each codeword in NAND page. > */ > static void > -config_nand_cw_read(struct qcom_nand_controller *nandc, bool use_ecc) > +config_nand_cw_read(struct qcom_nand_controller *nandc, bool use_ecc, bool last_cw) > { > - if (nandc->props->is_bam) > - write_reg_dma(nandc, NAND_READ_LOCATION_0, 4, > - NAND_BAM_NEXT_SGL); > + if (nandc->props->is_bam) { > + if (nandc->props->qpic_v2 && last_cw) > + write_reg_dma(nandc, NAND_READ_LOCATION_LAST_CW_0, 4, > + NAND_BAM_NEXT_SGL); > + else > + write_reg_dma(nandc, NAND_READ_LOCATION_0, 4, > + NAND_BAM_NEXT_SGL); I guess write_reg_dma should be updated as well. [...] > > - config_nand_cw_read(nandc, false); > + config_nand_cw_read(nandc, false, cw == ecc->steps - 1 ? true : false); > > read_data_dma(nandc, reg_off, data_buf, data_size1, 0); > reg_off += data_size1; > @@ -1873,18 +1938,31 @@ static int read_page_ecc(struct qcom_nand_host *host, u8 *data_buf, > > if (nandc->props->is_bam) { > if (data_buf && oob_buf) { > - nandc_set_read_loc(nandc, 0, 0, data_size, 0); > - nandc_set_read_loc(nandc, 1, data_size, > - oob_size, 1); > + if (nandc->props->qpic_v2 && i == (ecc->steps - 1)) { I would like the helper to handle this condition. I would prefer to avoid yet an extra indentation level. > + nandc_set_read_loc(chip, i, 0, 0, data_size, 0); > + nandc_set_read_loc(chip, i, 1, data_size, > + oob_size, 1); > + } else { > + nandc_set_read_loc(chip, i, 0, 0, data_size, 0); > + nandc_set_read_loc(chip, i, 1, data_size, > + oob_size, 1); > + } > } else if (data_buf) { > - nandc_set_read_loc(nandc, 0, 0, data_size, 1); > + if (nandc->props->qpic_v2 && i == (ecc->steps - 1)) > + nandc_set_read_loc(chip, i, 0, 0, data_size, 1); > + else > + nandc_set_read_loc(chip, i, 0, 0, data_size, 1); > } else { > - nandc_set_read_loc(nandc, 0, data_size, > - oob_size, 1); > + if (nandc->props->qpic_v2 && i == (ecc->steps - 1)) > + nandc_set_read_loc(chip, i, 0, data_size, > + oob_size, 1); > + else > + nandc_set_read_loc(chip, i, 0, data_size, > + oob_size, 1); > } > } > > - config_nand_cw_read(nandc, true); > + config_nand_cw_read(nandc, true, i == ecc->steps - 1 ? true : false); i == (ecc->steps - 1) is already a boolean, you don't need "? true : false" > > if (data_buf) > read_data_dma(nandc, FLASH_BUF_ACC, data_buf, > @@ -1946,7 +2024,7 @@ static int copy_last_cw(struct qcom_nand_host *host, int page) > set_address(host, host->cw_size * (ecc->steps - 1), page); > update_rw_regs(host, 1, true); > > - config_nand_single_cw_page_read(nandc, host->use_ecc); > + config_nand_single_cw_page_read(nandc, host->use_ecc, true); Maybe it's best to just forward the codeword and let the code that needs to know if it is the last one or not do the comparison. > > read_data_dma(nandc, FLASH_BUF_ACC, nandc->data_buffer, size, 0); > Thanks, Miquèl