Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1080005pxb; Fri, 27 Aug 2021 00:17:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSc3YWXV+JBnN3ZFXqmgmpHw4AWxMkbMFyn1OsR4f6Fn1Fdy/e8ua+9BH+kcc7r6W6YWPD X-Received: by 2002:a05:6e02:1905:: with SMTP id w5mr5635209ilu.165.1630048636689; Fri, 27 Aug 2021 00:17:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630048636; cv=none; d=google.com; s=arc-20160816; b=F79pN392GIsFKOTc7ERofZR64erI8VIXb+GlsSxXMr8Oif0Kw1d7Z7olYiUKm1f1w3 +RueqUJ/olgbutwHkMrl4JQoI6BmFekOId42Z9kKPAXIH2LZBFqr2RuK/qlemhhMTYFr gIZSBPZ7aWxi6mlePGWQmlY1xJ7iLnYeb2xdlXfIG2xGfym9TGi/7HupKQT0w95B4vTD tVG6vOc+LDG5ZIrCaEE0qo6c2VIkCs+x/aqM+w9zaOug09evZQyr8sXA0wi4isi5M8Ds YS9U3H5gKsiBay+evnz4p08NKipl2qiqQUJLnQwVvIeQxv6Ickto5r+PmXdfIBJT0YA+ spNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=klUOcUD9qLf5NfNg0UtU+v3yUWdoTEltUuJtGR/uoJo=; b=yjxxEBLiy2H2QC8b6tgBqDDPlWiEhe3A8+oEpDCkgdl5IAfW0NgdZJGVK1OSf7NOEK RLePNaIQOfwOMyoweXvKtgIv111QnO6p5dXs6YjC3BujdZ/4LRFyICWPPl5kK3GcBKxW CUYSHnyNiG0qc8ryYDMZf0xF+BhTq2fOAVnVvLaL/vT9ByOesiiHpZ2Pjg0bLzBxJJ7E 8b11bSy1BY0R3B00wdS4COmCPNIkp5C0yAImEo5l0QWqM8HLJ9fk/tJZe4nb7+gydBUl knul0CqkjkrBHMPsj/6BQJ1KsdORW6smghMAFGcwj0ii1Kypjmg7IqWWIK+bGwMxpzUi eiiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 8si1266189jay.69.2021.08.27.00.17.05; Fri, 27 Aug 2021 00:17:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244340AbhH0HQh (ORCPT + 99 others); Fri, 27 Aug 2021 03:16:37 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:41216 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S244274AbhH0HQc (ORCPT ); Fri, 27 Aug 2021 03:16:32 -0400 X-UUID: 32bfc58617334ef286f85314b60c1b0a-20210827 X-UUID: 32bfc58617334ef286f85314b60c1b0a-20210827 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 366452259; Fri, 27 Aug 2021 15:15:41 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 27 Aug 2021 15:15:40 +0800 Received: from localhost.localdomain (10.15.20.246) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 27 Aug 2021 15:15:39 +0800 From: Derong Liu To: Chaotian Jing , Ulf Hansson , Matthias Brugger CC: , , , , , Peng Zhou , Derong Liu Subject: [PATCH v3] mmc: mediatek: add wait dma stop done flow Date: Fri, 27 Aug 2021 15:15:37 +0800 Message-ID: <20210827071537.1034-1-derong.liu@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We found this issue on a 5G platform, during CMDQ error handling, if DMA status is active when it call msdc_reset_hw, it means mmc host hw reset and DMA transfer will be parallel, mmc host may access sram region unexpectedly. According to the programming guide of mtk mmc host, it needs to wait for dma stop done after set dma stop. This change should be applied to all SoCs. Change-Id: I9b87523f19b24ca73958bbcb83bb418413c5a180 Signed-off-by: Derong Liu --- drivers/mmc/host/mtk-sd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c index 4dfc246c5f95..b99330bad6a5 100644 --- a/drivers/mmc/host/mtk-sd.c +++ b/drivers/mmc/host/mtk-sd.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -2330,6 +2331,7 @@ static void msdc_cqe_enable(struct mmc_host *mmc) static void msdc_cqe_disable(struct mmc_host *mmc, bool recovery) { struct msdc_host *host = mmc_priv(mmc); + unsigned int val = 0; /* disable cmdq irq */ sdr_clr_bits(host->base + MSDC_INTEN, MSDC_INT_CMDQ); @@ -2339,6 +2341,9 @@ static void msdc_cqe_disable(struct mmc_host *mmc, bool recovery) if (recovery) { sdr_set_field(host->base + MSDC_DMA_CTRL, MSDC_DMA_CTRL_STOP, 1); + if (WARN_ON(readl_poll_timeout(host->base + MSDC_DMA_CFG, val, + !(val & MSDC_DMA_CFG_STS), 1, 3000))) + return; msdc_reset_hw(host); } } -- 2.18.0