Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp693714rwl; Fri, 24 Mar 2023 00:10:51 -0700 (PDT) X-Google-Smtp-Source: AK7set8MVcSqCNC6Hr85u5kaFz68L8W4YDYPYrO9vqVN9TxPdSOO5APZb5GhGaw5oap3hE5owdmz X-Received: by 2002:a05:6a20:4a13:b0:d8:afd4:4ac7 with SMTP id fr19-20020a056a204a1300b000d8afd44ac7mr2007711pzb.4.1679641851408; Fri, 24 Mar 2023 00:10:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679641851; cv=none; d=google.com; s=arc-20160816; b=tPvVfUikNdS94TeLYWXvN1rofPtAQcNl18KKQmPrj7RcCBJoSK4w1DLYVeg3RAy4b1 4pRtuIKDPv0io2qxif/xMaX8alqkBbGi1XWEFQcV5N0ov3OFV/D8GuWQgk8qKU1BBIzI 3FaiiXyv6pIC73+pIFYOv3LgfuzmR/tcemMeH0Z6k73R2A3QUK+ume4oEqnUtj3dobZ/ RqkYkiT9YaVFU2TYeYMyz5o6yD7unO5szVTfQDdqkuDrK6SpAdrctBhQuFrIbzvCufnW wHqzF/p0vGkuPob+Z5j5Lbvg+q6u9Jsq2E48miZv7XsgROD1knPlH9JUFsc3Xvy0N3CJ ChrQ== 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=Pjkuq56Hjqbyp3nRU5SXqN8WHBcPHrTnvEXcZbJ2lxY=; b=PRqLuh7DoRnH9b8jTU7RY044YPxRLxINbz8mggxfKymiSJm3Vzv8DjBYk0cNtOkvfE /HiFWDIOazQtJ72gjIOJL++ZziKte7XKllrh0NHT2jWYg0Z/WL+Jc3fYPNnO8C2vhBsT hNcrkoJVOJyJIj67qlY4QyIxDmDZCyE4ejoZDviAjptLt4wtfDYCCzZ2m7WF0omae+s1 wr/MVjsxZ/fJOTqYiZ/B8G9WqGiCFlBK/Q/oum4XiHG58AQIW0DdZm0St01/nVW9WkHN gcJi4nxsp5rWr4QR8hAvo5E3Tab2OkJAgrhgcV90MUUR2lYkJAYtHjtzm4gMZsgwM29V 00CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=F4jTTHnM; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q19-20020a632a13000000b0050bc928c0d4si21003156pgq.418.2023.03.24.00.10.39; Fri, 24 Mar 2023 00:10:51 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=F4jTTHnM; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231327AbjCXHI2 (ORCPT + 99 others); Fri, 24 Mar 2023 03:08:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230491AbjCXHIS (ORCPT ); Fri, 24 Mar 2023 03:08:18 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B969E2723; Fri, 24 Mar 2023 00:08:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679641697; x=1711177697; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DNQRMQLHwGWEKQ5jQmcWcG0jrDlQUzQ9voomVMZTSz8=; b=F4jTTHnMhJRVdfDYr1sqW1xw7ofz+7oJ+Q28R37QQei5ja0chpI+LGC8 0bcoMm92u7djLPv75f1T+ygOOmUhbgDbXNVmmeBqOIo75ZVweCpytAGOF RosBzFrpNgM71FXopBLtbpaWLeAt8yiZLT2vAN7C+cMJIKnA14syONI6R Oy6Lfki9QG+qdHxTME1dz7/30m4Q34TrBZFyNLW4RNXdPY1eiuZGn0UjA GgGlHtQ6m5mH+Dx34hWvE2w263maJnKKc39gO8Pl5i++Kr1ovifcYPhZF 9VX7UEmrefGpSo9Fv/K+Zx/BHIlOsyQRUzd8t7KEyF97jI+ZU96LLW2Vu A==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402296717" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="402296717" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2023 00:08:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="747046053" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="747046053" Received: from fli4-mobl1.ccr.corp.intel.com (HELO rzhang1-DESK.intel.com) ([10.255.28.30]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2023 00:08:16 -0700 From: Zhang Rui To: linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 2/5] thermal/core: Reset cooling state during cooling device unregistration Date: Fri, 24 Mar 2023 15:08:04 +0800 Message-Id: <20230324070807.6342-2-rui.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230324070807.6342-1-rui.zhang@intel.com> References: <20230324070807.6342-1-rui.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=unavailable 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 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. --- 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