Skip to content

Commit

Permalink
mmc_block: do not DMA to stack
Browse files Browse the repository at this point in the history
In the write recovery routine, the data to get from the card
is allocated from the stack. The DMA mapping documentation says
explicitly stack memory is not mappable by any of the DMA calls.

Change to using kmalloc() to allocate the memory for the result
from the card and then free it once we've finished with the
transaction.

[ Changed to GFP_KERNEL allocation - Pierre Ossman ]

Signed-off-by: Ben Dooks <ben@simtec.co.uk>
Signed-off-by: Pierre Ossman <pierre@ossman.eu>
  • Loading branch information
Ben Dooks authored and Pierre Ossman committed Jun 13, 2009
1 parent be3f4ae commit 051913d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions drivers/mmc/card/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ struct mmc_blk_request {
static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
{
int err;
__be32 blocks;
u32 result;
__be32 *blocks;

struct mmc_request mrq;
struct mmc_command cmd;
Expand Down Expand Up @@ -199,14 +200,21 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
mrq.cmd = &cmd;
mrq.data = &data;

sg_init_one(&sg, &blocks, 4);
blocks = kmalloc(4, GFP_KERNEL);
if (!blocks)
return (u32)-1;

sg_init_one(&sg, blocks, 4);

mmc_wait_for_req(card->host, &mrq);

result = ntohl(*blocks);
kfree(blocks);

if (cmd.error || data.error)
return (u32)-1;
result = (u32)-1;

return ntohl(blocks);
return result;
}

static u32 get_card_status(struct mmc_card *card, struct request *req)
Expand Down

0 comments on commit 051913d

Please sign in to comment.