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: 156996 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4736739jaa; Tue, 29 Jan 2019 06:36:04 -0800 (PST) X-Received: by 2002:a19:910d:: with SMTP id t13mr19973108lfd.98.1548772564426; Tue, 29 Jan 2019 06:36:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548772564; cv=none; d=google.com; s=arc-20160816; b=IxQmFux4x4N+iXw8jPsts9/tR2i95sAqSTiHIN+9aeO3bvagDCzDqUHeNsLqVpi+85 T9GDQZJ0YzwcxPWSWPu9ERNfIitiBVjnnFO7PSwcnu0LZ3TIWw9kHjMfJfbiR6ieVpKb qUvvX72L8cD7LlTCmxAM32iiGBZmTaSyIim0OIydsBKIHRaTMgD9N/lwPrnoxtqLeEUM RJ8uGlQ06tbEolRY057VVBYiV7USGxXuM84Pdu5yiT83E4QG+9ot99HXS72p1g8Unb6/ 8uOvw0+x9bYDPHQagxHh1KFd8/YHkWqjfj7rb+T4KF2PoveKlXwPMkfeo4aAlYEDQuKM ksYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=+nzS6nXKpopYdhb1ytlfHFQ1nVp/WMSEgcypYiMygBI=; b=leyrXtrqanZ840z5SILf/suva+9j3u2qodZrIoEEIRdfmUCH9gUSH/rBlAatG+u2DQ Gq6dagUh4jTqknem6uSiNlZQ6Yqv/C5jXw9rfNWSKzY9XTTYazIX26WFFw7tUey5dUtR n9eKiGYN9Z7biqTD4jhhwVRmzBEOu5PUdafApItbWlRQMomDX4ifBSj6BYNWMi+XH+PK rQsLCQseuKc6HE1Pjtl2N2AOToP71xMUoOBJwZBQO4EjtFlr42R6xXo3+nJ4bf8jpFzh sFciRM7klJhyDU8KZN/85xwkvs96zbywic2kS3xJ2eni4q11dQPxY8PSIkhjkuIb/mhf 5mbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Oy9TaDKH; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p12sor5811014lfk.37.2019.01.29.06.36.04 for (Google Transport Security); Tue, 29 Jan 2019 06:36:04 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Oy9TaDKH; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=YT1+Qc4ZYIoURzl9CQX/YXj5ZtrIQ/ATrAoiSdYiEx/vvcfGHhDi86LSRYb8rre52H 1QY6qU59yZq4LU+XttC0UMkRksHqOmgU4lpd7kWjDRJUJuMqbPvi7DMHydlebCP6zXQz xIO1GRd3my3M2KRq4hRW7bfD+1Ho4SlUznrWTAUBfUyFz7fWysS2rBTsm2T+7I6TiQA6 ciJyl07RQit0J051GtNZIokav2zehP7V8BcUP2Izt/g+E4STUI4BWygfEflK2dSSNDHQ 1DLPxdGj9wDZZGSLJugzN4oOmcKP+8nYXI8nBJoU6mWVJFRWXVMbMjeUpsat2VXr+iRM +ITA== X-Gm-Message-State: AJcUukcrg3I9Rj2mZAqeU/0G6oqp5ju26fIns+wKnp6XfI8MtWL/UbSs 2CwUUW0mBFkllc6WqrOqUiD2auP0 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) Return-Path: 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 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 --- drivers/mmc/host/mmci.c | 25 +++++++++++++++++++++++-- drivers/mmc/host/mmci.h | 1 + 2 files changed, 24 insertions(+), 2 deletions(-) -- 2.17.1 Tested-by: Ludovic Barre 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;