From patchwork Fri Mar 25 06:06:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 661071 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 p2P66OQV010715 for ; Fri, 25 Mar 2011 06:06:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753674Ab1CYGGX (ORCPT ); Fri, 25 Mar 2011 02:06:23 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:50968 "EHLO relmlor1.renesas.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753492Ab1CYGGW (ORCPT ); Fri, 25 Mar 2011 02:06:22 -0400 Received: from relmlir4.idc.renesas.com ([10.200.68.154]) by relmlor1.idc.renesas.com ( SJSMS) with ESMTP id <0LIL005LBNMLAG30@relmlor1.idc.renesas.com> for linux-mmc@vger.kernel.org; Fri, 25 Mar 2011 15:06:21 +0900 (JST) Received: from relmlac3.idc.renesas.com ([10.200.69.23]) by relmlir4.idc.renesas.com ( SJSMS) with ESMTP id <0LIL000LPNMDAU80@relmlir4.idc.renesas.com> for linux-mmc@vger.kernel.org; Fri, 25 Mar 2011 15:06:21 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id 7687A18094; Fri, 25 Mar 2011 15:06:21 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id 09B461808C; Fri, 25 Mar 2011 15:06:21 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac3.idc.renesas.com with ESMTP id RBC26555; Fri, 25 Mar 2011 15:06:21 +0900 X-IronPort-AV: E=Sophos; i="4.63,241,1299423600"; d="scan'208"; a="18188042" Received: from unknown (HELO [172.30.8.157]) ([172.30.8.157]) by relmlii1.idc.renesas.com with ESMTP; Fri, 25 Mar 2011 15:06:19 +0900 Message-id: <4D8C30DB.1010007@renesas.com> Date: Fri, 25 Mar 2011 15:06:19 +0900 From: Yoshihiro Shimoda User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-version: 1.0 To: cjb@laptop.org Cc: linux-mmc@vger.kernel.org Subject: [PATCH resend] 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]); Fri, 25 Mar 2011 06:06:24 +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)