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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A665C433F5 for ; Wed, 11 May 2022 10:18:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=z5ah5QTXYj9C3Sjwg4KU0czRN0SU05XoHLVjxxk3q+w=; b=X2SGXJYP9f9SLx mPpLbKs6S5ECFHxHx+/ZnZnCfplgLMjxG9KtchqHE74ASpotxz6uXXCLZUgx7bOtjivPCusrup0oZ cRjLxPgf4fRKGWaJOET21r5Rm8+O3nv1HMJM8cUdg/om/FEGV+B5nRD0TITbi0g64aHYprGYR1VME xSAOfwNBquBcp3zSLEVS6wKIqIqRN22N/ocN5KYy+2dEiYs/+NXS0yWDsiO8bvX3oXPscqZouFLHX YikAfjac+qLElXbogoXwoM/eWsYEHTYGLNzTBelw5IedbXvcuLmwJGVv7JMXzTWa0/S8YywncKzFH 1vIw7svI5/N2YaA7imIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nojPO-006JxH-QY; Wed, 11 May 2022 10:17:30 +0000 Received: from mx1.tq-group.com ([93.104.207.81]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nojPK-006Jvg-Lm for linux-arm-kernel@lists.infradead.org; Wed, 11 May 2022 10:17:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1652264246; x=1683800246; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e76YbbcJAIaWL6oq8ERlef6zyHi3bYsCnwvHmGABLoM=; b=QSF8DBtubQoIlY0aDp/0Vvy8zKb+q8/namyZdrbA3fp80ovNnqzB4UtL ZQxQlg8N5tGZG4umfeXvpgmHr5Mqg+8rEwNyezgT0vNkz+E0deD2hZ5mi rJ8Gkbyv0RSMPAjaDPfCf3+TY2s6YfFkN8whsUKiUrRO4RP1mnXMfzpfg IKQSFRB0XmYWG5eyp+GFhakZl0XdEhF6PbikR3UW5tOEwSUfkNsz1Xzk8 VRAb2UdTtq1bmc/9fsoJGcQR+fpHHH997TfVeGWtnj/u4/SUmqzK/Jyv9 QD5lv7jovr1slEibjYU80hh4w39U9AdgAXQ5aIJhf99iPTysl1vn569tv g==; X-IronPort-AV: E=Sophos;i="5.91,216,1647298800"; d="scan'208";a="23806256" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 11 May 2022 12:17:21 +0200 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Wed, 11 May 2022 12:17:21 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Wed, 11 May 2022 12:17:21 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1652264241; x=1683800241; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e76YbbcJAIaWL6oq8ERlef6zyHi3bYsCnwvHmGABLoM=; b=YUZ/P4IsjG6WTqFxUNl5MqsoZ1vTQX9a+wJrNzyfll8ToxISMh2eTne/ IQmuonU34NCQQ1YFfkCSTILuFdM/M685TPcVetYxAxjmNpVoMWIwKqzK6 WZnmpgaiD0KExC/sviHDFIIYD/ssJjlEAY1QMp2OMeBssB1Cq5hpEwSyg KBWq4hitQ56xbundDFE67o2viYVfQpXV+JMx5Fd54lDzHW2NlgpcXgTTa mnV6sKTwIGx49zkPLZMm/RnAPJkTDM7n1KvZEIosFt8rQ1+OZPUgOcJhX 0VHiBmvRJRaOu/+bQP2uBlztVZ6aL+ubrOlIyTRapxeWwW/tPBA7YCL9Q Q==; X-IronPort-AV: E=Sophos;i="5.91,216,1647298800"; d="scan'208";a="23806255" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 11 May 2022 12:17:21 +0200 Received: from steina-w.localnet (unknown [10.123.49.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by vtuxmail01.tq-net.de (Postfix) with ESMTPSA id 71977280070; Wed, 11 May 2022 12:17:21 +0200 (CEST) From: Alexander Stein To: Daniel Lezcano , "Rafael J . Wysocki" , Amit Kucheria , Zhang Rui , Shawn Guo , Sascha Hauer , Fabio Estevam , Nitin Garg Cc: "linux-pm@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: Re: (EXT) RE: [PATCH 2/2] thermal/drivers/thermal_helpers: Adjust output format Date: Wed, 11 May 2022 12:17:19 +0200 Message-ID: <4711874.GXAFRqVoOG@steina-w> Organization: TQ-Systems GmbH In-Reply-To: References: <20220408110920.3809225-1-alexander.stein@ew.tq-group.com> <82d08ff0-41bf-d249-1216-0da3f0cdc5b9@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220511_031727_159212_2BA73555 X-CRM114-Status: GOOD ( 31.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hello, Am Mittwoch, 11. Mai 2022, 00:48:00 CEST schrieb Nitin Garg: > On 08/04/2022 13:09, Alexander Stein wrote: > >> Outputs like this where -1 is printed as unsigned is somewhat misleading > >> > >> thermal thermal_zone1: Trip3[type=0,temp=48000]:trend=4,throttle=1 > >> thermal cooling_device3: cur_state=1 > >> thermal cooling_device3: old_target=-1, target=2 > >> thermal cooling_device3: zone1->target=1 > >> thermal cooling_device3: zone1->target=2 > >> thermal cooling_device3: zone1->target=18446744073709551615 > >> thermal cooling_device3: set to state 2 > >> > >> With THERMAL_NO_TARGET assigning -1 as unsigned it make sense to print > >> the target as signed integer, even if the type is actually unsigned. > >> > >> Signed-off-by: Alexander Stein > >> --- > >> An alternative would be to change thermal_instance::target from unsigned > >> long to long, but this would entail a lot of API & driver changes as well > >> which looks less intriguing. > >> > >> drivers/thermal/thermal_helpers.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/drivers/thermal/thermal_helpers.c > >> b/drivers/thermal/thermal_helpers.c index 3edd047e144f..0d0da6670267 > >> 100644 > >> --- a/drivers/thermal/thermal_helpers.c > >> +++ b/drivers/thermal/thermal_helpers.c > >> @@ -199,7 +199,7 @@ void __thermal_cdev_update(struct > >> thermal_cooling_device *cdev)>> > >> /* Make sure cdev enters the deepest cooling state */ > >> list_for_each_entry(instance, &cdev->thermal_instances, cdev_node) { > >> > >> - dev_dbg(&cdev->device, "zone%d->target=%lu\n", > >> + dev_dbg(&cdev->device, "zone%d->target=%ld\n", > >> > >> instance->tz->id, instance->target); > >> > >> if (instance->target == THERMAL_NO_TARGET) > >> > >> continue; > > > >Actually you pointed out something fuzzy in the target values. > > > >The unsigned long type for the target and THERMAL_NO_TARGET are not > >compatible. > > > >It would be much simpler to have THERMAL_NO_TARGET = 0 which > >semantically makes more sense than a negative value. Is it identical? Apparently target value is used differently in each governor. At least for gov_bang_bang 'THERMAL_NO_TARGET = 0' is no difference. Im not so sure about gov_step_wise. > The compare of unsigned long and negative int is bad idea. Well, THERMAL_NO_TARGET actually is an unsigned long (-1UL), so the comparison is unsigned long to unsigned long, so it should not be an issue. But this implies that printing the target as unsigned int, results in a huge number, not immediately recognizable as -1, which I tried to address here. > But there is serious problem introduced by "thermal: core: Add notifications > call in the framework" patch. When system resumes from mem suspend first > time (this happen only on 1st resume), the thermal notification is sent to > drivers with value of 0 (meaning system is no longer hot). This is due to > the fact target is init to 0 and when there is only 1 cooling device; it > gets out of the loop (due to continue;) with target still set to 0 and > calls thermal_cdev_set_cur_state(cdev, target). From there > thermal_notify_cdev_state_update is called with argument of 0 which > notifies drivers with value of 0. > > May be "unsigned long target" should be initialized to THERMAL_NO_TARGET > instead of 0. > > [ 29.107048] OOM killer enabled. > [ 29.110225] Restarting tasks ... done. > [ 29.124816] thermal cooling_device0: zone0->target=18446744073709551615 > [ 29.138388] GPU0: Hot alarm is canceled. > [ 29.145399] thermal cooling_device0: set to state 0 > [ 29.198954] PM: suspend exit Is it legal to pass THERMAL_NO_TARGET to .set_cur_state()? At least pwm-fan will return -EINVAL in this case. Alexander _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel