Received: by 10.223.185.116 with SMTP id b49csp2147528wrg; Mon, 12 Feb 2018 05:14:23 -0800 (PST) X-Google-Smtp-Source: AH8x2273maSQqNQyzcfUZVTaLjipMZZsH8vR/5ktbqYN7Av274jB9LH4tUQBQwavVRKzitsrBZuA X-Received: by 10.98.196.204 with SMTP id h73mr11839543pfk.143.1518441263063; Mon, 12 Feb 2018 05:14:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441263; cv=none; d=google.com; s=arc-20160816; b=staafQjQnGhClJMPkdVjS9u3rwjrnfXB4g3LOgDg/XJW+F/2fQ+oKagsz8Rzp9JqRf /cfopkM1gVuf1F0rrFnAa26XTXQjtGbVNdKAImANbbHiQuWGAxwx1GgBQz6z/k98C5Rt 0YEregwIQqzmRj0WqqDvDMQU0H+QsCkpnMKCnHn4xVHNLn6zkfR9WBfk5rWlt5Iw28m4 3yGVQaYdkQMkzT8AS1mIuEaZdPCXsdtmkOQolY+Tqe5+99v78KyYXvkohjPrz+GcU221 rdh/wU1J4r/lN6rxm3YyBwhF4z8xtq7VkyAPyfFuE2THc+nR6uGeQkkopYCLD9qi0Cgl 0R3w== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=Wy5z+V31vq9nfDCJwnlLWWh6c27dWDgf2smRM4UwsLc=; b=0uKZf1OsD5/0SfcVxUrf3ZoRrDCkTMEj8P+l4KdDfrWnwfSqjyWpPc4OzTu+c9E8dW TBWOrcmxzJxXnP1xP/IDji2SLTlZiXY8OYzw6ZZzqrmIqVZho0m+e0bexTsDPLtWIoxI DKYhSKJa7tVQPztk6sh3j7rYPpV1qG2JiXrlUogY7h5tgV1wfZVy9FVSYoFnlcWqs62U A8I023qInFtpEU9hLQkA7BkgnfbI509WxJKtIcxyx47eZaaaVCIbF5rNy0CfKsdTOZnk aiKcakHl7lMVKSS79SVyLO7V27cOrV3xhf22vstyxQq6hM2R57KK2lUBeN3A626BPAPs UOww== 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 i1-v6si5883259pld.42.2018.02.12.05.14.08; Mon, 12 Feb 2018 05:14:23 -0800 (PST) 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 S933719AbeBLKby (ORCPT + 99 others); Mon, 12 Feb 2018 05:31:54 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:39791 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932941AbeBLKbx (ORCPT ); Mon, 12 Feb 2018 05:31:53 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id 7D44F203A2; Mon, 12 Feb 2018 11:31:51 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.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 bbrezillon (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 2285B20381; Mon, 12 Feb 2018 11:31:51 +0100 (CET) Date: Mon, 12 Feb 2018 11:31:51 +0100 From: Boris Brezillon To: Stefan Agner Cc: han.xu@nxp.com, boris.brezillon@free-electrons.com, marek.vasut@gmail.com, richard@nod.at, dwmw2@infradead.org, cyrille.pitchen@wedev4u.fr, max.oss.09@gmail.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] mtd: nand: gpmi: add support for specific ECC strength Message-ID: <20180212113151.17c60680@bbrezillon> In-Reply-To: <20180206174021.5947-2-stefan@agner.ch> References: <20180206174021.5947-1-stefan@agner.ch> <20180206174021.5947-2-stefan@agner.ch> 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=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 6 Feb 2018 18:40:21 +0100 Stefan Agner wrote: > Add support for specified ECC strength/size using device tree > properties nand-ecc-strength/nand-ecc-step-size. > > Signed-off-by: Stefan Agner > --- > .../devicetree/bindings/mtd/gpmi-nand.txt | 5 ++++ I don't care that much, but I know DT maintainers like to have DT bindings changes placed in a separate patch. > drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 29 ++++++++++++++-------- > 2 files changed, 24 insertions(+), 10 deletions(-) > > diff --git a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt > index eb2d9919d063..ea6e9b735160 100644 > --- a/Documentation/devicetree/bindings/mtd/gpmi-nand.txt > +++ b/Documentation/devicetree/bindings/mtd/gpmi-nand.txt > @@ -46,6 +46,11 @@ Optional properties: > partitions written from Linux with this feature > turned on may not be accessible by the BootROM > code. > + - nand-ecc-strength: integer representing the number of bits to correct > + per ECC step. Needs to be a multiple of 2. > + - nand-ecc-step-size: integer representing the number of data bytes > + that are covered by a single ECC step. The driver > + supports 512 and 1024. > > The device tree may optionally contain sub-nodes describing partitions of the > address space. See partition.txt for more detail. > diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c > index 50f8d4a1b983..8cb378358e11 100644 > --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c > +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c > @@ -198,17 +198,15 @@ static inline bool gpmi_check_ecc(struct gpmi_nand_data *this) > * > * We may have available oob space in this case. > */ > -static int set_geometry_by_ecc_info(struct gpmi_nand_data *this) > +static int set_geometry_by_ecc_info(struct gpmi_nand_data *this, > + unsigned int ecc_strength, unsigned int ecc_step) > { > struct bch_geometry *geo = &this->bch_geometry; > struct nand_chip *chip = &this->nand; > struct mtd_info *mtd = nand_to_mtd(chip); > unsigned int block_mark_bit_offset; > > - if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0)) > - return -EINVAL; > - > - switch (chip->ecc_step_ds) { > + switch (ecc_step) { > case SZ_512: > geo->gf_len = 13; > break; > @@ -221,8 +219,8 @@ static int set_geometry_by_ecc_info(struct gpmi_nand_data *this) > chip->ecc_strength_ds, chip->ecc_step_ds); > return -EINVAL; > } > - geo->ecc_chunk_size = chip->ecc_step_ds; > - geo->ecc_strength = round_up(chip->ecc_strength_ds, 2); > + geo->ecc_chunk_size = ecc_step; > + geo->ecc_strength = round_up(ecc_strength, 2); > if (!gpmi_check_ecc(this)) > return -EINVAL; > > @@ -230,7 +228,7 @@ static int set_geometry_by_ecc_info(struct gpmi_nand_data *this) > if (geo->ecc_chunk_size < mtd->oobsize) { > dev_err(this->dev, > "unsupported nand chip. ecc size: %d, oob size : %d\n", > - chip->ecc_step_ds, mtd->oobsize); > + ecc_step, mtd->oobsize); > return -EINVAL; > } > > @@ -423,9 +421,20 @@ static int legacy_set_geometry(struct gpmi_nand_data *this) > > int common_nfc_set_geometry(struct gpmi_nand_data *this) > { > + struct nand_chip *chip = &this->nand; > + > + if (chip->ecc.strength > 0 && chip->ecc.size > 0) > + return set_geometry_by_ecc_info(this, chip->ecc.strength, > + chip->ecc.size); > + > if ((of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc")) > - || legacy_set_geometry(this)) > - return set_geometry_by_ecc_info(this); > + || legacy_set_geometry(this)) { > + if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0)) > + return -EINVAL; > + > + return set_geometry_by_ecc_info(this, chip->ecc_strength_ds, > + chip->ecc_step_ds); > + } > > return 0; > } Both patches look good to me. Han, could review them and add your Ack if you're happy with the changes. Thanks, Boris -- Boris Brezillon, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering http://bootlin.com