From patchwork Sat Jan 4 12:51:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arend van Spriel X-Patchwork-Id: 3433391 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4D5C3C02DD for ; Sat, 4 Jan 2014 12:51:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 76F76200C1 for ; Sat, 4 Jan 2014 12:51:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 742DF20136 for ; Sat, 4 Jan 2014 12:51:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751943AbaADMvs (ORCPT ); Sat, 4 Jan 2014 07:51:48 -0500 Received: from mail-gw2-out.broadcom.com ([216.31.210.63]:34456 "EHLO mail-gw2-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753367AbaADMv3 (ORCPT ); Sat, 4 Jan 2014 07:51:29 -0500 X-IronPort-AV: E=Sophos;i="4.95,603,1384329600"; d="scan'208";a="7615276" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw2-out.broadcom.com with ESMTP; 04 Jan 2014 05:00:14 -0800 Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.1.438.0; Sat, 4 Jan 2014 04:51:28 -0800 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.1.438.0; Sat, 4 Jan 2014 04:51:28 -0800 Received: from xl-bun-04.broadcom.com (xl-bun-04.bun.broadcom.com [10.176.128.58]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 486AC246A5; Sat, 4 Jan 2014 04:51:28 -0800 (PST) Received: by xl-bun-04.broadcom.com (Postfix, from userid 25152) id 985BCF01EAB; Sat, 4 Jan 2014 13:51:27 +0100 (CET) From: Arend van Spriel To: Chris Ball CC: , Arend van Spriel Subject: [PATCH V3] sdhci: only reprogram retuning timer when flag is set Date: Sat, 4 Jan 2014 13:51:26 +0100 Message-ID: <1388839886-18657-1-git-send-email-arend@broadcom.com> X-Mailer: git-send-email 1.8.1.3 MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 When the host->tuning_count is zero it means that the retuning is disabled. This is checked on the first run of sdhci_execute_tuning() by the if statement below: if (!(host->flags & SDHCI_NEEDS_RETUNING) && host->tuning_count && (host->tuning_mode == SDHCI_TUNING_MODE_1)) { So only when tuning_count is non-zero it will set the host flag SDHCI_USING_RETUNING_TIMER. The else statement is only for re-programming the timer, which means that flag must be set. Because that is not checked the else statement is executed in the first run when tuning_count is zero. This was seen on a host controller which indicated SDHCI_TUNING_MODE_1 (0) and tuning_count being zero. Suspect that (one of) these registers is not properly set. Signed-off-by: Arend van Spriel --- It has been a while looking at this, but I believe I never sent a V3 of this patch so here it is. This patch applies to the mmc-next branch. V3: - remote tuning mode check for retuning timer reload V2: - add more explanation to the commit message - check host flag SDHCI_USING_RETUNING_TIMER --- drivers/mmc/host/sdhci.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index cc00bed..058b7de 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2026,12 +2026,11 @@ out: host->tuning_count * HZ); /* Tuning mode 1 limits the maximum data length to 4MB */ mmc->max_blk_count = (4 * 1024 * 1024) / mmc->max_blk_size; - } else { + } else if (host->flags & SDHCI_USING_RETUNING_TIMER) { host->flags &= ~SDHCI_NEEDS_RETUNING; /* Reload the new initial value for timer */ - if (host->tuning_mode == SDHCI_TUNING_MODE_1) - mod_timer(&host->tuning_timer, jiffies + - host->tuning_count * HZ); + mod_timer(&host->tuning_timer, jiffies + + host->tuning_count * HZ); } /*