Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3982844pxb; Tue, 25 Jan 2022 00:38:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQBHbSE2IohjBBjUTUyZMClFKAxnmAOjB31B/dbao/58JJiHyPbb7R/65OD0j3yLigx+S5 X-Received: by 2002:a63:7202:: with SMTP id n2mr14700569pgc.254.1643099890732; Tue, 25 Jan 2022 00:38:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643099890; cv=none; d=google.com; s=arc-20160816; b=e1X1/lqNxd3TP4zlB72VDrWVIHx5u+LS+2uaUJv9cD80uckqtB2zsFJRPJ/MC4m1s7 3VXi685FCOvJQjlLGczGquES37EvYZIVhHi+SvYgyIc8PjcrHdqmrhjfTWdZ2SUq+6sS 1rr1WWEtOmV22kHMBGIfs6as3Io1yleI2pEUnGs3OZYm1V2yNrSmy2Gld7Ft1vR5k35S ssYezXXiMufRI/Y7xxd/vQ4D96vel2eyoWD2faIvdpXx/OzAvDToR0z/HZGRNs6+W9nj UP2OGthMfNfY7pdp58MeENlC7jxf8htuIuP9p58FfVKG3hFzvBq4+NhUeiMnu7qa1UG5 owbw== 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:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=t2/pVCkMGUvGOAzHtcsjzXK8+5zE14NO4NddvkDqj9w=; b=QcC6UG9P+PNCH5IseJCObRbadxf4A3PXr/MnQNijb+vN90Mk9qxT9nhh13nqccjPvm VWzRQ2RYagBs210fbOP5sa8tR7Fy1gOBzF7nNAEAPzTE/Sq5D8VJHqkhGkhbcON8zY1W L5cpcTN8IgHbQuT3ahLgOO6myxZYCBqxz8ITB8f+gYweIDx12/mUvH1cgKRL8AMOQA1t kgUYbU+Xhj9rdW2D7K97Gyj6KDvW+aaPXgKITiJ0lmuKbdXSrAzGTGRRzCukKYJ6htzX dgwaJmiusn5rDanrYiX7Kp1tZPOmFax7eq1Qyum+xFNnOb2Jx/nDvV3O2QMBjhnDxbCw lO2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=zgQsj3L6; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y10si14132825plr.263.2022.01.25.00.37.59; Tue, 25 Jan 2022 00:38:10 -0800 (PST) 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; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=zgQsj3L6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1315736AbiAYCyG (ORCPT + 99 others); Mon, 24 Jan 2022 21:54:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S3407930AbiAYAVN (ORCPT ); Mon, 24 Jan 2022 19:21:13 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53F14C036BC9 for ; Mon, 24 Jan 2022 14:05:19 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id 128so17400755pfe.12 for ; Mon, 24 Jan 2022 14:05:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=t2/pVCkMGUvGOAzHtcsjzXK8+5zE14NO4NddvkDqj9w=; b=zgQsj3L6OSg50dgEyhI8VbLJQG2U1v8YozGt0iCNFUM1VD44MdEEHw1TSHFiiFusYm KDxrEiMMuxae+sOtjt1EAf0QRiHYPBqrWfrqeoKDDcS9C6HEE8Yc+eiMecOXPMVj7yBn vR6x7/Nxu9rUwbIaPs6BeMj7O0HmKhccqmGffa7QrvZQpq6IeST+8ublmUmvRAE0oJYn AdMckgD861YXcZiqZQjGz7k0XtXBU9eYrbKNJx0axcLK9lsZTYS39AsDHHQjpRxksUAV NzMsZ/b68MBEQWFupMhFjbLnuTikjDakneYKyipvasoYBv/IYV2UBa0nLqwjNKUeungZ 2D2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=t2/pVCkMGUvGOAzHtcsjzXK8+5zE14NO4NddvkDqj9w=; b=jHpqOVxh4bax0Fs1BuATblyVK8EK4MP1o/zz8cZ2JPwzIWICaN6yWM7LyKD++ZgyAY DweXyzEmNGlTAydm1+favtmZXb5peYnyHuGoOolk5zWjnkThOHK+cpB1qEaS0xylqVGG ofV7a31Vpa7nY/K53LbrdUVA6huZwv+TbrbQTSKZYg8E1Afxu0OCHJLzArktSzuQBsDw sXJQiPj8kkPGYHlr1A674WqipBY19GTI/gBLQMzsc8d/OzODbuCFzd3eBgYYnH3g11lq xgzAmM+CJCrmcKCtGnIzCqG683yoeu1KX0kIZlzVBeKaxEV+wuAuE+U7i44v7aS1GUYf DAHg== X-Gm-Message-State: AOAM5318tkAAN5tPQ0rTY0qvYw0/fxziD5XlyDTdcCua+SHFXzaNO6GX UEE5LsNQzXQjomYqMdrULQJEgQ== X-Received: by 2002:a05:6a00:114f:b0:4c5:72f6:d0b5 with SMTP id b15-20020a056a00114f00b004c572f6d0b5mr15521818pfm.61.1643061918766; Mon, 24 Jan 2022 14:05:18 -0800 (PST) Received: from localhost (c-71-197-186-152.hsd1.wa.comcast.net. [71.197.186.152]) by smtp.gmail.com with ESMTPSA id g12sm16231227pfm.119.2022.01.24.14.05.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 14:05:18 -0800 (PST) From: Kevin Hilman To: Rong Chen , Ulf Hansson , 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 Cc: 45581586@qq.com, Rong Chen Subject: Re: [PATCH] mmc: meson: Fix usage of meson_mmc_post_req() In-Reply-To: <20220106105453.3875119-1-rong.chen@amlogic.com> References: <20220106105453.3875119-1-rong.chen@amlogic.com> Date: Mon, 24 Jan 2022 14:05:17 -0800 Message-ID: <7htudsx00y.fsf@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Rong, First, thank you finding the issue and for submitting a fix! Rong Chen writes: > To ensure the DMA moves data correctly from memory to > peripherals, DMA unmapping when the MMC request done > with calls meson_mmc_post_req(). > > Signed-off-by: Rong Chen The patch looks correct, but I think I think the changelog could be improved. If I understand the code correctly, I think what you're doing is: """ Currently meson_mmc_post_req() is called in meson_mmc_request() right after _start_cmd(). This could lead to DMA unmapping before the request is actually finished. To fix, ton't call meson_mmc_post_req() until _request_done(). """ Kevin > --- > drivers/mmc/host/meson-gx-mmc.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c > index 8f36536cb1b6..6a9554ae4b1c 100644 > --- a/drivers/mmc/host/meson-gx-mmc.c > +++ b/drivers/mmc/host/meson-gx-mmc.c > @@ -173,6 +173,7 @@ struct meson_host { > int irq; > > bool vqmmc_enabled; > + bool needs_pre_post_req; > }; > > #define CMD_CFG_LENGTH_MASK GENMASK(8, 0) > @@ -663,6 +664,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 +883,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 +899,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) > > base-commit: 356f3f2c5756bbb67a515760966a40fc7043cdda > -- > 2.25.1