From patchwork Thu Nov 20 19:18:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Branden X-Patchwork-Id: 41261 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F21A225AEA for ; Thu, 20 Nov 2014 19:18:19 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id f15sf1052227lbj.3 for ; Thu, 20 Nov 2014 11:18:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=WotHGAY7grbKOH6k01pZX/fgw6BSSDkeNRaS6ip1xVk=; b=WdL07ChtNz4ZBIUqWtQa2W5pWhZNrTrsLhGhfBATpu+DGWSAUjPAm6XXUftol026I0 rk05wuSaNpHeLpjwo4+AOSYQkB3YH415fCM+t8IRlCWPGaoCY1JLZS4pYFdBNxPv6nGX IJfTzyHxRgpK9F5Y4C9ngW+So1J0q5wVtARE1dccuq/jHarb/aAOwtMcFsMI/hyyIUc+ jGbrKnKKNgjJlz5IF6S5hZWxp4jM3Fohia38nYeo/zvfsZdwuuxDFXsx4X4qfLSzSHhH KYHeJ4OFXa1neXO+0bBjkcwLuqptntN6V2zmxAYQ96tdmDxJZWoGRXspNobBUNACvT9B AsoQ== X-Gm-Message-State: ALoCoQm8YahLPLZN2AYwNV5Hzglg9PiwueLknfoyBqK/yUH5wdnmreOJJV1Co8reXXEYGBKPOinv X-Received: by 10.194.176.106 with SMTP id ch10mr17573wjc.6.1416511098572; Thu, 20 Nov 2014 11:18:18 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.1 with SMTP id lk1ls114059lac.9.gmail; Thu, 20 Nov 2014 11:18:18 -0800 (PST) X-Received: by 10.112.72.225 with SMTP id g1mr4626283lbv.75.1416511098303; Thu, 20 Nov 2014 11:18:18 -0800 (PST) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id az8si2848711lbc.132.2014.11.20.11.18.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Nov 2014 11:18:18 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id pv20so3044100lab.9 for ; Thu, 20 Nov 2014 11:18:18 -0800 (PST) X-Received: by 10.112.45.102 with SMTP id l6mr26303lbm.46.1416511098026; Thu, 20 Nov 2014 11:18:18 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp322598lbc; Thu, 20 Nov 2014 11:18:17 -0800 (PST) X-Received: by 10.70.64.134 with SMTP id o6mr32438116pds.153.1416511096407; Thu, 20 Nov 2014 11:18:16 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id mq7si4677511pdb.105.2014.11.20.11.18.15 for ; Thu, 20 Nov 2014 11:18:16 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758044AbaKTTSO (ORCPT + 26 others); Thu, 20 Nov 2014 14:18:14 -0500 Received: from mail-gw2-out.broadcom.com ([216.31.210.63]:65088 "EHLO mail-gw2-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756223AbaKTTSM (ORCPT ); Thu, 20 Nov 2014 14:18:12 -0500 X-IronPort-AV: E=Sophos;i="5.07,425,1413270000"; d="scan'208";a="51255234" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw2-out.broadcom.com with ESMTP; 20 Nov 2014 11:45:28 -0800 Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.174.1; Thu, 20 Nov 2014 11:18:38 -0800 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.3.174.1; Thu, 20 Nov 2014 11:18:21 -0800 Received: from mail.broadcom.com (lbrmn-lnxub113.ric.broadcom.com [10.136.13.65]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 0CA1D40FE9; Thu, 20 Nov 2014 11:17:43 -0800 (PST) From: Scott Branden To: Scott Branden , David Woodhouse , Brian Norris CC: Ray Jui , Corneliu Doban , , Subject: [PATCH] mtd: nand: added nand_shutdown Date: Thu, 20 Nov 2014 11:18:05 -0800 Message-ID: <1416511085-3930-1-git-send-email-sbranden@broadcom.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sbranden@broadcom.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add nand_shutdown to wait for current nand operations to finish and prevent further operations by changing the nand flash state to FL_SHUTDOWN. This is addressing a problem observed during reboot tests using UBIFS root file system: NAND erase operations that are in progress during system reboot/shutdown are causing partial erased blocks. Although UBI should be able to detect and recover from this error, this change will avoid the creation of partial erased blocks on reboot in the middle of a NAND erase operation. Signed-off-by: Scott Branden --- drivers/mtd/nand/nand_base.c | 11 +++++++++++ include/linux/mtd/nand.h | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 5b5c627..100a967 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -4236,6 +4236,17 @@ void nand_release(struct mtd_info *mtd) } EXPORT_SYMBOL_GPL(nand_release); +/** + * nand_shutdown - [NAND Interface] finish the current nand operation and + * prevent further operations + * @mtd: MTD device structure + */ +int nand_shutdown(struct mtd_info *mtd) +{ + return nand_get_device(mtd, FL_SHUTDOWN); +} +EXPORT_SYMBOL_GPL(nand_shutdown); + static int __init nand_base_init(void) { led_trigger_register_simple("nand-disk", &nand_led_trigger); diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index e4d451e..80e4367 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -48,6 +48,13 @@ extern int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len); /* unlocks specified locked blocks */ extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); +/* + * Internal helper for board drivers which need to make sure that the current + * nand operation is finished and further operations are prevented before + * rebooting the system. + */ +extern int nand_shutdown(struct mtd_info *mtd); + /* The maximum number of NAND chips in an array */ #define NAND_MAX_CHIPS 8