From patchwork Mon Mar 19 13:47:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 887713 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Te2IyzuP"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 404crN18yjz9sWW for ; Tue, 20 Mar 2018 00:49:56 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=8cCSehd3YKBkv8Q2NLmuOos/7JxfCkhNJSzmiDOrjao=; b=Te2IyzuPwmZv67 OKPFLbgj6AJk82TPyX9L4M1MvkA4HeF33kiTBWw0QZBPNE1WInJ9GbpWvjmOHyBSde2lP6uTiF9Tw 3o6lYZfORJZi5pWzxccNT8Re7azlvUJsRfjzflS7BxB50RlXj6HMQZnuLiwyOe7NJqui9FoiF+wIW RsnWDnnqVjdvu2317X+eY0N/uswKil2LCbDm25JwUff1TBWrLdFSuZ3O0cWuvURZQHQCZROQo0e2y hPO90MyhaqeHuWLCChPVgvu5q1m+c4yTIjBIQ3dDtM+SDDtpVXSY2RpFgDMAzn5y7zrabmarkWZav 4kL95V89BhHGxGhhSNVQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1exvAZ-0005RT-Iv; Mon, 19 Mar 2018 13:49:47 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1exv9F-0004dS-Qv for linux-mtd@lists.infradead.org; Mon, 19 Mar 2018 13:48:30 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id EDAD2207E5; Mon, 19 Mar 2018 14:48:13 +0100 (CET) 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 shortcircuit=ham autolearn=disabled version=3.4.0 Received: from xps13.event.rightround.com (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.bootlin.com (Postfix) with ESMTPSA id 6F32A2064B; Mon, 19 Mar 2018 14:48:13 +0100 (CET) From: Miquel Raynal To: Boris Brezillon , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut Subject: [PATCH v5 00/14] Improve timings handling in the NAND framework Date: Mon, 19 Mar 2018 14:47:17 +0100 Message-Id: <20180319134731.22605-1-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180319_064826_253716_C20FDD03 X-CRM114-Status: GOOD ( 24.53 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jocelyncarroue@macronix.com, juliensu@mxic.com.tw, Stefan Agner , linux-mtd@lists.infradead.org, Miquel Raynal , Han Xu Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Hello, This series evolves how GET/SET_FEATURES operations are handled by the NAND core by adding two helpers that should be called instead of calling directly the ->onfi_get/set_feature() hooks. Then, the parameter page that was always allocated no matter if the NAND core could make use of it is dropped. Instead, a much smaller structure is embedded in the nand_chip structure and just stores the information that will be useful for the core. Future enhancements of the core that will need more information will just have to add a new entry in this structure and fill it during the detection phase. A bitmap is used to know which optional feature is actually supported. This give the possibility in vendor code to overload this bitmap and force the addition/removal of supported features in the list, depending for instance on the NAND chip currently being used. This new possibility is effectively used for Macronix NAND chip MX30LF2G18AC. This chip supports natively the timing mode 5, and its parameter page indicates that it supports GET/SET_FEATURES on timing modes, while in reality it does not. Removing this feature from the supported bitmap makes it usable at high speed instead of unnecessarily limiting it to timing mode 0. Thank you, Miquèl Changes since v4: ================= - As discussed internally: the controller can return -ENOTSUP during a set/get_features() while the this error cas come from a lack of support from the NAND chip itself as well. For most cases these errors can be mixed and an error must be returned. However, when it comes to timings, both errors should be handled differently: if the controller cannot do the operation, an error should be returned and the timings left unchanged. If the NAND chip does not support the operation, as explained all along this series, this is not an actual error and we should continue the operation. This is handled in this version of the series in nand_setup_data_interface(): if the NAND chip does not support the operation, nand_get/set_features() calls are skipped. Otherwise, any error from nand_get/set_features() is an actual error and leads to the error path. Changes since v3: ================= - Fixed commit log of patch "check ONFI timings have been acked by the chip" - Squashed patch that renamed the ->seg/get_features() local hooks in the mxc driver into the patch that renames these hooks. - Moved patch introducing the nand_set/get_features() helpers earlier to avoid modifiying twice nand_setup_data_interface(). - s/memcpy/strncpy/ around the model name to avoid possible overflows. - Added kernel-doc documentation. - Renamed the "onfi_params" entry in the nand_parameters structure as "onfi". Changes since v2: ================= - Squashed the series with another preparation series not yet merged about GPMI timings improvements. Core patches are here now, while a second series with only GPMI-related changes will be sent very soon. - s/support_setting_features/supports_set_get_features/ - Used a bitmap for set_features and another for get_features. - Removed repetiting setting the timings mode parameters bit in the supported features bitmap in Micron driver. - Split the commit removing the parameter pages in three (one that adds the new structure, one that get rid of JEDEC parameter page, one that get rid of ONFI parameter page). - Moved the ONFI-specific fields in the nand_parameters structure into an onfi_parameters structure within it. It is statically allocated today, and will move to dynamic allocation in the near future. - Removed the __packed attribute on the nand_parameters structure. Changes since v1: ================= - Some changes, a bit unrelated to what we try to achieve here have been moved to the series that prepares this one. - Change the formula in Macronix code that determines if we are dealing with the failing chip. Miquel Raynal (14): mtd: rawnand: rename default ->onfi_get/set_features() implementations mtd: rawnand: rename SET/GET FEATURES related functions mtd: rawnand: use wrappers to call onfi GET/SET_FEATURES mtd: rawnand: handle differently chip/controller errors about timings mtd: rawnand: mxc: remove useless checks in GET/SET_FEATURES functions mtd: rawnand: move calls to ->select_chip() in nand_setup_data_interface() mtd: rawnand: check ONFI timings have been acked by the chip mtd: rawnand: avoid setting again the timings to mode 0 after a reset mtd: rawnand: prepare the removal of ONFI/JEDEC parameter pages mtd: rawnand: prepare the removal of the ONFI parameter page mtd: rawnand: allow vendors to declare (un)supported features mtd: rawnand: macronix: nack the support of changing timings for one chip mtd: rawnand: get rid of the JEDEC parameter page in nand_chip mtd: rawnand: get rid of the ONFI parameter page in nand_chip drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c | 4 +- drivers/mtd/nand/raw/cafe_nand.c | 4 +- drivers/mtd/nand/raw/docg4.c | 4 +- drivers/mtd/nand/raw/fsl_elbc_nand.c | 4 +- drivers/mtd/nand/raw/fsl_ifc_nand.c | 4 +- drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c | 8 +- drivers/mtd/nand/raw/hisi504_nand.c | 4 +- drivers/mtd/nand/raw/mpc5121_nfc.c | 4 +- drivers/mtd/nand/raw/mxc_nand.c | 24 +- drivers/mtd/nand/raw/nand_base.c | 286 ++++++++++++++++------- drivers/mtd/nand/raw/nand_macronix.c | 13 ++ drivers/mtd/nand/raw/nand_micron.c | 39 ++-- drivers/mtd/nand/raw/nand_timings.c | 10 +- drivers/mtd/nand/raw/qcom_nandc.c | 4 +- drivers/mtd/nand/raw/sh_flctl.c | 4 +- drivers/staging/mt29f_spinand/mt29f_spinand.c | 4 +- include/linux/mtd/rawnand.h | 96 ++++---- 17 files changed, 330 insertions(+), 186 deletions(-)