Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1086010rwn; Thu, 15 Sep 2022 10:11:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM40g/8ts6lxT8MPGwmpP+LmeVddVC8A6moEuQcVkzrpyUEEbCd9rkJ+Z1AFAXqqz+PF/x48 X-Received: by 2002:a17:903:245:b0:172:bf22:fc5 with SMTP id j5-20020a170903024500b00172bf220fc5mr516764plh.101.1663261888252; Thu, 15 Sep 2022 10:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663261888; cv=none; d=google.com; s=arc-20160816; b=Yv0oVxbVm5NIlbqKhLIaqHQDGEJLnxmTQL0jjya/MFsSK3/29MFrkD9I8ln1h935Ct lHmNVUGoZen2zfS4MOaieqkpKonF39U064pIEySqN4RlsD5uGDOQb8ejGtWbCfeLWywD OcBTPS27fy/vGKB9aR1m4SGmJ5Nzaf9HHrAMo9QxmPRXHQC5XSnWcinPG4CH9mBzOdJS GJnobLlGJU10LcRnWgd0wD/Mim/RX4O2LrSw44F5Rq+BdvnxGuOHP4ucAfcgdiHu5vgW 6mHAmFvOFSNaAqgVGRcovOtIWsLG6TAdQSE6eLFYKGik/8X0m0vMkaKlN3rUx/X6Zxwb Lrrg== 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=DGGPltysYKSp/7lQwYUdbyRbVIJyU3VFPRDcDMDYhRs=; b=JWKaRd35JLJDJNk/Q1m04PqXrLefzu7ZJBRaz3Bp5K3zP0adRJntxCh3jbrZds580e Qb5ghr3gVR+aj62L85FiqkBg/0bAbHtwsJCIFh4GbJDBw3vIYVJvPGxmjxKXROIyPfIT KrCPt9vEEMeHyB2BQamI9QfesjAGsdmpngEBjtwqEURql3chDjLpHY/UI3Ot+cBRtVtD CiLuJTPZkvRsJleqsDdNaZ8k4eylD2jlJ1VNUS+8vd8rPMkgN3h75rdG6h6vUNTAXUp3 vAee90axLRRfriqTgs+DPuRZO+aPH89wJ8yCidvRXhfbtChHYV0xehkJ7SFOt3p9dG+7 xxLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=GTpQoXRE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id np12-20020a17090b4c4c00b00201d6d4cc79si301697pjb.113.2022.09.15.10.11.09; Thu, 15 Sep 2022 10:11:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=GTpQoXRE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230153AbiIOQ66 (ORCPT + 99 others); Thu, 15 Sep 2022 12:58:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230242AbiIOQ6x (ORCPT ); Thu, 15 Sep 2022 12:58:53 -0400 Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5CB097B34 for ; Thu, 15 Sep 2022 09:58:50 -0700 (PDT) Received: by mail-yb1-xb35.google.com with SMTP id 130so28614766ybz.9 for ; Thu, 15 Sep 2022 09:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=DGGPltysYKSp/7lQwYUdbyRbVIJyU3VFPRDcDMDYhRs=; b=GTpQoXRELGKRGGrEnQpUG6fqFn95MU+JX7Awv2d0h+D+NLsQ/r1UDWlPfW+GzOhld8 bAGtuk2DCu/dhAJ6RnbkX/ET49JQClyB7mybPtc+ltnm1nb1hsch1CDbW6bYdS0x51cb CWeDIJm/TL5RPQ3+maQlmciTLLWbP7C5UsLFr7N/8C951nfRSa/6oNnXrjdC8pKXgaYD Ubx6YxV13D04BE0gT/4Alk5fBE1OaKJkLAdMY3GdGXv4B0C5jGrlPOY9+X1Qb4j/7Rjq YYmW6MriaI0Ik0g8rSswhW7g7gDHZvTJ+kUKai/+YL5bNKnmo183NUkjYIVe7EnfgT67 PCfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=DGGPltysYKSp/7lQwYUdbyRbVIJyU3VFPRDcDMDYhRs=; b=qRhKR2VKxpCAELhYkImz60jjlGv5Z2vQvHo1KIbT+AtM3uBFVWNsvr/ZBx+zXp3fxR hYx5ovl21NMBzoXcscrZb0Ai60RpxB+k8kPyKF6J2quADd0KW/mO7kn8pbIavc4XGIom fCFGqzye0Pb9nAxKwiNkrGuaA+HqLMETl9hoOjUfznRntNQuniNcVJ30umBOkfwwaL7R QEELdAs97cMOkb2FgJiljpFGA9slQdnUAXCW3ZD3dy52G/wugM68xXYeS5MZQ6jfn7xZ FhpVz4DjYt3+5gO4W9gvdEWO8F/cLfDs2rxGLuzG7iCfzLIHylfQAcy2SfxXD3mVOza4 97SQ== X-Gm-Message-State: ACrzQf2eUh/8coraYTGMGGwLESf+XoVDMITN3YE7WFat/JdaSApX174l YM9J9bvgMTVFV3B7GeiJS+5WzNl71Z2zkopKz+GlKw== X-Received: by 2002:a25:e74f:0:b0:6ae:eaef:36cb with SMTP id e76-20020a25e74f000000b006aeeaef36cbmr649534ybh.199.1663261129842; Thu, 15 Sep 2022 09:58:49 -0700 (PDT) MIME-Version: 1.0 References: <20220817080757.352021-1-bchihi@baylibre.com> <20220817080757.352021-5-bchihi@baylibre.com> <8d6383e0-329e-ca91-6e79-85b3806a2af3@collabora.com> In-Reply-To: <8d6383e0-329e-ca91-6e79-85b3806a2af3@collabora.com> From: Balsam CHIHI Date: Thu, 15 Sep 2022 18:58:13 +0200 Message-ID: Subject: Re: [PATCH v9,4/7] thermal: mediatek: Add LVTS driver for mt8192 thermal zones To: AngeloGioacchino Del Regno Cc: rafael@kernel.org, rui.zhang@intel.com, daniel.lezcano@linaro.org, amitk@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, mka@chromium.org, robh+dt@kernel.org, krzk+dt@kernel.org, matthias.bgg@gmail.com, p.zabel@pengutronix.de, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, james.lo@mediatek.com, fan.chen@mediatek.com, louis.yu@mediatek.com, rex-bc.chen@mediatek.com, abailon@baylibre.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Angelo, > > +static int soc_temp_lvts_read_temp(void *data, int *temperature) > > +{ > > + struct soc_temp_tz *lvts_tz = (struct soc_temp_tz *)data; > > + struct lvts_data *lvts_data = lvts_tz->lvts_data; > > + struct device *dev = lvts_data->dev; > > + unsigned int msr_raw; > > + > > + msr_raw = readl(lvts_data->reg[lvts_tz->id]) & MRS_RAW_MASK; > > + if (msr_raw == 0) { > > + /* Prevents a false critical temperature trap */ > > + *temperature = 0; > > + dev_dbg(dev, "LVTS not yet ready\n"); > > ...and you're not returning an error code, despite this function was called > while LVTS is still not ready? :-) > if I add "return -ENAVAIL;" here, I will get the following errors on boot : [ 0.292094] thermal thermal_zone0: failed to read out thermal zone (-119) [ 0.293019] thermal thermal_zone1: failed to read out thermal zone (-119) [ 0.294158] thermal thermal_zone6: failed to read out thermal zone (-119) [ 0.295697] thermal thermal_zone9: failed to read out thermal zone (-119) [ 0.296600] thermal thermal_zone10: failed to read out thermal zone (-119) [ 0.297698] thermal thermal_zone15: failed to read out thermal zone (-119) [ 0.298625] thermal thermal_zone16: failed to read out thermal zone (-119) I just preferred : *temperature = 0; to avoid a false critical temperature trap, and "return 0;" to suppress these errors. After that (first read at boot when LVTS is not fully ready), "msr_raw" will be always != 0. And I did not want to add a "delay" or a "sleep". Please let me know if you have any suggestions that could fix it in a better way. > > + > > + } else > > + *temperature = lvts_raw_to_temp(&lvts_data->coeff, msr_raw); > > + > > + return 0; > > +} Best regards, Balsam