From patchwork Thu Sep 17 03:22:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 312839 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp79594ilg; Wed, 16 Sep 2020 20:29:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOTLEHSx8iQl891jtwm6HFmgdvj6+dZhBeP70x+mLy/XFiWXI4FG8Ii32IGPCXOhjv4JlA X-Received: by 2002:a17:906:f0cb:: with SMTP id dk11mr18679102ejb.457.1600313342656; Wed, 16 Sep 2020 20:29:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600313342; cv=none; d=google.com; s=arc-20160816; b=B2lZoUQxTJJjCFarbgzH6vOi3OinKMo14i1mt9+YyrBTLgJBO9m1ltSAmYjzYnL0wO z1kxbezt4eJey4bC+DSpq7o4RIGtFSCUhsDwUIpjfI35Bkf1+ujTEuv7K9T1o+UIwcFM QPWD/eYabDllWXdo4NrWPXUJoJtHkP1uau/vGacPvHumk+dJ8eSeSqMyUzgE21vI31l2 y0t1OKHHKJXKGcXwu53lMnT1ciwKUXLLAg4y9TdPu0Q2Ob1IF/VWXG5t3tqofMQe6POl ZIHf1ovuol/N4uhqDAocxooNewbbCJXYYl2RIGugWWzQx0ktOPXx70Tkv1XAOblLRbIp IUgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wyquXDsI5PpUswweH/QuIkj+hc4Cb9K+5Ghm5R3vs34=; b=oSu6W+Jzy4FBiSizwfRdVSsngvGftNGpJWl0bf89LD3KekMqi76i4LyRP9hM4aODw7 9QhrWQ9Emes2BJyzh9DOSvmplrr3bSD0tziOw6jsXtBXSPJc1KBEzoGgFCnL7QSpZ9YA TIbtMoOCLUteIwJJbHZX3RG/S05R7Dwp+WHxwNQHFQr9HLUwL09IarNJFeVNkOKXZEmI BZmnkRXYlOhNBtvzpT/s4ivH0+2wP3kMagtTEFwajeLk7vgMuMV/4gXIO3kkbiSeTPtG RJZ5GVKnkemrjSUBnzEQVbF+wbe7idrUPyuXlS4sz398jHGzOsm3h1v12xpU3Hl80Zz3 KkIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TMVcDNfE; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 la9si12970128ejb.699.2020.09.16.20.29.02; Wed, 16 Sep 2020 20:29:02 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-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=TMVcDNfE; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 S1726185AbgIQD27 (ORCPT + 6 others); Wed, 16 Sep 2020 23:28:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726178AbgIQD2N (ORCPT ); Wed, 16 Sep 2020 23:28:13 -0400 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DF5AC061222 for ; Wed, 16 Sep 2020 20:22:33 -0700 (PDT) Received: by mail-qt1-x841.google.com with SMTP id n10so809111qtv.3 for ; Wed, 16 Sep 2020 20:22:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wyquXDsI5PpUswweH/QuIkj+hc4Cb9K+5Ghm5R3vs34=; b=TMVcDNfEewcm+Zlud5OWrLGCMtmG1XeduU2v6C81w3F27mDgOu5Dyjif/uvvhdsYNA ZF8agjfrxmavZWYFccuoVVZlNqDx0D0M8v89KjTasVKsAGJ0woopsXMrlfQW6hml+tj7 HbYKk+7NjJA1wjTkgwVq8paXmKSU7anwXtDDTxJ6UI0n9HIBv1l/7FIFf3nujZ/cMksP D30K4FMm77sR/DQzZYi3o8+kiBT5hGNj53VO3GKFGrms6Ft+lOz/pPXHxlP5KppRbvmu gvcisGJ/2G+AGfGNjBI+cqLJF6D8VAqNrlUesqay0E9Wqa6RHukc2cdU2ZZifdEo+a52 uZkg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=wyquXDsI5PpUswweH/QuIkj+hc4Cb9K+5Ghm5R3vs34=; b=cxkrL7BLqETacPC28vhw38Kx/eEIcQrIzK8Xai+mzR+TbGgmaf81BI5VG/OtbEQS1g e0KNORFirw0d+RsIvQdM4qW4Ac8hJ4hNwQHl8ot73Fb5p4yUFYUzfZckBxkV++ixw7ci tIZdlMiTi290evIdWWmBtw5L6RaS64J1O+XTNBYWTXmFAMbOJ+VbOXWG8tchXJGmr498 2mVfB0btg7nPxEwCR0MOYOjhVdqG/mA28LRVWvvr2do8wCYqgnxr1jrj4Dob5DUvnjSd p2uXepQFSrOAhtQmtBpXEJfDG5HblVxykunETw+T6zxhVbckBoINhX0Yu0w8MZTNwCST nEzw== X-Gm-Message-State: AOAM531DdDuNgD+pdi87gyrEhW2XQEbphHiQI8/3c+rNvCO1h2Se3jOy Tro/9AiGFHdF1m2Z8MVf4PKfQA== X-Received: by 2002:ac8:1108:: with SMTP id c8mr13557566qtj.323.1600312952482; Wed, 16 Sep 2020 20:22:32 -0700 (PDT) Received: from pop-os.fios-router.home (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.googlemail.com with ESMTPSA id g45sm21370801qtb.60.2020.09.16.20.22.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 20:22:32 -0700 (PDT) From: Thara Gopinath To: rui.zhang@intel.com, daniel.lezcano@linaro.org, robh+dt@kernel.org, agross@kernel.org, bjorn.andersson@linaro.org Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, lukasz.luba@arm.com, amitk@kernel.org Subject: [PATCH RFC 5/8] thermal: gov_step_wise: Extend thermal step-wise governor to monitor falling temperature. Date: Wed, 16 Sep 2020 23:22:23 -0400 Message-Id: <20200917032226.820371-6-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200917032226.820371-1-thara.gopinath@linaro.org> References: <20200917032226.820371-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org >From the step wise governor point of view, the policy decisions that has to taken on a thermal trip point that is defined to be monitored for falling temperature is the mirror opposite of the decisions it has to take on a trip point that is monitored for rising temperature. Signed-off-by: Thara Gopinath --- drivers/thermal/gov_step_wise.c | 62 +++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 15 deletions(-) -- 2.25.1 diff --git a/drivers/thermal/gov_step_wise.c b/drivers/thermal/gov_step_wise.c index 2ae7198d3067..c036ff7b4fb2 100644 --- a/drivers/thermal/gov_step_wise.c +++ b/drivers/thermal/gov_step_wise.c @@ -35,7 +35,8 @@ * deactivate the thermal instance */ static unsigned long get_target_state(struct thermal_instance *instance, - enum thermal_trend trend, bool throttle) + enum thermal_trend trend, bool throttle, + enum thermal_trip_monitor_type type) { struct thermal_cooling_device *cdev = instance->cdev; unsigned long cur_state; @@ -65,11 +66,24 @@ static unsigned long get_target_state(struct thermal_instance *instance, switch (trend) { case THERMAL_TREND_RAISING: - if (throttle) { - next_target = cur_state < instance->upper ? - (cur_state + 1) : instance->upper; - if (next_target < instance->lower) - next_target = instance->lower; + if (type == THERMAL_TRIP_MONITOR_FALLING) { + if (cur_state <= instance->lower) { + if (!throttle) + next_target = THERMAL_NO_TARGET; + } else { + if (!throttle) { + next_target = cur_state - 1; + if (next_target > instance->upper) + next_target = instance->upper; + } + } + } else { + if (throttle) { + next_target = cur_state < instance->upper ? + (cur_state + 1) : instance->upper; + if (next_target < instance->lower) + next_target = instance->lower; + } } break; case THERMAL_TREND_RAISE_FULL: @@ -77,14 +91,23 @@ static unsigned long get_target_state(struct thermal_instance *instance, next_target = instance->upper; break; case THERMAL_TREND_DROPPING: - if (cur_state <= instance->lower) { - if (!throttle) - next_target = THERMAL_NO_TARGET; + if (type == THERMAL_TRIP_MONITOR_FALLING) { + if (throttle) { + next_target = cur_state < instance->upper ? + (cur_state + 1) : instance->upper; + if (next_target < instance->lower) + next_target = instance->lower; + } } else { - if (!throttle) { - next_target = cur_state - 1; - if (next_target > instance->upper) - next_target = instance->upper; + if (cur_state <= instance->lower) { + if (!throttle) + next_target = THERMAL_NO_TARGET; + } else { + if (!throttle) { + next_target = cur_state - 1; + if (next_target > instance->upper) + next_target = instance->upper; + } } } break; @@ -117,6 +140,8 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) { int trip_temp; enum thermal_trip_type trip_type; + enum thermal_trip_monitor_type monitor_type = + THERMAL_TRIP_MONITOR_RISING; enum thermal_trend trend; struct thermal_instance *instance; bool throttle = false; @@ -130,9 +155,15 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) tz->ops->get_trip_type(tz, trip, &trip_type); } + if (tz->ops->get_trip_mon_type) + tz->ops->get_trip_mon_type(tz, trip, &monitor_type); + trend = get_tz_trend(tz, trip); - if (tz->temperature >= trip_temp) { + if (((monitor_type == THERMAL_TRIP_MONITOR_RISING) && + (tz->temperature >= trip_temp)) || + ((monitor_type == THERMAL_TRIP_MONITOR_FALLING) && + (tz->temperature <= trip_temp))) { throttle = true; trace_thermal_zone_trip(tz, trip, trip_type); } @@ -147,7 +178,8 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) continue; old_target = instance->target; - instance->target = get_target_state(instance, trend, throttle); + instance->target = get_target_state(instance, trend, + throttle, monitor_type); dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n", old_target, (int)instance->target); From patchwork Thu Sep 17 03:22:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 312842 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp79679ilg; Wed, 16 Sep 2020 20:29:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwoyqWU3+WyK/K3JOCe+paQNHVsRVNLdVe5UKSHhQ/lbniuaLwhIKLmKiuNzIBrVih4qwid X-Received: by 2002:a05:6402:1a48:: with SMTP id bf8mr30402947edb.298.1600313354077; Wed, 16 Sep 2020 20:29:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600313354; cv=none; d=google.com; s=arc-20160816; b=Twy764rMj0m69kO061+LZSzJwIqbxtH4cyvq5+EkR87a02slfNxWZdWtp84lZjeJCH pe3OfkajjrGmlqPsMi+a/GQFZGe8eaYx9NGSUD425iBmW1vjcIKyfO8IX9Xl10Gf9z8g TyE2XFZqmEtT9WlwD1GDDlFodpOq+ZQVsokWBfgilY4yVPOnYXEZL7YtmGaYwm68zcLG AOWvqfXwKWCIxIDqVDAaaLIK4pMUBruX1brcdvJkWwMeGltssnRBTslbX6x5UqSDhVhu i9n6XmHUAvMmFUx4BRpn7Enk6Kv+ciUUzDiLhnG8ujSjiqtRJEUkT8ZjstUQPi5IYk5W tIbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7uYlLNN0UyKBRIab8OLOITLg387YzzBqmIZv+ipj1Bk=; b=UwSrAMeHExFB85AvqaJI1eP9vtB/koGSg1G8+qEqH+lvpszqnwpaDkFG7Cp0FHC3gH 5WCZXpw3F2/j1MJF44VLPBORiT8RpMI4mpK3sQFC4tmlBhx4bDyHKfigOWenCl3FEGfK cmlhn3RmgO7cuhH7MpzLd1Pb+Tc+rjg4+XNsegkAR0b/CoB/ciHqx0gCILJX0DMFis17 kDE2R17xAifIqb9vuUMDrTIur4Kk2Yez3tCar4HPKdFIrFbkO98N8YRO6F0z0nIJSyHg PF3oi+8a6MkeqmxnLrTAxOhl6pCMiv34lYlN61EeA2RT0GGqk6X8nRAFMabTOZFzYk5F GMXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WgQWIsUl; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 d15si12747758ejr.178.2020.09.16.20.29.13; Wed, 16 Sep 2020 20:29:14 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-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=WgQWIsUl; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 S1726186AbgIQD3M (ORCPT + 6 others); Wed, 16 Sep 2020 23:29:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726154AbgIQD2J (ORCPT ); Wed, 16 Sep 2020 23:28:09 -0400 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6718C061A29 for ; Wed, 16 Sep 2020 20:22:35 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id g3so773073qtq.10 for ; Wed, 16 Sep 2020 20:22:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7uYlLNN0UyKBRIab8OLOITLg387YzzBqmIZv+ipj1Bk=; b=WgQWIsUlbXN3VVXSecXh6NSwzMBUdXegJ1UbE5dZ5hL0zTZqMnJXK3IU1YodWCoeuB Y4OEpjgNajgPg+yhYvIAF872GecFsE1BgxlzwnqnA2jGT679cwonprKHeJe8p+UZy5J4 r72IIPcyanDumuLDsqhSxQlUc1HrTMomgmZd3gWrEDjF51lbPdFbSTdtKnYDJe3bi49z HEdjA9fmvjxIv9m2vCLCmsz7H6ZD+ixW5RTucdXqj8nak9ZZl5Ra/dU9HxJrqjt1fx3v 5Uc6+JFwsR2u575L2MXyGO88rbRgDz78wJEGc2KS0sgSp02IBTsoU+HrrDclIL7UUzD5 yPIA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=7uYlLNN0UyKBRIab8OLOITLg387YzzBqmIZv+ipj1Bk=; b=rahnta0FhyE8YSYHZZ2EV3dFtxUaD6+z32QstWuR57Ovl3g3L1FoWVkT6ecQ8yZMey PToYo9kCKikvzQGFR2vfmGHbv1qy3wpNLh5SaVViDVEnMYIreCcv32ctmnKk3Cvq8dDe 3JyeVFRQ/zgwM6bRBYOSXC3I8F1peR4p0YH0Izfqnbpk4jTGffUT0WDIeRp06Kb96DyT BsXvKW7AUYRPaeXMC9Gpkdn3FpYe6M3QjcevbIOzQ46fZN0ACVoq4XfHNvsTo6sCaNf2 XJS9mm2/A6H6bKg+9fJcupHK8RJLGyVBBRNmTFSm0iTewO4vrUC/CyyTFlqu7yRW0tdi +Qxg== X-Gm-Message-State: AOAM532MfXKKJ7NTlFoG1IHevIlkPtanFY5+0Ej9dnH5RAQ07JHc4pra dCCLq8f9iBuSzkZYr660r2vQnJ5bdk1zfg== X-Received: by 2002:aed:2b86:: with SMTP id e6mr25582795qtd.86.1600312955087; Wed, 16 Sep 2020 20:22:35 -0700 (PDT) Received: from pop-os.fios-router.home (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.googlemail.com with ESMTPSA id g45sm21370801qtb.60.2020.09.16.20.22.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 20:22:34 -0700 (PDT) From: Thara Gopinath To: rui.zhang@intel.com, daniel.lezcano@linaro.org, robh+dt@kernel.org, agross@kernel.org, bjorn.andersson@linaro.org Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, lukasz.luba@arm.com, amitk@kernel.org Subject: [PATCH RFC 8/8] soc:qcom:qcom_aoss: Change cooling_device_register to warming_device_register Date: Wed, 16 Sep 2020 23:22:26 -0400 Message-Id: <20200917032226.820371-9-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200917032226.820371-1-thara.gopinath@linaro.org> References: <20200917032226.820371-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Always on subsystem host resources cx and ebi that are used as warming devices. Use the newly introduce _warming_device_register to register these devices with the thermal framework. Signed-off-by: Thara Gopinath --- drivers/soc/qcom/qcom_aoss.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.25.1 diff --git a/drivers/soc/qcom/qcom_aoss.c b/drivers/soc/qcom/qcom_aoss.c index ed2c687c16b3..4f65c03a5def 100644 --- a/drivers/soc/qcom/qcom_aoss.c +++ b/drivers/soc/qcom/qcom_aoss.c @@ -461,7 +461,7 @@ static int qmp_cooling_device_add(struct qmp *qmp, qmp_cdev->qmp = qmp; qmp_cdev->state = !qmp_cdev_max_state; qmp_cdev->name = cdev_name; - qmp_cdev->cdev = devm_thermal_of_cooling_device_register + qmp_cdev->cdev = devm_thermal_of_warming_device_register (qmp->dev, node, cdev_name, qmp_cdev, &qmp_cooling_device_ops); @@ -501,7 +501,7 @@ static int qmp_cooling_devices_register(struct qmp *qmp) unroll: while (--count >= 0) - thermal_cooling_device_unregister + thermal_warming_device_unregister (qmp->cooling_devs[count].cdev); return ret; @@ -512,7 +512,7 @@ static void qmp_cooling_devices_remove(struct qmp *qmp) int i; for (i = 0; i < QMP_NUM_COOLING_RESOURCES; i++) - thermal_cooling_device_unregister(qmp->cooling_devs[i].cdev); + thermal_warming_device_unregister(qmp->cooling_devs[i].cdev); } static int qmp_probe(struct platform_device *pdev)