From patchwork Sat Mar 25 10:26:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9644499 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 3C1EB60328 for ; Sat, 25 Mar 2017 10:28:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1995F265B9 for ; Sat, 25 Mar 2017 10:28:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E7102684F; Sat, 25 Mar 2017 10:28:42 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 363E6265B9 for ; Sat, 25 Mar 2017 10:28:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751227AbdCYK2k (ORCPT ); Sat, 25 Mar 2017 06:28:40 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36279 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751242AbdCYK2j (ORCPT ); Sat, 25 Mar 2017 06:28:39 -0400 Received: by mail-wm0-f65.google.com with SMTP id x124so2332893wmf.3 for ; Sat, 25 Mar 2017 03:28:38 -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=LRmR5nfB7KFM0EmewCs11bDvoht8UefpkSNahS9pgbY=; b=HkJuRiQkcH1kOZ9i4kDuNEljDiX4XfG36RGJikIphk0GvFGB9+ggbU9rBBK4KN9EKr 3jimL7vUSqNupeBXGsI5yJO9FKFyfI/PdECT3NmfX4zs33astI4FkkcIZ9Ly+7dEFNKf pADBGwC1gvFoH059M9a6GbsrMn8f+sXNEcdgS2fD0VNcjNxBYCi4MkgMGRBMfeKgihGl 4HAyCFe5Jz/SPjxgRp1cmoDR4BigYiFEuM3yK1eXXreDKW8f1CTCqDjm8GsqpmCJwJLd bqVzZOE9Cy21BygrNvXqhwRbJ992lmILF4Tf3lx7WvMl9bKylREUuMHPUpjNHuI298PZ W8vg== 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=LRmR5nfB7KFM0EmewCs11bDvoht8UefpkSNahS9pgbY=; b=q7dkdHAe/CUtnY/5IKSH+PAcXSVl3BVwb9N/PMAaRg+epeIANEnD4XvqGusd4MEcsR UGJAzHFkaPOBWD398NIr9oBHo2hIOPcdPNsKjcmWREJFHjPa1FprlldvGRILSzgHRp4e LwqkvcJ4T82aK1tdslpkFYPNApm0NuYxqt3fkIHeou2zmKATX+kJ6ReqXO0Uk4Wk8XZI Ia8iU56YseZ3mfRPQQdUrWJHzsIH8QLeS9FSJJ97ko+tWZGdjfgR7ocDzHxZhPDvrkKf s0g1gYp2Gsz0Ix14pR+5rZN0Zu2w5EXk46p5mYcM0rtQ6hjojv+57573UhK3clwfIwDc dZBw== X-Gm-Message-State: AFeK/H2FMyTC69ErHYu2j/btzw/p/ykNaEhxl8f3s/63al3inC3uBkpxmn/cxFt+Nh1xuQ== X-Received: by 10.28.136.204 with SMTP id k195mr1468381wmd.99.1490437717442; Sat, 25 Mar 2017 03:28:37 -0700 (PDT) Received: from ?IPv6:2003:c6:ebdc:4000:b429:3993:904f:3ba7? (p200300C6EBDC4000B4293993904F3BA7.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:b429:3993:904f:3ba7]) by smtp.googlemail.com with ESMTPSA id 10sm6351442wrz.44.2017.03.25.03.28.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Mar 2017 03:28:36 -0700 (PDT) Subject: [PATCH v2 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: Sat, 25 Mar 2017 11:26:18 +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 --- v2: - added _msecs suffix to function name --- 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 0a0f5008..810b68d5 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -163,6 +163,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_msecs(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; @@ -441,7 +453,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_msecs(data))); if (data->blocks > 1) { cmd_cfg |= CMD_CFG_BLOCK_MODE;