Received: by 10.192.165.148 with SMTP id m20csp3362142imm; Mon, 7 May 2018 10:56:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqWFJL7t5xxbinKa1DVUk45Ai9EJu8X5km62opTP7P6zic4nUTtxzwAqZA4jcmteg3+sxMI X-Received: by 2002:a6b:c741:: with SMTP id x62-v6mr32136089iof.97.1525715795901; Mon, 07 May 2018 10:56:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525715795; cv=none; d=google.com; s=arc-20160816; b=Oat8v0APekEj/sRczs2qLVxcbpTPL2QoyBdLWGXk4NDAznao/cM4RhqJD9t8MivcDL tEz2GB7dePG3WyUc+uwRG65R+5LUyRAb1eC9osVzvU9ba7xk80T4Z2KcgctfpCy8JSC4 GMltTfed7voq4CFasFvNvOZvgY3h/qviZmRhKstBWOYAZ/hDW9pNVV+i/lCeW3TX3VQl drbaDKsRiLAoVKHETub/g7SqRZ0lSIH6rDi4DaA85zCy49uE+ICpZHh0s0Bp3cd4P88V odbMB9QG2DOqxNy0td4N+9/MMYcstBwoSfb4WItDoAiuVFLMB9nQ+rlnN0K9rcL/fG// Td1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=dtZIZZ9voB0BfBl5t298A95HsTo+DRd9xWq8bpYOWlA=; b=HYS2QuNXfv/WBiilvEyufwOj1bJLesD4+j2KV0041rizQZgdBdZy8GrR/Ue28CpZpL 8Wuex5DX5xLdjqCcdFrTqHO/JkQtWbow9btSPfXoEJlRq4xtFg2he6LBPJxHXrVWUX8s WxjHD8gaKMmFkDGwkBaQR/grt88ACaGJyn9vafMUmBThdXVndNCo/s2o11rvOpurka37 qk+gX7qhk0oZsvkiv1ufCSXGuEei0HaHEVM9671peW7/HRE/HcVPnm1QbJRL9RnVFltQ 7JDzWv76F21ahUVF5wLerL/sN3zX+DBuHL4qBh0vOfD+A237kEpK8SscBQzsqvw9JJI9 bRmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=KSJ6iC1c; dkim=pass header.i=@codeaurora.org header.s=default header.b=KSJ6iC1c; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e19-v6si19833024ioe.69.2018.05.07.10.56.22; Mon, 07 May 2018 10:56:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=KSJ6iC1c; dkim=pass header.i=@codeaurora.org header.s=default header.b=KSJ6iC1c; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752788AbeEGRyW (ORCPT + 99 others); Mon, 7 May 2018 13:54:22 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:49776 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751976AbeEGRyU (ORCPT ); Mon, 7 May 2018 13:54:20 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D7C976022C; Mon, 7 May 2018 17:54:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525715659; bh=aPLr3MAl6kHCPGyQTefxmupu40p8fLM8xiczH5XBI4Y=; h=From:To:Cc:Subject:Date:From; b=KSJ6iC1c0bmJIXu1UWZOLaT5X03/ElUtcFYwdxMXRjTbJ8IiKyiCDjv3xJJV3QVm1 0aW7Jup1FyBIiauR6rOHfA6ILSqti42gJZtcLLo3J+52SyLfuhdrD1VjFKk/pMW5bt n103IEACCSmC1HMKzFg3CEvvA09o8KsEYWeVTugg= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from codeaurora.org (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: ilina@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id CB3A060767; Mon, 7 May 2018 17:54:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525715659; bh=aPLr3MAl6kHCPGyQTefxmupu40p8fLM8xiczH5XBI4Y=; h=From:To:Cc:Subject:Date:From; b=KSJ6iC1c0bmJIXu1UWZOLaT5X03/ElUtcFYwdxMXRjTbJ8IiKyiCDjv3xJJV3QVm1 0aW7Jup1FyBIiauR6rOHfA6ILSqti42gJZtcLLo3J+52SyLfuhdrD1VjFKk/pMW5bt n103IEACCSmC1HMKzFg3CEvvA09o8KsEYWeVTugg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org CB3A060767 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=ilina@codeaurora.org From: Lina Iyer To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Ram Chandrasekar , Lina Iyer Subject: [PATCH] drivers: thermal: step_wise: add support for hysteresis Date: Mon, 7 May 2018 11:54:08 -0600 Message-Id: <20180507175408.2154-1-ilina@codeaurora.org> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ram Chandrasekar From: Ram Chandrasekar Step wise governor increases the mitigation level when the temperature goes above a threshold and will decrease the mitigation when the temperature falls below the threshold. If it were a case, where the temperature hovers around a threshold, the mitigation will be applied and removed at every iteration. This reaction to the temperature is inefficient for performance. The use of hysteresis temperature could avoid this ping-pong of mitigation by relaxing the mitigation to happen only when the temperature goes below this lower hysteresis value. Signed-off-by: Ram Chandrasekar Signed-off-by: Lina Iyer --- drivers/thermal/step_wise.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c index ee047ca43084..cf07e2269291 100644 --- a/drivers/thermal/step_wise.c +++ b/drivers/thermal/step_wise.c @@ -36,7 +36,7 @@ * for this trip point * d. if the trend is THERMAL_TREND_DROP_FULL, use lower limit * for this trip point - * If the temperature is lower than a trip point, + * If the temperature is lower than a hysteresis temperature, * a. if the trend is THERMAL_TREND_RAISING, do nothing * b. if the trend is THERMAL_TREND_DROPPING, use lower cooling * state for this trip point, if the cooling state already @@ -127,7 +127,7 @@ static void update_passive_instance(struct thermal_zone_device *tz, static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) { - int trip_temp; + int trip_temp, hyst_temp; enum thermal_trip_type trip_type; enum thermal_trend trend; struct thermal_instance *instance; @@ -135,22 +135,23 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) int old_target; if (trip == THERMAL_TRIPS_NONE) { - trip_temp = tz->forced_passive; + hyst_temp = trip_temp = tz->forced_passive; trip_type = THERMAL_TRIPS_NONE; } else { tz->ops->get_trip_temp(tz, trip, &trip_temp); + hyst_temp = trip_temp; + if (tz->ops->get_trip_hyst) { + tz->ops->get_trip_hyst(tz, trip, &hyst_temp); + hyst_temp = trip_temp - hyst_temp; + } tz->ops->get_trip_type(tz, trip, &trip_type); } trend = get_tz_trend(tz, trip); - if (tz->temperature >= trip_temp) { - throttle = true; - trace_thermal_zone_trip(tz, trip, trip_type); - } - - dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n", - trip, trip_type, trip_temp, trend, throttle); + dev_dbg(&tz->device, + "Trip%d[type=%d,temp=%d,hyst=%d]:trend=%d,throttle=%d\n", + trip, trip_type, trip_temp, hyst_temp, trend, throttle); mutex_lock(&tz->lock); @@ -159,6 +160,18 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) continue; old_target = instance->target; + throttle = false; + /* + * Lower the mitigation only if the temperature + * goes below the hysteresis temperature. + */ + if (tz->temperature >= trip_temp || + (tz->temperature >= hyst_temp && + old_target != THERMAL_NO_TARGET)) { + throttle = true; + trace_thermal_zone_trip(tz, trip, trip_type); + } + instance->target = get_target_state(instance, trend, throttle); dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n", old_target, (int)instance->target); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project