From patchwork Fri Mar 24 22:10:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9644087 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8AA2E602C9 for ; Fri, 24 Mar 2017 22:16:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B761206AC for ; Fri, 24 Mar 2017 22:16:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 702AE2522B; Fri, 24 Mar 2017 22:16:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E736206AC for ; Fri, 24 Mar 2017 22:16:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754909AbdCXWQB (ORCPT ); Fri, 24 Mar 2017 18:16:01 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33516 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754733AbdCXWQA (ORCPT ); Fri, 24 Mar 2017 18:16:00 -0400 Received: by mail-wm0-f65.google.com with SMTP id n11so632299wma.0 for ; Fri, 24 Mar 2017 15:15:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=pTxo3ovxNA2reIkFXa/AnpCBEO/ZUNDvWsiJ+4CyC8s=; b=qa+BPch6xDmjDqaaOpYH28/zGCBzQSBOX/JBPc4MyXk1h1XF9tj+YFhNdRoDNrpceD yF/gL7V6y4W9JiceZy1e9yFKWpwJcDLTjBftYktz5d71FSDiz/hbz184eC0VKN4tGbGC RR2jbMu3ZueTpg2sUo9vfeTnJn91G56tHwpYyNkwM+JDjNlb/Dd10Abuk7XTtoOwZ1LG yH2eZIgC948QVQESW66DyXxv9TVdpakfRBmkdfFf1msAcpp+07HeByrRUUsU7IKaJ64j DL89S04/hutv2s3Xf/tZetLqX7OvDaiBWkIrpPvDgjQYo/3OIPPdMwxdA/F9u7IOoX4Q x1uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=pTxo3ovxNA2reIkFXa/AnpCBEO/ZUNDvWsiJ+4CyC8s=; b=jEd6VHrFUcnc+rN40oZNNkypSYiGA8b9XZHy6upzgHBD+eg8fMvqT5n8Di1NMLkDOf e+4/4fWT2vj36CWYuMjsD1dNlatyfbh6eS5ZgQvS+QPZDWPXKVIlOQn21k/c75UXiYcN 2nfONvoEV4eA8CJzBHTk2UsjYFtToas8A7k2H3+shsUWWTNCgtl7WO6j6XAFo36XPr8r 77Ik9myqyW9UigAEXlyufAMgoddSOrh0QmiJJFW6k69E8RkcnhAuvS7BnQjSkaWQ6mmd G8yAX4agmTWsapIkIrGRytjflFrMTJyvKKtvxooKYLJg9QF0GsxP/0Fcrg+Xpn/B+8ZB f/DQ== X-Gm-Message-State: AFeK/H3eMiXVkrHXTEqSmiGMUCHXOa5/GRKKlk5+iMRi71uvpS3Y3entsYkbbGNaqyqUVw== X-Received: by 10.28.71.87 with SMTP id u84mr5015643wma.101.1490393758896; Fri, 24 Mar 2017 15:15:58 -0700 (PDT) Received: from ?IPv6:2003:c6:ebdc:4000:f190:68e:63eb:6801? (p200300C6EBDC4000F190068E63EB6801.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:f190:68e:63eb:6801]) by smtp.googlemail.com with ESMTPSA id j77sm4033758wmj.3.2017.03.24.15.15.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Mar 2017 15:15:58 -0700 (PDT) Subject: [PATCH 3/4] mmc: meson-gx: switch to dynamic timeout values To: Ulf Hansson , Kevin Hilman References: Cc: "linux-mmc@vger.kernel.org" , linux-amlogic@lists.infradead.org From: Heiner Kallweit Message-ID: Date: Fri, 24 Mar 2017 23:10:58 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently we use a fixed timeout of 4s for all data transfers. Switch to dynamic timeout values by making use of data->timeout_ns. Signed-off-by: Heiner Kallweit Reviewed-by: Kevin Hilman --- drivers/mmc/host/meson-gx-mmc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index b0a9317b..e637b3ba 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -169,6 +169,18 @@ struct sd_emmc_desc { #define CMD_RESP_MASK GENMASK(31, 1) #define CMD_RESP_SRAM BIT(0) +static unsigned int meson_mmc_get_timeout(struct mmc_data *data) +{ + unsigned int timeout = data->timeout_ns / NSEC_PER_MSEC; + + if (!timeout) + return SD_EMMC_CMD_TIMEOUT_DATA; + + timeout = roundup_pow_of_two(timeout); + + return min(timeout, 32768U); /* max. 2^15 ms */ +} + static int meson_mmc_clk_set(struct meson_host *host, unsigned long clk_rate) { struct mmc_host *mmc = host->mmc; @@ -448,7 +460,7 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) if (data) { cmd_cfg |= CMD_CFG_DATA_IO; cmd_cfg |= FIELD_PREP(CMD_CFG_TIMEOUT_MASK, - ilog2(SD_EMMC_CMD_TIMEOUT_DATA)); + ilog2(meson_mmc_get_timeout(data))); if (data->blocks > 1) { cmd_cfg |= CMD_CFG_BLOCK_MODE;