* [PATCH] mmc: meson: Fix usage of meson_mmc_post_req()
@ 2022-01-06 10:54 Rong Chen
2022-01-24 22:05 ` Kevin Hilman
0 siblings, 1 reply; 2+ messages in thread
From: Rong Chen @ 2022-01-06 10:54 UTC (permalink / raw)
To: Ulf Hansson, Neil Armstrong, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, 1131046452, linux-mmc, linux-arm-kernel,
linux-amlogic, linux-kernel
Cc: 45581586, Rong Chen
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 <rong.chen@amlogic.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mmc: meson: Fix usage of meson_mmc_post_req()
2022-01-06 10:54 [PATCH] mmc: meson: Fix usage of meson_mmc_post_req() Rong Chen
@ 2022-01-24 22:05 ` Kevin Hilman
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Hilman @ 2022-01-24 22:05 UTC (permalink / raw)
To: Rong Chen, Ulf Hansson, Neil Armstrong, Jerome Brunet,
Martin Blumenstingl, 1131046452, linux-mmc, linux-arm-kernel,
linux-amlogic, linux-kernel
Cc: 45581586, Rong Chen
Hello Rong,
First, thank you finding the issue and for submitting a fix!
Rong Chen <rong.chen@amlogic.com> 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 <rong.chen@amlogic.com>
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-25 3:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-06 10:54 [PATCH] mmc: meson: Fix usage of meson_mmc_post_req() Rong Chen
2022-01-24 22:05 ` Kevin Hilman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).