From patchwork Wed Feb 9 04:51:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 542881 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p194pCJc002932 for ; Wed, 9 Feb 2011 04:51:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750757Ab1BIEvM (ORCPT ); Tue, 8 Feb 2011 23:51:12 -0500 Received: from relmlor1.renesas.com ([210.160.252.171]:52276 "EHLO relmlor1.renesas.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750845Ab1BIEvL (ORCPT ); Tue, 8 Feb 2011 23:51:11 -0500 Received: from relmlir3.idc.renesas.com ([10.200.68.153]) by relmlor1.idc.renesas.com ( SJSMS) with ESMTP id <0LGC00JT12TA1BE0@relmlor1.idc.renesas.com> for linux-mmc@vger.kernel.org; Wed, 09 Feb 2011 13:51:10 +0900 (JST) Received: from relmlac1.idc.renesas.com ([10.200.69.21]) by relmlir3.idc.renesas.com ( SJSMS) with ESMTP id <0LGC00DNW2TA2HD0@relmlir3.idc.renesas.com> for linux-mmc@vger.kernel.org; Wed, 09 Feb 2011 13:51:10 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id E20F380088; Wed, 09 Feb 2011 13:51:09 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id DD99080030; Wed, 09 Feb 2011 13:51:09 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac1.idc.renesas.com with ESMTP id PAE02495; Wed, 09 Feb 2011 13:51:09 +0900 X-IronPort-AV: E=Sophos; i="4.60,445,1291561200"; d="scan'208"; a="10576063" Received: from unknown (HELO [172.30.8.157]) ([172.30.8.157]) by relmlii1.idc.renesas.com with ESMTP; Wed, 09 Feb 2011 13:51:09 +0900 Message-id: <4D521D3D.8040308@renesas.com> Date: Wed, 09 Feb 2011 13:51:09 +0900 From: Yoshihiro Shimoda User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-version: 1.0 To: cjb@laptop.org Cc: linux-mmc@vger.kernel.org Subject: [PATCH] mmc: fix the mmc_app_send_scr() for dma transfer Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7bit Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 09 Feb 2011 04:51:13 +0000 (UTC) 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 #include #include @@ -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)