Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp389375imm; Sat, 26 May 2018 01:44:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZofPZuAMO7uXe8q2eKEMUoBd648Gjg3UWYgFeYPZbS+mMdM2yyW/L6G5dgWa7Ba81exMefF X-Received: by 2002:a17:902:26:: with SMTP id 35-v6mr5974845pla.104.1527324248929; Sat, 26 May 2018 01:44:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527324248; cv=none; d=google.com; s=arc-20160816; b=yEqNBZ3smHXtzTW142BDN91o8TpWDJyzFsOHkzA7D3HCg3AYUzc4L5eMnguW8g6Lp3 O7+DX0hKU3XSorrAXF4rtvJ6kPYRce+hjF2+/4uUCYyEOwwVzP40xkYSCQgbNBHri+Wg UAIVpNffJQl1OqtyNwXhfuXBvxyl3dhI/vFjGDyRzpbB6e7FDwc1lvPWuZ55NtmRXw1S xXkxGLt5WyQ8AZj141mb/P3hyoSZaxoKSf1F6chgt7zR27fIxsBcoFKCIlkaMshlcMeI agAbray6SxQPSsYbe8sNdVWvX0YbKdy4BJKB+0aFhbfBNhG1j6lFJkRE9ozMhHv2BzXl UBBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=Tw2PgVkfh8FK29gjKltWJi5rhSOtKZ8gBe8qaiiPcrM=; b=DX1nNozBo0gxP3KlItBf+vJxV8jDIY/xeZqNBZgYru9RtxffPz6HybhC8M+KUyuv/R WsyrkROtGquY5TD8MZz8shp6Ffa5/mzcgBHLBV+iGN3ZcqvTPP+za1q/AjTwZgpe95Tx bXphjeYVUwbweXeo00ddhVBRwxwuG16dPvNJfvnwOLlhHbxBjBmh8QnSoRK94zrCBTk1 45YwqSwXnvsyZslxYWHLYgr7K4DLClWkFtH/zDbkX+zQkWekp/CZ7+CHmryHvIUikxjM gzQPf4AzA4MAO3cPz1SjsHUAE70W56+rvg6f48//KzJwA/lHVOpfsFrIMBQmSyGf3Ufv 0jEw== ARC-Authentication-Results: i=1; mx.google.com; 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 b6-v6si24405728plx.211.2018.05.26.01.43.54; Sat, 26 May 2018 01:44:08 -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; 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 S1031457AbeEZIn1 convert rfc822-to-8bit (ORCPT + 99 others); Sat, 26 May 2018 04:43:27 -0400 Received: from mail.bootlin.com ([62.4.15.54]:35904 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031300AbeEZInW (ORCPT ); Sat, 26 May 2018 04:43:22 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id C51F02073D; Sat, 26 May 2018 10:43:20 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from xps13 (unknown [37.169.55.10]) by mail.bootlin.com (Postfix) with ESMTPSA id DBBF22072C; Sat, 26 May 2018 10:43:08 +0200 (CEST) Date: Sat, 26 May 2018 10:43:05 +0200 From: Miquel Raynal To: Abhishek Sahu Cc: Boris Brezillon , David Woodhouse , Brian Norris , Marek Vasut , Richard Weinberger , Cyrille Pitchen , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Andy Gross , Archit Taneja Subject: Re: [PATCH v3 06/16] mtd: rawnand: qcom: use the ecc strength from device parameter Message-ID: <20180526104305.6f957db9@xps13> In-Reply-To: <1527250904-21988-7-git-send-email-absahu@codeaurora.org> References: <1527250904-21988-1-git-send-email-absahu@codeaurora.org> <1527250904-21988-7-git-send-email-absahu@codeaurora.org> Organization: Bootlin X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Abhishek, On Fri, 25 May 2018 17:51:34 +0530, Abhishek Sahu wrote: > Currently the driver uses the ECC strength specified in DT. > The QPIC/EBI2 NAND supports 4 or 8-bit ECC correction. The same > kind of board can have different NAND parts so use the ECC > strength from device parameters if it is not specified in DT. > > Signed-off-by: Abhishek Sahu > --- > * Changes from v2: > NONE Yes you did change things: - s/<< 2/* 4/ - updated the cwperpage location - the block handling the ecc-step-size property has been removed in a previous patch Please be careful with that, it is time consuming to review the patches all over again. > > * Changes from v1: > > 1. Removed the custom logic and used the helper fuction. > > drivers/mtd/nand/raw/qcom_nandc.c | 29 +++++++++++++++++++++-------- > 1 file changed, 21 insertions(+), 8 deletions(-) > > diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c > index b538390..7377923 100644 > --- a/drivers/mtd/nand/raw/qcom_nandc.c > +++ b/drivers/mtd/nand/raw/qcom_nandc.c > @@ -2315,19 +2315,39 @@ static int qcom_nand_ooblayout_free(struct mtd_info *mtd, int section, > .free = qcom_nand_ooblayout_free, > }; > > +static int > +qcom_nandc_calc_ecc_bytes(int step_size, int strength) > +{ > + return strength == 4 ? 12 : 16; > +} > +NAND_ECC_CAPS_SINGLE(qcom_nandc_ecc_caps, qcom_nandc_calc_ecc_bytes, > + NANDC_STEP_SIZE, 4, 8); > + > static int qcom_nand_host_setup(struct qcom_nand_host *host) > { > struct nand_chip *chip = &host->chip; > struct mtd_info *mtd = nand_to_mtd(chip); > struct nand_ecc_ctrl *ecc = &chip->ecc; > struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); > - int cwperpage, bad_block_byte; > + int cwperpage, bad_block_byte, ret; > bool wide_bus; > int ecc_mode = 1; > > /* controller only supports 512 bytes of data in each step */ > ecc->size = NANDC_STEP_SIZE; > wide_bus = chip->options & NAND_BUSWIDTH_16 ? true : false; > + cwperpage = mtd->writesize / NANDC_STEP_SIZE; > + > + /* > + * Each CW has 4 available OOB bytes which will be protected with ECC > + * so remaining bytes can be used for ECC. > + */ > + ret = nand_ecc_choose_conf(chip, &qcom_nandc_ecc_caps, > + mtd->oobsize - cwperpage * 4); Nitpick: could you add parenthesis around (cwperpage * 4) just for clarity. > + if (ret) { > + dev_err(nandc->dev, "No valid ECC settings possible\n"); > + return ret; > + } > > if (ecc->strength >= 8) { > /* 8 bit ECC defaults to BCH ECC on all platforms */ > @@ -2396,7 +2416,6 @@ static int qcom_nand_host_setup(struct qcom_nand_host *host) > > mtd_set_ooblayout(mtd, &qcom_nand_ooblayout_ops); > > - cwperpage = mtd->writesize / ecc->size; > nandc->max_cwperpage = max_t(unsigned int, nandc->max_cwperpage, > cwperpage); > > @@ -2412,12 +2431,6 @@ static int qcom_nand_host_setup(struct qcom_nand_host *host) > * for 8 bit ECC > */ > host->cw_size = host->cw_data + ecc->bytes; > - > - if (ecc->bytes * (mtd->writesize / ecc->size) > mtd->oobsize) { > - dev_err(nandc->dev, "ecc data doesn't fit in OOB area\n"); > - return -EINVAL; > - } > - > bad_block_byte = mtd->writesize - host->cw_size * (cwperpage - 1) + 1; > > host->cfg0 = (cwperpage - 1) << CW_PER_PAGE Once corrected: Acked-by: Miquel Raynal Thanks, Miquèl