Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7201903rwp; Tue, 18 Jul 2023 11:31:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlENc5FPKftafVzrDJPg3IH6g5PLWn8w1RExwJJqEuFbxT5Bitlz3gKfJ7Xp3dPIehy+9Yfn X-Received: by 2002:a05:6402:51cc:b0:51d:9a92:24f0 with SMTP id r12-20020a05640251cc00b0051d9a9224f0mr513782edd.4.1689705105519; Tue, 18 Jul 2023 11:31:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689705105; cv=none; d=google.com; s=arc-20160816; b=v1tYmq19d5tjHrRfmGmQKgfqz2K0kVlLI/ZoUyeyeCNQ59nkkWkeHOy7YTcIevf0eO g1R9XWhfRoJGRk7TRApd2hZDdbnSSqC+myFUfXM9c2+y1LAjB4mdj2eSFul6/jSDKtsd 8jBKLdAZKpgq82f1K1TVM5P9t4v/T74EFZZcgxIHVYAYGatviNE/JnV66hOwLoo36faa 9rXJRauyJ/JYJWO9umhUeXne2DYOiociKEbQp1oKjn2snxQ3GO1s57t4csCLewwGA0L4 w/fVopJBjiRsJ9LHJFpAhiJmexlE+stKTktf1yTso29UyI65/hNiFrQAe6oHlimsg0DZ PW4g== 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; bh=RqsLgAHG1ElqV+YrLiaoxgDR9kem7XP2SXh6iE4duBw=; fh=WAm0nkxw3rD71A4QzwJS1JiPPKRsyn91IiWMPsOrzoY=; b=B1a4nOaZT3lsXboFE34g9Hwc6q0M7UGggRNBFMlO/hN8ox30WIU7qjrHA+rTm7fLgF dP557mAq9U8O5gUu7M75C2O3cUBkKNk8IeuAEdnNQzgQXoxxMuGzTOEhVGSaFo3D613u V8Ca9PlBDfMZbbPkd7lqztl75ELmUxsVYVoDvZCMoMMz9AFqHXT4nKuTW/3Jk5pZYBdq /9R1EHQBpWxuZN3ANm3NIQhi7qtXZZOinBMoyHhuLBT7ypAd+6/RJZf11Y1/qYyYvEmC uTmWMd4+FENv7AvAq/Tn4vqHQzrmFmRqPHJZjH5kbTeRZ/gnVBVXSjnKYxSuDB1KYcL3 QGbA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z25-20020aa7c659000000b0051e0fbcde2dsi1579854edr.620.2023.07.18.11.31.21; Tue, 18 Jul 2023 11:31: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; 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 S229795AbjGRSVm (ORCPT + 99 others); Tue, 18 Jul 2023 14:21:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229536AbjGRSVe (ORCPT ); Tue, 18 Jul 2023 14:21:34 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81D7BFD; Tue, 18 Jul 2023 11:21:27 -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 1abb4fa41606034e; Tue, 18 Jul 2023 20:21:26 +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 86FC26614F7; Tue, 18 Jul 2023 20:21:25 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Linux PM , Michal Wilczynski , Zhang Rui , Srinivas Pandruvada , Daniel Lezcano Subject: [PATCH v1 4/7] ACPI: thermal: Hold thermal_check_lock around trip updates Date: Tue, 18 Jul 2023 20:06:02 +0200 Message-ID: <21958338.EfDdHjke4D@kreacher> In-Reply-To: <13318886.uLZWGnKmhe@kreacher> References: <13318886.uLZWGnKmhe@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedviedrgeeggdduudelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepjedprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehmihgthhgrlhdrfihilhgtiiihnhhskhhisehinhhtvghlrdgtohhmpdhr tghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=7 Fuz1=7 Fuz2=7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Rafael J. Wysocki There is a race condition between acpi_thermal_trips_update() and acpi_thermal_check_fn(), because the trip points may get updated while the latter is running which in theory may lead to inconsistent results. For example, if two trips are updated together, using the temperature value of one of them from before the update and the temperature value of the other one from after the update may not lead to the expected outcome. To address this, make acpi_thermal_trips_update() hold thermal_check_lock across the entire update of trip points. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/thermal.c | 4 ++++ 1 file changed, 4 insertions(+) Index: linux-pm/drivers/acpi/thermal.c =================================================================== --- linux-pm.orig/drivers/acpi/thermal.c +++ linux-pm/drivers/acpi/thermal.c @@ -193,6 +193,8 @@ static int acpi_thermal_trips_update(str struct acpi_handle_list devices; bool valid = false; int i; + + mutex_lock(&tz->thermal_check_lock); /* Critical Shutdown */ if (flag & ACPI_TRIPS_CRITICAL) { @@ -395,6 +397,8 @@ static int acpi_thermal_trips_update(str } } + mutex_unlock(&tz->thermal_check_lock); + return 0; }