Received: by 10.223.185.116 with SMTP id b49csp1223989wrg; Wed, 14 Feb 2018 13:37:29 -0800 (PST) X-Google-Smtp-Source: AH8x227ENWctGcV6QGSAjSHgudrgSviW3aje53+LL3H59H9j6rqbwlC2lj74zzDDKbC89AmuRw+k X-Received: by 10.101.99.133 with SMTP id h5mr317260pgv.381.1518644249502; Wed, 14 Feb 2018 13:37:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518644249; cv=none; d=google.com; s=arc-20160816; b=gMdz2BJi9UJUXPSk8YjDnclW6Xoj9r1SJWX4UsKYai0zqTLd0TJY0e2Y7Rbjc9xEzn 25wL3chEsZrIwz7Q/aF9vIs8QIjSOU4OXBEU/Laz86O8blIgSmeh064S6Md7FLH5uQSE s2WOGn8dH3cTU5QtKk2XWvXuDzgE/vScvDj7QH1sj+jvAA34SMZwPjr8yYh+nbhYvFdP yRvMYkPTolXFFbdZqmy8X1sPsd/W+nPdJ4Tex+mazFwzpqIBo0VHbE8lHmNgZNd0Ika7 Cih8iU/p21m2k6ZUDIr36R+7RHK4p3Yn8CYYqqBdJcy7XJX7iTbu17AeTSlFoXDwefz+ O6YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:user-agent:message-id :references:in-reply-to:subject:cc:to:from:date :content-transfer-encoding:mime-version:arc-authentication-results; bh=5y7wtUX63iSak2TVB3i7gmxOTbwi3TJvfeA0mh0h0ZQ=; b=eYmptB92TakPtkb+0b4QXmCAODLsD4r6CJYsMmFRDgjZbK5Rfo5Y1FNpn6u9ZRSNEM aIk//zwH2eWJRHt3h4UB5/tn/tjW7lYwrv9yrrWImHYpFbQMu1VTnaguEMG2WB99urnT 3g2jB2OAFuMC9gfKGhqklx1o9SpMlhFpK+5B52I6Asy5HrpQD73Cke6yU8ZX/3cbGXHi 54+mG2Z2WB4K74ikSvVCzrF4BSYv6GoJw+5c13UYmhvAOe8S0G1U4ulwtUmHuTsteBV+ MAEeFpkjBOjVYMrBcP5iHIA1F9PUiJ/UNMgBOvs+t2hGjpUt/7KQlaBt4JWV+B3mm5oP GW0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=VBwu/L7G; 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 l3-v6si1979092pld.519.2018.02.14.13.37.15; Wed, 14 Feb 2018 13:37:29 -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; dkim=pass header.i=@agner.ch header.s=dkim header.b=VBwu/L7G; 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 S1031516AbeBNVgW (ORCPT + 99 others); Wed, 14 Feb 2018 16:36:22 -0500 Received: from mail.kmu-office.ch ([178.209.48.109]:53415 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030501AbeBNVgV (ORCPT ); Wed, 14 Feb 2018 16:36:21 -0500 Received: from webmail.kmu-office.ch (unknown [IPv6:2a02:418:6a02::a3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id C0B3F5C0469; Wed, 14 Feb 2018 22:28:45 +0100 (CET) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Date: Wed, 14 Feb 2018 22:36:19 +0100 From: Stefan Agner To: Boris Brezillon Cc: Han Xu , 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 In-Reply-To: <20180214200537.2c043a21@bbrezillon> References: <20180206174021.5947-1-stefan@agner.ch> <20180206174021.5947-2-stefan@agner.ch> <2f28681f-c261-31f7-9f93-602f50109343@nxp.com> <20180214200537.2c043a21@bbrezillon> Message-ID: <27a3becf329c1aa8ce8b3cc99f5a4de7@agner.ch> X-Sender: stefan@agner.ch User-Agent: Roundcube Webmail/1.3.3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1518643725; bh=5y7wtUX63iSak2TVB3i7gmxOTbwi3TJvfeA0mh0h0ZQ=; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Date:From:To:Cc:Subject:In-Reply-To:References:Message-ID; b=VBwu/L7Gb369jp/iiZKj4B88BaoivF41Ya3NctsTwSPFt96gM5PLpjltYxLKxoOaCN5QE+xJPmuv5u5iePeT9Y1iXEcIpa/DBma1aiCkWkmr0FIzIaWmRYUwJCdjqJYMp4XgfrhpitwdIjQk5Nt5awoS/IRq8QV7QlZB1Z5PKzk= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14.02.2018 20:05, Boris Brezillon wrote: > On Wed, 14 Feb 2018 16:28:36 +0000 > Han Xu wrote: > >> On 02/06/2018 11:40 AM, 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 ++++ >> > 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); >> > + >> >> I was wondering how to keep, let's say u-boot, and kernel ecc setting >> aligned, if users can specify the strength and step_ds in DT? Did u-boot >> enable to get these parameters from DT? > > Both u-boot and Linux have to support using strength/step information > passed through the DT before you can start patching dts files. Anyway, > users will have to change their DT (add the nand-ecc-strength/step-size > properties) to use this feature, so they should quickly notice that > something is going wrong and update their bootloader or drop those > nand-ecc-xxx props. > Yes, the MTD stack has support for those properties also in U-Boot. But currently the GPMI NAND driver (mxs_nand) in U-Boot has no DT support. But I do have a preliminary patch set for this. Will send it out soon. -- Stefan >> > 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; >> > }