From patchwork Thu Jul 4 08:50:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 2822381 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2BBF09F3C3 for ; Thu, 4 Jul 2013 08:51:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 43F8220141 for ; Thu, 4 Jul 2013 08:51:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03F8B200EA for ; Thu, 4 Jul 2013 08:51:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964883Ab3GDIvo (ORCPT ); Thu, 4 Jul 2013 04:51:44 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:34883 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933708Ab3GDIvV (ORCPT ); Thu, 4 Jul 2013 04:51:21 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MPE009XSLWZ37K0@mailout2.samsung.com>; Thu, 04 Jul 2013 17:51:15 +0900 (KST) X-AuditID: cbfee61a-b7f3b6d000006edd-9c-51d537835683 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 21.01.28381.38735D15; Thu, 04 Jul 2013 17:51:15 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MPE008KLLW9XTB0@mmp1.samsung.com>; Thu, 04 Jul 2013 17:51:15 +0900 (KST) From: Lukasz Majewski To: Viresh Kumar , "Rafael J. Wysocki" , Zhang Rui , Eduardo Valentin Cc: "cpufreq@vger.kernel.org" , Linux PM list , Jonghwa Lee , Lukasz Majewski , l.majewski@majess.pl, linux-kernel , Andre Przywara , Daniel Lezcano , Kukjin Kim , Myungjoo Ham Subject: [PATCH v5 5/7] thermal:boost: Automatic enable/disable of BOOST feature Date: Thu, 04 Jul 2013 10:50:28 +0200 Message-id: <1372927830-2949-6-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1372927830-2949-1-git-send-email-l.majewski@samsung.com> References: <1370502472-7249-1-git-send-email-l.majewski@samsung.com> <1372927830-2949-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHLMWRmVeSWpSXmKPExsVy+t9jAd1m86uBBjunK1r8ebuc1eJp0w92 i3mfZS3W7P/JZNF59gmzRe+Cq2wWbx5xW7x5uJnR4vKuOWwWn3uPMFrcblzBZtG/sJfJ4snD PjaLjV89HPg8Fu95yeRx59oeNo91094ye/RtWcXo8WhxC6PH8RvbmTw+b5ILYI/isklJzcks Sy3St0vgyrj2+SFrwUGJireNrewNjL+Euxg5OCQETCS6r4p3MXICmWISF+6tZ+ti5OIQEljE KNE1dR4zhNPFJLF73XdGkCo2AT2Jz3efMoHYIgJzGCXuHHUHsZkFVjJLnGh0BLGFBQIken6u ZgWxWQRUJVrfbWIHsXkFXCV2zd3AArFNXuLp/T42EJtTwE3i8oUeJohljYwSGzo+sExg5F3A yLCKUTS1ILmgOCk911CvODG3uDQvXS85P3cTIzhUn0ntYFzZYHGIUYCDUYmHV8LqSqAQa2JZ cWXuIUYJDmYlEV4njquBQrwpiZVVqUX58UWlOanFhxilOViUxHkPtFoHCgmkJ5akZqemFqQW wWSZODilGhjz80rWmoUXL57SqzBrwsW1BU2hkTenKMqurpvv4rdJ6pL/R56dLhIqG26tuT1R qUDI8lrB/MM7qy0eb/p07Tif86mQljPnZMRqJthf+fTqazIL38wJKSmx5xoWTT72qXlawdld 6RGbr6nwZBbfY/c5tOvh7RaJqOmLrS6/ZStr2XKS9yy7wGUVJZbijERDLeai4kQAJA4gNFEC AAA= Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch provides auto disable/enable operation for boost. When any defined trip point is passed, the boost is disabled. In that moment thermal monitor workqueue is woken up and it monitors if the device temperature drops below 75% of the smallest trip point. When device cools down, the boost is enabled again. Signed-off-by: Lukasz Majewski Signed-off-by: Myungjoo Ham --- Changes for v5: - Move boost disable code from cpu_cooling.c to thermal_core.c (to handle_non_critical_trips) - Extent struct thermal_zone_device by adding overheated bool flag - Implement auto enable of boost after device cools down - Introduce boost_polling flag, which indicates if thermal uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down. Changes for v4: - New patch drivers/thermal/thermal_core.c | 31 +++++++++++++++++++++++++++++++ include/linux/thermal.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index d755440..12adbad 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -326,6 +327,15 @@ static void monitor_thermal_zone(struct thermal_zone_device *tz) static void handle_non_critical_trips(struct thermal_zone_device *tz, int trip, enum thermal_trip_type trip_type) { + if (cpufreq_boost_supported()) { + tz->overheated = true; + cpufreq_boost_trigger_state(0); + if (!tz->polling_delay) { + tz->boost_polling = true; + tz->polling_delay = 1000; + } + } + if (tz->governor) tz->governor->throttle(tz, trip); } @@ -453,6 +463,27 @@ static void thermal_zone_device_check(struct work_struct *work) struct thermal_zone_device *tz = container_of(work, struct thermal_zone_device, poll_queue.work); + long trip_temp; + + if (cpufreq_boost_supported() && tz->overheated) { + tz->ops->get_trip_temp(tz, 0, &trip_temp); + /* + * Enable boost again only when current temperature is less + * than 75% of trip_temp[0] + */ + if ((tz->temperature + (trip_temp >> 2)) < trip_temp) { + tz->overheated = false; + if (tz->boost_polling) { + tz->boost_polling = false; + tz->polling_delay = 0; + monitor_thermal_zone(tz); + } + + cpufreq_boost_trigger_state(1); + return; + } + } + thermal_zone_device_update(tz); } diff --git a/include/linux/thermal.h b/include/linux/thermal.h index a386a1c..f1aa3c2 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -172,6 +172,8 @@ struct thermal_zone_device { int emul_temperature; int passive; unsigned int forced_passive; + bool overheated; + bool boost_polling; const struct thermal_zone_device_ops *ops; const struct thermal_zone_params *tzp; struct thermal_governor *governor;