Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1114870rwl; Fri, 24 Mar 2023 06:32:32 -0700 (PDT) X-Google-Smtp-Source: AKy350aV8dd8bXbrOPWFEXjrV8LlMkMsDViYbH753v9rUNS4sEyF1VNRfFlif26rC6HHeW/Ado5P X-Received: by 2002:a17:903:11c8:b0:19d:1871:3bfa with SMTP id q8-20020a17090311c800b0019d18713bfamr3513482plh.27.1679664751804; Fri, 24 Mar 2023 06:32:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679664751; cv=none; d=google.com; s=arc-20160816; b=nHSQWrfxUetYBaWUGhQrJ29D/ZGsiBC24cfFAI/Ah2/hd91KWiCUvfOho85B9GMIj/ 8ZiTyMX22f5+xN7SFpFv+QrYmxDt9N+ke1Amqp8bF/A/HYpAZnGpN05gy8KT8pwqd2wn 3102Dnr0wUK3RlxV19l5eUA4GyA2Y1+cwesDnqWrwXbIVSEqv/N0UJp4ptRx2WxRfe1w u935f8A5icqJanr1bY5BUQCWG2CsiG4aH7NHQtWUXZRP1R17Mm4tP8CITR8ak7N3pBpG vB+jhUPYjTrdqlOSUy+bysQmm3eAKcc+I+/utm9ODJcuhEfjpfT8JG0/1qPuX/E2u6J+ wioA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=TTRoqk3RMklFbw/fMSf7iWExIprc3/BKX4RMtn4ECkQ=; b=ikwZ7Rm/eaQe4kMW/tx8jNSWQ60msuOL/G7fJFqK/Wxy9YCK2TLYmUf/TytBazuZWW RgO+8+086Zn45EdOF8Z3yqUaRv9S01Ttl0L6ZrMgisue3Wb9ZMIt0Xia4fySha12bN5M hRCIkfgqXwJedGG7gKvCLX3CQd2lG/T16YWmePqv+WsRwTI8tRurJph0AluTxqHYUQlq L3XmEUlDC8Rv3bUT5q5NTnXZFwO2CvjrG+nlkNZraHfKIwGMHSQDregPfbSKT5KGGVgE Hz0Pw447KRHheeTf5dm/7ZGNCSwYTbDIzvVks5ivB72+SBMOTn9rAI7mUPWmYg9mp5i7 pxeg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j1-20020a17090276c100b001a18fd4024bsi20255624plt.7.2023.03.24.06.32.19; Fri, 24 Mar 2023 06:32:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232041AbjCXNUe convert rfc822-to-8bit (ORCPT + 99 others); Fri, 24 Mar 2023 09:20:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231990AbjCXNUd (ORCPT ); Fri, 24 Mar 2023 09:20:33 -0400 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 680C123C44; Fri, 24 Mar 2023 06:20:11 -0700 (PDT) Received: by mail-ed1-f49.google.com with SMTP id o12so7829683edb.9; Fri, 24 Mar 2023 06:20:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679664009; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uNm7/WTsv7sBaucBf7bTAXfGkLVnEd5WdePhGNx//2Q=; b=WwKb8pq5GY3Zf1PerMx2LoRF4OyV3TzD3yNSF/3CtTGWPqwm2jkNDBiSNvfXxCLeZg LsV4lsTWkhElUqm1Izwha8i74Lea+k/nG14dEnS2y4815tFrJz6uBvfzRgievz5tHuTq mKc5/eKamD1xYJZyIi7/nxl0ZwT/czI1Dkre3XQvIWVaAPu42Fk1d3KztoD1qACU4aU/ 6MPYO+qrx2nzDtX7bgNagFESCD6i7b8GcgPKNPof9s0ReI5vO7HtKDQASxzCWqINLAiI AnxHLzPXxxBcM3punrtoPP/WCD1KXTcCujiFMk7lehC5kkUAnRNlZGumY84eyklhRXAN 5YLg== X-Gm-Message-State: AO0yUKUfWILItSbpEhEWF2PJOBl3+DWw4z7mDkIpLTV713VmzzFFwEEk cHkWHcLgAlI0k9yqQX74rb1m4mCXWYQad18CKVQ= X-Received: by 2002:a17:907:d20e:b0:8d7:edbc:a7b6 with SMTP id vd14-20020a170907d20e00b008d7edbca7b6mr1711538ejc.2.1679664009293; Fri, 24 Mar 2023 06:20:09 -0700 (PDT) MIME-Version: 1.0 References: <20230324070807.6342-1-rui.zhang@intel.com> <20230324070807.6342-2-rui.zhang@intel.com> In-Reply-To: <20230324070807.6342-2-rui.zhang@intel.com> From: "Rafael J. Wysocki" Date: Fri, 24 Mar 2023 14:19:58 +0100 Message-ID: Subject: Re: [PATCH 2/5] thermal/core: Reset cooling state during cooling device unregistration To: Zhang Rui Cc: linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, daniel.lezcano@linaro.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=0.5 required=5.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 24, 2023 at 8:08 AM Zhang Rui wrote: > > When unregistering a cooling device, it is possible that the cooling > device has been activated. And once the cooling device is unregistered, > no one will deactivate it anymore. > > Reset cooling state during cooling device unregistration. > > Signed-off-by: Zhang Rui > --- > In theory, this problem that this patch fixes can be triggered on a > platform with ACPI Active cooling, by > 1. overheat the system to trigger ACPI active cooling > 2. unload ACPI fan driver > 3. check if the fan is still spinning > But I don't have such a system so I didn't trigger then problem and I > only did build & boot test. So I'm not sure if this change is actually safe. In the example above, the system will still need the fan to spin after the ACPI fan driver is unloaded in order to cool down, won't it? > --- > drivers/thermal/thermal_core.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c > index 30ff39154598..fd54e6c10b60 100644 > --- a/drivers/thermal/thermal_core.c > +++ b/drivers/thermal/thermal_core.c > @@ -1192,6 +1192,10 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) > } > } > > + mutex_lock(&cdev->lock); > + cdev->ops->set_cur_state(cdev, 0); > + mutex_unlock(&cdev->lock); > + > mutex_unlock(&thermal_list_lock); > > device_unregister(&cdev->device); > -- > 2.25.1 >