From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 7B128278170 for ; Tue, 29 Apr 2025 06:54:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909700; cv=none; b=rCJT/7zvhN2lRgDI1rfveoOLLWDJ/4nsQV78sGwSuG7rEgUrfpIc9i/6wsZEB2xC5WATcSZezhgB0Yn5BaaE6GGtRPYz0N2UyXE5AGe3IF/k7Rx0TVSyQgDsLhV/Y0i/gIagtUO5jpnc9hm9BpSmQNtKjnB7VLak9q5oL5RqqOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909700; c=relaxed/simple; bh=BWVRW9YA5cTKoCcGVsxNlU8n1clFrzbVU2pWay4GD/k=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=JZoMWDGMr9vbIZlctWHnfzkj7ZQTXqFCMr3/9tulqw3svYuyRxajsVMqFiQB85Edcl++IEtAVS+g1UruZhcRPSnvU/tVf/T0IsZwcmEwFMkwzhdJK92CuorDl+FMMS5HMQVDsn8A0QQoxeUBOLfVcKmhIJlmq4mVSoSh9ljU2pE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=2JWA+rR6; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=vJQo7D06; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="2JWA+rR6"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="vJQo7D06" Message-ID: <20250429065420.061659985@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=8wB5bfUxsIJlccvcP/91E0ttQd1d4YLJbnfb/Vr+Klg=; b=2JWA+rR6h2drRLE6gM2WioHseeMQH6z76rUbb0urwyKCKCXAqEw5i60PgSIB3kov2p/jnm Bwuiw89TR9gznCbjuXNZhOKZJAOxusKSk4R3hDNPlXczge/wyq44x2f5W198EFP/RLgj3k UXZlou2hjnyrFx/PAdmgf9cczgaFA0KsLCrc4TmnkyvAA/LpOcI/r8ZucTEJMlop2FDbVb yDatqQCaq0G+/DFRTN+n0+rFoJeSw9XrJjlcMeTmJ0MzSc9WeXo7RCTyTf7G7qwy7S0cDb xAfMBaB1+EK2Zh84HyWzMM6M/KXM0MnjQdIdlnglR8co72U+tP6hhPDaOB8tMQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=8wB5bfUxsIJlccvcP/91E0ttQd1d4YLJbnfb/Vr+Klg=; b=vJQo7D06i+KPtlm2WvIAiPfPgVXz0jAyK2OXY+GSmu6nxxCubkWaGgIiAwqSr2bBwbSesH mEWawn8Qx0Ut/5Ag== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 01/45] genirq: Provide conditional lock guards References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:54:49 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The interrupt core code has an ever repeating pattern: unsigned long flags; struct irq_desc *desc =3D irq_get_desc_[bus]lock(irq, &flags, mode); if (!desc) return -EINVAL; .... irq_put_desc_[bus]unlock(desc, flags); That requires gotos in failure paths and just creates visual clutter. Provide lock guards, which allow to simplify the code. Signed-off-by: Thomas Gleixner Cc: Jiri Slaby Acked-by: Peter Zijlstra (Intel) --- kernel/irq/internals.h | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h @@ -141,6 +141,10 @@ extern int irq_setup_affinity(struct irq static inline int irq_setup_affinity(struct irq_desc *desc) { return 0; } #endif =20 + +#define for_each_action_of_desc(desc, act) \ + for (act =3D desc->action; act; act =3D act->next) + /* Inline functions for support of irq chips on slow busses */ static inline void chip_bus_lock(struct irq_desc *desc) { @@ -160,14 +164,33 @@ static inline void chip_bus_sync_unlock( #define IRQ_GET_DESC_CHECK_GLOBAL (_IRQ_DESC_CHECK) #define IRQ_GET_DESC_CHECK_PERCPU (_IRQ_DESC_CHECK | _IRQ_DESC_PERCPU) =20 -#define for_each_action_of_desc(desc, act) \ - for (act =3D desc->action; act; act =3D act->next) - -struct irq_desc * -__irq_get_desc_lock(unsigned int irq, unsigned long *flags, bool bus, - unsigned int check); +struct irq_desc *__irq_get_desc_lock(unsigned int irq, unsigned long *flag= s, bool bus, + unsigned int check); void __irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags, boo= l bus); =20 +__DEFINE_CLASS_IS_CONDITIONAL(irqdesc_lock, true); +__DEFINE_UNLOCK_GUARD(irqdesc_lock, struct irq_desc, + __irq_put_desc_unlock(_T->lock, _T->flags, _T->bus), + unsigned long flags; bool bus); + +static inline class_irqdesc_lock_t class_irqdesc_lock_constructor(unsigned= int irq, bool bus, + unsigned int check) +{ + class_irqdesc_lock_t _t =3D { + .bus =3D bus, + .lock =3D __irq_get_desc_lock(irq, &_t.flags, bus, check), + }; + return _t; +} + +#define scoped_irqdesc_get_and_lock(_irq, _check) \ + scoped_guard(irqdesc_lock, _irq, false, _check) + +#define scoped_irqdesc_get_and_buslock(_irq, _check) \ + scoped_guard(irqdesc_lock, _irq, true, _check) + +#define scoped_irqdesc ((struct irq_desc *)(__guard_ptr(irqdesc_lock)(&sc= ope))) + static inline struct irq_desc * irq_get_desc_buslock(unsigned int irq, unsigned long *flags, unsigned int = check) { From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 243561E515 for ; Tue, 29 Apr 2025 06:54:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909695; cv=none; b=ubd+B5Fn/cbN9Bkjrg93B1jV530cuuGhqaPxeUFOmFhQ9hAqOlqhWIWa/Z8o9tAbHEEgY30YJpokyiX2HTmtx6WI9JSfe0IOxx4UEZzTQRUJmrIQ3+dmxvwJucp920uoRTTMO78ffuNAut83FMumFgTF7SIn4dfoALwjmmk3Q20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909695; c=relaxed/simple; bh=AvMfWLvTTNlSaZzhYJRzJ22Y5akNCKwEDl/ms22zTVU=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=XcZ6+n+DJDjbEUlxZMOQLNfZfJ4s/PKXZRzVcppuYrreUorvaHkquwqxW1J/fBVjx2LgUQOZHKiEK5diXtZPAZQM7K8zSfX6Cd4XCjCx+p/1KlIT2hh1k4z01320thVuxLhNDKLv7pbfqj+mDQ3OxjY+A1p4lphM7y2Od/qIpZg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=VeKO/AHP; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=8CthQKMc; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="VeKO/AHP"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="8CthQKMc" Message-ID: <20250429065420.125439431@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909691; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=dzosJNCvmzKIX9RdmCBoR9wrniXmPjUK+yULOxcvuuE=; b=VeKO/AHPNroIZTKJ5iP49KHuGZDccYESayyG87yQrtH0RH76kREPD9E82VFb4Wt4E2QyPE 7xJmWpKVTkAKwocyw34yq0g/e5of6zwqK7ZJbRz6y0+kqO4Rdidmk3bKE3Kj7njU00/bbX L8/UIBe/Jglv5PmDIZN2FFNuPtO1E1Rrusa4aVSE5oxhHbTesPKd4jYIXsFqdcFzjdXcTW rj09ioYHN4IwsIbAEtzAYdKKXMlx9hQ70x4YVuOsT1XqvpaBse2sRsFf3ubVXPiU4rB4Ju RHwYuC1bGdrt7NfQp86fNFUXNr/7E4u08U1e2DRx0gsAkdlFj3nbCUbXeQWkNg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909691; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=dzosJNCvmzKIX9RdmCBoR9wrniXmPjUK+yULOxcvuuE=; b=8CthQKMcLK7Pt9tLeSJfrWQluJfOf2GiwZAEr7PJNCiGoRdq+3iyW5Z2bGS4y62nyrfoJz mXVT6Dui6fU/P2Bg== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 02/45] genirq/irqdesc: Switch to lock guards References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:54:50 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace all lock/unlock pairs with lock guards and simplify the code flow. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/irqdesc.c | 127 +++++++++++++++++-----------------------------= ----- 1 file changed, 43 insertions(+), 84 deletions(-) --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -246,8 +246,7 @@ static struct kobject *irq_kobj_base; #define IRQ_ATTR_RO(_name) \ static struct kobj_attribute _name##_attr =3D __ATTR_RO(_name) =20 -static ssize_t per_cpu_count_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) +static ssize_t per_cpu_count_show(struct kobject *kobj, struct kobj_attrib= ute *attr, char *buf) { struct irq_desc *desc =3D container_of(kobj, struct irq_desc, kobj); ssize_t ret =3D 0; @@ -266,99 +265,75 @@ static ssize_t per_cpu_count_show(struct } IRQ_ATTR_RO(per_cpu_count); =20 -static ssize_t chip_name_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) +static ssize_t chip_name_show(struct kobject *kobj, struct kobj_attribute = *attr, char *buf) { struct irq_desc *desc =3D container_of(kobj, struct irq_desc, kobj); - ssize_t ret =3D 0; =20 - raw_spin_lock_irq(&desc->lock); + guard(raw_spinlock_irq)(&desc->lock); if (desc->irq_data.chip && desc->irq_data.chip->name) - ret =3D sysfs_emit(buf, "%s\n", desc->irq_data.chip->name); - raw_spin_unlock_irq(&desc->lock); - - return ret; + return sysfs_emit(buf, "%s\n", desc->irq_data.chip->name); + return 0; } IRQ_ATTR_RO(chip_name); =20 -static ssize_t hwirq_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) +static ssize_t hwirq_show(struct kobject *kobj, struct kobj_attribute *att= r, char *buf) { struct irq_desc *desc =3D container_of(kobj, struct irq_desc, kobj); - ssize_t ret =3D 0; =20 + guard(raw_spinlock_irq)(&desc->lock); raw_spin_lock_irq(&desc->lock); if (desc->irq_data.domain) - ret =3D sysfs_emit(buf, "%lu\n", desc->irq_data.hwirq); - raw_spin_unlock_irq(&desc->lock); - - return ret; + return sysfs_emit(buf, "%lu\n", desc->irq_data.hwirq); + return 0; } IRQ_ATTR_RO(hwirq); =20 -static ssize_t type_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) +static ssize_t type_show(struct kobject *kobj, struct kobj_attribute *attr= , char *buf) { struct irq_desc *desc =3D container_of(kobj, struct irq_desc, kobj); - ssize_t ret =3D 0; - - raw_spin_lock_irq(&desc->lock); - ret =3D sysfs_emit(buf, "%s\n", irqd_is_level_type(&desc->irq_data) ? "le= vel" : "edge"); - raw_spin_unlock_irq(&desc->lock); =20 - return ret; + guard(raw_spinlock_irq)(&desc->lock); + return sysfs_emit(buf, "%s\n", irqd_is_level_type(&desc->irq_data) ? "lev= el" : "edge"); =20 } IRQ_ATTR_RO(type); =20 -static ssize_t wakeup_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) +static ssize_t wakeup_show(struct kobject *kobj, struct kobj_attribute *at= tr, char *buf) { struct irq_desc *desc =3D container_of(kobj, struct irq_desc, kobj); - ssize_t ret =3D 0; - - raw_spin_lock_irq(&desc->lock); - ret =3D sysfs_emit(buf, "%s\n", str_enabled_disabled(irqd_is_wakeup_set(&= desc->irq_data))); - raw_spin_unlock_irq(&desc->lock); - - return ret; =20 + guard(raw_spinlock_irq)(&desc->lock); + return sysfs_emit(buf, "%s\n", str_enabled_disabled(irqd_is_wakeup_set(&d= esc->irq_data))); } IRQ_ATTR_RO(wakeup); =20 -static ssize_t name_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) +static ssize_t name_show(struct kobject *kobj, struct kobj_attribute *attr= , char *buf) { struct irq_desc *desc =3D container_of(kobj, struct irq_desc, kobj); - ssize_t ret =3D 0; =20 - raw_spin_lock_irq(&desc->lock); + guard(raw_spinlock_irq)(&desc->lock); if (desc->name) - ret =3D sysfs_emit(buf, "%s\n", desc->name); - raw_spin_unlock_irq(&desc->lock); - - return ret; + return sysfs_emit(buf, "%s\n", desc->name); + return 0; } IRQ_ATTR_RO(name); =20 -static ssize_t actions_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) +static ssize_t actions_show(struct kobject *kobj, struct kobj_attribute *a= ttr, char *buf) { struct irq_desc *desc =3D container_of(kobj, struct irq_desc, kobj); struct irqaction *action; ssize_t ret =3D 0; char *p =3D ""; =20 - raw_spin_lock_irq(&desc->lock); - for_each_action_of_desc(desc, action) { - ret +=3D sysfs_emit_at(buf, ret, "%s%s", p, action->name); - p =3D ","; + scoped_guard(raw_spinlock_irq, &desc->lock) { + for_each_action_of_desc(desc, action) { + ret +=3D sysfs_emit_at(buf, ret, "%s%s", p, action->name); + p =3D ","; + } } - raw_spin_unlock_irq(&desc->lock); =20 if (ret) ret +=3D sysfs_emit_at(buf, ret, "\n"); - return ret; } IRQ_ATTR_RO(actions); @@ -414,19 +389,14 @@ static int __init irq_sysfs_init(void) int irq; =20 /* Prevent concurrent irq alloc/free */ - irq_lock_sparse(); - + guard(mutex)(&sparse_irq_lock); irq_kobj_base =3D kobject_create_and_add("irq", kernel_kobj); - if (!irq_kobj_base) { - irq_unlock_sparse(); + if (!irq_kobj_base) return -ENOMEM; - } =20 /* Add the already allocated interrupts */ for_each_irq_desc(irq, desc) irq_sysfs_add(irq, desc); - irq_unlock_sparse(); - return 0; } postcore_initcall(irq_sysfs_init); @@ -569,12 +539,12 @@ static int alloc_descs(unsigned int star return -ENOMEM; } =20 -static int irq_expand_nr_irqs(unsigned int nr) +static bool irq_expand_nr_irqs(unsigned int nr) { if (nr > MAX_SPARSE_IRQS) - return -ENOMEM; + return false; nr_irqs =3D nr; - return 0; + return true; } =20 int __init early_irq_init(void) @@ -652,11 +622,9 @@ EXPORT_SYMBOL(irq_to_desc); static void free_desc(unsigned int irq) { struct irq_desc *desc =3D irq_to_desc(irq); - unsigned long flags; =20 - raw_spin_lock_irqsave(&desc->lock, flags); - desc_set_defaults(irq, desc, irq_desc_get_node(desc), NULL, NULL); - raw_spin_unlock_irqrestore(&desc->lock, flags); + scoped_guard(raw_spinlock_irqsave, &desc->lock) + desc_set_defaults(irq, desc, irq_desc_get_node(desc), NULL, NULL); delete_irq_desc(irq); } =20 @@ -677,14 +645,13 @@ static inline int alloc_descs(unsigned i =20 static int irq_expand_nr_irqs(unsigned int nr) { - return -ENOMEM; + return false; } =20 void irq_mark_irq(unsigned int irq) { - mutex_lock(&sparse_irq_lock); + guard(mutex)(&sparse_irq_lock); irq_insert_desc(irq, irq_desc + irq); - mutex_unlock(&sparse_irq_lock); } =20 #ifdef CONFIG_GENERIC_IRQ_LEGACY @@ -823,11 +790,9 @@ void irq_free_descs(unsigned int from, u if (from >=3D nr_irqs || (from + cnt) > nr_irqs) return; =20 - mutex_lock(&sparse_irq_lock); + guard(mutex)(&sparse_irq_lock); for (i =3D 0; i < cnt; i++) free_desc(from + i); - - mutex_unlock(&sparse_irq_lock); } EXPORT_SYMBOL_GPL(irq_free_descs); =20 @@ -844,11 +809,10 @@ EXPORT_SYMBOL_GPL(irq_free_descs); * * Returns the first irq number or error code */ -int __ref -__irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node, - struct module *owner, const struct irq_affinity_desc *affinity) +int __ref __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, = int node, + struct module *owner, const struct irq_affinity_desc *affinity) { - int start, ret; + int start; =20 if (!cnt) return -EINVAL; @@ -866,22 +830,17 @@ int __ref from =3D arch_dynirq_lower_bound(from); } =20 - mutex_lock(&sparse_irq_lock); + guard(mutex)(&sparse_irq_lock); =20 start =3D irq_find_free_area(from, cnt); - ret =3D -EEXIST; if (irq >=3D0 && start !=3D irq) - goto unlock; + return -EEXIST; =20 if (start + cnt > nr_irqs) { - ret =3D irq_expand_nr_irqs(start + cnt); - if (ret) - goto unlock; + if (!irq_expand_nr_irqs(start + cnt)) + return -ENOMEM; } - ret =3D alloc_descs(start, cnt, node, affinity, owner); -unlock: - mutex_unlock(&sparse_irq_lock); - return ret; + return alloc_descs(start, cnt, node, affinity, owner); } EXPORT_SYMBOL_GPL(__irq_alloc_descs); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 09223275844 for ; Tue, 29 Apr 2025 06:54:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909696; cv=none; b=JN6H8UbqtNbyzEz/UrD1zOnwpJ0aAZZGUorP8K2RvfGrzmCweS1KRh2+/QGl+J0YW6kzeCjATDBXEWwtdWkKZiAEpYpfYk/ifKZBnPNtAmFOzizqiQm6N0Ac37C4gny4SYOzlEonM7oBFOBohOE2ZmVwHohhPBrMZgGnWloXw1c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909696; c=relaxed/simple; bh=R6Oe7khnWkwcjhwjQWXM9/cUpFiONrmk2BxBrz0nO2g=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Zvvy5irVKwVSASCILntGIPbN+BfiYTrs79EwCNTKY/y1MdV6RIfRK6zf+rBv+LM6CkY4MEUZ6oAL4L9MJ9u/dHvs8A26s6jR0NIEqKxzqsEHBR6ufpAHy940esl6MlEIiFxqVJ4l1ph106HQRK8LlyD+iaqHuGT2/ZsEXQgmJf4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=w47YubRX; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=RGDynBWn; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="w47YubRX"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="RGDynBWn" Message-ID: <20250429065420.188866381@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909692; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=8Lrnr7Wjtl13Tnh7B/iTi/GvYg4WRlxJArWA8pN4YdQ=; b=w47YubRXI9t84t5CuVRZWKRf35gec+rHKEZ5RF24DKc7+eCXdupuvx+Ebblfoxl9bHKx8h G50PCJXyX6s0ddun1PHVSFfAzLn5UWlfcusS1hD+xf1UumZYK8AjYSFJVvlzZCBBJfVoxM +MfM4OBYVDBMI2ituE7a+W87DpP9K+ix1yqXvN2W79HVuj4zUZetqDdpTO/MiIs/3ESOdJ dQhyPv8c4n6cJmCLmzsOv4TzyDsjc8bAPVbRvN5Ey2Fm2ZSd/EpWTTjPHUQJNDAdTvg1n4 EGBotDcS2WlbuSucv7T6vc+7oiif6FTCzHfgIWihw0V1QBU6gT2Z1BNouQeIsA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909692; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=8Lrnr7Wjtl13Tnh7B/iTi/GvYg4WRlxJArWA8pN4YdQ=; b=RGDynBWn4nFT2TMA+6tvl5xqFV2LwPBPGaH+w8OOmtpVGV21L2hrlQaJoPhP7VXlSod9Zh zmfPPNQY2RgVWeAQ== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 03/45] genirq/autoprobe: Switch to lock guards References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:54:52 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert all lock/unlock pairs to guards. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/autoprobe.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) --- a/kernel/irq/autoprobe.c +++ b/kernel/irq/autoprobe.c @@ -43,18 +43,16 @@ unsigned long probe_irq_on(void) * flush such a longstanding irq before considering it as spurious. */ for_each_irq_desc_reverse(i, desc) { - raw_spin_lock_irq(&desc->lock); + guard(raw_spinlock_irq)(&desc->lock); if (!desc->action && irq_settings_can_probe(desc)) { /* * Some chips need to know about probing in * progress: */ if (desc->irq_data.chip->irq_set_type) - desc->irq_data.chip->irq_set_type(&desc->irq_data, - IRQ_TYPE_PROBE); + desc->irq_data.chip->irq_set_type(&desc->irq_data, IRQ_TYPE_PROBE); irq_activate_and_startup(desc, IRQ_NORESEND); } - raw_spin_unlock_irq(&desc->lock); } =20 /* Wait for longstanding interrupts to trigger. */ @@ -66,13 +64,12 @@ unsigned long probe_irq_on(void) * happened in the previous stage, it may have masked itself) */ for_each_irq_desc_reverse(i, desc) { - raw_spin_lock_irq(&desc->lock); + guard(raw_spinlock_irq)(&desc->lock); if (!desc->action && irq_settings_can_probe(desc)) { desc->istate |=3D IRQS_AUTODETECT | IRQS_WAITING; if (irq_activate_and_startup(desc, IRQ_NORESEND)) desc->istate |=3D IRQS_PENDING; } - raw_spin_unlock_irq(&desc->lock); } =20 /* @@ -84,18 +81,16 @@ unsigned long probe_irq_on(void) * Now filter out any obviously spurious interrupts */ for_each_irq_desc(i, desc) { - raw_spin_lock_irq(&desc->lock); - + guard(raw_spinlock_irq)(&desc->lock); if (desc->istate & IRQS_AUTODETECT) { /* It triggered already - consider it spurious. */ if (!(desc->istate & IRQS_WAITING)) { desc->istate &=3D ~IRQS_AUTODETECT; irq_shutdown_and_deactivate(desc); - } else - if (i < 32) - mask |=3D 1 << i; + } else if (i < 32) { + mask |=3D 1 << i; + } } - raw_spin_unlock_irq(&desc->lock); } =20 return mask; @@ -121,7 +116,7 @@ unsigned int probe_irq_mask(unsigned lon int i; =20 for_each_irq_desc(i, desc) { - raw_spin_lock_irq(&desc->lock); + guard(raw_spinlock_irq)(&desc->lock); if (desc->istate & IRQS_AUTODETECT) { if (i < 16 && !(desc->istate & IRQS_WAITING)) mask |=3D 1 << i; @@ -129,7 +124,6 @@ unsigned int probe_irq_mask(unsigned lon desc->istate &=3D ~IRQS_AUTODETECT; irq_shutdown_and_deactivate(desc); } - raw_spin_unlock_irq(&desc->lock); } mutex_unlock(&probing_active); =20 @@ -160,8 +154,7 @@ int probe_irq_off(unsigned long val) struct irq_desc *desc; =20 for_each_irq_desc(i, desc) { - raw_spin_lock_irq(&desc->lock); - + guard(raw_spinlock_irq)(&desc->lock); if (desc->istate & IRQS_AUTODETECT) { if (!(desc->istate & IRQS_WAITING)) { if (!nr_of_irqs) @@ -171,7 +164,6 @@ int probe_irq_off(unsigned long val) desc->istate &=3D ~IRQS_AUTODETECT; irq_shutdown_and_deactivate(desc); } - raw_spin_unlock_irq(&desc->lock); } mutex_unlock(&probing_active); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 168B9277002 for ; Tue, 29 Apr 2025 06:54:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909697; cv=none; b=CqWf07poQS9bIeSdvTMjIx9b7HOFOzLjuKnIxdxnAh7MUA3UvuhKpa+JiRIpNQcuA/MHSrfbQlPQLPGoMHKSob16ZZgM1mh6QwlUcnF6+2+9SF0lZcxOd3emdpvJXfY0dpljniCqGxKFCQXZCJzu3e7P2mUUNz/40sJdyywEoY0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909697; c=relaxed/simple; bh=5e8N7AhvOi0OtytDRRtSyTsFfv+PPBlDCnk0DxMSIbE=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=gyheihQ2EJJFP6RzX7CA0IOHGeopqVHd/auNcJOYcSS8KVjFX2cwr1ZkOdpW75hXQivNO+SBwn4nQiQ33z7RkCww7sZV+5BLtECC6SnlfPvQTrPl0BvPf4lhhu0fzOP33kMkGQh6MdbmtYXnxyGCIvvo5JjPLTmXFXpHahj9krI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=2WAx6HTO; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=qwsB585x; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="2WAx6HTO"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="qwsB585x" Message-ID: <20250429065420.251299112@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=dzug9PSb1hRGMbAMs5O0DoRZ9PXFq2b5flFpCdZwkw4=; b=2WAx6HTOgvruBzHCLLPo267oIajhucSXyc9iahp7kcMNZVwSQnR8pVIukjtNbYRnBMd4GX QByhiF+hNeyif0oY1qmKxScWZgVHbtjIzXInIYGBYxCxUerqLEdbCj0nz6upknA1NQpDZq PLeokLOUdOHMhxroah3UBjCLq2w5OpJY5CszN/Gu4mjELHcQOtGZgeYYwZgmKPjbKwIfu+ RfDUbHNMTSIR/RKjlHLARnE9eqbIwkWAQRCn9rfK2sQFGbWfFWXG9TuOWjfehXJn9ey8nQ lE0s1dAKtQC/pnyy5LLlypTQcsIMzwM3+Ojy9uZB/XBk5JVJ4eiaOKC5pzgMOA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=dzug9PSb1hRGMbAMs5O0DoRZ9PXFq2b5flFpCdZwkw4=; b=qwsB585xxlLceRAtnhT4OtwZjlzlptdcdCYMh5MVzHmnKKbygcJdAOM2IQVZNAo13mSY2I I+ViehBUfmuUp8DA== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 04/45] genirq/pm: Switch to lock guards References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:54:53 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert all lock/unlock pairs to guards and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/pm.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) --- a/kernel/irq/pm.c +++ b/kernel/irq/pm.c @@ -46,8 +46,7 @@ void irq_pm_install_action(struct irq_de desc->cond_suspend_depth++; =20 WARN_ON_ONCE(desc->no_suspend_depth && - (desc->no_suspend_depth + - desc->cond_suspend_depth) !=3D desc->nr_actions); + (desc->no_suspend_depth + desc->cond_suspend_depth) !=3D desc->nr_a= ctions); } =20 /* @@ -134,14 +133,12 @@ void suspend_device_irqs(void) int irq; =20 for_each_irq_desc(irq, desc) { - unsigned long flags; bool sync; =20 if (irq_settings_is_nested_thread(desc)) continue; - raw_spin_lock_irqsave(&desc->lock, flags); - sync =3D suspend_device_irq(desc); - raw_spin_unlock_irqrestore(&desc->lock, flags); + scoped_guard(raw_spinlock_irqsave, &desc->lock) + sync =3D suspend_device_irq(desc); =20 if (sync) synchronize_irq(irq); @@ -186,18 +183,15 @@ static void resume_irqs(bool want_early) int irq; =20 for_each_irq_desc(irq, desc) { - unsigned long flags; - bool is_early =3D desc->action && - desc->action->flags & IRQF_EARLY_RESUME; + bool is_early =3D desc->action && desc->action->flags & IRQF_EARLY_RESUM= E; =20 if (!is_early && want_early) continue; if (irq_settings_is_nested_thread(desc)) continue; =20 - raw_spin_lock_irqsave(&desc->lock, flags); + guard(raw_spinlock_irqsave)(&desc->lock); resume_irq(desc); - raw_spin_unlock_irqrestore(&desc->lock, flags); } } =20 @@ -207,22 +201,16 @@ static void resume_irqs(bool want_early) */ void rearm_wake_irq(unsigned int irq) { - unsigned long flags; - struct irq_desc *desc =3D irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_= CHECK_GLOBAL); + scoped_irqdesc_get_and_buslock(irq, IRQ_GET_DESC_CHECK_GLOBAL) { + struct irq_desc *desc =3D scoped_irqdesc; =20 - if (!desc) - return; - - if (!(desc->istate & IRQS_SUSPENDED) || - !irqd_is_wakeup_set(&desc->irq_data)) - goto unlock; - - desc->istate &=3D ~IRQS_SUSPENDED; - irqd_set(&desc->irq_data, IRQD_WAKEUP_ARMED); - __enable_irq(desc); + if (!(desc->istate & IRQS_SUSPENDED) || !irqd_is_wakeup_set(&desc->irq_d= ata)) + return; =20 -unlock: - irq_put_desc_busunlock(desc, flags); + desc->istate &=3D ~IRQS_SUSPENDED; + irqd_set(&desc->irq_data, IRQD_WAKEUP_ARMED); + __enable_irq(desc); + } } =20 /** From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 780C12777E4 for ; Tue, 29 Apr 2025 06:54:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909699; cv=none; b=EataXbtZLwu4AiQVbzUC6Ygq7dBI1IdmyQhrLnN9qqHWZ1Osaik5pW3fkXt/FbPUYLiZJ36IYTdwKMEoBufwgEJVJclF/3H4R2sYwdEeZRkBCGFYBiFQJEoOUEIV3RCcDe/oEyREFD29vEVnnCScttsJ4x0bsHYbEAngQTIW6gA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909699; c=relaxed/simple; bh=8cOz+mxhqrNemsJxNIB2y98DSQNypLkLtwrZ6EtsqtQ=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Eo6u9hdmyCXckFQf6iIivxpcm1xMy7Eus+87rJko7j50ijZWvVEpFS9VDr/yX2W7Q2Eowt80r4MRIITTbZbC1cx+dqqDLkE5h3aJS/eKSLTSY/cUgUy63eB5tZ9jXDjvHDQLNLNt9pgkcJ4K3jO3tRcOm0823OnGmvLIfCqBuME= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=BR13VEf4; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=C0ipgEmM; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="BR13VEf4"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="C0ipgEmM" Message-ID: <20250429065420.312487167@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909695; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=B+/JBq3ESzVGFoGKqyWN21BcIWknHhWUvKsJOEZWk7c=; b=BR13VEf4Mvl9LZ12oZOsvbtj8l7fl+gQPPJB76/AVpxKdsZC99cf2IaLuh8VyZxxyg06mz 85ZNEzM4hx8RYlLkGatEhrJCJQhA+vb7HYkKvtqvILRi5T721Vv1LKkhv3PpOfKSB00Rph f8WhLN9KWsse25JNIxEkZSVGLEWf1eCAk9lhPv8WDrcZiTo1s8rXl+whlnBFFRD/vAQ+W4 1d/0XD4CksdM/i9j8DGr2E2ZnRA35QMIXSOYlZ0/dxcBdBv+2cXvYCwIsjch4fEBeDl1vr OpEqQVkDkW1pBZS+PkEpV+mbh1sK69BBUO7ZweGCzxO5EaWHWvBZvNTiFaskoA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909695; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=B+/JBq3ESzVGFoGKqyWN21BcIWknHhWUvKsJOEZWk7c=; b=C0ipgEmMz5hGMb6E6FaAVkd6utJwzvv/LXKwYIjhEonyIhbZjrhhXY4jc1Z0cwUGLakjUC qcKuVZl0bEKoZmCg== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 05/45] genirq/resend: Switch to lock guards References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:54:55 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert all lock/unlock pairs to guards and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/resend.c | 50 +++++++++++++++++++++--------------------------= --- 1 file changed, 21 insertions(+), 29 deletions(-) --- a/kernel/irq/resend.c +++ b/kernel/irq/resend.c @@ -30,18 +30,17 @@ static DEFINE_RAW_SPINLOCK(irq_resend_lo */ static void resend_irqs(struct tasklet_struct *unused) { - struct irq_desc *desc; - - raw_spin_lock_irq(&irq_resend_lock); + guard(raw_spinlock_irq)(&irq_resend_lock); while (!hlist_empty(&irq_resend_list)) { - desc =3D hlist_entry(irq_resend_list.first, struct irq_desc, - resend_node); + struct irq_desc *desc; + + desc =3D hlist_entry(irq_resend_list.first, struct irq_desc, resend_nod= e); hlist_del_init(&desc->resend_node); + raw_spin_unlock(&irq_resend_lock); desc->handle_irq(desc); raw_spin_lock(&irq_resend_lock); } - raw_spin_unlock_irq(&irq_resend_lock); } =20 /* Tasklet to handle resend: */ @@ -75,19 +74,18 @@ static int irq_sw_resend(struct irq_desc } =20 /* Add to resend_list and activate the softirq: */ - raw_spin_lock(&irq_resend_lock); - if (hlist_unhashed(&desc->resend_node)) - hlist_add_head(&desc->resend_node, &irq_resend_list); - raw_spin_unlock(&irq_resend_lock); + scoped_guard(raw_spinlock, &irq_resend_lock) { + if (hlist_unhashed(&desc->resend_node)) + hlist_add_head(&desc->resend_node, &irq_resend_list); + } tasklet_schedule(&resend_tasklet); return 0; } =20 void clear_irq_resend(struct irq_desc *desc) { - raw_spin_lock(&irq_resend_lock); + guard(raw_spinlock)(&irq_resend_lock); hlist_del_init(&desc->resend_node); - raw_spin_unlock(&irq_resend_lock); } =20 void irq_resend_init(struct irq_desc *desc) @@ -172,30 +170,24 @@ int check_irq_resend(struct irq_desc *de */ int irq_inject_interrupt(unsigned int irq) { - struct irq_desc *desc; - unsigned long flags; - int err; + int err =3D -EINVAL; =20 /* Try the state injection hardware interface first */ if (!irq_set_irqchip_state(irq, IRQCHIP_STATE_PENDING, true)) return 0; =20 /* That failed, try via the resend mechanism */ - desc =3D irq_get_desc_buslock(irq, &flags, 0); - if (!desc) - return -EINVAL; + scoped_irqdesc_get_and_buslock(irq, 0) { + struct irq_desc *desc =3D scoped_irqdesc; =20 - /* - * Only try to inject when the interrupt is: - * - not NMI type - * - activated - */ - if (irq_is_nmi(desc) || !irqd_is_activated(&desc->irq_data)) - err =3D -EINVAL; - else - err =3D check_irq_resend(desc, true); - - irq_put_desc_busunlock(desc, flags); + /* + * Only try to inject when the interrupt is: + * - not NMI type + * - activated + */ + if (!irq_is_nmi(desc) && irqd_is_activated(&desc->irq_data)) + err =3D check_irq_resend(desc, true); + } return err; } EXPORT_SYMBOL_GPL(irq_inject_interrupt); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 278A41E515 for ; Tue, 29 Apr 2025 06:54:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909701; cv=none; b=q9cH5fpTWii9zKNveRFUB14BBolA7CUU2rxacM25/qzlsDxot9u9H8GWd7yR6yMp2OM1VbRZWeM2GFMlLqBs5zbIYVFljovx9hwca6ebXw5jpsyt71ddolEVNHCizV2nyE/Mv9lOeQLRDtFShFQ3IU8hhWFQHIDJ5nzW+fcLYqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909701; c=relaxed/simple; bh=p83oHxttfdm0y+u5gX77fDL5atQ/kVFM8a5AB9t5GRY=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Q/KELKuLpFrjBw5M+OAD2Btcz6rPYwL3Ds8A0KqaSpBvvwXJCQIKhnJ1p1XiSsZpqaowCgcJ6BvgO8XWht5LskN3YAvw3zc9qx4fqvl7O2OFGpLiPGF2LdbkYLA2h0RWmZfF5UXBoi58J2QU0p2TxQQXQH0yAxTNZPBCXnBI5f8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=vBNmukrA; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Ps5vujrM; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="vBNmukrA"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Ps5vujrM" Message-ID: <20250429065420.373998838@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=QWjg99Fn1vizO7Nd6kXsxIDLfeT41JKoGSwCBQRcpL0=; b=vBNmukrAqaK06OdFINBr9e6huVENz4qtzvWMJuwegJGxwfj0do10QV7zYhYs3oGABz3AFO 8452U+bdYaIVyFPWuj4EjmRIG6g7RLbxjv37idnWYzfSahFFRaLIGS5YbBXXMEyS3FalAi v52liM6uCW9U7XgCwjaRfJ/1Uko14hNPu7H/Iy50xbS7jUleS/OE1e05FBxsEu7c4V8+QA RsPwgBHPNqXfOHxx1Il3uhvwl5TbEZEFe0NdBjmwJlLINnWJrWcUYIJB0O7sJFdiUDEkLW wetsgLrvmXnbCXMRNEs6tOC4FDSrovBmxm58UycpK4YnAy/zk2GFETYO4CxGTg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=QWjg99Fn1vizO7Nd6kXsxIDLfeT41JKoGSwCBQRcpL0=; b=Ps5vujrMWu6U44wQfK2NIEcWP4nNybkYCXSl5BWaGf7DCiZDIhE+H+aDcMP0Z9bwVjAwBi vv4IQ/iKGHXpqjCw== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 06/45] genirq/proc: Switch to lock guards References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:54:56 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert all lock/unlock pairs to guards and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/proc.c | 65 +++++++++++++++++++------------------------------= ----- 1 file changed, 24 insertions(+), 41 deletions(-) --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c @@ -81,20 +81,18 @@ static int show_irq_affinity(int type, s static int irq_affinity_hint_proc_show(struct seq_file *m, void *v) { struct irq_desc *desc =3D irq_to_desc((long)m->private); - unsigned long flags; cpumask_var_t mask; =20 if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) return -ENOMEM; =20 - raw_spin_lock_irqsave(&desc->lock, flags); - if (desc->affinity_hint) - cpumask_copy(mask, desc->affinity_hint); - raw_spin_unlock_irqrestore(&desc->lock, flags); + scoped_guard(raw_spinlock_irq, &desc->lock) { + if (desc->affinity_hint) + cpumask_copy(mask, desc->affinity_hint); + } =20 seq_printf(m, "%*pb\n", cpumask_pr_args(mask)); free_cpumask_var(mask); - return 0; } =20 @@ -295,23 +293,18 @@ static int irq_spurious_proc_show(struct =20 #define MAX_NAMELEN 128 =20 -static int name_unique(unsigned int irq, struct irqaction *new_action) +static bool name_unique(unsigned int irq, struct irqaction *new_action) { struct irq_desc *desc =3D irq_to_desc(irq); struct irqaction *action; - unsigned long flags; - int ret =3D 1; =20 - raw_spin_lock_irqsave(&desc->lock, flags); + guard(raw_spinlock_irq)(&desc->lock); for_each_action_of_desc(desc, action) { if ((action !=3D new_action) && action->name && - !strcmp(new_action->name, action->name)) { - ret =3D 0; - break; - } + !strcmp(new_action->name, action->name)) + return false; } - raw_spin_unlock_irqrestore(&desc->lock, flags); - return ret; + return true; } =20 void register_handler_proc(unsigned int irq, struct irqaction *action) @@ -319,8 +312,7 @@ void register_handler_proc(unsigned int char name [MAX_NAMELEN]; struct irq_desc *desc =3D irq_to_desc(irq); =20 - if (!desc->dir || action->dir || !action->name || - !name_unique(irq, action)) + if (!desc->dir || action->dir || !action->name || !name_unique(irq, actio= n)) return; =20 snprintf(name, MAX_NAMELEN, "%s", action->name); @@ -347,17 +339,16 @@ void register_irq_proc(unsigned int irq, * added, not when the descriptor is created, so multiple * tasks might try to register at the same time. */ - mutex_lock(®ister_lock); + guard(mutex)(®ister_lock); =20 if (desc->dir) - goto out_unlock; - - sprintf(name, "%d", irq); + return; =20 /* create /proc/irq/1234 */ + sprintf(name, "%d", irq); desc->dir =3D proc_mkdir(name, root_irq_dir); if (!desc->dir) - goto out_unlock; + return; =20 #ifdef CONFIG_SMP umode_t umode =3D S_IRUGO; @@ -366,31 +357,27 @@ void register_irq_proc(unsigned int irq, umode |=3D S_IWUSR; =20 /* create /proc/irq//smp_affinity */ - proc_create_data("smp_affinity", umode, desc->dir, - &irq_affinity_proc_ops, irqp); + proc_create_data("smp_affinity", umode, desc->dir, &irq_affinity_proc_ops= , irqp); =20 /* create /proc/irq//affinity_hint */ proc_create_single_data("affinity_hint", 0444, desc->dir, - irq_affinity_hint_proc_show, irqp); + irq_affinity_hint_proc_show, irqp); =20 /* create /proc/irq//smp_affinity_list */ proc_create_data("smp_affinity_list", umode, desc->dir, &irq_affinity_list_proc_ops, irqp); =20 - proc_create_single_data("node", 0444, desc->dir, irq_node_proc_show, - irqp); + proc_create_single_data("node", 0444, desc->dir, irq_node_proc_show, irqp= ); # ifdef CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK proc_create_single_data("effective_affinity", 0444, desc->dir, - irq_effective_aff_proc_show, irqp); + irq_effective_aff_proc_show, irqp); proc_create_single_data("effective_affinity_list", 0444, desc->dir, - irq_effective_aff_list_proc_show, irqp); + irq_effective_aff_list_proc_show, irqp); # endif #endif proc_create_single_data("spurious", 0444, desc->dir, - irq_spurious_proc_show, (void *)(long)irq); + irq_spurious_proc_show, (void *)(long)irq); =20 -out_unlock: - mutex_unlock(®ister_lock); } =20 void unregister_irq_proc(unsigned int irq, struct irq_desc *desc) @@ -468,7 +455,6 @@ int show_interrupts(struct seq_file *p, int i =3D *(loff_t *) v, j; struct irqaction *action; struct irq_desc *desc; - unsigned long flags; =20 if (i > ACTUAL_NR_IRQS) return 0; @@ -487,13 +473,13 @@ int show_interrupts(struct seq_file *p, seq_putc(p, '\n'); } =20 - rcu_read_lock(); + guard(rcu)(); desc =3D irq_to_desc(i); if (!desc || irq_settings_is_hidden(desc)) - goto outsparse; + return 0; =20 if (!desc->action || irq_desc_is_chained(desc) || !desc->kstat_irqs) - goto outsparse; + return 0; =20 seq_printf(p, "%*d:", prec, i); for_each_online_cpu(j) { @@ -503,7 +489,7 @@ int show_interrupts(struct seq_file *p, } seq_putc(p, ' '); =20 - raw_spin_lock_irqsave(&desc->lock, flags); + guard(raw_spinlock_irq)(&desc->lock); if (desc->irq_data.chip) { if (desc->irq_data.chip->irq_print_chip) desc->irq_data.chip->irq_print_chip(&desc->irq_data, p); @@ -532,9 +518,6 @@ int show_interrupts(struct seq_file *p, } =20 seq_putc(p, '\n'); - raw_spin_unlock_irqrestore(&desc->lock, flags); -outsparse: - rcu_read_unlock(); return 0; } #endif From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 853B82797B3 for ; Tue, 29 Apr 2025 06:55:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909702; cv=none; b=kYjUE8UK4wu/1e6T7sE4WSuWdGXtP2jw2/8FHhAOpAWAzNLi7YaDIgcQQic/xRCT/pUmy0sea0snhGkMtTUhysaKHDQdoS4aAWrLA1OSL9WpJmgWG8S8jhn8jvLrj82qNn6/3qlzkWGLTfg+gzFodo4IwBumpEpydLiJv6rqDx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909702; c=relaxed/simple; bh=edtEWB4k+k/L4w/yDTmAXNYh2BhBLKh0TvCU/HTNNwA=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=tRWcRxL57AaPFJ5f1Dwb1mY28kIHg8ku62utVybH8Kf7g3wZCKZxp0rNaEysSdDUiUymKwaT2l+FOjlNyrW77DcdXjf1iuuueWbr3cisgS6HCyov4jm9q0z42m3+XHqy8uc8X12WqLSrnSviT8JWwIUv+Eog3W6WIW3qxfHjElk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=wNiKn1GW; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=yqrOTY5J; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="wNiKn1GW"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="yqrOTY5J" Message-ID: <20250429065420.437285102@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909698; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=Dkh13FM0z5C9yReJqSNpjRvp0mM9pBI+DFdk+sv+vbw=; b=wNiKn1GW3L+EuYNiJ42xvWLIvhFbFa5cyxz2D5hrvbr8nGLQNiXmG4xItvnP7azVt7Tq0+ iYeGHsw9nUylMvqF62m3f5fuA0nh96ctlx59GzsCEslyXJ/+zWE9Owyx9GvHdWO7H0i3Jz NV8Z0LTfJmEyLCNMr5+3Il2isSvGyerA+hZGYU1N28Ajp0Idu0GCr5edS5SDYslvFdypUe xeTDd85qqRCU1ZEA3Hb12s8H/LgKiXVA8+pSRjgUKsMpcAgfqFb0Ss6ocu+1gkcc3Lkq7v O0o+dO+lTicetjJ4O0uKBXsIGkg388orLH2rVd6M8ttep77ZuREeFtZ76BkC7g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909698; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=Dkh13FM0z5C9yReJqSNpjRvp0mM9pBI+DFdk+sv+vbw=; b=yqrOTY5Jh8kun+Ppy+Rve/PIvF85Ljxr4e0NyC3+F5/kd+xQdNW2t8Tt3qYQxOL4UoBtFe HPDrBQU2WNsJK+Cw== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 07/45] genirq/spurious: Cleanup code References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:54:58 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Clean up the coding style No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/spurious.c | 74 ++++++++++++++++++---------------------------= ----- 1 file changed, 28 insertions(+), 46 deletions(-) --- a/kernel/irq/spurious.c +++ b/kernel/irq/spurious.c @@ -34,8 +34,9 @@ static atomic_t irq_poll_active; * true and let the handler run. */ bool irq_wait_for_poll(struct irq_desc *desc) - __must_hold(&desc->lock) { + lockdep_assert_held(&desc->lock); + if (WARN_ONCE(irq_poll_cpu =3D=3D smp_processor_id(), "irq poll in progress on cpu %d for irq %d\n", smp_processor_id(), desc->irq_data.irq)) @@ -157,8 +158,7 @@ static void poll_spurious_irqs(struct ti continue; =20 /* Racy but it doesn't matter */ - state =3D desc->istate; - barrier(); + state =3D READ_ONCE(desc->istate); if (!(state & IRQS_SPURIOUS_DISABLED)) continue; =20 @@ -168,8 +168,7 @@ static void poll_spurious_irqs(struct ti } out: atomic_dec(&irq_poll_active); - mod_timer(&poll_spurious_irq_timer, - jiffies + POLL_SPURIOUS_IRQ_INTERVAL); + mod_timer(&poll_spurious_irq_timer, jiffies + POLL_SPURIOUS_IRQ_INTERVAL); } =20 static inline int bad_action_ret(irqreturn_t action_ret) @@ -195,15 +194,12 @@ static void __report_bad_irq(struct irq_ struct irqaction *action; unsigned long flags; =20 - if (bad_action_ret(action_ret)) { - printk(KERN_ERR "irq event %d: bogus return value %x\n", - irq, action_ret); - } else { - printk(KERN_ERR "irq %d: nobody cared (try booting with " - "the \"irqpoll\" option)\n", irq); - } + if (bad_action_ret(action_ret)) + pr_err("irq event %d: bogus return value %x\n", irq, action_ret); + else + pr_err("irq %d: nobody cared (try booting with the \"irqpoll\" option)\n= ", irq); dump_stack(); - printk(KERN_ERR "handlers:\n"); + pr_err("handlers:\n"); =20 /* * We need to take desc->lock here. note_interrupt() is called @@ -213,11 +209,10 @@ static void __report_bad_irq(struct irq_ */ raw_spin_lock_irqsave(&desc->lock, flags); for_each_action_of_desc(desc, action) { - printk(KERN_ERR "[<%p>] %ps", action->handler, action->handler); + pr_err("[<%p>] %ps", action->handler, action->handler); if (action->thread_fn) - printk(KERN_CONT " threaded [<%p>] %ps", - action->thread_fn, action->thread_fn); - printk(KERN_CONT "\n"); + pr_cont(" threaded [<%p>] %ps", action->thread_fn, action->thread_fn); + pr_cont("\n"); } raw_spin_unlock_irqrestore(&desc->lock, flags); } @@ -232,18 +227,17 @@ static void report_bad_irq(struct irq_de } } =20 -static inline int -try_misrouted_irq(unsigned int irq, struct irq_desc *desc, - irqreturn_t action_ret) +static inline bool try_misrouted_irq(unsigned int irq, struct irq_desc *de= sc, + irqreturn_t action_ret) { struct irqaction *action; =20 if (!irqfixup) - return 0; + return false; =20 /* We didn't actually handle the IRQ - see if it was misrouted? */ if (action_ret =3D=3D IRQ_NONE) - return 1; + return true; =20 /* * But for 'irqfixup =3D=3D 2' we also do it for handled interrupts if @@ -251,19 +245,16 @@ try_misrouted_irq(unsigned int irq, stru * traditional PC timer interrupt.. Legacy) */ if (irqfixup < 2) - return 0; + return false; =20 if (!irq) - return 1; + return true; =20 /* * Since we don't get the descriptor lock, "action" can - * change under us. We don't really care, but we don't - * want to follow a NULL pointer. So tell the compiler to - * just load it once by using a barrier. + * change under us. */ - action =3D desc->action; - barrier(); + action =3D READ_ONCE(desc->action); return action && (action->flags & IRQF_IRQPOLL); } =20 @@ -273,8 +264,7 @@ void note_interrupt(struct irq_desc *des { unsigned int irq; =20 - if (desc->istate & IRQS_POLL_INPROGRESS || - irq_settings_is_polled(desc)) + if (desc->istate & IRQS_POLL_INPROGRESS || irq_settings_is_polled(desc)) return; =20 if (bad_action_ret(action_ret)) { @@ -420,13 +410,12 @@ void note_interrupt(struct irq_desc *des /* * Now kill the IRQ */ - printk(KERN_EMERG "Disabling IRQ #%d\n", irq); + pr_emerg("Disabling IRQ #%d\n", irq); desc->istate |=3D IRQS_SPURIOUS_DISABLED; desc->depth++; irq_disable(desc); =20 - mod_timer(&poll_spurious_irq_timer, - jiffies + POLL_SPURIOUS_IRQ_INTERVAL); + mod_timer(&poll_spurious_irq_timer, jiffies + POLL_SPURIOUS_IRQ_INTERVAL= ); } desc->irqs_unhandled =3D 0; } @@ -436,11 +425,9 @@ bool noirqdebug __read_mostly; int noirqdebug_setup(char *str) { noirqdebug =3D 1; - printk(KERN_INFO "IRQ lockup detection disabled\n"); - + pr_info("IRQ lockup detection disabled\n"); return 1; } - __setup("noirqdebug", noirqdebug_setup); module_param(noirqdebug, bool, 0644); MODULE_PARM_DESC(noirqdebug, "Disable irq lockup detection when true"); @@ -452,12 +439,10 @@ static int __init irqfixup_setup(char *s return 1; } irqfixup =3D 1; - printk(KERN_WARNING "Misrouted IRQ fixup support enabled.\n"); - printk(KERN_WARNING "This may impact system performance.\n"); - + pr_warn("Misrouted IRQ fixup support enabled.\n"); + pr_warn("This may impact system performance.\n"); return 1; } - __setup("irqfixup", irqfixup_setup); module_param(irqfixup, int, 0644); =20 @@ -468,11 +453,8 @@ static int __init irqpoll_setup(char *st return 1; } irqfixup =3D 2; - printk(KERN_WARNING "Misrouted IRQ fixup and polling support " - "enabled\n"); - printk(KERN_WARNING "This may significantly impact system " - "performance\n"); + pr_warn("Misrouted IRQ fixup and polling support enabled\n"); + pr_warn("This may significantly impact system performance\n"); return 1; } - __setup("irqpoll", irqpoll_setup); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 1EBF727A939 for ; Tue, 29 Apr 2025 06:55:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909703; cv=none; b=DEDILUccrSRt9LTuShNbkYDZtewJzwbvYl1m/U+Ce4O87Sj75Eo8MVwgojTxmP+I3z6+r4UXYeEsXTJ9UOB2cS/BQh79yHPDR5lgzk+X2oHBSxDakRARKGrViJdctAfzgaNhAcRi1kXfmrD7k/wSu+3N60dyqLlSMqSTfoqWMcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909703; c=relaxed/simple; bh=/v+Xz0j5Au5Flc7pmD0k4+c5Q3zYLPRIknNWV/nC/1Y=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=oEIXBJZO8459U39LTzr3qkCGvjPendyppXPoZaLpRNN2cTB6aRrWd0rAvOBFJfyKg77gxkXXeCbTttNK02eXtLRh3W/lE4bQQ7Enf02v7tFrseUIEz4QPHFOz/HW3EwUZsx3lLKNcIgCdovGtIGfC02L4F851VuDqw/JRAzg88E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=I3JqWjIC; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=UYrWv4OS; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="I3JqWjIC"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="UYrWv4OS" Message-ID: <20250429065420.497714413@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909700; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=EJsNgAsLYnt1Rjy6yLuTAVVOslcX0E45dn2ezz2Rn1c=; b=I3JqWjICAaybHZRt0pUktTLrWtDvLfUOOPPkSt/LjIREg9A3nqVNwljdXTATLR6p0SvFRy R0Au0WFRuifAJKNe94+r8eybNcTOi8kT5aQrMTJRzOHEUQBbW6WFa4BkKSo/qqso8PeMjr gNMIbTIYStYqs/ygjPLOr4pBi7/ycHvnF9m+mXW/vEz4jEtRB0PUCNkYx0CQQvCUS9T7p4 2YZmmVKUNS7uAPex0Wzl0GV7p4+wglskRDYseAU0BppHn9o3Vv7YFiB/ckVqa9nBEAqV+P 7iYS+OJZy69R8ybiSNbOe9yij7yype5h0fBfq9kAjMI6pT8FuIbuO69zFk0Djw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909700; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=EJsNgAsLYnt1Rjy6yLuTAVVOslcX0E45dn2ezz2Rn1c=; b=UYrWv4OSTF/55utDOhZIcFhoA3uhovIzXW+9oeg8FAXllFLAHTNkLtffDiKuty2mdiWgrD YOOx7fkp6M7fQeDg== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 08/45] genirq/spurious: Switch to lock guards References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:54:59 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert all lock/unlock pairs to guards and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/spurious.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) --- a/kernel/irq/spurious.c +++ b/kernel/irq/spurious.c @@ -60,37 +60,35 @@ bool irq_wait_for_poll(struct irq_desc * /* * Recovery handler for misrouted interrupts. */ -static int try_one_irq(struct irq_desc *desc, bool force) +static bool try_one_irq(struct irq_desc *desc, bool force) { - irqreturn_t ret =3D IRQ_NONE; struct irqaction *action; + bool ret =3D false; =20 - raw_spin_lock(&desc->lock); + guard(raw_spinlock)(&desc->lock); =20 /* * PER_CPU, nested thread interrupts and interrupts explicitly * marked polled are excluded from polling. */ - if (irq_settings_is_per_cpu(desc) || - irq_settings_is_nested_thread(desc) || + if (irq_settings_is_per_cpu(desc) || irq_settings_is_nested_thread(desc) = || irq_settings_is_polled(desc)) - goto out; + return false; =20 /* * Do not poll disabled interrupts unless the spurious * disabled poller asks explicitly. */ if (irqd_irq_disabled(&desc->irq_data) && !force) - goto out; + return false; =20 /* * All handlers must agree on IRQF_SHARED, so we test just the * first. */ action =3D desc->action; - if (!action || !(action->flags & IRQF_SHARED) || - (action->flags & __IRQF_TIMER)) - goto out; + if (!action || !(action->flags & IRQF_SHARED) || (action->flags & __IRQF_= TIMER)) + return false; =20 /* Already running on another processor */ if (irqd_irq_inprogress(&desc->irq_data)) { @@ -99,21 +97,19 @@ static int try_one_irq(struct irq_desc * * CPU to go looking for our mystery interrupt too */ desc->istate |=3D IRQS_PENDING; - goto out; + return false; } =20 /* Mark it poll in progress */ desc->istate |=3D IRQS_POLL_INPROGRESS; do { if (handle_irq_event(desc) =3D=3D IRQ_HANDLED) - ret =3D IRQ_HANDLED; + ret =3D true; /* Make sure that there is still a valid action */ action =3D desc->action; } while ((desc->istate & IRQS_PENDING) && action); desc->istate &=3D ~IRQS_POLL_INPROGRESS; -out: - raw_spin_unlock(&desc->lock); - return ret =3D=3D IRQ_HANDLED; + return ret; } =20 static int misrouted_irq(int irq) @@ -192,7 +188,6 @@ static void __report_bad_irq(struct irq_ { unsigned int irq =3D irq_desc_get_irq(desc); struct irqaction *action; - unsigned long flags; =20 if (bad_action_ret(action_ret)) pr_err("irq event %d: bogus return value %x\n", irq, action_ret); @@ -207,14 +202,13 @@ static void __report_bad_irq(struct irq_ * with something else removing an action. It's ok to take * desc->lock here. See synchronize_irq(). */ - raw_spin_lock_irqsave(&desc->lock, flags); + guard(raw_spinlock_irqsave)(&desc->lock); for_each_action_of_desc(desc, action) { pr_err("[<%p>] %ps", action->handler, action->handler); if (action->thread_fn) pr_cont(" threaded [<%p>] %ps", action->thread_fn, action->thread_fn); pr_cont("\n"); } - raw_spin_unlock_irqrestore(&desc->lock, flags); } =20 static void report_bad_irq(struct irq_desc *desc, irqreturn_t action_ret) From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 30D66280A57 for ; Tue, 29 Apr 2025 06:55:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909704; cv=none; b=aL1Pulexka/iyXbWSm9DPlQEFqoAGfdB+VTur//Ig+J3QBS/kLzn7KMXNK4QLMSKSJAiLuwnBZPETzcYLc65iXCucaQ2d/l7rx2JkWp73CSNt8qWKd32fSvQEg68JDMcc/4XmtJmLInCowgKLWoLhjpNjw49F+5Zhn9BzWQkBBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909704; c=relaxed/simple; bh=+pGm+87RV33jEvsOAQNhY7ERqZsLYXRP2LLkYG9zh0g=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=JdHTkGpmPaju3JWlGlAXgbuoNH/yebBgQw45mgAsZeqQc5uhUCcd10L+GsxPBp+RlLHmWqypBqospmcpy+h14f2JFXtygFsd/COJ5YosDPfOI6MDUzrzEeEk3/QMcym5pVbw18a9xXhzSjzZrLl30DCrrW4B1hGuJscBoH+N2TU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=F6MU4OIL; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=A9WZ9W9Y; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="F6MU4OIL"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="A9WZ9W9Y" Message-ID: <20250429065420.560083665@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=1fztzzmyuBZmFHvPkzd1352r9hM/gYhsCUv4KQIAziY=; b=F6MU4OIL878vuFRwhz/BTpiBhHS6CawswyZgqz+IkA1qPo/qASkToxtmLyjvDnsmS8OzEU Saais4m8hXaQA5LjUMjMlcPlNrUtXCcd13/oHGzCPan1mcDgBJHYXlRoBZpgBgQVpefbSp zCXaPL7Wlt8SjfVLfN7ELM7fIwFIjbQrOW3MbxyLPtyNZ0FKMN79I/5R0qu4rVHddWetDM Z/mtC89hQvEFaKxXHIBQfDCeDMOHp8vFNcJrNp6E+Ek4Km4v3WftDgT9ZnZhdZvr2/dxSP FWT191etjyQBr4oBx7qOnpqR3P1k5JF1BXepiJLNJYc03lhJ/4dNb0sH3LOp2A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=1fztzzmyuBZmFHvPkzd1352r9hM/gYhsCUv4KQIAziY=; b=A9WZ9W9YmY6V8l1DHrlwdkOkg83o678pfMHc2Yp2+2wBxZUNwMwsLTMUaNzagFG3AIABbV AnXYFTZYBUv2VMCA== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 09/45] genirq/cpuhotplug: Convert to lock guards References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:01 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert all lock/unlock pairs to guards and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/cpuhotplug.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) --- a/kernel/irq/cpuhotplug.c +++ b/kernel/irq/cpuhotplug.c @@ -177,9 +177,8 @@ void irq_migrate_all_off_this_cpu(void) bool affinity_broken; =20 desc =3D irq_to_desc(irq); - raw_spin_lock(&desc->lock); - affinity_broken =3D migrate_one_irq(desc); - raw_spin_unlock(&desc->lock); + scoped_guard(raw_spinlock, &desc->lock) + affinity_broken =3D migrate_one_irq(desc); =20 if (affinity_broken) { pr_debug_ratelimited("IRQ %u: no longer affine to CPU%u\n", @@ -244,9 +243,8 @@ int irq_affinity_online_cpu(unsigned int irq_lock_sparse(); for_each_active_irq(irq) { desc =3D irq_to_desc(irq); - raw_spin_lock_irq(&desc->lock); - irq_restore_affinity_of_irq(desc, cpu); - raw_spin_unlock_irq(&desc->lock); + scoped_guard(raw_spinlock, &desc->lock) + irq_restore_affinity_of_irq(desc, cpu); } irq_unlock_sparse(); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 04C4928D850 for ; Tue, 29 Apr 2025 06:55:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909706; cv=none; b=LdkCP5bpfzkUIyFpgH6+spufGeLPQl9bJB9AYWrCTAhjH1HG6Ne5y4IOigNjIVBopFtbfeGX/gyA+KwS9ntln5onxnXPX3lNH9AM7RDGpm5owmG2hkpNeyzEpDRoLmI7oA4l9uKJaLc4n+pfiZ2e1IYQZuXFc3TH3bN+INsy23M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909706; c=relaxed/simple; bh=Dxk9kviW1jE9kunPeDh6mO84LJh/7jpiB8henybvJHs=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=jwnqtGAwDiM4beXGQUDQ0OD6GxfpFVIkrHOnf5S7RCTMJbt6tL+jX9jPnjhLwJ7JZpbR/nb778wfq2D1PClqHOVeU8KpacJZ/WcYulsFpnhXsaZcJ9DJ2nOLeEXUk4vMM2qfvhtI+ok0uLHsxNEs2AmylMx8tuxROSpRzHP2Nok= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=KQFs9uhr; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=0F7ND3TF; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="KQFs9uhr"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0F7ND3TF" Message-ID: <20250429065420.620200108@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909703; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=XaBNorVPoQIjdihkTL64MEhNSumYpX6J1+eefUBdUaU=; b=KQFs9uhrhdp6z9AN/N/HPXZp6Oib8v7xrW9JMYfZfCayDSvx6n8BvZTDXoG2Ai2kIRGE1N QouJvD8V7/wsl8/3uN6ffL4MLpStR4HaBcNF9T40Gg9h2sLJLknW4u9u3CSRm2RxNekO2V 60hrRk4cE4fxU74h6FYmbhtW0zwW9enP3ORnoXFVqQRRhFibXsg1snkpsceZjdOfWUKWm1 SM79gcnCGtyk53EMx9+zcGYBcPdVjTUFDfjUfgOwV545q6yABF26d6hCFf+7TZ2Yh5PXvo oM//ufvnTykDG9UWzqjRdNFTYzbn7ns0ys7/ttcgc9jQi7XIHYAUV6TbVzzFGg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909703; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=XaBNorVPoQIjdihkTL64MEhNSumYpX6J1+eefUBdUaU=; b=0F7ND3TFEhU66q6z3PeU5e7pVfwHfa1rkvikn4DDym/BA7kVx7CehvkTgO9e28vFpYYjTv 9Dq3GJzjKjI06UAQ== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 10/45] genirq/debugfs: Convert to lock guards References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:02 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert all lock/unlock pairs to guards and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/debugfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/kernel/irq/debugfs.c +++ b/kernel/irq/debugfs.c @@ -160,7 +160,7 @@ static int irq_debug_show(struct seq_fil struct irq_desc *desc =3D m->private; struct irq_data *data; =20 - raw_spin_lock_irq(&desc->lock); + guard(raw_spinlock_irq)(&desc->lock); data =3D irq_desc_get_irq_data(desc); seq_printf(m, "handler: %ps\n", desc->handle_irq); seq_printf(m, "device: %s\n", desc->dev_name); @@ -178,7 +178,6 @@ static int irq_debug_show(struct seq_fil seq_printf(m, "node: %d\n", irq_data_get_node(data)); irq_debug_show_masks(m, desc); irq_debug_show_data(m, data, 0); - raw_spin_unlock_irq(&desc->lock); return 0; } From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 37C60274FF2 for ; Tue, 29 Apr 2025 06:55:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909707; cv=none; b=SN/NldMUr6rNziiV2zREw5ljrD55ls+7jLRbB8OmkZq18QQ5g34wlCoPPzyS8sNxo3c/U+nVjo4AeaLKcMn5Z7toevkvbwqp4myvXkBnmKBxvFGhgkB5awXyHnvU0Ait3NJ1KutwqvcSiKwdGZpD3gqiqhMg40y+BCjhpI6bx0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909707; c=relaxed/simple; bh=VcRYaZtM9wzeeqjgdaUm7JvL7Sr89tNJHk3nn7VOPVg=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=WmqdWszuUgAROR2NpUwbl0jmpaLtoLfDDbStZEU3lXSPWfUNJ6NMqDNQiWR48LwzvfrTWMa0qEnC6X2CnvYHkH848vlbK8yVS1G9LIYVnJnvcwWwwSNcosQ5l9dIq3BJMe5NlaTOJBDCbX3KiEGneAgAXinpCLO1tagAh3x439k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=baYSX7jq; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=O3k9tqab; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="baYSX7jq"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="O3k9tqab" Message-ID: <20250429065420.682547546@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909704; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=QN6bEzxyXGVAZ9bIwLpJ9oOlP1yu1xAu69uA1smVlqE=; b=baYSX7jqxK4G49pyFxbjOeqOcrUJR2J2beKiaJVdPElZqJrD8oUlZzUvJeAoA6BFlItEBr SX+8lNhd9CrvDIv9eGXVMmDYno2syJKp+56mHO+NQGWMpW55AxhOCmfg3quvXbZZB1jpNE 8LR+8xZpGLwTq6edSAjOT2v5bkRniiYqe3O9JD7y+u/ULk50ckCuNBoVupG2tzRHEi2Z8r JEc3haZeG54S5RF3mgJjM+Q5mTIS/PdolkG5uwmS/ZrB3SvEr4pATBxjj6vLjPcGWsrUHF 7ceR7pUJSrM0PPlu16C4tXa7XVFP4n5EKJJHVk7uRKgbaWh45vH7C1SsYqgwcA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909704; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=QN6bEzxyXGVAZ9bIwLpJ9oOlP1yu1xAu69uA1smVlqE=; b=O3k9tqabgzhqFB1//973jxggWOTYaLBHz6ojeoEqZ3fJZakaDtGc7UaOA9ki/IfN9vYR7n DPst2iK41z7zw7Bw== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 11/45] genirq/chip: Prepare for code reduction References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:04 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The interrupt flow handlers have similar patterns to decide whether to handle an interrupt or not. Provide common helper functions to allow removal of duplicated code. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/chip.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -499,7 +499,7 @@ static bool irq_check_poll(struct irq_de return irq_wait_for_poll(desc); } =20 -static bool irq_may_run(struct irq_desc *desc) +static bool irq_can_handle_pm(struct irq_desc *desc) { unsigned int mask =3D IRQD_IRQ_INPROGRESS | IRQD_WAKEUP_ARMED; =20 @@ -524,6 +524,25 @@ static bool irq_may_run(struct irq_desc return irq_check_poll(desc); } =20 +static inline bool irq_can_handle_actions(struct irq_desc *desc) +{ + desc->istate &=3D ~(IRQS_REPLAY | IRQS_WAITING); + + if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) { + desc->istate |=3D IRQS_PENDING; + return false; + } + return true; +} + +static inline bool irq_can_handle(struct irq_desc *desc) +{ + if (!irq_can_handle_pm(desc)) + return false; + + return irq_can_handle_actions(desc); +} + /** * handle_simple_irq - Simple and software-decoded IRQs. * @desc: the interrupt description structure for this irq @@ -539,7 +558,7 @@ void handle_simple_irq(struct irq_desc * { raw_spin_lock(&desc->lock); =20 - if (!irq_may_run(desc)) + if (!irq_can_handle_pm(desc)) goto out_unlock; =20 desc->istate &=3D ~(IRQS_REPLAY | IRQS_WAITING); @@ -574,7 +593,7 @@ void handle_untracked_irq(struct irq_des { raw_spin_lock(&desc->lock); =20 - if (!irq_may_run(desc)) + if (!irq_can_handle_pm(desc)) goto out_unlock; =20 desc->istate &=3D ~(IRQS_REPLAY | IRQS_WAITING); @@ -630,7 +649,7 @@ void handle_level_irq(struct irq_desc *d raw_spin_lock(&desc->lock); mask_ack_irq(desc); =20 - if (!irq_may_run(desc)) + if (!irq_can_handle_pm(desc)) goto out_unlock; =20 desc->istate &=3D ~(IRQS_REPLAY | IRQS_WAITING); @@ -695,7 +714,7 @@ void handle_fasteoi_irq(struct irq_desc * can arrive on the new CPU before the original CPU has completed * handling the previous one - it may need to be resent. */ - if (!irq_may_run(desc)) { + if (!irq_can_handle_pm(desc)) { if (irqd_needs_resend_when_in_progress(&desc->irq_data)) desc->istate |=3D IRQS_PENDING; goto out; @@ -790,7 +809,7 @@ void handle_edge_irq(struct irq_desc *de =20 desc->istate &=3D ~(IRQS_REPLAY | IRQS_WAITING); =20 - if (!irq_may_run(desc)) { + if (!irq_can_handle_pm(desc)) { desc->istate |=3D IRQS_PENDING; mask_ack_irq(desc); goto out_unlock; @@ -1166,7 +1185,7 @@ void handle_fasteoi_ack_irq(struct irq_d =20 raw_spin_lock(&desc->lock); =20 - if (!irq_may_run(desc)) + if (!irq_can_handle_pm(desc)) goto out; =20 desc->istate &=3D ~(IRQS_REPLAY | IRQS_WAITING); @@ -1218,7 +1237,7 @@ void handle_fasteoi_mask_irq(struct irq_ raw_spin_lock(&desc->lock); mask_ack_irq(desc); =20 - if (!irq_may_run(desc)) + if (!irq_can_handle_pm(desc)) goto out; =20 desc->istate &=3D ~(IRQS_REPLAY | IRQS_WAITING); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 84122275855 for ; Tue, 29 Apr 2025 06:55:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909710; cv=none; b=D2kD+gSQ+X/2YMWp6OGQkHogc9x+DlE0X6HGlpvZCjIW3onIGZBAxwTXchVN7wmdMIcsFqgGE1KsEq82xw0XAsljI3ynEKRgbXCjExte+keybTmAYwyKzlcG9a3CPBByJqJ0zNCaQgWvSB76RNFcKBeaoy2sdSPE6GWKQjVUH1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909710; c=relaxed/simple; bh=vQdhMB02L4GMfUK8MWk+sLjTzs62NpK5Bm59ZUweYSM=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=gjDDh45SfPZZ5faLXQFhMR9kls1Q/AdjPjDgrpjgGBTmOjJrfMkRsfwKd6kvVmcw8vqsTkGzMdRChyjQo6lZhdO6Wv06GhE8VlpGcZClF8DMskTFHvEh5+UvQ38uWybSPByj4KhXlZ0G6cgzJSvyFqrudtjIKAkp3WAmO5Sn1m0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ARFDm+6K; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=95LXb03J; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ARFDm+6K"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="95LXb03J" Message-ID: <20250429065420.744042890@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=Elt7wbsb65w2Qe5D8R4S76SkUL3H0H5hKtbrtwxL6nI=; b=ARFDm+6Kf5Uyj5S8beCPR9hjLgHr0BXivrbypI7du0N96JKtYwEwJSVU6DfJ/+XN2mRuhS YExfHO+zepiQNNdCXyFY6hHxJmLXHvkBwwnahghPoZK84UWLHzEuflMZ0qhPHGjNeMdt5K VD3wT7kEwf4Heu6FOH4SrQVE6hY3gY0kzYqWgDJ+8c8eXWj+Ql6Pm2wFtwj+Mqass66Cfp YNUAbuOb7wqB6SVHp2aJpXTS1x/LQtrvqoYzSrDzlfr2JDiUh0o2lL4XKzTe2fs7fYdP1O PPzkf87+pTQbG07tlgDSpcPpLR8umLL2rM5AZTG/IfP707lUTvJ1XFbLwF9PEA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=Elt7wbsb65w2Qe5D8R4S76SkUL3H0H5hKtbrtwxL6nI=; b=95LXb03JzMnoq+Ya027eVGF4H5t6x7zfw345kmySsspwOoE0hY+8nLdAPeSVL1PIsiDny4 GFDWHp7bywQCYpCA== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 12/45] genirq/chip: Rework handle_nested_irq() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:05 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new helpers to decide whether the interrupt should be handled and switch the descriptor locking to guard(). Fixup the kernel doc comment while at it. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/chip.c | 78 ++++++++++++++++++++++++-------------------------= ----- 1 file changed, 36 insertions(+), 42 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -450,48 +450,6 @@ void unmask_threaded_irq(struct irq_desc unmask_irq(desc); } =20 -/* - * handle_nested_irq - Handle a nested irq from a irq thread - * @irq: the interrupt number - * - * Handle interrupts which are nested into a threaded interrupt - * handler. The handler function is called inside the calling - * threads context. - */ -void handle_nested_irq(unsigned int irq) -{ - struct irq_desc *desc =3D irq_to_desc(irq); - struct irqaction *action; - irqreturn_t action_ret; - - might_sleep(); - - raw_spin_lock_irq(&desc->lock); - - desc->istate &=3D ~(IRQS_REPLAY | IRQS_WAITING); - - action =3D desc->action; - if (unlikely(!action || irqd_irq_disabled(&desc->irq_data))) { - desc->istate |=3D IRQS_PENDING; - raw_spin_unlock_irq(&desc->lock); - return; - } - - kstat_incr_irqs_this_cpu(desc); - atomic_inc(&desc->threads_active); - raw_spin_unlock_irq(&desc->lock); - - action_ret =3D IRQ_NONE; - for_each_action_of_desc(desc, action) - action_ret |=3D action->thread_fn(action->irq, action->dev_id); - - if (!irq_settings_no_debug(desc)) - note_interrupt(desc, action_ret); - - wake_threads_waitq(desc); -} -EXPORT_SYMBOL_GPL(handle_nested_irq); - static bool irq_check_poll(struct irq_desc *desc) { if (!(desc->istate & IRQS_POLL_INPROGRESS)) @@ -544,6 +502,42 @@ static inline bool irq_can_handle(struct } =20 /** + * handle_nested_irq - Handle a nested irq from a irq thread + * @irq: the interrupt number + * + * Handle interrupts which are nested into a threaded interrupt + * handler. The handler function is called inside the calling threads + * context. + */ +void handle_nested_irq(unsigned int irq) +{ + struct irq_desc *desc =3D irq_to_desc(irq); + struct irqaction *action; + irqreturn_t action_ret; + + might_sleep(); + + scoped_guard(raw_spinlock_irq, &desc->lock) { + if (irq_can_handle_actions(desc)) + return; + + action =3D desc->action; + kstat_incr_irqs_this_cpu(desc); + atomic_inc(&desc->threads_active); + } + + action_ret =3D IRQ_NONE; + for_each_action_of_desc(desc, action) + action_ret |=3D action->thread_fn(action->irq, action->dev_id); + + if (!irq_settings_no_debug(desc)) + note_interrupt(desc, action_ret); + + wake_threads_waitq(desc); +} +EXPORT_SYMBOL_GPL(handle_nested_irq); + +/** * handle_simple_irq - Simple and software-decoded IRQs. * @desc: the interrupt description structure for this irq * From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 8AE2F29CB5E for ; Tue, 29 Apr 2025 06:55:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909711; cv=none; b=pXECL0X0oiLFuV5k6NhLULWTq/9AOpv9OjnsQReSSUN/bK35hxbLGbEbh3N19z/vBJCgRRq0RjGQCrVC5pRoY48PuhegLsPbt72V1wLz9y+/SkzF6VES4dnvet0KOvOEMcwr+nrqdG2ukejLn0J/MuPwDQgFyTnnoQ3U+tqZ/z0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909711; c=relaxed/simple; bh=SWruWjq7NrJh4GW6JpsESKSHFkheXo+rUk/pWg501Ec=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=NKY3LJsoMBG7l52VHMxGfuP8nMO5S0wGJpCV5QzKjQ63q2ocQ0byWNX00F5MMB1PY4onnvdyQWNzJ1MTl93hfUQUiIsp7gqESQpj9qmPleeYUEu+1SSRBprPJnhB/HMzCy+Ha75KjtMfQB0pckCTGtoJPJQyNWM+FguB/8Xd6oA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=JXdU1HIF; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=YhBI99P0; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JXdU1HIF"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="YhBI99P0" Message-ID: <20250429065420.804683349@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=tLeDTvhOlopO8mWHtAUXcGd29hb+8xAyrOVF30gQF8M=; b=JXdU1HIFeCnjI28W0/ytZosx3sr53KS/ldcUzhj4Qe7oXP2bFdmUJMNJv4h3NFpF2HvNpo Mieh0FNDuf8dvhamNeJG4JzajMLrCs7I3zEAmBliJbyLzdyUPzkq+sEtwS8qhEfu9dDrTU NefbKYKJZomfxRn+9KOpUY8yxrFbc4MBvTyB5Ouf1Qh2ziCgiU4FNALbxp4Txb5/NA39h9 fundFwkYk3e+fAgi0fv4xHUm/BNKm4u1P/ou7PWHMvjIn9zQiVnEcIbyas1gSEIkYCTDeg uiGxOCp+O9HOOwMsL8zuTq5z4sMKqSpoAcsU0q5LSogQIX4e7kyd+B8nJGGR0Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=tLeDTvhOlopO8mWHtAUXcGd29hb+8xAyrOVF30gQF8M=; b=YhBI99P0kCXy6laG1EbV1KSVTGDp97HGrjzrgReD2Dy5GUsbb2Hx7cjWcWNTbNamy2hMwO 29pT8V6VXqGUNxBQ== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 13/45] genirq/chip: Rework handle_simple_irq() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:07 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new helpers to decide whether the interrupt should be handled and switch the descriptor locking to guard(). Fixup the kernel doc comment while at it. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/chip.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -538,35 +538,25 @@ void handle_nested_irq(unsigned int irq) EXPORT_SYMBOL_GPL(handle_nested_irq); =20 /** - * handle_simple_irq - Simple and software-decoded IRQs. - * @desc: the interrupt description structure for this irq + * handle_simple_irq - Simple and software-decoded IRQs. + * @desc: the interrupt description structure for this irq * - * Simple interrupts are either sent from a demultiplexing interrupt - * handler or come from hardware, where no interrupt hardware control - * is necessary. + * Simple interrupts are either sent from a demultiplexing interrupt + * handler or come from hardware, where no interrupt hardware control is + * necessary. * - * Note: The caller is expected to handle the ack, clear, mask and - * unmask issues if necessary. + * Note: The caller is expected to handle the ack, clear, mask and unmask + * issues if necessary. */ void handle_simple_irq(struct irq_desc *desc) { - raw_spin_lock(&desc->lock); + guard(raw_spinlock)(&desc->lock); =20 - if (!irq_can_handle_pm(desc)) - goto out_unlock; - - desc->istate &=3D ~(IRQS_REPLAY | IRQS_WAITING); - - if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) { - desc->istate |=3D IRQS_PENDING; - goto out_unlock; - } + if (!irq_can_handle(desc)) + return; =20 kstat_incr_irqs_this_cpu(desc); handle_irq_event(desc); - -out_unlock: - raw_spin_unlock(&desc->lock); } EXPORT_SYMBOL_GPL(handle_simple_irq); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 EBF8829DB7B for ; Tue, 29 Apr 2025 06:55:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909712; cv=none; b=N2/PkCzjviQi+kYXZ42GvUUlm38Cn31pHbylGwgB48Caibm1l9hYVAy/B8/PCnWjA9dMsCKZjfpAIFzDXQniMmmXrHCj4b6+pwz2aQxKm93PB36J9g4jLLb7EZG7ACTno/EB4phJb2gXk7jhDJoEwCqWD1Yxk2j+3HqDnO7NT6A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909712; c=relaxed/simple; bh=9ADQ8q4irEqvsLxBjscvDczzPCp3K6JV4Zg7QYDEZTM=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=CL9Qcr4Ae03LgvBIN90F1IKNhaNvBClfZzuyFH2mte25dZriOOk4gaoyyKoVA4Ee0IGyBmvxN/MeHASlo48uHNhWDgSJb7KuBh4oWnHnX3RFhHJDWBxPehanWVAkvPnhvB5AjdYxDjzElPHmmaUMV00pzx6UQ6c4rLM7PjGbZ28= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=EiUNVPWh; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=nRqEJ0zC; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="EiUNVPWh"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="nRqEJ0zC" Message-ID: <20250429065420.865212916@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909709; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=/1C8I6OREyZIk5Yy5HonLyBS6RAOxNzQN5SHdHA4gxk=; b=EiUNVPWhDYsW/wzEJzLt+tq71AdVtPm8s60OOs9nWU8VhAnae80FZ34TaOj8kZ6uAdRTj+ FnhMrD9wy58zdehy8/QXTISzfl+HEZ10UH0cBAB+R0GJe/6j1muTu0xc2a91zQSQ70uIOh TNsdXHj7CHwyuTAEk8Wofqi1+Zs215so490//woG0jDUe25CBU755vlJxUNsbb4QYrEKIg CyMH+eOw62INaeyN4Ev7ghjk8THS/zH1NFQlFAGjo1c7hlrr7AaDemblV0b8MxYSOrisTF lS3c1w5Y65FmLpXbJeYuUJbJBk7906rWK2tnWYO/ja3ypOu3mJwDYLsWv5ClxQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909709; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=/1C8I6OREyZIk5Yy5HonLyBS6RAOxNzQN5SHdHA4gxk=; b=nRqEJ0zCEluVCBQELyeaHCAbYeKAG3uZHjyOBRAynyLsFk7yWJk1QwVUUilW/M9BMl3viW WPCHC/p28WnKGIBg== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 14/45] genirq/chip: Rework handle_untracked_irq() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:08 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new helpers to decide whether the interrupt should be handled and switch the descriptor locking to guard(). Fixup the kernel doc comment while at it. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/chip.c | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -561,43 +561,32 @@ void handle_simple_irq(struct irq_desc * EXPORT_SYMBOL_GPL(handle_simple_irq); =20 /** - * handle_untracked_irq - Simple and software-decoded IRQs. - * @desc: the interrupt description structure for this irq + * handle_untracked_irq - Simple and software-decoded IRQs. + * @desc: the interrupt description structure for this irq * - * Untracked interrupts are sent from a demultiplexing interrupt - * handler when the demultiplexer does not know which device it its - * multiplexed irq domain generated the interrupt. IRQ's handled - * through here are not subjected to stats tracking, randomness, or - * spurious interrupt detection. + * Untracked interrupts are sent from a demultiplexing interrupt handler + * when the demultiplexer does not know which device it its multiplexed irq + * domain generated the interrupt. IRQ's handled through here are not + * subjected to stats tracking, randomness, or spurious interrupt + * detection. * - * Note: Like handle_simple_irq, the caller is expected to handle - * the ack, clear, mask and unmask issues if necessary. + * Note: Like handle_simple_irq, the caller is expected to handle the ack, + * clear, mask and unmask issues if necessary. */ void handle_untracked_irq(struct irq_desc *desc) { - raw_spin_lock(&desc->lock); + scoped_guard(raw_spinlock, &desc->lock) { + if (!irq_can_handle(desc)) + return; =20 - if (!irq_can_handle_pm(desc)) - goto out_unlock; - - desc->istate &=3D ~(IRQS_REPLAY | IRQS_WAITING); - - if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) { - desc->istate |=3D IRQS_PENDING; - goto out_unlock; + desc->istate &=3D ~IRQS_PENDING; + irqd_set(&desc->irq_data, IRQD_IRQ_INPROGRESS); } =20 - desc->istate &=3D ~IRQS_PENDING; - irqd_set(&desc->irq_data, IRQD_IRQ_INPROGRESS); - raw_spin_unlock(&desc->lock); - __handle_irq_event_percpu(desc); =20 - raw_spin_lock(&desc->lock); - irqd_clear(&desc->irq_data, IRQD_IRQ_INPROGRESS); - -out_unlock: - raw_spin_unlock(&desc->lock); + scoped_guard(raw_spinlock, &desc->lock) + irqd_clear(&desc->irq_data, IRQD_IRQ_INPROGRESS); } EXPORT_SYMBOL_GPL(handle_untracked_irq); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 40FB029DB98 for ; Tue, 29 Apr 2025 06:55:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909713; cv=none; b=Pg3V1m3mSFHydDzROs1C98v2WiCW3qXgdWvbwypAXDbLsDESLLHJnazFkASAuFNfOGSiqcNV8rzIxcg6/lDHO42suPtw/UJvk63x0dbhbCHGw2cFV4D8qY4EPHWbZ5XdiyZlPAT/0FZvAdaG1lCE6JSWtu/7TPc6oSHagsXCwgE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909713; c=relaxed/simple; bh=4uy/0MQtewojBOepFXdoI7S1S1htmg9NVRaV1ckApQM=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Tz6Q5nBO/qKX2c3t8RjkzaAIYzPaa89Ufp6ZWIsFsRpSM+ZkUDE03J+Qht6jBh8915O/UkHH5jLqb1aYtDNzQ/Bjbf0qLEdgtxvPZwFUXP8PN03i6f8QB2OOhV0Jr40rCp8KY4XJak1sPOBhNSc6T3js31ZBy2IQzRWRfJitUrM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=idyFHCGU; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=78oqSr89; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="idyFHCGU"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="78oqSr89" Message-ID: <20250429065420.926362488@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909710; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=RuDZMp9D+gp8EySkGfhyFxWNuHAfWXE5BrBGEQsh6Ng=; b=idyFHCGUFBlRXyUWIJKrfens/GtUD0M+zfYuZ5mrgCSSFiqkrDgStT/w34Y/RZ7xhejPWx a9pRmm8DIAUm74xDgWp/HAgeYnL1XXgu4wsRWVSBoa/sZDOV1v83yyvONr6IoN6OJZVIgU ygF7hpmVIOb+vyRActbtyNB4gU+631ZQvzfymsOpOGM1ZuNPGHsDjOaHrPmoOw3k9CCep7 NxpA+xZgGrLjTMzSnS6H3L0SMVr/WJilVyLYPsWNuOFppKn9wkqRxP6QqFPUOleW/yp1Dn juVoHbo3KoXJxhkdOuBGUQEIpQrzMmdFfs5Uqyhg9NgJBzRDWOq9jphGfzbxTg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909710; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=RuDZMp9D+gp8EySkGfhyFxWNuHAfWXE5BrBGEQsh6Ng=; b=78oqSr89tz6yVE72vDA6aRYn0vN/54kz9l8PpteSeN3LCMBC52ntvIr3uf+IXt+clPJYdI aBLFI4OsVTmD3KDA== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 15/45] genirq/chip: Rework handle_level_irq() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:10 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new helpers to decide whether the interrupt should be handled and switch the descriptor locking to guard(). Fixup the kernel doc comment while at it. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/chip.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -609,40 +609,26 @@ static void cond_unmask_irq(struct irq_d } =20 /** - * handle_level_irq - Level type irq handler - * @desc: the interrupt description structure for this irq + * handle_level_irq - Level type irq handler + * @desc: the interrupt description structure for this irq * - * Level type interrupts are active as long as the hardware line has - * the active level. This may require to mask the interrupt and unmask - * it after the associated handler has acknowledged the device, so the - * interrupt line is back to inactive. + * Level type interrupts are active as long as the hardware line has the + * active level. This may require to mask the interrupt and unmask it after + * the associated handler has acknowledged the device, so the interrupt + * line is back to inactive. */ void handle_level_irq(struct irq_desc *desc) { - raw_spin_lock(&desc->lock); + guard(raw_spinlock)(&desc->lock); mask_ack_irq(desc); =20 - if (!irq_can_handle_pm(desc)) - goto out_unlock; - - desc->istate &=3D ~(IRQS_REPLAY | IRQS_WAITING); - - /* - * If its disabled or no action available - * keep it masked and get out of here - */ - if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) { - desc->istate |=3D IRQS_PENDING; - goto out_unlock; - } + if (!irq_can_handle(desc)) + return; =20 kstat_incr_irqs_this_cpu(desc); handle_irq_event(desc); =20 cond_unmask_irq(desc); - -out_unlock: - raw_spin_unlock(&desc->lock); } EXPORT_SYMBOL_GPL(handle_level_irq); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 9A6F429E05D for ; Tue, 29 Apr 2025 06:55:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909715; cv=none; b=DxNCBvzXIuLjtfcpw4ZKKMe0+UNDe+Fc9OCfIxTnmKa38bVKl6pK5uhPrRcvQcOBilSFUYo4oEag/2E/KvsQ4BDBJH+T67fHpBNSCVKaPGuHnvl2bpSGQKOPfc2TLPLDs1osvLOfiIRmymgOpUhwePP7gPjoumvDHwvLkbIdU+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909715; c=relaxed/simple; bh=JY55ckGPun0VFenj+VGvTxnmtiBk05Qfzvupa8ijVCk=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=TukVmThEDQVecIAbBOROyB1+DUfzFB4twcPV+FJXhQppSwfYBAfrX86j67yE5oXj5ByvkwB864CvwdelAEzfDkzQ5AMKWEOKuH33BzBLsmEkkmBwnq49FjzdcqZU2UYBfengJ0v9cLpai21UzhkUqfEGWTkxbO4L6FF/ajn2pFc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=MZ1fYCDn; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=HxjN2Emm; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="MZ1fYCDn"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="HxjN2Emm" Message-ID: <20250429065420.986002418@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=En6C3bol8LI9sAhXjlJqBpxjtJUTEi/+UmlYb37p1m0=; b=MZ1fYCDnF2HEr6HLJ9UTYVH5iOep70Qd96CRNlfG9JOVSsJ8E2LH9lM7vE10acDq2BkNvL Be5bejF4iVmyEbF8wkd0qQFymSVZ9tQD32Sxq5qxrTuYoLFdMFvjfiWoWlejmXC4Onbxn1 Wbla15LpXO2/pn/GY4TOcEIkX2qiUXL2MSzkmtBxe5xaq5dhmg9NIHvDtkar9JKdzKhsUt wEOUO8bnc8Z37oCj3OZ9QO94QB4ZD6t1DuV1gCJagWmIL9c6yrn2ayec7DEFysZSdLDSZV d3MDUYEqRYlQn9vTNUYUkuG6OupiJadZouRy/6fD8z/LhHovlYlGdCDdaoCybw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=En6C3bol8LI9sAhXjlJqBpxjtJUTEi/+UmlYb37p1m0=; b=HxjN2EmmqUkW7ONqtmPlfuyAEojSt31LNnBLZ+H9oJrpRhzdtLqGp5uEXf27TxI3HG6tiO 7IiIbQIHU5bpJnDg== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 16/45] genirq/chip: Rework handle_eoi_irq() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:11 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new helpers to decide whether the interrupt should be handled and switch the descriptor locking to guard(). Fixup the kernel doc comment while at it. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/chip.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -653,20 +653,26 @@ static void cond_unmask_eoi_irq(struct i } } =20 +static inline void cond_eoi_irq(struct irq_chip *chip, struct irq_data *da= ta) +{ + if (!(chip->flags & IRQCHIP_EOI_IF_HANDLED)) + chip->irq_eoi(data); +} + /** - * handle_fasteoi_irq - irq handler for transparent controllers - * @desc: the interrupt description structure for this irq + * handle_fasteoi_irq - irq handler for transparent controllers + * @desc: the interrupt description structure for this irq * - * Only a single callback will be issued to the chip: an ->eoi() - * call when the interrupt has been serviced. This enables support - * for modern forms of interrupt handlers, which handle the flow - * details in hardware, transparently. + * Only a single callback will be issued to the chip: an ->eoi() call when + * the interrupt has been serviced. This enables support for modern forms + * of interrupt handlers, which handle the flow details in hardware, + * transparently. */ void handle_fasteoi_irq(struct irq_desc *desc) { struct irq_chip *chip =3D desc->irq_data.chip; =20 - raw_spin_lock(&desc->lock); + guard(raw_spinlock)(&desc->lock); =20 /* * When an affinity change races with IRQ handling, the next interrupt @@ -676,19 +682,14 @@ void handle_fasteoi_irq(struct irq_desc if (!irq_can_handle_pm(desc)) { if (irqd_needs_resend_when_in_progress(&desc->irq_data)) desc->istate |=3D IRQS_PENDING; - goto out; + cond_eoi_irq(chip, &desc->irq_data); + return; } =20 - desc->istate &=3D ~(IRQS_REPLAY | IRQS_WAITING); - - /* - * If its disabled or no action available - * then mask it and get out of here: - */ - if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) { - desc->istate |=3D IRQS_PENDING; + if (!irq_can_handle_actions(desc)) { mask_irq(desc); - goto out; + cond_eoi_irq(chip, &desc->irq_data); + return; } =20 kstat_incr_irqs_this_cpu(desc); @@ -704,13 +705,6 @@ void handle_fasteoi_irq(struct irq_desc */ if (unlikely(desc->istate & IRQS_PENDING)) check_irq_resend(desc, false); - - raw_spin_unlock(&desc->lock); - return; -out: - if (!(chip->flags & IRQCHIP_EOI_IF_HANDLED)) - chip->irq_eoi(&desc->irq_data); - raw_spin_unlock(&desc->lock); } EXPORT_SYMBOL_GPL(handle_fasteoi_irq); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 45DA229E050 for ; Tue, 29 Apr 2025 06:55:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909716; cv=none; b=aOjQxpAxytNqiADIjw9XgZ44zopU4BuC9SO3Zu3O9OrgVwdIM7U5rq30rBHNhO8/+WHO7pw5e0aOV9A2TJc5OG+79bkBaXSe+TjPAbhxr6/CuhqaisCv6fsUk0j8umYf0jnq/gakQL17T8/PA/lXyKllLmRdBfcx2plgbQHvNE8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909716; c=relaxed/simple; bh=mGCb5zTix+6ZenP8v2HFCcBeJlKvwLORLxBK/RyV4DI=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=pEWo+aKBU7z9ABe03d1AB96OefIQM3GgQetdkDzKSeUu5RaWq/svZ4S8q9xVnDia/dIpFNATpvIhxaBnbUAuk91+ZeNFyhFQiqK7pU2+48QPq5s7u62TxJ1dVRqWs/8PTFIPJTn8Jt5HyVArzHS5UCE3ZcNNipFeyeCeBxGfcqo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=qhyVDgXY; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=W50/P351; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="qhyVDgXY"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="W50/P351" Message-ID: <20250429065421.045492336@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909713; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=bRM/R0aUzWZeAfZCtlDdcrEw9RKacHntnf1+QoxDFCA=; b=qhyVDgXYG1/A7ISYKyPU14l9raThkpExtaD0YZpedhrNkEGyLK/S8FxpqXet5gOQg72X35 XvAAG75NVxyd0C/IG6GNIN5ew32VC7KgRhiSqjK9GUe3cvUHhM03jLFQ/GM1A47kKQ2CuD fsUXmhKUE7vKLvqX+GYA7tGSv6n2i1V7yCEdcGj35oMX0WVjF88ptlmKEJByGIoix5H7pf Qbkyvnq1g3icxfrm9ozheW2S564APeOhIPvQ9Lg6qNisedaqTbK7NubzJOpED3uESXtakJ 7Vcn9uEBnSkZ0mEy07tJR7bU57YWSbLi/qgEkyKKhkcyP+VpJLbq9wgY2lJlFA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909713; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=bRM/R0aUzWZeAfZCtlDdcrEw9RKacHntnf1+QoxDFCA=; b=W50/P3518dMdO2uYvbKG8Nu03yu1hoJninO35aBHUTFwBcyInW5KTGg0hVBTDG4sL/pA37 qYknYgxI1L9DrVDg== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 17/45] genirq/chip: Rework handle_edge_irq() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:13 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new helpers to decide whether the interrupt should be handled and switch the descriptor locking to guard(). Fixup the kernel doc comment while at it. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/chip.c | 49 ++++++++++++++++--------------------------------- 1 file changed, 16 insertions(+), 33 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -742,40 +742,27 @@ void handle_fasteoi_nmi(struct irq_desc EXPORT_SYMBOL_GPL(handle_fasteoi_nmi); =20 /** - * handle_edge_irq - edge type IRQ handler - * @desc: the interrupt description structure for this irq + * handle_edge_irq - edge type IRQ handler + * @desc: the interrupt description structure for this irq * - * Interrupt occurs on the falling and/or rising edge of a hardware - * signal. The occurrence is latched into the irq controller hardware - * and must be acked in order to be reenabled. After the ack another - * interrupt can happen on the same source even before the first one - * is handled by the associated event handler. If this happens it - * might be necessary to disable (mask) the interrupt depending on the - * controller hardware. This requires to reenable the interrupt inside - * of the loop which handles the interrupts which have arrived while - * the handler was running. If all pending interrupts are handled, the - * loop is left. + * Interrupt occurs on the falling and/or rising edge of a hardware + * signal. The occurrence is latched into the irq controller hardware and + * must be acked in order to be reenabled. After the ack another interrupt + * can happen on the same source even before the first one is handled by + * the associated event handler. If this happens it might be necessary to + * disable (mask) the interrupt depending on the controller hardware. This + * requires to reenable the interrupt inside of the loop which handles the + * interrupts which have arrived while the handler was running. If all + * pending interrupts are handled, the loop is left. */ void handle_edge_irq(struct irq_desc *desc) { - raw_spin_lock(&desc->lock); + guard(raw_spinlock)(&desc->lock); =20 - desc->istate &=3D ~(IRQS_REPLAY | IRQS_WAITING); - - if (!irq_can_handle_pm(desc)) { - desc->istate |=3D IRQS_PENDING; - mask_ack_irq(desc); - goto out_unlock; - } - - /* - * If its disabled or no action available then mask it and get - * out of here. - */ - if (irqd_irq_disabled(&desc->irq_data) || !desc->action) { + if (!irq_can_handle(desc)) { desc->istate |=3D IRQS_PENDING; mask_ack_irq(desc); - goto out_unlock; + return; } =20 kstat_incr_irqs_this_cpu(desc); @@ -786,7 +773,7 @@ void handle_edge_irq(struct irq_desc *de do { if (unlikely(!desc->action)) { mask_irq(desc); - goto out_unlock; + return; } =20 /* @@ -802,11 +789,7 @@ void handle_edge_irq(struct irq_desc *de =20 handle_irq_event(desc); =20 - } while ((desc->istate & IRQS_PENDING) && - !irqd_irq_disabled(&desc->irq_data)); - -out_unlock: - raw_spin_unlock(&desc->lock); + } while ((desc->istate & IRQS_PENDING) && !irqd_irq_disabled(&desc->irq_d= ata)); } EXPORT_SYMBOL(handle_edge_irq); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 25F282BCF61 for ; Tue, 29 Apr 2025 06:55:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909718; cv=none; b=SxOuh4SPAmZxFCnAPVqdYjhmIbfTZ+6C0UyULpCgettSpqRQ3MsYVkKSVjNThaK0ZPO4EoA3vrlG5WZtOVzgMaRQDGhaWFua1U/AknA2ClR5rNp0Vwurf8laY1uQoVU4amUDrxkanqUGsN1sJLev3JPOCWdrHdZ5UkGUoQyu4vs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909718; c=relaxed/simple; bh=DbnTL4qlJcYqzE7rRzgjCwtX1JxogP9NhfoJkwo0RAA=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=u/E2CMqRoZairYOGRQFh+zezDcHqB4m8g+B5MWNpTefved8jftIqkW5W5d5N9IH/gQ04qA/eltv+6uOqismuTUqrcSyzDocxP9Dk6gOtK3Jmhy8Kn9CB9ctFVSBZC2/alTxh5CfH0+D+rF2oXditkPyi3QGeZi8lPD58tisoHMs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=F/QJobC6; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=N+2GAs4J; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="F/QJobC6"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="N+2GAs4J" Message-ID: <20250429065421.105015800@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909715; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=lGutETkITAVxGTPxI1jmGIcy6NGL7xFgPOTePO5qpzc=; b=F/QJobC6Jju23iJFpIMnyrP90p0XCRcu7dLF9Tr8s/ugSZ3SsoGsvNJhy5wi6uw6yAk7sf 4AixrqDD5/6vcImKizRG/wKF87W/FRCGQV/KHDbi70gSlAA/xFbwTKo9udiM664AbXD1gV /pWcntNgz/NJ1G773/SguEFEPENXX90r1M+LCAhGk7/4dGGVQdwnZEoXYgUd0+FNdxj3zn d+epYFYmFdbrH7JT5GEUBo1X/FDzdBggygiAMYoSJohmhtWKEuPb8NKUNRhVMH6YXhQnRH k1g7J4p9Y++tt4bZYDeTK5Ob0gFuFivZqTNQEVIIrBgcYiQs8jNWIDh6899TTA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909715; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=lGutETkITAVxGTPxI1jmGIcy6NGL7xFgPOTePO5qpzc=; b=N+2GAs4JSsMSeh1E5Ao+cyC2k0cEe4r9KZB75u9sQ1vmykS+BitTf3bNLjVCBiEN79Jzw5 Faw1BF4PIagbDQAA== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 18/45] genirq/chip: Rework handle_fasteoi_ack_irq() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:14 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new helpers to decide whether the interrupt should be handled and switch the descriptor locking to guard(). Fixup the kernel doc comment while at it. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/chip.c | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -1138,53 +1138,40 @@ void irq_cpu_offline(void) =20 #ifdef CONFIG_IRQ_FASTEOI_HIERARCHY_HANDLERS /** - * handle_fasteoi_ack_irq - irq handler for edge hierarchy - * stacked on transparent controllers + * handle_fasteoi_ack_irq - irq handler for edge hierarchy stacked on + * transparent controllers * - * @desc: the interrupt description structure for this irq + * @desc: the interrupt description structure for this irq * - * Like handle_fasteoi_irq(), but for use with hierarchy where - * the irq_chip also needs to have its ->irq_ack() function - * called. + * Like handle_fasteoi_irq(), but for use with hierarchy where the irq_chip + * also needs to have its ->irq_ack() function called. */ void handle_fasteoi_ack_irq(struct irq_desc *desc) { struct irq_chip *chip =3D desc->irq_data.chip; =20 - raw_spin_lock(&desc->lock); + guard(raw_spinlock)(&desc->lock); =20 - if (!irq_can_handle_pm(desc)) - goto out; - - desc->istate &=3D ~(IRQS_REPLAY | IRQS_WAITING); + if (!irq_can_handle_pm(desc)) { + cond_eoi_irq(chip, &desc->irq_data); + return; + } =20 - /* - * If its disabled or no action available - * then mask it and get out of here: - */ - if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) { - desc->istate |=3D IRQS_PENDING; + if (unlikely(!irq_can_handle_actions(desc))) { mask_irq(desc); - goto out; + cond_eoi_irq(chip, &desc->irq_data); + return; } =20 kstat_incr_irqs_this_cpu(desc); if (desc->istate & IRQS_ONESHOT) mask_irq(desc); =20 - /* Start handling the irq */ desc->irq_data.chip->irq_ack(&desc->irq_data); =20 handle_irq_event(desc); =20 cond_unmask_eoi_irq(desc, chip); - - raw_spin_unlock(&desc->lock); - return; -out: - if (!(chip->flags & IRQCHIP_EOI_IF_HANDLED)) - chip->irq_eoi(&desc->irq_data); - raw_spin_unlock(&desc->lock); } EXPORT_SYMBOL_GPL(handle_fasteoi_ack_irq); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 3EEEA2BCF7A for ; Tue, 29 Apr 2025 06:55:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909719; cv=none; b=JkZJ9trq5shF31bEd6H17Xgq1abdKrRAgWABEfzfLLq7XfIfB6aN5nxyr5XfpLoHYD76Kcjd80gPWRXA8eImpGqWQz9HQ0a6W/Z0RSQOtITgFFCBD+1pYt1ry/pU8vm1RN0GX9hgQtOvF8orebChI95/YyInW07J+asQwb3vL00= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909719; c=relaxed/simple; bh=9vjPmHuG3NR0cykd0xsQqHx6qyFaDhu555aHQFVhs4E=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=ElA/4fbc8Z7/U2EFU23NQZ4mcRZX69uDSh/pV7CAVletRxbOTpTSpWfONX7lbA0G8Uyl5zk+YvVEh6S/62xyCoseBGUHC4ByAwculJW5M9CJS9kt3VWgyjIdjbJOgRUt0m+N3LbIxtn6ahEpByzoXJqV/bU139HLe8OZMKi+A9o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=EfFXVQAB; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=b2AsClC4; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="EfFXVQAB"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="b2AsClC4" Message-ID: <20250429065421.175652864@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909716; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=FioYXungJwAP0LQRkaMmnkXo8H1/6MehVCSXXKb8ffc=; b=EfFXVQAB2YTPX7spVciHCh2sexAEVuPggJJwoWHApWVEAnV+6/U9G848ruO6as1ahS3Vif dZbBRmvyZm9iqaHlcES6BeiMxt6G4Hcb4kryBbO+g+YfmHzNFiG0rHemPKUFnV0eGh73YO 1x2W/Nxc3p3yNeguq0N6brJZCGto5wMITTSqc90Lr+SNblZ3spwtahCZipPG9JeviArvp9 cjr8iHbvzLFdCuaFa3Q0gB3lchLPfDkWDX8G/p0qveY4N8nNApE2Qq0UUVusp0xjsjbui+ YCHwRHuXpOpCHYzaF5Iu2TWmuCaNOXyvm5IIut9YCvKhtL2UYCMsIVmPu9Gwrg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909716; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=FioYXungJwAP0LQRkaMmnkXo8H1/6MehVCSXXKb8ffc=; b=b2AsClC4s5HcR2Xw5QErNH5+EO9WP/UBpXJTD2IA5FmznVmv4KxkDd0c22SDE4p0Dh2i0N YEEron+mPUPkgnAA== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 19/45] genirq/chip: Rework handle_fasteoi_mask_irq() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:16 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new helpers to decide whether the interrupt should be handled and switch the descriptor locking to guard(). Note: The mask_irq() operation in the second condition was redundant as the interrupt is already masked right at the beginning of the function. Fixup the kernel doc comment while at it. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/chip.c | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -1176,51 +1176,31 @@ void handle_fasteoi_ack_irq(struct irq_d EXPORT_SYMBOL_GPL(handle_fasteoi_ack_irq); =20 /** - * handle_fasteoi_mask_irq - irq handler for level hierarchy - * stacked on transparent controllers + * handle_fasteoi_mask_irq - irq handler for level hierarchy stacked on + * transparent controllers * - * @desc: the interrupt description structure for this irq + * @desc: the interrupt description structure for this irq * - * Like handle_fasteoi_irq(), but for use with hierarchy where - * the irq_chip also needs to have its ->irq_mask_ack() function - * called. + * Like handle_fasteoi_irq(), but for use with hierarchy where the irq_chip + * also needs to have its ->irq_mask_ack() function called. */ void handle_fasteoi_mask_irq(struct irq_desc *desc) { struct irq_chip *chip =3D desc->irq_data.chip; =20 - raw_spin_lock(&desc->lock); + guard(raw_spinlock)(&desc->lock); mask_ack_irq(desc); =20 - if (!irq_can_handle_pm(desc)) - goto out; - - desc->istate &=3D ~(IRQS_REPLAY | IRQS_WAITING); - - /* - * If its disabled or no action available - * then mask it and get out of here: - */ - if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) { - desc->istate |=3D IRQS_PENDING; - mask_irq(desc); - goto out; + if (!irq_can_handle(desc)) { + cond_eoi_irq(chip, &desc->irq_data); + return; } =20 kstat_incr_irqs_this_cpu(desc); - if (desc->istate & IRQS_ONESHOT) - mask_irq(desc); =20 handle_irq_event(desc); =20 cond_unmask_eoi_irq(desc, chip); - - raw_spin_unlock(&desc->lock); - return; -out: - if (!(chip->flags & IRQCHIP_EOI_IF_HANDLED)) - chip->irq_eoi(&desc->irq_data); - raw_spin_unlock(&desc->lock); } EXPORT_SYMBOL_GPL(handle_fasteoi_mask_irq); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 13AA02BD5AF for ; Tue, 29 Apr 2025 06:55:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909722; cv=none; b=OxUSe8qfCEmM6KvV1btVj/2p7z+XKPtPg/KzPC8ZGV8BkuE5AICqb/K+xMTl6EkhBEoT/HlzBVpVMdO/xnor/eT64Vn3mBOZLPx2ylPIDwn9t7YXbDIJm7BlBrCM9jGsuQb11HuHeHeKhGG8Mn2vLtYgF+LcoXUUDLZPSQgQZSg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909722; c=relaxed/simple; bh=Zyyn0b8pYfYTNd082gEspst2f0gS5WpoAJ7EljKJ5tU=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=HFLY8avwp5dVlbgfKdP8kq/DejgQR2UXnIYL9nASJbxagdHeGjUjWOKOQSnZWJ1LtZB9LmBPRNKuTq9CbjBAi0DL5oTYgUGtXYgmoGwmRT0+a2R+MMCbXvrZzdfbXVCkV5DXnESFp28Zgmu3y7a30j2Q6svn0uFn0ALLvHb5Xi4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=xf+3+cuX; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=SIJw9+IV; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="xf+3+cuX"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="SIJw9+IV" Message-ID: <20250429065421.236248749@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909718; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=+KV90yNo+Gg1NpgnhoaNuQuxScQl8JaVVsaQRxBDSbM=; b=xf+3+cuXDQpMgYGRdhc9vWIDH3k3PARVie5iqu2iojIhaImjpezQbmZrI2St0o/lw07+Eg KvnIKd6C/D1A27WS8u4PAJkimhKgMAFTcu8nbJXF1tCe6S2eMuQ830tI69585NxQJ7p8R8 wTL48cJ8dk14G+cUEXOAuUuYDMctEfcCUnQyxs0DABCUFNTxaA3YUNtUd3q06Fu48KXMh8 91K3pxIpqRjH6E0BSsBk3+3WP76ncPzuCLNuruHT/JMd0K0xfod6GQYkZRJ5ux70UDZ9K8 vnLAq5idO5Fk6qiDxBdQXSL7yxICfKHrGfm7ivBXKo8vVaA13GLS83iAZViUqw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909718; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=+KV90yNo+Gg1NpgnhoaNuQuxScQl8JaVVsaQRxBDSbM=; b=SIJw9+IVlube8rFlbvNGzjt/e52dNLsT3ljTrBPJdvdqL2Eq6KVj5ACc0wlJKCjszuImXU CBZRa+oKCqoPjFAw== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 20/45] genirq/chip: Use lock guards where applicable References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:17 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert all lock/unlock pairs to guards and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/chip.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -1081,25 +1081,21 @@ EXPORT_SYMBOL_GPL(irq_modify_status); */ void irq_cpu_online(void) { - struct irq_desc *desc; - struct irq_chip *chip; - unsigned long flags; unsigned int irq; =20 for_each_active_irq(irq) { - desc =3D irq_to_desc(irq); + struct irq_desc *desc =3D irq_to_desc(irq); + struct irq_chip *chip; + if (!desc) continue; =20 - raw_spin_lock_irqsave(&desc->lock, flags); - + guard(raw_spinlock_irqsave)(&desc->lock); chip =3D irq_data_get_irq_chip(&desc->irq_data); if (chip && chip->irq_cpu_online && (!(chip->flags & IRQCHIP_ONOFFLINE_ENABLED) || !irqd_irq_disabled(&desc->irq_data))) chip->irq_cpu_online(&desc->irq_data); - - raw_spin_unlock_irqrestore(&desc->lock, flags); } } =20 @@ -1111,25 +1107,21 @@ void irq_cpu_online(void) */ void irq_cpu_offline(void) { - struct irq_desc *desc; - struct irq_chip *chip; - unsigned long flags; unsigned int irq; =20 for_each_active_irq(irq) { - desc =3D irq_to_desc(irq); + struct irq_desc *desc =3D irq_to_desc(irq); + struct irq_chip *chip; + if (!desc) continue; =20 - raw_spin_lock_irqsave(&desc->lock, flags); - + guard(raw_spinlock_irqsave)(&desc->lock); chip =3D irq_data_get_irq_chip(&desc->irq_data); if (chip && chip->irq_cpu_offline && (!(chip->flags & IRQCHIP_ONOFFLINE_ENABLED) || !irqd_irq_disabled(&desc->irq_data))) chip->irq_cpu_offline(&desc->irq_data); - - raw_spin_unlock_irqrestore(&desc->lock, flags); } } #endif From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 826712BD5B3 for ; Tue, 29 Apr 2025 06:55:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909723; cv=none; b=Cx2LS18H/jEaWwOFEe4L9PMCyD2qcuUCrsDVo/H3VtslHzPxYVpiLqJsRZVholk3nxJq6YN0SiF6fYfghU8muVlpHR9w3gWFhvCNthdJ4uZNROj4NfEypYXOlU3v87fu05DixL4HDU+D5DfX70/LFql0fo0w4MG3zVDB37rrtRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909723; c=relaxed/simple; bh=48+VKlH9tu2Xh4CZBWtpL24Y/bts9hBSVsFJXgZcKfY=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=ZHLxySBoPh0oQj9lFi2WvnIFejqbLy/QzYonfPCx6oMNhIdgvrmM6+pxsNxjct4A8wKFAqKEr9LCkE6RIAt7pz5eOflFnSqOOWKAal3iP8NxHNmZ3SANEjEths8Kbo/pdJQte4Ngd40jSPmx1xHJaMMhJM9aEnfn2u77u/Z4yGE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=g0H5VOAB; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=CsO35V/b; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="g0H5VOAB"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="CsO35V/b" Message-ID: <20250429065421.295400891@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909719; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=5NWvdpRY8bOYsaM2bFB6TtpfUvkrriNDslgB4IH7rF4=; b=g0H5VOABiYT8vzBOQo4EsYOGq51MLi7dfwgu3r1O2bTulv/FnwGh4GtYIu1EZWr4EuUQ92 Qe3yaytUUOKC6CSGIkdVrQDBRc3LQf7t8hWF4ESWm4ukYnl03Jz3OF1OMna4y7qgNhrfN0 aosw8XkD3D6bXsgfbv1mNUzZgfgZa1edL6peDW1eL3jBdg+HS9AtPxk2joh+pI/oXZaAHq FZ83MuWKbrlDM0dP2jaPK1QegQbqKGZyVLRCG8iblrq+oHDY3bp4OvfxKZBbxBBd3+IjsY xdBsCoprFfu+TTZxC28smMI5f3SmHohANKUm2xGHXFmmQT3bSBdQeSP8djqYKw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909719; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=5NWvdpRY8bOYsaM2bFB6TtpfUvkrriNDslgB4IH7rF4=; b=CsO35V/bcWQNrM0HPa/HJCsmhORUa4GmZqa30Kj9WUxR+sWFcSa2DnggPOerFROaWH6YqN 9dlE/jCRo0BgD8CA== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 21/45] genirq/chip: Rework irq_set_chip() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:19 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. Fixup the kernel doc comment while at it. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/chip.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -34,26 +34,22 @@ struct irqaction chained_action =3D { }; =20 /** - * irq_set_chip - set the irq chip for an irq - * @irq: irq number - * @chip: pointer to irq chip description structure + * irq_set_chip - set the irq chip for an irq + * @irq: irq number + * @chip: pointer to irq chip description structure */ int irq_set_chip(unsigned int irq, const struct irq_chip *chip) { - unsigned long flags; - struct irq_desc *desc =3D irq_get_desc_lock(irq, &flags, 0); + int ret =3D -EINVAL; =20 - if (!desc) - return -EINVAL; - - desc->irq_data.chip =3D (struct irq_chip *)(chip ?: &no_irq_chip); - irq_put_desc_unlock(desc, flags); - /* - * For !CONFIG_SPARSE_IRQ make the irq show up in - * allocated_irqs. - */ - irq_mark_irq(irq); - return 0; + scoped_irqdesc_get_and_lock(irq, 0) { + scoped_irqdesc->irq_data.chip =3D (struct irq_chip *)(chip ?: &no_irq_ch= ip); + ret =3D 0; + } + /* For !CONFIG_SPARSE_IRQ make the irq show up in allocated_irqs. */ + if (!ret) + irq_mark_irq(irq); + return ret; } EXPORT_SYMBOL(irq_set_chip); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 803322BE0EC for ; Tue, 29 Apr 2025 06:55:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909725; cv=none; b=H3opC25CI8zIN4OXIMwJCq/Z1QTz6p7spXFcYIh2A7nziEMzmRTnl4c9l0BRHJ0oAyxyIJFbPhjLKkvm2uPNos8lYytr9HkonSOwCa0V5lnEeWXMP9yj0PGzvVVV9LqIRXb/uCXwfiyhzisWyo3iudpf6ljVStTQ9Y2oFy3tvwo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909725; c=relaxed/simple; bh=Yuvj5vXczApFsUTUfuq/AFPun9HkDFo5MSzEN/HdA2M=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Sw39NKWkmQy/+buJ0abXjQ/ytnDpJiEipOSYjWqX/rkxYY5BJzI6R+Bto9kjdFrgoGfJf6+7/nEub4ETisspFkoZj0oSb2EOAYvGZwoDv96QdE/UiJQAmKwZhqVjL1by6eHfUUS3g01xdvL4Ueqgtb3s9/pHUqd7Ey8IJM3uftg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=pCx4+HgZ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=eVl3gGU8; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pCx4+HgZ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="eVl3gGU8" Message-ID: <20250429065421.355673840@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909721; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=mBJqPlklc0FYu+2IBvY7En8BpltE37+szQDuVdfinoE=; b=pCx4+HgZ6/T6w8PE3ZoEmVEN3aUeyaipV02ceOJj+V4ech4NkaTEWOPaofU/tMGPT0se5o 6g9Acxa+imcsxCtUKVf3llsQZK9eLZ489rIFlcIWWE0VDzfbhE9ypn/ukpMtbKMT6cEp32 tpz3oZpju7LyXVChStnMR9RK5FkIU0rDVH4Y+udIjD8N0f463PEtc2knpYsNi6GdRGPn7/ /fEB2Ih4Mo/PL+aexS7DQzzO7myoeeQoFa8ddxEF492FK5hDXh6lA5W06vACfIFE97dST8 4pvgnFLotZfmvzcSiMY0P5x/7N3Mdbhwma5iphQTHGOm5UxOuAhscMwwOT2Egw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909721; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=mBJqPlklc0FYu+2IBvY7En8BpltE37+szQDuVdfinoE=; b=eVl3gGU8381JQaz+AgKCYzFfUgHCivD970bhyROOuh5UmJxIFsK8YfpbAPyDA+FCIECRDL EAML/qx+4+HlUUCQ== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 22/45] genirq/chip: Rework irq_set_irq_type() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:20 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. Fixup the kernel doc comment while at it. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/chip.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -54,22 +54,15 @@ int irq_set_chip(unsigned int irq, const EXPORT_SYMBOL(irq_set_chip); =20 /** - * irq_set_irq_type - set the irq trigger type for an irq - * @irq: irq number - * @type: IRQ_TYPE_{LEVEL,EDGE}_* value - see include/linux/irq.h + * irq_set_irq_type - set the irq trigger type for an irq + * @irq: irq number + * @type: IRQ_TYPE_{LEVEL,EDGE}_* value - see include/linux/irq.h */ int irq_set_irq_type(unsigned int irq, unsigned int type) { - unsigned long flags; - struct irq_desc *desc =3D irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_= CHECK_GLOBAL); - int ret =3D 0; - - if (!desc) - return -EINVAL; - - ret =3D __irq_set_trigger(desc, type); - irq_put_desc_busunlock(desc, flags); - return ret; + scoped_irqdesc_get_and_buslock(irq, IRQ_GET_DESC_CHECK_GLOBAL) + return __irq_set_trigger(scoped_irqdesc, type); + return -EINVAL; } EXPORT_SYMBOL(irq_set_irq_type); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 1D7AC2BE0F6 for ; Tue, 29 Apr 2025 06:55:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909725; cv=none; b=kd25Uxn1C4vIIHaGkAg+1bE05PeU6d0oWFI0JF09MbcdIOg0+Kd2/Cp3HbglgS9y5QXYGIR7i4OPU2I6vDjkGMD1GUlCuBb4l0KVTyCQaMaVxIGrtDxwyeaHDl+lw62gKoVFp2qST+jRS7VoXQ177RP+d5sDcavNw1Mebi3HcgI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909725; c=relaxed/simple; bh=WnaFCQNi32Ga6a3ETJu1H0bGRqKZ2xjzvnigGEf+zKw=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=J+MvuNd8ougA0xXcAC01KHtbmHGMgXHyzWtpnzUoD5BERxfgdgcb7zYsyJ4gexCjjEmFJ/w35Gdc9yx+qs/Ut6zxmnD5bM+UaPlJ7SRgK1oXdzVDxGtTtg3SE0VUKqEIv61rpJO+TFzx5dfbObtl+u2ybnFvGcQ9JgdHn7WYaLE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=PegEv+8f; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Szd7QekR; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="PegEv+8f"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Szd7QekR" Message-ID: <20250429065421.415072350@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909722; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=BRLQLQgqt1HIYMINIP9eLa5+g/xohe4V4/YURrXVr3A=; b=PegEv+8fj9Cq52bAWee4Q2CecG0qam6JFntVsU6BFJCrU/w+GoWRnE4y8sZVEf5G2BY1de aybY+ZgVtiKGNmHhG86DXGzMLRVKHKxKxKmGk54hO+gbpfRRGbTUwUbWc8pddzfGeblTr2 CgO4yOxVqGkDr47UW8DLddD3G3BWbn62yUg4zyJQD29nabbtwwZhnhWr5n3beKJGZxtbjP KoJf33P0HIMzvdFJA1bEl/PvWCPYa5QAm1tW1iEgy2dfsglVzCpy4O0K/xQFcezL4hZA2N uuRKeg/BhUvaS2NG+FcLsyL9dvAOf1JKPnUQIsZ/CfOpZi+3LBQhWNn3FDM4dA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909722; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=BRLQLQgqt1HIYMINIP9eLa5+g/xohe4V4/YURrXVr3A=; b=Szd7QekRIvgBYI0DpCqVqspDJbuJftOrgQDGC6subMi6RwhsVfhIiPT8YIVk3PLGFUEb6/ dp7Zd++Y9C8FpTCg== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 23/45] genirq/chip: Rework irq_set_handler_data() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:22 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. Fixup the kernel doc comment while at it. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/chip.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -67,22 +67,19 @@ int irq_set_irq_type(unsigned int irq, u EXPORT_SYMBOL(irq_set_irq_type); =20 /** - * irq_set_handler_data - set irq handler data for an irq - * @irq: Interrupt number - * @data: Pointer to interrupt specific data + * irq_set_handler_data - set irq handler data for an irq + * @irq: Interrupt number + * @data: Pointer to interrupt specific data * - * Set the hardware irq controller data for an irq + * Set the hardware irq controller data for an irq */ int irq_set_handler_data(unsigned int irq, void *data) { - unsigned long flags; - struct irq_desc *desc =3D irq_get_desc_lock(irq, &flags, 0); - - if (!desc) - return -EINVAL; - desc->irq_common_data.handler_data =3D data; - irq_put_desc_unlock(desc, flags); - return 0; + scoped_irqdesc_get_and_lock(irq, 0) { + scoped_irqdesc->irq_common_data.handler_data =3D data; + return 0; + } + return -EINVAL; } EXPORT_SYMBOL(irq_set_handler_data); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 D072F2BE11C for ; Tue, 29 Apr 2025 06:55:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909727; cv=none; b=Q3IVlezpdiabw2X+8EH0mJ4jsAuAwT+AADxijLgbLDAP4TIYuKSKCNjntLdT/ryzq5o2wSVkCH+GV2LxoSf3Ai7FBCQ1K8mnfhL1uqT55gk/dbVMVO5FrXNvmB0i3U4lz0b779XOL9/rTWFREXFgjRwRRCKfYM7LgcVXQ5Ki6Uc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909727; c=relaxed/simple; bh=kYrW1aCSFM7d/LAfW4csVW3fqi0jntKr26U57f80Ii0=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=A1V511UEnevTWKSRXO2KDRq4Whye2qv0QoL4ieziGAA3olCPtUeD4F+8+bqIJdMF2ksIg0KxZQ/Az323MBI3bJviPYMmX1gd7SeuYM8IrQsfVtOMFUXwI/qryNqd3kadtimdC3vvhx4lT5osuOynT7FNRKlUo59/whlCkAgEVr8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Dg1UKJ09; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=t6WAxPAF; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Dg1UKJ09"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="t6WAxPAF" Message-ID: <20250429065421.473563978@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909724; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=++AIhjmIh0ASRd6AQRmDvZEsMS+B3sfFmYcYg6SfaIM=; b=Dg1UKJ09A5YX6kSkSrDqFuHNQSEKpOXU4UxPJPayMaSD5deFTfBd/uBGE+1fkY63pL9Zma 9lx6wyXTKEPPyqIz98gEqP36ZGq+HatibSGPRbMr1jaj+86QURSiArKCK8EJY2ur2EXJn6 IazkbkkKYmbcmaAgx/qZxa15edVXLQ7cfYBbx51iyzJNQDWRB0qsVznYRQEi25Uy+1Ugf9 h2cLjrU/0+vXdHa89qKHtmL4iSYQ/vSH9w1CazEKQGUDJMbrXTCW+T1lCdByPM+cXu1ITt um+D4dSX1N+rqNqnlDWj76YHmM/eVzXMoKWOoOgwptaibx7NPP6vqQ8umwLNpA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909724; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=++AIhjmIh0ASRd6AQRmDvZEsMS+B3sfFmYcYg6SfaIM=; b=t6WAxPAFK1KI76THRYboxKnfD+SudvvtnruVUwf379BtVkExbf6VEgSPvaiziacwpLfB2U VUc0MYMgRY5P7tDA== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 24/45] genirq/chip: Rework irq_set_msi_desc_off() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:23 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. Fixup the kernel doc comment while at it. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/chip.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -84,34 +84,30 @@ int irq_set_handler_data(unsigned int ir EXPORT_SYMBOL(irq_set_handler_data); =20 /** - * irq_set_msi_desc_off - set MSI descriptor data for an irq at offset - * @irq_base: Interrupt number base - * @irq_offset: Interrupt number offset - * @entry: Pointer to MSI descriptor data + * irq_set_msi_desc_off - set MSI descriptor data for an irq at offset + * @irq_base: Interrupt number base + * @irq_offset: Interrupt number offset + * @entry: Pointer to MSI descriptor data * - * Set the MSI descriptor entry for an irq at offset + * Set the MSI descriptor entry for an irq at offset */ -int irq_set_msi_desc_off(unsigned int irq_base, unsigned int irq_offset, - struct msi_desc *entry) +int irq_set_msi_desc_off(unsigned int irq_base, unsigned int irq_offset, s= truct msi_desc *entry) { - unsigned long flags; - struct irq_desc *desc =3D irq_get_desc_lock(irq_base + irq_offset, &flags= , IRQ_GET_DESC_CHECK_GLOBAL); - - if (!desc) - return -EINVAL; - desc->irq_common_data.msi_desc =3D entry; - if (entry && !irq_offset) - entry->irq =3D irq_base; - irq_put_desc_unlock(desc, flags); - return 0; + scoped_irqdesc_get_and_lock(irq_base + irq_offset, IRQ_GET_DESC_CHECK_GLO= BAL) { + scoped_irqdesc->irq_common_data.msi_desc =3D entry; + if (entry && !irq_offset) + entry->irq =3D irq_base; + return 0; + } + return -EINVAL; } =20 /** - * irq_set_msi_desc - set MSI descriptor data for an irq - * @irq: Interrupt number - * @entry: Pointer to MSI descriptor data + * irq_set_msi_desc - set MSI descriptor data for an irq + * @irq: Interrupt number + * @entry: Pointer to MSI descriptor data * - * Set the MSI descriptor entry for an irq + * Set the MSI descriptor entry for an irq */ int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry) { From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 9082B2BE7BD for ; Tue, 29 Apr 2025 06:55:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909729; cv=none; b=myir7Vci60XSfP1iQt7oRWJN27KCoYFt9f85uz7BErgL3bnc4+XtRgB56B8TG+4RyCOp3kh9A0NGG9IQ65M3uZgbfl9UbdxndYOJcqMp5qhu/NmOtnuuywgpadrEe6KL5kPo/xP+gK8KesnX3C+3nkfsmLBcVtRkplJpXoEzsNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909729; c=relaxed/simple; bh=/xFqWxDOQcLY5sARogn1L8CamXbgGc5iEeMfrjVgUhw=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=rX5wv4B3pguyxGqZdycLY3iWaaKfA3o7+50fQKHM9s+eoWS/tuzKC/IQ/LFYqQH1aNMnyOYvrm+dAMNMlBX7RSfZu3uN3vkB/ygifCgUx/pD2L2wWqG7SXxJyE7cggFglt01XqNdSyylbX9NTRHwXvbbODc84g8aWU1wGNlfVs4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=J6AQIgvz; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=2Jl9laiI; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="J6AQIgvz"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="2Jl9laiI" Message-ID: <20250429065421.532308759@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909725; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=dawquaW1ByrXorIP1SoqONqlwfMGSrQIBJriFwabwNQ=; b=J6AQIgvzamqvO/pClcTpPJ+1Vufdm11/qr7IWT2OroAoEmuoR+j6qDUMhX3yfnCAos4ZBc Xdv7aPnI/UwjQc+BCK2+QK4G2ciL0Yk9FiPHW+nZhaLelCk6ageQRxRpfhmmch+XoeYUfG X/JsOgHLlovrCHOHtmJ6/izigs5RxSRTmYEhE+6DHgjFHQFJeiMr6lRlqt/Joc18+pJ2aq /kRhnBDfmrYbLcABhnUYrM+MkQEFjatzRadQsJdzcGkWgNznBwosn8RXFWHo1YIFWEpxJ0 LoYBZY8kH5Snm20AN+px587E1Kq384fW4Rtnx8CJAyMOmJp4hXBjip3RRLMr5g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909725; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=dawquaW1ByrXorIP1SoqONqlwfMGSrQIBJriFwabwNQ=; b=2Jl9laiIqnruA5fbLkQ0qD5jUGJ6Mq5XhkpLsHNQGVIZtTM6pQdO35T92zSmrDrkXHV8ut 09LuNwDecVLT9fCA== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 25/45] genirq/chip: Rework irq_set_chip_data() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:25 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. Fixup the kernel doc comment while at it. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/chip.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -115,22 +115,19 @@ int irq_set_msi_desc(unsigned int irq, s } =20 /** - * irq_set_chip_data - set irq chip data for an irq - * @irq: Interrupt number - * @data: Pointer to chip specific data + * irq_set_chip_data - set irq chip data for an irq + * @irq: Interrupt number + * @data: Pointer to chip specific data * - * Set the hardware irq chip data for an irq + * Set the hardware irq chip data for an irq */ int irq_set_chip_data(unsigned int irq, void *data) { - unsigned long flags; - struct irq_desc *desc =3D irq_get_desc_lock(irq, &flags, 0); - - if (!desc) - return -EINVAL; - desc->irq_data.chip_data =3D data; - irq_put_desc_unlock(desc, flags); - return 0; + scoped_irqdesc_get_and_lock(irq, 0) { + scoped_irqdesc->irq_data.chip_data =3D data; + return 0; + } + return -EINVAL; } EXPORT_SYMBOL(irq_set_chip_data); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 988AC2BE7CF for ; Tue, 29 Apr 2025 06:55:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909730; cv=none; b=i7KMAnpAGOWR5L1h/hxvM2xOLIqDlHDkzATyd/acZlPFaxPWHNwyc23HzE5jjvBIrn9No7tQrUL7TzenYjjT3BPpNvEN6TQ38Ak+y2B6ftGZ6NvfUQWkmg4vi9soP8ZEz1eJhqTG2+AZPq7MFRudjQlLPiG1kYs5EleqOxmUN3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909730; c=relaxed/simple; bh=fsBTkKRPpH+5EGM8jon02QuU9oxuKW8qdaYnPm2x5CU=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=U0sx7A3X1RgJT++6q3yf81L71MRx3F7mJj0VAXWopxyJuOx0zkNY4Itkm42Cvx4t4rXc2dZTjiC3m+M37wzg9Bzv7ufKin3mEL7OTesomDvZvJAceTbGE7nOlBPZz5m5NMkf4THjxJBib1P45OzMVYqdC+DkksFb8Pto/+/Zlpk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Lo2XaxJL; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=bM6/BKLZ; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Lo2XaxJL"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="bM6/BKLZ" Message-ID: <20250429065421.590753128@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909727; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=5k0UxYxBzX3GM/fq2LsOBR7xYTZrMu1uT7QHB/rdNx0=; b=Lo2XaxJLY8oyozrFmzF+QgZD5OroumDvFE7I6sQI1+vgfJglMOeJfhn2ozDRjX75e7QVKb fnp9kRUYn0ZfVRXg6d2ajchVSQF2KGtExiOabHVzIo3fRTn6TrC1dZzvw5z37XVoqAyvv9 22I8m5yp/TNGrg2RY4uRcRZOeKxpEJtDOWpxDKFdFmLAl3158ACRUd3TztWH+RmHQ919yG WoYooCmQ5mPeEhQP48bkDJhAU/CwsO61vWMN2Xvyndr9wJS/CW3FWbFvatTQuXHvk8M7dD b3PYV/ha6vWuSuJjKRqE+RlE8l1zRZJxBpRhoUO4qSKYoFRcS/Q3mDO++LM11Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909727; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=5k0UxYxBzX3GM/fq2LsOBR7xYTZrMu1uT7QHB/rdNx0=; b=bM6/BKLZo3CC5EozKTcBtLfLdttKur7UUPc2iowjj9rpMiL7xTScvhVogvZ23sjdMb98+h PKPiBvmzK76mYDDQ== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 26/45] genirq/chip: Rework irq_set_handler() variants References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:26 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. Fixup the kernel doc comment while at it. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/chip.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -973,35 +973,23 @@ static void } } =20 -void -__irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chai= ned, - const char *name) +void __irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is= _chained, + const char *name) { - unsigned long flags; - struct irq_desc *desc =3D irq_get_desc_buslock(irq, &flags, 0); - - if (!desc) - return; - - __irq_do_set_handler(desc, handle, is_chained, name); - irq_put_desc_busunlock(desc, flags); + scoped_irqdesc_get_and_lock(irq, 0) + __irq_do_set_handler(scoped_irqdesc, handle, is_chained, name); } EXPORT_SYMBOL_GPL(__irq_set_handler); =20 -void -irq_set_chained_handler_and_data(unsigned int irq, irq_flow_handler_t hand= le, - void *data) +void irq_set_chained_handler_and_data(unsigned int irq, irq_flow_handler_t= handle, + void *data) { - unsigned long flags; - struct irq_desc *desc =3D irq_get_desc_buslock(irq, &flags, 0); - - if (!desc) - return; + scoped_irqdesc_get_and_buslock(irq, 0) { + struct irq_desc *desc =3D scoped_irqdesc; =20 - desc->irq_common_data.handler_data =3D data; - __irq_do_set_handler(desc, handle, 1, NULL); - - irq_put_desc_busunlock(desc, flags); + desc->irq_common_data.handler_data =3D data; + __irq_do_set_handler(desc, handle, 1, NULL); + } } EXPORT_SYMBOL_GPL(irq_set_chained_handler_and_data); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 9FD8D2BEC2F for ; Tue, 29 Apr 2025 06:55:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909732; cv=none; b=eZe/SxEWEvECGlkNo2YQhs5b0QbpfgHdCeryGUNhy7UoQpfSEM5u4EJU9xb2z1pNY+phdqfYnKFAYSjewP6Qi3uv6wXOlPMKo/32o1sDK60ck/nWAYuaIx6EMWQAZcUgfXZMxiTObM5gfB+Dn3QM9YZ6fBFnyrQgaTj+TNV3n4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909732; c=relaxed/simple; bh=bvApdSitIIcDFjuPFEEzU1FSqU95bWDNnJJJe2q6exs=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Up5IsOuIGZOXbHmw9kn0StscUnsbYTbqjsiRchh/R6lp69zmQ3WbkFPD4RPbxw/ZG9FfZvQQ1AVDgsZyDWxW4xmPo1fiHKYng2MVAY9JX/z5+imExgzypKXEfR00rprOXVu5bPXRiaWOWisLYaxWLIfqNFno2Q4HIWzv8jEF8PE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=tjmxrlV8; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=fffWh6cd; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="tjmxrlV8"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fffWh6cd" Message-ID: <20250429065421.650454052@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909728; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=cYWKdRXEr+TFQ30HnuL3MaDMsBDCslh0hKjVi8Z4UC4=; b=tjmxrlV8xiE2BeyDEopWrIP2Sv3gu7LaxVx+ca+cXh7D0HYbRwPCHDRvMNhOH7XjzMa088 LlJYfsFxyZWF/yDzf+inzasm3YKo32ZOBOGlFwn12a8QW7cbHryAEMLhRBVOGP/KF90yAl ngnjiza75HG+CZ/5LdRFFTHU3BefQVxOrRVCRl3ahDz+ivOCNrUX7ON1ZnNn+NTtW4KKh6 U8r3DxDxL05yn6mSFQtyKiq6P1f9nf7dXzlAYdGs9pDWIUZD6Venfh6lp0CJ4AgSGwdygx fpYSCfPtXqkcE+gF+0BeDOrrCs4gbMr5ViRbcIibbAlBl1a0NjYWa8QYn68zUA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909728; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=cYWKdRXEr+TFQ30HnuL3MaDMsBDCslh0hKjVi8Z4UC4=; b=fffWh6cdHlqftSlCRWyzwsPOYkylD8p9POYyFwhR4Tc6+JNwVpKQQbPwWEYm9aABdjEBBY Ganu2VN+RXPv2cDg== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 27/45] genirq/chip: Rework irq_modify_status() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:28 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. Fixup the kernel doc comment while at it. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/chip.c | 58 +++++++++++++++++++++++++------------------------= ----- 1 file changed, 27 insertions(+), 31 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -1004,38 +1004,34 @@ EXPORT_SYMBOL_GPL(irq_set_chip_and_handl =20 void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long = set) { - unsigned long flags, trigger, tmp; - struct irq_desc *desc =3D irq_get_desc_lock(irq, &flags, 0); + scoped_irqdesc_get_and_lock(irq, 0) { + struct irq_desc *desc =3D scoped_irqdesc; + unsigned long trigger, tmp; + /* + * Warn when a driver sets the no autoenable flag on an already + * active interrupt. + */ + WARN_ON_ONCE(!desc->depth && (set & _IRQ_NOAUTOEN)); + + irq_settings_clr_and_set(desc, clr, set); + + trigger =3D irqd_get_trigger_type(&desc->irq_data); + + irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU | + IRQD_TRIGGER_MASK | IRQD_LEVEL); + if (irq_settings_has_no_balance_set(desc)) + irqd_set(&desc->irq_data, IRQD_NO_BALANCING); + if (irq_settings_is_per_cpu(desc)) + irqd_set(&desc->irq_data, IRQD_PER_CPU); + if (irq_settings_is_level(desc)) + irqd_set(&desc->irq_data, IRQD_LEVEL); + + tmp =3D irq_settings_get_trigger_mask(desc); + if (tmp !=3D IRQ_TYPE_NONE) + trigger =3D tmp; =20 - if (!desc) - return; - - /* - * Warn when a driver sets the no autoenable flag on an already - * active interrupt. - */ - WARN_ON_ONCE(!desc->depth && (set & _IRQ_NOAUTOEN)); - - irq_settings_clr_and_set(desc, clr, set); - - trigger =3D irqd_get_trigger_type(&desc->irq_data); - - irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU | - IRQD_TRIGGER_MASK | IRQD_LEVEL); - if (irq_settings_has_no_balance_set(desc)) - irqd_set(&desc->irq_data, IRQD_NO_BALANCING); - if (irq_settings_is_per_cpu(desc)) - irqd_set(&desc->irq_data, IRQD_PER_CPU); - if (irq_settings_is_level(desc)) - irqd_set(&desc->irq_data, IRQD_LEVEL); - - tmp =3D irq_settings_get_trigger_mask(desc); - if (tmp !=3D IRQ_TYPE_NONE) - trigger =3D tmp; - - irqd_set(&desc->irq_data, trigger); - - irq_put_desc_unlock(desc, flags); + irqd_set(&desc->irq_data, trigger); + } } EXPORT_SYMBOL_GPL(irq_modify_status); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 1548C2BE7BD for ; Tue, 29 Apr 2025 06:55:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909734; cv=none; b=pFMHXQzZtdq6nUQ4lo/THUS0qHoaJyIJmFs6xCG8thbHga0a0c8f2cPXzFBYymtgLdi+EsEgVHRPEZxEbXGIS9Yi+PgAhm/ioyUSpO6AZeRBOu6sVLzmVx5G1sMniT+ZAkRhv2OkWZju9cqIUT9nPjXqMTXjhgJ4LIW9InH71h0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909734; c=relaxed/simple; bh=F+KbE8WDzlGqmL0lMPRM8PnONEay3eFfoaYBog3X79M=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=F3UzekTc4z4RR2ce1b9gWmCmNpXsUltlBjubZcXB0Cew2Zbbr1bL0Uc+hyhvgJplBUKEontXT4fLb1jyufl59GlR+2Hr0hPVsda1R6VYQ3SLjvv599BwEV6jq3nTYZbQHW2fr0YXkqVEbpsWEDe/hVGiJNTxiWEUsWb97i5M3ac= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=XET/3dx5; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=oX/Gu2Ok; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="XET/3dx5"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="oX/Gu2Ok" Message-ID: <20250429065421.710273122@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909730; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=6bbgmFrbvvso3BhsFboBC2Lf92/eSSJ+PHsB7wnwxrk=; b=XET/3dx5OXNoIv12wJKl3LdQEi+L6VMHlWxtM6p/xN2G05QkCiNQKP6SuEVWNHdAFl6Y8L TiQbtP2qJoLrCbm2pSGaN0f/6lSSjSa+ui8mY2CaQ2KlEadHFsr8829XCLA/+As+ylyDNQ TR8KVGWYhieVDzAFOeL+HDEa3ziWXt8GhMtgM5JVDbRqYyJ+D26/dvyooVEoNn6ajq4GTC mHBoCrW6O9a77CrRAvI3AkAZiTd3BqWCdtyY9I217xfgr/HMNjos6/slVoCzMIs4TL1kv2 3+2V0j9g3VNL7lD3y7RCmJ0P5BdN68ywZzoYTNmexLITsjOpaFwxYQCm2dN0yQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909730; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=6bbgmFrbvvso3BhsFboBC2Lf92/eSSJ+PHsB7wnwxrk=; b=oX/Gu2Okb+bftrWvnYa9BOw2rJlO7Mwz1794SA4PeBOVqrv/GBh/3NPVqi3nrqLrR66d5t OpLAZRHOu+1xZyCA== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 28/45] genirq/manage: Cleanup kernel doc comments References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:29 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Get rid of the extra tab to make it consistent. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/manage.c | 570 +++++++++++++++++++++++++----------------------= ----- 1 file changed, 276 insertions(+), 294 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -76,26 +76,25 @@ static void __synchronize_hardirq(struct } =20 /** - * synchronize_hardirq - wait for pending hard IRQ handlers (on other CPUs) - * @irq: interrupt number to wait for + * synchronize_hardirq - wait for pending hard IRQ handlers (on other CPUs) + * @irq: interrupt number to wait for * - * This function waits for any pending hard IRQ handlers for this - * interrupt to complete before returning. If you use this - * function while holding a resource the IRQ handler may need you - * will deadlock. It does not take associated threaded handlers - * into account. - * - * Do not use this for shutdown scenarios where you must be sure - * that all parts (hardirq and threaded handler) have completed. - * - * Returns: false if a threaded handler is active. - * - * This function may be called - with care - from IRQ context. - * - * It does not check whether there is an interrupt in flight at the - * hardware level, but not serviced yet, as this might deadlock when - * called with interrupts disabled and the target CPU of the interrupt - * is the current CPU. + * This function waits for any pending hard IRQ handlers for this interrupt + * to complete before returning. If you use this function while holding a + * resource the IRQ handler may need you will deadlock. It does not take + * associated threaded handlers into account. + * + * Do not use this for shutdown scenarios where you must be sure that all + * parts (hardirq and threaded handler) have completed. + * + * Returns: false if a threaded handler is active. + * + * This function may be called - with care - from IRQ context. + * + * It does not check whether there is an interrupt in flight at the + * hardware level, but not serviced yet, as this might deadlock when called + * with interrupts disabled and the target CPU of the interrupt is the + * current CPU. */ bool synchronize_hardirq(unsigned int irq) { @@ -121,19 +120,19 @@ static void __synchronize_irq(struct irq } =20 /** - * synchronize_irq - wait for pending IRQ handlers (on other CPUs) - * @irq: interrupt number to wait for + * synchronize_irq - wait for pending IRQ handlers (on other CPUs) + * @irq: interrupt number to wait for * - * This function waits for any pending IRQ handlers for this interrupt - * to complete before returning. If you use this function while - * holding a resource the IRQ handler may need you will deadlock. - * - * Can only be called from preemptible code as it might sleep when - * an interrupt thread is associated to @irq. - * - * It optionally makes sure (when the irq chip supports that method) - * that the interrupt is not pending in any CPU and waiting for - * service. + * This function waits for any pending IRQ handlers for this interrupt to + * complete before returning. If you use this function while holding a + * resource the IRQ handler may need you will deadlock. + * + * Can only be called from preemptible code as it might sleep when + * an interrupt thread is associated to @irq. + * + * It optionally makes sure (when the irq chip supports that method) + * that the interrupt is not pending in any CPU and waiting for + * service. */ void synchronize_irq(unsigned int irq) { @@ -156,8 +155,8 @@ static bool __irq_can_set_affinity(struc } =20 /** - * irq_can_set_affinity - Check if the affinity of a given irq can be set - * @irq: Interrupt to check + * irq_can_set_affinity - Check if the affinity of a given irq can be set + * @irq: Interrupt to check * */ int irq_can_set_affinity(unsigned int irq) @@ -181,13 +180,13 @@ bool irq_can_set_affinity_usr(unsigned i } =20 /** - * irq_set_thread_affinity - Notify irq threads to adjust affinity - * @desc: irq descriptor which has affinity changed + * irq_set_thread_affinity - Notify irq threads to adjust affinity + * @desc: irq descriptor which has affinity changed * - * We just set IRQTF_AFFINITY and delegate the affinity setting - * to the interrupt thread itself. We can not call - * set_cpus_allowed_ptr() here as we hold desc->lock and this - * code can be called from hard interrupt context. + * Just set IRQTF_AFFINITY and delegate the affinity setting to the + * interrupt thread itself. We can not call set_cpus_allowed_ptr() here as + * we hold desc->lock and this code can be called from hard interrupt + * context. */ static void irq_set_thread_affinity(struct irq_desc *desc) { @@ -543,18 +542,17 @@ static void irq_affinity_notify(struct w } =20 /** - * irq_set_affinity_notifier - control notification of IRQ affinity changes - * @irq: Interrupt for which to enable/disable notification - * @notify: Context for notification, or %NULL to disable - * notification. Function pointers must be initialised; - * the other fields will be initialised by this function. - * - * Must be called in process context. Notification may only be enabled - * after the IRQ is allocated and must be disabled before the IRQ is - * freed using free_irq(). + * irq_set_affinity_notifier - control notification of IRQ affinity changes + * @irq: Interrupt for which to enable/disable notification + * @notify: Context for notification, or %NULL to disable + * notification. Function pointers must be initialised; + * the other fields will be initialised by this function. + * + * Must be called in process context. Notification may only be enabled + * after the IRQ is allocated and must be disabled before the IRQ is freed + * using free_irq(). */ -int -irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *no= tify) +int irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify= *notify) { struct irq_desc *desc =3D irq_to_desc(irq); struct irq_affinity_notify *old_notify; @@ -645,15 +643,14 @@ int irq_setup_affinity(struct irq_desc * =20 =20 /** - * irq_set_vcpu_affinity - Set vcpu affinity for the interrupt - * @irq: interrupt number to set affinity - * @vcpu_info: vCPU specific data or pointer to a percpu array of vCPU - * specific data for percpu_devid interrupts - * - * This function uses the vCPU specific data to set the vCPU - * affinity for an irq. The vCPU specific data is passed from - * outside, such as KVM. One example code path is as below: - * KVM -> IOMMU -> irq_set_vcpu_affinity(). + * irq_set_vcpu_affinity - Set vcpu affinity for the interrupt + * @irq: interrupt number to set affinity + * @vcpu_info: vCPU specific data or pointer to a percpu array of vCPU + * specific data for percpu_devid interrupts + * + * This function uses the vCPU specific data to set the vCPU affinity for + * an irq. The vCPU specific data is passed from outside, such as KVM. One + * example code path is as below: KVM -> IOMMU -> irq_set_vcpu_affinity(). */ int irq_set_vcpu_affinity(unsigned int irq, void *vcpu_info) { @@ -705,15 +702,15 @@ static int __disable_irq_nosync(unsigned } =20 /** - * disable_irq_nosync - disable an irq without waiting - * @irq: Interrupt to disable + * disable_irq_nosync - disable an irq without waiting + * @irq: Interrupt to disable * - * Disable the selected interrupt line. Disables and Enables are - * nested. - * Unlike disable_irq(), this function does not ensure existing - * instances of the IRQ handler have completed before returning. + * Disable the selected interrupt line. Disables and Enables are + * nested. + * Unlike disable_irq(), this function does not ensure existing + * instances of the IRQ handler have completed before returning. * - * This function may be called from IRQ context. + * This function may be called from IRQ context. */ void disable_irq_nosync(unsigned int irq) { @@ -722,17 +719,17 @@ void disable_irq_nosync(unsigned int irq EXPORT_SYMBOL(disable_irq_nosync); =20 /** - * disable_irq - disable an irq and wait for completion - * @irq: Interrupt to disable + * disable_irq - disable an irq and wait for completion + * @irq: Interrupt to disable + * + * Disable the selected interrupt line. Enables and Disables are nested. * - * Disable the selected interrupt line. Enables and Disables are - * nested. - * This function waits for any pending IRQ handlers for this interrupt - * to complete before returning. If you use this function while - * holding a resource the IRQ handler may need you will deadlock. + * This function waits for any pending IRQ handlers for this interrupt to + * complete before returning. If you use this function while holding a + * resource the IRQ handler may need you will deadlock. * - * Can only be called from preemptible code as it might sleep when - * an interrupt thread is associated to @irq. + * Can only be called from preemptible code as it might sleep when an + * interrupt thread is associated to @irq. * */ void disable_irq(unsigned int irq) @@ -744,40 +741,39 @@ void disable_irq(unsigned int irq) EXPORT_SYMBOL(disable_irq); =20 /** - * disable_hardirq - disables an irq and waits for hardirq completion - * @irq: Interrupt to disable + * disable_hardirq - disables an irq and waits for hardirq completion + * @irq: Interrupt to disable * - * Disable the selected interrupt line. Enables and Disables are - * nested. - * This function waits for any pending hard IRQ handlers for this - * interrupt to complete before returning. If you use this function while - * holding a resource the hard IRQ handler may need you will deadlock. + * Disable the selected interrupt line. Enables and Disables are nested. * - * When used to optimistically disable an interrupt from atomic context - * the return value must be checked. + * This function waits for any pending hard IRQ handlers for this interrupt + * to complete before returning. If you use this function while holding a + * resource the hard IRQ handler may need you will deadlock. * - * Returns: false if a threaded handler is active. + * When used to optimistically disable an interrupt from atomic context the + * return value must be checked. * - * This function may be called - with care - from IRQ context. + * Returns: false if a threaded handler is active. + * + * This function may be called - with care - from IRQ context. */ bool disable_hardirq(unsigned int irq) { if (!__disable_irq_nosync(irq)) return synchronize_hardirq(irq); - return false; } EXPORT_SYMBOL_GPL(disable_hardirq); =20 /** - * disable_nmi_nosync - disable an nmi without waiting - * @irq: Interrupt to disable + * disable_nmi_nosync - disable an nmi without waiting + * @irq: Interrupt to disable + * + * Disable the selected interrupt line. Disables and enables are nested. * - * Disable the selected interrupt line. Disables and enables are - * nested. - * The interrupt to disable must have been requested through request_nmi. - * Unlike disable_nmi(), this function does not ensure existing - * instances of the IRQ handler have completed before returning. + * The interrupt to disable must have been requested through request_nmi. + * Unlike disable_nmi(), this function does not ensure existing + * instances of the IRQ handler have completed before returning. */ void disable_nmi_nosync(unsigned int irq) { @@ -817,15 +813,14 @@ void __enable_irq(struct irq_desc *desc) } =20 /** - * enable_irq - enable handling of an irq - * @irq: Interrupt to enable + * enable_irq - enable handling of an irq + * @irq: Interrupt to enable * - * Undoes the effect of one call to disable_irq(). If this - * matches the last disable, processing of interrupts on this - * IRQ line is re-enabled. + * Undoes the effect of one call to disable_irq(). If this matches the + * last disable, processing of interrupts on this IRQ line is re-enabled. * - * This function may be called from IRQ context only when - * desc->irq_data.chip->bus_lock and desc->chip->bus_sync_unlock are NULL ! + * This function may be called from IRQ context only when + * desc->irq_data.chip->bus_lock and desc->chip->bus_sync_unlock are NULL ! */ void enable_irq(unsigned int irq) { @@ -845,13 +840,12 @@ void enable_irq(unsigned int irq) EXPORT_SYMBOL(enable_irq); =20 /** - * enable_nmi - enable handling of an nmi - * @irq: Interrupt to enable + * enable_nmi - enable handling of an nmi + * @irq: Interrupt to enable * - * The interrupt to enable must have been requested through request_nmi. - * Undoes the effect of one call to disable_nmi(). If this - * matches the last disable, processing of interrupts on this - * IRQ line is re-enabled. + * The interrupt to enable must have been requested through request_nmi. + * Undoes the effect of one call to disable_nmi(). If this matches the last + * disable, processing of interrupts on this IRQ line is re-enabled. */ void enable_nmi(unsigned int irq) { @@ -873,23 +867,22 @@ static int set_irq_wake_real(unsigned in } =20 /** - * irq_set_irq_wake - control irq power management wakeup - * @irq: interrupt to control - * @on: enable/disable power management wakeup - * - * Enable/disable power management wakeup mode, which is - * disabled by default. Enables and disables must match, - * just as they match for non-wakeup mode support. - * - * Wakeup mode lets this IRQ wake the system from sleep - * states like "suspend to RAM". - * - * Note: irq enable/disable state is completely orthogonal - * to the enable/disable state of irq wake. An irq can be - * disabled with disable_irq() and still wake the system as - * long as the irq has wake enabled. If this does not hold, - * then the underlying irq chip and the related driver need - * to be investigated. + * irq_set_irq_wake - control irq power management wakeup + * @irq: interrupt to control + * @on: enable/disable power management wakeup + * + * Enable/disable power management wakeup mode, which is disabled by + * default. Enables and disables must match, just as they match for + * non-wakeup mode support. + * + * Wakeup mode lets this IRQ wake the system from sleep states like + * "suspend to RAM". + * + * Note: irq enable/disable state is completely orthogonal to the + * enable/disable state of irq wake. An irq can be disabled with + * disable_irq() and still wake the system as long as the irq has wake + * enabled. If this does not hold, then the underlying irq chip and the + * related driver need to be investigated. */ int irq_set_irq_wake(unsigned int irq, unsigned int on) { @@ -1334,10 +1327,9 @@ static int irq_thread(void *data) } =20 /** - * irq_wake_thread - wake the irq thread for the action identified by dev_= id - * @irq: Interrupt line - * @dev_id: Device identity for which the thread should be woken - * + * irq_wake_thread - wake the irq thread for the action identified by dev_= id + * @irq: Interrupt line + * @dev_id: Device identity for which the thread should be woken */ void irq_wake_thread(unsigned int irq, void *dev_id) { @@ -2005,20 +1997,19 @@ static struct irqaction *__free_irq(stru } =20 /** - * free_irq - free an interrupt allocated with request_irq - * @irq: Interrupt line to free - * @dev_id: Device identity to free - * - * Remove an interrupt handler. The handler is removed and if the - * interrupt line is no longer in use by any driver it is disabled. - * On a shared IRQ the caller must ensure the interrupt is disabled - * on the card it drives before calling this function. The function - * does not return until any executing interrupts for this IRQ - * have completed. + * free_irq - free an interrupt allocated with request_irq + * @irq: Interrupt line to free + * @dev_id: Device identity to free + * + * Remove an interrupt handler. The handler is removed and if the interrupt + * line is no longer in use by any driver it is disabled. On a shared IRQ + * the caller must ensure the interrupt is disabled on the card it drives + * before calling this function. The function does not return until any + * executing interrupts for this IRQ have completed. * - * This function must not be called from interrupt context. + * This function must not be called from interrupt context. * - * Returns the devname argument passed to request_irq. + * Returns the devname argument passed to request_irq. */ const void *free_irq(unsigned int irq, void *dev_id) { @@ -2099,42 +2090,40 @@ const void *free_nmi(unsigned int irq, v } =20 /** - * request_threaded_irq - allocate an interrupt line - * @irq: Interrupt line to allocate - * @handler: Function to be called when the IRQ occurs. - * Primary handler for threaded interrupts. - * If handler is NULL and thread_fn !=3D NULL - * the default primary handler is installed. - * @thread_fn: Function called from the irq handler thread - * If NULL, no irq thread is created - * @irqflags: Interrupt type flags - * @devname: An ascii name for the claiming device - * @dev_id: A cookie passed back to the handler function - * - * This call allocates interrupt resources and enables the - * interrupt line and IRQ handling. From the point this - * call is made your handler function may be invoked. Since - * your handler function must clear any interrupt the board - * raises, you must take care both to initialise your hardware - * and to set up the interrupt handler in the right order. - * - * If you want to set up a threaded irq handler for your device - * then you need to supply @handler and @thread_fn. @handler is - * still called in hard interrupt context and has to check - * whether the interrupt originates from the device. If yes it - * needs to disable the interrupt on the device and return - * IRQ_WAKE_THREAD which will wake up the handler thread and run - * @thread_fn. This split handler design is necessary to support - * shared interrupts. - * - * Dev_id must be globally unique. Normally the address of the - * device data structure is used as the cookie. Since the handler - * receives this value it makes sense to use it. + * request_threaded_irq - allocate an interrupt line + * @irq: Interrupt line to allocate + * @handler: Function to be called when the IRQ occurs. + * Primary handler for threaded interrupts. + * If handler is NULL and thread_fn !=3D NULL + * the default primary handler is installed. + * @thread_fn: Function called from the irq handler thread + * If NULL, no irq thread is created + * @irqflags: Interrupt type flags + * @devname: An ascii name for the claiming device + * @dev_id: A cookie passed back to the handler function + * + * This call allocates interrupt resources and enables the interrupt line + * and IRQ handling. From the point this call is made your handler function + * may be invoked. Since your handler function must clear any interrupt the + * board raises, you must take care both to initialise your hardware and to + * set up the interrupt handler in the right order. + * + * If you want to set up a threaded irq handler for your device then you + * need to supply @handler and @thread_fn. @handler is still called in hard + * interrupt context and has to check whether the interrupt originates from + * the device. If yes it needs to disable the interrupt on the device and + * return IRQ_WAKE_THREAD which will wake up the handler thread and run + * @thread_fn. This split handler design is necessary to support shared + * interrupts. + * + * @dev_id must be globally unique. Normally the address of the device data + * structure is used as the cookie. Since the handler receives this value + * it makes sense to use it. * - * If your interrupt is shared you must pass a non NULL dev_id - * as this is required when freeing the interrupt. + * If your interrupt is shared you must pass a non NULL dev_id as this is + * required when freeing the interrupt. * - * Flags: + * Flags: * * IRQF_SHARED Interrupt is shared * IRQF_TRIGGER_* Specify active edge(s) or level @@ -2232,21 +2221,20 @@ int request_threaded_irq(unsigned int ir EXPORT_SYMBOL(request_threaded_irq); =20 /** - * request_any_context_irq - allocate an interrupt line - * @irq: Interrupt line to allocate - * @handler: Function to be called when the IRQ occurs. - * Threaded handler for threaded interrupts. - * @flags: Interrupt type flags - * @name: An ascii name for the claiming device - * @dev_id: A cookie passed back to the handler function - * - * This call allocates interrupt resources and enables the - * interrupt line and IRQ handling. It selects either a - * hardirq or threaded handling method depending on the - * context. + * request_any_context_irq - allocate an interrupt line + * @irq: Interrupt line to allocate + * @handler: Function to be called when the IRQ occurs. + * Threaded handler for threaded interrupts. + * @flags: Interrupt type flags + * @name: An ascii name for the claiming device + * @dev_id: A cookie passed back to the handler function + * + * This call allocates interrupt resources and enables the interrupt line + * and IRQ handling. It selects either a hardirq or threaded handling + * method depending on the context. * - * On failure, it returns a negative value. On success, - * it returns either IRQC_IS_HARDIRQ or IRQC_IS_NESTED. + * Returns: On failure, it returns a negative value. On success, it return= s either + * IRQC_IS_HARDIRQ or IRQC_IS_NESTED. */ int request_any_context_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *dev_id) @@ -2273,30 +2261,29 @@ int request_any_context_irq(unsigned int EXPORT_SYMBOL_GPL(request_any_context_irq); =20 /** - * request_nmi - allocate an interrupt line for NMI delivery - * @irq: Interrupt line to allocate - * @handler: Function to be called when the IRQ occurs. - * Threaded handler for threaded interrupts. - * @irqflags: Interrupt type flags - * @name: An ascii name for the claiming device - * @dev_id: A cookie passed back to the handler function - * - * This call allocates interrupt resources and enables the - * interrupt line and IRQ handling. It sets up the IRQ line - * to be handled as an NMI. - * - * An interrupt line delivering NMIs cannot be shared and IRQ handling - * cannot be threaded. - * - * Interrupt lines requested for NMI delivering must produce per cpu - * interrupts and have auto enabling setting disabled. - * - * Dev_id must be globally unique. Normally the address of the - * device data structure is used as the cookie. Since the handler - * receives this value it makes sense to use it. + * request_nmi - allocate an interrupt line for NMI delivery + * @irq: Interrupt line to allocate + * @handler: Function to be called when the IRQ occurs. + * Threaded handler for threaded interrupts. + * @irqflags: Interrupt type flags + * @name: An ascii name for the claiming device + * @dev_id: A cookie passed back to the handler function + * + * This call allocates interrupt resources and enables the interrupt line + * and IRQ handling. It sets up the IRQ line to be handled as an NMI. + * + * An interrupt line delivering NMIs cannot be shared and IRQ handling + * cannot be threaded. + * + * Interrupt lines requested for NMI delivering must produce per cpu + * interrupts and have auto enabling setting disabled. + * + * @dev_id must be globally unique. Normally the address of the device data + * structure is used as the cookie. Since the handler receives this value + * it makes sense to use it. * - * If the interrupt line cannot be used to deliver NMIs, function - * will fail and return a negative value. + * If the interrupt line cannot be used to deliver NMIs, function will fail + * and return a negative value. */ int request_nmi(unsigned int irq, irq_handler_t handler, unsigned long irqflags, const char *name, void *dev_id) @@ -2498,9 +2485,9 @@ static struct irqaction *__free_percpu_i } =20 /** - * remove_percpu_irq - free a per-cpu interrupt - * @irq: Interrupt line to free - * @act: irqaction for the interrupt + * remove_percpu_irq - free a per-cpu interrupt + * @irq: Interrupt line to free + * @act: irqaction for the interrupt * * Used to remove interrupts statically setup by the early boot process. */ @@ -2509,20 +2496,20 @@ void remove_percpu_irq(unsigned int irq, struct irq_desc *desc =3D irq_to_desc(irq); =20 if (desc && irq_settings_is_per_cpu_devid(desc)) - __free_percpu_irq(irq, act->percpu_dev_id); + __free_percpu_irq(irq, act->percpu_dev_id); } =20 /** - * free_percpu_irq - free an interrupt allocated with request_percpu_irq - * @irq: Interrupt line to free - * @dev_id: Device identity to free + * free_percpu_irq - free an interrupt allocated with request_percpu_irq + * @irq: Interrupt line to free + * @dev_id: Device identity to free * - * Remove a percpu interrupt handler. The handler is removed, but - * the interrupt line is not disabled. This must be done on each - * CPU before calling this function. The function does not return - * until any executing interrupts for this IRQ have completed. + * Remove a percpu interrupt handler. The handler is removed, but the + * interrupt line is not disabled. This must be done on each CPU before + * calling this function. The function does not return until any executing + * interrupts for this IRQ have completed. * - * This function must not be called from interrupt context. + * This function must not be called from interrupt context. */ void free_percpu_irq(unsigned int irq, void __percpu *dev_id) { @@ -2551,9 +2538,9 @@ void free_percpu_nmi(unsigned int irq, v } =20 /** - * setup_percpu_irq - setup a per-cpu interrupt - * @irq: Interrupt line to setup - * @act: irqaction for the interrupt + * setup_percpu_irq - setup a per-cpu interrupt + * @irq: Interrupt line to setup + * @act: irqaction for the interrupt * * Used to statically setup per-cpu interrupts in the early boot process. */ @@ -2578,21 +2565,20 @@ int setup_percpu_irq(unsigned int irq, s } =20 /** - * __request_percpu_irq - allocate a percpu interrupt line - * @irq: Interrupt line to allocate - * @handler: Function to be called when the IRQ occurs. - * @flags: Interrupt type flags (IRQF_TIMER only) - * @devname: An ascii name for the claiming device - * @dev_id: A percpu cookie passed back to the handler function - * - * This call allocates interrupt resources and enables the - * interrupt on the local CPU. If the interrupt is supposed to be - * enabled on other CPUs, it has to be done on each CPU using - * enable_percpu_irq(). - * - * Dev_id must be globally unique. It is a per-cpu variable, and - * the handler gets called with the interrupted CPU's instance of - * that variable. + * __request_percpu_irq - allocate a percpu interrupt line + * @irq: Interrupt line to allocate + * @handler: Function to be called when the IRQ occurs. + * @flags: Interrupt type flags (IRQF_TIMER only) + * @devname: An ascii name for the claiming device + * @dev_id: A percpu cookie passed back to the handler function + * + * This call allocates interrupt resources and enables the interrupt on the + * local CPU. If the interrupt is supposed to be enabled on other CPUs, it + * has to be done on each CPU using enable_percpu_irq(). + * + * @dev_id must be globally unique. It is a per-cpu variable, and + * the handler gets called with the interrupted CPU's instance of + * that variable. */ int __request_percpu_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *devname, @@ -2640,25 +2626,25 @@ int __request_percpu_irq(unsigned int ir EXPORT_SYMBOL_GPL(__request_percpu_irq); =20 /** - * request_percpu_nmi - allocate a percpu interrupt line for NMI delivery - * @irq: Interrupt line to allocate - * @handler: Function to be called when the IRQ occurs. - * @name: An ascii name for the claiming device - * @dev_id: A percpu cookie passed back to the handler function - * - * This call allocates interrupt resources for a per CPU NMI. Per CPU NMIs - * have to be setup on each CPU by calling prepare_percpu_nmi() before - * being enabled on the same CPU by using enable_percpu_nmi(). - * - * Dev_id must be globally unique. It is a per-cpu variable, and - * the handler gets called with the interrupted CPU's instance of - * that variable. + * request_percpu_nmi - allocate a percpu interrupt line for NMI delivery + * @irq: Interrupt line to allocate + * @handler: Function to be called when the IRQ occurs. + * @name: An ascii name for the claiming device + * @dev_id: A percpu cookie passed back to the handler function + * + * This call allocates interrupt resources for a per CPU NMI. Per CPU NMIs + * have to be setup on each CPU by calling prepare_percpu_nmi() before + * being enabled on the same CPU by using enable_percpu_nmi(). + * + * @dev_id must be globally unique. It is a per-cpu variable, and the + * handler gets called with the interrupted CPU's instance of that + * variable. * - * Interrupt lines requested for NMI delivering should have auto enabling - * setting disabled. + * Interrupt lines requested for NMI delivering should have auto enabling + * setting disabled. * - * If the interrupt line cannot be used to deliver NMIs, function - * will fail returning a negative value. + * If the interrupt line cannot be used to deliver NMIs, function + * will fail returning a negative value. */ int request_percpu_nmi(unsigned int irq, irq_handler_t handler, const char *name, void __percpu *dev_id) @@ -2716,17 +2702,17 @@ int request_percpu_nmi(unsigned int irq, } =20 /** - * prepare_percpu_nmi - performs CPU local setup for NMI delivery - * @irq: Interrupt line to prepare for NMI delivery + * prepare_percpu_nmi - performs CPU local setup for NMI delivery + * @irq: Interrupt line to prepare for NMI delivery * - * This call prepares an interrupt line to deliver NMI on the current CPU, - * before that interrupt line gets enabled with enable_percpu_nmi(). + * This call prepares an interrupt line to deliver NMI on the current CPU, + * before that interrupt line gets enabled with enable_percpu_nmi(). * - * As a CPU local operation, this should be called from non-preemptible - * context. + * As a CPU local operation, this should be called from non-preemptible + * context. * - * If the interrupt line cannot be used to deliver NMIs, function - * will fail returning a negative value. + * If the interrupt line cannot be used to deliver NMIs, function will fail + * returning a negative value. */ int prepare_percpu_nmi(unsigned int irq) { @@ -2760,16 +2746,14 @@ int prepare_percpu_nmi(unsigned int irq) } =20 /** - * teardown_percpu_nmi - undoes NMI setup of IRQ line - * @irq: Interrupt line from which CPU local NMI configuration should be - * removed - * - * This call undoes the setup done by prepare_percpu_nmi(). + * teardown_percpu_nmi - undoes NMI setup of IRQ line + * @irq: Interrupt line from which CPU local NMI configuration should be r= emoved * - * IRQ line should not be enabled for the current CPU. + * This call undoes the setup done by prepare_percpu_nmi(). * - * As a CPU local operation, this should be called from non-preemptible - * context. + * IRQ line should not be enabled for the current CPU. + * As a CPU local operation, this should be called from non-preemptible + * context. */ void teardown_percpu_nmi(unsigned int irq) { @@ -2815,17 +2799,16 @@ static int __irq_get_irqchip_state(struc } =20 /** - * irq_get_irqchip_state - returns the irqchip state of a interrupt. - * @irq: Interrupt line that is forwarded to a VM - * @which: One of IRQCHIP_STATE_* the caller wants to know about - * @state: a pointer to a boolean where the state is to be stored - * - * This call snapshots the internal irqchip state of an - * interrupt, returning into @state the bit corresponding to - * stage @which + * irq_get_irqchip_state - returns the irqchip state of a interrupt. + * @irq: Interrupt line that is forwarded to a VM + * @which: One of IRQCHIP_STATE_* the caller wants to know about + * @state: a pointer to a boolean where the state is to be stored + * + * This call snapshots the internal irqchip state of an interrupt, + * returning into @state the bit corresponding to stage @which * - * This function should be called with preemption disabled if the - * interrupt controller has per-cpu registers. + * This function should be called with preemption disabled if the interrupt + * controller has per-cpu registers. */ int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which, bool *state) @@ -2849,19 +2832,18 @@ int irq_get_irqchip_state(unsigned int i EXPORT_SYMBOL_GPL(irq_get_irqchip_state); =20 /** - * irq_set_irqchip_state - set the state of a forwarded interrupt. - * @irq: Interrupt line that is forwarded to a VM - * @which: State to be restored (one of IRQCHIP_STATE_*) - * @val: Value corresponding to @which + * irq_set_irqchip_state - set the state of a forwarded interrupt. + * @irq: Interrupt line that is forwarded to a VM + * @which: State to be restored (one of IRQCHIP_STATE_*) + * @val: Value corresponding to @which * - * This call sets the internal irqchip state of an interrupt, - * depending on the value of @which. + * This call sets the internal irqchip state of an interrupt, depending on + * the value of @which. * - * This function should be called with migration disabled if the - * interrupt controller has per-cpu registers. + * This function should be called with migration disabled if the interrupt + * controller has per-cpu registers. */ -int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which, - bool val) +int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which, = bool val) { struct irq_desc *desc; struct irq_data *data; From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 0F9922BEC5A for ; Tue, 29 Apr 2025 06:55:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909734; cv=none; b=d6sOfJ5E8ZyCROrdVb58pYA/kGgV6+SEn/aR6r86FD8Sn2SJj5cu4oSQKsJ7e+ssMJn69/KFyxmvdRcYvUYoGxN22ttDcxMLBYNaRVfMibrTNUZ6wjxpbgl3Vur6/2c5pitD6VivVas6mDADveB0TRKOFPmhht2LGsvwLGntHWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909734; c=relaxed/simple; bh=eDJKE5DgOvPqgcB2EUysQTDX13M5iNO35ssASXREp80=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=lDfOnnJxKvQEM3Qx/Y23cP4x7WMoYs6rFbH9g/KNIl7vpGVbFJH2KHFsilOX+N5KLADq4CpFx9gR3geHIpHaHHTjvKY95SWYEIvnxFjmtAw5p/8pxJrrS8N04jOoSelqhFpxuPRC181HhOTdzkx3w8wo+ujIxQMAcnZENCycjaA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=CSDLvBS3; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=pgf1CxYD; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="CSDLvBS3"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pgf1CxYD" Message-ID: <20250429065421.771476066@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909731; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=tJZIepXVGTfxsjDYJGDWC0tG+TVomFfCu/lJ+mn8OZE=; b=CSDLvBS3gfKA9C63WL+xU2fA8QoE0UUslXRBlIj7Xs9N8uHTxQFc4BnQa0l2pGVo3Uk7wi 3Y5B2EcAEstZ046GJos056gDaZq3jd4tQempuzBi0BqEYvw6cAojU4YB4sH6LNCm/IlazN x8M15eUSEBm6DYfc6k6Wf3nd+hjURAm+z8upzYoajCOZ+BAUb/ff5lB5XtJHAdOk5PR6/b I/b9Peb5thEddHpRsjmgvR1HhPE1NW112yd5pXij0LQx2LvSTLMufRvNXnuhqcYZ7fuOJs hBwtbvGKBAjAbWWgewaYOqcGSJZfVgK0c4r3CtmjyQMWKdgPDo3d1DQyxXA90Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909731; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=tJZIepXVGTfxsjDYJGDWC0tG+TVomFfCu/lJ+mn8OZE=; b=pgf1CxYDmFUdlZRREVNHKLCIPGHKZdvvr20gITyo1wLEEGD3EpuaXRj3YsqcYeiBaBzTef K6DRiqzTfTxvTXBw== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 29/45] genirq/manage: Convert to lock guards References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:31 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert lock/unlock pairs to guards. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/manage.c | 155 +++++++++++++++++++----------------------------= ----- 1 file changed, 58 insertions(+), 97 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -41,8 +41,6 @@ static void __synchronize_hardirq(struct bool inprogress; =20 do { - unsigned long flags; - /* * Wait until we're out of the critical section. This might * give the wrong answer due to the lack of memory barriers. @@ -51,7 +49,7 @@ static void __synchronize_hardirq(struct cpu_relax(); =20 /* Ok, that indicated we're done: double-check carefully. */ - raw_spin_lock_irqsave(&desc->lock, flags); + guard(raw_spinlock_irqsave)(&desc->lock); inprogress =3D irqd_irq_inprogress(&desc->irq_data); =20 /* @@ -67,8 +65,6 @@ static void __synchronize_hardirq(struct __irq_get_irqchip_state(irqd, IRQCHIP_STATE_ACTIVE, &inprogress); } - raw_spin_unlock_irqrestore(&desc->lock, flags); - /* Oops, that failed? */ } while (inprogress); } @@ -456,16 +452,12 @@ static int __irq_set_affinity(unsigned i bool force) { struct irq_desc *desc =3D irq_to_desc(irq); - unsigned long flags; - int ret; =20 if (!desc) return -EINVAL; =20 - raw_spin_lock_irqsave(&desc->lock, flags); - ret =3D irq_set_affinity_locked(irq_desc_get_irq_data(desc), mask, force); - raw_spin_unlock_irqrestore(&desc->lock, flags); - return ret; + guard(raw_spinlock_irqsave)(&desc->lock); + return irq_set_affinity_locked(irq_desc_get_irq_data(desc), mask, force); } =20 /** @@ -520,17 +512,16 @@ static void irq_affinity_notify(struct w container_of(work, struct irq_affinity_notify, work); struct irq_desc *desc =3D irq_to_desc(notify->irq); cpumask_var_t cpumask; - unsigned long flags; =20 if (!desc || !alloc_cpumask_var(&cpumask, GFP_KERNEL)) goto out; =20 - raw_spin_lock_irqsave(&desc->lock, flags); - if (irq_move_pending(&desc->irq_data)) - irq_get_pending(cpumask, desc); - else - cpumask_copy(cpumask, desc->irq_common_data.affinity); - raw_spin_unlock_irqrestore(&desc->lock, flags); + scoped_guard(raw_spinlock_irqsave, &desc->lock) { + if (irq_move_pending(&desc->irq_data)) + irq_get_pending(cpumask, desc); + else + cpumask_copy(cpumask, desc->irq_common_data.affinity); + } =20 notify->notify(notify, cpumask); =20 @@ -554,7 +545,6 @@ int irq_set_affinity_notifier(unsigned i { struct irq_desc *desc =3D irq_to_desc(irq); struct irq_affinity_notify *old_notify; - unsigned long flags; =20 /* The release function is promised process context */ might_sleep(); @@ -569,10 +559,10 @@ int irq_set_affinity_notifier(unsigned i INIT_WORK(¬ify->work, irq_affinity_notify); } =20 - raw_spin_lock_irqsave(&desc->lock, flags); - old_notify =3D desc->affinity_notify; - desc->affinity_notify =3D notify; - raw_spin_unlock_irqrestore(&desc->lock, flags); + scoped_guard(raw_spinlock_irqsave, &desc->lock) { + old_notify =3D desc->affinity_notify; + desc->affinity_notify =3D notify; + } =20 if (old_notify) { if (cancel_work_sync(&old_notify->work)) { @@ -593,7 +583,8 @@ EXPORT_SYMBOL_GPL(irq_set_affinity_notif int irq_setup_affinity(struct irq_desc *desc) { struct cpumask *set =3D irq_default_affinity; - int ret, node =3D irq_desc_get_node(desc); + int node =3D irq_desc_get_node(desc); + static DEFINE_RAW_SPINLOCK(mask_lock); static struct cpumask mask; =20 @@ -601,7 +592,7 @@ int irq_setup_affinity(struct irq_desc * if (!__irq_can_set_affinity(desc)) return 0; =20 - raw_spin_lock(&mask_lock); + guard(raw_spinlock)(&mask_lock); /* * Preserve the managed affinity setting and a userspace affinity * setup, but make sure that one of the targets is online. @@ -626,9 +617,7 @@ int irq_setup_affinity(struct irq_desc * if (cpumask_intersects(&mask, nodemask)) cpumask_and(&mask, &mask, nodemask); } - ret =3D irq_do_set_affinity(&desc->irq_data, &mask, false); - raw_spin_unlock(&mask_lock); - return ret; + return irq_do_set_affinity(&desc->irq_data, &mask, false); } #else /* Wrapper for ALPHA specific affinity selector magic */ @@ -1070,19 +1059,19 @@ static void irq_thread_check_affinity(st return; } =20 - raw_spin_lock_irq(&desc->lock); - /* - * This code is triggered unconditionally. Check the affinity - * mask pointer. For CPU_MASK_OFFSTACK=3Dn this is optimized out. - */ - if (cpumask_available(desc->irq_common_data.affinity)) { - const struct cpumask *m; + scoped_guard(raw_spinlock_irq, &desc->lock) { + /* + * This code is triggered unconditionally. Check the affinity + * mask pointer. For CPU_MASK_OFFSTACK=3Dn this is optimized out. + */ + if (cpumask_available(desc->irq_common_data.affinity)) { + const struct cpumask *m; =20 - m =3D irq_data_get_effective_affinity_mask(&desc->irq_data); - cpumask_copy(mask, m); - valid =3D true; + m =3D irq_data_get_effective_affinity_mask(&desc->irq_data); + cpumask_copy(mask, m); + valid =3D true; + } } - raw_spin_unlock_irq(&desc->lock); =20 if (valid) set_cpus_allowed_ptr(current, mask); @@ -1250,9 +1239,8 @@ static void irq_wake_secondary(struct ir if (WARN_ON_ONCE(!secondary)) return; =20 - raw_spin_lock_irq(&desc->lock); + guard(raw_spinlock_irq)(&desc->lock); __irq_wake_thread(desc, secondary); - raw_spin_unlock_irq(&desc->lock); } =20 /* @@ -1333,12 +1321,11 @@ void irq_wake_thread(unsigned int irq, v { struct irq_desc *desc =3D irq_to_desc(irq); struct irqaction *action; - unsigned long flags; =20 if (!desc || WARN_ON(irq_settings_is_per_cpu_devid(desc))) return; =20 - raw_spin_lock_irqsave(&desc->lock, flags); + guard(raw_spinlock_irqsave)(&desc->lock); for_each_action_of_desc(desc, action) { if (action->dev_id =3D=3D dev_id) { if (action->thread) @@ -1346,7 +1333,6 @@ void irq_wake_thread(unsigned int irq, v break; } } - raw_spin_unlock_irqrestore(&desc->lock, flags); } EXPORT_SYMBOL_GPL(irq_wake_thread); =20 @@ -1977,9 +1963,8 @@ static struct irqaction *__free_irq(stru * There is no interrupt on the fly anymore. Deactivate it * completely. */ - raw_spin_lock_irqsave(&desc->lock, flags); - irq_domain_deactivate_irq(&desc->irq_data); - raw_spin_unlock_irqrestore(&desc->lock, flags); + scoped_guard(raw_spinlock_irqsave, &desc->lock) + irq_domain_deactivate_irq(&desc->irq_data); =20 irq_release_resources(desc); chip_bus_sync_unlock(desc); @@ -2064,8 +2049,6 @@ static const void *__cleanup_nmi(unsigne const void *free_nmi(unsigned int irq, void *dev_id) { struct irq_desc *desc =3D irq_to_desc(irq); - unsigned long flags; - const void *devname; =20 if (!desc || WARN_ON(!irq_is_nmi(desc))) return NULL; @@ -2077,14 +2060,9 @@ const void *free_nmi(unsigned int irq, v if (WARN_ON(desc->depth =3D=3D 0)) disable_nmi_nosync(irq); =20 - raw_spin_lock_irqsave(&desc->lock, flags); - + guard(raw_spinlock_irqsave)(&desc->lock); irq_nmi_teardown(desc); - devname =3D __cleanup_nmi(irq, desc); - - raw_spin_unlock_irqrestore(&desc->lock, flags); - - return devname; + return __cleanup_nmi(irq, desc); } =20 /** @@ -2288,7 +2266,6 @@ int request_nmi(unsigned int irq, irq_ha { struct irqaction *action; struct irq_desc *desc; - unsigned long flags; int retval; =20 if (irq =3D=3D IRQ_NOTCONNECTED) @@ -2330,21 +2307,17 @@ int request_nmi(unsigned int irq, irq_ha if (retval) goto err_irq_setup; =20 - raw_spin_lock_irqsave(&desc->lock, flags); - - /* Setup NMI state */ - desc->istate |=3D IRQS_NMI; - retval =3D irq_nmi_setup(desc); - if (retval) { - __cleanup_nmi(irq, desc); - raw_spin_unlock_irqrestore(&desc->lock, flags); - return -EINVAL; + scoped_guard(raw_spinlock_irqsave, &desc->lock) { + /* Setup NMI state */ + desc->istate |=3D IRQS_NMI; + retval =3D irq_nmi_setup(desc); + if (retval) { + __cleanup_nmi(irq, desc); + return -EINVAL; + } + return 0; } =20 - raw_spin_unlock_irqrestore(&desc->lock, flags); - - return 0; - err_irq_setup: irq_chip_pm_put(&desc->irq_data); err_out: @@ -2443,43 +2416,34 @@ static struct irqaction *__free_percpu_i { struct irq_desc *desc =3D irq_to_desc(irq); struct irqaction *action; - unsigned long flags; =20 WARN(in_interrupt(), "Trying to free IRQ %d from IRQ context!\n", irq); =20 if (!desc) return NULL; =20 - raw_spin_lock_irqsave(&desc->lock, flags); + scoped_guard(raw_spinlock_irqsave, &desc->lock) { + action =3D desc->action; + if (!action || action->percpu_dev_id !=3D dev_id) { + WARN(1, "Trying to free already-free IRQ %d\n", irq); + return NULL; + } =20 - action =3D desc->action; - if (!action || action->percpu_dev_id !=3D dev_id) { - WARN(1, "Trying to free already-free IRQ %d\n", irq); - goto bad; - } + if (!cpumask_empty(desc->percpu_enabled)) { + WARN(1, "percpu IRQ %d still enabled on CPU%d!\n", + irq, cpumask_first(desc->percpu_enabled)); + return NULL; + } =20 - if (!cpumask_empty(desc->percpu_enabled)) { - WARN(1, "percpu IRQ %d still enabled on CPU%d!\n", - irq, cpumask_first(desc->percpu_enabled)); - goto bad; + /* Found it - now remove it from the list of entries: */ + desc->action =3D NULL; + desc->istate &=3D ~IRQS_NMI; } =20 - /* Found it - now remove it from the list of entries: */ - desc->action =3D NULL; - - desc->istate &=3D ~IRQS_NMI; - - raw_spin_unlock_irqrestore(&desc->lock, flags); - unregister_handler_proc(irq, action); - irq_chip_pm_put(&desc->irq_data); module_put(desc->owner); return action; - -bad: - raw_spin_unlock_irqrestore(&desc->lock, flags); - return NULL; } =20 /** @@ -2649,7 +2613,6 @@ int request_percpu_nmi(unsigned int irq, { struct irqaction *action; struct irq_desc *desc; - unsigned long flags; int retval; =20 if (!handler) @@ -2685,10 +2648,8 @@ int request_percpu_nmi(unsigned int irq, if (retval) goto err_irq_setup; =20 - raw_spin_lock_irqsave(&desc->lock, flags); + guard(raw_spinlock_irqsave)(&desc->lock); desc->istate |=3D IRQS_NMI; - raw_spin_unlock_irqrestore(&desc->lock, flags); - return 0; =20 err_irq_setup: From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 817FB2BF3C7 for ; Tue, 29 Apr 2025 06:55:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909736; cv=none; b=hRfq2k0UBjwuJuRB++T0Hh07qlQGDhhC2Jg2miOwuUD8iE7Ij7tT3gb5DylixtzD+q7mD1jqd7rG+NxePIgNrPCkgzLkt1OwZJLcvh2g5gEr2k9DeBoverzx9kRYgQAymjfSTehNc8hOW6AM6ZdOCfLswwU8tntgwYbe/aPHOcE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909736; c=relaxed/simple; bh=tuEEFk8TcHvWKFiT97V6fnjqa0MsE28d8fxiVRK083c=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=oFO+Cwu1yKdWdXW8XsWNI2wtf296grczuBMaPN1/ccCJEejkfMKegMnJ2ncTTa8Jl5OaeujEdo/XLLLuYTL/72E4v0cjsB+vE69Y5lsGZrIPAC9NgazfmNHWKieUpCPDEB25XyTY0uTC8kJ/0qf2veYeCGOLMpyVtepfvLG7DvQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ntoeZz9a; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=l6k2nIz1; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ntoeZz9a"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="l6k2nIz1" Message-ID: <20250429065421.830357569@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909733; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=bYqokDAXltzvGtNSThKO/zTEdwgjP0tUlXPO/QfeS7o=; b=ntoeZz9aBs83duSRbsgwLsDePRFcNaJF/7bFFRTVLTYXbWHj1WO5k0eQNZt2dNdNbdWvp5 1sQShxOVWRpVf+LDoD8zE+MyCYmjrdKAzGT7vPabjo4UEvemwc2uM+vsRZzmsW1pbk0laa 4gmFg09bTc0gFXHeerCW2EPkz/hOVY3w/NtV1FsEtWZL30zwjYrX1xr7BF0C1xxI/F81xN 42dUvR22cq+utqvj2Rhx5tLuumuf1gMibuuNbSi4YE8GUt562eGKLQ3aan0yIsKJD+3hBE l/hWJxcn4ZBBe1DBQvei/hs5m0/zrCocf26BqmjF8b3LDzdQDrQNwqLyWz9T8g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909733; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=bYqokDAXltzvGtNSThKO/zTEdwgjP0tUlXPO/QfeS7o=; b=l6k2nIz1am1Xqa8YFmg+LG+UZZTpLQOp71Bbcw+HTaJTiQFqnV/+d/s8A5+9c84VeSV3qw n+2P1MTg1D1jXgCg== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 30/45] genirq/manage: Rework irq_update_affinity_desc() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:32 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/manage.c | 76 +++++++++++++++++++++--------------------------= ----- 1 file changed, 32 insertions(+), 44 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -393,14 +393,8 @@ int irq_set_affinity_locked(struct irq_d * an interrupt which is already started or which has already been configu= red * as managed will also fail, as these mean invalid init state or double i= nit. */ -int irq_update_affinity_desc(unsigned int irq, - struct irq_affinity_desc *affinity) +int irq_update_affinity_desc(unsigned int irq, struct irq_affinity_desc *a= ffinity) { - struct irq_desc *desc; - unsigned long flags; - bool activated; - int ret =3D 0; - /* * Supporting this with the reservation scheme used by x86 needs * some more thought. Fail it for now. @@ -408,44 +402,38 @@ int irq_update_affinity_desc(unsigned in if (IS_ENABLED(CONFIG_GENERIC_IRQ_RESERVATION_MODE)) return -EOPNOTSUPP; =20 - desc =3D irq_get_desc_buslock(irq, &flags, 0); - if (!desc) - return -EINVAL; - - /* Requires the interrupt to be shut down */ - if (irqd_is_started(&desc->irq_data)) { - ret =3D -EBUSY; - goto out_unlock; - } - - /* Interrupts which are already managed cannot be modified */ - if (irqd_affinity_is_managed(&desc->irq_data)) { - ret =3D -EBUSY; - goto out_unlock; + scoped_irqdesc_get_and_buslock(irq, 0) { + struct irq_desc *desc =3D scoped_irqdesc; + bool activated; + + /* Requires the interrupt to be shut down */ + if (irqd_is_started(&desc->irq_data)) + return -EBUSY; + + /* Interrupts which are already managed cannot be modified */ + if (irqd_affinity_is_managed(&desc->irq_data)) + return -EBUSY; + /* + * Deactivate the interrupt. That's required to undo + * anything an earlier activation has established. + */ + activated =3D irqd_is_activated(&desc->irq_data); + if (activated) + irq_domain_deactivate_irq(&desc->irq_data); + + if (affinity->is_managed) { + irqd_set(&desc->irq_data, IRQD_AFFINITY_MANAGED); + irqd_set(&desc->irq_data, IRQD_MANAGED_SHUTDOWN); + } + + cpumask_copy(desc->irq_common_data.affinity, &affinity->mask); + + /* Restore the activation state */ + if (activated) + irq_domain_activate_irq(&desc->irq_data, false); + return 0; } - - /* - * Deactivate the interrupt. That's required to undo - * anything an earlier activation has established. - */ - activated =3D irqd_is_activated(&desc->irq_data); - if (activated) - irq_domain_deactivate_irq(&desc->irq_data); - - if (affinity->is_managed) { - irqd_set(&desc->irq_data, IRQD_AFFINITY_MANAGED); - irqd_set(&desc->irq_data, IRQD_MANAGED_SHUTDOWN); - } - - cpumask_copy(desc->irq_common_data.affinity, &affinity->mask); - - /* Restore the activation state */ - if (activated) - irq_domain_activate_irq(&desc->irq_data, false); - -out_unlock: - irq_put_desc_busunlock(desc, flags); - return ret; + return -EINVAL; } =20 static int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 4A06C2BF3D7 for ; Tue, 29 Apr 2025 06:55:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909737; cv=none; b=LChptnZVPsjPOxdy8GGRqCVEYHPOIY2iRKwb5q5A2U03TE/LP5NLtgPi8qw3RzCinuGcqmpepoAhfiuA3DJVk5y84GVwU9KFti6F+OpJVh370Vno/tZ9+TBQHghkguTpt1AGXOv553Wrtc08eAWTyLM3RE+Emv/WeHRp8IQJh4I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909737; c=relaxed/simple; bh=fm3PuL0Z5EVw/Xl29bOskHTN/0mrNZWUMhnYiWNkOz4=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=KA+ZWjv2dzVua+UO8dp6eKEB7oHkqoPdSoZYHBlmIaANXlAhTK33b78VZqq4Phyhragemef6dpL859/0OW4sZdhYbTcIDkN8KizTAL8+/8Ssq3aphJtYx4sSToeEzs6MzVEQmJYAiIe4HGcJRuAGY4tKRsM7nK2fThy+pGaxqKM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=fj/A/K2b; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=9M6dYs/G; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fj/A/K2b"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="9M6dYs/G" Message-ID: <20250429065421.897188799@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=WseL2vuiLU0EnidX1w6WyZGxzdmKSxETXXKWL4AxYeU=; b=fj/A/K2bmaYqHF18c74cgOYP9rhZ5yQsF5Q6s+46NXza2H/9Ssf3Rh4CRKgWGfLopNDV+Y bNX/lNFkLHUKoYpIo+UwP0X/FFCi1nywZ3dcG/0a3p9YHrTmPG1nbCLKVkUWB0of1gZduF D2M2iIVAuf1JBeI4Zv1pmpRgISLaAs2jaL87S2Z0AZet1pnrzb8kJfjY7opydlDIbGeSR2 plYx7Bkx4H3ik4BlL64ZPld7/OXiqlyxjD4KiwbA85SScpSqZWnhrFIJkf6ZtbqieJcWbz 1yuOOFuptJxB5CtqxucHRS66uwL8/Vz+N+D0pfklbSVsQdKvynqUSTyPgjMkUA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=WseL2vuiLU0EnidX1w6WyZGxzdmKSxETXXKWL4AxYeU=; b=9M6dYs/G8fuMbVjWMFkzc6wwixSYR53Qdy7R1hQYzAl9+VxKrXnnUOIJiIaG2nIrK6ac3r DmqX6ttiJAM3TyDw== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 31/45] genirq/manage: Rework __irq_apply_affinity_hint() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:34 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/manage.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -478,26 +478,24 @@ int irq_force_affinity(unsigned int irq, } EXPORT_SYMBOL_GPL(irq_force_affinity); =20 -int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m, - bool setaffinity) +int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m, b= ool setaffinity) { - unsigned long flags; - struct irq_desc *desc =3D irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHE= CK_GLOBAL); + int ret =3D -EINVAL; =20 - if (!desc) - return -EINVAL; - desc->affinity_hint =3D m; - irq_put_desc_unlock(desc, flags); - if (m && setaffinity) + scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_GLOBAL) { + scoped_irqdesc->affinity_hint =3D m; + ret =3D 0; + } + + if (!ret && m && setaffinity) __irq_set_affinity(irq, m, false); - return 0; + return ret; } EXPORT_SYMBOL_GPL(__irq_apply_affinity_hint); =20 static void irq_affinity_notify(struct work_struct *work) { - struct irq_affinity_notify *notify =3D - container_of(work, struct irq_affinity_notify, work); + struct irq_affinity_notify *notify =3D container_of(work, struct irq_affi= nity_notify, work); struct irq_desc *desc =3D irq_to_desc(notify->irq); cpumask_var_t cpumask; From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 854A22BF3ED for ; Tue, 29 Apr 2025 06:55:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909739; cv=none; b=e/JK3UOButuqsUjtAlebet3rcNZlap7Ik+f4Damcb2ElIdonsynA0p+60JudtxrgEOFZv+U90rggIUa6ATV77KtYVMctvx8tjT5bf2htWCzx4mTCO9xbVMK/E7eYxoe7INXcwhIYTJV210lzw1YJRXHduGBo/ZnEi1mLLjZSuqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909739; c=relaxed/simple; bh=YVtZijiZyzlpE1ERBc6qBMrNAt6o6OH9MDI3lN1aRbk=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=T4Z+D/djB1PKg57Zfaee3gr5CB1tDEjWaWjxfQE3QhVh+YDVOPujsG36pTg6PvBlKmJijTWSr8chAr6IhuA6vKmAywBm6cfh5Gw0dqr+D9c1tLoecXgxHdUVhhqt+Kue1/dbIvG7/YbnHgIIiQQSUofVOaooCv3WLlunR+1Al0A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=dot4+qaJ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Oh2DXtC/; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dot4+qaJ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Oh2DXtC/" Message-ID: <20250429065421.954584482@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909736; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=O1SZUl65koY2vfVoG5zr6VPLgG1xPah5aNKSZiQfGVA=; b=dot4+qaJF+wH3B82hLDhLvrvEn2bYcwRZRTaPCvqfgfdLQ9JIYSDQWxl17HGnkzWkz6187 cet/tN6NAConXGZaI3rLzwg3wGCP1Lt0m835a3D7fVEaStwLUM5rd7A8yfPFVoaYMJoPIH 6FE/9qHx7L1FhBDTcM+oKMdwT6uo7LCYLGADS7z7SDS1BEbJJvFyZQZ60ocU2G3qe41ICo XTwdTokNgYwQmXdtK7Voqzn8NWKKdY2UpvdNdrhGjyzFokS6zbi1xLOPYsFdHRVf93xa4i EnTrXAWIMVPRgNquJtGhghPmTamVwHvbbswzr26Bq6eW48tlDsfRMYkC8SCmjg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909736; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=O1SZUl65koY2vfVoG5zr6VPLgG1xPah5aNKSZiQfGVA=; b=Oh2DXtC/UtVXEjPZaK/gUtSWTu29XopnCvUxiTpivkUc+kuI8nxxzcwTiP5F6SbeJHik8q oRYTzu6yT0BXlbDw== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 32/45] genirq/manage: Rework irq_set_vcpu_affinity() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:35 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/manage.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -627,32 +627,26 @@ int irq_setup_affinity(struct irq_desc * */ int irq_set_vcpu_affinity(unsigned int irq, void *vcpu_info) { - unsigned long flags; - struct irq_desc *desc =3D irq_get_desc_lock(irq, &flags, 0); - struct irq_data *data; - struct irq_chip *chip; - int ret =3D -ENOSYS; + scoped_irqdesc_get_and_lock(irq, 0) { + struct irq_desc *desc =3D scoped_irqdesc; + struct irq_data *data; + struct irq_chip *chip; + int ret =3D -ENOSYS; =20 - if (!desc) - return -EINVAL; + data =3D irq_desc_get_irq_data(desc); + do { + chip =3D irq_data_get_irq_chip(data); + if (chip && chip->irq_set_vcpu_affinity) + break; =20 - data =3D irq_desc_get_irq_data(desc); - do { - chip =3D irq_data_get_irq_chip(data); - if (chip && chip->irq_set_vcpu_affinity) - break; -#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY - data =3D data->parent_data; -#else - data =3D NULL; -#endif - } while (data); + data =3D irqd_get_parent_data(data); + } while (data); =20 - if (data) - ret =3D chip->irq_set_vcpu_affinity(data, vcpu_info); - irq_put_desc_unlock(desc, flags); - - return ret; + if (data) + ret =3D chip->irq_set_vcpu_affinity(data, vcpu_info); + return ret; + } + return -EINVAL; } EXPORT_SYMBOL_GPL(irq_set_vcpu_affinity); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 ED7252C1092 for ; Tue, 29 Apr 2025 06:55:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909740; cv=none; b=ceQYPXoSf3byecETjQmmwCRYD+ArBYWdiH/NXZltHA00C/5h74ILMpRS+bZOtXZ0K9ch3D6u07ul8P/3Nf/LzXtOYunw9/Uf0RzNEDKrTgbrkQyWr2Jk5WJBE0rO/uMrYp0qK8/wdZVXZQNQ0JHwQlQ10cFrnc7izmYoVesyjV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909740; c=relaxed/simple; bh=rCH7D3YVndEYHBTKqPrNqC8oHb9QQzzNUIxTqgLAkRQ=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Gzi9qzY8pJ+Oa/iuxxrE0YpynWiXDy8v8pGz5/mpMGCEGLkHz9NmjZUBinize1X/ZBbGib7OJbi6zG8f3gJZ8LoJf18O0zGMq1iL+eou7BLd/uediJPT8dvNI41RTpPkjlebLNNX/+oEB9DweYWXqDM/qoDgXkeVcriJtgqGpm4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=IE7dhnHS; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=AJVnwbAE; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="IE7dhnHS"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="AJVnwbAE" Message-ID: <20250429065422.013088277@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909737; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=mixybEw9e+vbXEPkKLLg2DsKs+WX44nTeRjKqscHOG4=; b=IE7dhnHSGujZHuosb/hG6Ajo1vS7CrXe2i2XlErtruH/qOA/rE/ZSB/yt6lPJT2Ui1wW6m I396DBprNiGj5Xzq7AnisIs/YV+hlFLsLkkTgjPi0lKaAuNfEjGM3foA9AJf0BuVR2uQGF H7LWk/06+V/VN67latoD2uqYkTf0LafBlwuixoLlz6K7myzVAlKYKdTQ+I3u/zoHJgvzeg 7ocdfMyuWnxUee9fMKo3FdkSgxdOm5WZWcLSTk3fpRHGh68zm72HRqbFipxSvMUtzoh96N qxrRn9UTsTlTPvg+AmNhK8rHXVtryiy3gBpMN0J5WyknIIKS1eqKal7f9JtZFQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909737; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=mixybEw9e+vbXEPkKLLg2DsKs+WX44nTeRjKqscHOG4=; b=AJVnwbAEqbw7j4sw1slhr764QYPY+a5/W4j696YK3HIllVsvmuGVamvTvz/EKi+J5+gUKQ JysFUrpyzK5jnAAQ== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 33/45] genirq/manage: Rework __disable_irq_nosync() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:37 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/manage.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -658,14 +658,11 @@ void __disable_irq(struct irq_desc *desc =20 static int __disable_irq_nosync(unsigned int irq) { - unsigned long flags; - struct irq_desc *desc =3D irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_= CHECK_GLOBAL); - - if (!desc) - return -EINVAL; - __disable_irq(desc); - irq_put_desc_busunlock(desc, flags); - return 0; + scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_GLOBAL) { + __disable_irq(scoped_irqdesc); + return 0; + } + return -EINVAL; } =20 /** From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 6A5ED2C10B9 for ; Tue, 29 Apr 2025 06:55:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909742; cv=none; b=dV8kUVr5LqyL0vLpX/7Rlf937qbKcYKWsa1C/GBKpNXT+dhWcMysCPQe2Z/tycZJP0/xfGQeQs1X8JFwF7i5xlBE2Kpx9wgcVcaqWr0jx+bbJmsQxxUToj7bnHLmXkDI4RfayP6F/6b3K4WVHwiCNpI4dUUU/epbQFU9wule6vs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909742; c=relaxed/simple; bh=BeD5kZT74bu3qyAzu3fyRx9ZyaUisi/okyxKpdNbjSY=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=JbBXxrAvFSDpDnpLXatUIk4frThKbFjcJVuTuwnlbv0kTe9KS0yL6KPXWxyz+iaZf5hzadVUGRr78+pOYy/Q6LKtg2YZA9HGmtQhKrR/OoqqxscGAlkCnSlnLJ4uXmNmYzxAjaIhZr+miF6AU/iv6Ax4u+az3+D8tVHaE7fKook= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=nWhVKtSk; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=grGXVVIj; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="nWhVKtSk"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="grGXVVIj" Message-ID: <20250429065422.071157729@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=oRbFP2vqazsQwq3w2vtQwN8kPro/wwr3nyA7EAA8DbE=; b=nWhVKtSkWMo1lTQqzeMWKJe5HV7E1xkRvPMXzQHpwNkZoNr4rgxKlDbwHOwRNMfO7WHDJy 62Ic8qG1hQfBQfeEvYqMaPX3sMZb+1/OX2NQq/ITO/QeAGiDUn6AKb63VuoBYLubFbL9u+ kUHEbrAo6tbS+pAMzu650SIEhbmoqWHEQ8sskIV+2ocDFw/JnUMMhiufkLCdvyIvlpp1vJ 076caJA4aiQGSLxdpTR85lIOi9eIYhnOEs/sgty3t6be7P+zxfSfG1vkg83B8o0LZq5QaK Ovr19kw6l/snFTNGdJIiOQcLjydMQH+XXdc5BWUGsKzSmArLrl3cr2EFsp51JQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=oRbFP2vqazsQwq3w2vtQwN8kPro/wwr3nyA7EAA8DbE=; b=grGXVVIjqeruCd2YEMqJ7gthA+2wTKP3qyxH62JFFQYdkSJeS2IBdaJB6QrWx2i9uDJDfv qCIm6zndJDNwJwBA== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 34/45] genirq/manage: Rework enable_irq() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:38 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/manage.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -788,18 +788,13 @@ void __enable_irq(struct irq_desc *desc) */ void enable_irq(unsigned int irq) { - unsigned long flags; - struct irq_desc *desc =3D irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_= CHECK_GLOBAL); + scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_GLOBAL) { + struct irq_desc *desc =3D scoped_irqdesc; =20 - if (!desc) - return; - if (WARN(!desc->irq_data.chip, - KERN_ERR "enable_irq before setup/request_irq: irq %u\n", irq)) - goto out; - - __enable_irq(desc); -out: - irq_put_desc_busunlock(desc, flags); + if (WARN(!desc->irq_data.chip, "enable_irq before setup/request_irq: irq= %u\n", irq)) + return; + __enable_irq(desc); + } } EXPORT_SYMBOL(enable_irq); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 04FB22C1797 for ; Tue, 29 Apr 2025 06:55:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909743; cv=none; b=OGdIkrAqs2gmFJiEYjutXo3luASrBpHKp0IuM+zPWuZMcc2WmpFB9FatdJ5QEFM2Zo0ZEJyne3C+tw2TLG40zbda8fjxLIPi6Sb1WR8KxZMXuxQw8ONOBtblppNYHokaBg8WsXXYIDlSgdtBBUlbEWgHRktJZp/TT1TKeHpOKRw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909743; c=relaxed/simple; bh=EuLYauwadghvJEvsNd6VI6s0gL8WDpjyJCnEyNnJjlI=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=MoDUnlrsFJHL3vTun/fVLitXJwiloAkypv3xnDSP1ck3WBsTIXmtgGpeJy0Zp4PxeDC2FSID7g/cOyXE2eweTaf/CJORG0hqkT9HMxAp48RCBBTwWXueH7ndCaLxmOyLXdAHSsQ5CiLQ1nSdVM1zJmA+Xw/dHHO5UAI0jg1CL/c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ffhiiDhB; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Cexvem7N; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ffhiiDhB"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Cexvem7N" Message-ID: <20250429065422.128859754@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=HsKlxOdXhcjf92lznpzYlonKTEkeL+LMzog3zS1q83Y=; b=ffhiiDhBgstfmBgasZPSHm7SzZZrXIyY/RYMxBOgZmEgbGrF3ccMtyZ7dea6KOvmuGl0ZE Nnw7CDAvELM8ibLJZr2oLT7l4vdoWEmdNAW+/WhiBOfJtFLwkNYRzL9JCFnh5o+QZEWW3B wn05si7mswUZOsaIeOjytkTPkb/tMBDfka1fQpsZljqZTW4NInNqkHSywSAdeBh0kcC3C+ iSulyE/UIvJ24h2odbY2Itx45p9hRAXqnf/zgiKIhqs4QWdKMz+XHhg9R7Iw8+972RWcdD +nFEY7CTIyy1gkPlaRN4RC/5pG1kND9PSQDr0znfv/1LlMlMtpJ1o5nZfn/8tw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=HsKlxOdXhcjf92lznpzYlonKTEkeL+LMzog3zS1q83Y=; b=Cexvem7N6BM01y9ddj3F7PhILxJX8v3Onwit+nLxdUBk877q4KvoJstToeFlg03BB3S83W d/c3XyPLe6Qg/QDQ== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 35/45] genirq/manage: Rework irq_set_irq_wake() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:40 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/manage.c | 61 +++++++++++++++++++++++------------------------= ----- 1 file changed, 28 insertions(+), 33 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -845,44 +845,39 @@ static int set_irq_wake_real(unsigned in */ int irq_set_irq_wake(unsigned int irq, unsigned int on) { - unsigned long flags; - struct irq_desc *desc =3D irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_= CHECK_GLOBAL); - int ret =3D 0; + int ret =3D -EINVAL; =20 - if (!desc) - return -EINVAL; + scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_GLOBAL) { + struct irq_desc *desc =3D scoped_irqdesc; =20 - /* Don't use NMIs as wake up interrupts please */ - if (irq_is_nmi(desc)) { - ret =3D -EINVAL; - goto out_unlock; - } + /* Don't use NMIs as wake up interrupts please */ + if (irq_is_nmi(desc)) + return -EINVAL; =20 - /* wakeup-capable irqs can be shared between drivers that - * don't need to have the same sleep mode behaviors. - */ - if (on) { - if (desc->wake_depth++ =3D=3D 0) { - ret =3D set_irq_wake_real(irq, on); - if (ret) - desc->wake_depth =3D 0; - else - irqd_set(&desc->irq_data, IRQD_WAKEUP_STATE); - } - } else { - if (desc->wake_depth =3D=3D 0) { - WARN(1, "Unbalanced IRQ %d wake disable\n", irq); - } else if (--desc->wake_depth =3D=3D 0) { - ret =3D set_irq_wake_real(irq, on); - if (ret) - desc->wake_depth =3D 1; - else - irqd_clear(&desc->irq_data, IRQD_WAKEUP_STATE); + /* + * wakeup-capable irqs can be shared between drivers that + * don't need to have the same sleep mode behaviors. + */ + if (on) { + if (desc->wake_depth++ =3D=3D 0) { + ret =3D set_irq_wake_real(irq, on); + if (ret) + desc->wake_depth =3D 0; + else + irqd_set(&desc->irq_data, IRQD_WAKEUP_STATE); + } + } else { + if (desc->wake_depth =3D=3D 0) { + WARN(1, "Unbalanced IRQ %d wake disable\n", irq); + } else if (--desc->wake_depth =3D=3D 0) { + ret =3D set_irq_wake_real(irq, on); + if (ret) + desc->wake_depth =3D 1; + else + irqd_clear(&desc->irq_data, IRQD_WAKEUP_STATE); + } } } - -out_unlock: - irq_put_desc_busunlock(desc, flags); return ret; } EXPORT_SYMBOL(irq_set_irq_wake); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 015022C10A6 for ; Tue, 29 Apr 2025 06:55:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909745; cv=none; b=LriodpIp+1BcWuTfbrMW0Ro+m/N8KwldXfzMKD8pVDnbTtQn9b5SZbLSWks4/e05RcneoCkLDkXPWXV2DdIgkUKMMVc5V22dXCFyl2ZMfz5yiJYA/xBAW0mgRirS+Mq0uXdonnEbGS1ViqYnc4HQRZY/nUhxlWKEy38j8Y0ybnQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909745; c=relaxed/simple; bh=hp1XbnU/jvxo7xR1mH4pdc8VWSxrDmBVBzwN/X7WGPY=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Q/WY/wY2hQRiWm5MS2ia+yVsC4rhgvByA99dJ3Y3q/WhM+GGYySdVqJ2YagN6Ocge6g5Yxz3/owpKz4vkbM5fY3nlPKTvz5mYu8FGmfG4FpFKgeg9WuiNhU2ns3EBO1fNwUR5BEK/42K6E9kuJVt4bd71w3h+UCZRsYe/C8DoF8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=SoZBHu2k; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=2Z5tqrUB; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="SoZBHu2k"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="2Z5tqrUB" Message-ID: <20250429065422.187250840@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909742; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=7H2bRV4kA50vCHAXHxdbJBAI6o+7XpjxSy9MxMVDH2c=; b=SoZBHu2kxLgrpqZMw8oggbTcP1Av0Ri04+tEXXeNn1v/OgyEGZBoOxp9Ec4L+n/vbW8ElZ n6JYuc22lzsrrqOs2QpXXl03rvG1yPPLZDOE/dPjkthSEK7hvnleiCf1HmpGzJ9/g7aiEN /Rw5QPnKH2fhKuPHPsllpDXHow0tReE1gRWZrxKlgRJc8E3tyDw/An43Vs2swE3/ghPS3P M/OOj0xGTgrLeQ0DSY4W+/An4g7tveGG5Mj4w802Ifl9ZTx3YW1m0cRPbB6YnhjTdRynXz ag/QuJJt5JyFVxJg74RS0R2kzUyXQBwCqgkQpD5skPVoCwkl+HbxBrgam7OOKw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909742; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=7H2bRV4kA50vCHAXHxdbJBAI6o+7XpjxSy9MxMVDH2c=; b=2Z5tqrUBFzYRoVSZKJPqhXg7SC9d+kmCJ65mJVl22RfOSTW+mfgr0eJQZEb2kH76KOFDsx U5u2Hg5wmv7B8ZCA== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 36/45] genirq/manage: Rework can_request_irq() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:41 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. Make the return value boolean to reflect it's meaning. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- include/linux/irq.h | 2 +- kernel/irq/manage.c | 21 ++++++++------------- 2 files changed, 9 insertions(+), 14 deletions(-) --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -700,7 +700,7 @@ extern void note_interrupt(struct irq_de extern int noirqdebug_setup(char *str); =20 /* Checks whether the interrupt can be requested by request_irq(): */ -extern int can_request_irq(unsigned int irq, unsigned long irqflags); +extern bool can_request_irq(unsigned int irq, unsigned long irqflags); =20 /* Dummy irq-chip implementations: */ extern struct irq_chip no_irq_chip; --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -887,22 +887,17 @@ EXPORT_SYMBOL(irq_set_irq_wake); * particular irq has been exclusively allocated or is available * for driver use. */ -int can_request_irq(unsigned int irq, unsigned long irqflags) +bool can_request_irq(unsigned int irq, unsigned long irqflags) { - unsigned long flags; - struct irq_desc *desc =3D irq_get_desc_lock(irq, &flags, 0); - int canrequest =3D 0; + scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_GLOBAL) { + struct irq_desc *desc =3D scoped_irqdesc; =20 - if (!desc) - return 0; - - if (irq_settings_can_request(desc)) { - if (!desc->action || - irqflags & desc->action->flags & IRQF_SHARED) - canrequest =3D 1; + if (irq_settings_can_request(desc)) { + if (!desc->action || irqflags & desc->action->flags & IRQF_SHARED) + return true; + } } - irq_put_desc_unlock(desc, flags); - return canrequest; + return false; } =20 int __irq_set_trigger(struct irq_desc *desc, unsigned long flags) From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 D5F9A2C1E16 for ; Tue, 29 Apr 2025 06:55:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909746; cv=none; b=Zq2fFf0+DiGeIz9fhXPJPdV5cVs/WwF679pV/W/lh8Eerd0FE+9qgIHE+G4yah+HjmAX8Vmv1OhYG9GFWYP/daljZISod6HSC18nRqSTE+AesaN5AkVL4mxFdsh+f4CkhsiDNqaALXyf28uNFzJ30QM34pjUA3rQ3ykjAzOIHMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909746; c=relaxed/simple; bh=uWc/0dk9VurpXJBAwPLXkPXP89nU98zgJYgRWU00PYA=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=HUTYB2RmXAYtTCAsgt4MHf9YW6WzrQiz0HZ3MII6SNzBh1pAy0x/fAV7sJGQ1CR0UnojeILJLgT420DsD11U1KNxMtkbPpMYdMAsrLV8KZvsZ5lcHjc1UZa6bRKeaxKvT6MoLQdtG2ypCEOcp2k+EG8Zv/1IvgU6y98zulY/olg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=PEGcj1uu; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=jcN4XojN; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="PEGcj1uu"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="jcN4XojN" Message-ID: <20250429065422.258216558@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=O9cC3l3NuY11K5tWj89mtb2MBOMdw0xdTbcCSn48HHM=; b=PEGcj1uuWU46c2Y4Gm25jDN6dNg32QjkiNb4ccNzatu/hha9j/ruxErXuDDU1brAMlnk4E wZFtM2rTCBqyGMbJZQ6prGpxc2zJU+e41qVPibdEfuj/b/pOz/0TAT6z+OBWHYAxxJe24d 4V0PkE/Vdl0ZdeaHy8ehTrYkDIUHpUjXLSe9t7eUOVkCmalEic9DOpC2+UJmZhmIeZBlIn OU9YIL0+IlNG7zAzIMFekfa/R/mfY5MdsqA+xv+vgv6qhUKSAsr71yoZHZ71Tb2Imh7vMl +yv6ESpbKWITiZOzM7H5RTfrawgHBi5b53gxB9LKqfQuAjuvhYHWaYrDz+HVXw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=O9cC3l3NuY11K5tWj89mtb2MBOMdw0xdTbcCSn48HHM=; b=jcN4XojNxPhYlaZadgxvlbgOf2OzCvQmPS6CXjaVMRRTg2ca1qRY9swCDtJIiUEYNnPXfW /RNNyyK9909yiyBQ== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 37/45] genirq/manage: Rework irq_set_parent() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:43 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/manage.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -958,16 +958,11 @@ int __irq_set_trigger(struct irq_desc *d #ifdef CONFIG_HARDIRQS_SW_RESEND int irq_set_parent(int irq, int parent_irq) { - unsigned long flags; - struct irq_desc *desc =3D irq_get_desc_lock(irq, &flags, 0); - - if (!desc) - return -EINVAL; - - desc->parent_irq =3D parent_irq; - - irq_put_desc_unlock(desc, flags); - return 0; + scoped_irqdesc_get_and_lock(irq, 0) { + scoped_irqdesc->parent_irq =3D parent_irq; + return 0; + } + return -EINVAL; } EXPORT_SYMBOL_GPL(irq_set_parent); #endif From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 60F5F2C1E2A for ; Tue, 29 Apr 2025 06:55:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909747; cv=none; b=QY0e2giQy3jfYEDEqn0tKp6tE/VLpfzSXyJlhQvM38G5/FY46Z7hn3wqWMEb7sNd0ilR1qGKhOj56KnveFmaAPYCi2u3C1hHP/Nt9vCLu1BmHUEdbziSqRLgRhwA0odEK4Uj3llq20Wq140pE/pwdltqDhRPyZzQq7AMrRbBek0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909747; c=relaxed/simple; bh=pSdGud0pdsDuQAiwZsJxWzc1blchhGKzeVzdfQKR/zU=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=FuizVUkjxIKMmttv6NwirIbI00pnM7Aioinf+0bCIdhjIByfEx+XydeOHr1YVCjkt/6+bjWuIkfjonsnWJ5CGVoZajJUK9sNWYQPrOvxD6JN7VhF+8O4ivv4uC+84Vxqh6vCGictGi9F0Yap921mVcFmfn3Rs2O4xHktWtV7eeE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=qmJMyjJ5; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=yPcABZS7; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="qmJMyjJ5"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="yPcABZS7" Message-ID: <20250429065422.315844964@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=iRPvvR1vdljT5JQUmMeQpQOdsqp0lDA5a4Uza/350Bs=; b=qmJMyjJ500SPKH9ibcJK5SAP2wRH5PL/7gsMaqhHl/VEa2IlCLhadnPpXOJsN2kd+hcyxj +h+CHu7TE3T6C59bxFBFrimZCjjT1ePSAB0n2GE/Hmg1xCfBCEDanGbv6elzx6JrDIaB/B JDD3lu8J4Zej4J3EaFtJGzxMLsoqPMsktvi1tY7T6eXRPR4/MVMpkr9zgaUqWP4Y0Xmlop L7DoU4XfDi/nXwr6W1r8z30+iOdyLk5luWWFj7JnYWnUWEWaorLAerYJbSbY03aaeNOLbk NhRjKBaiz4kzjnTVzgZnIIWTG98eQZF392Lb4yN6D3ZjB7sKXEjs8A6XLoi1hQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=iRPvvR1vdljT5JQUmMeQpQOdsqp0lDA5a4Uza/350Bs=; b=yPcABZS7z54UcEPsg05FQX7oe1hF0WE/qG4sH1S7WL/7ZuP9MfiaQAIrNjQ2rQ5MNM95Ez fy8N7YEgKhdTBEDA== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 38/45] genirq/manage: Rework enable_percpu_irq() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:44 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/manage.c | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2285,35 +2285,25 @@ int request_nmi(unsigned int irq, irq_ha =20 void enable_percpu_irq(unsigned int irq, unsigned int type) { - unsigned int cpu =3D smp_processor_id(); - unsigned long flags; - struct irq_desc *desc =3D irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHE= CK_PERCPU); + scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_PERCPU) { + struct irq_desc *desc =3D scoped_irqdesc; =20 - if (!desc) - return; - - /* - * If the trigger type is not specified by the caller, then - * use the default for this interrupt. - */ - type &=3D IRQ_TYPE_SENSE_MASK; - if (type =3D=3D IRQ_TYPE_NONE) - type =3D irqd_get_trigger_type(&desc->irq_data); - - if (type !=3D IRQ_TYPE_NONE) { - int ret; - - ret =3D __irq_set_trigger(desc, type); - - if (ret) { - WARN(1, "failed to set type for IRQ%d\n", irq); - goto out; + /* + * If the trigger type is not specified by the caller, then + * use the default for this interrupt. + */ + type &=3D IRQ_TYPE_SENSE_MASK; + if (type =3D=3D IRQ_TYPE_NONE) + type =3D irqd_get_trigger_type(&desc->irq_data); + + if (type !=3D IRQ_TYPE_NONE) { + if (__irq_set_trigger(desc, type)) { + WARN(1, "failed to set type for IRQ%d\n", irq); + return; + } } + irq_percpu_enable(desc, smp_processor_id()); } - - irq_percpu_enable(desc, cpu); -out: - irq_put_desc_unlock(desc, flags); } EXPORT_SYMBOL_GPL(enable_percpu_irq); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 A35F82C2584 for ; Tue, 29 Apr 2025 06:55:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909750; cv=none; b=iBHJ0Bu5aoWcOoa1aAyMAcLq9HLihHsKBRUjTj1QD9ydT9AEEWrSgfsmTJDj6Hx2fAWcXpc0Sr24ef0jOeRIEhGfpxEBvQmk7RO+3blovpqTg8cHGD4etMzYyI0/ZzoAA/yRDKyPMP4Ut9kXU9vxyepUVsn82yXexU1tGN89JR8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909750; c=relaxed/simple; bh=2XxpC2RxhOA7srYB+U7Vp2rZuFSoscf2aU9AyMnU7b8=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=kddpEltkxGQpxrxBj4YLRTNdf1OoTR0NNb5RatrZr7bfDH5boqqHq598/AjIwECUrdc5kpz+6P4mWNOMYcISA1+oAk1bW5Zx6S57zq2gJC5GASnubxZbsjRNfyTKB9xPB6KzsMt5aZ63tEluj3RsCgwXh4r6FG64yj3Mq4gVndw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=0Rbu3fzF; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=OiwUQlw2; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0Rbu3fzF"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="OiwUQlw2" Message-ID: <20250429065422.376836282@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=y0RQv0Usg6hq2Yp5lrhta5X/eMpx9K5AAvjl1AWK/n8=; b=0Rbu3fzFw7EIo3Mi5SR33dZmt3k0pbykzFBj/SmgivzDpBEnTg424CVlRfNgofGkQPe16o BRdTB0JGpiztLi2+2Qk+u/tgexQf7WqkocqVyVHNrZL7yX1VGJfC+rvdPndg/M9oKYYmB0 x1K7DSGEkrS1x525WcmKy/TQ2pr35Rm1iw950JHRqk+4th0bbng/HavqfvXnQHSXuIKsBW k4+i6A0pwq20XgRnj/Dl1uknQrRTt30Jsrg/EjerAL4XWpVPhOavCQameDQw+JS5mQXC8V MQdCkUCCDAATaDINu9Z5oY8HYbpESbsHkCcpwW1ufzacnG/tc8MsEwNOTnuQ+Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=y0RQv0Usg6hq2Yp5lrhta5X/eMpx9K5AAvjl1AWK/n8=; b=OiwUQlw2LMJzTqIDPLhoIpqd+Lz65KXZQR/BczY3P++XZDJ+BoQ1bgV7//2/3xWdgEQ9cH 3bG4IyGvAhZEotAQ== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 39/45] genirq/manage: Rework irq_percpu_is_enabled() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:46 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/manage.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2321,19 +2321,9 @@ void enable_percpu_nmi(unsigned int irq, */ bool irq_percpu_is_enabled(unsigned int irq) { - unsigned int cpu =3D smp_processor_id(); - struct irq_desc *desc; - unsigned long flags; - bool is_enabled; - - desc =3D irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_PERCPU); - if (!desc) - return false; - - is_enabled =3D cpumask_test_cpu(cpu, desc->percpu_enabled); - irq_put_desc_unlock(desc, flags); - - return is_enabled; + scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_PERCPU) + return cpumask_test_cpu(smp_processor_id(), scoped_irqdesc->percpu_enabl= ed); + return false; } EXPORT_SYMBOL_GPL(irq_percpu_is_enabled); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 B9B132C2594 for ; Tue, 29 Apr 2025 06:55:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909751; cv=none; b=PuWQ/WHvI2zSbe5m+RkhDs0nJs6F4v80F0d5aZnNed/V2E+oke/Zl7aXE5T9gVn1H67mI3kc+3860UubBg3SXNtM0b5uk3wrB2se33KcnlNWs1eHbGcqXHxt4uCProuNr4vRhHGPeEdLOcP2I5+dkZTiZYSYNF6G88fdT3jlXWg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909751; c=relaxed/simple; bh=P42hnB6j3DJbVSHlLu4GOxnDjvWen9dRzM9wM4+LWJA=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=qbiewwr5VeT7dl1g1Jyy6MxSzKKfNMlrIeJbkHJYCzDi5Xkh8UGhajxYGNrVESIEfX04DurK+880SLCJnKoVoo5pVeVxfhAmjt0R7ej02oMRcoUnSll6Wy9YoepOAX5BmFJ9KMas0f4S2t21VYac0Th4OV22Z+mJgc73fkAZqZo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=P7PybItJ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=dFE1BBCf; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="P7PybItJ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dFE1BBCf" Message-ID: <20250429065422.435932527@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=65sRjBqgyaDaw21QgaT0ciFt04GaxsOuuK1XPfRRKqc=; b=P7PybItJVQhnSagNun2aEZEXGnz3La+FRvDPBBRznjoUhthU8zS56yDrLto0wKtKkuErl+ qsMeOw2fIl0WhbMtd6b/J6bpobM+nrev8Vt5ChKfeo+UflbU/0hSwfTwIXbacFQL1/Bg8r U3i/GHNT6KlqhzC1AsroPZIgO+Ck7LMSl2Qt3wWGNQIDOaj8gV0wrdWQL42fk/gniPmKPP JxHFp//T9bZ6dqYkdgyjG6BXufJZdyXz0W2pGmNvY657iD/qgYMA8eV0NJZzHyLVJdJEeH fEnXd9mm6ELFo3geyzs+Jx1JTb7y68115ZNWeM6EOjm9HvJRTfh03zn9HcQRPw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=65sRjBqgyaDaw21QgaT0ciFt04GaxsOuuK1XPfRRKqc=; b=dFE1BBCf2Dmv2DSE3hZphaOrXYsD06DjVLuLx/N1TmPYNIiANJFHenjpmvuDHdVjbGr9HR ESMdqDiJl1TY6eBw== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 40/45] genirq/manage: Rework disable_percpu_irq() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:47 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/manage.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2329,15 +2329,8 @@ EXPORT_SYMBOL_GPL(irq_percpu_is_enabled) =20 void disable_percpu_irq(unsigned int irq) { - unsigned int cpu =3D smp_processor_id(); - unsigned long flags; - struct irq_desc *desc =3D irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHE= CK_PERCPU); - - if (!desc) - return; - - irq_percpu_disable(desc, cpu); - irq_put_desc_unlock(desc, flags); + scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_PERCPU) + irq_percpu_disable(scoped_irqdesc, smp_processor_id()); } EXPORT_SYMBOL_GPL(disable_percpu_irq); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 C40CF2C2AAC for ; Tue, 29 Apr 2025 06:55:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909754; cv=none; b=Vz+u8UIMc44OlfBbujF1REGjG+FyBmmT+2SrLTclkZf06xHntVV4b1qCOymEFI9T3nPZaBbWphrURKgY+D7vrwOy7yyUDh6a53SeDSaFYM4NsOmoOgby0IWVS8HBFA4kJFp9TVOsj8rP6m9/AXiF/AQGutJYsSuYepdy/KZniiE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909754; c=relaxed/simple; bh=EscLPA6Ui9DVdZvvRYs/ZOQxb87jF2v0Kse8MMN7sfo=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=m6CSaBAkvm5+P850nhMm72+PwNV0jaYoATizgFJ6b4BudHHInpvrT6uAvyxYU0xBSOXh/hC2gnlQk2Ks7wRJuMYMyxP/PygefvADF7aOr3v03rb/7aMHX+0fTH37P9Zzpq+TwdN7oRyUa5efKCz8Kc15RuWXAbYeMjVVdlptvk4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ov1kbNuo; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=6IZ458hB; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ov1kbNuo"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="6IZ458hB" Message-ID: <20250429065422.494561120@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909749; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=teNvXoruARNQEkuaxvyETAwfG95tGssxz5B3UPQFHUg=; b=ov1kbNuoIspQh+02lNjTXR+jaBXnpv7kdtnhxw4laYk5Moyes+9leCPE3sMlNCz3Sq4h6n ubZ8MX3D6fRkEN3yL7vM7SXnSB0IXS09g+pCv2PsURfhLPxKRtxQ58f7O2LM91SDIGckJT lwh9iAi/t9cOAKrbGO2BpISwHhrVK83k6Ap1gZ47AfO2EbSrvYkGNIfSWsbPERg8/ySimN R9JyCi2rbJ7BO8MW6NC5oNQ2gX2UWYKbpZhB2gWWzets+Z0KheLNQGkv7+1RKiTedTYS0r oVhvP/tnuIh/NwnDLp5Xn1KsEuLPJQiX+7xOTDnsM11307Byxu/bi2m4kl1Qbg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909749; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=teNvXoruARNQEkuaxvyETAwfG95tGssxz5B3UPQFHUg=; b=6IZ458hBxnewxnk0a+FbeBnUbvaaQTv5msfge8FKmlaSK24ez2p8uFfwVnwE1i5+tpmysW F3hWoDMxRUzVH/BQ== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 41/45] genirq/manage: Rework prepare_percpu_nmi() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:49 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/manage.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2605,32 +2605,19 @@ int request_percpu_nmi(unsigned int irq, */ int prepare_percpu_nmi(unsigned int irq) { - unsigned long flags; - struct irq_desc *desc; - int ret =3D 0; + int ret =3D -EINVAL; =20 WARN_ON(preemptible()); =20 - desc =3D irq_get_desc_lock(irq, &flags, - IRQ_GET_DESC_CHECK_PERCPU); - if (!desc) - return -EINVAL; - - if (WARN(!irq_is_nmi(desc), - KERN_ERR "prepare_percpu_nmi called for a non-NMI interrupt: irq %u\n", - irq)) { - ret =3D -EINVAL; - goto out; - } - - ret =3D irq_nmi_setup(desc); - if (ret) { - pr_err("Failed to setup NMI delivery: irq %u\n", irq); - goto out; + scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_PERCPU) { + if (WARN(!irq_is_nmi(scoped_irqdesc), + "prepare_percpu_nmi called for a non-NMI interrupt: irq %u\n", irq)) + return -EINVAL; + + ret =3D irq_nmi_setup(scoped_irqdesc); + if (ret) + pr_err("Failed to setup NMI delivery: irq %u\n", irq); } - -out: - irq_put_desc_unlock(desc, flags); return ret; } From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 B57E42C2ABB for ; Tue, 29 Apr 2025 06:55:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909754; cv=none; b=hGxdVOVNKDDiuJVGKHWoAyyX4+k44hjkhYPpRPcH/QujjjeVnXkS1gNnIgFR8JQWb3tAdyiuVnKfQieQDCGg4nBKGKmMypdyyRv0M4HUMwQROaL2rrgyu5dVIxpBiG19nvURDFmpb2Rl6V0Hc/7DMpFzhDf1uni4/lBvWUN79lg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909754; c=relaxed/simple; bh=NysoEMc8sHk+hVKOaj5S21HDxeYCPz+SeqCFfnyod/E=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=RgUufC1bY479Ps+H71wrU4vwClNvjkqGdw/fbIpO4lihtbtayTJMmleooj1yaxRoqupxg64loRCqNy9F7LxKR3a2SYraAmJ09rIyF5kijfzGbI/GwVw7ZItbAdJxYqHzewkTNJnNreUebueyTIfkd2cMsVXE84rc6JDX1yppJl8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=dNQg77LH; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=tFa+KQgV; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dNQg77LH"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="tFa+KQgV" Message-ID: <20250429065422.552884529@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909751; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=PZStIo/KVfZY9c2a55J+FjqPZf5Oq/jY/bI6TOIxB5I=; b=dNQg77LHIKLmwifjssEqntiJ+FNc5lPiSsK2jCB0wmiVG+nxIVyqdTxZJ1fBK4lNejlCJc BiTlq3vJfnb2vLLn5lbZkjqAaLoRTBW4qlLaVUzeePfNXylHlTK1MCNzxV54sm/ykh0fLq FhF7QqrrzpPvxUgKTC50w9TDmozQYIR9MIhefBqzyy/cnByN0edLN7hIig8B6bSzWe51iF tHcZoXZILQJaiGOsPyXGL4WeQ5N5ofh2dS8YRekNvZaZaru4pXeaqseAb/VJT9vdLpdyvE fH2UXjkBIDkdkGv9iWPUoIhfVlloUoxZhFmTurax/ZIhhe+HbZzO4cFPHvrIcA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909751; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=PZStIo/KVfZY9c2a55J+FjqPZf5Oq/jY/bI6TOIxB5I=; b=tFa+KQgVRUkR5YzpN+oBXj0Q/YSWvu7m3z0dB6Zl+t7ho7doQKuHCo5tN/b8dQq/oqFrUB v9piSMcHb1ZHF6BA== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 42/45] genirq/manage: Rework teardown_percpu_nmi() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:50 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/manage.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2635,22 +2635,13 @@ int prepare_percpu_nmi(unsigned int irq) */ void teardown_percpu_nmi(unsigned int irq) { - unsigned long flags; - struct irq_desc *desc; - WARN_ON(preemptible()); =20 - desc =3D irq_get_desc_lock(irq, &flags, - IRQ_GET_DESC_CHECK_PERCPU); - if (!desc) - return; - - if (WARN_ON(!irq_is_nmi(desc))) - goto out; - - irq_nmi_teardown(desc); -out: - irq_put_desc_unlock(desc, flags); + scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_PERCPU) { + if (WARN_ON(!irq_is_nmi(scoped_irqdesc))) + return; + irq_nmi_teardown(scoped_irqdesc); + } } =20 static int __irq_get_irqchip_state(struct irq_data *data, enum irqchip_irq= _state which, bool *state) From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 4F2432C2ACD for ; Tue, 29 Apr 2025 06:55:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909755; cv=none; b=O6j0mKy/ND92Gg5mUATQUfx6T6zc3LKwF3zi0sbWM2KWvqL2OcWawfwqsXG4W1iNtqhjM2J8JZkF/H5fTj6Bj4gdFSBbnbS1i8GpHJDDyCL2RcF0mHKwdxJ4Z5HHsUyF5hwJ4XrCr8exEKNwlHgk/yv0DK+MCev/lEEiOPMav4M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909755; c=relaxed/simple; bh=CqOoBoxPn59Lk+B8VXRAe/PpXesnV+W6WcfsyWXUY9g=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=PShqk/P/Qj2b3IKPpc/cXgBL98ks6UDXttI750pZvzCJJAy2mFiLsZHW8ycCGH9xxf6F/1bM/WvtC3FoLAZLb3Ps3cg9S6H04GF/6xj+/SprTBx/lsRrDrxbvSgakXMiBxQNd+G1jrlns8RU03ut84zjHChS1SHcg7n9SHIutyU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Gv2fJPta; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=qOJenP7O; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Gv2fJPta"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="qOJenP7O" Message-ID: <20250429065422.612184618@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909752; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=EEtdnupWv9I26kCA+YPdjj0rMnyT0nFIZklaHgPYBc8=; b=Gv2fJPtavN/1+d1lJIKPjlOIGFdxz/bK2L5cC49n8lrUiEoIRXLioIEeNBzqqjzf7WUOLO xIzb99Vx1Mfg03g3pVZ2LKyzRLNTQ0xWYJw+pxX5tu1UMWAdughQA2mPYbYDYiiGRJiRs3 0jDrUeKmjoE8nEdVcMLAT3OL5apPCy0jwxRC3CTtZEvuaSXcKZE3LisU6IJX+uPCQfGnOd eNRRnVXVGDk/6DEE7FBbplQngOBu5HcX975HBmKQXa+unSJ1zhy3rbPxpelQTKMKxnFbVR 28QQmmMNU6Av5cXkunWPdql96WDWlkGSQtk4t/lbVRgVZShktsQnZBYX2OKpZQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909752; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=EEtdnupWv9I26kCA+YPdjj0rMnyT0nFIZklaHgPYBc8=; b=qOJenP7OARXJogVZmxGOZuzyZyQTbI/jNRZASdD4HY25YUp9WrYvghrQ/f9Ao/0sMmkHfS FqRxl14Jrk4fQ/Dg== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 43/45] genirq/manage: Rework irq_get_irqchip_state() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:52 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/manage.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2678,24 +2678,14 @@ int __irq_get_irqchip_state(struct irq_d * This function should be called with preemption disabled if the interrupt * controller has per-cpu registers. */ -int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which, - bool *state) +int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which, = bool *state) { - struct irq_desc *desc; - struct irq_data *data; - unsigned long flags; - int err =3D -EINVAL; + scoped_irqdesc_get_and_buslock(irq, 0) { + struct irq_data *data =3D irq_desc_get_irq_data(scoped_irqdesc); =20 - desc =3D irq_get_desc_buslock(irq, &flags, 0); - if (!desc) - return err; - - data =3D irq_desc_get_irq_data(desc); - - err =3D __irq_get_irqchip_state(data, which, state); - - irq_put_desc_busunlock(desc, flags); - return err; + return __irq_get_irqchip_state(data, which, state); + } + return -EINVAL; } EXPORT_SYMBOL_GPL(irq_get_irqchip_state); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 479432C2ADE for ; Tue, 29 Apr 2025 06:55:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909756; cv=none; b=q8I6/sHom4cPvOW062h7XrYyfzkheBW5gxag1S6JhBT7u2J2THcFR3aQqmgRRYfLx90GAcidr1r9NB+pSriyRkukVCj92f7x2noNyM/qbQRwTkekFPtazKxjVOtkIV6teiLxy9iZZyPzz7LWo442KaBsn7XxDI9WJYBltVBsQDk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909756; c=relaxed/simple; bh=Pty16V0aUdjfc4iLm9KGFQyZNC+KLWVQ8C8jh9Mvng4=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=fv3+/8tTruIqX1Vg6bqnAvHCWW8Ql/2i2O9KVZcX2ZC7zuIs+9M6NLpQo5dtmyZYAKO77/035Z4j6erkgPs9JLBpAzCIrkYxuQks2kcS6gsslGYS8oYSz2THy6EIgUFdpIjtpOwGcWTTgSIO4KTdMOd38VTRLfBs83p3CU7XpgQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=JOZF6pR8; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=o3zdPGuW; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JOZF6pR8"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="o3zdPGuW" Message-ID: <20250429065422.670808288@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909754; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=CREQ8Y0Hd7OuMmIhnKzrHG4hV9t2fLzNznUeP+yjxsw=; b=JOZF6pR8Sv/5j0E2OohaYJAddo0dGj4MNuaN/GNmYo8/ZyHeL537YQDfHtoQKHdkeyjlP6 FH26fv+Ehgc5+P1GEvRMqY+yGPV5PIP2lzibtF7lEABmo7DFzheD+ca2a1Z+YSXtdc3QUH FdfktvpywHLLO0uq6+niiCzCV8k/5xx7KrBRNn1RKC79Nx40kQEXJS85xsqB7rZD6jCy6p 4ygUQbrpbpTX/MWkTeSJ3PV7/qPk6/truBwDjHpinze+n/EpXvFD+MLUlMPMd8aETFuu8S pkc9E3R0aWl8wV1IXcxbC/dhJbVgoBOtMdz0aO9JpKpxeL818JDrGlIi0hCKtA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909754; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=CREQ8Y0Hd7OuMmIhnKzrHG4hV9t2fLzNznUeP+yjxsw=; b=o3zdPGuW4pqyEaqyQ/guKsqKVDOpT0ZbmiI68Mmq5zJhUJrtV6NsQ6SXiEJ3QZajZHgagL D50LIncXtjUOqjDA== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 44/45] genirq/manage: Rework irq_set_irqchip_state() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:53 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new guards to get and lock the interrupt descriptor and tidy up the code. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/manage.c | 53 +++++++++++++++++++----------------------------= ----- 1 file changed, 20 insertions(+), 33 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2703,39 +2703,26 @@ EXPORT_SYMBOL_GPL(irq_get_irqchip_state) */ int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which, = bool val) { - struct irq_desc *desc; - struct irq_data *data; - struct irq_chip *chip; - unsigned long flags; - int err =3D -EINVAL; - - desc =3D irq_get_desc_buslock(irq, &flags, 0); - if (!desc) - return err; - - data =3D irq_desc_get_irq_data(desc); - - do { - chip =3D irq_data_get_irq_chip(data); - if (WARN_ON_ONCE(!chip)) { - err =3D -ENODEV; - goto out_unlock; - } - if (chip->irq_set_irqchip_state) - break; -#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY - data =3D data->parent_data; -#else - data =3D NULL; -#endif - } while (data); - - if (data) - err =3D chip->irq_set_irqchip_state(data, which, val); - -out_unlock: - irq_put_desc_busunlock(desc, flags); - return err; + scoped_irqdesc_get_and_buslock(irq, 0) { + struct irq_data *data =3D irq_desc_get_irq_data(scoped_irqdesc); + struct irq_chip *chip; + + do { + chip =3D irq_data_get_irq_chip(data); + + if (WARN_ON_ONCE(!chip)) + return -ENODEV; + + if (chip->irq_set_irqchip_state) + break; + + data =3D irqd_get_parent_data(data); + } while (data); + + if (data) + return chip->irq_set_irqchip_state(data, which, val); + } + return -EINVAL; } EXPORT_SYMBOL_GPL(irq_set_irqchip_state); From nobody Thu Dec 18 07:29:20 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 DF3722C3764 for ; Tue, 29 Apr 2025 06:55:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909758; cv=none; b=lfIso4DKqEvtMDkJlWpkuv6R09ZS2+rYlxwT/LomNNxlTOGaq0LvHI22I8QNvqF+q6XAjsUDFYnYtkSxHd9/r30GAhIdrGUQD/MugEPFOf4muVZQFc1iLgslClzJ5n8BNCKSJBEqtjatMshNng/hMv7WjkLQ1TQcv9NQX5L1rF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745909758; c=relaxed/simple; bh=A53lDnTtx1pSe4rB+QcTgrY2OTzmit0u8CfjoqN4b+4=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=rKtG/22GJS8edu98fcSUNuhsqkfQaRAPc0OfR8bMYbdVVcBaKD734DFAje/rFy2gUh0wgpy07Y8Mj6CNhffxb+w1grhvCTjiwATa65AlmPwzFG3gFAoLzoTs34eVUBwJK6bUT3/lqrtyy2AwCi8ihGbMtKffWdSWHr/Cf5+amB4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=a64przSr; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=4zAxbean; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="a64przSr"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="4zAxbean" Message-ID: <20250429065422.729586582@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1745909755; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=9e21ikF2knHkJivTgzjPtHpEHiTJHT9JB5QoqPVKPvw=; b=a64przSr0Pt8KY/e0kvyPioZh1C0J6Sqa4qwCnrQkSClZ7Ukd93CqAgki+l7up64o3qqGW UfHjYUNmyS6tsyDZALKDzWbgf1m+Taytd7EIqfhOQfTwXZ2RU+aSlFV9aj9uYyPbdWZgWK ZT6oEmMNos3Q4rn5BFNYj7gTlAo3aY+B9IT7geBr+6JNs9nswJajk3XxU0D6gZ/VsQD+tU SLPsC8MQAxbn6s1dGR/DR+Mdcp1zLF/+AMcIQRKHSyCtCTM73cqe3jkWdAk6rFMPh16xWr fDRFIGKyBFBE+vEiYBLT7e7R2G/0RhkGoEfstOkH72gXTbfCBhLET8ue9L4TqQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1745909755; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=9e21ikF2knHkJivTgzjPtHpEHiTJHT9JB5QoqPVKPvw=; b=4zAxbeanjaBFDb2QfhHEiygmfDWtuJpgNBtaGeqwHhvTmFUqw9Lp6ZUsje+OstrI7KH1UF e1+zVhKtNVMRBoCw== From: Thomas Gleixner To: LKML Cc: Jiri Slaby , Peter Zijlstra Subject: [patch V2 45/45] genirq: Remove irq_[get|put]_desc*() References: <20250429065337.117370076@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 29 Apr 2025 08:55:54 +0200 (CEST) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" All users are converted to the guards. Remove the helpers. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- kernel/irq/internals.h | 24 ------------------------ 1 file changed, 24 deletions(-) --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h @@ -191,30 +191,6 @@ static inline class_irqdesc_lock_t class =20 #define scoped_irqdesc ((struct irq_desc *)(__guard_ptr(irqdesc_lock)(&sc= ope))) =20 -static inline struct irq_desc * -irq_get_desc_buslock(unsigned int irq, unsigned long *flags, unsigned int = check) -{ - return __irq_get_desc_lock(irq, flags, true, check); -} - -static inline void -irq_put_desc_busunlock(struct irq_desc *desc, unsigned long flags) -{ - __irq_put_desc_unlock(desc, flags, true); -} - -static inline struct irq_desc * -irq_get_desc_lock(unsigned int irq, unsigned long *flags, unsigned int che= ck) -{ - return __irq_get_desc_lock(irq, flags, false, check); -} - -static inline void -irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags) -{ - __irq_put_desc_unlock(desc, flags, false); -} - #define __irqd_to_state(d) ACCESS_PRIVATE((d)->common, state_use_accessors) =20 static inline unsigned int irqd_get(struct irq_data *d)