Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3007491pxm; Mon, 28 Feb 2022 10:10:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPOROyvfGRr5dQBULcpR9J+5zlVUPokAVmlURFYXTk+xLzPXwUKfRfrZH/gvioELN5ixww X-Received: by 2002:a17:90a:5797:b0:1bc:56a9:f6c8 with SMTP id g23-20020a17090a579700b001bc56a9f6c8mr18059635pji.12.1646071818670; Mon, 28 Feb 2022 10:10:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646071818; cv=none; d=google.com; s=arc-20160816; b=VYDA/1jyTPmPKCVaSg9ipce9AXPtFdE0vw/3ZZontaTOqZuV8U35CKuXmI1+/S9X3N kg1eCax2211Pax5VR/BfdfPaM6iOW0n2cirCnczYg06Oo07bydM66R/ri4uVHieTj7aM GeRw1TiY0spswX66Qs7Sw6jGH091QHJG2kV0Omrs98zjgdcc0RU3vh7lyOf0RvwSdMgj BTrtqkDoKWHLP7zcRzS/VOi5Z9T2Pd7o4+UTMfoyxMvrw9Li/xNr3cAj0pD7+q+jdQD6 JqLpQtYzWvyVwdxm+mk2bWpUP9UUV/E7kLNNFfJpvDczUGiowVm35kd7Dix+ensagf1Y ma8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=iCqSJLVmzSiAQCZuGWx3jdcx0OAjD7prrRZYblRmLXk=; b=yKS3Uap2vqBHkuFIAmRoIrWgVrkaqZJCur9ABfYirKA5NcnzJtJDIQ4X/xMwbom0bN 5FHLW/954gRm34Bc0bx1orNL9hK0Q2CYA1Nug3iuMk6Nzr81VIkKp+mf/5A3joDz7zOt Qidv46NwuhAKDhtIjFHNgcPSVi8li7tZsrKTy8Ybrx33xCJUbB/coCLAEUGzGz/uObr6 hgCuuolYEpxQgqhP2nAk+TPSfGIlqOSXC8ArjsGHUBr3sW0j4wrMsrYpOw48va+P8s0E e8oiDcEC6XhK/MIRx+w7a1+XoejLMRrgCiYcRKQurpwuHBFXv2rx9RW7koL4HOK6NPUj rmIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=biJj7wiv; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d9-20020a631d09000000b0037562967a7fsi9913342pgd.160.2022.02.28.10.09.59; Mon, 28 Feb 2022 10:10:18 -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; dkim=pass header.i=@linaro.org header.s=google header.b=biJj7wiv; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237939AbiB1RGx (ORCPT + 99 others); Mon, 28 Feb 2022 12:06:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235160AbiB1RGw (ORCPT ); Mon, 28 Feb 2022 12:06:52 -0500 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0188A82D17 for ; Mon, 28 Feb 2022 09:06:13 -0800 (PST) Received: by mail-lf1-x130.google.com with SMTP id b11so22460485lfb.12 for ; Mon, 28 Feb 2022 09:06:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iCqSJLVmzSiAQCZuGWx3jdcx0OAjD7prrRZYblRmLXk=; b=biJj7wivuUwsykg3cCHNhf5pu9DOv2jbE6fUXHgxl5AXqJvtb2ehNXEpFdBsjf5qD4 vkHTAQcKYQZBp7geavn1aVx7d+zborulBdlwD7Z9JRROJb12Mj6rRHX0cdfRhdrBzE0T /VohSnvjl3cAMBB76kxjvj0WUoNEYnotB2u9aY4x3HQ8MsPfk5guRYXgM9MGsq6586hO P3k48kII6PkFhXlZjZdrwpfYsUaBAhs1H81yb5JvQCu2e5fNvNljwd6rz18hGoRAllT7 8vpUEGH8aPTJnoNzpFlbD5QQcpiY4id2uDJYhd0pnDZxqOyuc1WlmXodzzdBd3L88bUq P45A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iCqSJLVmzSiAQCZuGWx3jdcx0OAjD7prrRZYblRmLXk=; b=vwVZ3i4ETIR2dCd4i/SKfdJSqNkvxhw5dVGqkMG2F2dKHle93AXe7nVyPgGj79KeY7 tqCjevA7G0obEkAzQPraV4Vp0ma9Oxqq6CDWXkSnJOXYHgOMv/e+pSQL/0OX8FgImOrO icDdiOxoa4RPj8L0L9NHRng5HIymnxAZWWdavzYaoMCYibXeSd3Zgp0a+LieT1I2sXX4 Jpu1zP6Db0tUAYxh8Ffl7M+6PvMGeRrD3xYZaejatJH44l4+cEnmlkt1CNMfwnZHuZzI DsyyO88OmoozIEQP+oldIlrU6q4XFYsn8gRG+6lfI7Y6B+p905qlyO4/a1TN0LsVMIQl DKJQ== X-Gm-Message-State: AOAM530eNFKmalb/gBRpLPZGYod/V1Z7elNjxrGtmReiwY/e9SGktoL7 K5pRePB8CXKfaQ9VIubLM7Uy/1N57Bq8f2x3fhgpBA== X-Received: by 2002:a19:9144:0:b0:43b:86a4:1497 with SMTP id y4-20020a199144000000b0043b86a41497mr13291435lfj.254.1646067971343; Mon, 28 Feb 2022 09:06:11 -0800 (PST) MIME-Version: 1.0 References: <20220216124239.4007667-1-rong.chen@amlogic.com> In-Reply-To: <20220216124239.4007667-1-rong.chen@amlogic.com> From: Ulf Hansson Date: Mon, 28 Feb 2022 18:05:35 +0100 Message-ID: Subject: Re: [PATCH v2] mmc: meson: Fix usage of meson_mmc_post_req() To: Kevin Hilman , Rong Chen Cc: Neil Armstrong , Jerome Brunet , Martin Blumenstingl , 1131046452@qq.com, linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, 45581586@qq.com, Heiner Kallweit Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 + Hainer On Wed, 16 Feb 2022 at 13:42, Rong Chen wrote: > > 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 We should probably add a fixes tag to this, right? Fixes: 79ed05e329c3 ("mmc: meson-gx: add support for descriptor chain mode") Moreover, you want this tagged for stable kernels too, right? I have applied it for fixes and added the above tags, please tell if you want me to change it. Kind regards Uffe > --- > 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 >