From patchwork Wed Aug 13 15:13:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 4719371 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C48A99F377 for ; Wed, 13 Aug 2014 15:14:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EBA7E2018B for ; Wed, 13 Aug 2014 15:14:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D5426201BC for ; Wed, 13 Aug 2014 15:14:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752718AbaHMPO2 (ORCPT ); Wed, 13 Aug 2014 11:14:28 -0400 Received: from mail-oi0-f74.google.com ([209.85.218.74]:57891 "EHLO mail-oi0-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751518AbaHMPO1 (ORCPT ); Wed, 13 Aug 2014 11:14:27 -0400 Received: by mail-oi0-f74.google.com with SMTP id a141so2143527oig.1 for ; Wed, 13 Aug 2014 08:14:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=K73/4NYsU0CU4D0L4XooVS9Hewl2zutLqp2uX2XtamY=; b=Jc+rick5tv9uJMTaZRWqRUFzskZaHLGQhsVOEmsO1VkntDG9vPthyOPONteTkxRrKm 83Db6Fxiip0sKOYOTewr5vOPK/LN9lAfC/jJaXANX9OZV3v7d/K9ula50KlhaB5jtTat 66nSMdvTYwztuAiL3sV+R00ZhOCGHJy9VVbXY3N+j/s0avRNxA7TJiiadDihYS6RFrJJ LWcdLrtubgKTBJm1JFjhmxQi8+auxy2PUShi7Whv/Q/s89m9FHFGnvMckp4Tsr4G3yUQ jsuIyQ228bo2crlBgo8k0SEkSvAovZAdrmsAU3LbIDkfCmUsDu57K7BOdX9oLOEMKCeY PfVw== X-Gm-Message-State: ALoCoQkD7He1xdZHztTWlCSIxUWkqFDeDIT2qIeRaqS6mwjXjdQmrDDBsd7Pi4tQIz5BPdMCh4jE X-Received: by 10.43.1.133 with SMTP id nq5mr3245364icb.21.1407942866452; Wed, 13 Aug 2014 08:14:26 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id j43si148069yhh.5.2014.08.13.08.14.26 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Aug 2014 08:14:26 -0700 (PDT) Received: from tictac.mtv.corp.google.com (tictac.mtv.corp.google.com [172.22.162.15]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 2937831C3BF; Wed, 13 Aug 2014 08:14:26 -0700 (PDT) Received: by tictac.mtv.corp.google.com (Postfix, from userid 121310) id BC6DD80AA5; Wed, 13 Aug 2014 08:14:25 -0700 (PDT) From: Doug Anderson To: ulf.hansson@linaro.org, Chris Ball , Seungwon Jeon , Jaehoon Chung Cc: Sonny Rao , Tomasz Figa , Yuvaraj Kumar C D , linux-samsung-soc@vger.kernel.org, Doug Anderson , chris@printf.net, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [REPOST PATCH v2] mmc: dw_mmc: Make sure we don't get stuck when we get an error Date: Wed, 13 Aug 2014 08:13:43 -0700 Message-Id: <1407942823-4271-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 If we happened to get a data error at just the wrong time the dw_mmc driver could get into a state where it would never complete its request. That would leave the caller just hanging there. We fix this two ways and both of the two fixes on their own appear to fix the problems we've seen: 1. Fix a race in the tasklet where the interrupt setting the data error happens _just after_ we check for it, then we get a EVENT_XFER_COMPLETE. We fix this by repeating a bit of code. 2. Fix it so that if we detect that we've got an error in the "data busy" state and we're not going to do anything else we end the request and unblock anyone waiting. Signed-off-by: Doug Anderson Signed-off-by: Yuvaraj Kumar C D Acked-by: Seungwon Jeon --- Changes in v2: - Removed TODO - Set cmd to NULL before calling dw_mci_request_end() drivers/mmc/host/dw_mmc.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 8f216ed..7f227e9 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1299,6 +1299,14 @@ static void dw_mci_tasklet_func(unsigned long priv) /* fall through */ case STATE_SENDING_DATA: + /* + * We could get a data error and never a transfer + * complete so we'd better check for it here. + * + * Note that we don't really care if we also got a + * transfer complete; stopping the DMA and sending an + * abort won't hurt. + */ if (test_and_clear_bit(EVENT_DATA_ERROR, &host->pending_events)) { dw_mci_stop_dma(host); @@ -1312,7 +1320,29 @@ static void dw_mci_tasklet_func(unsigned long priv) break; set_bit(EVENT_XFER_COMPLETE, &host->completed_events); + + /* + * Handle an EVENT_DATA_ERROR that might have shown up + * before the transfer completed. This might not have + * been caught by the check above because the interrupt + * could have gone off between the previous check and + * the check for transfer complete. + * + * Technically this ought not be needed assuming we + * get a DATA_COMPLETE eventually (we'll notice the + * error and end the request), but it shouldn't hurt. + * + * This has the advantage of sending the stop command. + */ + if (test_and_clear_bit(EVENT_DATA_ERROR, + &host->pending_events)) { + dw_mci_stop_dma(host); + send_stop_abort(host, data); + state = STATE_DATA_ERROR; + break; + } prev_state = state = STATE_DATA_BUSY; + /* fall through */ case STATE_DATA_BUSY: @@ -1335,6 +1365,22 @@ static void dw_mci_tasklet_func(unsigned long priv) /* stop command for open-ended transfer*/ if (data->stop) send_stop_abort(host, data); + } else { + /* + * If we don't have a command complete now we'll + * never get one since we just reset everything; + * better end the request. + * + * If we do have a command complete we'll fall + * through to the SENDING_STOP command and + * everything will be peachy keen. + */ + if (!test_bit(EVENT_CMD_COMPLETE, + &host->pending_events)) { + host->cmd = NULL; + dw_mci_request_end(host, mrq); + goto unlock; + } } /*