From patchwork Fri Dec 5 11:11:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 5443371 Return-Path: X-Original-To: patchwork-linux-mmc@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 75F719F30B for ; Fri, 5 Dec 2014 11:44:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BCB7020265 for ; Fri, 5 Dec 2014 11:44:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A45432025A for ; Fri, 5 Dec 2014 11:44:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751168AbaLELoD (ORCPT ); Fri, 5 Dec 2014 06:44:03 -0500 Received: from mail-bl2on0139.outbound.protection.outlook.com ([65.55.169.139]:38256 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751122AbaLELoB (ORCPT ); Fri, 5 Dec 2014 06:44:01 -0500 X-Greylist: delayed 1154 seconds by postgrey-1.27 at vger.kernel.org; Fri, 05 Dec 2014 06:44:01 EST Received: from DM2PR03CA0041.namprd03.prod.outlook.com (10.141.96.40) by BY2PR0301MB0630.namprd03.prod.outlook.com (25.160.125.28) with Microsoft SMTP Server (TLS) id 15.1.31.17; Fri, 5 Dec 2014 11:43:59 +0000 Received: from BN1AFFO11FD035.protection.gbl (2a01:111:f400:7c10::115) by DM2PR03CA0041.outlook.office365.com (2a01:111:e400:2428::40) with Microsoft SMTP Server (TLS) id 15.1.31.17 via Frontend Transport; Fri, 5 Dec 2014 11:43:58 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD035.mail.protection.outlook.com (10.58.52.159) with Microsoft SMTP Server (TLS) id 15.1.26.17 via Frontend Transport; Fri, 5 Dec 2014 11:43:57 +0000 Received: from shlinux1.ap.freescale.net (shlinux1.ap.freescale.net [10.192.225.216]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id sB5BhqfB028046; Fri, 5 Dec 2014 04:43:53 -0700 Date: Fri, 5 Dec 2014 19:11:01 +0800 From: Dong Aisheng To: Ulf Hansson CC: , Chris Ball , Seungwon Jeon , Jaehoon Chung , Shawn Guo , Sascha Hauer , Stephen Boyd , Minda Chen , Barry Song Subject: Re: [PATCH 1/4] mmc: sdhci-esdhc-imx: Convert to mmc_send_tuning() Message-ID: <20141205111100.GC21173@shlinux1.ap.freescale.net> References: <1417449730-5880-1-git-send-email-ulf.hansson@linaro.org> <1417449730-5880-2-git-send-email-ulf.hansson@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1417449730-5880-2-git-send-email-ulf.hansson@linaro.org> User-Agent: Mutt/1.5.20 (2009-06-14) X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(979002)(6009001)(189002)(199003)(51704005)(24454002)(19580395003)(6806004)(19580405001)(31966008)(99396003)(33656002)(23726002)(83506001)(84676001)(77096005)(68736005)(54356999)(76176999)(50986999)(92566001)(87936001)(20776003)(47776003)(97756001)(120916001)(64706001)(77156002)(110136001)(230783001)(105606002)(62966003)(104016003)(107046002)(46406003)(106466001)(46102003)(97736003)(21056001)(50466002)(4396001)(42262002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR0301MB0630; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB0630; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(602002); SRVR:BY2PR0301MB0630; X-Forefront-PRVS: 04163EF38A Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=Aisheng.Dong@freescale.com; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:; SRVR:BY2PR0301MB0630; X-OriginatorOrg: freescale.com Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@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 On Mon, Dec 01, 2014 at 05:02:07PM +0100, Ulf Hansson wrote: > Instead of having a local function taking care of sending the tuning > command, let's use the common mmc_send_tuning() API provided by the mmc > core. In this way the request will be handled as any other request by > sdhci core. > > As an effect of this change, the pm_runtime_get_sync() call at > esdhc_prepare_tuning() isn't needed any more. > > This patch will also introduce another change in behavior, since before > the response pattern to the tuning command wasn't verified by > sdhci-esdhc-imx. The mmc_send_tuning() does that. > > Signed-off-by: Ulf Hansson After applying your mmc_send_tuning() fix patch and it's usage update, i tested it worked well on a imx6dl sabreauto board. So you can add my tag when update the patch. Tested-by: Dong Aisheng Acked-by: Dong Aisheng Regards Dong Aisheng > --- > drivers/mmc/host/sdhci-esdhc-imx.c | 68 ++------------------------------------ > 1 file changed, 3 insertions(+), 65 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c > index 0135f00..a33d64c 100644 > --- a/drivers/mmc/host/sdhci-esdhc-imx.c > +++ b/drivers/mmc/host/sdhci-esdhc-imx.c > @@ -65,8 +65,6 @@ > /* NOTE: the minimum valid tuning start tap for mx6sl is 1 */ > #define ESDHC_TUNING_START_TAP 0x1 > > -#define ESDHC_TUNING_BLOCK_PATTERN_LEN 64 > - > /* pinctrl state */ > #define ESDHC_PINCTRL_STATE_100MHZ "state_100mhz" > #define ESDHC_PINCTRL_STATE_200MHZ "state_200mhz" > @@ -692,8 +690,6 @@ static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val) > /* FIXME: delay a bit for card to be ready for next tuning due to errors */ > mdelay(1); > > - /* This is balanced by the runtime put in sdhci_tasklet_finish */ > - pm_runtime_get_sync(host->mmc->parent); > reg = readl(host->ioaddr + ESDHC_MIX_CTRL); > reg |= ESDHC_MIX_CTRL_EXE_TUNE | ESDHC_MIX_CTRL_SMPCLK_SEL | > ESDHC_MIX_CTRL_FBCLK_SEL; > @@ -704,54 +700,6 @@ static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val) > val, readl(host->ioaddr + ESDHC_TUNE_CTRL_STATUS)); > } > > -static void esdhc_request_done(struct mmc_request *mrq) > -{ > - complete(&mrq->completion); > -} > - > -static int esdhc_send_tuning_cmd(struct sdhci_host *host, u32 opcode, > - struct scatterlist *sg) > -{ > - struct mmc_command cmd = {0}; > - struct mmc_request mrq = {NULL}; > - struct mmc_data data = {0}; > - > - cmd.opcode = opcode; > - cmd.arg = 0; > - cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; > - > - data.blksz = ESDHC_TUNING_BLOCK_PATTERN_LEN; > - data.blocks = 1; > - data.flags = MMC_DATA_READ; > - data.sg = sg; > - data.sg_len = 1; > - > - mrq.cmd = &cmd; > - mrq.cmd->mrq = &mrq; > - mrq.data = &data; > - mrq.data->mrq = &mrq; > - mrq.cmd->data = mrq.data; > - > - mrq.done = esdhc_request_done; > - init_completion(&(mrq.completion)); > - > - spin_lock_irq(&host->lock); > - host->mrq = &mrq; > - > - sdhci_send_command(host, mrq.cmd); > - > - spin_unlock_irq(&host->lock); > - > - wait_for_completion(&mrq.completion); > - > - if (cmd.error) > - return cmd.error; > - if (data.error) > - return data.error; > - > - return 0; > -} > - > static void esdhc_post_tuning(struct sdhci_host *host) > { > u32 reg; > @@ -763,21 +711,13 @@ static void esdhc_post_tuning(struct sdhci_host *host) > > static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode) > { > - struct scatterlist sg; > - char *tuning_pattern; > int min, max, avg, ret; > > - tuning_pattern = kmalloc(ESDHC_TUNING_BLOCK_PATTERN_LEN, GFP_KERNEL); > - if (!tuning_pattern) > - return -ENOMEM; > - > - sg_init_one(&sg, tuning_pattern, ESDHC_TUNING_BLOCK_PATTERN_LEN); > - > /* find the mininum delay first which can pass tuning */ > min = ESDHC_TUNE_CTRL_MIN; > while (min < ESDHC_TUNE_CTRL_MAX) { > esdhc_prepare_tuning(host, min); > - if (!esdhc_send_tuning_cmd(host, opcode, &sg)) > + if (!mmc_send_tuning(host->mmc->card)) > break; > min += ESDHC_TUNE_CTRL_STEP; > } > @@ -786,7 +726,7 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode) > max = min + ESDHC_TUNE_CTRL_STEP; > while (max < ESDHC_TUNE_CTRL_MAX) { > esdhc_prepare_tuning(host, max); > - if (esdhc_send_tuning_cmd(host, opcode, &sg)) { > + if (mmc_send_tuning(host->mmc->card)) { > max -= ESDHC_TUNE_CTRL_STEP; > break; > } > @@ -796,11 +736,9 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode) > /* use average delay to get the best timing */ > avg = (min + max) / 2; > esdhc_prepare_tuning(host, avg); > - ret = esdhc_send_tuning_cmd(host, opcode, &sg); > + ret = mmc_send_tuning(host->mmc->card); > esdhc_post_tuning(host); > > - kfree(tuning_pattern); > - > dev_dbg(mmc_dev(host->mmc), "tunning %s at 0x%x ret %d\n", > ret ? "failed" : "passed", avg, ret); > > -- > 1.9.1 > --- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index a33d64c..12711ab 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -717,7 +717,7 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode) min = ESDHC_TUNE_CTRL_MIN; while (min < ESDHC_TUNE_CTRL_MAX) { esdhc_prepare_tuning(host, min); - if (!mmc_send_tuning(host->mmc->card)) + if (!mmc_send_tuning(host->mmc)) break; min += ESDHC_TUNE_CTRL_STEP; } @@ -726,7 +726,7 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode) max = min + ESDHC_TUNE_CTRL_STEP; while (max < ESDHC_TUNE_CTRL_MAX) { esdhc_prepare_tuning(host, max); - if (mmc_send_tuning(host->mmc->card)) { + if (mmc_send_tuning(host->mmc)) { max -= ESDHC_TUNE_CTRL_STEP; break; } @@ -736,7 +736,7 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode) /* use average delay to get the best timing */ avg = (min + max) / 2; esdhc_prepare_tuning(host, avg); - ret = mmc_send_tuning(host->mmc->card); + ret = mmc_send_tuning(host->mmc); esdhc_post_tuning(host); dev_dbg(mmc_dev(host->mmc), "tunning %s at 0x%x ret %d\n",