Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp60038rdh; Mon, 18 Dec 2023 11:28:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IFuPcM+4AS2497igto+HPy6JkWUhzQJHoIwmE1DYTYeV4fKkYGO0PeP3mqpHEl3gwkoP0z/ X-Received: by 2002:a17:902:64cf:b0:1d3:b076:5d02 with SMTP id y15-20020a17090264cf00b001d3b0765d02mr1262975pli.53.1702927738930; Mon, 18 Dec 2023 11:28:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702927738; cv=none; d=google.com; s=arc-20160816; b=UlWow4Auy343a1+Si4XUv6+p1kA4BAFx+dVIP0Sn9X+zoIsWhHGbUmI2n5aL6B93fG OhxQcFPae6f/K8bRxwGM1olc6BNy7yHtx5oBJkW6yiIxUiu6cmzkfSBtq3J14XBtHh3z Xcz3P9xtvsTHukyqdZ9CMVtGzooA3PwcPUqRyWEi+K3RyVvvjy9RdykZr7gVoGQhQvQv FgkmwBbDSY+q5+euDX69IaBYt39lutmaIZ8hIAo0morMfriNZbkDn4jv0PXu5WJfbvXm uwUoChYW2hlVsy2RodpYz9XHPY81zEap7WYAWHBC4j7f0gguoUCDxWTwrLxiAyAYBg84 Wxag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=q2eo3vKVbVlmA0j7GP13raKN02rkkhrAg290Mh31Uo8=; fh=2TBTLE+7hwRmsglPVuDIwEDU8ud99AOK8iC3bR96O5I=; b=Fgap77oq0NoayXVGWPD9rkIUo6a5qsGilbpP3oVxYee8v7IgXCXQQjZ0dNN39eDS2u xNpsthhoP4w8erqU/Uq6AqD4G/urvJ943GEYU+m6PE8RdLJS9nhkfBdrrLN1a0XHaoFM 6L3VO1G7dqOhq5hJ9KmITDCWso3IY5dEJS4dSm2KwTYnrzVAk/L5friQVB0kYKWducj3 lezJp9dL53onobazgV5DrxZCB0pem+EypiRxjP8YXHBjXiD4bJJUP85rBjxjvlxEFa1P seXD7asXfTALAU4/tFfIaY3mJt8wGMRpZ0Yu4HK67D1XSGBAsiKfzNdLNNQQTDd86k9x YsQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4295-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4295-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ay9-20020a1709028b8900b001d06b5f9af4si7513471plb.441.2023.12.18.11.28.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 11:28:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4295-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4295-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4295-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6076B285847 for ; Mon, 18 Dec 2023 19:28:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BC4637146C; Mon, 18 Dec 2023 19:28:51 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F09B31E530; Mon, 18 Dec 2023 19:28:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rjwysocki.net 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.4.0) id 418abba5cde14e05; Mon, 18 Dec 2023 20:28:41 +0100 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 cloudserver094114.home.pl (Postfix) with ESMTPSA id 0CE4E668C31; Mon, 18 Dec 2023 20:28:41 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM Cc: Srinivas Pandruvada , Daniel Lezcano , Zhang Rui , LKML , Lukasz Luba , Bo Ye , Radu Solea Subject: [PATCH v1 2/3] thermal: core: Initialize poll_queue in thermal_zone_device_init() Date: Mon, 18 Dec 2023 20:26:47 +0100 Message-ID: <2321768.ElGaqSPkdT@kreacher> In-Reply-To: <5751163.DvuYhMxLoT@kreacher> References: <5751163.DvuYhMxLoT@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtkedguddvfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeekpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepshhrihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomhdprhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgt phhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehluhhkrghsiidrlhhusggrsegrrhhmrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=8 Fuz1=8 Fuz2=8 From: Rafael J. Wysocki In preparation for a subsequent change, move the initialization of the poll_queue delayed work from thermal_zone_device_register_with_trips() to thermal_zone_device_init() which is called by the former. However, because thermal_zone_device_init() is also called by thermal_pm_notify(), make the latter call cancel_delayed_work() on poll_queue before invoking the former, so as to allow the work item to be re-initialized safely. Also move thermal_zone_device_check() which needs to be defined before thermal_zone_device_init(), so the latter can pass it to the INIT_DELAYED_WORK() macro. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/thermal_core.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) Index: linux-pm/drivers/thermal/thermal_core.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_core.c +++ linux-pm/drivers/thermal/thermal_core.c @@ -410,9 +410,20 @@ static void update_temperature(struct th thermal_genl_sampling_temp(tz->id, temp); } +static void thermal_zone_device_check(struct work_struct *work) +{ + struct thermal_zone_device *tz = container_of(work, struct + thermal_zone_device, + poll_queue.work); + thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); +} + static void thermal_zone_device_init(struct thermal_zone_device *tz) { struct thermal_instance *pos; + + INIT_DELAYED_WORK(&tz->poll_queue, thermal_zone_device_check); + tz->temperature = THERMAL_TEMP_INVALID; tz->prev_low_trip = -INT_MAX; tz->prev_high_trip = INT_MAX; @@ -509,14 +520,6 @@ void thermal_zone_device_update(struct t } EXPORT_SYMBOL_GPL(thermal_zone_device_update); -static void thermal_zone_device_check(struct work_struct *work) -{ - struct thermal_zone_device *tz = container_of(work, struct - thermal_zone_device, - poll_queue.work); - thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); -} - int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *), void *data) { @@ -1372,8 +1375,6 @@ thermal_zone_device_register_with_trips( /* Bind cooling devices for this zone */ bind_tz(tz); - INIT_DELAYED_WORK(&tz->poll_queue, thermal_zone_device_check); - thermal_zone_device_init(tz); /* Update the new thermal zone and mark it as already updated. */ if (atomic_cmpxchg(&tz->need_update, 1, 0)) @@ -1556,6 +1557,8 @@ static int thermal_pm_notify(struct noti list_for_each_entry(tz, &thermal_tz_list, node) { mutex_lock(&tz->lock); + cancel_delayed_work(&tz->poll_queue); + tz->suspended = false; thermal_zone_device_init(tz);