From patchwork Sun Sep 20 19:45:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 7226651 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A9CF99F695 for ; Sun, 20 Sep 2015 19:46:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EA27220760 for ; Sun, 20 Sep 2015 19:46:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0CDD3209D9 for ; Sun, 20 Sep 2015 19:46:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755243AbbITTqQ (ORCPT ); Sun, 20 Sep 2015 15:46:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35121 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755096AbbITTqO (ORCPT ); Sun, 20 Sep 2015 15:46:14 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 1B33B8EA21; Sun, 20 Sep 2015 19:46:14 +0000 (UTC) Received: from localhost.localdomain.com (vpn1-5-111.ams2.redhat.com [10.36.5.111]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8KJk4Fn019752; Sun, 20 Sep 2015 15:46:11 -0400 From: Hans de Goede To: Chris Ball , Ulf Hansson Cc: Maxime Ripard , linux-mmc@vger.kernel.org, linux-sunxi@googlegroups.com, Hans de Goede Subject: [PATCH RFC 2/3] mmc: Wait for card_busy before starting sdio requests Date: Sun, 20 Sep 2015 15:45:57 -0400 Message-Id: <1442778358-7491-3-git-send-email-hdegoede@redhat.com> In-Reply-To: <1442778358-7491-1-git-send-email-hdegoede@redhat.com> References: <1442778358-7491-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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); }