Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp458904ybr; Fri, 22 May 2020 10:35:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO+zT1RTEkyvzhy8wdGPELb8XiCk8Pr0Fk8uI8K8xIwS1lQ8W6jHUd0dW7kT+XACKnryBf X-Received: by 2002:a17:907:43bf:: with SMTP id ok23mr9774467ejb.68.1590168927314; Fri, 22 May 2020 10:35:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590168927; cv=none; d=google.com; s=arc-20160816; b=wiBKth+NOw3CoKpKVohye0JgRrrmu64RWKhLWrNm5cy83P/5hPPVKQrZEHK1bqbVdp E6hNszTd2xjFUiNKAaR25XZWETDrhEiMasZZ4U/nPTfIah0YKyS2ZUg3HOFdTirWqnJ5 i6WYpRbJ6sw0SEl5vN5OaEgJ2hutjxJtRnc66gxggW3WgvXieUnsTr0eXIehzCTksOG3 E/DBZigjkwkn9pAV8vrdCNiToXsnG2D8AcUozVh4KcKxYJsJO8TOnb46DbK4PrkWmCOP n8JUEmqLBAiu4lMC2VhRJzfY0ssLSVnF90GHXiRvfZI0i9hbOKNxIr/BG/AipBQrHHUE 3dKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=VLbtYmWmQJbiFJ2E3A6qyIEbqWJ+t8w0WcuXKvFftBM=; b=sZL+SQ/qnIsBj9N1o1YiRTV7Z3ntKaznoSIt9kIWSA1TfbaD57uwUIpRDPiNzEH2OO jJxv9OJj25yS5+jSg+tZPrZBRvaM1yLCgah2EjK5PvUVl4+ox5nKNxs94nDEgbvBKdSU VPaWUNAV31DTC4gcEcQOjAcU/TCagYWzPL/xPwdKT3IP3hfHoRSoGFuQp4H6gKYWJbLN sZkh8WU847fmfueYLKCI6mF3jhhVosTSxqBTuODN1mRbti44EmG+EWS7luP+rGZ9MVaO SFcEYLbidQ8H/bxF0CQSbarUkqlXQxMbKxYOuFOdQFxy8w+NLJsncB53OeRIgny6rs7B V7qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ptf99yRr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 m25si5330304edj.212.2020.05.22.10.35.04; Fri, 22 May 2020 10:35:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=ptf99yRr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1730678AbgEVRdO (ORCPT + 99 others); Fri, 22 May 2020 13:33:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730636AbgEVRdO (ORCPT ); Fri, 22 May 2020 13:33:14 -0400 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 A53B4C05BD43 for ; Fri, 22 May 2020 10:33:13 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id g12so9725500wrw.1 for ; Fri, 22 May 2020 10:33:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=VLbtYmWmQJbiFJ2E3A6qyIEbqWJ+t8w0WcuXKvFftBM=; b=ptf99yRrw4EIojq7DT7XBDmqVK3BXlNklUP+YLMzHqL9DxIWWzT112sAOKqee3nSRn QUFCueS41OH+yUGAj8gAo4vfU1shdTCVKxxjH2JGeEMqbu8qaTe1mkEK+POyDPJF6X0O 6GzrTuu2uCQ1tSS8OsCTDnqsFkxDmnNirxW1x1NmNgro481PJr/aUsJpyixsdU3uDLqy 3l6ZQ++xMuHYXJXJ3eoXs6veh+0m6QfvZOo5N8Rl26/bSaYxgtupN427Z345+slPvbo8 JgwpKw7kT96xeTJ0b10F4kVepUjw2nKaQdhuCgq5jIZQ990Y07uGjssycHTt0B01fcVn 4Apw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=VLbtYmWmQJbiFJ2E3A6qyIEbqWJ+t8w0WcuXKvFftBM=; b=PtiZxmkIbgRtboN8nphcy2CM6v29+I42OY/r/JvInk7v+4p9tzSrdvDQjYvOrd0x1B k00UlNGBR+/aDp2mZx7DjF/QmVMOfdCYre6FReRTjbeOYUIT9LmssazAA0IjZMhSQc3o aWr/cAExtYoQjS+66RAdbHUCzMzXAvNYJEQ4ZNafsk7cEbcbqLlAsL7WlpEbIZSgIijz AgoK9V085lQhXxjAdejZC7STr8vcV9PxZMoMcPsgXdFoIFdQ8IEvqaklMXNwzCwVeN+n 91ZV3niR3j4du3nG9JuiO6TuJbDgxH6uCdxZlz4e6+64tD8sWXR8htFd7ieY44Z7kU/B o3mQ== X-Gm-Message-State: AOAM532QHTk0g1Ckh9TYKqapITF42ch0/mnN0TerEI3jT8nW/rkCoKLG riDKPZHlOppjVX+unAAde+ibUA== X-Received: by 2002:a5d:4390:: with SMTP id i16mr1540564wrq.186.1590168792082; Fri, 22 May 2020 10:33:12 -0700 (PDT) Received: from ?IPv6:2a01:e34:ed2f:f020:a82f:eaec:3c49:875a? ([2a01:e34:ed2f:f020:a82f:eaec:3c49:875a]) by smtp.googlemail.com with ESMTPSA id i6sm11436865wmb.41.2020.05.22.10.33.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 May 2020 10:33:11 -0700 (PDT) Subject: Re: [PATCH] thermal: imx8mm: Add get_trend ops To: Anson Huang , rui.zhang@intel.com, amit.kucheria@verdurent.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Linux-imx@nxp.com References: <1589338689-15700-1-git-send-email-Anson.Huang@nxp.com> From: Daniel Lezcano Message-ID: Date: Fri, 22 May 2020 19:33:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <1589338689-15700-1-git-send-email-Anson.Huang@nxp.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/05/2020 04:58, Anson Huang wrote: > Add get_trend ops for i.MX8MM thermal to apply fast cooling > mechanism, when temperature exceeds passive trip point, the > highest cooling action will be applied, and when temperature > drops to lower than the margin below passive trip point, the > lowest cooling action will be applied. You are not describing what is the goal of this change. IIUC, the resulting change will be an on/off action. The thermal zone is mitigated with the highest cooling effect, so the lowest OPP, then the temperature trend is stable until it goes below the trip - margin where the mitigation is stopped. Except, I'm missing something, setting a trip point with a 10000 hysteresis and a cooling map min/max set to the highest opp will result on the same. > Signed-off-by: Anson Huang > --- > drivers/thermal/imx8mm_thermal.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/drivers/thermal/imx8mm_thermal.c b/drivers/thermal/imx8mm_thermal.c > index e6061e2..8f6a0b8 100644 > --- a/drivers/thermal/imx8mm_thermal.c > +++ b/drivers/thermal/imx8mm_thermal.c > @@ -38,6 +38,8 @@ > #define TMU_VER1 0x1 > #define TMU_VER2 0x2 > > +#define IMX_TEMP_COOL_MARGIN 10000 > + > struct thermal_soc_data { > u32 num_sensors; > u32 version; > @@ -103,8 +105,33 @@ static int tmu_get_temp(void *data, int *temp) > return tmu->socdata->get_temp(data, temp); > } > > +static int tmu_get_trend(void *p, int trip, enum thermal_trend *trend) > +{ > + struct tmu_sensor *sensor = p; > + int trip_temp, temp, ret; > + > + if (!sensor->tzd) > + return -EINVAL; > + > + ret = sensor->tzd->ops->get_trip_temp(sensor->tzd, trip, &trip_temp); > + if (ret) > + return ret; > + > + temp = READ_ONCE(sensor->tzd->temperature); > + > + if (temp > trip_temp) > + *trend = THERMAL_TREND_RAISE_FULL; > + else if (temp < (trip_temp - IMX_TEMP_COOL_MARGIN)) > + *trend = THERMAL_TREND_DROP_FULL; > + else > + *trend = THERMAL_TREND_STABLE; > + > + return 0; > +} > + > static struct thermal_zone_of_device_ops tmu_tz_ops = { > .get_temp = tmu_get_temp, > + .get_trend = tmu_get_trend, > }; > > static void imx8mm_tmu_enable(struct imx8mm_tmu *tmu, bool enable) > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog