mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Irina Tirdea <irina.tirdea@intel.com>
To: Anton Vorontsov <cbouatmailru@gmail.com>,
	Colin Cross <ccross@android.com>,
	Kees Cook <keescook@chromium.org>,
	Tony Luck <tony.luck@intel.com>, Chris Ball <cjb@laptop.org>
Cc: linux-kernel@vger.kernel.org,
	Adrian Hunter <adrian.hunter@intel.com>,
	Octavian Purdila <octavian.purdila@intel.com>,
	Irina Tirdea <irina.tirdea@intel.com>
Subject: [PATCH 25/26] mmc: sdhci: panic write: trap nonpanic tasks
Date: Tue, 23 Oct 2012 16:48:23 +0300	[thread overview]
Message-ID: <1351000104-13015-26-git-send-email-irina.tirdea@intel.com> (raw)
In-Reply-To: <1351000104-13015-1-git-send-email-irina.tirdea@intel.com>

From: Adrian Hunter <adrian.hunter@intel.com>

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
---
 drivers/mmc/host/sdhci.c  |   47 +++++++++++++++++++++++++++++++++++++++++----
 include/linux/mmc/sdhci.h |    1 +
 2 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 9a24417..db12fad 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2204,8 +2204,12 @@ static void sdhci_panic_cleanup(struct mmc_host *mmc)
 
 void sdhci_lock(struct sdhci_host *host)
 {
-	if (mmc_am_panic_task(host->mmc))
-		return;
+	if (mmc_panic_task_active(host->mmc)) {
+		if (mmc_am_panic_task(host->mmc))
+			return;
+		while (mmc_am_nonpanic_task(host->mmc))
+			cpu_relax();
+	}
 	spin_lock(&host->lock);
 }
 
