Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp827416pxb; Wed, 16 Feb 2022 05:24:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJyK9Fpj/GYLe05YyQff2iZAKHjHkcMmN4azW0T5dlO4kaKD8EoTfvsQTj5BGwRDBU5H4MMq X-Received: by 2002:a17:906:fa02:b0:6ce:78fb:2b94 with SMTP id lo2-20020a170906fa0200b006ce78fb2b94mr2265876ejb.396.1645017851659; Wed, 16 Feb 2022 05:24:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645017851; cv=none; d=google.com; s=arc-20160816; b=q6GlKHJzBSd9kWXoPTD7AySCEmOMwuRe2lV0mfQjtMnMALQ+AP+cglsbQobAuI3qOf y8PdBn1HRCWNYhTGyTn2SCbpD9PMA72zpcc1J0/iPxirWkRDq9ZKdjpii2yUOldKMqXK L1cbK9HvpCb3TIG6SOcUaMw0H1KoE6BBVdVs75zMK64Coq1RHboap/viMnEyeHCFeZVd ysaJH5H4AZKmKUgCO0aSVrM2faFLPloh5lhGq8E5G0SGTHWs/Zx9I7GtUnwT+ELan4T4 +lajfcSY1b5pKTvAiReudy9fjgodEvOi25wj+Tzf4AUU++M+4HGxTrydr28HRvIb76SV 1c3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=D+ZgYKnX9FudN15WYgCjHTu6+855Wqg3VZQA2vfsfng=; b=dwz8npKZj4djByLrdnraUc5s+pP2u+5Cno9JFENJWpqQIQSNHCe8rjdjDS0W6PROcK CLQfjFwkmHvRHe97SCA7XlcBfSp7UWNjeKd66QHD/j143zQYUqccnIeA23ayouaqT0DO hzzYK7ZHr/uI4YIHRdMJ4Gbv7WTgivNK1Y1hg0y/mdZ9nyL5fxxc4uZzWuZhONOx87GB sVhqlVV2PsvcPRXOF5z+l0ms6ytsIRa3XF3bITK/FKTjqk9/VJafe0dCuyGCAhA35FY1 LmVEorRNAyZopCYaVGGxYZGzUQ00re8x/wCZ3tJKFVajA+7YNA9AYOZq8ocWsa0qn4CA rKLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b19si1942400edj.358.2022.02.16.05.23.48; Wed, 16 Feb 2022 05:24:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233276AbiBPM57 (ORCPT + 99 others); Wed, 16 Feb 2022 07:57:59 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbiBPM56 (ORCPT ); Wed, 16 Feb 2022 07:57:58 -0500 X-Greylist: delayed 902 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 16 Feb 2022 04:57:46 PST Received: from mail-sz.amlogic.com (mail-sz.amlogic.com [211.162.65.117]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 391D6107822; Wed, 16 Feb 2022 04:57:46 -0800 (PST) Received: from rd02-sz.amlogic.software (10.28.8.43) by mail-sz.amlogic.com (10.28.11.5) with Microsoft SMTP Server id 15.1.2176.2; Wed, 16 Feb 2022 20:42:41 +0800 From: Rong Chen To: Ulf Hansson , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , <1131046452@qq.com>, , , , CC: <45581586@qq.com>, Rong Chen Subject: [PATCH v2] mmc: meson: Fix usage of meson_mmc_post_req() Date: Wed, 16 Feb 2022 20:42:39 +0800 Message-ID: <20220216124239.4007667-1-rong.chen@amlogic.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.28.8.43] X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently meson_mmc_post_req() is called in meson_mmc_request() right after meson_mmc_start_cmd(). This could lead to DMA unmapping before the request is actually finished. To fix, don't call meson_mmc_post_req() until meson_mmc_request_done(). Signed-off-by: Rong Chen --- drivers/mmc/host/meson-gx-mmc.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index 8f36536cb1b6..58ab9d90bc8b 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -173,6 +173,8 @@ struct meson_host { int irq; bool vqmmc_enabled; + bool needs_pre_post_req; + }; #define CMD_CFG_LENGTH_MASK GENMASK(8, 0) @@ -663,6 +665,8 @@ static void meson_mmc_request_done(struct mmc_host *mmc, struct meson_host *host = mmc_priv(mmc); host->cmd = NULL; + if (host->needs_pre_post_req) + meson_mmc_post_req(mmc, mrq, 0); mmc_request_done(host->mmc, mrq); } @@ -880,7 +884,7 @@ static int meson_mmc_validate_dram_access(struct mmc_host *mmc, struct mmc_data static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq) { struct meson_host *host = mmc_priv(mmc); - bool needs_pre_post_req = mrq->data && + host->needs_pre_post_req = mrq->data && !(mrq->data->host_cookie & SD_EMMC_PRE_REQ_DONE); /* @@ -896,22 +900,19 @@ static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq) } } - if (needs_pre_post_req) { + if (host->needs_pre_post_req) { meson_mmc_get_transfer_mode(mmc, mrq); if (!meson_mmc_desc_chain_mode(mrq->data)) - needs_pre_post_req = false; + host->needs_pre_post_req = false; } - if (needs_pre_post_req) + if (host->needs_pre_post_req) meson_mmc_pre_req(mmc, mrq); /* Stop execution */ writel(0, host->regs + SD_EMMC_START); meson_mmc_start_cmd(mmc, mrq->sbc ?: mrq->cmd); - - if (needs_pre_post_req) - meson_mmc_post_req(mmc, mrq, 0); } static void meson_mmc_read_resp(struct mmc_host *mmc, struct mmc_command *cmd) -- 2.25.1