Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4083087ybi; Tue, 18 Jun 2019 11:27:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXoFjrlDuoOrHO87PWJGq2nqrQuO5v+d0CVZOJgjBYGeZg0OhBDQEjGKGZK2dj1KGYyXR4 X-Received: by 2002:a17:90a:bc0c:: with SMTP id w12mr6192920pjr.111.1560882476293; Tue, 18 Jun 2019 11:27:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560882476; cv=none; d=google.com; s=arc-20160816; b=Ux54+qN1qsk1Rgtna+a8/Kvrib4Y3eBe9j73ZMnkR/lEa5DEgO8MbU8TI2J8IKSBQL Tv+8YXNurmrcBHXx25qlQmyH4s82ZkgyZwvEr4iBtjpWg2xAQfP1RoIa5u4ghJm/b9Xx 2UKmUmVOBPYpHR2HXCML2NlvVDdllK+hYkH+Ag/bZ1CsvLNPY8dUgpkTS0d2L3Ev4g4H jTZiZJYannRjuCKL54xWcBlxykwpBYp6vVuPPzgbQ38AKI1Yt364LX8IvHHG+qFCVMu+ Jrjqe10fIONKvk+KiGQ0onmBKCeSutLJgT60sIQgHv4sZtlKgYngDawxO3P6yeVf1oTG kcQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=f1jztib4H2AhReDzbfPoXEq38V+b/2OjoyCgjVjM/vY=; b=DCVQg7FAAzWBklbLXhmh1hM+oC26a4Ae+M4hZfTafHAlJ44ROSFWFQVx+os/jA8Z1/ uQgeGF4tNmxA0oUILXvZ05tfhObocVbeu31SbQ/Bz5LLTnMUOXlzgk0gFLqriDjo4zB6 /pqCiU4HtMOonGg7xkh1IlKazMtXnFNAoyk7sa1k+Zoz9btGxVuAVMjYMZw41JXh+niD 97eVYrK05f+bmEJMqdcthJsO7rGkJ68QkaHjj2WhIas3K3yUIzY1xzQuPM4JKP3Ay771 6/A5R/qYbHVj7OebwRfyAdCGo6MxgFqsmfFee+qO8CpgxSuWshk6y8S9CscgR9Mpb83n 94+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qQN5Ajlv; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a20si804684pgw.306.2019.06.18.11.27.40; Tue, 18 Jun 2019 11:27:56 -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=@gmail.com header.s=20161025 header.b=qQN5Ajlv; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730358AbfFRS1a (ORCPT + 99 others); Tue, 18 Jun 2019 14:27:30 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45394 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727616AbfFRS1a (ORCPT ); Tue, 18 Jun 2019 14:27:30 -0400 Received: by mail-pf1-f196.google.com with SMTP id r1so8132814pfq.12 for ; Tue, 18 Jun 2019 11:27:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f1jztib4H2AhReDzbfPoXEq38V+b/2OjoyCgjVjM/vY=; b=qQN5AjlvxoOzG6zwGQCL4kP4KMEGWQWZBJwkiUejECOHE1LzLRRze29XzBsI9kIf93 wefOzzVhaGj5tNJujkqJULJTeDydev5qgyw4XF6HkP+Ibpgb5e6/AStQywOrVor3B6/Q NVSTQ9Ja0CMVgNihdqI1lmDS6BApg51HwyNKsdR5c9azUL5XFNq17/aIFbk79uZiyHfF Gs4O7vnSFTyBoXDBJ44AMiaJCbQt5Yhz8pFgOL0ik8VWl1sTVT1QciHexbnlCrBMUC8x 7j0OXIkL1A/A+GTeaY8OC46Xt8uiz9yxPQWCIbvQhqjdc5v2YlwMMDFfGqgiE2gYZGJ+ DAEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f1jztib4H2AhReDzbfPoXEq38V+b/2OjoyCgjVjM/vY=; b=Kycnr4AGaeCLir7n7T/7RAwCD83oL9eR7nSD65lZ4j8pIQ98lUMWpCYoykWq9l924j egoM6hQGkMJTXIx4VARLvHA/HWP/1opH2qiUevxLq/YI7SSpxLjGBnww4HFSE3TZSu7v gwtURr6OGHlqYYMo26oH27oKVLoNnL0N9tKtdnSkvI1mLsKK6rXo//y1ibUvKqoKpZB/ HjRHqwvE5MuLxOXIgnxNeoD0F+gcPK54v+zydkpHoUOhRGgppAVm14zcAdJgpe5fuQqP 3hBgcLIBmfRMaHHaQTjO/dAzE21QbJ71nQ99B3b932SB+1yBQ8RB0vRkXViF1mHmcElD K9aw== X-Gm-Message-State: APjAAAXa0j2EiqMfVYYi0Hms7froQdOuRn4DpldMVm7FUJcnB9Zma4nd wH/61UHq/ulnwwNPMbtzpi0WpIhc X-Received: by 2002:a63:6883:: with SMTP id d125mr3963722pgc.281.1560882449634; Tue, 18 Jun 2019 11:27:29 -0700 (PDT) Received: from mail.broadcom.com ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id k4sm6639480pfk.42.2019.06.18.11.27.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Jun 2019 11:27:29 -0700 (PDT) From: Kamal Dasu To: linux-mtd@lists.infradead.org Cc: bcm-kernel-feedback-list@broadcom.com, linux-kernel@vger.kernel.org, Kamal Dasu , Brian Norris , Miquel Raynal , Richard Weinberger , David Woodhouse , Marek Vasut , Vignesh Raghavendra Subject: [PATCH v4 2/2] mtd: nand: raw: brcmnand: When oops in progress use pio and interrupt polling Date: Tue, 18 Jun 2019 14:26:43 -0400 Message-Id: <1560882420-727-2-git-send-email-kdasu.kdev@gmail.com> X-Mailer: git-send-email 1.9.0.138.g2de3478 In-Reply-To: <1560882420-727-1-git-send-email-kdasu.kdev@gmail.com> References: <1560882420-727-1-git-send-email-kdasu.kdev@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If mtd_oops is in progress, switch to polling during NAND command completion instead of relying on DMA/interrupts so that the mtd_oops buffer can be completely written in the assigned NAND partition. Signed-off-by: Kamal Dasu --- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 48 ++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c index 8735277..27b22d6 100644 --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c @@ -151,6 +151,7 @@ struct brcmnand_controller { u32 nand_cs_nand_xor; u32 corr_stat_threshold; u32 flash_dma_mode; + bool pio_poll_mode; }; struct brcmnand_cfg { @@ -815,6 +816,20 @@ static inline bool has_flash_dma(struct brcmnand_controller *ctrl) return ctrl->flash_dma_base; } +static inline void disable_ctrl_irqs(struct brcmnand_controller *ctrl) +{ + if (ctrl->pio_poll_mode) + return; + + if (has_flash_dma(ctrl)) { + ctrl->flash_dma_base = 0; + disable_irq(ctrl->dma_irq); + } + + disable_irq(ctrl->irq); + ctrl->pio_poll_mode = true; +} + static inline bool flash_dma_buf_ok(const void *buf) { return buf && !is_vmalloc_addr(buf) && @@ -1229,15 +1244,42 @@ static void brcmnand_cmd_ctrl(struct nand_chip *chip, int dat, /* intentionally left blank */ } +static bool brcmstb_nand_wait_for_completion(struct nand_chip *chip) +{ + struct brcmnand_host *host = nand_get_controller_data(chip); + struct brcmnand_controller *ctrl = host->ctrl; + struct mtd_info *mtd = nand_to_mtd(chip); + bool err = false; + int sts; + + if (mtd->panic_write_triggered) { + /* switch to interrupt polling and PIO mode */ + disable_ctrl_irqs(ctrl); + sts = bcmnand_ctrl_poll_status(ctrl, NAND_CTRL_RDY, + NAND_CTRL_RDY, 0); + err = (sts < 0) ? true : false; + } else { + unsigned long timeo = msecs_to_jiffies( + NAND_POLL_STATUS_TIMEOUT_MS); + /* wait for completion interrupt */ + sts = wait_for_completion_timeout(&ctrl->done, timeo); + err = (sts <= 0) ? true : false; + } + + return err; +} + static int brcmnand_waitfunc(struct nand_chip *chip) { struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_controller *ctrl = host->ctrl; - unsigned long timeo = msecs_to_jiffies(100); + bool err = false; dev_dbg(ctrl->dev, "wait on native cmd %d\n", ctrl->cmd_pending); - if (ctrl->cmd_pending && - wait_for_completion_timeout(&ctrl->done, timeo) <= 0) { + if (ctrl->cmd_pending) + err = brcmstb_nand_wait_for_completion(chip); + + if (err) { u32 cmd = brcmnand_read_reg(ctrl, BRCMNAND_CMD_START) >> brcmnand_cmd_shift(ctrl); -- 1.9.0.138.g2de3478