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: 4719361 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E987AC0338 for ; Wed, 13 Aug 2014 15:14:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D4A53201B9 for ; Wed, 13 Aug 2014 15:14:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E990F2018B for ; Wed, 13 Aug 2014 15:14:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752705AbaHMPO1 (ORCPT ); Wed, 13 Aug 2014 11:14:27 -0400 Received: from mail-oi0-f73.google.com ([209.85.218.73]:58781 "EHLO mail-oi0-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751429AbaHMPO1 (ORCPT ); Wed, 13 Aug 2014 11:14:27 -0400 Received: by mail-oi0-f73.google.com with SMTP id u20so2145367oif.4 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=H/efIVua77i4lIyqkQVqt6w/p9VYps3yUNsr3irZ8zJaWJbofD/Dw2N5u2JUwWDUm9 CtqA1fkHJo0uelJjyHTB43JsXTYsxOutfQ/KCgglUBPW8uhKIt3cxH3SFT9N4E+J6sRe UDeOXijk/RaTw/rz/6ZvCP656Lt4B99KSLurEZvUjm5vF62J3zpqX9fG6El3PyncZq84 3GF080EC8YGwZXn5wTMRGRToHyZiMFwKemuZmuTIxXm49ySi7hUwivkJTaqk/Nr9HIZY ymy/Vdsgq4cEh/a3o61jRCW85H098chDlJcGvjZVh4y+rHOE5uVB0sBtEDaogydeE42Q 0XzA== X-Gm-Message-State: ALoCoQlwH1E6rPruy9V0tAunX+Aa2rTZ97cZisBMEQXNTxHpkoqlH5Z7uubKpiJoTUO0TfRk7vjK 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-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@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=ham 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; + } } /*