Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp67487imu; Wed, 2 Jan 2019 14:15:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN5JuzCptWcur3/jAfYEjAlDTzTyAHicpax/dHgKwV/2Nq8JQQm4gEh4sq0+i+/rdSuGEH/V X-Received: by 2002:a17:902:8e8a:: with SMTP id bg10mr44929681plb.192.1546467342847; Wed, 02 Jan 2019 14:15:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546467342; cv=none; d=google.com; s=arc-20160816; b=MyCxueNMeFhfoyNt7IvDO4VKIEAoOye5O2Mx9LjvFSauO/XjDKNoWlcrL9kgt6LR2a oTBQDUiUmB1QVAzvSzn10+lIrsOCgasV3Y2wlVKAen4Ls7r8xH9nKY7THMtHFk1LQO0T CLM+10AH9EQa+WwX3hvYfLUk4aEX9amqvAUujPNxWooCGnb8jz0o+nhBZ/DxkvFwS95T SmyJzZ2qZ6nkKXBYCjkinkR4Nnrei4cEvB/Uadntk0QdfkXsxqvFG2CtZst3se8AOrtz nkUeXI/3h1doS/GnFf8Slcsx2HmeqrPmFZ4ecx/Yc8DSIa5//h+tt6JKd58egjrm5H3S qXqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=e3J2PKoNnhuKlbLXczQn3aGMt1Uyj5P+mc2x7Reu84M=; b=SXazPodfjYN71sy8LgO7Jo9qWBgJju+eyJ4J/89LR+chSg7i+nXFGSbTkwg7SVyuSi eZfR1k8i/HqbaDTh3KeGcc36wDCReTxpUxAXCN8oHzN/juSN0lmq7gUNOFpsGq35F+Th wrxb+id1FMlYnFLrRwdVfOQ9fe3ksrrRjVD4h6cjK2S+Kx1bHfKLYBiDaEZwP3BPCq4r mOm0FrZ563tE95SVXVyr7jgIJAQ3rYQxKFx1dQcIIEpTpoNq0Yh813aSM5CS5j9T6FWy ZWPu6/19V1i41AJTeWPIQ/dr4KkdFC7cO+MW0idgouuyCpTQ+isbUq3P+cStTDZceJAm YKdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="CeTsRIk/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1si28046864pgq.13.2019.01.02.14.15.26; Wed, 02 Jan 2019 14:15:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="CeTsRIk/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726913AbfABT4c (ORCPT + 99 others); Wed, 2 Jan 2019 14:56:32 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:38376 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726089AbfABT4b (ORCPT ); Wed, 2 Jan 2019 14:56:31 -0500 Received: by mail-pl1-f196.google.com with SMTP id e5so14912344plb.5; Wed, 02 Jan 2019 11:56:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=e3J2PKoNnhuKlbLXczQn3aGMt1Uyj5P+mc2x7Reu84M=; b=CeTsRIk/cQdt52ZinWN6hUuMdpGqfAWZ4sarniOPR/I3SMFJfAucdcTkxgeRCeIy9D q/OOF9dovnhbBQ/j3FKThPstJs79GF2jGwWwTr10ym6arJbItvqmyvszqkqQ+G4HPium duKyNeGWFNUuybAko5KrDvAmJ/8B4xZlfkmJ1OfopJvplB1tMQ9oSRa02yt7tLp41TzW k12peCQEb4u4BJIr3Ntft+/rA8id7/rnGsJmT33pJxIMws1tWokx7FIDNlh5pu3bQJmM 5inWyC1UvAQUhw/fC2FQBkuf1grOCwNcf/L4YjwhT+GFg97/SpSrZbpZBHHvo5U4S6Yf AwOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=e3J2PKoNnhuKlbLXczQn3aGMt1Uyj5P+mc2x7Reu84M=; b=oEsvNkPvhnDVAmUZ9QYl97UQ4inKHXmwmWks7EV53lRIHLy+tL5rd6vRsf0ivGtG7s DuzSF43/NbjkDtLQWWebe2SdrCvWwr9JFtc2kcOc7Jr0eOP74yX8ejAKG7wqwwbBu1g3 +0oqf3EOescITuFu9Rf+V1rptcGBtz34OfKLxD52nD1TRXGoWI6+owhH69SIgs0GQt4v /MqL8EI5WpijBdECvYq3eNMiYDMKjf3T93uXUBDoFdKVZO4H3TE3FJiGt32eN/1jc3Zm JB3CaIKx501XHQiu6ORCES2OzOfnsgWKPyLf/BLBIzBpn+NL2WtBmbCXF+lxBGJ925mF 3oAw== X-Gm-Message-State: AJcUukcdhkHQMEv1LjChhzbunJ5qufSFiLdWOgQaz0VdW/Zd1oB9/wlT s6ttVc8MuGVTZ3pEPzWsaF8= X-Received: by 2002:a17:902:20e9:: with SMTP id v38mr2006440plg.250.1546458990854; Wed, 02 Jan 2019 11:56:30 -0800 (PST) Received: from localhost.localdomain ([207.86.76.174]) by smtp.gmail.com with ESMTPSA id y5sm86943418pge.49.2019.01.02.11.56.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Jan 2019 11:56:30 -0800 (PST) Date: Wed, 2 Jan 2019 11:56:28 -0800 From: Eduardo Valentin To: Olof Johansson Cc: Ulf Hansson , Faiz Abbas , Linux Kernel Mailing List , "linux-mmc@vger.kernel.org" , Adrian Hunter , Kishon , Keerthy , Zhang Rui , Daniel Lezcano , Santosh Shilimkar , Tony Lindgren Subject: Re: [PATCH v2 2/2] mmc: sdhci-omap: Workaround errata regarding SDR104/HS200 tuning failures (i929) Message-ID: <20190102195626.GA2024@localhost.localdomain> References: <20181211142253.23747-1-faiz_abbas@ti.com> <20181211142253.23747-3-faiz_abbas@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 02, 2019 at 10:29:31AM -0800, Olof Johansson wrote: > Hi, > > > On Wed, Dec 12, 2018 at 1:20 AM Ulf Hansson wrote: > > > > + Thermal maintainers > > > > On Tue, 11 Dec 2018 at 15:20, Faiz Abbas wrote: > > > > > > Errata i929 in certain OMAP5/DRA7XX/AM57XX silicon revisions > > > (SPRZ426D - November 2014 - Revised February 2018 [1]) mentions > > > unexpected tuning pattern errors. A small failure band may be present > > > in the tuning range which may be missed by the current algorithm. > > > Furthermore, the failure bands vary with temperature leading to > > > different optimum tuning values for different temperatures. > > > > > > As suggested in the related Application Report (SPRACA9B - October 2017 > > > - Revised July 2018 [2]), tuning should be done in two stages. > > > In stage 1, assign the optimum ratio in the maximum pass window for the > > > current temperature. In stage 2, if the chosen value is close to the > > > small failure band, move away from it in the appropriate direction. > > > > > > References: > > > [1] http://www.ti.com/lit/pdf/sprz426 > > > [2] http://www.ti.com/lit/pdf/SPRACA9 > > > > > > Signed-off-by: Faiz Abbas > > > Acked-by: Adrian Hunter > > > --- > > > drivers/mmc/host/Kconfig | 2 + > > > drivers/mmc/host/sdhci-omap.c | 90 ++++++++++++++++++++++++++++++++++- > > > 2 files changed, 91 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig > > > index 5fa580cec831..d8f984483ab0 100644 > > > --- a/drivers/mmc/host/Kconfig > > > +++ b/drivers/mmc/host/Kconfig > > > @@ -977,6 +977,8 @@ config MMC_SDHCI_XENON > > > config MMC_SDHCI_OMAP > > > tristate "TI SDHCI Controller Support" > > > depends on MMC_SDHCI_PLTFM && OF > > > + select THERMAL > > > + select TI_SOC_THERMAL > > > help > > > This selects the Secure Digital Host Controller Interface (SDHCI) > > > support present in TI's DRA7 SOCs. The controller supports > > > diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c > > > index f588ab679cb0..b75c55011fcb 100644 > > > --- a/drivers/mmc/host/sdhci-omap.c > > > +++ b/drivers/mmc/host/sdhci-omap.c > > > @@ -27,6 +27,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > > > > #include "sdhci-pltfm.h" > > > > > > @@ -286,15 +287,19 @@ static int sdhci_omap_execute_tuning(struct mmc_host *mmc, u32 opcode) > > > struct sdhci_host *host = mmc_priv(mmc); > > > struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); > > > struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); > > > + struct thermal_zone_device *thermal_dev; > > > struct device *dev = omap_host->dev; > > > struct mmc_ios *ios = &mmc->ios; > > > u32 start_window = 0, max_window = 0; > > > + bool single_point_failure = false; > > > bool dcrc_was_enabled = false; > > > u8 cur_match, prev_match = 0; > > > u32 length = 0, max_len = 0; > > > u32 phase_delay = 0; > > > + int temperature; > > > int ret = 0; > > > u32 reg; > > > + int i; > > > > > > /* clock tuning is not needed for upto 52MHz */ > > > if (ios->clock <= 52000000) > > > @@ -304,6 +309,16 @@ static int sdhci_omap_execute_tuning(struct mmc_host *mmc, u32 opcode) > > > if (ios->timing == MMC_TIMING_UHS_SDR50 && !(reg & CAPA2_TSDR50)) > > > return 0; > > > > > > + thermal_dev = thermal_zone_get_zone_by_name("cpu_thermal"); > > > > I couldn't find a corresponding call to a put function, like > > "thermal_zone_put()" or whatever, which made me realize that the > > thermal zone API is incomplete. Or depending on how you put it, it > > lacks object reference counting, unless I am missing something. > > > > For example, what happens if the thermal zone becomes unregistered > > between this point and when you call thermal_zone_get_temp() a couple > > of line below. I assume it's a known problem, but just wanted to point > > it out. > > Yes, there is no ref counting. Specially because the get zones usages were too specific, and mostly used in application cases that module would not really be removed. Though not a good excuse, still, not very problematic. Now, if the API is getting other usages, then refcounting may be necessary. > > > + if (IS_ERR(thermal_dev)) { > > > + dev_err(dev, "Unable to get thermal zone for tuning\n"); > > > + return PTR_ERR(thermal_dev); > > > + } > > > + > > > + ret = thermal_zone_get_temp(thermal_dev, &temperature); > > > + if (ret) > > > + return ret; > > > + > > > > [...] > > > > Anyway, I have applied this for next, thanks! > > This is throwing errors on builds of keystone_defconfig in next and mainline: > > http://arm-soc.lixom.net/buildlogs/next/next-20190102/buildall.arm.keystone_defconfig.log.passed > > WARNING: unmet direct dependencies detected for TI_SOC_THERMAL > Depends on [n]: THERMAL [=y] && (ARCH_HAS_BANDGAP [=n] || > COMPILE_TEST [=n]) && HAS_IOMEM [=y] > Selected by [y]: > - MMC_SDHCI_OMAP [=y] && MMC [=y] && MMC_SDHCI_PLTFM [=y] && OF [=y] > > So, thermal depends on ARCH_HAS_BANDGAP, which keystone doesn't provide. > > Selecting a major framework such as THERMAL from a driver config is > likely not the right solution anyway, especially since THERMAL does > provide stubbed out versions of the functions if it's not enabled. Yeah, that seams a bit up-side-down. Can you guys give a bit more of context? Why do you need the cpu thermal zone ? From patch description, looks like you want to have your own zone then apply different tuning values based on temperature (range?). Why do you need to mess up with cpu_thermal zone? Don't you have a bandgap in the mem controller for this application? > > > -Olof