Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp693907lqp; Thu, 21 Mar 2024 12:35:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWYjmse/bIQxgJ2F4iprqu1bBwgaYOioHtMOwQpsqVtDR8xDW22VZ7yJQN6m8tCR370OAGePap3f/IKYBiGs/N696NfcisqTHeW63h4XQ== X-Google-Smtp-Source: AGHT+IFVi4wpHYsJI3YVE7OGox2GsfDwGaoxqQYY0XjdmaPD3i1y6lI5HlDUw99bC5lU12FFMcX7 X-Received: by 2002:a25:844b:0:b0:dcf:ef13:4cff with SMTP id r11-20020a25844b000000b00dcfef134cffmr168693ybm.16.1711049700002; Thu, 21 Mar 2024 12:35:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711049699; cv=pass; d=google.com; s=arc-20160816; b=yTIEx7Es92pR2Mu7flk6UJUjjtr0UQBHuKnvohKMv+RvjVqxm2sXMTnXvOJeHxMGRE UrsBpWb45k4dZQ6sY3YDo6CHgO4rqNvRciD2bZsX6Dw/n4u8XViuPusbD0FNjjfERU6I zC7ICbTfClNiXreD0BSFu4Q4aI5aGBbNEIBk25s6G5pCTzBu7egjSl2s5+M1XKZBZzcI wvmh/Npt0X2TShYSRVgsMlO4vonYiPtiuq6d9l77bK9on6lqLHkHTq1nSft8TApDZStR dRErgtuwcoBTBr3KvovY7rUuvSdccbnihkf3hJIz7NLSUsU4EWZswj2tYbLlfnJ73xim ufZA== ARC-Message-Signature: i=2; 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:dkim-signature; bh=aG7BVMFY1HyWVnA3I10NgFEuRw1oYBi1HeP7xojogzA=; fh=ioMWnWtowhk3HBvhCOjNmK8xJXWkeaWr8of6U42MhKE=; b=sWIZW1fvCR4ojQNKT3gWg/4XT0aVec83jFjbOFsCwQA+Al0BH+QEPHzx26z8mVyR2X NbFgFW/Qsw9iBXu2KkFniF+35sP5voqGSpSsDvttzlawDeGFqGY4yWpB7uRHGDlmybGp ALzAyb52Z2v4JqNgCfr1k25mhK7Qqs2z+fSKAw4ShnPXwNnHAMNTaMDu8OzOUi21T3Dy tWvuiUHgvraD0BYC2j4p+KTnJzkPBpuIR58PyjnfKSZBqv/CO29P1fDEzRQt5X7ZLk2T ojfFzbx3k+JWDt7z3PlTgH763gN1Y325srBIZltX1EKbXFGSvWYAJFG1GF9ZSk/jRFQZ VRHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=YN19dssV; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-110596-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110596-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h13-20020ac85e0d000000b00430d31a5767si414339qtx.326.2024.03.21.12.34.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 12:34:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110596-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=YN19dssV; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-110596-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110596-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B62CB1C2191F for ; Thu, 21 Mar 2024 19:34:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2238C1350EF; Thu, 21 Mar 2024 19:34:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b="YN19dssV" 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 0F50D134412; Thu, 21 Mar 2024 19:34:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.96.170.134 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711049666; cv=none; b=j4ZLJIlDA6O/d5+u9g3NSIVeiviqqeoldpvaSdRAP4lUnVBXtKarG/t4kUYm17YljK+GMtP+8h1rhMPbZkirXChuu9rYGmAHi8mIvw6o2O9x8aPfA3k6wiiJ86W9tkNt/Jp+TuMsxVIhS+ItntyoNWoRx+jqLT/iG8WEupV3PFk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711049666; c=relaxed/simple; bh=i1usLfR5NyS2UrfhcopXRBbPH/6dK9UVT3GxquuQz0g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GugJK7TEEAE+JVLouompv2tyGOVvq2B84bKNfPjW6hMxqSewlR06UVxnyW/uqGG+QIvc2nSer577+uTYvNKjqVPqASR+EuioUG/53m66zSgkH84E6aJrkmBRX3+POVNZmzphEbSZrUqJtjvnY8LuzeuRss3HREcACePqY2Sdu90= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net; spf=pass smtp.mailfrom=rjwysocki.net; dkim=fail (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b=YN19dssV reason="signature verification failed"; arc=none smtp.client-ip=79.96.170.134 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 9e9f95f3a11f2a70; Thu, 21 Mar 2024 20:34:16 +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 D73B166B8E0; Thu, 21 Mar 2024 20:34:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1711049655; bh=i1usLfR5NyS2UrfhcopXRBbPH/6dK9UVT3GxquuQz0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YN19dssVABiz1hrNArxlVwcB5BiXpiVrzzQiuuF+M0AuK9Qs+QSHhhHkCkBMIuh06 3UY9MapSIWXSTLqdObOA8daYJEJAStGyOmwJ8aKbMZHy5Wlkkt1uQ3MZg/mH7m3JO5 v4JelW4lO99qhon1ZhBEoEcltmMn4+XDFjtDjOUu1mEvE2HD0Rg6JNpgUll1qW6N73 5mPCYuW4neAiIxVCqixoeuCTqEBOyvN+pXyym/PU0VhfUB7ob15ycOl3gOsfRy/SOe k7svObfEBJbqAjZpScV+5f9bjohVrtubMycHJAfcxd5eAu3TgRkiyjNHlp62v7l1fJ sDWN8hrzwlRlA== From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Srinivas Pandruvada Subject: [PATCH v1 3/5] cpufreq: intel_pstate: Wait for canceled delayed work to complete Date: Thu, 21 Mar 2024 20:32:02 +0100 Message-ID: <4885534.GXAFRqVoOG@kreacher> In-Reply-To: <12409658.O9o76ZdvQC@kreacher> References: <12409658.O9o76ZdvQC@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: gggruggvucftvghtrhhoucdtuddrgedvledrleejgdeihecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeefpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepshhrihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=3 Fuz1=3 Fuz2=3 From: Rafael J. Wysocki Make intel_pstate_disable_hwp_interrupt() wait for canceled delayed work to complete to avoid leftover work items running when it returns which may be during driver unregistration and may confuse things going forward. Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/intel_pstate.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) Index: linux-pm/drivers/cpufreq/intel_pstate.c =================================================================== --- linux-pm.orig/drivers/cpufreq/intel_pstate.c +++ linux-pm/drivers/cpufreq/intel_pstate.c @@ -1682,6 +1682,8 @@ ack_intr: static void intel_pstate_disable_hwp_interrupt(struct cpudata *cpudata) { + bool cancel_work; + if (!boot_cpu_has(X86_FEATURE_HWP_NOTIFY)) return; @@ -1689,9 +1691,11 @@ static void intel_pstate_disable_hwp_int wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x00); spin_lock_irq(&hwp_notify_lock); - if (cpumask_test_and_clear_cpu(cpudata->cpu, &hwp_intr_enable_mask)) - cancel_delayed_work(&cpudata->hwp_notify_work); + cancel_work = cpumask_test_and_clear_cpu(cpudata->cpu, &hwp_intr_enable_mask); spin_unlock_irq(&hwp_notify_lock); + + if (cancel_work) + cancel_delayed_work_sync(&cpudata->hwp_notify_work); } static void intel_pstate_enable_hwp_interrupt(struct cpudata *cpudata)