From patchwork Wed Jan 25 12:17:42 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: 48144 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp248127wrn; Wed, 25 Jan 2023 04:31:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXtqksyo6KlWAWMF+tlSzI5Qnu3Kw1Q6KcHvbMz40l8M+3jt5ig0wNNHjmEt+u9cfMJbz8BG X-Received: by 2002:a05:6a21:338a:b0:a5:60d7:fb82 with SMTP id yy10-20020a056a21338a00b000a560d7fb82mr42701838pzb.60.1674649880623; Wed, 25 Jan 2023 04:31:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674649880; cv=none; d=google.com; s=arc-20160816; b=wt5kK8bh2gl8jAm2cZUR7hny8M6F5SqRnotBc72P0NXGhZVm/0dL4c8QUCR6LLu7Yu bOgginO+PMfPbGqpI8rKmRYXPb66dLCSd2g2AH70mr62/A4JpeBZe3ZBPqc/u4kyY8L7 sbkQclQKcPAjRCErnRDQp3Dj0YNhQ1exhIEf2xVhQvAmGTS1NxeMoUELp81y4BAsFdk3 WbS5DGcYUqbL1VrNh/3D8KUdE+kAzI23NaQfy52QTVrEg/JdVWOJ7r2ykJTrTDQcQQF4 vJQXls63t6SjE1qDTTOYmAR2jG+pdzVm0Ien08B1fnJ6ig8R/rbgSNmPRQl6MNNXfWe6 uPDQ== 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=i608LBMINYkmEehTU3J4dbfnC2P2k1Rfhcr4x+E8fcA=; b=qJrVK4tt8F/iGeV+SauVIXRHjifVQjUtmP3R9L4qwn2R68AAxbchQ4COHv8rpIXBA9 dvQ0787vdJtXD4ywFFKVpBmXJzMoACDjFDrW1HoBjvCjoTjQwepT18W/iORmd8JWRkgU YORcqVfGYVMdOVff1LIjO7O8i0v2CXNazPxa7mvY5cY3GCHLmteVk8bRFgIfTUCorxbD GVa1foi+vuqwM79ima0sZ7bwepKn5PjIcHeocQHZz+8JJQ/ZzxHgh/qwVOATqUj6h+Ou 4orEgw+InVW2s6oFClWWLaBDpnaIZoptPbaw/qWvi8s0KUGNVkH15qq8h0aZdZqDMH28 UFVA== 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 n2-20020a638f02000000b004bfe397619asi5028836pgd.795.2023.01.25.04.31.08; Wed, 25 Jan 2023 04:31:20 -0800 (PST) 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 S235466AbjAYMR6 (ORCPT + 99 others); Wed, 25 Jan 2023 07:17:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235268AbjAYMR4 (ORCPT ); Wed, 25 Jan 2023 07:17:56 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CB7E61AE; Wed, 25 Jan 2023 04:17:46 -0800 (PST) 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 6adeaa922a7c58fb; Wed, 25 Jan 2023 13:17:44 +0100 Received: from kreacher.localnet (unknown [213.134.163.149]) (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 94B3022094AA; Wed, 25 Jan 2023 13:17:43 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM , Srinivas Pandruvada Cc: LKML , Zhang Rui , Daniel Lezcano Subject: [PATCH v1] thermal: intel: int340x: Add locking to int340x_thermal_get_trip_type() Date: Wed, 25 Jan 2023 13:17:42 +0100 Message-ID: <2688799.mvXUDI8C0e@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.163.149 X-CLIENT-HOSTNAME: 213.134.163.149 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedruddvvddgfeekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepffffffekgfehheffleetieevfeefvefhleetjedvvdeijeejledvieehueevueffnecukfhppedvudefrddufeegrdduieefrddugeelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudeifedrudegledphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohephedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtgho mhdprhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhg X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755997673402386007?= X-GMAIL-MSGID: =?utf-8?q?1755997673402386007?= From: Rafael J. Wysocki In order to prevent int340x_thermal_get_trip_type() from possibly racing with int340x_thermal_read_trips() invoked by int3403_notify() add locking to it in analogy with int340x_thermal_get_trip_temp(). Fixes: 6757a7abe47b ("thermal: intel: int340x: Protect trip temperature from concurrent updates") Signed-off-by: Rafael J. Wysocki --- On top of the linux-next branch in linux-pm.git from today. --- drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) Index: linux-pm/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c =================================================================== --- linux-pm.orig/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c +++ linux-pm/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c @@ -75,7 +75,9 @@ static int int340x_thermal_get_trip_type enum thermal_trip_type *type) { struct int34x_thermal_zone *d = zone->devdata; - int i; + int i, ret = 0; + + mutex_lock(&d->trip_mutex); if (trip < d->aux_trip_nr) *type = THERMAL_TRIP_PASSIVE; @@ -94,10 +96,12 @@ static int int340x_thermal_get_trip_type } } if (i == INT340X_THERMAL_MAX_ACT_TRIP_COUNT) - return -EINVAL; + ret = -EINVAL; } - return 0; + mutex_unlock(&d->trip_mutex); + + return ret; } static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone,