* [U-Boot] [PATCH] mmc/dw_mmc: Fix DMA descriptor corruption
@ 2013-07-26 12:08 Mischa Jonker
2013-08-02 14:33 ` Jaehoon Chung
2013-09-06 11:32 ` Pantelis Antoniou
0 siblings, 2 replies; 3+ messages in thread
From: Mischa Jonker @ 2013-07-26 12:08 UTC (permalink / raw)
To: u-boot
In dwmci_prepare_data, the descriptors are allocated for DMA transfer.
These are allocated using the ALLOC_CACHE_ALIGN_BUFFER. This macro uses
the stack to allocate these descriptors. This becomes a problem if the
DMA transfer continues after the processor leaves the function in which
the descriptors were allocated.
Therefore, I have moved the allocated of the buffers up one level, to
dwmci_send_cmd(). The DMA transfer should be complete when leaving this
function.
Signed-off-by: Mischa Jonker <mjonker@synopsys.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Andy Fleming <afleming@gmail.com>
---
drivers/mmc/dw_mmc.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c
index a82ee17..796a811 100644
--- a/drivers/mmc/dw_mmc.c
+++ b/drivers/mmc/dw_mmc.c
@@ -41,12 +41,11 @@ static void dwmci_set_idma_desc(struct dwmci_idmac *idmac,
}
static void dwmci_prepare_data(struct dwmci_host *host,
- struct mmc_data *data)
+ struct mmc_data *data, struct dwmci_idmac *cur_idmac)
{
unsigned long ctrl;
unsigned int i = 0, flags, cnt, blk_cnt;
ulong data_start, data_end, start_addr;
- ALLOC_CACHE_ALIGN_BUFFER(struct dwmci_idmac, cur_idmac, data->blocks);
blk_cnt = data->blocks;
@@ -111,6 +110,8 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
struct mmc_data *data)
{
struct dwmci_host *host = (struct dwmci_host *)mmc->priv;
+ ALLOC_CACHE_ALIGN_BUFFER(struct dwmci_idmac, cur_idmac,
+ data ? data->blocks : 0);
int flags = 0, i;
unsigned int timeout = 100000;
u32 retry = 10000;
@@ -127,7 +128,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
dwmci_writel(host, DWMCI_RINTSTS, DWMCI_INTMSK_ALL);
if (data)
- dwmci_prepare_data(host, data);
+ dwmci_prepare_data(host, data, cur_idmac);
dwmci_writel(host, DWMCI_CMDARG, cmd->cmdarg);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* [U-Boot] [PATCH] mmc/dw_mmc: Fix DMA descriptor corruption
2013-07-26 12:08 [U-Boot] [PATCH] mmc/dw_mmc: Fix DMA descriptor corruption Mischa Jonker
@ 2013-08-02 14:33 ` Jaehoon Chung
2013-09-06 11:32 ` Pantelis Antoniou
1 sibling, 0 replies; 3+ messages in thread
From: Jaehoon Chung @ 2013-08-02 14:33 UTC (permalink / raw)
To: u-boot
Hi, Mischa,
Looks good to me.
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Best Regards,
Jaehoon Chung
On 07/26/2013 09:08 PM, Mischa Jonker wrote:
> In dwmci_prepare_data, the descriptors are allocated for DMA transfer.
> These are allocated using the ALLOC_CACHE_ALIGN_BUFFER. This macro uses
> the stack to allocate these descriptors. This becomes a problem if the
> DMA transfer continues after the processor leaves the function in which
> the descriptors were allocated.
>
> Therefore, I have moved the allocated of the buffers up one level, to
> dwmci_send_cmd(). The DMA transfer should be complete when leaving this
> function.
>
> Signed-off-by: Mischa Jonker <mjonker@synopsys.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Cc: Andy Fleming <afleming@gmail.com>
> ---
> drivers/mmc/dw_mmc.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c
> index a82ee17..796a811 100644
> --- a/drivers/mmc/dw_mmc.c
> +++ b/drivers/mmc/dw_mmc.c
> @@ -41,12 +41,11 @@ static void dwmci_set_idma_desc(struct dwmci_idmac *idmac,
> }
>
> static void dwmci_prepare_data(struct dwmci_host *host,
> - struct mmc_data *data)
> + struct mmc_data *data, struct dwmci_idmac *cur_idmac)
> {
> unsigned long ctrl;
> unsigned int i = 0, flags, cnt, blk_cnt;
> ulong data_start, data_end, start_addr;
> - ALLOC_CACHE_ALIGN_BUFFER(struct dwmci_idmac, cur_idmac, data->blocks);
>
>
> blk_cnt = data->blocks;
> @@ -111,6 +110,8 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
> struct mmc_data *data)
> {
> struct dwmci_host *host = (struct dwmci_host *)mmc->priv;
> + ALLOC_CACHE_ALIGN_BUFFER(struct dwmci_idmac, cur_idmac,
> + data ? data->blocks : 0);
> int flags = 0, i;
> unsigned int timeout = 100000;
> u32 retry = 10000;
> @@ -127,7 +128,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
> dwmci_writel(host, DWMCI_RINTSTS, DWMCI_INTMSK_ALL);
>
> if (data)
> - dwmci_prepare_data(host, data);
> + dwmci_prepare_data(host, data, cur_idmac);
>
> dwmci_writel(host, DWMCI_CMDARG, cmd->cmdarg);
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread* [U-Boot] [PATCH] mmc/dw_mmc: Fix DMA descriptor corruption
2013-07-26 12:08 [U-Boot] [PATCH] mmc/dw_mmc: Fix DMA descriptor corruption Mischa Jonker
2013-08-02 14:33 ` Jaehoon Chung
@ 2013-09-06 11:32 ` Pantelis Antoniou
1 sibling, 0 replies; 3+ messages in thread
From: Pantelis Antoniou @ 2013-09-06 11:32 UTC (permalink / raw)
To: u-boot
Hi Mischa,
On Jul 26, 2013, at 3:08 PM, Mischa Jonker wrote:
> In dwmci_prepare_data, the descriptors are allocated for DMA transfer.
> These are allocated using the ALLOC_CACHE_ALIGN_BUFFER. This macro uses
> the stack to allocate these descriptors. This becomes a problem if the
> DMA transfer continues after the processor leaves the function in which
> the descriptors were allocated.
>
> Therefore, I have moved the allocated of the buffers up one level, to
> dwmci_send_cmd(). The DMA transfer should be complete when leaving this
> function.
>
> Signed-off-by: Mischa Jonker <mjonker@synopsys.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Cc: Andy Fleming <afleming@gmail.com>
Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
Thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-09-06 11:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-26 12:08 [U-Boot] [PATCH] mmc/dw_mmc: Fix DMA descriptor corruption Mischa Jonker
2013-08-02 14:33 ` Jaehoon Chung
2013-09-06 11:32 ` Pantelis Antoniou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox