Received: by 10.213.65.68 with SMTP id h4csp907162imn; Tue, 27 Mar 2018 10:58:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Ls/CKIuthnT3c9NZPPsHiRhTIyq3wI5bFkzPmdnvGlXPNVs5uLqZa/h0LPVbffLvjQu2+ X-Received: by 10.98.131.75 with SMTP id h72mr250532pfe.166.1522173526867; Tue, 27 Mar 2018 10:58:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522173526; cv=none; d=google.com; s=arc-20160816; b=tcfoTojpwmfRIg4tLT6ZvvDyBz2I3+h26hvoBHx6oBY82iSeI46w9Um3TbwIJVneew PWJ0OAyTLYBRMSBu3LfFFSO49geEY4fYK0I05ANM1JkhBxoQQPk5Dy+dzM41G4Cu+2BQ zSzze6ETYXFphYkRoxrJTkAcva6QGlBZ0b7hXjmb4YQzZVMrjjMOZnsHGaK6A6MLqkSI +TVZPfahHSySDOsSjUdLdgVkh2/iOlmWlnhHIfdMYlO5e7Ib2gSlVw2tuNm0G5OKOvp6 XrrOCBp1HVAoNCPkM+UIl0FOmrTh2lj/Cp5j5yEIrEJdpVcdi5s6PLaC729AfJjAxbU8 VTOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=M7zklXPaVcAR2m2aCok14URe/0A8YwDFkat3NbW2W0k=; b=fN7msZ64nfl/1eYCWEwLOiM0CguFp3fKrercwkyH+AaDt4WZCrORiwMyS66IIc2kLv OztWNx4OgDpzGk2BxhwiSgs/I3VpwA1QC3a4Oli2ogqWvXkRd2rfuS/HZRxhIgdiXUbM Bs4JAVbclcFDFRQX5MV7EOp+b0yNFZiPOW1gz7m6VT6+Mi/ZggLNorgyFDXHJjMtbIvs qAEATlfxB6/r+sBhA+7hamMwRdAhakEL/YPmY5DbleKbXHGlasuv1zU/WwjMlM4gZa9c s54eNJmCdbz6XBbgSJOY08sAplEqzbHlM9URZJBb1HqU9Vw7CYndpwXrmE2oR04Ku1Pe Xf1A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t23-v6si1654389ply.482.2018.03.27.10.58.31; Tue, 27 Mar 2018 10:58:46 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753259AbeC0QbF (ORCPT + 99 others); Tue, 27 Mar 2018 12:31:05 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42772 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753240AbeC0QbC (ORCPT ); Tue, 27 Mar 2018 12:31:02 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 12016CF9; Tue, 27 Mar 2018 16:31:02 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Evgeniy Didin , Jaehoon Chung , Ulf Hansson , Andy Shevchenko , Jisheng Zhang , Shawn Lin , Alexey Brodkin , Eugeniy Paltsev , linux-snps-arc@lists.infradead.org Subject: [PATCH 4.9 07/67] mmc: dw_mmc: fix falling from idmac to PIO mode when dw_mci_reset occurs Date: Tue, 27 Mar 2018 18:26:59 +0200 Message-Id: <20180327162727.087079723@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162726.702411083@linuxfoundation.org> References: <20180327162726.702411083@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Evgeniy Didin commit 47b7de2f6c18f75d1f2716efe752cba43f32a626 upstream. It was found that in IDMAC mode after soft-reset driver switches to PIO mode. That's what happens in case of DTO timeout overflow calculation failure: 1. soft-reset is called 2. driver restarts dma 3. descriptors states are checked, one of descriptor is owned by the IDMAC. 4. driver can't use DMA and then switches to PIO mode. Failure was already fixed in: https://www.spinics.net/lists/linux-mmc/msg48125.html. Behaviour while soft-reset is not something we except or even want to happen. So we switch from dw_mci_idmac_reset to dw_mci_idmac_init, so descriptors are cleaned before starting dma. And while at it explicitly zero des0 which otherwise might contain garbage as being allocated by dmam_alloc_coherent(). Signed-off-by: Evgeniy Didin Cc: Jaehoon Chung Cc: Ulf Hansson Cc: Andy Shevchenko Cc: Jisheng Zhang Cc: Shawn Lin Cc: Alexey Brodkin Cc: Eugeniy Paltsev Cc: linux-snps-arc@lists.infradead.org Cc: # 4.4+ Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/dw_mmc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -490,6 +490,7 @@ static int dw_mci_idmac_init(struct dw_m (sizeof(struct idmac_desc_64addr) * (i + 1))) >> 32; /* Initialize reserved and buffer size fields to "0" */ + p->des0 = 0; p->des1 = 0; p->des2 = 0; p->des3 = 0; @@ -512,6 +513,7 @@ static int dw_mci_idmac_init(struct dw_m i++, p++) { p->des3 = cpu_to_le32(host->sg_dma + (sizeof(struct idmac_desc) * (i + 1))); + p->des0 = 0; p->des1 = 0; } @@ -2878,8 +2880,8 @@ static bool dw_mci_reset(struct dw_mci * } if (host->use_dma == TRANS_MODE_IDMAC) - /* It is also recommended that we reset and reprogram idmac */ - dw_mci_idmac_reset(host); + /* It is also required that we reinit idmac */ + dw_mci_idmac_init(host); ret = true;