Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2745999ybh; Mon, 5 Aug 2019 06:12:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqw72zsP2MKbMUNHCi8lxokAUK1Mfu0UXzxr95j8ghz7mwFO1fh0X04Vpac8ERddDHJXQ8td X-Received: by 2002:a65:4509:: with SMTP id n9mr82869896pgq.133.1565010762872; Mon, 05 Aug 2019 06:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565010762; cv=none; d=google.com; s=arc-20160816; b=az46C5TB6zs/JyGlxSXas0xafTN4NTmQLinmGIVArBv+Wk7CReKBzkXEDb7MjC6ox3 uXcy98ytZYXaq52jPt+dcRbypN1z9UW3F6sTWYoYg2tQ2nTXfFshuywOUvdNlEDx4Du3 xDKCaE9bJubeU2U4EPVe2SSSKLQpI/xXh9h7839KdIxtXNVGqS2goMIEaT3HNhXRUOo7 B/07RlOcSa4BHMBPOh0ldmhh8ts/kcEZcH5C/5Dwc7MHoykBnDJ6N+gRBfiAjwMl//Tw DbrG53YpnwYOvb9u5n9Cv7vMemM0d8niche11Jr7/BKf9/DQWdcEh+W1oksaO/2loBCA bC6g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FWlxqqtwYacxnySyYZLBeqMC/Gaq1aPb7CZezpkoSEc=; b=eSfTF3+KwQ7fkjS6oqVCIKPjqv701dBTLFSntPj/z5dQIRB25zsqiuMbuOcQzDJ+JW +cmgKs7JBsf3TsTHL4c0N8rfdw23meG8Z3JkOLPdeYI0ziRMS1zoi+XfMMc7OdwhpeSA KghwptqR1edu0hr1IwXgu8OEF8548V6m6dVnLOXkJqjb8oa3y/lVw7vWvlOR3Fn0BSXZ +mhtrruB3orEGhpVpSA2lcEs6yFj2jUuZejjmTxeL/gF3X/uFwbdECNRk05itViDOtl7 dL/lylB3tuN6EMj07MiPrDa1LNADZABzNJqlllSoPmG2B5gQOUiA6ZATbhvoPsmpc8wN 9QEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VLFnHfDs; 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 v184si45149989pgv.566.2019.08.05.06.12.27; Mon, 05 Aug 2019 06:12:42 -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=@kernel.org header.s=default header.b=VLFnHfDs; 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 S1730468AbfHENLK (ORCPT + 99 others); Mon, 5 Aug 2019 09:11:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:50342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729841AbfHENLH (ORCPT ); Mon, 5 Aug 2019 09:11:07 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 45AFB216F4; Mon, 5 Aug 2019 13:11:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565010666; bh=4pL1hx2ppMTBaKCpsGaTGvaIoDclQ1WBXEy5XCKPB3Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VLFnHfDsHwnrnaI879Qcg6q6PKRRMnPdQxt/SyXMIbvYENO/fJxBj/O7pFhJyarBY iJKZAsvDSuH9E4DlqKV+Z20BRVT0T/rChq/4UVfBQkeAqECV0hVlyPylELF3zPpqQn 2WE2ykxgDUVm9eNignUtXQ6xDOmI8YUPOw+TCxNs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marco Felsch , Boris Brezillon , Miquel Raynal Subject: [PATCH 4.19 50/74] mtd: rawnand: micron: handle on-die "ECC-off" devices correctly Date: Mon, 5 Aug 2019 15:03:03 +0200 Message-Id: <20190805124939.943312281@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124935.819068648@linuxfoundation.org> References: <20190805124935.819068648@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Marco Felsch commit 8493b2a06fc5b77ef5c579dc32b12761f7b7a84c upstream. Some devices are not supposed to support on-die ECC but experience shows that internal ECC machinery can actually be enabled through the "SET FEATURE (EFh)" command, even if a read of the "READ ID Parameter Tables" returns that it is not. Currently, the driver checks the "READ ID Parameter" field directly after having enabled the feature. If the check fails it returns immediately but leaves the ECC on. When using buggy chips like MT29F2G08ABAGA and MT29F2G08ABBGA, all future read/program cycles will go through the on-die ECC, confusing the host controller which is supposed to be the one handling correction. To address this in a common way we need to turn off the on-die ECC directly after reading the "READ ID Parameter" and before checking the "ECC status". Cc: stable@vger.kernel.org Fixes: dbc44edbf833 ("mtd: rawnand: micron: Fix on-die ECC detection logic") Signed-off-by: Marco Felsch Reviewed-by: Boris Brezillon Signed-off-by: Miquel Raynal Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/raw/nand_micron.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) --- a/drivers/mtd/nand/raw/nand_micron.c +++ b/drivers/mtd/nand/raw/nand_micron.c @@ -400,6 +400,14 @@ static int micron_supports_on_die_ecc(st (chip->id.data[4] & MICRON_ID_INTERNAL_ECC_MASK) != 0x2) return MICRON_ON_DIE_UNSUPPORTED; + /* + * It seems that there are devices which do not support ECC officially. + * At least the MT29F2G08ABAGA / MT29F2G08ABBGA devices supports + * enabling the ECC feature but don't reflect that to the READ_ID table. + * So we have to guarantee that we disable the ECC feature directly + * after we did the READ_ID table command. Later we can evaluate the + * ECC_ENABLE support. + */ ret = micron_nand_on_die_ecc_setup(chip, true); if (ret) return MICRON_ON_DIE_UNSUPPORTED; @@ -408,13 +416,13 @@ static int micron_supports_on_die_ecc(st if (ret) return MICRON_ON_DIE_UNSUPPORTED; - if (!(id[4] & MICRON_ID_ECC_ENABLED)) - return MICRON_ON_DIE_UNSUPPORTED; - ret = micron_nand_on_die_ecc_setup(chip, false); if (ret) return MICRON_ON_DIE_UNSUPPORTED; + if (!(id[4] & MICRON_ID_ECC_ENABLED)) + return MICRON_ON_DIE_UNSUPPORTED; + ret = nand_readid_op(chip, 0, id, sizeof(id)); if (ret) return MICRON_ON_DIE_UNSUPPORTED;