Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp4068147pxp; Tue, 15 Mar 2022 11:49:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRANG0dESWPRO0HwjyojyUhYIHOB492kDDwO8fKnFyin1dJTNZr8rfc/EJWQhzGK4I7+YV X-Received: by 2002:a05:6a00:cd3:b0:4f7:31e2:349b with SMTP id b19-20020a056a000cd300b004f731e2349bmr30078358pfv.67.1647370152244; Tue, 15 Mar 2022 11:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647370152; cv=none; d=google.com; s=arc-20160816; b=H3/2HACYLyXojihgY3UMGw4w+W1maBwaca4iNKxz8EE08SfN81eYm8O4SSAoe1zMWJ W6JFRU3dXZ5k/LaYyGFFkydPWWEPt30+fB+GFGAhtDL57WGFiMUZHakcJ+a5KlfaryPj EPctEyoCLWQxTfU9eAKUCczWsZhIjitp13tp74KgrbY36Uc84eWdUFOGeJwHBzwKDBMC dcgVgXBkb14ctWXuljiIipviZ6Kv6GFLg23Eg81vJtnAHuh6thYHAdT5O2wVRgAahSvB wz1OeJOb2BXNKUM0NIRYLswWCdCjJwsx8rZsZHQnGFBgePSn1+PzL+xbFsyTVRKsWDho mYdw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dFJXVxVtfraQdywQwXUvhT4bPlRCyRdfztDbKOsVxQw=; b=jqrQbHgPqJjrlAmzbvAgpXyilHjWJzOITDPFSVLHECT+vUSRleP3Pfkk0G3VrXz+Ot 6mSpd8jd8HJFkToe7iUjRos7vj/T8FcaVHGUnvz/juRdHb+Aak0tq3hMfbcAZhe0T7IV aKI6XI58Omyn3b2/Pq8TO/jFTYFKjtxXndYRPZOwni0YwA6QMMxm3eNmaExSVMmqpQ2m KdqFykZVGU3zx8ibGbRK8d2NyB3xiQVajKsoXyUkmb25E+bw7hIMYZtjPM4NLk52rqIm HfEIKt2RaHfGdGvQcx8EcgCA2qkKPqpeklD9EAQYcY06YmAnu2tX10oXZR58rihdLje9 uVUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="hbgac/TO"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m9-20020a639409000000b003789b2416cdsi18738780pge.828.2022.03.15.11.48.58; Tue, 15 Mar 2022 11:49:12 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="hbgac/TO"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244739AbiCNMcU (ORCPT + 99 others); Mon, 14 Mar 2022 08:32:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243853AbiCNMVT (ORCPT ); Mon, 14 Mar 2022 08:21:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3939B08; Mon, 14 Mar 2022 05:17:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A7498B80DEB; Mon, 14 Mar 2022 12:17:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E842DC340E9; Mon, 14 Mar 2022 12:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647260237; bh=Wsxqznz+IquJ0SiSvvBnpxlHeNi7tUeAdIQmNX7KyFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hbgac/TOshweMNlprv5TaflX5TjKxP++FCyiw5tFi5Xn9+QvcDKQ7Rvp9DHc4CGSp kyppQ9T+jkMJh81y/1EM8W44ALnqb0qQ7iQlZINaWVdLw4qpkDZsFFkeZtnUaBsDHM gDw8kljInOuerZthj+7+V0UhDNLbtzuCV3RFsCNI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rong Chen , Kevin Hilman , Ulf Hansson Subject: [PATCH 5.16 093/121] mmc: meson: Fix usage of meson_mmc_post_req() Date: Mon, 14 Mar 2022 12:54:36 +0100 Message-Id: <20220314112746.712066290@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314112744.120491875@linuxfoundation.org> References: <20220314112744.120491875@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Rong Chen commit f0d2f15362f02444c5d7ffd5a5eb03e4aa54b685 upstream. 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 Reviewed-by: Kevin Hilman Fixes: 79ed05e329c3 ("mmc: meson-gx: add support for descriptor chain mode") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220216124239.4007667-1-rong.chen@amlogic.com Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/meson-gx-mmc.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) --- 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(struc 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_acces 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 } } - 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)