From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A0DDC4361B for ; Wed, 9 Dec 2020 09:31:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6D0A23B7B for ; Wed, 9 Dec 2020 09:31:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729315AbgLIJar (ORCPT ); Wed, 9 Dec 2020 04:30:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728613AbgLIJal (ORCPT ); Wed, 9 Dec 2020 04:30:41 -0500 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43667C0613D6 for ; Wed, 9 Dec 2020 01:30:26 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id a3so896657wmb.5 for ; Wed, 09 Dec 2020 01:30:26 -0800 (PST) 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=L61+JwkcFzkud7jR/ngEi5aVujc/do/nVLhcrDG/U8k=; b=k3RHRHtV5XNvz0FnIXPif1joM+tCHTwCDBCVYI7Fkq4M8PyR36rHWwZVqjJXxHp3QR bnfXyMEYEdGkGiprQvtkTXJiOtwSOC0D+O9nk5moay5UV0Ylc7q4QFxcTr2MURouNGmn 7C93MSB4SgsK5E4IiQ/7ZYiTAHMCh7PDCyVQbIKDKkhfWlI5MtuwgjG8aR444jtUDXDQ QUpcCzgWiSEiOnkHysofod4gNjGzP/KjydFr/2dlxZIX2mUT8s66qZQXh+YYN3kO9nhj p45rN2rTcRaFWn59p8ud0TXlARrXzP6mo+f9SEz8/QSzT9Vv5tWscIQHk3KAsz4Ku4i4 +fPA== 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=L61+JwkcFzkud7jR/ngEi5aVujc/do/nVLhcrDG/U8k=; b=ciYmt3/7POxItY87R/zUO6rVjNhobWuHGHPXPePBO2jPHBMtCFO2dco7KBwftWS6P6 wbhHe/ee9UlpF8JSBAa4DqB0H6mDfwwG/gvJ9bJq5PEocosw8wM8375/eaAKmzKh+GaH XCfrfleJds2VAPVqb6rcNapDAz8oEQI2hptPweqC1gzDG/5gknuRSUQKCysCTSRBxyAg dCJyBi3KtFw5SuEY96pBUuHlLp1HetUKW5ui2xa3o+eDL82zlB+zNBT4Sj152OKX1t9k bAt4m6uGml9k4gn/S2d4F/YUuHC9OO9eyVX9p6efifNh1kMczXVniT53saLKv0qceMrL JaCA== X-Gm-Message-State: AOAM530QUIYIuNtEMePVEEZQBnMKirPyxikQALtEMWajorpAT+yfqEYG MdpAsTXRDz3NMv4GsVbNzBbAPoT/mdwOnw== X-Google-Smtp-Source: ABdhPJwqcV0/86kY52CzPqXaDjCXA6dBC2F9HG+ByXzdzWJaOzBWEPskANgnY9UktMu/luOWbxK7Bg== X-Received: by 2002:a1c:55ca:: with SMTP id j193mr1734133wmb.87.1607506224513; Wed, 09 Dec 2020 01:30:24 -0800 (PST) Received: from ?IPv6:2a01:e34:ed2f:f020:8cf2:3820:1fbd:70ad? ([2a01:e34:ed2f:f020:8cf2:3820:1fbd:70ad]) by smtp.googlemail.com with ESMTPSA id d8sm2053234wrp.44.2020.12.09.01.30.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Dec 2020 01:30:23 -0800 (PST) Subject: Re: [PATCH 1/3] thermal: core: Add indication for userspace usage To: Kai-Heng Feng Cc: Srinivas Pandruvada , Zhang Rui , amitk@kernel.org, "open list:THERMAL" , open list References: <20201128175450.12456-1-kai.heng.feng@canonical.com> <004fe225-1009-06d8-b297-c03a4c67550f@linaro.org> <860126B8-1152-4EE3-B15E-B4E45EFE879F@canonical.com> <34348B03-5E27-49A0-A704-6332BAC00758@canonical.com> <585bb5d3ee5bea063795682108576c3464ba72b6.camel@linux.intel.com> From: Daniel Lezcano Message-ID: <4767b493-fa24-e294-66df-3989b72bfb01@linaro.org> Date: Wed, 9 Dec 2020 10:30:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/12/2020 06:36, Kai-Heng Feng wrote: > > >> On Dec 1, 2020, at 02:39, Srinivas Pandruvada wrote: >> >> On Tue, 2020-12-01 at 02:22 +0800, Kai-Heng Feng wrote: >>>> On Dec 1, 2020, at 02:13, Srinivas Pandruvada < >>>> srinivas.pandruvada@linux.intel.com> wrote: >>> >>> [snipped] >>> >>>>>> What about creating an new callback >>>>>> >>>>>> enum thermal_trip_status { >>>>>> THERMAL_TRIP_DISABLED = 0, >>>>>> THERMAL_TRIP_ENABLED, >>>>>> }; >>>>>> >>>>>> int get_trip_status(struct thermal_zone_device *, int trip, >>>>>> enum >>>>>> thermal_trip_status *state); >>>>>> >>>>>> Then in >>>>>> static void handle_thermal_trip(struct thermal_zone_device *tz, >>>>>> int >>>>>> trip) >>>>>> { >>>>>> >>>>>> /* before tz->ops->get_trip_temp(tz, trip, &trip_temp); */ >>>>>> if (tz->ops->get_trip_status) { >>>>>> enum thermal_trip_status *status; >>>>>> >>>>>> if (!tz->ops->get_trip_status(tz, trip, &status)) { >>>>>> if (status == THERMAL_TRIP_DISABLED) >>>>>> return; >>>>>> } >>>>>> } >>>>>> ... >>>>>> ... >>>>>> >>>>>> } >>>>>> >>>>>> >>>>>> This callback will help the cases: >>>>>> - Allows drivers to selectively disable certain trips during >>>>>> init >>>>>> state >>>>>> or system resume where there can be spikes or always. int340x >>>>>> drivers >>>>>> can disable always. >>>>> >>>>> This sounds really great. This is indeed can happen on system >>>>> resume, >>>>> before userspace process thaw. >>>>> >>>>>> - Still give options for drivers to handle critical trip even >>>>>> if >>>>>> they >>>>>> are bound to user space governors. User space process may be >>>>>> dead, >>>>>> so >>>>>> still allow kernel to process graceful shutdown >>>>> >>>>> To make the scenario happen, do we need a new sysfs to let >>>>> usespace >>>>> enable it with THERMAL_TRIP_ENABLED? >>>> This should be drivers call not user space. >>> >>> Understood. So after thermal_zone_device_register(), the driver can >>> decide to what to return on get_trip_temp(). >> get_trip_status() >> >>> Let me work on a new patch if there's no other concern. >> Better to wait for confirmation from Daniel and others. > > Daniel, > > Do you like Srinivas' proposed solution? > > I hope we can find a solution in upstream kernel soon. (just trying to figure out the full context) If the device is enumerated outside of a thermal zone, the sensor should not register in the thermal zone no ? -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog