From patchwork Tue Jul 29 08:44:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 4638981 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D0A529F32F for ; Tue, 29 Jul 2014 08:44:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BF4402018B for ; Tue, 29 Jul 2014 08:44:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8BCA920149 for ; Tue, 29 Jul 2014 08:44:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752903AbaG2Ioa (ORCPT ); Tue, 29 Jul 2014 04:44:30 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:45155 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752896AbaG2Io0 (ORCPT ); Tue, 29 Jul 2014 04:44:26 -0400 Received: by mail-pa0-f41.google.com with SMTP id rd3so12061718pab.28 for ; Tue, 29 Jul 2014 01:44:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:sender:message-id:from:subject:user-agent:mime-version:to:cc :in-reply-to:references:content-type; bh=6PbpryCurUTGV1lW/MemH+GMnyFJ/15FbGD07cEQ1Hk=; b=rTLK6PjykOxuqKITfr0r1Eb7vkVVSJc2ti4vXBqWbYBRZ9QSoLR25M9WI9IMidW4jw RPp8M+y/itEAH98KC5i5iTw4vqlAvGqKrAT0VsaIzKKmwC4IzFHZGTgRAWERRxPj1zNY 8he9LXesUO+twLkzaj6sCgtgaS6w+uo0cxER/Yt1uZJN4JBjdNbCMLomEF+VyyBezG1i x9PA7+oVsdokrh2AQAViWtkiXUZwknPkM8KRd0WEHhORB7sbs/UwqyGX8rbR3mDxgmu+ ABWzTNSYzqocaoMuWCKBYOdgBdOoymzekWy5Hfne9gUNEZP+5GJDWiS7XP8nCVRipuZN QccQ== X-Received: by 10.70.1.100 with SMTP id 4mr447812pdl.147.1406623465805; Tue, 29 Jul 2014 01:44:25 -0700 (PDT) Received: from remon.gmail.com (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPSA id q6sm27937712pdp.5.2014.07.29.01.44.23 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 29 Jul 2014 01:44:25 -0700 (PDT) Date: Tue, 29 Jul 2014 01:44:25 -0700 (PDT) Message-ID: <87lhrco8pl.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 01/10 v2] mmc: block: add block number limitation flag for multiple block read User-Agent: Wanderlust/2.14.0 Emacs/23.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") To: Simon , Chris Ball Cc: Ian Molton , TOSHIAKI KOMATSU , NAOYA SHIIBA , Magnus , Linux-SH , (Renesas) goda , linux-mmc@vger.kernel.org, ryo.kataoka.wt@renesas.com, shinobu.uehara.xc@renesas.com, kouei.abe.cp@renesas.com, cm-hiep@jinso.co.jp, Kuninori Morimoto , Kuninori Morimoto In-Reply-To: <87mwbso8sp.wl%kuninori.morimoto.gx@gmail.com> References: <87simtenpi.wl%kuninori.morimoto.gx@renesas.com> <87pphxe2q0.wl%kuninori.morimoto.gx@renesas.com> <53AD638C.5060907@renesas.com> <87egxehsec.wl%kuninori.morimoto.gx@gmail.com> <87mwbso8sp.wl%kuninori.morimoto.gx@gmail.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 From: Shinobu Uehara In some controllers, when performing a multiple block read of one or two blocks, depending on the timing with which the response register is read, the response value may not be read properly. MMC_CAP2_NO_MULTI_READ flags disable all multiple block read, but, it is over-kill for this issue. This patch adds new MMC_CAP2_2BLKS_LIMIT to use single block read when it was two blocks. This is additional option of MMC_CAP2_NO_MULTI_READ [Kuninori Morimoto: tidyup for upstreaming, and cared mach-shmobile] Signed-off-by: Shinobu Uehara Signed-off-by: Kuninori Morimoto --- arch/arm/mach-shmobile/board-koelsch.c | 6 +++--- arch/arm/mach-shmobile/board-lager.c | 4 ++-- drivers/mmc/card/block.c | 19 +++++++++++++++++-- drivers/mmc/host/sh_mobile_sdhi.c | 2 +- include/linux/mmc/host.h | 3 +++ 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-shmobile/board-koelsch.c b/arch/arm/mach-shmobile/board-koelsch.c index 2cd3194..4936436 100644 --- a/arch/arm/mach-shmobile/board-koelsch.c +++ b/arch/arm/mach-shmobile/board-koelsch.c @@ -333,7 +333,7 @@ SDHI_REGULATOR(2, RCAR_GP_PIN(7, 19), RCAR_GP_PIN(2, 26)); static struct sh_mobile_sdhi_info sdhi0_info __initdata = { .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD, - .tmio_caps2 = MMC_CAP2_NO_MULTI_READ, + .tmio_caps2 = MMC_CAP2_NO_2BLKS_READ, .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT, }; @@ -346,7 +346,7 @@ static struct resource sdhi0_resources[] __initdata = { static struct sh_mobile_sdhi_info sdhi1_info __initdata = { .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD, - .tmio_caps2 = MMC_CAP2_NO_MULTI_READ, + .tmio_caps2 = MMC_CAP2_NO_2BLKS_READ, .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT, }; @@ -359,7 +359,7 @@ static struct resource sdhi1_resources[] __initdata = { static struct sh_mobile_sdhi_info sdhi2_info __initdata = { .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD, - .tmio_caps2 = MMC_CAP2_NO_MULTI_READ, + .tmio_caps2 = MMC_CAP2_NO_2BLKS_READ, .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE, }; diff --git a/arch/arm/mach-shmobile/board-lager.c b/arch/arm/mach-shmobile/board-lager.c index b8b2b44..ad85f9d 100644 --- a/arch/arm/mach-shmobile/board-lager.c +++ b/arch/arm/mach-shmobile/board-lager.c @@ -634,7 +634,7 @@ static void __init lager_add_rsnd_device(void) static struct sh_mobile_sdhi_info sdhi0_info __initdata = { .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD, - .tmio_caps2 = MMC_CAP2_NO_MULTI_READ, + .tmio_caps2 = MMC_CAP2_NO_2BLKS_READ, .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE, }; @@ -648,7 +648,7 @@ static struct resource sdhi0_resources[] __initdata = { static struct sh_mobile_sdhi_info sdhi2_info __initdata = { .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD, - .tmio_caps2 = MMC_CAP2_NO_MULTI_READ, + .tmio_caps2 = MMC_CAP2_NO_2BLKS_READ, .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE, }; diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 452782b..f3cbe37 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -1400,8 +1400,23 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, /* Some controllers can't do multiblock reads due to hw bugs */ if (card->host->caps2 & MMC_CAP2_NO_MULTI_READ && - rq_data_dir(req) == READ) - brq->data.blocks = 1; + rq_data_dir(req) == READ) { + + if (card->host->caps2 & MMC_CAP2_2BLKS_LIMIT) { + /* + * In some controllers, when performing a + * multiple block read of one or two blocks, + * depending on the timing with which the + * response register is read, the response + * value may not be read properly. + * Use single block read for this HW bug + */ + if (brq->data.blocks == 2) + brq->data.blocks = 1; + } else { + brq->data.blocks = 1; + } + } } if (brq->data.blocks > 1 || do_rel_wr) { diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index 91058da..b3baa83 100644 --- a/drivers/mmc/host/sh_mobile_sdhi.c +++ b/drivers/mmc/host/sh_mobile_sdhi.c @@ -55,7 +55,7 @@ static const struct sh_mobile_sdhi_of_data of_rcar_gen1_compatible = { static const struct sh_mobile_sdhi_of_data of_rcar_gen2_compatible = { .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE, .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ, - .capabilities2 = MMC_CAP2_NO_MULTI_READ, + .capabilities2 = MMC_CAP2_NO_2BLKS_READ, }; static const struct of_device_id sh_mobile_sdhi_of_match[] = { diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 7960424..3510fba 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -266,6 +266,9 @@ struct mmc_host { #define MMC_CAP2_BOOTPART_NOACC (1 << 0) /* Boot partition no access */ #define MMC_CAP2_FULL_PWR_CYCLE (1 << 2) /* Can do full power cycle */ #define MMC_CAP2_NO_MULTI_READ (1 << 3) /* Multiblock reads don't work */ +#define MMC_CAP2_2BLKS_LIMIT (1 << 4) /* 2 blocks limit for multi read */ +#define MMC_CAP2_NO_2BLKS_READ (MMC_CAP2_NO_MULTI_READ | \ + MMC_CAP2_2BLKS_LIMIT) #define MMC_CAP2_HS200_1_8V_SDR (1 << 5) /* can support */ #define MMC_CAP2_HS200_1_2V_SDR (1 << 6) /* can support */ #define MMC_CAP2_HS200 (MMC_CAP2_HS200_1_8V_SDR | \