linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: hdegoede@redhat.com (Hans de Goede)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] mmc: Wait for card_busy before starting sdio requests
Date: Tue, 22 Sep 2015 17:30:25 +0200	[thread overview]
Message-ID: <1442935826-16758-3-git-send-email-hdegoede@redhat.com> (raw)
In-Reply-To: <1442935826-16758-1-git-send-email-hdegoede@redhat.com>

Some sdio wifi chips will not work properly if we try to start new
sdio-rw requests while the device is signalling that it is busy.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/mmc/core/core.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 0520064..ced66b8 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -204,6 +204,23 @@ static void __mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
 		return;
 	}
 
+	/*
+	 * For sdio rw commands we must wait for card busy otherwise some
+	 * sdio devices won't work properly.
+	 */
+	if (mmc_is_io_op(mrq->cmd->opcode) && host->ops->card_busy) {
+		int tries = 500; /* Wait aprox 500ms at maximum */
+
+		while (host->ops->card_busy(host) && --tries)
+			mmc_delay(1);
+
+		if (tries == 0) {
+			mrq->cmd->error = -EBUSY;
+			mmc_request_done(host, mrq);
+			return;
+		}
+	}
+
 	host->ops->request(host, mrq);
 }
 
-- 
2.4.3

  parent reply	other threads:[~2015-09-22 15:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-22 15:30 [PATCH 0/3] mmc: Wait for card_busy before starting sdio requests Hans de Goede
2015-09-22 15:30 ` [PATCH 1/3] mmc: Add mmc_is_io_op helper function Hans de Goede
2015-09-22 15:30 ` Hans de Goede [this message]
2015-09-22 15:30 ` [PATCH 3/3] mmc: sunxi: Add card busy detection Hans de Goede
2015-09-23 21:43 ` [PATCH 0/3] mmc: Wait for card_busy before starting sdio requests Ulf Hansson
2015-09-24  9:19   ` Hans de Goede
2015-09-24 11:18     ` Arend van Spriel
2015-09-24 16:04     ` Doug Anderson
2015-09-25  5:35       ` Jaehoon Chung
2015-09-25  7:53       ` Hans de Goede
2015-09-25  9:37         ` Jaehoon Chung
2015-09-25  9:41           ` Hans de Goede
2015-09-25  9:58             ` Jaehoon Chung
2015-09-25 10:06               ` Hans de Goede
2015-09-25 10:23                 ` Jaehoon Chung
2015-09-25 16:14         ` Doug Anderson
2015-09-29 12:58           ` Hans de Goede
2015-09-29 17:38             ` Doug Anderson

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=1442935826-16758-3-git-send-email-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).