From patchwork Wed Mar 22 19:34:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 73646 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2533230wrt; Wed, 22 Mar 2023 12:43:24 -0700 (PDT) X-Google-Smtp-Source: AKy350adedrR3a6VzeRR0aKtnLbX/dysSZn6HNANbITWkL5exhQkEFIejk3lA2NGVhdWnnVUJ9l7 X-Received: by 2002:a17:90b:17c5:b0:23f:634a:6c7 with SMTP id me5-20020a17090b17c500b0023f634a06c7mr3004702pjb.15.1679514203797; Wed, 22 Mar 2023 12:43:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679514203; cv=none; d=google.com; s=arc-20160816; b=V3+HOKA6UBUfNcyB3CxojrrGQB1oNev1vviDHuHL3sfavnz4dWppVSPBHClPKDnkBc BWdMBWi6eCawLUWwMvBVab8WdSABULVd5TfuD7Do2haG5PVAflGR5nlRhFKDJolEmTAm zTTB7Gifuwl6+DJN6oA1tyBr8ge2suJYUI93v/aECf+oeSuUH2B+HhmCC05CRMeGqtcZ r3iqg1GvJ+23PxiHu95Tti5nBKbZUJJ4NgXZUXsAkNZGqNKnnKOB996ZJTMGwXuukagc xOQ/BR373/vVRUApJ6hfcWtzwxSFA+ggFGm2RzbVUpiEKkH5Z716TFVeF3ED6ln0U1bJ seSA== 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; bh=OiseYTfqOzq25518qIky/j0dYFSiYNS5Vo18hBcrOY8=; b=PIKzHGzE6A8kzP/bdUdhyTMkzutLBPKP+imsWGshCLJ2uYuEww8yPcgEthdo9S7QNS WtjH1DNpZLoPIedoPcChPJEKTiaXTfxU2L2AStFCXJNKdsSoa4GLA/j17I9AuY+cFTxP DZtmZPtBUSOyal0s11IjnxuYUs3Kd96ZC9YqstvXL/LplxTaWntwy+haDbuk/KENumwH ShKhqFKztt4eVgBruL/qZpQAvRTXDvHAMaGu3mq8gYueiRiNTz2ES6xAASF3cF15rVzk y/bFxI0kk4fBGqRhtD8u0BQXnepjytlp/0PDde53yLzTBxq8I6Ey6tcYFR16Ddx2phXx TvNQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a12-20020a17090a854c00b0023d1bcea88bsi21066212pjw.66.2023.03.22.12.43.10; Wed, 22 Mar 2023 12:43:23 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229754AbjCVTeY (ORCPT + 99 others); Wed, 22 Mar 2023 15:34:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229600AbjCVTeX (ORCPT ); Wed, 22 Mar 2023 15:34:23 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 932344E5F5; Wed, 22 Mar 2023 12:34:15 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id 66da7f182edbea95; Wed, 22 Mar 2023 20:34:13 +0100 Received: from kreacher.localnet (unknown [213.134.163.127]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 4245422201E0; Wed, 22 Mar 2023 20:34:13 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Zhang Rui , Srinivas Pandruvada , Daniel Lezcano Subject: [PATCH v1] thermal: core: Clean up thermal_list_lock locking Date: Wed, 22 Mar 2023 20:34:12 +0100 Message-ID: <2696911.mvXUDI8C0e@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.163.127 X-CLIENT-HOSTNAME: 213.134.163.127 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrvdegvddguddvjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpeffffffkefgheehffelteeiveeffeevhfelteejvddvieejjeelvdeiheeuveeuffenucfkphepvddufedrudefgedrudeifedruddvjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrdduieefrdduvdejpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeehpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgt ohhmpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS 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?1761098286023552439?= X-GMAIL-MSGID: =?utf-8?q?1761098286023552439?= From: Rafael J. Wysocki Once thermal_list_lock has been acquired in __thermal_cooling_device_register(), it is not necessary to drop it and take it again until all of the thermal zones have been updated, so change the code accordingly. No expected functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/thermal_core.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) Index: linux-pm/drivers/thermal/thermal_core.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_core.c +++ linux-pm/drivers/thermal/thermal_core.c @@ -826,8 +826,6 @@ static void bind_cdev(struct thermal_coo const struct thermal_zone_params *tzp; 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) continue; @@ -854,8 +852,6 @@ static void bind_cdev(struct thermal_coo tzp->tbp[i].weight); } } - - mutex_unlock(&thermal_list_lock); } /** @@ -933,17 +929,17 @@ __thermal_cooling_device_register(struct /* Add 'this' new cdev to the global cdev list */ mutex_lock(&thermal_list_lock); + list_add(&cdev->node, &thermal_cdev_list); - mutex_unlock(&thermal_list_lock); /* Update binding information for 'this' new cdev */ bind_cdev(cdev); - mutex_lock(&thermal_list_lock); list_for_each_entry(pos, &thermal_tz_list, node) if (atomic_cmpxchg(&pos->need_update, 1, 0)) thermal_zone_device_update(pos, THERMAL_EVENT_UNSPECIFIED); + mutex_unlock(&thermal_list_lock); return cdev;