Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3840764ybg; Sun, 20 Oct 2019 22:59:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUO4A47m/cT/pjE0sZcI3kM4AxHOD7y81zlyR7qFcekiEg8whFa/uVU5dSxgzFacgsTKRl X-Received: by 2002:a17:906:85c5:: with SMTP id i5mr20198138ejy.222.1571637585556; Sun, 20 Oct 2019 22:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571637585; cv=none; d=google.com; s=arc-20160816; b=dOBDSM7ZliddSwyJibMlAfWviLU7KWbZwFSWuqEw/M4zUl/qlDLU2J0UwGky6RZ/bN ovBwLtt1LmI3fqV3rg5VgbWp03gkfFFfHTIU30nQgZ5v1PtAhwaP9xy2FaezCuyf0O1Y CVtpb9JXB9OyPoWRF6FWjuV5H2rrTSip4C0jsb65YLxb3dwjQ59vJTm1buf/PquXz8Vn QXAZ6t08omGpAoHzd/mxUK940wgUceLD5CqID4io4B8dTbCgNume1RKpk7sT4d8OeTA1 0uPbvyo5eqxyE6VvcnTJG5OQrgKK/vyu3gbDe7O0gXdGfbf0UL50ZYRPfd30FcgXt1aY 0+UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=a6b0Q4jjKeBDLIoLuRE8/jg6HZCHWwpthKLqb8Aufb8=; b=YfoO5pQc+z1eb9uGcYyXHLoPJLOJHOU4ShIQiaBIvb9NzQC7WZ8t1/DD7S3y8JA4tt HPwDW1eSaa+qKaJQL+CKXjUHLYD95j7BXJAmR9uHtKOQtg/ISijWlql0u8LjKTYhfCbQ +EOejKEzg+ODvU6owZYcSIWd0L2VtIN4gKsUdhswTnICOp3VOKAVQFh98V0ga0J2ita6 I8k23lAtQ23xSnuiDqPqi2l8bTxr23qZpYdZU1yx4cWFCZFQ9aJo+XANSRhcxIK+moCw MvAUvjlQ+JryXsW1HINjZaZrBARklKcRGwWTtiCkmW7DI7UH/WqvK3dfmzhhYtodl25O pyjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bq16si7983285ejb.221.2019.10.20.22.59.22; Sun, 20 Oct 2019 22:59:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727143AbfJUF7H (ORCPT + 99 others); Mon, 21 Oct 2019 01:59:07 -0400 Received: from mail-sh.amlogic.com ([58.32.228.43]:32104 "EHLO mail-sh.amlogic.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726121AbfJUF7H (ORCPT ); Mon, 21 Oct 2019 01:59:07 -0400 Received: from droid13.amlogic.com (116.236.93.172) by mail-sh.amlogic.com (10.18.11.5) with Microsoft SMTP Server id 15.1.1591.10; Mon, 21 Oct 2019 13:59:15 +0800 From: Jianxin Pan To: Ulf Hansson , Kevin Hilman CC: Nan Li , Jianxin Pan , Jerome Brunet , Neil Armstrong , , , , Victor Wan Subject: [PATCH] mmc: fix mmc dma operation Date: Mon, 21 Oct 2019 13:59:01 +0800 Message-ID: <1571637541-119016-1-git-send-email-jianxin.pan@amlogic.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [116.236.93.172] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nan Li In MMC dma transfer, the region requested by dma_map_sg() may be released by dma_unmap_sg() before the transfer is completed. Put the unmap operation in front of mmc_request_done() to avoid this. Signed-off-by: Nan Li Signed-off-by: Jianxin Pan --- 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 e712315..7667e8a 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) @@ -654,6 +655,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); } @@ -803,25 +806,23 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) 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); - 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.7.4