Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp10510417pxu; Wed, 30 Dec 2020 04:57:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCiGN2dJRizyDqqI9jU+hXfsZx9Qx4ZurAym/1qXfXrvCK6x6bNFm68Y94qvVFIQW6PPOl X-Received: by 2002:a50:eb97:: with SMTP id y23mr50506536edr.29.1609333073869; Wed, 30 Dec 2020 04:57:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609333073; cv=none; d=google.com; s=arc-20160816; b=RI7zEzo19MV/CJTrCoSpE+otGT6hD7OwAvNkNOa8ZOzBLfCz6hw+v18/vXOe1J7/9p zpgBl3pr1locUWiONk0YlabjkFLRCIph/Y7QMpS80E/qW6WT9lj7LD8FAz2/XbZCiA7J 5PQdyU2TgdZrBAxCSCaSkJPjXku2jtnjTiZxb/h3E04+43nsEeLeNU9aiRrDoXU/hpDO R9mmStcE52QuKUgbP6MWGlcBLjWb7+g/w+JrmNQRYqVKujipTVqIpYVG3uuQTrVnITq7 zL6OmWIAW78FlN2tJy+oH1SwRpUel5AdHI8gNNCtfDaHdm1pCeVMT/ziKHqRRs99p4Kz wcyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9iM8agE+iBHoHtomhdS9+F4PQej5FoCFnQcb+9OYTYo=; b=vhmXVK3EOsqo54OaA4FxwL5+mp1dqlurC/wmGx0uftxurmAEt6Rgy+qXMeIjTWjXrR r3jItdZtgkQRt0LToSd4QOggn8ELcU91IvEc1qgv9puStDO6QO1CFzzM16n6t5aOoMG3 8sLV0u59qj4ijry5m2gzLx629oLkBhw0IMsveR5plkR38a0kdW5Ubwsp9RHcAvSqQgsJ WJRf7mtRzvN177jK4dvNO7IcAVzhQYyZyJlH0H0f/s1hocbo2GDJu/u+H32RKuyLqH3+ FdYJDPOKGCPpN+kgnHfEfBsrXItD/zRojAEYXhX8XCRsMvy/GBlR88FNqIDDQkB2vd7g zvdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qcrBD3ew; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id p8si23174780edm.143.2020.12.30.04.57.30; Wed, 30 Dec 2020 04:57:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qcrBD3ew; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726734AbgL3M43 (ORCPT + 99 others); Wed, 30 Dec 2020 07:56:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726718AbgL3M43 (ORCPT ); Wed, 30 Dec 2020 07:56:29 -0500 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDD4EC061799; Wed, 30 Dec 2020 04:55:48 -0800 (PST) Received: by mail-io1-xd33.google.com with SMTP id u26so11943466iof.3; Wed, 30 Dec 2020 04:55:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9iM8agE+iBHoHtomhdS9+F4PQej5FoCFnQcb+9OYTYo=; b=qcrBD3ewqL9uTP40JE4/GruakE9eY8RlTppWfe+U2wKAyFKPY8g1ZeXHPppVbyzHoo abNCbK7FoZsj1EQHF+Mg7ft0g/vHAf/vl+l3l6EHoxDn6d2Q4gAk0r74ogPAq0Wos5hX VqvlAxp2N+MgGvlzoa0z8QPPo1xPoaSxKpTA0QxBBiFb+xdKhm3FyFlikENBt09z7RZy 82sQkswul5bum4cFE59MnX47aHi7hxHAflFvXZGDlkgY3kvbAy9W9aR8NaPR6LhIn7cH uKmj7LZWy2900qb851jKa5StVC3PgOsy/XPol3H74V6j/+zVBXKeXQM9ADKHDyH2FJpR 122w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9iM8agE+iBHoHtomhdS9+F4PQej5FoCFnQcb+9OYTYo=; b=cK1ncm4xDSWc9vs+R/4DJPkxFihKKwhLaeaAIjUbK7E8tfz7V6Sr+GL0CehlkDVmpf ABY9GMrOVz4LFaK5CGsKTkPW/HkGime8gghMEFaVQi9+xKrB/FHzS5+F9xE+5wobqgGc s0DaH3WHd6i9Wm8kYgSD0aF8qbcXfDHI3J4jC/IcXiIuMNB/TxhHxjpNRYt3ZqPYjsms OxYO0jnhrmsog/nGjXMkSAwIvX8nitrCSTZGlqs0mbds1N1KkF6BysVwklMdxs7es5Dr qI+f66IGLP+YA25Fi543xDHDQzv3BwYu7AVmlOgvmEBOKUnMvYBI8Bw0ekHVCyLOVXgA qy7g== X-Gm-Message-State: AOAM531dKC1P2Yb/slJyQ42TxMy03lJiNgXca16WyKMq3zRiZZyCpP/T d+/1bavzrm+4OVZmSoaKhwTrUAgl8HGPe1piyMI= X-Received: by 2002:a05:6638:50c:: with SMTP id i12mr46825155jar.74.1609332947916; Wed, 30 Dec 2020 04:55:47 -0800 (PST) MIME-Version: 1.0 References: <20201230084338.19410-1-tony@atomide.com> In-Reply-To: <20201230084338.19410-1-tony@atomide.com> From: Adam Ford Date: Wed, 30 Dec 2020 06:55:37 -0600 Message-ID: Subject: Re: [PATCH 1/3] thermal: ti-soc-thermal: Fix stuck sensor with continuous mode for 4430 To: Tony Lindgren Cc: Amit Kucheria , Daniel Lezcano , Zhang Rui , Eduardo Valentin , Keerthy , linux-pm@vger.kernel.org, Linux Kernel Mailing List , Linux-OMAP , Carl Philipp Klemm , Merlijn Wajer , Pavel Machek , Peter Ujfalusi , Sebastian Reichel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 30, 2020 at 2:43 AM Tony Lindgren wrote: > > At least for 4430, trying to use the single conversion mode eventually > hangs the thermal sensor. This can be quite easily seen with errors: > > thermal thermal_zone0: failed to read out thermal zone (-5) > > Also, trying to read the temperature shows a stuck value with: > > $ while true; do cat /sys/class/thermal/thermal_zone0/temp; done > > Where the temperature is not rising at all with the busy loop. > > Additionally, the EOCZ (end of conversion) bit is not rising on 4430 in > single conversion mode while it works fine in continuous conversion mode. > It is also possible that the hung temperature sensor can affect the > thermal shutdown alert too. > > Let's fix the issue by adding TI_BANDGAP_FEATURE_CONT_MODE_ONLY flag and > use it for 4430. > > Note that we also need to add udelay to for the EOCZ (end of conversion) > bit polling as otherwise we have it time out too early on 4430. We'll be > changing the loop to use iopoll in the following clean-up patch. > > Cc: Adam Ford I don't have an OMAP4, but if you want, I can test a DM3730. adam > Cc: Carl Philipp Klemm > Cc: Eduardo Valentin > Cc: Merlijn Wajer > Cc: Pavel Machek > Cc: Peter Ujfalusi > Cc: Sebastian Reichel > Signed-off-by: Tony Lindgren > --- > drivers/thermal/ti-soc-thermal/omap4-thermal-data.c | 3 ++- > drivers/thermal/ti-soc-thermal/ti-bandgap.c | 9 +++++++-- > drivers/thermal/ti-soc-thermal/ti-bandgap.h | 2 ++ > 3 files changed, 11 insertions(+), 3 deletions(-) > > diff --git a/drivers/thermal/ti-soc-thermal/omap4-thermal-data.c b/drivers/thermal/ti-soc-thermal/omap4-thermal-data.c > --- a/drivers/thermal/ti-soc-thermal/omap4-thermal-data.c > +++ b/drivers/thermal/ti-soc-thermal/omap4-thermal-data.c > @@ -58,7 +58,8 @@ omap4430_adc_to_temp[OMAP4430_ADC_END_VALUE - OMAP4430_ADC_START_VALUE + 1] = { > const struct ti_bandgap_data omap4430_data = { > .features = TI_BANDGAP_FEATURE_MODE_CONFIG | > TI_BANDGAP_FEATURE_CLK_CTRL | > - TI_BANDGAP_FEATURE_POWER_SWITCH, > + TI_BANDGAP_FEATURE_POWER_SWITCH | > + TI_BANDGAP_FEATURE_CONT_MODE_ONLY, > .fclock_name = "bandgap_fclk", > .div_ck_name = "bandgap_fclk", > .conv_table = omap4430_adc_to_temp, > diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c > --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c > +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -605,8 +606,10 @@ ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id) > u32 counter = 1000; > struct temp_sensor_registers *tsr; > > - /* Select single conversion mode */ > - if (TI_BANDGAP_HAS(bgp, MODE_CONFIG)) > + /* Select continuous or single conversion mode */ > + if (TI_BANDGAP_HAS(bgp, CONT_MODE_ONLY)) > + RMW_BITS(bgp, id, bgap_mode_ctrl, mode_ctrl_mask, 1); > + else if (TI_BANDGAP_HAS(bgp, MODE_CONFIG)) > RMW_BITS(bgp, id, bgap_mode_ctrl, mode_ctrl_mask, 0); > > /* Start of Conversion = 1 */ > @@ -619,6 +622,7 @@ ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id) > if (ti_bandgap_readl(bgp, tsr->temp_sensor_ctrl) & > tsr->bgap_eocz_mask) > break; > + udelay(1); > } > > /* Start of Conversion = 0 */ > @@ -630,6 +634,7 @@ ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id) > if (!(ti_bandgap_readl(bgp, tsr->temp_sensor_ctrl) & > tsr->bgap_eocz_mask)) > break; > + udelay(1); > } > > return 0; > diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.h b/drivers/thermal/ti-soc-thermal/ti-bandgap.h > --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.h > +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.h > @@ -280,6 +280,7 @@ struct ti_temp_sensor { > * has Errata 814 > * TI_BANDGAP_FEATURE_UNRELIABLE - used when the sensor readings are too > * inaccurate. > + * TI_BANDGAP_FEATURE_CONT_MODE_ONLY - used when single mode hangs the sensor > * TI_BANDGAP_HAS(b, f) - macro to check if a bandgap device is capable of a > * specific feature (above) or not. Return non-zero, if yes. > */ > @@ -295,6 +296,7 @@ struct ti_temp_sensor { > #define TI_BANDGAP_FEATURE_HISTORY_BUFFER BIT(9) > #define TI_BANDGAP_FEATURE_ERRATA_814 BIT(10) > #define TI_BANDGAP_FEATURE_UNRELIABLE BIT(11) > +#define TI_BANDGAP_FEATURE_CONT_MODE_ONLY BIT(12) > #define TI_BANDGAP_HAS(b, f) \ > ((b)->conf->features & TI_BANDGAP_FEATURE_ ## f) > > -- > 2.29.2