From patchwork Fri Feb 13 05:55:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: keita kobayashi X-Patchwork-Id: 5823431 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2F93CBF440 for ; Fri, 13 Feb 2015 05:56:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5892020364 for ; Fri, 13 Feb 2015 05:56:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7156720379 for ; Fri, 13 Feb 2015 05:56:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752204AbbBMF4W (ORCPT ); Fri, 13 Feb 2015 00:56:22 -0500 Received: from relmlor4.renesas.com ([210.160.252.174]:42057 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752342AbbBMF4K (ORCPT ); Fri, 13 Feb 2015 00:56:10 -0500 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie3.idc.renesas.com with ESMTP; 13 Feb 2015 14:56:08 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 517A83E9D3; Fri, 13 Feb 2015 14:56:08 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id 3131128070; Fri, 13 Feb 2015 14:56:07 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id 75AF62806F; Fri, 13 Feb 2015 14:56:07 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac2.idc.renesas.com with ESMTP id QAB01410; Fri, 13 Feb 2015 14:56:07 +0900 X-IronPort-AV: E=Sophos;i="5.09,569,1418050800"; d="scan'208";a="180912280" Received: from mail-hk1lp0121.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.121]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 13 Feb 2015 14:56:06 +0900 Received: from [10.161.20.223] (211.11.155.147) by SG2PR06MB0569.apcprd06.prod.outlook.com (25.161.11.13) with Microsoft SMTP Server (TLS) id 15.1.81.19; Fri, 13 Feb 2015 05:56:05 +0000 Message-ID: <54DD91E3.3070903@renesas.com> Date: Fri, 13 Feb 2015 14:55:47 +0900 From: keita kobayashi User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 To: CC: Subject: [RFC/PATCH] mmc: tmio: Fix PIO mode with CONFIG_HIGHMEM X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: HKNPR06CA0027.apcprd06.prod.outlook.com (10.141.16.17) To SG2PR06MB0569.apcprd06.prod.outlook.com (25.161.11.13) Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB0569; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004); SRVR:SG2PR06MB0569; X-Forefront-PRVS: 0486A0CB86 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6049001)(6009001)(36756003)(2351001)(77156002)(110136001)(62966003)(19580395003)(80316001)(23736002)(229853001)(50466002)(450100001)(120846001)(33656002)(54356999)(46102003)(65816999)(50986999)(92566002)(77096005)(83506001)(42186005)(86362001)(66066001)(86152002)(40100003)(65956001)(19580405001)(122386002)(47776003); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR06MB0569; H:[10.161.20.223]; FPR:; SPF:None; MLV:sfv; LANG:en; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:; SRVR:SG2PR06MB0569; X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2015 05:56:05.7888 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB0569 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Current PIO mode occurred kernel panic with CONFIG_HIGHMEM. This patch fixes the kernel panic by converting the driver to the sg_miter API. Reported-by: Cao Minh Hiep Signed-off-by: Keita Kobayashi --- This patch is based on renesas.git / renesas-devel-20150211-v3.19 tag. drivers/mmc/host/tmio_mmc.h | 1 + drivers/mmc/host/tmio_mmc_pio.c | 35 ++++++++++++++++------------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index a34ecbe..3092219 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h @@ -56,6 +56,7 @@ struct tmio_mmc_host { struct scatterlist *sg_orig; unsigned int sg_len; unsigned int sg_off; + struct sg_mapping_iter sg_miter; struct platform_device *pdev; struct tmio_mmc_data *pdata; diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c index 250bf8c..6d8f363 100644 --- a/drivers/mmc/host/tmio_mmc_pio.c +++ b/drivers/mmc/host/tmio_mmc_pio.c @@ -70,17 +70,14 @@ static void tmio_mmc_ack_mmc_irqs(struct tmio_mmc_host *host, u32 i) static void tmio_mmc_init_sg(struct tmio_mmc_host *host, struct mmc_data *data) { - host->sg_len = data->sg_len; - host->sg_ptr = data->sg; - host->sg_orig = data->sg; - host->sg_off = 0; -} + unsigned int flags = SG_MITER_ATOMIC; -static int tmio_mmc_next_sg(struct tmio_mmc_host *host) -{ - host->sg_ptr = sg_next(host->sg_ptr); - host->sg_off = 0; - return --host->sg_len; + if (data->flags & MMC_DATA_READ) + flags |= SG_MITER_TO_SG; + else + flags |= SG_MITER_FROM_SG; + + sg_miter_start(&host->sg_miter, data->sg, data->sg_len, flags); } #ifdef CONFIG_MMC_DEBUG @@ -418,7 +415,7 @@ static void tmio_mmc_transfer_data(struct tmio_mmc_host *host, static void tmio_mmc_pio_irq(struct tmio_mmc_host *host) { struct mmc_data *data = host->data; - void *sg_virt; + struct sg_mapping_iter *sg_miter = &host->sg_miter; unsigned short *buf; unsigned int count; unsigned long flags; @@ -431,10 +428,12 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host) return; } - sg_virt = tmio_mmc_kmap_atomic(host->sg_ptr, &flags); - buf = (unsigned short *)(sg_virt + host->sg_off); + local_irq_save(flags); - count = host->sg_ptr->length - host->sg_off; + if (!sg_miter_next(sg_miter)) + return; + buf = sg_miter->addr; + count = sg_miter->length; if (count > data->blksz) count = data->blksz; @@ -444,12 +443,10 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host) /* Transfer the data */ tmio_mmc_transfer_data(host, buf, count); - host->sg_off += count; - - tmio_mmc_kunmap_atomic(host->sg_ptr, &flags, sg_virt); + sg_miter->consumed = count; + sg_miter_stop(sg_miter); - if (host->sg_off == host->sg_ptr->length) - tmio_mmc_next_sg(host); + local_irq_restore(flags); return; }