From patchwork Sat Oct 7 11:34:35 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: 149554 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp875662vqo; Sat, 7 Oct 2023 04:35:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEoj78obISPRC8/P8Wpq4Z3luWJIRZfHSMLFT7dnIWmB/6eC3H2kMeUyIDTNl3CXqkHes7j X-Received: by 2002:a17:902:f7d3:b0:1c4:32da:2037 with SMTP id h19-20020a170902f7d300b001c432da2037mr8882462plw.64.1696678501923; Sat, 07 Oct 2023 04:35:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696678501; cv=none; d=google.com; s=arc-20160816; b=sd4C1MJ2DiWu70VsKMFLUP94Jyh1NVIvHcFIEMe4dmTqooHfGxTN2WbZpfmGKUbK5e I7Yt0QmwfhZ4AFbZIW6SRho0lXTsdju6yIphFUU6Goe/hfdvS3qQwbQUH4SpWfPlulPt yR1qWctu27MQdnlxkr2f8a63nFTUW4bnTMelmcYn73iRnR3aECg1W+Cbo6VPpGniYcbo YApdRHWVajaQAcGDaakN6URPPuZTS4TA7XTgTmuX+R0Iat68CsyQvR5rJkPFk0w345nq eOJe1HfMVb4Yeqthq6e/qRTKHtSSg5jjLQffjYfzdHyFdmT1MFwGpDBHqMccEaND6opi 30FA== 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=ZE86UMKJeU52dyZHCGRwDD6gAcMF5ConRr1/EzeAsOU=; fh=5OBIUCw4znRZzzo1fNLLIKs/qNmPBukD41q/q7SVSTQ=; b=pBt/Ozoa1OoIO/6fKUaMVByA8LeIBIgUaw0KA5elivGvamruKPrT7PC/iPpG16pj7K fjJHa9Zi8VczFlSmDHLhsSZIROlbPsl+VLNjBNLue49BaT+b50s7/MzBjE+8Wc+5MAdU 7jdzSWx0Pj+fLtsyJlhZfAHLAyXVRaJsUWYtbJPvsjFefneC+luwjNSN+Ze6EVvmuPYZ rrZzPFYHrZbPp/euEz5f57V7YeM3XWZ4Qo4AKExKN/MzmlfOZOY8Dd4sjg9gUT1Asga0 tgkhYJb3FI5pHYMabmJkLi/8JE6+WuTcH8fxi+bYYGjxSWspc+vHEjdagwdnEMwkd70g QRZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id lm5-20020a170903298500b001c20db2510asi5682972plb.53.2023.10.07.04.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 04:35:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id DAA648047847; Sat, 7 Oct 2023 04:34:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343873AbjJGLen (ORCPT + 18 others); Sat, 7 Oct 2023 07:34:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233662AbjJGLem (ORCPT ); Sat, 7 Oct 2023 07:34:42 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04532FA; Sat, 7 Oct 2023 04:34:38 -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.2.0) id 9c1dd8458e715ef9; Sat, 7 Oct 2023 13:34:36 +0200 Received: from kreacher.localnet (unknown [195.136.19.94]) (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 D356B6621FA; Sat, 7 Oct 2023 13:34:35 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: Daniel Lezcano , Linux ACPI , LKML , "Rafael J. Wysocki" , Srinivas Pandruvada , Zhang Rui Subject: [PATCH v1] thermal: trip: Remove lockdep assertion from for_each_thermal_trip() Date: Sat, 07 Oct 2023 13:34:35 +0200 Message-ID: <2709769.mvXUDI8C0e@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvkedrgeelgdegudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpeffffffkefgheehffelteeiveeffeevhfelteejvddvieejjeelvdeiheeuveeuffenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeejpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrghdprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthho pehrrghfrggvlheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepshhrihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=7 Fuz1=7 Fuz2=7 X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,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 fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sat, 07 Oct 2023 04:34:59 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779096356801720227 X-GMAIL-MSGID: 1779096356801720227 From: Rafael J. Wysocki The lockdep assertion in for_each_thermal_trip() was added to possibly catch incorrect usage of that function without the thermal zone lock. However, it turns out that the ACPI thermal driver has a legitimate reason to call for_each_thermal_trip() without locking. Namely, it is called by acpi_thermal_bind_unbind_cdev() in the thermal zone registration and unregistration paths. That function cannot acquire the thermal zone lock by itself, because it calls functions that acquire it, thermal_bind_cdev_to_trip() or thermal_unbind_cdev_from_trip(). However, it is invoked when the ACPI notify handler for the thermal zone in question has not been registered yet (in the registration path) or after that handler has been unregistered (in the unregistration path). Therefore, when for_each_thermal_trip() is called by acpi_thermal_bind_unbind_cdev(), thermal trip changes induced by the platform firmware cannot take place and so the thermal zone's trips[] table is effectively immutable. Hence, it is valid to call for_each_thermal_trip() from acpi_thermal_bind_unbind_cdev() without locking and the lockdep assertion in the former is in fact incorrect, so remove it. Fixes: d5ea889246b1 ("ACPI: thermal: Do not use trip indices for cooling device binding") Signed-off-by: Rafael J. Wysocki --- drivers/thermal/thermal_trip.c | 2 -- 1 file changed, 2 deletions(-) Index: linux-pm/drivers/thermal/thermal_trip.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_trip.c +++ linux-pm/drivers/thermal/thermal_trip.c @@ -15,8 +15,6 @@ int for_each_thermal_trip(struct thermal { int i, ret; - lockdep_assert_held(&tz->lock); - for (i = 0; i < tz->num_trips; i++) { ret = cb(&tz->trips[i], data); if (ret)