Skip to content

Commit f0d2f15

Browse files
Rong ChenUlf Hansson
authored andcommitted
mmc: meson: Fix usage of meson_mmc_post_req()
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 <rong.chen@amlogic.com> Reviewed-by: Kevin Hilman <khilman@baylibre.com> Fixes: 79ed05e ("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 <ulf.hansson@linaro.org>
1 parent 7e57714 commit f0d2f15

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

drivers/mmc/host/meson-gx-mmc.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ struct meson_host {
173173
int irq;
174174

175175
bool vqmmc_enabled;
176+
bool needs_pre_post_req;
177+
176178
};
177179

178180
#define CMD_CFG_LENGTH_MASK GENMASK(8, 0)
@@ -663,6 +665,8 @@ static void meson_mmc_request_done(struct mmc_host *mmc,
663665
struct meson_host *host = mmc_priv(mmc);
664666

665667
host->cmd = NULL;
668+
if (host->needs_pre_post_req)
669+
meson_mmc_post_req(mmc, mrq, 0);
666670
mmc_request_done(host->mmc, mrq);
667671
}
668672

@@ -880,7 +884,7 @@ static int meson_mmc_validate_dram_access(struct mmc_host *mmc, struct mmc_data
880884
static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
881885
{
882886
struct meson_host *host = mmc_priv(mmc);
883-
bool needs_pre_post_req = mrq->data &&
887+
host->needs_pre_post_req = mrq->data &&
884888
!(mrq->data->host_cookie & SD_EMMC_PRE_REQ_DONE);
885889

886890
/*
@@ -896,22 +900,19 @@ static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
896900
}
897901
}
898902

899-
if (needs_pre_post_req) {
903+
if (host->needs_pre_post_req) {
900904
meson_mmc_get_transfer_mode(mmc, mrq);
901905
if (!meson_mmc_desc_chain_mode(mrq->data))
902-
needs_pre_post_req = false;
906+
host->needs_pre_post_req = false;
903907
}
904908

905-
if (needs_pre_post_req)
909+
if (host->needs_pre_post_req)
906910
meson_mmc_pre_req(mmc, mrq);
907911

908912
/* Stop execution */
909913
writel(0, host->regs + SD_EMMC_START);
910914

911915
meson_mmc_start_cmd(mmc, mrq->sbc ?: mrq->cmd);
912-
913-
if (needs_pre_post_req)
914-
meson_mmc_post_req(mmc, mrq, 0);
915916
}
916917

917918
static void meson_mmc_read_resp(struct mmc_host *mmc, struct mmc_command *cmd)

0 commit comments

Comments
 (0)