Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp594098rdg; Thu, 10 Aug 2023 12:39:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGHL3OcqvWb9ebptgQEtMa5Tn7Nty2twKQXOq+lX35C8437SwxLhBUN2SLGXjzAUFtegzbV X-Received: by 2002:a17:903:445:b0:1bb:b86e:8d6d with SMTP id iw5-20020a170903044500b001bbb86e8d6dmr2738183plb.29.1691696355009; Thu, 10 Aug 2023 12:39:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691696354; cv=none; d=google.com; s=arc-20160816; b=Ka9uLkBLg+kggzBKruSk2PsWo0Hg7/VbAmMBRpHupJ0ByBs6HhPZwBA1X9f3XYXiMD zZtVA31dIRZV1y6ilmvGYnNwG06nUuTZ3z1B52OzgMbzjsG8RlNSFmGNr9s4bZUzbA3P gaDBFPu+Ly6u6z/N2Fnr4xPpCgjlo+UqrcyFJam7LAVxW3TNnXs2xIcox1khYqtGe07i yNFtAuIT3W1aCaXWqXED+oDulQ8KNjzpjC0cBHFghk8GAvzsVJG+757liC1DJS7kAZFL vjuHZyVDV8ms3KsxM3RzhvoNlHC3Z74K3tb22EzNHf/sSasoRlCkfB95m629gk7vTEIG ut+A== 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=JE+qceskLV8uSBGMVJM6XhYt5LJ6L9wx/CFgJ3Rp27o=; fh=aK1D4KsZYozI75a+KCLuU03FxwQ8tTCKnM2T8GQ5ByU=; b=dNTEfNFfrjg2lGvKiah/KngGfvWr8YECmLr5zPcWfaIIdzJy7m7KW+ZvMM+YU0IoIZ jm0kLwNiom1O9cv/Mq3AuvphLPj09+b+sEe2cg2oh1Dq+Q9QPjX/esyeUnS9BIzFdVJZ vpFqmkh5EwHBoPy/zAGFBnzq7nhS7sP5QiC8m6IK/9qauwTSmSOwQ1XExx+xEJ+jyUM/ GdABzpfHqlIjyYEvWP2js8T15qOyJVTaCbxfcawaGrfQWgo/7FKT8ADHpBtSZzK3+Pdo 6c+CFQ0MNSgF/LH8fxxrGQRporDREGy3bU3RsUx1lwnxsGQ1Cq5RIDsCbjrK97P6jIsX pOhg== 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 z6-20020a170903018600b001b88dbc8b09si1989002plg.454.2023.08.10.12.38.58; Thu, 10 Aug 2023 12:39:14 -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 S236337AbjHJTRy (ORCPT + 99 others); Thu, 10 Aug 2023 15:17:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236312AbjHJTRs (ORCPT ); Thu, 10 Aug 2023 15:17:48 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A9DE271E; Thu, 10 Aug 2023 12:17:48 -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 956638716e953904; Thu, 10 Aug 2023 21:17:46 +0200 Authentication-Results: v370.home.net.pl; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=rjwysocki.net (client-ip=195.136.19.94; helo=[195.136.19.94]; envelope-from=rjw@rjwysocki.net; receiver=) 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 37BD2662742; Thu, 10 Aug 2023 21:17:46 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Srinivas Pandruvada , Zhang Rui , Daniel Lezcano Subject: [PATCH v1 4/7] thermal: intel: intel_soc_dts_iosf: Change initialization ordering Date: Thu, 10 Aug 2023 21:13:25 +0200 Message-ID: <13337847.uLZWGnKmhe@kreacher> In-Reply-To: <5713357.DvuYhMxLoT@kreacher> References: <5713357.DvuYhMxLoT@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: gggruggvucftvghtrhhoucdtuddrgedviedrleeigddufeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohephedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdp rhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhg 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, RCVD_IN_DNSWL_BLOCKED,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 From: Rafael J. Wysocki The initial configuration of trip points in intel_soc_dts_iosf_init() takes place after registering the sensor thermal zones which is potentially problematic, because it may race with the setting of trip point temperatures via sysfs, as there is no synchronization between it and sys_set_trip_temp(). To address this, change the initialization ordering so that the trip points are configured prior to the registration of thermal zones. Accordingly, change the cleanup ordering in intel_soc_dts_iosf_exit() to remove the thermal zones before resetting the trip points. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/intel/intel_soc_dts_iosf.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) Index: linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.c =================================================================== --- linux-pm.orig/drivers/thermal/intel/intel_soc_dts_iosf.c +++ linux-pm/drivers/thermal/intel/intel_soc_dts_iosf.c @@ -398,30 +398,37 @@ struct intel_soc_dts_sensors *intel_soc_ for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { sensors->soc_dts[i].sensors = sensors; - ret = add_dts_thermal_zone(i, &sensors->soc_dts[i], - read_only_trip_count); - if (ret) - goto err_free; - } - for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { ret = configure_trip(&sensors->soc_dts[i], 0, THERMAL_TRIP_PASSIVE, 0); if (ret) - goto err_remove_zone; + goto err_reset_trips; ret = configure_trip(&sensors->soc_dts[i], 1, THERMAL_TRIP_PASSIVE, 0); if (ret) + goto err_reset_trips; + } + + for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { + ret = add_dts_thermal_zone(i, &sensors->soc_dts[i], + read_only_trip_count); + if (ret) goto err_remove_zone; } return sensors; + err_remove_zone: for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) remove_dts_thermal_zone(&sensors->soc_dts[i]); -err_free: +err_reset_trips: + for (i = 0; i < SOC_MAX_DTS_SENSORS; i++) { + configure_trip(&sensors->soc_dts[i], 0, 0, 0); + configure_trip(&sensors->soc_dts[i], 1, 0, 0); + } + kfree(sensors); return ERR_PTR(ret); } @@ -432,9 +439,9 @@ void intel_soc_dts_iosf_exit(struct inte int i; for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { + remove_dts_thermal_zone(&sensors->soc_dts[i]); configure_trip(&sensors->soc_dts[i], 0, 0, 0); configure_trip(&sensors->soc_dts[i], 1, 0, 0); - remove_dts_thermal_zone(&sensors->soc_dts[i]); } kfree(sensors); }