Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3062559ybt; Mon, 29 Jun 2020 14:17:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzt9fovr5iHfno63peYFHgiW/usTaMpTAr2/pKgxJRcKUSesEHYKrL4qALMOe5JYYBZqdCt X-Received: by 2002:a17:906:915:: with SMTP id i21mr15601145ejd.313.1593465427460; Mon, 29 Jun 2020 14:17:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593465427; cv=none; d=google.com; s=arc-20160816; b=SewKtDz5AZPk+yQyZ61/M6ToqA+BcWknbwukZiBt4BHgLqUcxtLgdiolEYfHw0N6eh b5Iq9Y9EeZGProVwYcKfgP5l8cskjNulklRbMFNYpZHDafz7Da+36KcYNq+VOdmaCyVj LCyjMelWoENYcAlZVwcR1kFwDZ/3gQeK003PmeTi59Whl2M8Kp1NodhjmDNQptwFknBx 4HeaxwM5XbOQF2v8mNZxq/v6qWDCPC0mBy0iYGNZwf7br+o71WG/ZTeRgJBJJ9eujIz8 iM6v2QX3sGbr5IRKxYW38yH7Fz9dIAePEwL3HRrsgKY9727Eiyl0dFH8k87EjWwmEPr9 bqgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Y4V+XrtE0+gJDAtuOcLMM4vSoCKSSOk4Tz8au1evTDc=; b=VbPRtGrizOkwQchTqKGnjkQHf0L79tyqrhed1jYMze33I5IDCqWPTN0OH1i5atP3RC psGYHVUCajMaOJgTCvSi8iNKgv1LGKakXdterJe49gh37cNlleyTBlXRVlBCxCh0yIsh f7HsK7wNKB65eKvQ1LIYp6PfgOJrkw9QXubmq81MI09eE+13+yAQgCqa2it1ivufNDeA YOip20EJLFG7b9Y5fAEyz1F8SHDKjplhB7+sut+XsCLbMKoTETvQTaSpfnpzKSO9tEm6 DTajLvk/3lzAhwmL9AuyHo92JQUFXZlpI/0VfSbH+i5jKlpFp8BODmM3CUCVEdqocT6w IrUA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i26si480187ejy.58.2020.06.29.14.16.44; Mon, 29 Jun 2020 14:17:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390258AbgF2VNZ (ORCPT + 99 others); Mon, 29 Jun 2020 17:13:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730120AbgF2S5n (ORCPT ); Mon, 29 Jun 2020 14:57:43 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88CB7C00F810; Mon, 29 Jun 2020 05:30:02 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 8D4A02A2DAC From: Andrzej Pietrasiewicz To: linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org Cc: "Rafael J . Wysocki" , Len Brown , Vishal Kulkarni , "David S . Miller" , Jiri Pirko , Ido Schimmel , Johannes Berg , Emmanuel Grumbach , Luca Coelho , Intel Linux Wireless , Kalle Valo , Peter Kaestle , Darren Hart , Andy Shevchenko , Sebastian Reichel , Miquel Raynal , Daniel Lezcano , Amit Kucheria , Support Opensource , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Heiko Stuebner , Orson Zhai , Baolin Wang , Chunyan Zhang , Zhang Rui , Allison Randal , Enrico Weigelt , Gayatri Kammela , Thomas Gleixner , Bartlomiej Zolnierkiewicz , Andrzej Pietrasiewicz , kernel@collabora.com Subject: [PATCH v7 09/11] thermal: core: Stop polling DISABLED thermal devices Date: Mon, 29 Jun 2020 14:29:23 +0200 Message-Id: <20200629122925.21729-10-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200629122925.21729-1-andrzej.p@collabora.com> References: <20200629122925.21729-1-andrzej.p@collabora.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Polling DISABLED devices is not desired, as all such "disabled" devices are meant to be handled by userspace. This patch introduces and uses should_stop_polling() to decide whether the device should be polled or not. Signed-off-by: Andrzej Pietrasiewicz Reviewed-by: Bartlomiej Zolnierkiewicz --- drivers/thermal/thermal_core.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 52d136780577..e613f5c07bad 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -301,13 +301,22 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz, cancel_delayed_work(&tz->poll_queue); } +static inline bool should_stop_polling(struct thermal_zone_device *tz) +{ + return !thermal_zone_device_is_enabled(tz); +} + static void monitor_thermal_zone(struct thermal_zone_device *tz) { + bool stop; + + stop = should_stop_polling(tz); + mutex_lock(&tz->lock); - if (tz->passive) + if (!stop && tz->passive) thermal_zone_device_set_polling(tz, tz->passive_delay); - else if (tz->polling_delay) + else if (!stop && tz->polling_delay) thermal_zone_device_set_polling(tz, tz->polling_delay); else thermal_zone_device_set_polling(tz, 0); @@ -517,6 +526,9 @@ void thermal_zone_device_update(struct thermal_zone_device *tz, { int count; + if (should_stop_polling(tz)) + return; + if (atomic_read(&in_suspend)) return; -- 2.17.1