Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3701646imu; Mon, 28 Jan 2019 09:16:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN6KK7TQ+ilpfRj7np6+pdWYrNEZ8VVWyCVG34ZdJbIO7JCj1h24eHYcEqFNjqxVFNpI8b0m X-Received: by 2002:a62:6143:: with SMTP id v64mr22662712pfb.142.1548695817284; Mon, 28 Jan 2019 09:16:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548695817; cv=none; d=google.com; s=arc-20160816; b=DTJCfb0Eii7F5k8MmDEY4Pxht2xhH6sq8aa/dvISkpy2co8tZUu4D2hI11Zybarb9L egAEJDY7dauJpUjY0587aTYxVPfmAQC32pMGnJ1do6RFmOUa742CQyAck1ec7hM3iQvS IPbfJn4TXhIYEDyH9yARs6aEQ1WqaeHCOQLcsh0YlBU8YfwtCIOy+A1G4fceOvqAPzqP Y+pbYY7PN9xXTg8ewxlzod3oqwdNl0QPsQiux8gHpCMs82KHEa30RewDZ7efQr0r2rEK n2c3PeKAY7IhFWtUiNntuxaAZ81JnjJLP3bSBVtHf3/a9NYcGEF+WvMlQHcATWdaOZft Ux+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VlpE4SQdvyOURPgqNjoocZYllc9sP8IgOazujk9lDhc=; b=aIJxb2qiL81YJyXMfMvMEQ3YOBELG+WELTE1exyWBvbuvKcB3mzXys435ek2q9p13H WN8LkO5PeBF/dy8Cm5nKnZbdPKopqu58fM77PbIlMcGnUioiejdKQ30kEsz3mz1RWe2f fbANnhN9De6O9dYcO38J8KEzVAMFtOEu57m66hndF6W65bScLIO0zEUm17N5nzFnJJ9o s8wZlcvuj2FTil2JihNQ6IaCLOmwGlphMk64TCE8MJMUHnD+KUXQ6h+xi8RdHB7wwpvb Atf3HybMyVKdvl3emMMnF29o24WQhG5cAeVNnrQ0GaKEuSmfuJDWEVqCcQzIpGJZo4Vu /68Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=azHVl2dw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 66si14635523plc.125.2019.01.28.09.16.42; Mon, 28 Jan 2019 09:16:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=azHVl2dw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732029AbfA1QGb (ORCPT + 99 others); Mon, 28 Jan 2019 11:06:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:55374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727985AbfA1QG3 (ORCPT ); Mon, 28 Jan 2019 11:06:29 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3A11821738; Mon, 28 Jan 2019 16:06:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691588; bh=Xh9oBqZwuPzJcsNL1oJvb/evRqXbv2pdvg0Yi85km6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=azHVl2dwDd8KkVbBuWPlNtIUb3DUEFzNhF22qXudfAv/CxNTaM5flmwksEndSqa0U 2yBBOtwgGY78SLTDsSFmFv62pWwro4Fr7bfhb65n4mFRWi3tms5W0lhWZkR6uyNeXE oQ71M0ziPqPSoFiFhZ/w2rLDYMKbxM+WNIZcgSjU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Phil Elwell , Stefan Wahren , Ulf Hansson , Sasha Levin , linux-mmc@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 151/258] mmc: bcm2835: Recover from MMC_SEND_EXT_CSD Date: Mon, 28 Jan 2019 10:57:37 -0500 Message-Id: <20190128155924.51521-151-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Phil Elwell [ Upstream commit 07d405769afea5718529fc9e341f0b13b3189b6f ] If the user issues an "mmc extcsd read", the SD controller receives what it thinks is a SEND_IF_COND command with an unexpected data block. The resulting operations leave the FSM stuck in READWAIT, a state which persists until the MMC framework resets the controller, by which point the root filesystem is likely to have been unmounted. A less heavyweight solution is to detect the condition and nudge the FSM by asserting the (self-clearing) FORCE_DATA_MODE bit. Link: https://github.com/raspberrypi/linux/issues/2728 Signed-off-by: Phil Elwell Signed-off-by: Stefan Wahren Acked-by: Eric Anholt Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/mmc/host/bcm2835.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c index 768972af8b85..aef40e1739ee 100644 --- a/drivers/mmc/host/bcm2835.c +++ b/drivers/mmc/host/bcm2835.c @@ -772,6 +772,8 @@ static void bcm2835_finish_command(struct bcm2835_host *host) if (!(sdhsts & SDHSTS_CRC7_ERROR) || (host->cmd->opcode != MMC_SEND_OP_COND)) { + u32 edm, fsm; + if (sdhsts & SDHSTS_CMD_TIME_OUT) { host->cmd->error = -ETIMEDOUT; } else { @@ -780,6 +782,13 @@ static void bcm2835_finish_command(struct bcm2835_host *host) bcm2835_dumpregs(host); host->cmd->error = -EILSEQ; } + edm = readl(host->ioaddr + SDEDM); + fsm = edm & SDEDM_FSM_MASK; + if (fsm == SDEDM_FSM_READWAIT || + fsm == SDEDM_FSM_WRITESTART1) + /* Kick the FSM out of its wait */ + writel(edm | SDEDM_FORCE_DATA_MODE, + host->ioaddr + SDEDM); bcm2835_finish_request(host); return; } -- 2.19.1