@@ -2219,8 +2223,12 @@ void _sdhci_lock_irqsave(struct sdhci_host *host, unsigned long *flags_ptr)
 {
 	unsigned long flags;
 
-	if (mmc_am_panic_task(host->mmc))
-		return;
+	if (mmc_panic_task_active(host->mmc)) {
+		if (mmc_am_panic_task(host->mmc))
+			return;
+		while (mmc_am_nonpanic_task(host->mmc))
+			cpu_relax();
+	}
 
 	spin_lock_irqsave(&host->lock, flags);
 	*flags_ptr = flags;
@@ -2235,6 +2243,16 @@ void sdhci_unlock_irqrestore(struct sdhci_host *host, unsigned long flags)
 static void sdhci_panic_begin(struct mmc_host *mmc)
 {
 	struct sdhci_host *host = mmc_priv(mmc);
+	int i;
+
+	/* Wait a bit for other users to go away */
+	for (i = 0; i < 10000; i++) {
+		if (spin_trylock(&host->lock)) {
+			host->locked = 1;
+			break;
+		}
+		udelay(1);
+	}
 
 	if (host->runtime_suspended)
 		sdhci_runtime_resume_host(host);
@@ -2250,6 +2268,10 @@ static void sdhci_panic_end(struct mmc_host *mmc)
 
 	ier = sdhci_readl(host, SDHCI_INT_ENABLE);
 	sdhci_writel(host, ier, SDHCI_SIGNAL_ENABLE);
+	if (host->locked) {
+		host->locked = 0;
+		spin_unlock(&host->lock);
+	}
 }
 
 static const struct mmc_panic_ops sdhci_pops = {
@@ -2368,6 +2390,9 @@ static void sdhci_timeout_timer(unsigned long data)
 
 	host = (struct sdhci_host*)data;
 
+	if (mmc_am_nonpanic_task(host->mmc))
+		return;
+
 	sdhci_lock_irqsave(host, flags);
 
 	if (host->mrq) {
@@ -2399,6 +2424,9 @@ static void sdhci_tuning_timer(unsigned long data)
 
 	host = (struct sdhci_host *)data;
 
+	if (mmc_am_nonpanic_task(host->mmc))
+		return;
+
 	sdhci_lock_irqsave(host, flags);
 
 	host->flags |= SDHCI_NEEDS_RETUNING;
@@ -2596,6 +2624,9 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
 	u32 intmask, unexpected = 0;
 	int cardint = 0, max_loops = 16;
 
+	if (mmc_am_nonpanic_task(host->mmc))
+		return IRQ_HANDLED;
+
 	sdhci_lock(host);
 
 
@@ -2713,6 +2744,8 @@ int sdhci_suspend_host(struct sdhci_host *host)
 	if (host->ops->platform_suspend)
 		host->ops->platform_suspend(host);
 
+	mmc_trap_nonpanic_tasks(host->mmc);
+
 	sdhci_disable_card_detection(host);
 
 	/* Disable tuning since we are suspending */
@@ -2745,6 +2778,8 @@ int sdhci_resume_host(struct sdhci_host *host)
 {
 	int ret;
 
+	mmc_trap_nonpanic_tasks(host->mmc);
+
 	if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA)) {
 		if (host->ops->enable_dma)
 			host->ops->enable_dma(host);
@@ -2820,6 +2855,8 @@ int sdhci_runtime_suspend_host(struct sdhci_host *host)
 	unsigned long flags;
 	int ret = 0;
 
+	mmc_trap_nonpanic_tasks(host->mmc);
+
 	/* Disable tuning since we are suspending */
 	if (host->flags & SDHCI_USING_RETUNING_TIMER) {
 		del_timer_sync(&host->tuning_timer);
@@ -2845,6 +2882,8 @@ int sdhci_runtime_resume_host(struct sdhci_host *host)
 	unsigned long flags;
 	int ret = 0, host_flags = host->flags;
 
+	mmc_trap_nonpanic_tasks(host->mmc);
+
 	if (host_flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA)) {
 		if (host->ops->enable_dma)
 			host->ops->enable_dma(host);
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index 873e41d..13cc598 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -173,6 +173,7 @@ struct sdhci_host {
 	struct timer_list	tuning_timer;	/* Timer for tuning */
 
 #ifdef CONFIG_MMC_BLOCK_PANIC_WRITE
+	int			locked;		/* panic task has the lock */
 	void			*panic_buf;	/* buffer for panic requests */
 	size_t			panic_bufsize;	/* panic buffer size */
 	dma_addr_t		panic_dma_addr;	/* panic buffer dma address */
-- 
1.7.9.5


  parent reply	other threads:[~2012-10-23 13:44 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-23 13:47 [PATCH 00/26] pstore, mmc: add mmc as backend for pstore Irina Tirdea
2012-10-23 13:47 ` [PATCH 01/26] pstore: allow for big files Irina Tirdea
2012-10-23 16:48   ` Kees Cook
2012-10-25  8:54     ` Tatulea, Dragos
2012-10-23 13:48 ` [PATCH 02/26] pstore: add flags Irina Tirdea
2012-10-23 16:54   ` Kees Cook
2012-10-23 16:57     ` Luck, Tony
2012-10-25 11:25       ` Tatulea, Dragos
2012-10-23 13:48 ` [PATCH 03/26] pstore: add flush Irina Tirdea
2012-10-23 16:50   ` Kees Cook
2012-10-23 13:48 ` [PATCH 04/26] blkoops: add a block device oops / panic logger Irina Tirdea
2012-10-23 13:48 ` [PATCH 05/26] block: add panic write Irina Tirdea
2012-10-23 13:48 ` [PATCH 06/26] mmc: block: add panic write support Irina Tirdea
2012-10-23 13:48 ` [PATCH 07/26] mmc: panic write: bypass host claiming Irina Tirdea
2012-10-23 13:48 ` [PATCH 08/26] mmc: panic write: bypass request completion Irina Tirdea
2012-10-23 13:48 ` [PATCH 09/26] mmc: panic write: suppress host not claimed warnings Irina Tirdea
2012-10-23 13:48 ` [PATCH 10/26] mmc: panic write: do not msleep Irina Tirdea
2012-10-23 13:48 ` [PATCH 11/26] mmc: panic write: bypass clock gating Irina Tirdea
2012-10-23 13:48 ` [PATCH 12/26] mmc: panic write: bypass regulators Irina Tirdea
2012-10-23 13:48 ` [PATCH 13/26] mmc: panic write: trap non panic tasks Irina Tirdea
2012-10-23 13:48 ` [PATCH 14/26] mmc: panic write: bypass bus ref locking Irina Tirdea
2012-10-23 13:48 ` [PATCH 15/26] mmc: sdhci: panic write: bypass spin lock Irina Tirdea
2012-10-23 13:48 ` [PATCH 16/26] mmc: sdhci: panic write: no sleeping Irina Tirdea
2012-10-23 13:48 ` [PATCH 17/26] mmc: sdhci: panic write: call tasklets inline Irina Tirdea
2012-10-23 13:48 ` [PATCH 18/26] mmc: sdhci: panic write: no timeout timer Irina Tirdea
2012-10-23 13:48 ` [PATCH 19/26] mmc: sdhci: panic write: no runtime pm Irina Tirdea
2012-10-23 13:48 ` [PATCH 20/26] mmc: sdhci: panic write: no tuning Irina Tirdea
2012-10-23 13:48 ` [PATCH 21/26] mmc: sdhci: panic write: poll interrupts Irina Tirdea
2012-10-23 13:48 ` [PATCH 22/26] mmc: sdhci: panic write: no dma mapping Irina Tirdea
2012-10-23 13:48 ` [PATCH 23/26] mmc: sdhci: panic write: resume suspended host Irina Tirdea
2012-10-23 13:48 ` [PATCH 24/26] mmc: sdhci: panic write: abort request in progress Irina Tirdea
2012-10-23 13:48 ` Irina Tirdea [this message]
2012-10-23 13:48 ` [PATCH 26/26] mmc: sdhci-pci: add panic write support Irina Tirdea
2012-10-29 20:28 ` [PATCH 00/26] pstore, mmc: add mmc as backend for pstore Kirill A. Shutemov
2012-10-29 20:50   ` Chris Ball

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1351000104-13015-26-git-send-email-irina.tirdea@intel.com \
    --to=irina.tirdea@intel.com \
    --cc=adrian.hunter@intel.com \
    --cc=cbouatmailru@gmail.com \
    --cc=ccross@android.com \
    --cc=cjb@laptop.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=octavian.purdila@intel.com \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®