From patchwork Tue Jan 29 14:35:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10786421 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9B6531390 for ; Tue, 29 Jan 2019 14:36:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BC622C946 for ; Tue, 29 Jan 2019 14:36:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 808332C997; Tue, 29 Jan 2019 14:36:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A3D22C99E for ; Tue, 29 Jan 2019 14:36:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725911AbfA2OgG (ORCPT ); Tue, 29 Jan 2019 09:36:06 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:34328 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725769AbfA2OgG (ORCPT ); Tue, 29 Jan 2019 09:36:06 -0500 Received: by mail-lf1-f66.google.com with SMTP id p6so14830470lfc.1 for ; Tue, 29 Jan 2019 06:36:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=+nzS6nXKpopYdhb1ytlfHFQ1nVp/WMSEgcypYiMygBI=; b=Oy9TaDKHe5TXhnKcRxKTFZIZIWAdXK8sKHGwpGCFHQLTsVYGXHNSzv/6UNxhjovkTR hmUv+h9ComYNww5b3stx7PM8ci0mxh2ZvH0gkHtiKu/T4PJKj8dsK+1WzCL1XbTTjyev nTO6tZKkNFHuZYnDNfJFW5q0y3LnbDWM51Pag= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+nzS6nXKpopYdhb1ytlfHFQ1nVp/WMSEgcypYiMygBI=; b=pm9O1jIVnLySLlYcWbswMptoiMCivlVlMG77vCBxeDsSnP2JAyeTDZuhvvGkrHDHdf vv/NIvUsfZOJ21RU+ebQ8sgTyzDuMOQBzB78ynm7053ibhyPTh1V1kcqBf0WCEWXkjTk KjbQ4HFEFEubrv4y6vEBnqSpZxe0RHSxlGXnJ69Mf+Qf4drr4S1MWkif2SMSx5xRQ1MP F0aRrdt+H0fFM7NyEwQABuTmpBPyS1TE54fpPxx9+iy0JqEt3p0T1DmQSjN8UHDxFzKN /wcU11xG6a98yI5pK0vxAbijCULQtVr0ooLE9NoE3tp548z537gR09Lx7e2djU9OJiPk alHA== X-Gm-Message-State: AJcUukeIWIzaSB5ebRKYTzo6tzjZSJv+BfNM3twZ9Ar7I+VNnpkDPTmI Xk5BbznpcoL90DAjp4y7IkiZ4AkkkNg= X-Google-Smtp-Source: ALg8bN4ujRgZmBmHg0ihRZyXM2x3/Gt31mw8XEHC6urs0DUznpqXyNYz8cbC5T+5w2d6jjcM8P7MnA== X-Received: by 2002:a19:24c6:: with SMTP id k189mr20502116lfk.77.1548772563836; Tue, 29 Jan 2019 06:36:03 -0800 (PST) Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 85-v6sm3745815lja.16.2019.01.29.06.36.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 06:36:03 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Ludovic Barre Cc: Russell King , Linus Walleij Subject: [PATCH] mmc: mmci: Send a CMD12 to clear the DPSM at errors Date: Tue, 29 Jan 2019 15:35:56 +0100 Message-Id: <20190129143556.32705-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The current approach with sending a CMD12 (STOP_TRANSMISSION) to complete a data transfer request, either because of using the open-ended transmission type or because of receiving an error during a pre-defined data transfer, isn't sufficient for the STM32 sdmmc variant. More precisely, this variant needs to clear the DPSM ("Data Path State Machine") by sending a CMD12, for all failing ADTC commands. Support this, by adding a struct mmc_command inside the struct mmci_host and initialize it to a CMD12 during ->probe(). Let's also add checks for the new conditions, to enable mmci_data_irq() and mmci_cmd_irq() to postpone the calls to mmci_request_end(), but instead send the CMD12. Cc: Ludovic Barre Signed-off-by: Ulf Hansson Tested-by: Ludovic Barre --- drivers/mmc/host/mmci.c | 25 +++++++++++++++++++++++-- drivers/mmc/host/mmci.h | 1 + 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index e352f5ad5801..45b97b41601c 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1127,6 +1127,12 @@ mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c) writel(c, base + MMCICOMMAND); } +static void mmci_stop_command(struct mmci_host *host) +{ + host->stop_abort.error = 0; + mmci_start_command(host, &host->stop_abort, 0); +} + static void mmci_data_irq(struct mmci_host *host, struct mmc_data *data, unsigned int status) @@ -1196,10 +1202,16 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data, /* The error clause is handled above, success! */ data->bytes_xfered = data->blksz * data->blocks; - if (!data->stop || (host->mrq->sbc && !data->error)) + if (!data->stop) { + if (host->variant->cmdreg_stop && data->error) + mmci_stop_command(host); + else + mmci_request_end(host, data->mrq); + } else if (host->mrq->sbc && !data->error) { mmci_request_end(host, data->mrq); - else + } else { mmci_start_command(host, data->stop, 0); + } } } @@ -1298,6 +1310,10 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd, mmci_dma_error(host); mmci_stop_data(host); + if (host->variant->cmdreg_stop && cmd->error) { + mmci_stop_command(host); + return; + } } mmci_request_end(host, host->mrq); } else if (sbc) { @@ -1956,6 +1972,11 @@ static int mmci_probe(struct amba_device *dev, mmc->max_busy_timeout = 0; } + /* Prepare a CMD12 - needed to clear the DPSM on some variants. */ + host->stop_abort.opcode = MMC_STOP_TRANSMISSION; + host->stop_abort.arg = 0; + host->stop_abort.flags = MMC_RSP_R1B | MMC_CMD_AC; + mmc->ops = &mmci_ops; /* We support these PM capabilities. */ diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h index 24229097d05c..14df81054438 100644 --- a/drivers/mmc/host/mmci.h +++ b/drivers/mmc/host/mmci.h @@ -377,6 +377,7 @@ struct mmci_host { void __iomem *base; struct mmc_request *mrq; struct mmc_command *cmd; + struct mmc_command stop_abort; struct mmc_data *data; struct mmc_host *mmc; struct clk *clk;