From patchwork Fri Jul 13 03:58:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 1193651 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 8D3423FC33 for ; Fri, 13 Jul 2012 03:58:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753966Ab2GMD62 (ORCPT ); Thu, 12 Jul 2012 23:58:28 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:59326 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752901Ab2GMD61 (ORCPT ); Thu, 12 Jul 2012 23:58:27 -0400 Received: from epcpsbgm2.samsung.com (mailout3.samsung.com [203.254.224.33]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M72006MOZ1DQL20@mailout3.samsung.com> for linux-mmc@vger.kernel.org; Fri, 13 Jul 2012 12:58:26 +0900 (KST) X-AuditID: cbfee61b-b7f566d000005c8a-96-4fff9ce2e66b Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 49.34.23690.2EC9FFF4; Fri, 13 Jul 2012 12:58:26 +0900 (KST) Received: from [10.90.51.55] by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M7200810Z1CVZ50@mmp2.samsung.com> for linux-mmc@vger.kernel.org; Fri, 13 Jul 2012 12:58:25 +0900 (KST) Message-id: <4FFF9CD7.6000904@samsung.com> Date: Fri, 13 Jul 2012 12:58:15 +0900 From: Jaehoon Chung User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-version: 1.0 To: linux-mmc Cc: Chris Ball , Will Newton , James Hogan , Kyungmin Park Subject: [PATCH] mmc: dw-mmc: retry to send when inform ciu Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprILMWRmVeSWpSXmKPExsVy+t9jQd1Hc/77G2xsYLc48r+f0YHR4/Mm uQDGKC6blNSczLLUIn27BK6Mg1NOsBVsFKs4PF2qgfGnYBcjJ4eEgInEt651LBC2mMSFe+vZ uhi5OIQEpjNKNB/rZIFw2pkkTj1+AlbFK6Al0b3sOXsXIwcHi4CqxMZloSBhNgEdie3fjjOB 2KICYRKvpxyCKheU+DH5HpgtIqAp0bl9JdgCZoEZjBILNt8CaxAWsJa4s/wlM4jNDDRof+s0 NghbXmLzmrfMExj5ZiGZNQtJ2SwkZQsYmVcxiqYWJBcUJ6XnGukVJ+YWl+al6yXn525iBAfU M+kdjKsaLA4xCnAwKvHwTpjx31+INbGsuDL3EKMEB7OSCK/CNKAQb0piZVVqUX58UWlOavEh RmkOFiVxXhPvr/5CAumJJanZqakFqUUwWSYOTmB4Vnr/DbepTpHdPmfB4zlnNY9vWBlvHPKh KjBzl8YJHp0fCUbcd19ueNP/qlDW/6qLT6n1p2P5q0VNMkUVv+cGvs/jEp4c+PgBY2TjLHXj Hv0t4lN6r/IuOfRZunZ13m6p3g0bXtes1InpmWNiIisZlvv47jKtI9OvOnZszX6wXqDUtl7n yT4hJZbijERDLeai4kQAjzwgkyQCAAA= X-TM-AS-MML: No Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org As DesignWare spec, when inform ciu, waiting for clearing start_bit or HLE is set. In case of HLE, repeat the command. Before the patch, repeat the below message. mmc_host mmc0: Timeout sending command (cmd 0x202000 arg 0x0 status 0x80202000) If this message is produced, repeat the send command during 10 times. Signed-off-by: Jaehoon Chung Signed-off-by: Kyungmin Park --- drivers/mmc/host/dw_mmc.c | 39 +++++++++++++++++++++++++++++++-------- 1 files changed, 31 insertions(+), 8 deletions(-) -- 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/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 72dc3cd..bec1a67 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -603,7 +603,7 @@ static void dw_mci_submit_data(struct dw_mci *host, struct mmc_data *data) } } -static void mci_send_cmd(struct dw_mci_slot *slot, u32 cmd, u32 arg) +static int mci_send_cmd(struct dw_mci_slot *slot, u32 cmd, u32 arg) { struct dw_mci *host = slot->host; unsigned long timeout = jiffies + msecs_to_jiffies(500); @@ -616,11 +616,37 @@ static void mci_send_cmd(struct dw_mci_slot *slot, u32 cmd, u32 arg) while (time_before(jiffies, timeout)) { cmd_status = mci_readl(host, CMD); if (!(cmd_status & SDMMC_CMD_START)) - return; + return 0; } dev_err(&slot->mmc->class_dev, "Timeout sending command (cmd %#x arg %#x status %#x)\n", cmd, arg, cmd_status); + + return -ETIMEDOUT; +} + +static void dw_mci_inform_ciu(struct dw_mci_slot *slot) +{ + struct dw_mci *host = slot->host; + unsigned long retry = 10; + int ret; + u32 ctrl; + + while (1) { + ret = mci_send_cmd(slot, + SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); + if (!ret) + break; + ctrl = mci_readl(host, CTRL); + ctrl |= SDMMC_CTRL_RESET; + mci_writel(host, CTRL, ctrl); + + if (retry-- == 0) { + dev_err(&slot->mmc->class_dev,"Timeout inform CIU\n"); + break; + } else + dev_info(&slot->mmc->class_dev,"Retry send command\n"); + } } static void dw_mci_setup_bus(struct dw_mci_slot *slot) @@ -649,23 +675,20 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot) mci_writel(host, CLKSRC, 0); /* inform CIU */ - mci_send_cmd(slot, - SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); + dw_mci_inform_ciu(slot); /* set clock to desired speed */ mci_writel(host, CLKDIV, div); /* inform CIU */ - mci_send_cmd(slot, - SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); + dw_mci_inform_ciu(slot); /* enable clock */ mci_writel(host, CLKENA, ((SDMMC_CLKEN_ENABLE | SDMMC_CLKEN_LOW_PWR) << slot->id)); /* inform CIU */ - mci_send_cmd(slot, - SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); + dw_mci_inform_ciu(slot); host->current_speed = slot->clock; }