From nobody Thu Dec 18 07:30:09 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 49AD52690F2 for ; Thu, 13 Mar 2025 15:59: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=1741881587; cv=none; b=hSUBBGz5kwfu9DNvqZ3kYcZGhgV3fz6GUmBskF8AIwA4xWvyFrK54wYSZSqiArKRFJPIPXw0pp4gOm6iUDHPR2SHMvhiej2VxLMuFVcvg7MfLzdHLQdRCUqal9UGJ9w5uFrft/UhltidCHiB6wgoQDtlnFUTJvDRbJbIpZY5nXo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881587; c=relaxed/simple; bh=46A3UhnYd7qHpQVGclqJIBmLNsxJAxIKhYFDvz9/UgE=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Dz1Z+LFSmRxOTcJH++WLQIfLhJ3d5z7aPjpvfoG7lkIyZVazYcLI7RO3Ul7hxxXNXPKelhgApmeIFrd833WSHYmuGHFyTM0Hglu6g7PaSaY7w/kcpVwpo6c6OjFIGLKtAYDi+DkegamPm8lm5cAUAwGyGYWcU9DihD1F3GhOsQ8= 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=twDVoK7c; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Y9dib2Su; 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="twDVoK7c"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Y9dib2Su" Message-ID: <20250313155913.943406435@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881583; 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=Ock9hFbrCX/0jm57e6t3l2AeBjWICriMwni1mvhD8xw=; b=twDVoK7cubkvuOfqM+NtrWLAbzsXjgV1BIeS87rMK5S3lDDPDnsN4TXmH8wzRJtx6koQK/ tgkwqP3P/JECsazRSoJ/4ukDtNM2VDlg5qFVsUg087XXf6b1NAfGtbbIIx5+4HKx60gVFB 7mJ6/kwPhxMrf5P5pEj5RWonwSgf9iMZ6vAXbCFcmmZ7oECcU0l09AMfAG7tT9uYKVZ09w cICVNkSSquDf1yuWS8Nii5GKjLnq2dF61Z/IMVu9jbt5heJ+HLg6uQ0AxIud2XjRdKgX54 uNNFqdvgI04HRU9WU145AGS2qyg5brr93x3NxvBhItlzXtK95gY5PXvbiw9T5w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881583; 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=Ock9hFbrCX/0jm57e6t3l2AeBjWICriMwni1mvhD8xw=; b=Y9dib2Su5PG2HJXoaxY3SuUyTvpJzEAC+M/0eYFuJBNnZu3pIPMMfpkk+2ddELimWCVTMT cNqPVzLOBj1tXIAQ== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 01/46] genirq: Provide conditional lock guards References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 16:59:42 +0100 (CET) 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 --- kernel/irq/internals.h | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h @@ -150,6 +150,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) { @@ -169,14 +173,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:30:09 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 7AF11269D16 for ; Thu, 13 Mar 2025 15:59:47 +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=1741881589; cv=none; b=kbcMrIR9PlNUcc5pZF/MfFI6LFM2lUI1SqCbahlfd8DeO2tLXbmlbBWHBn21ShpZWfSzHzLAwsufFqjf4uV+J3K3X7Xm27nVxF3z4zz6EZFtZs9yRoCTJJvxTfQUWLGNhLw7jvD1b9h+0MYrsAEjBpsgVLqWcrPNCr0b533S/9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881589; c=relaxed/simple; bh=IVJhpYURztDJOZBABhyAoqcfzgKz3pCP/FdaRTf/1WA=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=es3dDL9O29wUZc6EMS5tzrRSwzl98KTEcYvFhlpPFJekuJtJboWJMFoMydT2DvUedYP8qsIS/QM4agQ4rC75haDMVfV5csXk7Px6+AGMbGYU4mh49iK/mSyqXVDPV7yMILjiHuOniXa0qH7AnYAycNHKrzdJ1eA1su5R0ItcTPo= 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=2HqymcWp; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=hHolmahl; 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="2HqymcWp"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="hHolmahl" Message-ID: <20250313155914.010145118@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881585; 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=waJW3YQ5oWNwI/K62CwSIbV5Ipj5dQb2DRtTEC5iKXQ=; b=2HqymcWpAVP30QeTxkq309VWpnQRwT1EZs/jYZuMKe34hSpQBxBh6GBuXNwkSKBb7vrEWv tevFf7ATtnQBTeQz2P1eNJgQ2Cs+Dc02MYGr7YREOPmnSkVa4LOz9H175YFmw7ygrIznyd 4Na+493RquM0+VDxht0LyJ8XCZO27pKt0zkpQjn17bQ7F83zOSSqKN3uoZ1AUwpBvLAEMi PSvGiZXQxNpqeUDrzmPuZGfrsiqmKVAWgpJbveJUJKq5Ra7dJhH3LWWfqzWZ8xMCFr9dRl tXmkFz4a0Sg6xNQhwWpvXFe3/ZEShkyjXOB/oazQJktbgQX66XA7XQVNaFFAWw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881585; 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=waJW3YQ5oWNwI/K62CwSIbV5Ipj5dQb2DRtTEC5iKXQ=; b=hHolmahlfg0z+gf36erbdveDBwhWLl4BwWoOAsmiG2dqn8CimNjClFhyMoQYord2zNrbi/ WCOBudo5kRVxQhAA== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 02/46] genirq/irqdesc: Switch to lock guards References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 16:59:44 +0100 (CET) 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 --- kernel/irq/irqdesc.c | 136 +++++++++++++++-------------------------------= ----- 1 file changed, 42 insertions(+), 94 deletions(-) --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -266,104 +266,68 @@ 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; - - raw_spin_lock_irq(&desc->lock); - if (desc->irq_data.chip && desc->irq_data.chip->name) { - ret =3D scnprintf(buf, PAGE_SIZE, "%s\n", - desc->irq_data.chip->name); - } - raw_spin_unlock_irq(&desc->lock); =20 - return ret; + guard(raw_spinlock_irq)(&desc->lock); + if (desc->irq_data.chip && desc->irq_data.chip->name) + return scnprintf(buf, PAGE_SIZE, "%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; - - raw_spin_lock_irq(&desc->lock); - if (desc->irq_data.domain) - ret =3D sprintf(buf, "%lu\n", desc->irq_data.hwirq); - raw_spin_unlock_irq(&desc->lock); =20 - return ret; + guard(raw_spinlock_irq)(&desc->lock); + return desc->irq_data.domain ? sprintf(buf, "%lu\n", desc->irq_data.hwirq= ) : 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 sprintf(buf, "%s\n", - irqd_is_level_type(&desc->irq_data) ? "level" : "edge"); - raw_spin_unlock_irq(&desc->lock); - - return ret; =20 + guard(raw_spinlock_irq)(&desc->lock); + return sprintf(buf, "%s\n", irqd_is_level_type(&desc->irq_data) ? "level"= : "edge"); } 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 sprintf(buf, "%s\n", str_enabled_disabled(irqd_is_wakeup_set(&des= c->irq_data))); - raw_spin_unlock_irq(&desc->lock); - - return ret; =20 + guard(raw_spinlock_irq)(&desc->lock); + return sprintf(buf, "%s\n", str_enabled_disabled(irqd_is_wakeup_set(&desc= ->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); - if (desc->name) - ret =3D scnprintf(buf, PAGE_SIZE, "%s\n", desc->name); - raw_spin_unlock_irq(&desc->lock); - - return ret; + guard(raw_spinlock_irq)(&desc->lock); + return desc->name ? scnprintf(buf, PAGE_SIZE, "%s\n", desc->name) : 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 scnprintf(buf + ret, PAGE_SIZE - ret, "%s%s", - p, action->name); - p =3D ","; + scoped_guard (raw_spinlock_irq, &desc->lock) { + for_each_action_of_desc(desc, action) { + ret +=3D scnprintf(buf + ret, PAGE_SIZE - ret, "%s%s", p, action->name); + p =3D ","; + } } - raw_spin_unlock_irq(&desc->lock); - - if (ret) - ret +=3D scnprintf(buf + ret, PAGE_SIZE - ret, "\n"); =20 - return ret; + return ret ? ret + scnprintf(buf + ret, PAGE_SIZE - ret, "\n") : 0; } IRQ_ATTR_RO(actions); =20 @@ -418,19 +382,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); @@ -573,12 +532,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) @@ -656,11 +615,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 @@ -681,14 +638,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 @@ -827,11 +783,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 @@ -848,11 +802,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; @@ -870,22 +823,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:30:09 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 8DB8926A0A7 for ; Thu, 13 Mar 2025 15:59: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=1741881590; cv=none; b=T7tQEeAiMxppSJD6/8PyhgvrLy3YKKIXoQJlciFq0LeNan5Nt1qedxyQnp0XfRbnFpN6oQrI/4ljS8QBTbiOfa707/T5w5aqRjZTc7mOe2+jnWM0n4kygdNg1/iT6bjRg+dM4n2QPJwNnHam5Qg/d59rxmtseo40FNW+BMfhxFE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881590; c=relaxed/simple; bh=bU3D3wueHKoa5YCZCU6TXnzyYTdb0pCfbkU5jkkZ3Ek=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Vrwpib7TflW891qN2PLzsEAskU2UBnzXtjbTxYrzCOvppZxmzxe7Lk9LxW3SgP2U+DuPBQD5mtLIYjx8TnfPQghhkiAQGTWKRtQGOP48MpjioI32OtsI3Nqcdtoku6KDHzGkCwOvSJZ2kc6sjU7YvYtSKgqvdA8dXk2lgRuXUEw= 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=sAsCqzrn; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=TIC+Ig0/; 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="sAsCqzrn"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="TIC+Ig0/" Message-ID: <20250313155914.075759643@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881586; 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=MzACv4gnMoRysCOuFSlNKThBLFwRas/s/LdFd8yEeYc=; b=sAsCqzrnY/JDCInUnIfuRZKlIApZ5BHXy0R3jfbN1I/CHJR1Arp6WQnGL8nqwDN3kfegCD RY2w4UrhU27ziNU0Fl3OpcHS5k6EyoeRqCO6w/XXxKpBouTf7jf4CX3k2MTHcRzqfabF/4 cpuoOoCp86guk9lY8/fanahKaz/y6tGe/2REmlJyizuDEnHi/s4wCAFVtG4vHHtw1LNx9M PizOLYUP4CFExWSHyT7X71QiwOF1YyIaiGDdxlv3THDn1dC0a7HSlNQe12c9A38kv+CpmQ ATDLQE3k3PKcR/Z6T9dwHXH3QB7Sopt5BLijbXL03CMjJEWV7ptOOfEssQivQQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881586; 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=MzACv4gnMoRysCOuFSlNKThBLFwRas/s/LdFd8yEeYc=; b=TIC+Ig0/YzlcNTZqDg8IsV83B5Ss/jI+Ys+wm9UC6+QSkLFI6P66NZDWK4SDsQ9zq95B8C Vozzs+pVA8zhfEBA== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 03/46] genirq/autoprobe: Switch to lock guards References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 16:59:46 +0100 (CET) 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 --- 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:30:09 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 D1C3F26A0C6 for ; Thu, 13 Mar 2025 15:59:50 +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=1741881592; cv=none; b=l+te+frWtpcrvuLh/sB4dE6EtcmmDUqsoJlflJBvrxlOY/U/ccb7SoYg4fLBSpDxzqzeQFJURprZlsK+HdfIrczYHIpubUln38KSd9U6FY5Ja+6LhQ42Y2Z1Re0m6VWx9stvtIO4cvGHOyMz4QkZ+vUITBBo1m8n8uTekuGwaFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881592; c=relaxed/simple; bh=ntM8kArfe0z/VjhhrlgBHB8lnNjQHLxcq2864LhbFUg=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=NoT/kn8CIWjqolYYRZHDaLT+0wxudYSd0TGU3uPQh8Y9rp6evoXuG8Bzro0fb2HkU8o9SVHUwDDAgJPLngjEaPkZOHADteRZqc7rsBzLuAznMpGXfkbzjqk6G+08WMaP9bP3U3fbVOygaCdXD/SibIbDOP+eyfk9h3W678DTBBg= 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=Yqz9oADB; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=YRJNLEm8; 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="Yqz9oADB"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="YRJNLEm8" Message-ID: <20250313155914.142099076@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881588; 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=zhvgbTp0hOygVEusPPs0+mNX6DOrLT/xrzx98rZIlSk=; b=Yqz9oADB1sWLue193XFQ4oIBUHmRTqGOUoQEnKN9XYAFrczT3X2Ga65xRqXVdnu6ZsdvoD hKtdrUMf/3uxO4f3bseXTof43XEQTw9aW7NC2zxqxEVGLY3oGyocFQfOh7e3ihQjaekEki RbtWefnfiYEynnA9A9uszFZ2NYP0alZag3/EllwR1dW1mrTxKkE8EllAO1vR0SI3tNSUN9 CpIsaouICz9mjvu0uXJfWR/C6mlDLnuhqB5mD1EIkI7YRumraB0CTHhbOf6cA9k7eZqHMb Y/5z/WthCX3zRYLi/BIGtUvwB/azNkAjeuljpzZzeoqNXHJrIxc4JYmNnVnfzg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881588; 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=zhvgbTp0hOygVEusPPs0+mNX6DOrLT/xrzx98rZIlSk=; b=YRJNLEm8V5yGk/YTfu47XHj4Kvbo2i9NYMiinRUrk7yPw2dqj2EwIZ1M/a0I/yyU/jZN9a sa1d68ehNVtmH4CQ== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 04/46] genirq/pm: Switch to lock guards References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 16:59:48 +0100 (CET) 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 --- 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:30:09 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 448E226A0E3 for ; Thu, 13 Mar 2025 15:59: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=1741881593; cv=none; b=YME/RK6M7aIwe6Nz/J8YNkL4e7Rw7iUoAQyGjIPUZdM1VhyMgRRouRKEwG6PdPYXqGQgx5mH1ptf07Ig+7LIlMwjzDFYMqRa4uGQL0GaO8nsEU/NMn38UEynqnPuIu6QMwj9Zf6So/EtsJKKSF301oPpYelSFrj39YWaeMadeog= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881593; c=relaxed/simple; bh=4P2AYZaXXdHY79QfXZ8TNnbeCKt3muYA/QNuktSJAdc=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=kzIifooESYXgLWF8pEgRnh0huipUQ9RbIEFs+RTBkORg+3nWHQzo/EUJg5Scx2GVoMN2+srXSS4PiuM3nMJDUkj/cnlooodcljZmdTYaGFSOlWsDZdfcPNYDijlLwEMEzGjzeDrdjQMmZRzHe9N4qtMakdftwzJxHN0m9siELzk= 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=Z6ei5Uwu; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=oVYS5euJ; 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="Z6ei5Uwu"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="oVYS5euJ" Message-ID: <20250313155914.210122456@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881590; 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=5LJQpMqIMYF5gjpITVf0v/W1X83bXVrvdfpXmhehpyk=; b=Z6ei5UwuxBHWaWp0mhNDq+1N3AOqAtKf1E7KRi5fakSV/z9NtCOuzGStiwFTtg0Vmrvw8E CvgWCeY+aUCnXbTrlUexjvx3OquXqc3Kwffj7/gJ65gBCCOicN/itTr4gTa9x5xCnhD6lL KxrNkybiL7TiATc0iC/lpqkFKrMemiLIgONXo8A7BPQ6YRCyjRtyb8H3E5Lgx3cNiot0c2 TNWwl4aBw1Cta8mg9B32Cl2ygJ2ZC7TQ+oMEtRbTECKWiBkuKxyTM+3Agm7yn+OOc7QsjC a9MEPNrBEVWPUZBHwxXtmH0suCGZ3+IVLv+C/f/FFDWTdSBT5ztr3brdoS97Jg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881590; 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=5LJQpMqIMYF5gjpITVf0v/W1X83bXVrvdfpXmhehpyk=; b=oVYS5euJfiY3zIHmtfz8GuICfzy1663pm/qP0jkskJc3ToUPZFL55opp6xXgb0cWtAg4io 00yi2XkCm9S/WsCg== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 05/46] genirq/resend: Switch to lock guards References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 16:59:49 +0100 (CET) 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 --- 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:30:09 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 B0145269D16 for ; Thu, 13 Mar 2025 15:59: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=1741881595; cv=none; b=HRLHpSN9CG3bNFa3sxzu4BbWobm3BX2ysezqj4LOsMouO2HrkK3cH3riAAnoszUjgUglehFPkaZ4CNKuDLCsQWqrdC6Sdr95hWa+prRfVVKPmy+CRJbNrEUB8/IpiRINXpDMTGSNQPURqFpQR11kfzIrcqvWM35/02TKEj3twOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881595; c=relaxed/simple; bh=BSeM3MygPsa2Ki+GyIgTvUBRixtUtAxOAhOHZhKHtT4=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=BzTnTYWt5nJFPqKa8YMPGFDcvOlsappY0zPiWJVhGK6VGD9qCuDD83+d8QhC82+WWvM26Oj4dFWjARgufEb5oahN5tN9UQmiBXaXxuWCdqUXuigv5BshIqE7K3flCWevJ9EyvtSlG8mQrmDbXNYuCaz2DvMsbXmicvzWL/drktI= 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=HEECuTeC; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Tqy9+HUd; 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="HEECuTeC"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Tqy9+HUd" Message-ID: <20250313155914.276685779@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881592; 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=pJ3c2uTRlpYbT0X+Ce70TgQESWwWd+/6IGj70OyJbAY=; b=HEECuTeCAMEgNVsMfcioaBmgcL71RjobCEqeYqRL9tEKubn9CneleMKoXfEejyPkVhay5u ctAVg2APF2RT0qE+vlj1+pqoXs2SWWicjUJk2Hi1LpRFpuYgSYLld2MAlRlZ2xH05ItnKM FEBgQsHFfgMGqUwijDMsaN6n3rSSN4M9eMRddu1LOxdRlTY09BrwL9qg61xY2x/k+nqOla 5hPjQvgTSEvRvIwJ2cGD6nUlnuW3WPv6iTznpUNUVoKAKgaNKcEE+ElggVBI02NQK0S2rR N6e4gC1tld5B0DmOPSnRhvXpJNysKmnNcrIo+wDaW9CM0Q2zpuz0yYAl9cUlqA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881592; 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=pJ3c2uTRlpYbT0X+Ce70TgQESWwWd+/6IGj70OyJbAY=; b=Tqy9+HUdO0v/fOr5sk0THam2tXUZ0VxswgOeJZPKnQvMjzF0eYVUyectzgpaU7OZOtJUp/ KI7hJD4wnjkzecBg== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 06/46] genirq/proc: Switch to lock guards References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 16:59:51 +0100 (CET) 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 --- 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:30:09 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 F30FB26A1D9 for ; Thu, 13 Mar 2025 15:59: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=1741881597; cv=none; b=VbwhO4/j8RfKb2+PekB7qogBK1O3Hix9jK+7TKjpOlk3yvLw3QzB0KADrnPTiYswitEZK6e9zNVXe4gM5GHrgd7d9fGdihWS5JNmIhrTDwbr8VpS09s3fbizRuBLS3MgpJkdOxi81PzCwyzvDn272qr0qjl82d0kiZUwcqt6yBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881597; c=relaxed/simple; bh=DqjGaG060lF4aE2timc47zvNhiw+mtiVztFT0F/eGLg=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Y5N2zNQP4KHt7T+t07+H3NVNcT9EFZWlvkqdCkQtvA+RCdAD0s9K4N5ASEmECS4hw3At9/Gdw5bwdecFbYof0MHWKtlj1yT1s2xFSpYutXmCjtMRts6tyYpxOolcvp5Az3cgUXtZOPTn0eW/55BkQjjOpn9frK4nxM/18nJdWTM= 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=aIkOL2hm; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=QN8w/sWM; 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="aIkOL2hm"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="QN8w/sWM" Message-ID: <20250313155914.342607279@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881594; 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=eulrkW/jQcxUqYO5aduwRSys83VZim01riXzxasZFKM=; b=aIkOL2hmvLadgFwu/m/H0lvxHDyXZLhPSU/+Cl7OePQgijFguatGm82yAUHV5vI1QVbGV9 uVSFEPnq1fzKuOXP9DuVEoJv539VxAF4Ju1EpeGMQvCRQ7kZfcQhEcKXaMVawRJtylnsCL uiD/rkrDjn9M9D8WUd8CBoq8KZaamdPP6KqptL497Z+tu28tw231JIYyrPj1lbbywrl93B k4Gt2VqDJdZjZQx3NFmZwAQuESXpQs/4xjYVK8PLaIvqXoUDwWBlRveAz1VQXnNgfyxAwr crEcX/yRnph+G9c3rkdLo88htOk3ZRvEwdkuxzHvRiY7GUt1yvDwyH5NWxuOgA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881594; 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=eulrkW/jQcxUqYO5aduwRSys83VZim01riXzxasZFKM=; b=QN8w/sWMR3AKYciupC4gtP2YzscR1AL87lp+RhO2XkG83iMW1toWTUwg/WK0YMpy3w7h7R 4jyVrStgnqvRK4Aw== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 07/46] genirq/spurious: Cleanup code References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 16:59:53 +0100 (CET) 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 --- 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:30:09 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 A28EE26982D for ; Thu, 13 Mar 2025 15:59: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=1741881600; cv=none; b=TuvSPZWMcAhGTXhB2MKtauYHLIQ8wD6HYggyGmqclNuFUTca2K/eZJEo7g6j15q+cWMd/bZSsidOq6r4M9jXKx+u55aoqnp/VFXdeu3SOWaekMJvneBW/1fmlC90PbV71xSVH5RX1b+WU5R5dM/ymTM8LIqUzlrTI4uTIXNxHEg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881600; c=relaxed/simple; bh=Nr8MDFSzC9BiU6791X4HYjhJnXQXWAAGArxTTP+vc0Y=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=i3x6K/80ezYqhI2PuOIBLdkfV0MMlLd6BnbvJvnqDAFGgQCZUs2bD5iObarrxfLvxaRVtX/eE7tpk/dTZU9SPC5UB7OSRuboU5xo8n/csjF06X+czJEiFVTbasa4d/ubOSaJlr8Byy9azF7m69IVBpCTNTp6PmQU39bcmVcM9Es= 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=uganGIAH; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=U0TZF+5P; 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="uganGIAH"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="U0TZF+5P" Message-ID: <20250313155914.408460923@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881595; 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=DU6XMVOUDxJPH8jcWvqONJ1ImJNmXAVWjdvJGxN/vho=; b=uganGIAH5do37fVQrvHA3jGKN2sT8AdpKaBBLNNgkMuW8M7Gp51asa0EQ4FT4EGs55JIJP ezGtXW0sVVTKoFkHKWjwrjxnf0RYXz6Qoowtppzcj5clu5NUF5oeSr+qQzWNkOBlPPuIui VYfbC9WWoRy2EPs9TKXxKpNTNnwbtFlA6emteQomwbQHEh7b8/q1XJOhaEoFI79OJbYZIL 5JhBz844s+q56d3+yxR2ozf8dWHqE8xMnngK10+QFGBeuQBW/Y1usPXeHVMO42F4wrlAZN fY2TurSeE1isJWtY29mq1COoh9k6332Zs2DZqERtnFaYpdmhDCphG/RQO/axRA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881595; 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=DU6XMVOUDxJPH8jcWvqONJ1ImJNmXAVWjdvJGxN/vho=; b=U0TZF+5PPkWENab+vZ/z9BUnOk2KxKgnHYI0bC5NpHgUzUt2BDyHcHpzY+yAQC4zDQ6d0d yOyNdX0ZcrkSHkBw== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 08/46] genirq/spurious: Switch to lock guards References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 16:59:55 +0100 (CET) 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 --- 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:30:09 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 C2B3226AAB5 for ; Thu, 13 Mar 2025 15:59:59 +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=1741881601; cv=none; b=CSQO58zzazP89K304vMoW5QbiO/ixgCftdXR9XgO2HA3RDZ4q/YqTGqaMiWfflZRQl9fW6BLyM5OHKFVOOYavUQAlg9GPStjJaeu4ybx3ZZlfko5FHK5rOVRoB9fayG1V1FzBLtTxPs5ceYyZPdmuIw57LdEDq6URAIBnTopaVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881601; c=relaxed/simple; bh=SXm/HPpRo9Hckn9uMEaCtJbqdUF8WWZ5y3ZzWz42Y+g=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Q9fBOMxCdyxCt7teSaShzgwJwczp9iQS6/okkADTdN+xX58NZEtCyoiFLZqFR8P61KEqNzvskoO5ukeNUkYEwkhTFU2ZXNFYhI3o1oK74obfoV4lOe0CBEdE94WrV9xQtdYR3VJFG1m/rRvGuvItvNrXruXdDyzbpYhxlqb3nS4= 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=pzCXlYly; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=pxmE3x4P; 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="pzCXlYly"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pxmE3x4P" Message-ID: <20250313155914.476509483@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881598; 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=RR9+I+Z137lD39z9Z00YQbOao2INFH7E7M22ZTqEg/k=; b=pzCXlYlyVioAOzvEAR+h7h7L0FbBPXNG1rc0aihp2bYLRFbHb15FXuT01Nu9uV22Af5XK6 DvH/oyGWFuuCilFe6RdEzo7567SRH/OHAROrMhStpeYO6f+/dNLNQzeaZBCwuhyWP4nurF HBB3ptP3F7+4/+rdjlITApzpNNdsjlRp7hgaSiDPfNDpOD2xYrkYE8qa5OW9xbWQUDpLao 7oOLYX1SowOCaBSXAdzlHDbm0goqbDp+Gqrw6KNfLO0ZeTaHdsQ+iKI12T//i903O/nR0S p2MT1yC4YLvNnqbsWFRfG6hnZJJN7rK53biw3/sWoTRw8eZkM00152RNN2Hp0Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881598; 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=RR9+I+Z137lD39z9Z00YQbOao2INFH7E7M22ZTqEg/k=; b=pxmE3x4P/bUtoWezCMkxIkhgO19obu9UKRPoS0t23v3+x7f1Dhx6ItBccI+5UJ7uY4OakH 9ZLhYGGZo9AdzjDQ== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 09/46] genirq/cpuhotplug: Convert to lock guards References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 16:59:57 +0100 (CET) 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 --- 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:30:09 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 0F62326B08D for ; Thu, 13 Mar 2025 16:00: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=1741881602; cv=none; b=S9RsJm38+FnRhCHS9/uUWmayfd9KNYtB0ZiUCe2MthtnaaUJJiuLB3PmSowZd9j1jwTITZ2BCFKQYYGFpEnZ+BoN+quduUpI8GGK+sinx0dWCW1Yroe6t7H1OgVXsRvAvbuYrOMCL0BZCyHLJw53Hd+gUbSMMo0tjczg55/IEQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881602; c=relaxed/simple; bh=8nc0Udtrh3p0WdZlunXEF/3qKBirL0LzIUuWvtLbWIk=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=mLunYX5t2z85C8dn7RonUKp/GlTyO7gAk7p7ax9e8Vqt4qXbaRGnxCeO4aVE2Nz+OQJQnDnSirN7ssZCsLDSAI2qPW4QNfDn1ratCUZMw23xJ+ZWLOQ+zYv867rCmKJpYNHrBjHUm2wN/XOkUHWQv7imBgFdKLxjTkw55N564jg= 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=GFGMK7ja; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=d6gwj5V4; 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="GFGMK7ja"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="d6gwj5V4" Message-ID: <20250313155914.542595506@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881599; 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=BaBDaqHlzc8qnLL0P0eR5zS1rCHI9lEMLIjAmMGd1QI=; b=GFGMK7jaA8oafcP5sXIcCJIU9eS9daOnQ3/971//I2wFek6GYly1lTSHEB3TrkhhOwfP6T nfOclbPCPlm1tMj1uzW4I3AVvrYVfhVwFIBDvR8bM7MmdkSW17Ll9fgsfZ6MaNLCzQcC+k UTZ/wUiRBa1TfW3JheGs36NbfolFmDEJXNoriMkFN7OBsr66jv8W0g44K4IkhoeKOpKmCl /U3UsrGqB3+QXjVToF538L8nBla66xKLtbHxKEsZmuKMvBIt9FanYQ3v8tBLluoV4gPbJC S4xgdR37ZFcFzYunuzM5DZx7urlWVqfnOWP+zm4YUR71ozx5G9FI2S/YAFe8zA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881599; 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=BaBDaqHlzc8qnLL0P0eR5zS1rCHI9lEMLIjAmMGd1QI=; b=d6gwj5V4lYz2PN5Mmj/DLx1yvbJ9+V2Z1W4LcOzQkgD50P/HkNupkxn0r3htxL+qMeK1ZP u4wWBGsOY/tWpVDw== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 10/46] genirq/debugfs: Convert to lock guards References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 16:59:59 +0100 (CET) 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 --- 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:30:09 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 15A1C13AA20 for ; Thu, 13 Mar 2025 16:00:02 +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=1741881604; cv=none; b=pCTh8RplJneWjCcbLNs+j5tKUGDcE/2p5jh5/9NIPyZo9+E+ybc1GR8zlaEnM/EVeJxavMMDWoHL/z1w9/lRTqj5r7Kolit8emq6YhPRAONmAnmUttorrCNFcaaBUJ1q/FMuJHyeCjCPC/tne66KlXkvvx91/+vE23ax8SGUejw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881604; c=relaxed/simple; bh=U6xnEiiLcxoUlj5oziXTzUPFCVFD860N0hio44XXlp0=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=rJV9PMklb6L+O08Su2gldI7uqyDkaDojTKlndJIEpMosaebpd0D/ypzErXvWdQXq8e5jG+HiaGuBa4M7F4oxU2NYbemw5TAft6F66s1rjNSiZlnQNKZpAFIa1VhGrv20d0mhd3tu3t9iSsFcLTiwhZ1hm5KOblvGBbj2efa/jxA= 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=FcDYFk7r; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=z7Ykj2n8; 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="FcDYFk7r"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="z7Ykj2n8" Message-ID: <20250313155914.608834932@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881601; 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=v9TPN0WGgiXJz+hAgbLeIiP+glBj25kHZkxUWZhnzK4=; b=FcDYFk7r4qpYrNzDyXzSok7grPr1HkMqpXfQBTX4RN19cdoDbLtG0Wn83nh88oPeDKff5X siZq1ktWbrwl6MSEaXBfIQNjl7sNbKCmDuy8JLt+OfwKXR2Etky5fWKf2VrAyeH6oNGBSz OoWZPYlHTUe2IQUeyM8JDCqZm/NNkDTUhXyYRIfALBqmbRGca3fcvS1vfCxO3j53vlcE8z qZJMM8WkTfrNHfyHE9M0ljwnVn9LnSRffvNeKraN81aPmJVwgmoO4ardwCTVVvz1EmnikP gfxaUDieU363C5FCBQhJP1lDxEMLBbv3/bQ9XRBYjNLGqgvxnCB3coxBJarSDA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881601; 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=v9TPN0WGgiXJz+hAgbLeIiP+glBj25kHZkxUWZhnzK4=; b=z7Ykj2n80telETYKwGRQYAK7Pe5c5Kg6kRsYZEj8ae1UxeLvfnAgoJDGkmjAtsSR0jPdFt jYGwMwNzuDFmKcDQ== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 11/46] genirq/chip: Prepare for code reduction References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:00 +0100 (CET) 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 --- kernel/irq/chip.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 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; @@ -854,7 +873,7 @@ void handle_edge_eoi_irq(struct irq_desc =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; goto out_eoi; } @@ -1213,7 +1232,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); @@ -1265,7 +1284,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:30:09 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 999F726B2CD for ; Thu, 13 Mar 2025 16:00: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=1741881606; cv=none; b=gxMGI01x6VigYaIjklc08s4inV0Dyhiy2h92tgenAYw8S3Lzfot+4lkJCxlzDGAEfsFLoCdxBI+pUtY3eT/Ze2r4AgP+VTZYoCZFiNDJexjcWwYn2EK4LCkAbuzWcorb3b7KLCivJ8M1autIa+AaoYIPWFTBaerOi+fOS69zAw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881606; c=relaxed/simple; bh=DeAIFcoJ+3BK85qfp+og+otEJSRQmyghxY1r0UFRW0Y=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=ishNV1TdD+lOmMWEIFn0jDgDzvpeMKReoe23QJzlqMIZm5v/+VecmLtDoDQDoke0kFCdBaZiN8o/aHHLmuM5kKlr6PJxwKLZWSrRuzYqHo8gmMqhoSY1DXAvB2bpuwg2Cu4bVkv+DOE54EXmttCsv28Ei5tCOlJJRnn3OiaNMV0= 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=aK0DSb2O; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=LIupAmLb; 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="aK0DSb2O"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="LIupAmLb" Message-ID: <20250313155914.675005577@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881603; 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=0QyH5gseyEzpnbzDVArTJJZpJ/ETcuGqcMoalcKD/+g=; b=aK0DSb2OIlGxkoGcKiQYvhZ9hITO/avRcxipr/AKbPguZR1g8aEz/7ogcBndtCC+NaGrbS l8xHSwQwoC2jcdkN5q++JXm/scBEcdmLr+vJwnsruVV2EHjKxj1WoNz3u9lUKO4mGYia9t MOod/W5Txew9TR/0oew7E2+kdCgrPIVtTBnLmagV7Terjimyu9YMfEiw4rhJf8RbPuDv27 QfNczuea1PC687X1sPS2nVgpj2yJQ9uXR7iFDn3lcIRtyCK1B3yDXfXxRXSD6pME/VLeYD 6s3t7hWiPAsdDGNlTJbj0UC46Dy3W08Lc19LF2Wb1/qW1HFr22CxfyHbpe7IKA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881603; 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=0QyH5gseyEzpnbzDVArTJJZpJ/ETcuGqcMoalcKD/+g=; b=LIupAmLbORKjFHjA1VyGXPXm0MWTKnCdQCel/gTQddpdvjaBcK14fW5od5kW0gd2gMptlA AvHB8sDv2SAoWqDw== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 12/46] genirq/chip: Rework handle_nested_irq() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:02 +0100 (CET) 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 --- 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:30:09 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 8D43C26B945 for ; Thu, 13 Mar 2025 16:00: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=1741881608; cv=none; b=N1DQSLa6tuBfOUz+v11fGBJM3xNij4nhcZBU19A2osJ7dskZICi1doMhnL5xU4USOyKEVlFayH0VoRvPgU1nY2UwyXvIkBJzrreJ/Y3MMODWEaGKnVsFQxzpqIRqV9XFkyZAdkjna7KsHe14aRcEiVX8q3fzazvl1BVw/vGt4b4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881608; c=relaxed/simple; bh=3j1UdluVBUaeENfQD/hEHlLRA6hs7QQlt4dExfD1TsA=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Rug9g9fk7z7UaUJFXQZz39cRnpgv2mNR/cGSfT930eLwwwkz5PGVOQd2n1Z7GJdhYiQJBp7EjLwc3PuxZcvn6zvgpAGVvlZ9ltFuHXq74y/Z0qYS4Th7cm1bqYd6niIQwzO9l9JPJcF3Sth3GJNCm4HINsTntmNYZu6xKqjdbZc= 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=lQDCu2J0; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=D4uDVth+; 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="lQDCu2J0"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="D4uDVth+" Message-ID: <20250313155914.743439508@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881604; 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=sICWpqh1x/oGKWN5RIIzAEe0Urq6dmsBpoEtBZUP36g=; b=lQDCu2J0seZ1qw1ztaeeGl1YPiWrmdMQU3ewCveDsxTb1+LHfSiev4csRAYkqUs9Vve2BJ 5thoy/ZgzFam9P+o6EirndAqfljX5avsM10QPvVRFQuWzTXSImXRnFgmRx04jGSfulwBw0 9OPAUH1U//jTflQ4z8GSI1x5FMODqgQqtLxHCd+clpjlCNAC+Ip6At9OB8Q5UULQ4Ph73t oQOKYE6s0GYNLDM/p/DsEc3TJNqCiMLIrbiHIJRyu8rhIiaEF44kfYCg0uL0x1eggwDQ9r tX69vtnzlvkY3WxFypnhnuRqqBmdTOFhLbVv7/8FMRkz5vKOS/xJtupgf3xV4Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881604; 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=sICWpqh1x/oGKWN5RIIzAEe0Urq6dmsBpoEtBZUP36g=; b=D4uDVth+tc5n2c9aOhI+FL6Ltfch+vt+fNtmX94wBLB0CJV1kbZPbCsvjNIOLX06K+JP9R A8TwxxyC/bxXO+Bw== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 13/46] genirq/chip: Rework handle_simple_irq() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:04 +0100 (CET) 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 --- 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:30:09 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 0998A26B2A9 for ; Thu, 13 Mar 2025 16:00: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=1741881609; cv=none; b=RzARCzeVnMDIo9AdsrwejSNKQJmuMvc/IKGlUaASd0HJziezSvoyIPRyOEh5F6tuNJxjqb/0v7sd6WiRT4c6LOQoNvlukAU0Hfmb3wW0ka7XD0j6VbeIGdEQ8J8fkjLdUeXP78My3uHUYwfQeIpNoZz4efSP9Q/9T3sO034ccSs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881609; c=relaxed/simple; bh=5ck3CiLrFDp8Ga3ABgCm8jslT3D/G6CsWLORrMGaGOs=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=PQL8VrbRhcbF/BuKysDypyZ8Wqv+w418jmJ3UJ+9QRewHgtE5YbaCzEVvoDieAds9860AtdjC8/AozwS+9OfCHhJEjieylPKRtbNiwgrEt8RKD/u6YREwOrZK7TZyRKlADzh3uinEKLK96S1NgT8PWcTt6nYlgyFryRS7OXMRJ8= 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=2jBFcl8i; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Yx+2Usc2; 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="2jBFcl8i"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Yx+2Usc2" Message-ID: <20250313155914.809874100@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881606; 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=6cbl1KwfK64weuhvN54DXi2/npqBXHAy3T7/1BalF2U=; b=2jBFcl8iS8YmKtgwoATrauJsa5d+Xm4EXfEYDrImh0bwUW/GTaHrgtKOVrPQSb3dpN1NLf dSh/95HVp/j9YJDS5CG45Miejixy9HSxVsJ+gnRbvCPUBz1E5pHMLsrD0p9kBCgJK1vIIY pgYoz4/+iZR9pQOyHyq0nOMzEfWfWz8BpiAFNo4DG/0PICW76l5+D6qFaKqx0UkIZfH1c3 mIVg0UCfDKaLNnyh34tPc/ha2+9tN1H/gVLzJif0i9X8gSEMmyk36I6mivyknZYRVolL7d kUHzkLdi933afgCNfgE0eIGkKXbhVtzN6HDD8aaqofOjPL+0Ts+ywnAmLrVFbA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881606; 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=6cbl1KwfK64weuhvN54DXi2/npqBXHAy3T7/1BalF2U=; b=Yx+2Usc2Oo/YnkyhWacc8v2tSB4N5JEbViR4GSS++0HgZfjF1Z3d7XWrpV1Y/ZuzHOBYon U6Mw0ro9WK0+npAA== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 14/46] genirq/chip: Rework handle_untracked_irq() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:06 +0100 (CET) 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 --- 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:30:09 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 B955626BDA3 for ; Thu, 13 Mar 2025 16:00: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=1741881611; cv=none; b=avGHwJMGCTUjqyQ83oB58XkDAjtRCXofcoyPLPt9JDlEbUAKfYy+vyztT2VFjTig0iSV/aIMVySxTC9DteVNimZMbQoBBa1hoPDbP5p3Fz44CS6xTDyP/7s5H5b/oYe6Ji/OnE5FRrVTXJNV5jO/ojnv61wMqgHb0JJdzGxRqIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881611; c=relaxed/simple; bh=4mnaCxGgovjXolEdUuFx8EH//EbtYUMPBXLgkYv5aFo=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=UVgu9ujwZmnZSPhuCaM+OCM18riNu/rQLu5fphjqF839bu8Ly7v4XzQOmi0n7mm4OXijPlYjdpS1PI4JYfhX07nVZcfRwgk5VgnQ388FLaeNVoxM4kxQ6SSO8KEwdpIFaZy1K85DO8F5demGnHwUIXHY25+/9gfewQyb5qbmhnU= 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=k/jbdwni; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=4hklptHE; 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="k/jbdwni"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="4hklptHE" Message-ID: <20250313155914.876406863@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881608; 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=ZyvCyewrVvXAU/CZ99lPev68Sm1EYZjAV8kymcxiFF0=; b=k/jbdwnit2maZYwCqPhMCGw3J7WlF/yYZRCdztZDHI8QmlqWxusgwtPC6n8Wbo8Ooa3ANv F3N6cAHlofpgf59VsmIXN9Hmfk/K/n6NrbKzJPPe83xHPaV81yKwL6WY8ShjqeVbGlnhTL dIWb9VQt/sQKAYPtEvKws3bbNZpugNTGym6D1r0OL35Qto6GttUQZPG+WvRqswwZUROMnP F7TeSNO6a9xPq6QsjWI8lHJCZkoIxMfr4pHPJMIqrvgbwhLAnH1zBE31UmlFvUM9p/UiiW 4gYIq5uUYOHzhZ4mraucbc+ewWSFXSFsZgeTDHaGQcJn1QB68amguBksMQB2JA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881608; 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=ZyvCyewrVvXAU/CZ99lPev68Sm1EYZjAV8kymcxiFF0=; b=4hklptHEIPwqk4eZ2xb6tCuhtr0pnaXlEBwFpPBRqP6PDmylZIbVxMkxUUvrqVbrM9yKV+ xLSWDwgGuOxL/gCg== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 15/46] genirq/chip: Rework handle_level_irq() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:07 +0100 (CET) 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 --- 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:30:09 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 C5B5E26D5A4 for ; Thu, 13 Mar 2025 16:00: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=1741881614; cv=none; b=GPo5LJNSHGElozGMF2+VNpgS9/4zRXOLOjbqshH64yOgTLN4vewbNtyjL3F+fEUSklzZWs9Ph1YAXr1rV6LpgqM6h81G7x7tx+4Zh0YEV79mXT/ZeF6kZbxUlt4GNNaNrWtKLo29Xd9LpCJO86AE6NTiOYWLmLTN5sn07dwPTUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881614; c=relaxed/simple; bh=vSuEFkUiIwR2lWjUNEItYlzLFkTCgRS7eBEJTslAWXc=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Vre+G7TemaZGuCmUML/hc5V36DQInFu3X9P+p5fnFzDD0BpPoOL29bKqf7voVaffS9uAJTV43N0j4wBcblAMe3eWS7udBTCTF9/3iTljYM5vJ7FNCu0rnSRwGNMsT0+vkb9F/jXl8HjQ7f40pnqsIvL23YrcSPgAORBkLbRdhDU= 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=WRzI6LOE; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=E7X0/U5P; 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="WRzI6LOE"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="E7X0/U5P" Message-ID: <20250313155914.943799712@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881610; 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=S/PCa3dU5Q78O6c+ooh++IFo/+FxyxivVyDPyxSN9/c=; b=WRzI6LOEmH8ZdqpT1CgSWDn8/8vi7TZuMhSgJBUz2IJp0V66S8NHxfRugxHYNRnW9odlyf KJjcgmkD6D6mwjMsDe7EvEDln0l9mxYdCOD8A0EYDnVrlWLyUEdUM4jkhB9XneNze8UagL +ZB/pDWDz/1fyu+NsKW7PqrmnlLj8tYzfAmbsxduMGjWBHT016djn+QUIiFR1WCl+D15JR nGD1cXKPZrNK574IKhdYh/B+XedYM9lewH5NC6MILcS+FNabGDPen4l1i+RImk4cRsaCml 9s8EAqvKIk6tiHEMM5m++wgma5Fuyl4lwwFl8DggNPI+SGWppkUFqfdnoJbpNQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881610; 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=S/PCa3dU5Q78O6c+ooh++IFo/+FxyxivVyDPyxSN9/c=; b=E7X0/U5PuTRqnugi+3P8OZHRIWwo2iO/GRlpBBXJ5Fa442OKgIzO38avKCakeOqaWmjglx YD2sNFpkFe226BAg== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 16/46] genirq/chip: Rework handle_eoi_irq() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:09 +0100 (CET) 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 --- 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:30:09 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 8E02726D5D9 for ; Thu, 13 Mar 2025 16:00: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=1741881615; cv=none; b=tYGjataAGrq2pqI74DBuswkZQtt2IVLTQ1BSuzgOgRJu3/lPLCkuTedptPnZacikHCSzFxjzFZFZbp7sNWPUzORaBRDJIobL2+aTc61z1+R+FzBFdEIAupM/MJEM4VUJDQg2WN9/MN6B2fg0vJ8AFI10gTxUnBnaTHq3OhgLOf8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881615; c=relaxed/simple; bh=0eKkvuqFSp6vxp+jRrwS/VA28lWYTAA5kR/e4n8yz2w=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=lpCZoQXX/URJXnsoC42OvClPNe4XyZOBi7zV2TkJIK0qGdSFf9RlOfADgM8MYCn1EwfMDAeC+jZhAKq6P0bVB/LhVTFgdJcz3tvj5R1GHUvQQizpNwMoNJhOqo9XhlKuUYuEcVOqwB40uo949O2GR7fGyWsDPC8mpjsNXS3c5fc= 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=CDenwpdK; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=s81nQXk8; 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="CDenwpdK"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="s81nQXk8" Message-ID: <20250313155915.025486178@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881611; 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=Ft+O9QRslr5GYC25zM4McalUWCmc7dV25og/dDV+Foo=; b=CDenwpdKMBvC/sMDiTRC/EUSS62yCuYVZiMRBEjrVN3TwhW5zJ38xDZYvKgSYIYWd76uNs 5QCMf2Q1XA+awrOWfw42NAfqITCmQzNaOkzDxY2PKnR5d3yIHkPkgjyk9ukkFkvwCw7sVM GuKHX2rjtEatgSWqbm5MYe+v7x1n5CTVxuwyQ7g0MAL5tLaeuCbgdVJvcuEy/ftUgy6BFw wViszPaA89AA9rwFNxYvZAk/JpoiG+oWPd79qa/+FZbrYKj3LioQFUTgXCeQo/cXWbqCC2 NEM+vI4NKRptYQWRp/IqqeShBiUhIotlusiweHU9gqTdoATWm10BmAZvItG+RQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881611; 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=Ft+O9QRslr5GYC25zM4McalUWCmc7dV25og/dDV+Foo=; b=s81nQXk8sPxBv7fu2MeVgZrEasPpnvrnfSsKB7RSEWE334+5a8BtKNM7rV6QVIO+mJFXla 83YfgC4J/4WDJVCA== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 17/46] genirq/chip: Rework handle_edge_irq() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:11 +0100 (CET) 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 --- 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:30:09 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 E1D8326E14D for ; Thu, 13 Mar 2025 16:00:14 +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=1741881616; cv=none; b=gUBq3u0CnKf+LqgHt77UyUZDX90642rXw/IdehtctfTWW6d9EH0NbNtAkrdpW20CmylCk/TN2El8xwihnj5RUdh89ylIgIoTGpI3nkZMCkDZHFZP4x/yfj1IM6lE1gO8h/1U8PU4L08EvpFKdaKaUr7VBcROw0oedsq14YeW0uU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881616; c=relaxed/simple; bh=WWq3KUG5f/nCLj5Qcgqq4kUJ18GwI47BH3UZ0s+Of50=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=kmwA073KAHUlXyULHQPlwvquZzjxTvWruICaeMdbQsKIqVWmgkcKHFqT3I830R41ZPkMAvLr4Oq8/QlYzVdB5JfYa7TccWsGr99UlKRwGXF+yud/bigpxe/Lk1s3GfJY9+MLYKcox///Nj45f6bF7ywvLhVbndwBC0UoZ58JrGQ= 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=W3xUzLF0; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=n1C322h7; 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="W3xUzLF0"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="n1C322h7" Message-ID: <20250313155915.094037144@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881613; 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=Jcmv7B5DflHiH05XE6cttIs2h3vY47Eqkh2aShVo4cE=; b=W3xUzLF0jYuNIaDIzqI34LjdmIWYtyUjJmtHUH3V1EHCRm/7nnl3fsIrEHukmDc+apdPx5 5Hz/6WJr9AcB4R71gCEPacGnKGTSF4oCGeugJONZH5VzMKsqZsp0G7im+eLqrulRd3E1j8 ru8XWc0CY46VV2TFwliZYX9VRcK2LYh0JeQgS5d3hCp00eVLnvSSX6+mpBGNrM9HK+GNOV u5uzeVaqeiZKCBlYz2AekFWIUwxJplUULTCkmw298qa9JJ4oo5rw3/bIma6lrFxzNIyOuD j56HchcR5YyZn02aGvMhE/IL2Svd5WLcOcHRWJonnSvsf2O86DrOBGNe7gY45Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881613; 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=Jcmv7B5DflHiH05XE6cttIs2h3vY47Eqkh2aShVo4cE=; b=n1C322h7601CtFReeflJByBVaT8i/xYP7kBBI/+EC+DmxDYg4hk4fnDpLt5EFvEu8XW165 F1Nxsn/+59U/hAAg== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 18/46] genirq/chip: Rework handle_edge_eoi_irq() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:13 +0100 (CET) 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 --- kernel/irq/chip.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -795,8 +795,8 @@ EXPORT_SYMBOL(handle_edge_irq); =20 #ifdef CONFIG_IRQ_EDGE_EOI_HANDLER /** - * handle_edge_eoi_irq - edge eoi type IRQ handler - * @desc: the interrupt description structure for this irq + * handle_edge_eoi_irq - edge eoi type IRQ handler + * @desc: the interrupt description structure for this irq * * Similar as the above handle_edge_irq, but using eoi and w/o the * mask/unmask logic. @@ -805,38 +805,23 @@ void handle_edge_eoi_irq(struct irq_desc { struct irq_chip *chip =3D irq_desc_get_chip(desc); =20 - 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; - goto out_eoi; - } - - /* - * 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; - goto out_eoi; + chip->irq_eoi(&desc->irq_data); + return; } =20 kstat_incr_irqs_this_cpu(desc); =20 do { if (unlikely(!desc->action)) - goto out_eoi; - + break; handle_irq_event(desc); + } while ((desc->istate & IRQS_PENDING) && !irqd_irq_disabled(&desc->irq_d= ata)); =20 - } while ((desc->istate & IRQS_PENDING) && - !irqd_irq_disabled(&desc->irq_data)); - -out_eoi: chip->irq_eoi(&desc->irq_data); - raw_spin_unlock(&desc->lock); } #endif From nobody Thu Dec 18 07:30:09 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 82F5226E16E for ; Thu, 13 Mar 2025 16:00: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=1741881618; cv=none; b=CIIsRS5hhjJori7BPvo4vhIXD2LOsJ0nww06ftrEo7SNY3SbAOkiKavvyeYrxejGQpC/OuLcmtpJyQkEACn6tyJz/IrGNB/dgE92jI0ogfa09uMxQI2Ni3Gzh9ZJJ3gnxDo0OJRQ5k0nFIrlAfOY3O2MibxkjdLdicSFSqaCAZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881618; c=relaxed/simple; bh=Q3LUk1H85yAzbN+t7w+kRu37buqF/Wl7SkFxbxxeCBM=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=fbSgSqgIhw49SDo+AaGHhb3Vv5TWQLAybbEVFccL7R6NrP1wE0TWo/0cH9UoYqp0IBZ46lIEorqKmxo8fGnIYZ3cvO1D/96UwwRlgViym+4BPyrDve7P+3oSnYP96Y5lmUkvs7Nh16cWFZAAe3zLAYPmJwz7WIRnrsP0wZoE+Wg= 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=DHNIrRNM; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=dAKYmhQ8; 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="DHNIrRNM"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dAKYmhQ8" Message-ID: <20250313155915.160710373@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881615; 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=Etegges49MUlZBBJQ6BosTJUnMsDSkEARClmQPZjN6s=; b=DHNIrRNMBxri68Pm5VzxX54ty6kXMPahQ5viLCFKKIX6gUZBd2D6luwaiPd9kVab9KDuxM oLeurF3EEIC8hwVdNXI6JxRO3s0QVk3Gfr+OJeB/N9neESK3sY5ikNOgRtstp0zVr4lJ8p duznFfAyGqwrGQxNoH8EtYSHi6E3S2+3aggiC6V2SI+ksWNp4KqgPNACH1opa3vcSIsXs1 CJKqsYFe5x5MTowUcOMdHlza5997yNI4ncfAan+gnOMIKmqSZ+z8SOasqY9C+3BVTJ6hP2 u6y2rNrjRdg3zKyxndmnvtMkDZujCTTxmmddTRHQvqEDcBTdD01ucUqjNZnGWg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881615; 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=Etegges49MUlZBBJQ6BosTJUnMsDSkEARClmQPZjN6s=; b=dAKYmhQ8+nc0DY2QUZVgXJ/myi+ZBLrr3DhE0ngDGDpww1nxkEUBaB2EfoAqI4yhVdPWe+ W9fv7tMEFTJSgQAA== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 19/46] genirq/chip: Rework handle_fasteoi_ack_irq() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:14 +0100 (CET) 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 --- 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:30:09 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 0280426E179 for ; Thu, 13 Mar 2025 16:00: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=1741881621; cv=none; b=WOXOb3oNpLbjdZwWyaBphsNwNC7MPIbFrmJFB+D9q37B3Q3D7ABSBBYgwKEK3wN7Yn6rDfxz0wz8xwSXRyPKIQ75nsbrIzgwipC9fXwGIVv4luWaU4QLR5/Wvoz93rpUYhzBEhqhv9N3JjpdxWPoA8dBQgGtDvtqvMEgpXKCga8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881621; c=relaxed/simple; bh=+jb2cVMFrK3JLI4YXqGnO7W/g2skxpSgj42RVfVe45U=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=iYD/bQ/odSoVQ8uxqUJqFFmJER54JgY2kt0FcYs2fXBgxmGIsSaDxdTOj5gRodMEbeT2ppZ2kYQwYKoyk/eC0C2NxiFN0EZtO9ymJcuSvqzZ3zpPKlX/QBoXBAyEc2qHUN4XE+qm6UOEMeJYsi6JA69QQL50rb5M4/mkY6x5wyE= 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=L5OWeVDX; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=gf0BIsoH; 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="L5OWeVDX"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="gf0BIsoH" Message-ID: <20250313155915.232665756@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881617; 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=SWG0FodRQ91tGX7TEvKXx2mG4eaRCsEYB9dnpaH3VVM=; b=L5OWeVDXAbplbGD6nk/6onDcT/rtjipgFjrfndQ5vmmgmjBlgeB/9w/JEJGEbgiM24tm8c ggPZr01pLyoHF72oyKWeR/bejDu3c04WXJKzAVypob22EohMujLmpG1FiYhFRyHfgNAKWx jiDXsFIELYBuEybubNjZX86MdoJ/enX4e0bfq1l2E7LYgTNYa+AnRaKPXMWnNQ2YfFXjvY sjBqoDnJFdBAPNKATTW08G4BA4vavjP23q9ZKRbeCabUMKxmXkODrZNAY/C5zWxQseWcUi XRUmKrPNefUVGn6dvaD8wwyaaxz+wux4Cz/hIt/su1+0VrrTcn+eKZwFLw1cZg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881617; 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=SWG0FodRQ91tGX7TEvKXx2mG4eaRCsEYB9dnpaH3VVM=; b=gf0BIsoHny5Ga9jsO14JKjVPi1He/XT39dARgs4gwYFeJ/9p1d/v2HRYf7B/6P4srGAF8g 2i8zUcxHI0/sfsCQ== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 20/46] genirq/chip: Rework handle_fasteoi_mask_irq() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:16 +0100 (CET) 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 --- 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:30:09 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 4A72426E16A for ; Thu, 13 Mar 2025 16:00:20 +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=1741881621; cv=none; b=KP4hh+45IKDdtYP+EznMDEHf/bAy+ET/yikVkaRGX2y71OgyiAVyRE/7QADwmviiRDOYW5I6BeE1zti/9sDGsikB8WCszJp1KHmvgPYIfok77d7kC+uvmRTJAg3FPOH38CfRI/ZTAFX1qiO66eM7RBdOxbF+GBl8iRNv52keYnI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881621; c=relaxed/simple; bh=b0JZPSifyH4V9k3xP9rALjjJADVVPT8f22DBM2AIRkc=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=uTTX54+lp4L8dsiwneEP9LlHDF5obaydCCpdUnMsugaXGVkIBKlH4kq7zcALGpUK9bmblv0tbOptEbj7StJbY8AOSHQLP0QC/tnT7vMOCW72F42zrw8+fNVuvX8KbA2UIHPcML5qJhMqPrTdZCyiqTP3I/hiPsWdGSz+4k0nFSs= 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=VBAno23t; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=HvWRmyrp; 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="VBAno23t"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="HvWRmyrp" Message-ID: <20250313155915.301000372@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881619; 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=21qxaZJUMfrnR91zfcgARK5+Av80xk5Antj7rW6iFIo=; b=VBAno23tKtjY32EkCAgiq+CghvliLpwm+CDVhBiaHiihyYKK5GFJ23z2kMf72KJ52FTJH8 KYWxD8ki3tETm5HBWsOei0FqJgtF0JH+6TgVddbWaGHm12j8Xt0nIqTukvZrna3y/lJiyY SmyraxOe6J3E6uXzwIidIdzOCRolRAoboJMMRsan7PZeW+L61jIpVz28LcmCYjWxosGhiq a/4cVBbSkpISmpmH6E5xvIOAZiCEry7yo/54f64mL1ev353vD4VO/bT39i+v/ATtGtHhkK qQfyrMxWJPz1dcdVU/d1r3vOpVJGseBcqQJ/llHxGexJCLcA2muS9Vv/dq+/EQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881619; 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=21qxaZJUMfrnR91zfcgARK5+Av80xk5Antj7rW6iFIo=; b=HvWRmyrp7szvuEs2oMyKIEiHzpUlvYNq9wctIieR+zts1esJZVAGVc6GqCVYj9q+BkZGpv 8pb2zV5LqqeuqWBg== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 21/46] genirq/chip: Use lock guards where applicable References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:18 +0100 (CET) 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 --- 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:30:09 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 C5FFF26E94E for ; Thu, 13 Mar 2025 16:00:22 +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=1741881625; cv=none; b=aXgSJCoKv1ukdqEN5Cs4foxiUcL+A+zINlDr9RAYW37Oz2xSDYELvY5cJ+bEoi/upZlfUq2Fe+eL1r2CC6AyiOL48UUcLYu/+lia8BV+eeTcEwhpwJ2J0Pjn04ODKoSItlyqDIRV19Oc+Mb5/CiVolFYPB6sIIlLzky5H0xrcLs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881625; c=relaxed/simple; bh=2oy4+AYag3wkv7a0aA2l4lnImRNYpzll8+i8lyaU+AI=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=pUytxp0i60dHoX7wWQC/N/g8IeomoW6HsW7A4bdJB30OU17itJHtfJls6x9ziCBXrb0GN/QsjNbbMCY7y3PWlJt4twWA9OFvrojPx6pF/E6e9j4g6iXVXOyGYA55Oh+atc61ndiA8CB3wY4BEWGOo4m5OpBaUG16IHyJapLs2i8= 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=VJSz1BDa; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=LOZJlPKr; 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="VJSz1BDa"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="LOZJlPKr" Message-ID: <20250313155915.368650725@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881621; 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=oqaWp4gFAuFMj1xMvqqWiSZD5kZ9/WoSzBbN7KUn7ec=; b=VJSz1BDa5dhf5b2R1y/wok9109SvSKdY24e9spGr80nLHMebTyAopxk2VBYND6Lohl0Eey qM3tpz2Xms24ONucWTqr5Njoxox6YepcZ22YWlLzoGQJ7nNrd/s7xltV1JPbGqzt3/39Y0 NUsxNb9s5P/Hd1esUxV54cgHI+pyjwHs066Ne8Q6ACCYZzBMSVWZyxTKd70qs7ZnnAqQH0 6GGg6ti/Fl5L2Bqm8XIFZ9cJLSBuq49xBRBCiMBgbAto9kmSKdPMi8GU7JdHnzVk7Z+WEn VQqONyqQrlua9LWXpFymnsQVgd/WO7++SyAVWfIqxTupCTycLW2IW+TCMYMeEg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881621; 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=oqaWp4gFAuFMj1xMvqqWiSZD5kZ9/WoSzBbN7KUn7ec=; b=LOZJlPKrza1g0WqcNdM5PXQ1UyjeA+uukXZSjd84sMDyletmD2Zt5+3NlEUsjK3AYVex91 E55mmBZDDK6SCQBw== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 22/46] genirq/chip: Rework irq_set_chip() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:20 +0100 (CET) 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 --- 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:30:09 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 2135826E952 for ; Thu, 13 Mar 2025 16:00: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=1741881626; cv=none; b=mbD+dnpJtBO1H+R3JgbNvgAXZxchjtIEwY7yXLgEwwvga8FEabJO7GYCz1Cf4LtgqfLFFc6uNhdy5nhAL0KJ+/yUTiwcudQ4yxPnTMaBzBsdGFpgXUwh3UxR50angRrHtpXffiopnMzC2sCkZ/eBxbTQE2wT314VPbsWYVtlnBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881626; c=relaxed/simple; bh=+eDcQW+ASiWa2cpmvtO1ybtAseF1B2h6ZHQFOMfdYnE=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Kp9Hr1ehWWhQ24ZalIpej+mTm6y9r0sGLE61whKOtlS33MU8qsEdTCneic1RD9W1ec1gB1B85oGH5SaaOppIky2Ds5qrqwXDcwEAoh7KjNobWSXTdyzj8Co1/HSL+QNwimrS8SP3gsYuPy0XgsM0dfwSTm3D0h6r+6LWgNmn33I= 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=hYhEvVEI; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=rhYsbRHr; 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="hYhEvVEI"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="rhYsbRHr" Message-ID: <20250313155915.453571016@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881622; 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=dp4NgCiDPp80fCiL6rbNPSkeQUAa0mSCzeJaGL1/OSE=; b=hYhEvVEIxTLhxiClp+wJFAcEdGsF4mcaOHZMgDeJSIQnkTG/fDkITG7cfpAZQ+IDxiqMm+ B+WyVFZFXRqhC8KXn8AfygywzXO7xniHyyO7zYHq5zOcqgj+8JrI4/uPJ41Th3KheXUatl LN3bHBXG4usOxN7fq5zzPbRpA0SwPpowuxVvR0cJlCfAalzQUu99in+w99GLu/G8G/5HY3 Qq67R0NVL2v0oiqfvky/G8N3DwWFMpSLUS9+wDrb7Y5Lv9Tgi5b0ostRuIl+cxCZQ+hFsk mgSA1z/dzLrECLrC0D0JRTCaSbd9tQgdMQNSOypU3PiUf7PRe7KzdAoDHqWgrw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881622; 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=dp4NgCiDPp80fCiL6rbNPSkeQUAa0mSCzeJaGL1/OSE=; b=rhYsbRHr1ZMWNz7GWt7gTDLCKxms8IttDRU2DxtX7cQVQGiO3ibBcGqRGMnLxcxdeckT8X +P5dIGv5zLWFF9Cg== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 23/46] genirq/chip: Rework irq_set_irq_type() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:22 +0100 (CET) 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 --- 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:30:09 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 12A8526E649 for ; Thu, 13 Mar 2025 16:00: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=1741881627; cv=none; b=KFbRRrbN6FV6qEcoY1jlpbzRFXV8yAwo6ZU5atzJF+Uuwsbc6XT+9LdJi3CM1hQF6SzWAZ7YoEnTkyv+SZ/aDkdY0gCvHb6Xwpzhf/hKY1aiAXIOvl014N+NxDppALJxNkXBH9hSiHCl4pSo258CjfUDgwnkDwT8u070Q2xedGI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881627; c=relaxed/simple; bh=4XMSv95UnRHRfs9Dp9DKs5bSM7EeJBEDLVlMfMExvKQ=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=lZ94cF2HCysZAOFNyYCRgX6q3BEoIASi/0KtpUjMMzQN/AF5JnDb2pXXT/OoTWyD2TI+2ju1szK7HMc+87530oG1i+niDYGa7mlYHrskhTZizlD5xmQfBqBumsJyHdjLd0sP6UtZHF01quIfbNCXzGuNhvJ+gCU53tIIHb/0G54= 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=muXYGaZM; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=bVLQNSY/; 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="muXYGaZM"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="bVLQNSY/" Message-ID: <20250313155915.521160607@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881624; 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=SZppYYpyTvmjB7MNa4nQjpEdTsOCMp/CZ0uXUVBIajU=; b=muXYGaZMKdhZ/ADsYGtBVTuHRDNvzGjti+ggh1jrloi1jJkG4dTbfuVRkecu1o9QvfLPZ6 PTQ20W0TSfPhZv8qfQ0s1EMd0t09jU10CgoeMTpnKgmCNIJhrKC6YIaaT0HddCBbAdT5jZ RyHf6OmN8kKToPy8KM+teX/+/jpH0GAA4BqUw22ismMaK84D3BUlZ8X+eWyaDX3l/uECJG sdHNvNx4XigBP6QXhED4aFrXOZW8H5GkHMa/c20aw6/Z6ODB1riw+DFkqNIy0SBJA5OSEJ r4FMfB2GsMXw8zEEhgNcCoKRRABU4ytDK2VOdRkaAPi2miVdseWmOdvoi6xBuw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881624; 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=SZppYYpyTvmjB7MNa4nQjpEdTsOCMp/CZ0uXUVBIajU=; b=bVLQNSY/IzZy9T/mdXlHAuD6Pc7kihOQ2JNM3Zk0whZiJjAa5upRWBDb4udlCYKK30YYDL E9ZZSbRKzTU3XvDA== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 24/46] genirq/chip: Rework irq_set_handler_data() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:23 +0100 (CET) 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 --- 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:30:09 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 5254A26E97E for ; Thu, 13 Mar 2025 16:00: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=1741881629; cv=none; b=oPqnmDRPoFhLbHFxuO89HyYqoauyffsVSWKBt9GrUuHJQoN7NxBVWRJJ1KS2z8DFwTHUENsFTGfXNxRKGD/CVH8GObztk4vrXwnSAUBv9OpdOSYVX38PgS2MtJxLZZ9HrhUsigSMbm5wbZd0E9BmxWiHZmYplaIhqa00Nbwr5Gg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881629; c=relaxed/simple; bh=6AdCTZXW4ujUGvs7TOpS+/fCGY/mpCKYZQSYTDFyDjk=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=jv4J8pvNxu9YvjuP1P8tRpwtSSyqnDLoytoNGnKOdD2U63ZM+ULjzekZykhTP3m+j5KZWMxzSLA7tmliHRUp34zGw1ukooi/g1vnYW5F6qkETcCm+vjcpVliHN2RpPXvz95jz2eHK/ce9AX1ekBsgxFTysiH0D9nuXCSsoyM8Xw= 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=FPxncm6I; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=i01WH0/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="FPxncm6I"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="i01WH0/g" Message-ID: <20250313155915.588553874@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881626; 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=8m0pS7BdpfO/t/en/kCD7bZ2bw6XD1PoP+xUffyza4U=; b=FPxncm6IbU7dpU6k/dE2L0zy2SNh8If5Jb39Tm/GLUDw8tieScc5ReeuBLZvjwngBzw04r 4yEGYwIfmCPmOch2uclSiMGWOM+LJbzjd3wj7HNqoPfo6Hp0lWtf2DRlh6+IMbyg1VSpb8 FYxhA1eyEfwxLeqRkyM8WLXLGgK7QBEXVIlhZ9gRWvGbnBySE7Mcr//975N/dls/t10e+5 bv7gaoqZT2+xgwa98xhlOydR7vltyrhU7k0HrahGXACEPKdUxvfaZ0L3WG5TAaWkUt5dpN cLOADfTXhgx7WyFkRZoUeTGuhXjHkuqMA6bzZWKDfAhMeSLFUuxHnRIteWpolg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881626; 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=8m0pS7BdpfO/t/en/kCD7bZ2bw6XD1PoP+xUffyza4U=; b=i01WH0/gFfZAVuocXXuSZUdArhynFszhkdJvR8SGR7ntzwmlo9l5Nazih3B2fPB915S2p1 KFSBODibJZ3bX1Aw== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 25/46] genirq/chip: Rework irq_set_msi_desc_off() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:25 +0100 (CET) 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 --- 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:30:09 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 7D13E26F453 for ; Thu, 13 Mar 2025 16:00:29 +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=1741881631; cv=none; b=ukpC6Q0i/qGb109kGXthVYtjproTNj/ViPKZ74a8mTySoWED1uXG3o3NQBGbxFhkOKLDyRcSHCpnj79JLFN7Zgyo3j/oheChW43Xaj3u884xGDYb90vYXch7Ula/gvLIg+wPHgfaUOCMIHuph9tcepptgy9IaLLnTNGBAAgSmKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881631; c=relaxed/simple; bh=dASglU6e2axvZ+0kMhEfTbhou/R1GYih/vYta8iaaHI=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=iTw2zm7MMBnlXGXz+qwH5ihcfuf4ZQs3fMQOfvCAZ4aRMOET4mnVCv2k7iU8GCYY7QB/x+yxxRYC+ZDXXuabJlrQ4XOd0pN3+8zn7ZkjRxzfBM+KOsp86+mHW1TAG9GcoWbuSVX2Hw/qCETPrQxOGtKJNPA1/+doedvPlh+KZpw= 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=Sz6QxyFY; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=VRQqvmSa; 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="Sz6QxyFY"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="VRQqvmSa" Message-ID: <20250313155915.660408159@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881627; 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=GyK0EH593FcjVwcKJ9EWWXsONVn3zLtDfRm+tTScKdE=; b=Sz6QxyFYdzf9mql5W+nvqH1Jh7Oi02aZnwYWv3rJXaSf5RrCvZv7eLTPoyRfkliNjjvv2y 8MJgHMnX7cgSP+ORmanMIKBHFwFQf3EHT9qNC/9J/Jqi7Co0KjBtypkzJS0+5irJ6fWx9u kIHXZvy3Pycqi+O5/ESrvLRLXpK33ClpkvOuI/eGBNm0KuvanM5YjljmLMCz7LKgv7gIIb /jwFNU1XqvmozVaeeH1GTIGHCW1fOXJjUP12Rg6UCx7Mfv/KyVq+81nLgeRbW7hiN5cBeb asBFB0HxpwzgSk6cOHgHAL3vNmwGZGspw9S4g8EPtYYMFxM5Pp699iltxR61zQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881627; 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=GyK0EH593FcjVwcKJ9EWWXsONVn3zLtDfRm+tTScKdE=; b=VRQqvmSaa4tbMqCJhYfIFkJnFF2/ZY22NVu+JKz3gMeV5G4gSwT/BG4hLaEN3E9SpK87CA zlU2dw03PB8kqxDA== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 26/46] genirq/chip: Rework irq_set_chip_data() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:27 +0100 (CET) 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 --- 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:30:09 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 402AB26E959 for ; Thu, 13 Mar 2025 16:00: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=1741881632; cv=none; b=JZnoJL18xxIrY2y4FN/LuuMSHCXtTvQ/WRdYBh7xlBG5dl1B8pnbACPDi25k8ywCvXStLtysCfcpz8cIcLLjfmKJDcutGhGtrPGfKYKw66Hl/+pc4Od34yONuuYh+0PDZ890yNZRksvDnli4XxcU40ilpL7vNESX9LHI5+1FdTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881632; c=relaxed/simple; bh=uB0sewD/X8gbJD9jyv6i4iez/rs62VLP62MvshpIqyo=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=eWD6t7H2mD7kMrTm0k1r8aMLvOTFC8FBFpOt+exBz+EfukotlOrFngHgSd/QwYUt9AALaoGe6CrWIzyrWmB5NO6MCro31RGT7JfZBhil4FCOp2fUC5Sl5jL5hr+fG53ScNanobkWXRzSWcFOFeC3YG+jOSZa+t6uAn20XItAGPc= 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=SBqtcnK7; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=bEDZX64B; 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="SBqtcnK7"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="bEDZX64B" Message-ID: <20250313155915.728402313@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881629; 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=gNmgVlyxfSLEM0Muk8MAQIlZJwhbT8iEAmWhEp/VBM8=; b=SBqtcnK7cXmD4e46E6Xn7C+Ek6z5QoKCFp8U9wzKAm6kUvBdUy6AKZ+h0Q6vKwCNSc77ah OOqpA0DLf5n//MNdUXbu88cBGvTp3j0S9doxw0Bnp275KcDyh4ffNOuL+Uh2/ZM3QHD1iS mw0WSRea4al+hrt/+/aO5ajahYA17sOOb+0At4o9oz+HmmV96XyOrG+gKkX6ailWU18DUT LDPdyIvPmBdTOqd+p9syhwjBHwI1ocIR6w7SsL5T/Pp2vS4bYPcLpkifCt4FKt9F7krX/L Us4uPy1POD3MKEq2TE/q+6Mv0Vj6+OkE6q/m/6LTrUnDmPdq9plXVsnTLSqYaA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881629; 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=gNmgVlyxfSLEM0Muk8MAQIlZJwhbT8iEAmWhEp/VBM8=; b=bEDZX64BM915n/4Gk6NqB7dick5dUJ74Nzg/uHlNhHiflFsKPLSGT1QqVCKyvkMbpg9m1s LKeGKsLlwI8v9HBQ== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 27/46] genirq/chip: Rework irq_set_handler() variants References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:28 +0100 (CET) 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 --- 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:30:09 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 B719B26F47C for ; Thu, 13 Mar 2025 16:00:32 +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=1741881634; cv=none; b=RxYImvkQDZpRu/UAHEqY7D/Nxu9VdP8b055+PSOXsJvPWQ3HzyTvQ/ARldeYVyxoIyT8qiGNsCV70VW2qzkuP5PIHxFDYnicadujmrrSsrn4UM6vZ/6KkwKP1l96REPXlQ/nzA6i3CZxyRsyg4rCrQz82RxZlJJ38uAmC+H9UN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881634; c=relaxed/simple; bh=Vavl2DtUnnB2ydlyEK1fgQDOt58k/ezEpxVpS0jYlA4=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Kugw00wsAyrZH56EGCMZdUQlNbrz12xCrjjKYftxs659DePZ6QGZU9LDBm9sjkeDHk8RXhvRaS1StpBOb61z7o5aUfSMzBHocjcv10nWNeqfoVfDCHm/bqMvak/hR3nWnN/7siECmr40W89C76NWjoHIWjykAxOs5zJImaFQCCw= 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=n0HdXtGe; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=VWur79KY; 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="n0HdXtGe"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="VWur79KY" Message-ID: <20250313155915.794856595@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881631; 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=Hm+dYey42J9LEd5L9MWy6SefTDYLCO+AcXSE5xq6HWI=; b=n0HdXtGeDk5gBOm4TZjtFSknh1nN2TBQNAHkg54eZ7Cps2D9B3CB+qA+z6y7i3536Z2mN/ AWsa7dhAYqcj7v2CSQAZfRcEEEwm1UwVkxmozhTbM0T8TLgAIOVP4b98UwkbFvON34MSxp rkcGFywKB9iclUl6phqaozoRMP2HZuFOuda55dKZMfKUa1KeFc7lIOBiXuiYDOcar0K0qF 9Iul5tvCM6X1fj9ZtImclyv/m53tOx1FvfFfG/sm9YpvNQDY5LmPVAwkVUNpNz05yGekjb aZL/6P7v0j+3Tsi9qTU2oEQCaqXB9w/1zXz/wFPTMAzCqO9znEEvU7fzEsX0tA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881631; 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=Hm+dYey42J9LEd5L9MWy6SefTDYLCO+AcXSE5xq6HWI=; b=VWur79KYFuCYs+Wu2hZJ3IwcoDSqjfSij2jZyAaqQZq2u2EEeY1iP0EC98e3TqW4y6HcQ4 B/gP6HuM/2aEIdAg== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 28/46] genirq/chip: Rework irq_modify_status() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:30 +0100 (CET) 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 --- 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:30:09 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 55615269CFD for ; Thu, 13 Mar 2025 16:00: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=1741881637; cv=none; b=MTJaGAVwphR8jIN2D+1grqr4Wc7PRk4kiUuI9SksjNHJG8STteCwV+sMQyi+/s/9y+LP6M7fTA1M7BI/FcapxgKEnwJaqRoFBomyx55wi5wXxQz3JJcLZqiUGO4mm+c8Iat8SKK8Jofeiz8+tKXfbo2OO2XYwEQ02vXtY1E571Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881637; c=relaxed/simple; bh=AA7DB44SqdT/Vv7gn7STjpwrmASbclM1h5N06XTG4OE=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=LO+/JN3oH5iSVNTCYl3uLeZIN9Y/iFqRDTzQ8fvzfrbEByZbSVJmrFK6C9jr542MpdlsTjTvhcNZlHsK2XaOa9XtzhmhvT85xVoUgfi6m6s8TUv9B07vyvdadcJTtDZEv1GAScn/BsVBGhPO92UcUIravnzRdgTWAcrFWHas55E= 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=JZix7BuB; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=7MMQjnnz; 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="JZix7BuB"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="7MMQjnnz" Message-ID: <20250313155915.861963285@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881633; 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=AVjQ0jXNc7+mnch6QGwXLNBX9mH745IofOEWtCCFZJU=; b=JZix7BuBUta2A5MWL6RzaWEG+03Cxrj86jr3MPgW+Vu/Zt4579hyikQp0Hju++yxqy7WIf iHBqkocy/ci5fl20D6eEQolLHHiYpTLifZhkN6nSRKt9T5bEs/t+eyZ3MMy2ESxCUlRY7c PD2+byMegw/kfjlm6Oq47q0J25anPT4hGW4bmdEoUIg2UiDS/uUMjM8Jyc7+dp8RqF6tDf BB0ZYVFZp5NdW37CBWSWdefAkbhc9eDjLpP4MRPYT0IXCSWP4YNf8uSA4aBBwTw4YFn3pV U4l3tXvj56RiPjvDNZr8lUvh+JGtrSgVCevdSQMT3f5yxVPyIWCxyj5vsCfN7g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881633; 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=AVjQ0jXNc7+mnch6QGwXLNBX9mH745IofOEWtCCFZJU=; b=7MMQjnnznzfo/pm5EdBk96RMZwVl3PIJ1Qhhxv74X0e8X4PrqjU3sB5o0fHTRXHxYUIZcN htDwyVBsSmbepACQ== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 29/46] genirq/manage: Cleanup kernel doc comments References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:32 +0100 (CET) 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 --- kernel/irq/manage.c | 570 +++++++++++++++++++++++++----------------------= ----- 1 file changed, 276 insertions(+), 294 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -74,26 +74,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) { @@ -119,19 +118,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) { @@ -154,8 +153,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) @@ -179,13 +178,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. */ void irq_set_thread_affinity(struct irq_desc *desc) { @@ -541,18 +540,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; @@ -643,15 +641,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) { @@ -703,15 +700,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) { @@ -720,17 +717,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) @@ -742,40 +739,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) { @@ -815,15 +811,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) { @@ -843,13 +838,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) { @@ -871,23 +865,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) { @@ -1332,10 +1325,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) { @@ -2003,20 +1995,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) { @@ -2097,42 +2088,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 @@ -2230,21 +2219,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) @@ -2271,30 +2259,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) @@ -2496,9 +2483,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. */ @@ -2507,20 +2494,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) { @@ -2549,9 +2536,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. */ @@ -2576,21 +2563,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, @@ -2638,25 +2624,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) @@ -2714,17 +2700,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) { @@ -2758,16 +2744,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) { @@ -2814,17 +2798,16 @@ int __irq_get_irqchip_state(struct irq_d } =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) @@ -2848,19 +2831,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:30:09 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 66B3E26FA73 for ; Thu, 13 Mar 2025 16:00: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=1741881638; cv=none; b=USguBuRleYjqqZrn+nwfp+PjCSikYO5LuzZIu8guSbDljGF9ropu6VN/PLx+KFCQGpXAaF6FUfHjbU5AiWxmN7XREoH8M1H/U1F/rCsQTaT+7FO6J+EK+u9m5tn6REslYtoxsPiwNExIPGul+oRXWONZFVgpc0GvMWa+loUnYrE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881638; c=relaxed/simple; bh=LOiEUN3sKn/CQUuv5YyzIRD2bVS8EwXZ+jX/5PelRaQ=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Emjyfgkph6F7MZufLfGImmL1VA/0ULDOLwwkHAG6jvEnMOKDzXKmdg82hLhiOTP7oKFiUXnT2A7XByWsaCy3T1a9jJTOMNhZQBRE16YEfcOL39rvEAMlpT7Ad1iZOPWhxj6cf9J/QdZQl4HtZ2o8TPwq5dh4f95/44Kir1jfAAc= 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=wDzgIE9d; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=clOuTTHO; 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="wDzgIE9d"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="clOuTTHO" Message-ID: <20250313155915.929305667@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881634; 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=gTG6G6FNOWG1almwGqUB7+4qFuR2aoT4zFt0q2JJ+Co=; b=wDzgIE9dtcUQqDjsQbSoEfKtA2sH9oeypZYFgoN8w9EhyHtbuHO3i2K+1t9Tg0jC27vO6O JxYl7iflojPWFaGV/9FA8G+s3NpqetZf92chJxCdIb9gbT1cVVzTU/I8wr2xhbieoxbHUo DHp6w33FWVluBHhFJD6xnpF/px62RpQA0R6X0q9UKPaDC7kgsSnyfeHgWQheCCgFShW+5T X49dHDY6E2pCfElCSTAo8sz1UkAu5fEEbgXGSSnpaAkcrKNQmNhw0LAgHR98+3w5qIaBXA hAWbdUFv6yK7e8JFBu08Y8LwxGwoEmXG9VJLQPe6hnhDZ9RJ/+BsCIp9vU7DdQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881634; 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=gTG6G6FNOWG1almwGqUB7+4qFuR2aoT4zFt0q2JJ+Co=; b=clOuTTHOTAsauSAHPEgIl8oFI8qGclRbGWo7GtDRtEYRZJyg9PgOVxPYUqxflxYiRmcH0O SRbvLQFsx8u/fCAw== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 30/46] genirq/manage: Convert to lock guards References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:34 +0100 (CET) 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 --- 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:30:09 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 4B8D926E959 for ; Thu, 13 Mar 2025 16:00: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=1741881639; cv=none; b=M9c+gF5+cq4JoxICQsDbuBD2KSrDsoRy1ANiZB1ECZEJOsfDN/m3NVAYc/uE0vPVaaU09oSxb9RPT31lcx7wngI/gYlxyL4S8tGNYWfbcdO9qyzsoOZbqsPC45mo8fZ3lJ8SXiH579nXmGfNe2W5H0KvXkuh6hL3oDEGB6t2IyY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881639; c=relaxed/simple; bh=bMN+DbojOy5B0OswHaeBgYwVxoMnEJCouo/AuqNgNy8=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=XBun9/Lrk1AiXuCyHRGH0b5XZGNChxxWQHZlIYU7P5X+AunoXpAwH9f64xHL9F9l6DJmi3PhZn5iUtqriOgYcovrWP9aA/dsSic749wPxahC8y3Fm6Gq5XiPtz/JRnSFukgX5BA3PGrwz5n1o4nlz4uXr92pnSph9kNG8Q3SG/A= 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=yr8yL4Nn; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=2GKbHPKL; 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="yr8yL4Nn"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="2GKbHPKL" Message-ID: <20250313155915.997259133@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881636; 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=2EVkz1rcKBRf6XF592WLPXvWWe+ptpgPbWZ56FdYztM=; b=yr8yL4NnSvcTKEFZ7buctpHapGv7WDDLFwguHj6k1jJh1yL/Pv9Ipgi4UmCGKQGJ3E22UK n/LDNuAOMYxeHe2hBM7knY0lktkhB02HsbRcETEsgj1AwjQPmn6mD9cMMsvaVfKE1DcTHF Vb1/bwtw/eRJPoTzDKIgHypttIPfYWX1th1jOQhTE4ZQT6+V+vkfilG5r8kuERJ4vaOkbL WuihRE3TUG58JUi9UhMVROInbof4QWfPp10kVqbFPvvbT9JGCgTSBZ3l8D07mHrMFiUIjH OZY2nwrdKtwYJimnnX1D9zEvGG0j1mJgNWY8mTXTo6TuSFQG38Em8HXOAsZzhw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881636; 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=2EVkz1rcKBRf6XF592WLPXvWWe+ptpgPbWZ56FdYztM=; b=2GKbHPKLw+ygJPiOD/SaG/Hfd0TMLB/MtRL6CiP6HM436TYYS09/SKwBg4aBjO+VTJ/hLU Mo2137yxySBlDGCg== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 31/46] genirq/manage: Rework irq_update_affinity_desc() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:35 +0100 (CET) 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 --- 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:30:09 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 7749B26FA79 for ; Thu, 13 Mar 2025 16:00:39 +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=1741881641; cv=none; b=nSBzPj1ySZo3t5ZbeGoAqCy/1X3SN1DU3MYFJLYAkeaX91YAmMnB0ZZf9KkGu8jtzKm2fFGWuHrW9p4Yan2pZDq5aIkC2pSwyOsT3mNIX69AOsljVcYMtamt4aK8TQvNWBcg+C+NsNYk2B3a5evWEoRhr+eanX9YRORYrt7yqaA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881641; c=relaxed/simple; bh=G+O6RUMMR7PjSszWNkH6ckyVAHAcBkve6EKrbzFLgE8=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=mhO/zB5woELGGRLx2tYgF9hXiIDW/wBN5nnG3FvVVh5NrugqkH1mReVLX8+ISbxHNJzqCqhuR97nQXiyzDNu3MLXBNYLgci1j5+vSuSFOQ2nZGuKuntsUCYTrx+O+u6bp+iwP5G2VWRJOf6LbojQ0YpY70iFntm3S+lUcpCMPmE= 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=gSA0dc4b; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=AszdOOlu; 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="gSA0dc4b"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="AszdOOlu" Message-ID: <20250313155916.064161381@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881638; 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=Zp9bqtXWJEgOWP1KXbSKC64/wDLZE5Pm7ZLMi8Ztu/Q=; b=gSA0dc4b78dWmKhrRcKJIn4FjTTg20qilKFrjF+OZON/sAX5QhVDGev0oSiw4cdF+1NNxt u3dw1fIg6QYjiW9HjLsFRzhk4K/Wg1s4jl4yLtTEVUdm83kdFcT2lK7qYwmBhLSy08Cb5l QPM5n+Aw3mkZorq481viEeeWPG3BQH8YS+5juv3IwgNmWY6ccDDtCcSBRadA90WsBQ2NhP CbItYNDucXM9nPfNWhRnPW/RxXY4ELDVFjMSSSxIJv7Sk8hSbZbg/rpnVuVVLzYdhXELDX 7Z9nXcs5wf+Lh4YVZRkWu84P8J14s+Gf03wEDU0dsb9bcm1iJLhpelSgqaaZSg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881638; 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=Zp9bqtXWJEgOWP1KXbSKC64/wDLZE5Pm7ZLMi8Ztu/Q=; b=AszdOOluoVxMJthyzCdCi03Z/u+/y9N/1fNhYyrOlQXiNP+MaLcty/H+uFUS00JmIDkd0F p/IBmVzF1z5FrrAQ== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 32/46] genirq/manage: Rework __irq_apply_affinity_hint() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:37 +0100 (CET) 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 --- 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:30:09 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 8859D26FD9F for ; Thu, 13 Mar 2025 16:00:41 +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=1741881643; cv=none; b=jOGHhx9uqGKf44OeRSEU0QBK0FQrqhDVVqVpXfrMhL5HZBf3wOfEKdOAkqaYmzggDpax13hsOm7XvLJbZnfOL46sbaAFY/83+7vsnx46QPShWkLsappG21Eu46xOFhRMK0V+i5fC6VITjUxgZxZlJwdbOOQU172dRbtXRz9pC8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881643; c=relaxed/simple; bh=fX+9V4hA3EQMuF54WJ/NA4nHJQFLadOEmXV9GbY9xOc=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=r0PB0b8fC0IplYOOCZ87kw9f09AML4TPRLV+ZSgSRdnxrP9/K2f5SWsoC2u3Bl+gxw3DjU5OUB2BTzYSbmbegQ85hjQFt3x6QOow0JmtaWKsqQQCPd2mS6Gjgni3n/ZVEXk6lCzKyazD7zDfhtdhwS/TZt2umqyk7wvZxq1hbDs= 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=3gTtskj3; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=G8L+RlfU; 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="3gTtskj3"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="G8L+RlfU" Message-ID: <20250313155916.130540523@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881639; 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=yrnX7COU4LFeImoI8Wb78L4FNIeSjf4l0HTLETlsEkY=; b=3gTtskj3yBKtHpIed725QXcgfplI1mgd78ieU55TvqMuc8u4fkLP8sf3DKMAcWaObdI1kO /051GjvL9IRAu0oPcI04bL1WIU/f8CeOlsSnwavwbKVXNY7lIc7+C7NynNIr+VgWppHjxv DCIBrG+fN//9i+y36v+YsveTHO+Q+sxHMLaKOsTaRNCLTgXAKdpqWn9nziBoh/UmmNfgmy t3SOrAoJ1tFzXeIwDxrMfr1MekFqzjsgFRpsaK+M1J/jRnSXSknqQAkNTHCGthk5AMJM56 zUOhH7yhJr6uojmn2rjuyz0ykrMMzdTssASTc3b/mxZdt9tAaZUXbksqOvVTlw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881639; 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=yrnX7COU4LFeImoI8Wb78L4FNIeSjf4l0HTLETlsEkY=; b=G8L+RlfUS8GAG+AZEcnKWEXydxCbgxnE+2tIp/gO+K1sMoDNExc+TanGbYeqFqvyJ+H2Ba pafk/5nxpf3eSRCw== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 33/46] genirq/manage: Rework irq_set_vcpu_affinity() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:39 +0100 (CET) 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 --- 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:30:09 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 32CE127002E for ; Thu, 13 Mar 2025 16:00: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=1741881644; cv=none; b=Yu3GZUh1xB+ijKJKXsPZM5GtK6phPsQfVwKYiYTzdEpW9xoXVSXI9DaQaFRofKiH4d6z7EMNqjq3pyY781WU2ryTu44d8NJhVinEXlHvuk2yhvKwEe06kV7nszNJw0LCyUrc84ZnOVu/QxnsLqcK+j79S/76hCuoMd2IbA1sd60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881644; c=relaxed/simple; bh=y2Qfgh9O3vyfxqJvAsH1OMkacDTWW15QSL0dVpGaE28=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=E9sJnnNPuxdRwAyFGZ1JYPnihffkFSQYjwKtjHOKfzr5L7FEYbSV2MFPAqOexwR0lz7QP3doUGHhTOWvtGsfIFAngi2NyOha55P0jtQnb0W4dSZ5GiTDVmT98qbjfmx1pQhip5a4KPaQ5elyYg2ZjDb7N2dt6BfVecCE8GR5GGA= 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=dIslWc8a; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=0UF9EI4n; 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="dIslWc8a"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0UF9EI4n" Message-ID: <20250313155916.196278528@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881641; 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=FyGdT/wj/ZEi69WkEeKXZEcm1FmkbQvnmLPT35GEITM=; b=dIslWc8aI/2PXqjTmJNj8f4AOFoGliEPZfH4g0UwtWC5ANf77GULiWfhekgrFjZvkxBn1T G+Ggi93Xk2jYFQzb9RJ9VsFdD4tVsmAs0pHVxHIGvt38r+YG0seSpQDfP08JHAbW2ezkjh hic96GmpLvSEURpqVmGq2moIPbNQ4kh83ztTZGS0GNCW1ZB/KsGba70q7QbJzTnkVCZlvD awG54W6KC+dFsLKGu3uIorx9/HelH7fut/gxNx9gBcINOqbL+zACQr3J8mH3g8CRVS1kve QDj93BCCJq63mVmcyM7276AAvTkXYOYlcObVOUqQr5FbtKGwOZB1sLlkC8JLhg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881641; 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=FyGdT/wj/ZEi69WkEeKXZEcm1FmkbQvnmLPT35GEITM=; b=0UF9EI4nGSzvcUYkJ7tFj4pq7YoYATJ2RSGDGYyi98SNY5g3u2YH6PivMrmIqT0lBbbc2w zxx9q++8cUgDHHCA== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 34/46] genirq/manage: Rework __disable_irq_nosync() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:41 +0100 (CET) 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 --- 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:30:09 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 2213C27005A for ; Thu, 13 Mar 2025 16:00: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=1741881647; cv=none; b=hWlY9i50myDSZQb6tfsGNElVZXT7EZuB4sxBg3E5QWp6wNOIb4aNd+aV3Y00XQDNcV+Owj2zzLpsooAzCQz0MQW4w1LYkkcNuedkrozQfRu2HRhnjynUWTn7rFnryXD0cFM+H07xcNDCKcX3RigXmUUiaf5TufQB3A2kCrHoOUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881647; c=relaxed/simple; bh=XPn9ovDcyi/hW6vEFdSZx8GOXw+zO7JA/Fus0LhHqMc=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=A3aymUnTxqowqm4EaioSns17JYc2e+KSOqdvVKLca1agSTx5Lns0vUfH/cUAdKVBTBTb/u/Sh9cDODLPazoFHTkH1LbizSDF7HRQwpAzM/LwJsyyUIi+dftUnrM1I7RLnBcAVs191zqaxyf2ZNAkFeBGk1LNbr2kF89pUBJBhcc= 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=v5Acw7ba; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=TlNDOjCQ; 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="v5Acw7ba"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="TlNDOjCQ" Message-ID: <20250313155916.262816046@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881643; 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=qAITU5mZvIeYzJYUj7EkSoCfebgAS5tXEspL0xsod3I=; b=v5Acw7baSufCUd2Clj7N47KcgovScxOPp4yPa/azOFCE6eBGIn3f1U8ycPa72GZCvAEQbz PADHBOaI5D1FgMn5iIhp9fy+WwMPtstXS95J0AmHd7x7zvQ6zKmWkIlQFP6uwF6AVgTYou VZSug6djafm+VbRjZ6ZO9IpmEKry8sIP8Gla+STF2gT4OLA2ciF/FZieiwUdBRRKfzV9gC +J8VY4thVWPvqhLaFCQHhEzLs+SeV24A3WrCMrVBO7RHPRY4m9sZwfZrEb715v+a6ZDTlb BzQ8YM1S93KTmwTPNnxUcyFWOG4OzPX0SA+Q/s10FIPU8NOGiRkUL5VWM7E2fg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881643; 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=qAITU5mZvIeYzJYUj7EkSoCfebgAS5tXEspL0xsod3I=; b=TlNDOjCQYAXsvGvRdT6cMXGviZS6haAar5XjIVup6FL/PO7rKQXN+VSE4tlLG92al47/eb 9fqQ7VlGjqxtffBg== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 35/46] genirq/manage: Rework enable_irq() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:42 +0100 (CET) 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 --- 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:30:09 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 61E7C27005D for ; Thu, 13 Mar 2025 16:00: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=1741881647; cv=none; b=fo/gGiLQq2NmUyZMGSxcPNJb73IUiBhN0iT829VDx56w+gMxlCktxxEHaLokkti5xlV7zKSp1kfxdScyeX+y6LcanoLKpTH6yOplcS/Pvvm1Un274CcBt6aSIeajZ8zQW1aHriiyXqA4CrEqA9Mf9M6/a66pYcfV1vCO2I3PxL8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881647; c=relaxed/simple; bh=Xbp4GPbXtcWOJ71YmuLxg1E6RaEKbB2RnvBInvUoDnI=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Psrvtd0jmBkzlvs7ULixF0ApIP3GaoGQaNOpA6IIxMehuJj6wRivg/kSjUDgJLf47J/ecPKoz3cfLgWLA/rSp/KLbpX0hFm0CinM4cp6lQhkjDk3+Gvo0GF43xMrkAVmmMDt95C171msce989e5ZYwxtnY9W1vMa07qnNhB6UC0= 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=EOqt56Sf; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=KkQGrnt6; 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="EOqt56Sf"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="KkQGrnt6" Message-ID: <20250313155916.329399391@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881645; 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=/BowEdnxdEYpHrLC8+9yvjB5ISXv0pAhEHCMyXLAkQI=; b=EOqt56Sf9jdWMGx9pREH8VxJiFW0a73gGkRo6n+pivgNEZ2QTe8frOdck7zFEPUHHIkLtB OhGijl+gS/KZvm8fzCGmu8+EYb+l53vbYe9uVyto7YVKoamDjLyCoIzlf7fKXrPRlEUOtq UIaa4nHBm4FTpetHoOhRgJ7j5i3tgHmxf79aI0YztZxb5TN3/G8McHJcvzY80bsrEUTBdN qAL327qGNjDZxOZvdHky7kpdp0cffrOc76x0K+Si4NEVyo3NQYfq0a9byXSQXhpZB8WC2o 1zJAn8TFbLVDCe0C3dKgcyEaZ8iGkQ7TkrYgc7dN5zk9K6j976WOlS/5G3KFyQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881645; 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=/BowEdnxdEYpHrLC8+9yvjB5ISXv0pAhEHCMyXLAkQI=; b=KkQGrnt6H8jLsD0oJEvOVnDQibhpauzIOqR4+125PyI5KlvswGaekWsL90+ayUPNHhn1Sg FNV7RqZx7brU+QDQ== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 36/46] genirq/manage: Rework irq_set_irq_wake() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:44 +0100 (CET) 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 --- 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:30:09 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 2C45D2702B4 for ; Thu, 13 Mar 2025 16:00: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=1741881649; cv=none; b=SdgBK1Eotr7UseL9HjUJYb5F40O91Z05irpeyuXhg+o/pXMkhiZRPWQn5sjRqg+D+N3bb2ZHA7HLQfKBDv40Q2JgeY9/DPZd3QqANnGmYxiPk+uu61RctfUqJqOlUcKdbcbIULSjaAkMhH2aed0hXhm+YcLAjNP8UNcOCr5WijM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881649; c=relaxed/simple; bh=VQzJgZotj8ZtgQcJ6Edhm1zAkrPtwYakyzFXTItHvYU=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=ahW1q31Yw0/2eqv0AldmMzcKFiCKIGNQke44jqInWOH6HwhGaOTzZFWy+rvanWlLIshqitlrbJcZXQ482xw7uzh1vXlR/qi5PSvwmBLob4ah6eL5RitiWYIfuNJv2NMeQlPQztLGo1fpIxbC5VOdh644S70xjowoubSFvUJtjyc= 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=UNwAMfGL; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ayh0/9oG; 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="UNwAMfGL"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ayh0/9oG" Message-ID: <20250313155916.394833438@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881646; 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=XEQFY2GvR2o0nlA2bS1T5VB3+fBDAJQ6z72wzlPROe8=; b=UNwAMfGLPzkHORz924FBXAq1HPhNYHtYN27WWapI7GY2YPlXzb4xOHKsx1TVF/Y3uIMXNe eXwPOo2kqgf4sdWMax5XiwP375Q8kmaNvai16P4m+pLLWc/Umj3LwQACKgd37EdmZa9pS3 AGCBYnPFDw4nqLvgs9NUzOrL0+4tYYQEAriIiob0hod88aXSS6xhyIfbkxceSyTWSfHPhr v8B/yPGew6i4nPC2uQQSYEFs2Nsy5lWnQO9VaNAau9WJPfyIUN1NI2/NRWnEAfnCfZgGFq mdfZuyxhiOlWnK4e5+BoDhfXqEqi9T8o58WKoFlp4He6dlVEhJ2EllSwVuMuqw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881646; 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=XEQFY2GvR2o0nlA2bS1T5VB3+fBDAJQ6z72wzlPROe8=; b=ayh0/9oGh3XYwzAVzJsAHCZWr5/Cp8rUAbsVEB0I0UQyZFh7K7esFwAfg3Jh5yQ56UH979 XR6e8jta3IFSBIBA== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 37/46] genirq/manage: Rework can_request_irq() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:46 +0100 (CET) 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 --- 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:30:09 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 485C91D79B6 for ; Thu, 13 Mar 2025 16:00: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=1741881651; cv=none; b=Pj/W86VGTghugP7Pbihi81KcEnDzt6Dbl7hGjBr47zalA+tlIFYqDuLaw0IDU52Ibjs9P7xKv2LHW8cuhgeO+gdfyRR0yZ18iWFv33i0QEfVivKp75k5qzZ+5nJziPxBDriG6jTPt2rPlCZLdaIzOFKOpQK87Pn7E0o/VX0z/78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881651; c=relaxed/simple; bh=7OGHj8ca1aYwqj1cPr9aQ7GIsfk2dFspz38uKwmKKO8=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=fdgVfsqai7KLg0oFG8z9X4Pz3BlSoWTwVDVEbAq04SpR4B1dB3caa6144sCOsgyXJd+5Bi4/7EHI2MZoSeECQR1SY2m7ltHwH61UKUR5X6UONpsU2FML33ymYwQizlaXsfgzCYPsMvt4qetde6OLEeJ4OMmHD0Sdsjex8Dzo2qY= 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=IFcj6FBD; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=QHyElu3r; 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="IFcj6FBD"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="QHyElu3r" Message-ID: <20250313155916.461197302@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881648; 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=o6UlnlIYX7HzshZEKYRUTMKnqz9sEvfGRD91Swcs20o=; b=IFcj6FBDmSgU0k7IfKJIfejmv7epSrPRq7e8ubdkfVgPwltJN6iGOkEgJ0PjwYaBR4ehT7 OJ7iqSlP1a/Om+ufwAz/SyAZNOEa+UmxZFyfFyJw33ZvHS7zte0aZbzOP1sBDdSw0ViX6K pzriFzyNvCAfejYnpFCi4E9t19+fLvZcaFr6TLBSwW4sfa53rQqjd4e4M/4T30QEO1Gn/g CN+X6+DW/qG3FCEpRsNa3hIzluXoJEUDKkOMPhy6NHxy9YJcU+DSd+KVnVcK0YumHvFxOV zlZy+M6s3OzkNuO2CPmbMw00CbY6uqwsLmZMgIhujifFCPbEp5MHmxNlbeTZvQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881648; 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=o6UlnlIYX7HzshZEKYRUTMKnqz9sEvfGRD91Swcs20o=; b=QHyElu3rMYT3f10vkHsJkyZKLrirwdlyvBLLeLPadqwBj8KchUgLBA0qXuxlB5KirjqKEX rnQd2Fy9UjnkRmBQ== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 38/46] genirq/manage: Rework irq_set_parent() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:48 +0100 (CET) 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 --- 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:30:09 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 A3F772690F6 for ; Thu, 13 Mar 2025 16:00: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=1741881654; cv=none; b=a5+hfgsmihXwD/I777dymXcfiDgrHORfN662fAp3j91Yu/o4/k903bezuh5QrW0GY9z+msuxJ1Pa9ilgPjJHLv7Rdgh3dvxwHbgYZx8AJlC6PhOIqC5xR13+SeTvY2JVbfzwLKpx1lQnwXJ6HK1OljjcSGBr60KEKHRHhYKpWo8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881654; c=relaxed/simple; bh=h/dtPELlqYG4UUaTn/ldfEgaz4FJRzqajpH3K8Iv1fI=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=d6piZVAjZEEVNtcb6nweX2OCHjy6i/ZKesApULAG7dMp/sZJXFnLaOkpqEfAzHgqIXIhtplpxYCtWSL9xVOx1JbrglA8IDlVa/KKa268O1vlYQnosBh4gGlENzKKIgN3xF0yzg2xsnPNVWoQVw8QWLCJlWUDmLQM5Q6k13RD6Zk= 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=UJIhb5wu; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Jn/KcOYG; 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="UJIhb5wu"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Jn/KcOYG" Message-ID: <20250313155916.527722355@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881650; 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=mLbsf8I7JWl/g0FpxPntaLQi4iP1ArHtbHP0OlmBo4g=; b=UJIhb5wuSLw1jESMazpUj0EH2XPyQb47VKjNoN270nzlaKwMkLAvLKTx8a/d971XEU309s vFmIdlaS1ATbY2NpJIlOXtKG38HbSyQ0LHFkTLHwJDplOyxTxymPBAYuqWhVmORcHkqsSN 33wNibofL70lvaLafoD/eGGVvpGXOB93vQtNvpryEAtTKos4ThXPcHMxllztqhpfigZnA/ JqqCX8+NvfSTj2pCM/KW6JK9mFPh1f3IETcwnfz8nlYUxwp87siqlLBmh1YjclgB+/f/IT d0BhkDfKX7dRAgv+JMqTJ2a12zlYPaIg9OQjC1w9XrhQ7lmFjQq8BbdRbMEXsQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881650; 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=mLbsf8I7JWl/g0FpxPntaLQi4iP1ArHtbHP0OlmBo4g=; b=Jn/KcOYGuJ/T9giGzoT+krteMFtV6x9tByHPxU0vvBveXmMbY66oWd9SMoWKZoSxbbTQCM zcmxICdoKYJgzNCg== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 39/46] genirq/manage: Rework enable_percpu_irq() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:50 +0100 (CET) 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 --- 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:30:09 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 C7A5E270ED1 for ; Thu, 13 Mar 2025 16:00: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=1741881655; cv=none; b=HUE9JiJwPhlbQHjpMHK/jjHqH9GbWfQbufj3mp3BDQg8pYw61ifYjW5VETIrePKRWv+bXQSjalyVT2frG+fGVEHzgoeuOYG12SYELZA/AHObyiegHCOBSMnv9MjhhoKQWyB3ZVTL739iy5+gAZ0t81PlWfr90AQvA8FkPviWed8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881655; c=relaxed/simple; bh=mVXxcoK3WExTSdKgmIUUyG89B2x71ZcLZlRZ5GExM7Q=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=KvkccBGCLp3+mDTdiPX6gdb/Ide+PRPYb0qpd07+k0myfdTcgJCz3shQH5xlDzm3y4x56nwzwZTve4YEZ4Sga1wqRIheSeCxgfbuwqupaZIjV846/e7bH6aC6brreipuX4Jzo5eYDjLaSiAHNm+h5vNAYHA8IzkcBaBnsVcKjiI= 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=IC2k4W1/; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Rl3gPVMA; 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="IC2k4W1/"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Rl3gPVMA" Message-ID: <20250313155916.593648845@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881652; 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=TFhQSReQb2KUOo2saM7MJ3Hp8TV3kdr6sRN4/io4++4=; b=IC2k4W1/9M3la0gilvJUi6wUnDvJlVEfEklt5Nlj5anbj1dIVwDfaJ+VZF4PTVav6jdBk0 FWuHoZib++0C5zhHP3c8n+8Wyh5CPJeCisVGAX/bo5Zyybt6v0j0Jz6NsedLJB9Dn9yZSB JomuKT5Vg0M7qiBWN7HzGKgxDMxv5TZPLribaDfCEzXpb3gqw3IiRDOZIc5AhJPaG8/U8f omaJleK31vjjtiQ7P71hOXWZTti4q37Yo9O+H7KP3iv799qAJIQEa9MpCBUkCmftjRXTmT m4CUdCe+Q4wxnSSQrpkbIzfhiW69jH2uHy6XA8ZnxX1GoegdGgotr9HtOT4tkA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881652; 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=TFhQSReQb2KUOo2saM7MJ3Hp8TV3kdr6sRN4/io4++4=; b=Rl3gPVMABG75qcj3fJGM0ZdBL/Mha0kIvpGDBBxL/rfYD2MG+/c3908Md6a/v08OTp0yXp jjfIPKuMCTpZO9Bw== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 40/46] genirq/manage: Rework irq_percpu_is_enabled() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:51 +0100 (CET) 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 --- 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:30:09 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 ECB6027126C for ; Thu, 13 Mar 2025 16:00: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=1741881657; cv=none; b=i4mimYGbfg/5aHc+Wa0CsqohbcKVrFbs8GL+mDOLV7cPfm7AxBynhj6MJXoz8LXzjVCHTlSmB/X1BmbhpVfBKmRwxFS6iH4miqlGu8vThfhnSLvMX+oBFPg7Pvl28kgLzRvg6ajfCCboeEU2/79Y4EgCxcCBJx6lOcE5yc6PD5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881657; c=relaxed/simple; bh=X6jwkEB9yQWrChjq2uc6ZtiKiZeDwJ0TDGLwjPBCJhk=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=q8VvAbGQczRy2U8JeJDmozuXh3OSbibFKRtBgr2FmnhGrpmiJjmvAUxqkjfXDd/gOqujgce0QG25wVtMmY45jiK9Obrg8sN92iMf6qZRR2i0opfGUAqdaI1FovRnTJwTjSH6wzZaLWbDxBOLhLTls3dO8UyPa+1x6s5tWcSNrqs= 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=uoRXRbd5; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=itc1WTwX; 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="uoRXRbd5"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="itc1WTwX" Message-ID: <20250313155916.660125402@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881654; 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=0QQlKjU5JNcUlgDlp+1nxq44TSqQa/e/i1U/EtqxR+U=; b=uoRXRbd5/b82Ka964KP9fS5ArAbuEVQI+aQRTsE7OamElr9LvgW+6BBYgZvz4aIOwKahpe ikzxchl+NRex0/1R92E8Dsaz9vZzCZeKPNRiZR38Zr2maeM8qCJDQKMy8FIMM66E3CctD4 rBZsSAhwBbj1WPDjq9odT3eobqZeT5Im3qNoYmCbBsLrAQQRw1nGrwKPbzrD57wqIuezuS eJwdcs35ivU8ylQ1ASNGBkElmdFIX76ONy6QhVccctWCFFSE/b/B2GoscrGs4ysO9bj28M GWKdP6LctwSBeyPgYNpY60aQ5AwvG+ueGvpHGoMIvnoYBrCt3Q58uPyP1BYwvw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881654; 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=0QQlKjU5JNcUlgDlp+1nxq44TSqQa/e/i1U/EtqxR+U=; b=itc1WTwX4edH0PB4nsjFquUsX3Rs3uDmKjhe+in1vc4T7xXRINyqAuuTVH5F/s9hG4NkUg F9M92HBhQjGwL6Dg== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 41/46] genirq/manage: Rework disable_percpu_irq() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:53 +0100 (CET) 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 --- 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:30:09 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 561D427127F for ; Thu, 13 Mar 2025 16:00: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=1741881660; cv=none; b=RivrUvCyxQ3PWj70Q4KbR+SGC3BGE1mVLVfvY6sCxx6nE55qKptTql8wkG+P4yFtz6AtzNg7wijQ7i+HtQA95akht5p8gLSJLhINlpeqsp3XiS7aRfOuSIVLMdmtXrjMU43RwZrehZJJQxBRAhiX/43QuI2Quvq2ofd0jHDbMHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881660; c=relaxed/simple; bh=oxAWkkjweR2dcrV3IFUDJGUa4rwOZbTpjVRPZpoxVJ8=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=tu9iF0Dc4+fVvKsxy4LqjAcx/eWDJAvlHl+pwXshvNsRIQYnukhQJE0IsdlBiyxFoURuBrv99b5q+vvseusg4OANS6fala26n8NlB0IRiaHVGXV7Cni4235tP8pE6Q7F48DCbn3nRGtupukdZbZArVH1WGF/ITA3U+ImJBt886Y= 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=hq4y0Mqw; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=k303IY3z; 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="hq4y0Mqw"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="k303IY3z" Message-ID: <20250313155916.727004678@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881656; 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=0oLkp+NEekLX9fYn3uXFTOkyFkfnNag3oPTNUCOTQAk=; b=hq4y0MqwDt2pOyLIRh2v4VN0SFAnNOil4r6LeF2cLG/Mdn8v4ny8n+tqes/6O0ag9LUc+Y 93zc7EMPuYiP4bMHA2fIeFTwdmuz7SwPsom/8Pp9WGXCsy6ichdWw0sKfjfUWU2uLugKXl Ndf7KuePvZovdpVwoI4iJduVZur9NEaCNkai1Anhr5RhygCIv236Z/HzfgU0oH2tsanUra AaYLIhFasB+yMHDxjI1PvdROkmGJd5ZmWLz030WXvyvLNZamtCyzhEiKEkDj9bx4+pM/i7 kX2Bl6RupQXDnelIHehDUE24s114Pf4jN5YfzjnWR1IYbJBRB6p2irlhntrugg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881656; 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=0oLkp+NEekLX9fYn3uXFTOkyFkfnNag3oPTNUCOTQAk=; b=k303IY3zdZDPjCvDEaSh+1oUAEmyYrcFRz+s6NcwgjpzTAxykB7UDzNl67UxVND50G4hK5 TnNDBI/q4pWhcdDw== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 42/46] genirq/manage: Rework prepare_percpu_nmi() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:55 +0100 (CET) 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 --- 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:30:09 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 8A4C9271801 for ; Thu, 13 Mar 2025 16:00:59 +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=1741881661; cv=none; b=qJLzAoUwWA5pPhNh8I/7OJt648aBTKw4TKRZu6SpJw+kOP2171sUwBUFdl4jQZcp1zL7toqMmc8hzQgo0ntJyoTuv0kAiuBj2ZPzeNQ+GRCFljre/gTMBcMRmdilzten5hcKL6M0E2mfEw1FFowA8I7sOucwA1shLvpYeTRp3EY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881661; c=relaxed/simple; bh=yg/ZmJBXFmKbBU6mz6fzEYdtgoVGLcu5d+ojwtGnWXc=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=KBn8scWI4/NYssiSLO3O1KNwy9Bynzk8+DxeJ53xDYvQnTdgGZ0f/9puobgxIIvH5iiG0l9BY9uEveWnZf6QpuGXL1B3D88gJAwRnJO8WHb7VgfOJPbQbkAcqNK6KGdwPp3HhuPe4XMSJSbaxLoEVmX1MbEcbYps7Wctm2yTeZI= 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/KvRQH3; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=JeLVVep0; 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/KvRQH3"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JeLVVep0" Message-ID: <20250313155916.793162927@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881657; 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=V5kaBJf0gcS62Piw8Vm7nlUZqbdpY8K201MQEACMUxM=; b=f/KvRQH3kOjEtpb799i96hyVD2jB4OYRoXiW2DYKliCToFMikmifeE2FyKuKQHZvWoHdkp 20yUNKeEWY6+jxWkFGVz1EXggkSFAEv+oNtSGcjWIocLG93fZeQMzFFyvDctQfAHnkKmDs CPU+nbfQjTPqvFrefUTJM7E63FvQJN2tXnCETQ8aXIYaBXSyCr+4MmhQ63DTAxp06F2XXe aOLAIajB4v1lnIp1oSAutMd07ASfG0RhGfbFFecqbAUdLE1xnpdavKB/Ll7o/MTuAQsx2k 6op8F0zCPd6OPeOZO1kDZ1qh3PT2wHnf2PZ52udYjUn8+OUXQz1c6SCf7Yjoqg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881657; 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=V5kaBJf0gcS62Piw8Vm7nlUZqbdpY8K201MQEACMUxM=; b=JeLVVep05ijCwCUj8G8dnbzasknLOltTnpyryIK/F3Hrfzz1HketeSu1P6kF0ATU6PyaZv DjZA9SQV6Kbo9lBQ== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 43/46] genirq/manage: Rework teardown_percpu_nmi() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:57 +0100 (CET) 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 --- kernel/irq/manage.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2633,22 +2633,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 int __irq_get_irqchip_state(struct irq_data *data, enum irqchip_irq_state = which, From nobody Thu Dec 18 07:30:10 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 0B715271819 for ; Thu, 13 Mar 2025 16:01: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=1741881662; cv=none; b=UP4SLQ0rNvEDVxVipWQTlYPvVG7IlDDzIL6XoMAqcNtrmEDLqFmv0gBmPByT7tij0SdmiJ6XAdPuY17wVAzwvyF9L1/QVHgIuJriXA04tpl10AjV4/KgHduZhtD9Erv1BXuZfayWkpw7Tom8s6q1UZDzK7ArAB8FENc3xBk1roo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881662; c=relaxed/simple; bh=OTtHhkGGlcFKDopIicgXvVvIR1TMBLwXHoae0RuWRb4=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=cwkeMQPk2lQZv0XdWTUUAVq6alNLV0UtMgMRpafcXogGy1q5OOHJW9EBslaXEErUe2rmqpSfEia99tALgbMJ7WMbaz2u1uveuTxuC+yEWe0aWZ4JxOUG2hwgFefUmifiUuRwVTPq4MjZUUAhFjh/OMmUEnG42kxwzKRRqOHJlZ8= 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=oV+AsFhA; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=zpMF8uOl; 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="oV+AsFhA"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="zpMF8uOl" Message-ID: <20250313155916.858899502@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881659; 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=58zsQ9UX99bgd9bgWnnVYlqUIZPx3Nt2FsMFZCwYlDQ=; b=oV+AsFhAkIKqvuYebhU78L8re/0CzIRRbizI0sdH1hlM1VjlKrqMDZ7Xik9Cx8sClakuw5 q6jZFQ9oMbbEAiqSQDwi2V6e9ouN0gpMLLYxjhr0i3mfMqHe9MAiL3JiGWDpKK1L8I7znp ojbFa/Wo1M2L+9l/iR6/SRJoXqY0PPwYBVm2FDAzrUkftU9M0KkncumiVYx+iPTcEOs+0c lqGYdpOTlONtEiZG3ZTBGQa/Js+rDLtcDdHUauM1BJeq4voj5yzP2cKfzt88kpGQRZC2R7 3FIq/aIOsnmlSYnwAe/WclDprt8qQwMlmB7B1kLpOP6kZV8Zh1Qc12ms6UojfQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881659; 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=58zsQ9UX99bgd9bgWnnVYlqUIZPx3Nt2FsMFZCwYlDQ=; b=zpMF8uOlchygSRiefK8E2PwAh0IhXOxVClASxQlxgMeZAgF+cjTPMKmPZOSDMggi+8wXOq yCSwiq8mntAJ0cAA== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 44/46] genirq/manage: Rework irq_get_irqchip_state() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:00:58 +0100 (CET) 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 --- 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:30:10 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 94CB727128E for ; Thu, 13 Mar 2025 16:01:02 +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=1741881664; cv=none; b=DcvpxnpRXQWt4Gm0OVjV2vpeCO0l+THm7Qx3Df8rbn/fhi891RCD4nhCH2U1Q1QE1elh0U8URpBWlpBEN1B4l9vOePuPqBzU8wM8QiN+DPdD9iJRtwrEsUC2cQZgUr5Y7E5V/p6VyTYsoOcyst52TcVySeEM4GxBBKqREpaTRPM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881664; c=relaxed/simple; bh=q158st3AWDgD/QhYClYB6SP10BGBl5wM2Bb+FoyFB2M=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=etYxjbi5bR/cF2QniaIXIVNdOzEKWiNxQFt8t88eOIppvoliXPDLdCE2ibSVkJn5+0Inf/pGRg8t87pbh5e9Jnd/B5QvyJSHkHqpNBkr2t7GjMjw4bnY5TKLYFKCy26CwMSigvRpwz5YDjjK7cRwAdOSCbQRuftZwmuwH/3FTqs= 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=zx8Dqiqc; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=VWv9qeBV; 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="zx8Dqiqc"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="VWv9qeBV" Message-ID: <20250313155916.925818202@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881661; 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=KBXZnQRPuFL7uTOxRhZqNx5wL5xMvufibFWX03o4FLk=; b=zx8DqiqcioO1e+18H7tT+/zTCbVC+MS63q1K8aXl8EZLYTYZvPAQC7TvRV1aO/dPm3lhmT KwXnxwAgQZ/VzcUvlfgBh2eguSG3/7T8tUnXZ8oG8zLo8G8L9DMltSe4TOsArCmnF9MYUC 8SXENnJcv4/DT6aXLacwY0M7Df5H5rlw/EXJ/Wpcfy386lV4onIRumub76ZV8IWiNbtGwL GnSX1NF2XZvvd6EzfzWhRJpQRIHpKMOCvmMI7q01DdO9jjCKwb6gIAIu3D62FasH096woy H1H+bR5/lhKrcvL7nvjt9pGCtD2KkQvzXjsjL/PEb2Ne43xI43LlhEMvf9Gp1g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881661; 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=KBXZnQRPuFL7uTOxRhZqNx5wL5xMvufibFWX03o4FLk=; b=VWv9qeBV7+ZQWqfKjeviaIgDGw+RTJzyKJssbrOKVcb2Rifg9vMWjo87uratpZrL5/w3E/ DLNZtKVgXpAMV9Bg== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 45/46] genirq/manage: Rework irq_set_irqchip_state() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:01:00 +0100 (CET) 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 --- 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:30:10 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 478D127291F for ; Thu, 13 Mar 2025 16:01: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=1741881665; cv=none; b=H3Fs033VuQVU4hyHvklwtiUKk1UamQXMSLDb9kM7HFF+eXNiYfwudep4rtg99qQYAvHsfJ1tW/DwHkqBYRsRT6j03iyrSRUOj2j9BHqH7gvt2Bze7RUcvgivxM7C0G7YNLhlu0DnwNpi4JxBGYyPXUXUEyJTYZArMd5ae3S98I0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741881665; c=relaxed/simple; bh=vMJNu4J7oiDUUh1E1vi9V+qoJCogfOGMeNQQ4+j8VoM=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=FATsm8ROqxTD3ZuBuDr4QUU/Hq0SW/vDVxC8xo3paRGeGyKZAPb0RI31pr4+NbB2dbv2is6nuxo9JYtWKmNvfHXr9v7+4skoCzbmEjpQ/oT4yBtqJhh0ILmI8UEGvo9VVpvi0E2pcFEpA0hSvp8Px3HpVmT7JIQnI6NeDmX93Hs= 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=QcAbpmtl; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=NItHWSAy; 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="QcAbpmtl"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NItHWSAy" Message-ID: <20250313155916.993446362@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741881662; 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=t3I5KX7KDZZiUjgYflehk310ztwRwVsgtSnc9ulIycc=; b=QcAbpmtlHObnqUn7AKD36q2arhr/uxkUt5lpRXGE1ZvXw4wgnK3aV6fsRFH5RiiO5hwajs QWZPIRci5V6CX9zXVTIXm0TSt1X0acDFZS6SOWWP//1RCpnMep45cOjW7Ula41TJUNQfgW +pzblArLytDnyGv+6sAzM5j5kKIH48TG91keJ4ZyWCshbMb/u/vg1sznEKIXOvdK9UkLNt 2Gx489HaILxBii7c47h828cFe04NdgfnwIyK7Omrj4wlIGgv6J1f/rizITU+6MobU0CGRF s5meHztECTX6axLv9X0G6ZrsuddEglX/xEzMUqsIkJPNecRPdYGu4ho02/1j1g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741881662; 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=t3I5KX7KDZZiUjgYflehk310ztwRwVsgtSnc9ulIycc=; b=NItHWSAyqBLRE5L0pTEMTE+svgCh2ArNfeJlVf0lYVlTdIK/tWOUUyAPwcHHIV8jftDzrB 35gDUVVB8nrkEGAQ== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Jiri Slaby Subject: [patch 46/46] genirq: Remove irq_[get|put]_desc*() References: <20250313154615.860723120@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Mar 2025 17:01:02 +0100 (CET) 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 --- kernel/irq/internals.h | 24 ------------------------ 1 file changed, 24 deletions(-) --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h @@ -200,30 +200,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)