Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp694029lqp; Thu, 21 Mar 2024 12:35:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWquWgHdmJHAxdEip7m59XRPRmQj1IBYq9LAVrrP8eWtcrvFHgYG2dKAFPHrZS+/9+AcjriYxb+kJc8+DFrGZ3wt7pvvRl/8W8ZkIhvdg== X-Google-Smtp-Source: AGHT+IFNo4cAZghCEmTdymni6Wffz60To8N6oj9pJwp1VvtlDKZ1YeTZx0xMoxlMBUf6hp7qh0Tx X-Received: by 2002:a05:6a00:21c3:b0:6ea:7e74:b256 with SMTP id t3-20020a056a0021c300b006ea7e74b256mr438215pfj.11.1711049713499; Thu, 21 Mar 2024 12:35:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711049713; cv=pass; d=google.com; s=arc-20160816; b=nFXs3QJvXYyR5ohUeWWPrG0/5Axjq0NoFmhdj+CwqjflyJ/tIaKGc2Pnc55TuBMI1H sT2DWVwEPdmlxEUUMSeDnqMiiBit1YxpXELTg0t/6DhvYuX7xkr6zq121UvuuGvQpe0z hfcRFD6bQpNmNolgtozscsv+GYRTmcy46srMO1+wbZttfxw+hxOIa1ZYa5zZuq8nOwlH ehb2ZQ4e0zXkbmznc6HW6moBspTOJCLLE8MWnhKa6fwhY2bKoNSfh+dR31D8PXsRghmo qSa5fvQ6mjjRdY0m+Pg85JVvMIdTV1dT27+6YjRvqkI+m4moxnuotRUY3oURwS7PEAPm jwfA== 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=6XpHrOuTOgqJMiJ1awlZxVB3xZJBR+N2rbJug0/ZNEs=; fh=ioMWnWtowhk3HBvhCOjNmK8xJXWkeaWr8of6U42MhKE=; b=iU9wXYkGTS3fJTiQ3zKMnCYO2fSz++rD/iQSaTkVu0fb+52LIScUNaDX84qnSkV8mF k1POj7M0MWw4ONU62HXp7kzZboW9adAfcw+j0Cx6uNqIOM7e8KNuK1ZGpZ16OVQtmCXn t0QhkQ3ccjXN0oxMrvfUh4PFy2noo9RHiCnLcNad4LYMiM6CPJPzdo6bBisla+XuHMXS IeQpupJ9ppovyN8ae2hbo4XiYeqkN4dfZOBIvEDu0Docc1vh7YtwIdOQ/S3wXPEb2epi pvbS30tPmgo4HnI0Ku+Tw1TQAf7QZXyxNYwU+bIuZGukt8Saq1FOfgxfzwi5IH5fbt+W cDZw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rjwysocki.net header.s=dkim header.b=JO5qvYAF; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net dkim=pass dkdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-110597-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110597-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g12-20020a63dd4c000000b005dccf9bcaa5si353834pgj.597.2024.03.21.12.35.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 12:35:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110597-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@rjwysocki.net header.s=dkim header.b=JO5qvYAF; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net dkim=pass dkdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-110597-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110597-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 F0855283946 for ; Thu, 21 Mar 2024 19:35:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D11B13540D; Thu, 21 Mar 2024 19:34:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b="JO5qvYAF" 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 EA68213442E; Thu, 21 Mar 2024 19:34:24 +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=1711049667; cv=none; b=pSSu3ht4ktbxmHb3FSnU8lQ+72oO7r5OYh4HT5uAopfaZiQkEwZ0WKwqR8GWyysyyN4LJTkQuwx+oBQJUlx/c8dBgAfgbQEq5kT/uG+VrBNEf/mg6pxx2DMd1CASRgrBtNBseIu1McV6dbPgoT6uAmQh0e/Gf90HOoH+oQrx0Kw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711049667; c=relaxed/simple; bh=8A2wrudJMqa4rJ04LxRBfhEzIL9L2ZJmURvmhuJpY4I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SzMn1izRJ+IwHEcgsXtdCcsNSRpiuew8OheJrn9H56VNkoZZ/Hu6wP00e0TZF2nCeCkbSWSu+O4tuYxBqkv/Z9O1GK+mCd6HNOwdAMVke/eQebtRY8n/BMQ4MXSbTDGHUCgKV/x0bWuuJisDZoY8xhtR19+yPrHo9nWXAEC2eDk= 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=pass (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b=JO5qvYAF; 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 1c1d074a8c5ff484; 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 4A7AB66B8D7; Thu, 21 Mar 2024 20:34:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1711049656; bh=8A2wrudJMqa4rJ04LxRBfhEzIL9L2ZJmURvmhuJpY4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JO5qvYAF0hvkGX48AKJ7qYq27wl8Cp21HWYmmNTRS6Q7hGEnxbCkmLX9ER1TjJ1Ju Y4wKHWHcklINPKby3oy7csjwp9vQDYQaR2Kz6zbK3q1+Vglfg+VrTqlSq9r5VP4Tpz NRkyFS7pwR1Fopps+wIGvqHdGOgfmGStb+Bx9BxEQfVrrR0jMDWPLZsgoodWelMTbO 3wifXplYSUHvQXFx4r7NYFYp1FVAXWtig4jnvjuKM2y7/ruQUxN6FXjJkPrQgZbydw h4Ix4nJOVaJUiZk1+UQ/+0WuyTOFVejv7xlq//crhfp2PC+nmTI998RHXpbZ04N6kq eF/h6WSMeEnYw== From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Srinivas Pandruvada Subject: [PATCH v1 2/5] cpufreq: intel_pstate: Simplify spinlock locking Date: Thu, 21 Mar 2024 20:30:42 +0100 Message-ID: <4561413.LvFx2qVVIh@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 Because intel_pstate_enable/disable_hwp_interrupt() are only called from thread context, they need not save the IRQ flags when using a spinlock as interrupts are guaranteed to be enabled when they run, so make them use spin_lock/unlock_irq(). Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/intel_pstate.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 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,30 +1682,26 @@ ack_intr: static void intel_pstate_disable_hwp_interrupt(struct cpudata *cpudata) { - unsigned long flags; - if (!boot_cpu_has(X86_FEATURE_HWP_NOTIFY)) return; /* wrmsrl_on_cpu has to be outside spinlock as this can result in IPC */ wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x00); - spin_lock_irqsave(&hwp_notify_lock, flags); + 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); - spin_unlock_irqrestore(&hwp_notify_lock, flags); + spin_unlock_irq(&hwp_notify_lock); } static void intel_pstate_enable_hwp_interrupt(struct cpudata *cpudata) { /* Enable HWP notification interrupt for guaranteed performance change */ if (boot_cpu_has(X86_FEATURE_HWP_NOTIFY)) { - unsigned long flags; - - spin_lock_irqsave(&hwp_notify_lock, flags); + spin_lock_irq(&hwp_notify_lock); INIT_DELAYED_WORK(&cpudata->hwp_notify_work, intel_pstate_notify_work); cpumask_set_cpu(cpudata->cpu, &hwp_intr_enable_mask); - spin_unlock_irqrestore(&hwp_notify_lock, flags); + spin_unlock_irq(&hwp_notify_lock); /* wrmsrl_on_cpu has to be outside spinlock as this can result in IPC */ wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x01);