From patchwork Fri Mar 24 07:08:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 74377 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp429089vqo; Fri, 24 Mar 2023 00:11:47 -0700 (PDT) X-Google-Smtp-Source: AKy350amOyhh0yGc9fXNQUC0HZ64SqPXn7odDUR8PCOWcBaXicPGmeuD1mDAuk5cyqfrIshmN8bF X-Received: by 2002:a17:902:ef91:b0:19f:3797:d8de with SMTP id iz17-20020a170902ef9100b0019f3797d8demr1451240plb.9.1679641907437; Fri, 24 Mar 2023 00:11:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679641907; cv=none; d=google.com; s=arc-20160816; b=oXWGKFS959oY8+8D0abnrS4BbmEUYTksTu0Y1gMy6V1NOWcxdvqbJ9SW/+JUWXE7AU CBqdlBwxWYqffAYEmdVuZWjl6FQ7HT/9nC+eNK6fguas60c5q4k2DV2JugcyntT6oXRQ B+Lje7rnOG+rJFPWaJ5YmIFFiFlDqSuu+etnElbzA7rSlPPX3/ws3WoopspIo87ebMfJ xXJJHNhBacoqoxvOLgKcKsGVuvriU0/RmE69/0ZDj/ktn1juDAUqsGs4U84cWHvP6JSH x/O6WAjasU3YAquM5ImzTeVaSgPb07ZQRLLJZvD1g+ECe8TXwV280LD7Db26kq3xsfat rUmA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=B7RsG/rKBwQv8qGXUpSzvFhtSda7aZPNKtKUl0neA2c=; b=lRRoogsEbvJ3tPawC8clDDFz2/0PFP3XREZHtOLP0X9f8GpCagkJ/Y3Wo03kpxfLde w/QaRkwlhb6SlEZT2jzoPwAkW3cpOcDuTGzq4Ga9t6//i0LSRUMS6ZxjUn/9jgTDp5eL 8fz2LZ3lhyRpx5NcLv2UnZuhd0VzPcf9KXLt8HZPJhch8+8Ry68LCNxCl8nIoYrV0iW6 XVVlQxCWQ7t4sp3Yomsgox0MA4iDdB5ZwLYPpWkqdnXwqV8C6tVxKVuErNNtqfo1KRnp thVdWFSlltAxQ+qvUyXg1/LHEtPD3VRaHF2fKofv5rIBwxJMZ85sO3UXsq2S84THoRvH bUmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WTsqof7Q; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kf12-20020a17090305cc00b001a1a8ead6c1si18756950plb.641.2023.03.24.00.11.35; Fri, 24 Mar 2023 00:11:47 -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=WTsqof7Q; 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 S231211AbjCXHIV (ORCPT + 99 others); Fri, 24 Mar 2023 03:08:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230079AbjCXHIR (ORCPT ); Fri, 24 Mar 2023 03:08:17 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A684270B; Fri, 24 Mar 2023 00:08:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679641696; x=1711177696; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=1QwNjA/703mfJcIj5DSMOgyWQ/j+uRh45wv8E+wMysE=; b=WTsqof7QB+w8HsQPQScXcuo8Fw4ijRo5+OJt7cRp/JmkxlF++//1FRAg dLdYVwBn8jVOCr6le+X0/Bdh2MjkgYyqZSxYhzl4SX7S1AvNcjK9+Q47p vYFuxCR7il+hxsl8mKRHMyz5iAGn9sK3Du0S8ktcCa7a6qPrC8qM8VnPV b5L0Tm3u8sCjrmqAp3SFZ2vr8agLUpT6+w2A/se/U4wT0XlLcuz8yROsU QYZ2Mqw5mgH6b8PkVNX4QczPVjqn7a/U6uYOVPJ9+128OiLzuqUs/GiuQ pmRtLSGVs5h2IpnVOFEJUBj3omup+OitRjZh8dZu19KfIHbQ9IcJPkpRc w==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402296711" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="402296711" 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:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="747046047" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="747046047" 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:14 -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 v2 1/5] thermal/core: Update cooling device during thermal zone unregistration Date: Fri, 24 Mar 2023 15:08:03 +0800 Message-Id: <20230324070807.6342-1-rui.zhang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761232192789849078?= X-GMAIL-MSGID: =?utf-8?q?1761232192789849078?= When unregistering a thermal zone device, update all cooling devices bound to the thermal zone device. This fixes a problem that the frequency of ACPI processors are still limited after unloading ACPI thermal driver while ACPI passive cooling is activated. Cc: stable@vger.kernel.org Signed-off-by: Zhang Rui --- v1 -> v2 Changelog update. Rearrange the code to elimiate an "iterator used outside loop" warning. --- drivers/thermal/thermal_core.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index cfd4c1afeae7..30ff39154598 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1497,9 +1497,24 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) /* Unbind all cdevs associated with 'this' thermal zone */ list_for_each_entry(cdev, &thermal_cdev_list, node) { + struct thermal_instance *ti; + + mutex_lock(&tz->lock); + list_for_each_entry(ti, &tz->thermal_instances, tz_node) { + if (ti->cdev == cdev) { + mutex_unlock(&tz->lock); + goto unbind; + } + } + + /* The cooling device is not bound to current thermal zone */ + mutex_unlock(&tz->lock); + continue; + +unbind: if (tz->ops->unbind) { tz->ops->unbind(tz, cdev); - continue; + goto deactivate; } if (!tzp || !tzp->tbp) @@ -1511,6 +1526,16 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) tzp->tbp[i].cdev = NULL; } } + +deactivate: + /* + * The thermal instances for current thermal zone has been + * removed. Update the cooling device in case it is activated + * by current thermal zone device. + */ + mutex_lock(&cdev->lock); + __thermal_cdev_update(cdev); + mutex_unlock(&cdev->lock); } mutex_unlock(&thermal_list_lock); From patchwork Fri Mar 24 07:08:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 74378 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp429195vqo; Fri, 24 Mar 2023 00:12:03 -0700 (PDT) X-Google-Smtp-Source: AKy350Zy0asQBlgTqv4LKd78Kh6Wjeuo+dYloqLE5qziT88hkhFTTjBQotd5YhoVIobClvyrXCy1 X-Received: by 2002:a62:1a10:0:b0:625:e77b:433e with SMTP id a16-20020a621a10000000b00625e77b433emr1767131pfa.24.1679641922799; Fri, 24 Mar 2023 00:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679641922; cv=none; d=google.com; s=arc-20160816; b=ysf952u8GoOoUMXe0UtbGOBmeEFI6kF3diNK7/57r6dYoh0ddsd+y8fS8PRQrlCqn5 eUQBVdzU+ibSp4kwtfc5Z48K8Z33f4GQYcveinlTzBjRKaoNcXYjbc87m5pENvTLV2/G Y1/UMPlphCeCaPJMAnNaCoOZLWDyCY3N4EmECeoxUs+Xlp0dOlhqD/9DPjAsRrGRSt4x xjk8AWm0fgkk3zuM1KYxThg5M25DFGSGUhV4Ecoe0x/scih88yeYEw9oMl9mV9H2TXf5 dulqQTeLCUY2Q4ireJFX+HI9XUuZTsGTbeFoih7AoQjTGA5xKog6aG5lFHlUUFK0VRsc BhoA== 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 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.11.50; Fri, 24 Mar 2023 00:12:02 -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 S231215AbjCXHI3 (ORCPT + 99 others); Fri, 24 Mar 2023 03:08:29 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761232208719528013?= X-GMAIL-MSGID: =?utf-8?q?1761232208719528013?= 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); From patchwork Fri Mar 24 07:08:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 74384 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp433594vqo; Fri, 24 Mar 2023 00:22:38 -0700 (PDT) X-Google-Smtp-Source: AKy350ZB6caIJCDddB7H++o+57NTfeM1lEEmJAJWwCQRoQJr+Tz4e90KpLyL1phNcZBArY/clUoo X-Received: by 2002:a17:907:77d3:b0:92b:f019:d5eb with SMTP id kz19-20020a17090777d300b0092bf019d5ebmr1485931ejc.44.1679642558318; Fri, 24 Mar 2023 00:22:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679642558; cv=none; d=google.com; s=arc-20160816; b=yt0/8E9KtA11i4qDPYlRc9niyMJdv+Zg0t9ajN7r4iCyVzW3nXIaiX8bDVYdWpg81G Mxi0/TBDTftbz99bP36t2NkNYGs9+Hfibe8nrXhPS+IdgVbM14SWjBDRJqQ1wSidGBj9 LI+e9fQJFeoH9JPgW2HyENnq44u5kzjZ7A2qObe+csAuE3LVbc/oH8qLoktcl7Q3N0oV p4do1R/pltnNQRIgSXC4OkcdW10zghvfX9eFDhDFDfF53ZidrdyjMiD4WOiz7YP92yDb ujJwbJKqT/RmTT/CJIsXMhulbpdHL2CU4RD3B8NUW5iDLBQ5FPyS+UJKrSVIotJfRDk/ hbWA== 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=uNX18VroqqY9Nvr3d+avwleXOiXN+cVp59mEF69iq0M=; b=0C6Ikmp8t21C/QJfRn19hoWvqAQ81I0bRA5UnOfaLOFtbz8CrX/h01O1LGpJEtzgcc i57ZZ0HV0AlZLp5ygpkDpjV9ZC/X5Hb0vbBUvI6ImGbkEmqBDK1GUPi8yelqkfmmHkkY ZQl8uVtRZLQ74bG8sIAOfcsK/AaNTYvhpvJtJGMBfp8gLPyBIUeOOLxcY/73p54a1JXo 35Qp1BisCnyUGaHvBqfPmN/w8n/f5afApnVEQ0Ext3AbFYg28UGmBQwEbbT8yX8I/dYn 7MiunOWT3Gwe/22DCXkSEv2gkBacQ/E7ftIlc8qFi5iTuz0VSEUmLTMq2sxiwUnKA9s1 w79Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Co4IB9WL; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id md5-20020a170906ae8500b008e3da5c56f4si19848162ejb.485.2023.03.24.00.21.58; Fri, 24 Mar 2023 00:22:38 -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=Co4IB9WL; 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 S231382AbjCXHIc (ORCPT + 99 others); Fri, 24 Mar 2023 03:08:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231189AbjCXHIU (ORCPT ); Fri, 24 Mar 2023 03:08:20 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E2F02723; Fri, 24 Mar 2023 00:08:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679641699; x=1711177699; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=u6iHiScBifXZ1ltDhXObrT9QpiwYLsnp8xcW9/S7U+I=; b=Co4IB9WLWmF/EB+Bp0QncespEoLf8/WEda4Jt5hc524q15UEYpheQNJJ MyENTgnCZyMdwKKQQfOmBnqQJNlOAPz+7KNv5uVOYKLyQSYDF/XOmu15l /nsu76JUJpDWKxc+cecGyI9aSiQCT+XeY3DrpHeX943MH2oIyBKAZrRoV wRWwYYXFh0oxQXvIJ1G7605Ig+/lR+MoBu0Uyx8mUsdGhjJwN+fEglY/V ffBNcd9H8sTaLI7aEjpZIClf3UUEJVFmRi2X7t0Qy3Kjk8ObXTEvpKUM9 Wxnf6Fxzp1gizLbfGjNofftVpNsKtvobUIsBzbLVNxaO2jNZtFZemJxZH w==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402296723" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="402296723" 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:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="747046056" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="747046056" 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:17 -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 3/5] thermal/core: Remove thermal_bind_params structure Date: Fri, 24 Mar 2023 15:08:05 +0800 Message-Id: <20230324070807.6342-3-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761232875350705026?= X-GMAIL-MSGID: =?utf-8?q?1761232875350705026?= Remove struct thermal_bind_params because no one is using it for thermal binding now. Signed-off-by: Zhang Rui --- .../driver-api/thermal/sysfs-api.rst | 40 ------ drivers/thermal/thermal_core.c | 134 ++---------------- include/linux/thermal.h | 38 ----- 3 files changed, 14 insertions(+), 198 deletions(-) diff --git a/Documentation/driver-api/thermal/sysfs-api.rst b/Documentation/driver-api/thermal/sysfs-api.rst index 2e0f79a9e2ee..6c1175c6afba 100644 --- a/Documentation/driver-api/thermal/sysfs-api.rst +++ b/Documentation/driver-api/thermal/sysfs-api.rst @@ -304,42 +304,6 @@ temperature) and throttle appropriate devices. 1.4 Thermal Zone Parameters --------------------------- - :: - - struct thermal_bind_params - - This structure defines the following parameters that are used to bind - a zone with a cooling device for a particular trip point. - - .cdev: - The cooling device pointer - .weight: - The 'influence' of a particular cooling device on this - zone. This is relative to the rest of the cooling - devices. For example, if all cooling devices have a - weight of 1, then they all contribute the same. You can - use percentages if you want, but it's not mandatory. A - weight of 0 means that this cooling device doesn't - contribute to the cooling of this zone unless all cooling - devices have a weight of 0. If all weights are 0, then - they all contribute the same. - .trip_mask: - This is a bit mask that gives the binding relation between - this thermal zone and cdev, for a particular trip point. - If nth bit is set, then the cdev and thermal zone are bound - for trip point n. - .binding_limits: - This is an array of cooling state limits. Must have - exactly 2 * thermal_zone.number_of_trip_points. It is an - array consisting of tuples of - state limits. Each trip will be associated with one state - limit tuple when binding. A NULL pointer means - on all trips. - These limits are used when binding a cdev to a trip point. - .match: - This call back returns success(0) if the 'tz and cdev' need to - be bound, as per platform data. - :: struct thermal_zone_params @@ -357,10 +321,6 @@ temperature) and throttle appropriate devices. will be created. when no_hwmon == true, nothing will be done. In case the thermal_zone_params is NULL, the hwmon interface will be created (for backward compatibility). - .num_tbps: - Number of thermal_bind_params entries for this zone - .tbp: - thermal_bind_params entries 2. sysfs attributes structure ============================= diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index fd54e6c10b60..5225d65fb0e0 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -794,65 +794,20 @@ void print_bind_err_msg(struct thermal_zone_device *tz, tz->type, cdev->type, ret); } -static void __bind(struct thermal_zone_device *tz, int mask, - struct thermal_cooling_device *cdev, - unsigned long *limits, - unsigned int weight) -{ - int i, ret; - - for (i = 0; i < tz->num_trips; i++) { - if (mask & (1 << i)) { - unsigned long upper, lower; - - upper = THERMAL_NO_LIMIT; - lower = THERMAL_NO_LIMIT; - if (limits) { - lower = limits[i * 2]; - upper = limits[i * 2 + 1]; - } - ret = thermal_zone_bind_cooling_device(tz, i, cdev, - upper, lower, - weight); - if (ret) - print_bind_err_msg(tz, cdev, ret); - } - } -} - static void bind_cdev(struct thermal_cooling_device *cdev) { - int i, ret; - const struct thermal_zone_params *tzp; + int ret; struct thermal_zone_device *pos = NULL; mutex_lock(&thermal_list_lock); list_for_each_entry(pos, &thermal_tz_list, node) { - if (!pos->tzp && !pos->ops->bind) + if (!pos->ops->bind) continue; - if (pos->ops->bind) { - ret = pos->ops->bind(pos, cdev); - if (ret) - print_bind_err_msg(pos, cdev, ret); - continue; - } - - tzp = pos->tzp; - if (!tzp || !tzp->tbp) - continue; - - for (i = 0; i < tzp->num_tbps; i++) { - if (tzp->tbp[i].cdev || !tzp->tbp[i].match) - continue; - if (tzp->tbp[i].match(pos, cdev)) - continue; - tzp->tbp[i].cdev = cdev; - __bind(pos, tzp->tbp[i].trip_mask, cdev, - tzp->tbp[i].binding_limits, - tzp->tbp[i].weight); - } + ret = pos->ops->bind(pos, cdev); + if (ret) + print_bind_err_msg(pos, cdev, ret); } mutex_unlock(&thermal_list_lock); @@ -1138,16 +1093,6 @@ void thermal_cooling_device_update(struct thermal_cooling_device *cdev) } EXPORT_SYMBOL_GPL(thermal_cooling_device_update); -static void __unbind(struct thermal_zone_device *tz, int mask, - struct thermal_cooling_device *cdev) -{ - int i; - - for (i = 0; i < tz->num_trips; i++) - if (mask & (1 << i)) - thermal_zone_unbind_cooling_device(tz, i, cdev); -} - /** * thermal_cooling_device_unregister - removes a thermal cooling device * @cdev: the thermal cooling device to remove. @@ -1157,8 +1102,6 @@ static void __unbind(struct thermal_zone_device *tz, int mask, */ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) { - int i; - const struct thermal_zone_params *tzp; struct thermal_zone_device *tz; if (!cdev) @@ -1175,21 +1118,8 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) /* Unbind all thermal zones associated with 'this' cdev */ list_for_each_entry(tz, &thermal_tz_list, node) { - if (tz->ops->unbind) { + if (tz->ops->unbind) tz->ops->unbind(tz, cdev); - continue; - } - - if (!tz->tzp || !tz->tzp->tbp) - continue; - - tzp = tz->tzp; - for (i = 0; i < tzp->num_tbps; i++) { - if (tzp->tbp[i].cdev == cdev) { - __unbind(tz, tzp->tbp[i].trip_mask, cdev); - tzp->tbp[i].cdev = NULL; - } - } } mutex_lock(&cdev->lock); @@ -1204,41 +1134,20 @@ EXPORT_SYMBOL_GPL(thermal_cooling_device_unregister); static void bind_tz(struct thermal_zone_device *tz) { - int i, ret; + int ret; struct thermal_cooling_device *pos = NULL; - const struct thermal_zone_params *tzp = tz->tzp; - if (!tzp && !tz->ops->bind) + if (!tz->ops->bind) return; mutex_lock(&thermal_list_lock); - /* If there is ops->bind, try to use ops->bind */ - if (tz->ops->bind) { - list_for_each_entry(pos, &thermal_cdev_list, node) { - ret = tz->ops->bind(tz, pos); - if (ret) - print_bind_err_msg(tz, pos, ret); - } - goto exit; - } - - if (!tzp || !tzp->tbp) - goto exit; - list_for_each_entry(pos, &thermal_cdev_list, node) { - for (i = 0; i < tzp->num_tbps; i++) { - if (tzp->tbp[i].cdev || !tzp->tbp[i].match) - continue; - if (tzp->tbp[i].match(tz, pos)) - continue; - tzp->tbp[i].cdev = pos; - __bind(tz, tzp->tbp[i].trip_mask, pos, - tzp->tbp[i].binding_limits, - tzp->tbp[i].weight); - } + ret = tz->ops->bind(tz, pos); + if (ret) + print_bind_err_msg(tz, pos, ret); } -exit: + mutex_unlock(&thermal_list_lock); } @@ -1477,15 +1386,13 @@ EXPORT_SYMBOL_GPL(thermal_zone_device_register); */ void thermal_zone_device_unregister(struct thermal_zone_device *tz) { - int i, tz_id; - const struct thermal_zone_params *tzp; + int tz_id; struct thermal_cooling_device *cdev; struct thermal_zone_device *pos = NULL; if (!tz) return; - tzp = tz->tzp; tz_id = tz->id; mutex_lock(&thermal_list_lock); @@ -1516,22 +1423,9 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) continue; unbind: - if (tz->ops->unbind) { + if (tz->ops->unbind) tz->ops->unbind(tz, cdev); - goto deactivate; - } - - if (!tzp || !tzp->tbp) - break; - - for (i = 0; i < tzp->num_tbps; i++) { - if (tzp->tbp[i].cdev == cdev) { - __unbind(tz, tzp->tbp[i].trip_mask, cdev); - tzp->tbp[i].cdev = NULL; - } - } -deactivate: /* * The thermal instances for current thermal zone has been * removed. Update the cooling device in case it is activated diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 13c6aaed18df..481417d3b9b7 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -207,41 +207,6 @@ struct thermal_governor { struct list_head governor_list; }; -/* Structure that holds binding parameters for a zone */ -struct thermal_bind_params { - struct thermal_cooling_device *cdev; - - /* - * This is a measure of 'how effectively these devices can - * cool 'this' thermal zone. It shall be determined by - * platform characterization. This value is relative to the - * rest of the weights so a cooling device whose weight is - * double that of another cooling device is twice as - * effective. See Documentation/driver-api/thermal/sysfs-api.rst for more - * information. - */ - int weight; - - /* - * This is a bit mask that gives the binding relation between this - * thermal zone and cdev, for a particular trip point. - * See Documentation/driver-api/thermal/sysfs-api.rst for more information. - */ - int trip_mask; - - /* - * This is an array of cooling state limits. Must have exactly - * 2 * thermal_zone.number_of_trip_points. It is an array consisting - * of tuples of state limits. Each trip - * will be associated with one state limit tuple when binding. - * A NULL pointer means - * on all trips. - */ - unsigned long *binding_limits; - int (*match) (struct thermal_zone_device *tz, - struct thermal_cooling_device *cdev); -}; - /* Structure to define Thermal Zone parameters */ struct thermal_zone_params { char governor_name[THERMAL_NAME_LENGTH]; @@ -253,9 +218,6 @@ struct thermal_zone_params { */ bool no_hwmon; - int num_tbps; /* Number of tbp entries */ - struct thermal_bind_params *tbp; - /* * Sustainable power (heat) that this thermal zone can dissipate in * mW From patchwork Fri Mar 24 07:08:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 74382 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp432446vqo; Fri, 24 Mar 2023 00:19:40 -0700 (PDT) X-Google-Smtp-Source: AKy350Y05Bzym1lyYLXI0iGQhY5hJNdletwyVsdO54YApNjN14FkFAlee4pb+YkVwm5JoK/74ynB X-Received: by 2002:a17:906:9619:b0:922:446b:105a with SMTP id s25-20020a170906961900b00922446b105amr1751771ejx.19.1679642380345; Fri, 24 Mar 2023 00:19:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679642380; cv=none; d=google.com; s=arc-20160816; b=vVlWIxHnDRJOLwMBWbzeNFx9HqatiLvYrsyQlZWO66Eon7MffluX9YEL4UHXBw1+zp jyYZ76v5M8OeXaT/zeA68Bt/3YNFces4zfm3QTTAPhqloSM1DF0nRQ5Z89lznqfcq2rH URZdO2PSoDWDEGgHrBOxbNqa7MsjTJxwRcPm4pC3BHyPBkRiZdF/yY50Awk1kDZdLxDV QX6mrd9DP1et+M/L89zXjAp6t637/SxKCzp+cTNA7bqPlkVkAeKhMgXMdZS1N1+FNPG9 QgY3JymHTXu95dosg8oL8bV24ZMOlpv8cNXoXErAlWdRrPJx7whnSKi3G9D1K6+X0bhb JhjQ== 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=IpxBKNfauOCmaQD3yyV8OgghieykzYY6kndQM1S08pI=; b=PwQgpRA/ajPbBXduTK7I2XREYgGGPrZ5LseiCtI9/IjLreJaIMseK+kU65o1ZKuMpb 9xGE1h374s2z2tUZ0hc5omy9CoiGxz+m876o2gqSlsGQlqrPm22k3WBQ4lcZ8psuHWk5 g6Ffjf8bnGT9ndE/e8b+IrlC6xnDWDnBep/9n701iecVJL3uUQQPESG52Kkg5f3ccIji 8F16CcD1mPXvPs0zPy2J9rAsJRQ/H4pxB6Ojq+tXUheR/2wUILTmdpWDxBqGZybYHOAI +/pgJPhDiSJGxhc6X9WzVjIPv79Rq0l8vC1utO91kOiyCyIUGviauD0UIszj7p5dTekL zV4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=abu2PdgA; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y21-20020a17090614d500b00922cbf5c852si4839050ejc.388.2023.03.24.00.19.08; Fri, 24 Mar 2023 00:19:40 -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=abu2PdgA; 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 S231419AbjCXHIf (ORCPT + 99 others); Fri, 24 Mar 2023 03:08:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231196AbjCXHIV (ORCPT ); Fri, 24 Mar 2023 03:08:21 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E33FD10ABA; Fri, 24 Mar 2023 00:08:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679641700; x=1711177700; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wFx21pLLRhlzjgfRpaT39oVLARW7iuGOv5zrbZTnlkk=; b=abu2PdgA1eA702P8ApPn2n/+vMIRXDH5u+K5esz1fQAaD/SyvTv8hW03 gj+1vkJnB/IsZnKc88jr6Kk4ZkdKsR7DbyHQdZElF+quhahn3NQ6VMwD6 CPhsx/EE+494mQUekW6gvKTM+yzmCugKCxoASD1tGBpw3un9/IZcnx+YG pWhXbGBx3dZFwCNJbqRkcC0s7s2Rm7oGWLc/+Gkp1DaacJCMWSKe0q6CH IASfyqFyXoVdbiZS14CFHN7N9tBE3n1QWTwA3bOZPAXBRfdFXPrt2Km03 ubDuAhtHHKcKEyfcpsukclgM+EjCfqkqs7st5OoKcR1UkFvK/dolAQcOX g==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402296729" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="402296729" 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:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="747046060" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="747046060" 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:19 -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 4/5] thermal/core: Enforce paired .bind/.unbind callbacks Date: Fri, 24 Mar 2023 15:08:06 +0800 Message-Id: <20230324070807.6342-4-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761232688946415546?= X-GMAIL-MSGID: =?utf-8?q?1761232688946415546?= The .bind/.unbind callbacks are designed to allow the thermal zone device to bind to/unbind from a matched cooling device, with thermal instances created/deleted. In this sense, .bind/.unbind callbacks must exist in pairs. Signed-off-by: Zhang Rui --- drivers/thermal/thermal_core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 5225d65fb0e0..9c447f22cb39 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1258,6 +1258,11 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t if (num_trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp) && !trips) return ERR_PTR(-EINVAL); + if ((ops->bind && !ops->unbind) || (!ops->bind && ops->unbind)) { + pr_err("Thermal zone device .bind/.unbind not paired\n"); + return ERR_PTR(-EINVAL); + } + if (!thermal_class) return ERR_PTR(-ENODEV); From patchwork Fri Mar 24 07:08:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 74380 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp430812vqo; Fri, 24 Mar 2023 00:15:46 -0700 (PDT) X-Google-Smtp-Source: AK7set/0lY0eX7OltWuqNfemvVjt0MWeD+7stA3gioQ+teGQWwQOkzzdGFEYBMoWT8QyW+H/2FzR X-Received: by 2002:a05:6a20:3104:b0:d9:91d2:b81e with SMTP id 4-20020a056a20310400b000d991d2b81emr1764373pzf.62.1679642145734; Fri, 24 Mar 2023 00:15:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679642145; cv=none; d=google.com; s=arc-20160816; b=BhrIUz0uSYiWbnB2YXLNz3CpLZm14PhxJBkxt/7BQaXSggUVaHXuT43IFwgMUwpQHs O5gDl9bbxBX/VQDDm7Shsz//BGNdEX46eBY5tgEqO52vEokWRv9sQKBrpHqMLDryr1n0 Mq8N7JHurEOphiPNOFBQ6k/5JpzTeGuJSKnIoq9yTrq/vGo+oVSA18F9HCuYIp0B+nxW ecyxzOLgG7P2AVPoaA4NVUIt2ieViQof668xmpwHEOxdT+TooiI1RiU5NXYdpzuKbJRw YTa1EQRBbdwgU+7ZSLqh2YFdqs+rF5ZBlg+UXq7FNqSnLiY5WniD9vFUiFPx8TVhfVIt oLBg== 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=Ls2mZeeu7roxMjEXsoSO2ZAJNsGdzwJ8fJ9rss3YYX8=; b=qFWvUnO9Nc5MyQvyJfGp7/SdQwhWTUlJSclPMgK5XZSY3LudvsVo+MZEA7K5hkX2XN D7yGW0dAIDBo+TQw8+VlYYjMYpnDFYzF7RMxIsB1Cb/Fmzy5/poWM0+cygDrHuTCE4GO YxYzKhq0GEoczgPU+LrFLGAJ/KqTcC8uT9CrfJc5KzMjs/0QVtanFXFwvfbbBkVjbLdI WAcz1k6jWHj8TBuHOLWsDDg9RYAvY53HJRSzIlg6ES5D2Pr1tRTH9AY9XbgqNqsx/rGT QIoZLmEIMAyfi9mSqr/PndkudXEiX3SZ05PeNwcvHgvXhlCS3xR4ih76kVTqCr0CDd8g Ly3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aUvsfTZq; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s15-20020a65690f000000b005032da7f05dsi20596954pgq.508.2023.03.24.00.15.33; Fri, 24 Mar 2023 00:15:45 -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=aUvsfTZq; 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 S231489AbjCXHIi (ORCPT + 99 others); Fri, 24 Mar 2023 03:08:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231241AbjCXHIY (ORCPT ); Fri, 24 Mar 2023 03:08:24 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C9B95261; Fri, 24 Mar 2023 00:08:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679641702; x=1711177702; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Is2PNwJDYKRvv3xNHfYVY2PhgMrlEfNhGTel6iyfNy8=; b=aUvsfTZqzs4/PkVoh8LJ+/8S0So/E1+Cli7KlLLMJP3dsW6toxaS+VW6 RWalAUS/V4yHCoj+Bq1IlqZ+PXT2tSC+cQ5wCQbY/suSft6+mS9fMdPYD /a4s4k/HdgrJ7QSQqtjg1f6JhCGTpv/gzu3sLhh1n3PIWrLfnWyInZBtP 0nG5tWLX+Cue+Y3Sd9aaVN1G2Cs6+ECswDbBueFwFrpQ/ep+nQIacm8IN a183X1RDkm3Pel4aoTZLZN+GtNF1eiwhDGMLWFz7DOCzqjhkjv2Bq5Quk fs724P15gRpswH6w6CEtoVARjkR+WfGZtMeDfkbHknKysWgPS5I3VFBnF w==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="402296736" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="402296736" 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:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="747046063" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="747046063" 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:20 -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 5/5] thermal/core: Avoid unbind for thermal zones without .unbind() Date: Fri, 24 Mar 2023 15:08:07 +0800 Message-Id: <20230324070807.6342-5-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761232442393518581?= X-GMAIL-MSGID: =?utf-8?q?1761232442393518581?= The ops->bind()/unbind() callback is the only way to bind/unbind a cooling device to/from a thermal zone. Optimize the code to avoid trying unbind when .unbind() callback doesn't exist. Signed-off-by: Zhang Rui --- drivers/thermal/thermal_core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 9c447f22cb39..1af36450f13e 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1411,6 +1411,9 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) } list_del(&tz->node); + if (!tz->ops->unbind) + goto unbind_done; + /* Unbind all cdevs associated with 'this' thermal zone */ list_for_each_entry(cdev, &thermal_cdev_list, node) { struct thermal_instance *ti; @@ -1428,8 +1431,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) continue; unbind: - if (tz->ops->unbind) - tz->ops->unbind(tz, cdev); + tz->ops->unbind(tz, cdev); /* * The thermal instances for current thermal zone has been @@ -1441,6 +1443,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) mutex_unlock(&cdev->lock); } +unbind_done: mutex_unlock(&thermal_list_lock); cancel_delayed_work_sync(&tz->poll_queue);