Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2697428pxb; Sat, 6 Feb 2021 05:05:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXXncSiSc0VpDRSpCziuajKxIRCqIQoaAwxQXNCh0lpN/ah5ZiY3PpLwQ+HZgj2wsrML9y X-Received: by 2002:aa7:c58e:: with SMTP id g14mr8559367edq.318.1612616720513; Sat, 06 Feb 2021 05:05:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612616720; cv=none; d=google.com; s=arc-20160816; b=EGNti8Zgt5f+6idX3+loZmRsS0829hvAqcUt2+bmxxj/2YovYEDbbHQgwoGB0hfZ7j r1QR/J8U9MKe0tlI5md+VBSXFQIGDMqOId/Fdb5M79344Vv2MlpQCJNrXw90v2Ob/iIV CXJQde0UAtcMlZFIUZcP4hF9ExVPTOZcXd9LSQhrbRVV7FfR+//SvGuf6ObE/BhhzVIU iZeOxzLzhzvJctPpnAl+d3fpZE+t560JaZ2LkDjBhYvXv/gPlTpqOzVsf/L35BvjQ6eU MF0qc/bAP2d3Iqg94KGfX9SyZ6GKSbISZdwYika4EXqtRxRA5K76wkC3Vmo0nqMbl1Wl L2Vw== 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=244Z31oFAGzpSNuKHU/MicO/I2Za+TwL6w/zVd76MAk=; b=WpG9f8yhgIUSvAq8BWhPx8iJDW62Wy7UDQVuU6h3yeLILz/vAnk+BaVdJ3ahQn1IRk UHpFccVToAOIczbdwEbC52+Gzhh7kUpA8jo12FMaMBuN3BHkgHxc24kxStRa4nPa4mtn qj1FWnuuXLZZP7zNtAEgNGIidDyNLMawWEpN4R9jdDI/BYy9byN1JTikMkWiVF5nIXkV iwOIjoECR9A+Nc9/Rd43dKbXN1DLbuDHRjIpczmmbsj4AxvuhBMU+sDkZQEBFfSUVpzW yxs1nXTuOkmETZ/1y+vgazwrR0S9/YPyIT7p+VhUiWP84zLJ2K3PuPXN2mS6cV5f6Gua XpPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bFQVwTF2; 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 d4si7443125edo.136.2021.02.06.05.04.51; Sat, 06 Feb 2021 05:05:20 -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=bFQVwTF2; 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 S229586AbhBFNDI (ORCPT + 99 others); Sat, 6 Feb 2021 08:03:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhBFNCx (ORCPT ); Sat, 6 Feb 2021 08:02:53 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7184AC06174A; Sat, 6 Feb 2021 05:02:13 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id g3so4999558plp.2; Sat, 06 Feb 2021 05:02:13 -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=244Z31oFAGzpSNuKHU/MicO/I2Za+TwL6w/zVd76MAk=; b=bFQVwTF2ZFuahwv0jbueMJrPC0wnR0Oax7RoEG4zTQJB8ZOgHu5HkuMl/YOpJM7Zd4 FbANCvdVMqv9Le8tb2kojJvs6ZU/cQnb5+/q43VCVMCqQhHXyXlmf4dCrJ3/Y9iy7wKD DPZr42XftDjfBPnfdqbnGoXZRqLxmbFg1uYMVudDl1pfAA+0jVd7oNVPtPDKEm3d55ot b9kETIAFlpH+oZAVK9xGVlD5pQb/hmvJrkwX8d9ard613CKERDaj0MlG+Y5PUuRqew2i o39b3Hi7Xu8vU8q235XjtEkWY+DjdGA7Vnfd0uD29weQLfI10OE8DAKEqS11G9x5xUut rlQA== 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=244Z31oFAGzpSNuKHU/MicO/I2Za+TwL6w/zVd76MAk=; b=uCN0XVNWyC/zPffSSk9+LzKOrUDuLMK4FjN5MBiJzGf3ge99nLAEelt/+96uAMduDs GIgxE02dRkwwEW1RanGjoSnnaLEKr7SNjsFNwPxyVeBwh84aE1EEue4vv8ZBk2W+shLz haCFmT29wc1vLwxzIzo8NjG8F+fEO2v26vRto3KONM7pCSlenZArpSKVRHysREUkJREX aqWkkb4NUJMW2N0d++0VCK4X14I1R+uEWD4Bq8YUx2dKIVEArUpR19aVxMaEmAUlhO7b qN/ZaqOqsKxlEdugC9DO/mY3LenjSzUDMfddNyn1AusBHHFTa5JaMEzYs76APpB7iFMt YAzw== X-Gm-Message-State: AOAM530Qa0KLYrglAaaPuepGVfukb3REZhUsZJFMKzEe5sXhA8O5+cyg 2vNddrgEU32qqy0UYwSWhciZZUSoJs/nwNIATRidWPkg2Qw0Ew== X-Received: by 2002:a17:90a:5601:: with SMTP id r1mr8523311pjf.236.1612616532713; Sat, 06 Feb 2021 05:02:12 -0800 (PST) MIME-Version: 1.0 References: <20210205134534.49200-1-tony@atomide.com> <20210205134534.49200-4-tony@atomide.com> In-Reply-To: <20210205134534.49200-4-tony@atomide.com> From: Adam Ford Date: Sat, 6 Feb 2021 07:02:01 -0600 Message-ID: Subject: Re: [PATCH 3/4] thermal: ti-soc-thermal: Simplify polling with iopoll 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 , "H . Nikolaus Schaller" , 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 Fri, Feb 5, 2021 at 7:45 AM Tony Lindgren wrote: > > We can use iopoll for checking the EOCZ (end of conversion) bit. And with > this we now also want to handle the timeout errors properly. > > For omap3, we need about 1.2ms for the single mode sampling to wait for > EOCZ down, so let's use 1.5ms timeout there. Waiting for sampling to start > is faster and we can use 1ms timeout. > > Cc: Adam Ford > Cc: Carl Philipp Klemm > Cc: Eduardo Valentin > Cc: H. Nikolaus Schaller > Cc: Merlijn Wajer > Cc: Pavel Machek > Cc: Peter Ujfalusi > Cc: Sebastian Reichel > Signed-off-by: Tony Lindgren For the series, Tested-by: Adam Ford #logicpd-torpedo-37xx-devkit > --- > drivers/thermal/ti-soc-thermal/ti-bandgap.c | 30 ++++++++++----------- > 1 file changed, 14 insertions(+), 16 deletions(-) > > 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,7 +15,6 @@ > #include > #include > #include > -#include > #include > #include > #include > @@ -27,6 +26,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -604,7 +604,9 @@ static int > ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id) > { > struct temp_sensor_registers *tsr = bgp->conf->sensors[id].registers; > - u32 counter; > + void __iomem *temp_sensor_ctrl = bgp->base + tsr->temp_sensor_ctrl; > + int error; > + u32 val; > > /* Select continuous or single conversion mode */ > if (TI_BANDGAP_HAS(bgp, MODE_CONFIG)) { > @@ -619,26 +621,22 @@ ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id) > RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 1); > > /* Wait for EOCZ going up */ > - counter = 1000; > - while (--counter) { > - if (ti_bandgap_readl(bgp, tsr->temp_sensor_ctrl) & > - tsr->bgap_eocz_mask) > - break; > - udelay(1); > - } > + error = readl_poll_timeout_atomic(temp_sensor_ctrl, val, > + val & tsr->bgap_eocz_mask, > + 1, 1000); > + if (error) > + dev_warn(bgp->dev, "eocz timed out waiting high\n"); > > /* Clear Start of Conversion if available */ > RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 0); > } > > /* Wait for EOCZ going down, always needed even if no bgap_soc_mask */ > - counter = 1000; > - while (--counter) { > - if (!(ti_bandgap_readl(bgp, tsr->temp_sensor_ctrl) & > - tsr->bgap_eocz_mask)) > - break; > - udelay(1); > - } > + error = readl_poll_timeout_atomic(temp_sensor_ctrl, val, > + !(val & tsr->bgap_eocz_mask), > + 1, 1500); > + if (error) > + dev_warn(bgp->dev, "eocz timed out waiting low\n"); > > return 0; > } > -- > 2.30.0