* [PATCH resend] mmc: fix the mmc_app_send_scr() for dma transfer
@ 2011-03-25 6:06 Yoshihiro Shimoda
2011-03-25 13:20 ` Chris Ball
0 siblings, 1 reply; 2+ messages in thread
From: Yoshihiro Shimoda @ 2011-03-25 6:06 UTC (permalink / raw)
To: cjb; +Cc: linux-mmc
This patch is based on the commit "af51715079e7fb6b290e1881d63d815dc4de5011":
* Bugfix to that mmc_send_cxd_data() code: dma-to-stack is
unsafe/nonportable, so kmalloc a bounce buffer instead.
The driver may invalidate the mmc_card->csd when host driver uses dma.
So the subroutine also needs kmalloc buffer.
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
drivers/mmc/core/sd_ops.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c
index 797cdb5..76af349 100644
--- a/drivers/mmc/core/sd_ops.c
+++ b/drivers/mmc/core/sd_ops.c
@@ -9,6 +9,7 @@
* your option) any later version.
*/
+#include <linux/slab.h>
#include <linux/types.h>
#include <linux/scatterlist.h>
@@ -252,6 +253,7 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr)
struct mmc_command cmd;
struct mmc_data data;
struct scatterlist sg;
+ void *data_buf;
BUG_ON(!card);
BUG_ON(!card->host);
@@ -263,6 +265,13 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr)
if (err)
return err;
+ /* dma onto stack is unsafe/nonportable, but callers to this
+ * routine normally provide temporary on-stack buffers ...
+ */
+ data_buf = kmalloc(sizeof(card->raw_scr), GFP_KERNEL);
+ if (data_buf == NULL)
+ return -ENOMEM;
+
memset(&mrq, 0, sizeof(struct mmc_request));
memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
@@ -280,12 +289,15 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr)
data.sg = &sg;
data.sg_len = 1;
- sg_init_one(&sg, scr, 8);
+ sg_init_one(&sg, data_buf, 8);
mmc_set_data_timeout(&data, card);
mmc_wait_for_req(card->host, &mrq);
+ memcpy(scr, data_buf, sizeof(card->raw_scr));
+ kfree(data_buf);
+
if (cmd.error)
return cmd.error;
if (data.error)
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH resend] mmc: fix the mmc_app_send_scr() for dma transfer
2011-03-25 6:06 [PATCH resend] mmc: fix the mmc_app_send_scr() for dma transfer Yoshihiro Shimoda
@ 2011-03-25 13:20 ` Chris Ball
0 siblings, 0 replies; 2+ messages in thread
From: Chris Ball @ 2011-03-25 13:20 UTC (permalink / raw)
To: Yoshihiro Shimoda; +Cc: linux-mmc
Hi Yoshihiro,
On Fri, Mar 25 2011, Yoshihiro Shimoda wrote:
> This patch is based on the commit "af51715079e7fb6b290e1881d63d815dc4de5011":
>
> * Bugfix to that mmc_send_cxd_data() code: dma-to-stack is
> unsafe/nonportable, so kmalloc a bounce buffer instead.
>
> The driver may invalidate the mmc_card->csd when host driver uses dma.
> So the subroutine also needs kmalloc buffer.
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Thanks for the resend, pushed to mmc-next for .39-rc2.
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-03-25 13:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-25 6:06 [PATCH resend] mmc: fix the mmc_app_send_scr() for dma transfer Yoshihiro Shimoda
2011-03-25 13:20 ` Chris Ball
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox