From patchwork Wed Dec 9 15:34:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 340361 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp4700357jai; Wed, 9 Dec 2020 07:35:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFZ6Kh8y/1zv5gkAI4fmCF612u75eXt5J7Xpxv/9tEE69st0lJ+Pxsq0cEPtiDm/RkiwWX X-Received: by 2002:aa7:d0c5:: with SMTP id u5mr2481774edo.46.1607528138738; Wed, 09 Dec 2020 07:35:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607528138; cv=none; d=google.com; s=arc-20160816; b=myArtRsuR2/7M2spexG+Dj9briyGVFyenp4813fxuSLoxjYrUT1R5t1P4H9B7/Sfq/ nAkFNGU378SkVDtYNxWQXQ2MVIv2aRKdJxAVJ3JcOqbowIS+Tt8ev/9V2fWj6hx42P8N V5i8UcqestVhsriKkRwxF6tQqjuxYAZKm/zyslh9/J4c+/dkeoT9fHNgnGiaiXmnd9XP bjuEHQe0gObFIrItvxogpxKNvQwQZb2TCZ6+BEDc0gV/x6DS6mKakZMS+5rvAyeRit/Z KT6TtrLeS7Sbg/077P3t5jIfIKS7fWSYbMcLauzCIGa9VnmSJJOjkSxnSpt3+W15sML8 JHTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=9lzHda3DkRGsaAMWdU4VLGvm72yuNdC03lUHj7g0BKQ=; b=e7J5PWahfwmhABj8gpK3R9KAZYcnR7+J3k3T3w6BYqmZNVN4epZWzQC5HWQHhZp+46 6ZuM0iiXQshsW0M5/JNwrS6ybSJXzPlQLIfDAzkn92SWjOUZt2L2pvOzGEbKlRLD8zWL erWtvgvEnozSEfwJfk2aSx7m3pRFKYsRYPvC8IGlhBoDh1wGwQ8vV7UyBMJhwLh2ZNI6 9VMbL0vyW0OSe5mpUtmWJPrNegjHX7ZpywJAx/JisZPCA7tlsTkFUdlTMb0jJ0oMkiFh 0MD3PUv3vSNl/LUYXBGkjyB9cFtYvVncALu+USlxRGWilYfA5ogHxNl2iighbz/dfSyN VlBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GhhAbALh; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zh18si911866ejb.624.2020.12.09.07.35.38; Wed, 09 Dec 2020 07:35:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-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=@linaro.org header.s=google header.b=GhhAbALh; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730271AbgLIPfh (ORCPT + 8 others); Wed, 9 Dec 2020 10:35:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730251AbgLIPfh (ORCPT ); Wed, 9 Dec 2020 10:35:37 -0500 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 534C0C0613CF for ; Wed, 9 Dec 2020 07:34:57 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id c1so2197352wrq.6 for ; Wed, 09 Dec 2020 07:34:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=9lzHda3DkRGsaAMWdU4VLGvm72yuNdC03lUHj7g0BKQ=; b=GhhAbALhf3of5VkM2LzUNsHuJej/dySMGdw+z4MhNerh+DyFl2VMiQPQUKh+LaYUmI VpJhaNHjrf/rXuhqRsIUFXqGRMyBc6xDLtKhYCXxFumdI6xus4ampbKpcW20dT21uhzo NzBSm6B/tkCCC+Jw2zUB1nHjRbrennKfbarqT5q41Echd4XojfMpSnYvtDXTDIc8lL9X Jw4nuFMB49N82BkXjTUHAhxnZABYDRwvuiDR4greQsliJsT3hp/tR1x8VgoJOqECP4jD HLR1s/5OJyl0P6PJ16FWcE7y5ASg2d+foQGcIDjmcH2rXRL3Pn4thGD3T4wgEXWp5RUs wkWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9lzHda3DkRGsaAMWdU4VLGvm72yuNdC03lUHj7g0BKQ=; b=Jet81tER1zP/esnpCpWEbek3nry2EerECyefFpyM2kbAasgT7O4aZjnnu1ADrD+r9i WQo4Wk61XR6Vu3c534HuFm37bbzyouGrbm6wacfZ210seiQVkRt0nuKm85+tnBKRn9NL vyRlESjTStHxhEK7on1GeZymC6SNqJgg2hnkU42e2J2ZHV7maf6ZKR0HPomXZajO2tc8 ubOypRzkXbdrRJIUxUYyAiZBgqpovMXLS6uv7F6DLVCFktGHBJcw9t7v6jzTOW6DyKLz LGShWlby55mV53S8H8YVMaVrggwYEJQWxoqvaJRvSzeNg1fukOlXX43UJNEHg2jKxlmf E4IQ== X-Gm-Message-State: AOAM533LDs1TPksJ4u1TEovYM+5/c8IccUHkQ8UoSQQokvUPJPZ+2yp7 cCs3NH1gPhAve9dQ3W4lKdxYVA== X-Received: by 2002:a5d:5604:: with SMTP id l4mr3317757wrv.127.1607528095968; Wed, 09 Dec 2020 07:34:55 -0800 (PST) Received: from localhost.localdomain (lns-bzn-59-82-252-158-132.adsl.proxad.net. [82.252.158.132]) by smtp.gmail.com with ESMTPSA id l8sm4208382wmf.35.2020.12.09.07.34.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 07:34:55 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rui.zhang@intel.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, lukasz.luba@arm.com, srinivas.pandruvada@linux.intel.com, kai.heng.feng@canonical.com Subject: [PATCH RFC 1/4] thermal/core: Emit a warning if the thermal zone is updated without ops Date: Wed, 9 Dec 2020 16:34:37 +0100 Message-Id: <20201209153440.27643-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The actual code is silently ignoring a thermal zone update when a driver is requesting it without a get_temp ops set. That looks not correct, as the caller should not have called this function if the thermal zone is unable to read the temperature. That makes the code less robust as the check won't detect the driver is inconsistently using the thermal API and that does not help to improve the framework as these circumvolutions hide the problem at the source. In order to detect the situation when it happens, let's add a warning when the update is requested without the get_temp() ops set. Any warning emitted will have to be fixed at the source of the problem: the caller must not call thermal_zone_device_update if there is not get_temp callback set. Cc: Thara Gopinath Cc: Amit Kucheria Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Lukasz Luba diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index dee40ff41177..afc02e7d1045 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -548,7 +548,8 @@ void thermal_zone_device_update(struct thermal_zone_device *tz, if (atomic_read(&in_suspend)) return; - if (!tz->ops->get_temp) + if (WARN_ONCE(!tz->ops->get_temp, "'%s' must not be called without " + "'get_temp' ops set\n", __FUNCTION__)) return; update_temperature(tz);