Received: by 10.192.165.156 with SMTP id m28csp1620225imm; Thu, 12 Apr 2018 00:03:22 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/hNfJzQkyjptbWDFNkLBoGlNUF4OIncS2v1EtGPxFMHUvogPkEsQteUOr12IyoHQ7Yz3DJ X-Received: by 2002:a17:902:b081:: with SMTP id p1-v6mr8423995plr.31.1523516602089; Thu, 12 Apr 2018 00:03:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523516602; cv=none; d=google.com; s=arc-20160816; b=f7UhOkCfMpl0nE07gLbddEbAx7ADp5Tpk+M4L+ox0ZOkDelIAKaPt2/cBy7CKt0MWJ mlk2o/28la7pdKAkqqZr0twG84KjAoRSuCxz0I3n/9iGxdxNQtOpz+yoXrB3yxrDb784 pyD7S0A9Wtab9QwstXX1/gkvEnusBQeBk/t7BM8reYjiEKzsDLKYvn8eiltobYF2Y41H TFiBzLD3bpq5bGSlxGak5IbHftFPWGGfLmqzrOH9XRA+FebqGhOhtE3LFWl5hzyQGtm7 E+LOkbwWFe0bKEovEmUxccBR8DSvh4p9R0CvE/UTf39qw1i+BL73KBdgT+fFPg6Kk3Ad C8dQ== 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=vK+/twAnuzL/SSuUOH5Tds5lQ6kfnRgJJ09tqKZb2dA=; b=EBnzR+GlkPwKQ+BfGMqQgPwx9soUBCXUGFGsCI21j74MxbYffcNVZ5zihaAUcThulA w5zxWftLfJisjB1WK88qrU4Owc1gXPMTXtL9oTzIyVMaiUbHmABQyl1anKODZramu189 iZnTatFvboUFUBhF/XzbNnlCcvOpXOtchNcJJdlgZdzLinGs6S7dOHni0yv5DKpiCk2x QnAQ77O/lthy5hhEFOpZ6BcjnleF6TpUd+rA30UFliIHqoGQrndq7JSSzxCq/qBXgBXN fBA0G+2qdsTErInX9GJxJVb6CsfJMNFYOQPXdXxFGnw42K63tL3ohPX5XK0f5qhiJ/mh fwng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=gjkKWG9M; 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 i1si1798435pgv.591.2018.04.12.00.02.45; Thu, 12 Apr 2018 00:03:22 -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=@agner.ch header.s=dkim header.b=gjkKWG9M; 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 S1752777AbeDLG4s (ORCPT + 99 others); Thu, 12 Apr 2018 02:56:48 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:59863 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751837AbeDLG4r (ORCPT ); Thu, 12 Apr 2018 02:56:47 -0400 Received: from webmail.kmu-office.ch (unknown [IPv6:2a02:418:6a02::a3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id F27395C1799; Thu, 12 Apr 2018 08:55:55 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Date: Thu, 12 Apr 2018 08:56:45 +0200 From: Stefan Agner To: Boris Brezillon , han.xu@nxp.com Cc: boris.brezillon@free-electrons.com, max.oss.09@gmail.com, richard@nod.at, linux-kernel@vger.kernel.org, marek.vasut@gmail.com, linux-mtd@lists.infradead.org, cyrille.pitchen@wedev4u.fr, dwmw2@infradead.org Subject: Re: [PATCH v2 1/2] mtd: rawnand: gpmi: add support for specific ECC strength In-Reply-To: References: <20180304200602.11475-1-stefan@agner.ch> <20180315163620.6122d752@bbrezillon> Message-ID: X-Sender: stefan@agner.ch User-Agent: Roundcube Webmail/1.3.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1523516156; bh=vK+/twAnuzL/SSuUOH5Tds5lQ6kfnRgJJ09tqKZb2dA=; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Date:From:To:Cc:Subject:In-Reply-To:References:Message-ID; b=gjkKWG9MqyEBqanl4M+gVxk5DFnAqdq8ua+vtAilsihwhqk3sjVCNxi7zgJ5e0wczM9DRXACoUbsH/AYc0OBlbglLglaJdlxbdYqNE3zL+HkpKt1FLnYYu2ldM9RCdQaSNdqUmEDaOXXUBkQ4KilM+gu8TpVqf8m4mBmcHRk8Vc= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Han, On 15.03.2018 16:39, Stefan Agner wrote: > On March 15, 2018 4:36:20 PM GMT+01:00, Boris Brezillon > wrote: >>Hi, >> >>On Sun, 4 Mar 2018 21:06:01 +0100 >>Stefan Agner wrote: >> >>> Add support for specified ECC strength/size using device tree >>> properties nand-ecc-strength/nand-ecc-step-size. >> >>Han, we didn't hear back from you on that. Are you okay with adding >>these new properties? IIRC, you feared there would be a delta between >>u-boot and linux support. Any comment on this? U-Boot support for device tree support and the same properties is underway. -- Stefan >> >>Stephan, there's no changelog. Has anything changed in this version or >>is this just a RESEND? > > Sorry forgot that. I just split documentation and driver changes. > > -- > Stefan > >> >>Regards, >> >>Boris >> >>> >>> Signed-off-by: Stefan Agner >>> --- >>> drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 30 >>++++++++++++++++++++---------- >>> 1 file changed, 20 insertions(+), 10 deletions(-) >>> >>> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c >>b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c >>> index 61fdd733492f..d04754289c03 100644 >>> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c >>> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c >>> @@ -198,17 +198,16 @@ 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 +220,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 +229,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 +422,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; >>> }