Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3007001imm; Sun, 1 Jul 2018 10:10:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe+4NNqriLrs9juL6GZjva0E0zz5m8UAjt3bI4mBLAk0i+Cn/+8IGcJ7uyETvCdvMDQP9Xt X-Received: by 2002:a62:3687:: with SMTP id d129-v6mr22222486pfa.137.1530465005760; Sun, 01 Jul 2018 10:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530465005; cv=none; d=google.com; s=arc-20160816; b=UCNKUBbFYOrHfBH/GKKhoBqmTBcNVKJs5a57YlR2G8GV2mUYpbxGcGZ2itligh6Xfj cLIFlukmm6C0TAiYkRdhpss6ndxm98KdkM8I/9QE3n022lE19Ek8R+wOus+Mbc+U09Kt RlkbF10r3XGqP4PvJUERBqtcE7rFDiQV0B98Hm/HeEQiqOgZ3d7CFVMkbm1UekeB+O2B +IRxsb422IVuSMFo24xpZVRcBG1Bf7KIFbksFiEOX7bzcLbQF11FqOhVwyiCvUrgH1uB IJcdrCprdhVdHmxDcR8seytJeTFUIKwAaC/XwABXZyBnhFu8gPdLI/rZjOWQklLtSEsp XQsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=dQ/U7BViIKiKBBPz2Wor/ee9fLSc3AICzyD9BywviqI=; b=p+M2yH8etyZ2pF8GywItCtyYgEO91HDGuZDH6T3a0nQM1VnM7LxpT6fWgHPJ66xAp7 5cLFMUz9r1IVBV0dmmfvBbS8M6LkoI82i9VTF9A89RNu1xF3FBbfFEW+vfGkIVVuesuM Uo4lFp46AE3V9+iySNSyn4jIPVghUGoBUIFtVrD+LOv9u55ZMDYq1JCnnulXvlvvj4WX dlNB3TBUTijAmrkk8b3cQcgwu61TARQe527fS02rY9euu7l3X+5XjDfr66iOIxmEfY9j rwUSKuqFP0sM7Of+CEKZjqggm7fRwYvheuj5RwFVgstoo/8ScsjjW72BvMKbHX2M92Sh +WAw== 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 h2-v6si14587322pls.245.2018.07.01.10.09.51; Sun, 01 Jul 2018 10:10:05 -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; 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 S934055AbeGARJC (ORCPT + 99 others); Sun, 1 Jul 2018 13:09:02 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37378 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031802AbeGAQl0 (ORCPT ); Sun, 1 Jul 2018 12:41:26 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9B89EACC; Sun, 1 Jul 2018 16:41:25 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mason Yang , Boris Brezillon , Miquel Raynal Subject: [PATCH 4.17 105/220] mtd: rawnand: All AC chips have a broken GET_FEATURES(TIMINGS). Date: Sun, 1 Jul 2018 18:22:09 +0200 Message-Id: <20180701160912.778392924@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mason Yang commit fe3dd97dd66bb7fb23b8077a3803d2f951e60b00 upstream. Make sure we flag all broken chips as not supporting this feature. Also move this logic to a new function to keep things readable. Fixes: 34c5c01e0c8c ("mtd: rawnand: macronix: nack the support of changing timings for one chip") Cc: Signed-off-by: Mason Yang Signed-off-by: Boris Brezillon Reviewed-by: Miquel Raynal Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/raw/nand_macronix.c | 48 ++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 12 deletions(-) --- a/drivers/mtd/nand/raw/nand_macronix.c +++ b/drivers/mtd/nand/raw/nand_macronix.c @@ -17,23 +17,47 @@ #include +/* + * Macronix AC series does not support using SET/GET_FEATURES to change + * the timings unlike what is declared in the parameter page. Unflag + * this feature to avoid unnecessary downturns. + */ +static void macronix_nand_fix_broken_get_timings(struct nand_chip *chip) +{ + unsigned int i; + static const char * const broken_get_timings[] = { + "MX30LF1G18AC", + "MX30LF1G28AC", + "MX30LF2G18AC", + "MX30LF2G28AC", + "MX30LF4G18AC", + "MX30LF4G28AC", + "MX60LF8G18AC", + }; + + if (!chip->parameters.supports_set_get_features) + return; + + for (i = 0; i < ARRAY_SIZE(broken_get_timings); i++) { + if (!strcmp(broken_get_timings[i], chip->parameters.model)) + break; + } + + if (i == ARRAY_SIZE(broken_get_timings)) + return; + + bitmap_clear(chip->parameters.get_feature_list, + ONFI_FEATURE_ADDR_TIMING_MODE, 1); + bitmap_clear(chip->parameters.set_feature_list, + ONFI_FEATURE_ADDR_TIMING_MODE, 1); +} + static int macronix_nand_init(struct nand_chip *chip) { if (nand_is_slc(chip)) chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; - /* - * MX30LF2G18AC chip does not support using SET/GET_FEATURES to change - * the timings unlike what is declared in the parameter page. Unflag - * this feature to avoid unnecessary downturns. - */ - if (chip->parameters.supports_set_get_features && - !strcmp("MX30LF2G18AC", chip->parameters.model)) { - bitmap_clear(chip->parameters.get_feature_list, - ONFI_FEATURE_ADDR_TIMING_MODE, 1); - bitmap_clear(chip->parameters.set_feature_list, - ONFI_FEATURE_ADDR_TIMING_MODE, 1); - } + macronix_nand_fix_broken_get_timings(chip); return 0; }