lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-f0cb32207307e9d7b3ee8117078b7a37f8d0166e@git.kernel.org>
Date:	Tue, 8 Dec 2015 03:57:51 -0800
From:	tip-bot for Thomas Petazzoni <tipbot@...or.com>
To:	linux-tip-commits@...r.kernel.org
Cc:	sebastian.hesselbarth@...il.com, andrew@...n.ch,
	tawfik@...vell.com, thomas.petazzoni@...e-electrons.com,
	hpa@...or.com, gregory.clement@...e-electrons.com,
	marc.zyngier@....com, jason@...edaemon.net, tglx@...utronix.de,
	linux-kernel@...r.kernel.org, nadavh@...vell.com,
	alior@...vell.com, mingo@...nel.org
Subject: [tip:irq/core] genirq: Implement irq_percpu_is_enabled()

Commit-ID:  f0cb32207307e9d7b3ee8117078b7a37f8d0166e
Gitweb:     http://git.kernel.org/tip/f0cb32207307e9d7b3ee8117078b7a37f8d0166e
Author:     Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>
AuthorDate: Tue, 20 Oct 2015 15:23:51 +0200
Committer:  Thomas Gleixner <tglx@...utronix.de>
CommitDate: Tue, 8 Dec 2015 12:53:29 +0100

genirq: Implement irq_percpu_is_enabled()

Certain interrupt controller drivers have a register set that does not
make it easy to save/restore the mask of enabled/disabled interrupts
at suspend/resume time. At resume time, such drivers rely on the core
kernel irq subsystem to tell whether such or such interrupt is enabled
or not, in order to restore the proper state in the interrupt
controller register.

While the irqd_irq_disabled() provides the relevant information for
global interrupts, there is no similar function to query the
enabled/disabled state of a per-CPU interrupt.

Therefore, this commit complements the percpu_irq API with an
irq_percpu_is_enabled() function.

[ tglx: Simplified the implementation and added kerneldoc ]

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>
Cc: linux-arm-kernel@...ts.infradead.org
Cc: Tawfik Bayouk <tawfik@...vell.com>
Cc: Nadav Haklai <nadavh@...vell.com>
Cc: Lior Amsalem <alior@...vell.com>
Cc: Andrew Lunn <andrew@...n.ch>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@...il.com>
Cc: Gregory Clement <gregory.clement@...e-electrons.com>
Cc: Jason Cooper <jason@...edaemon.net>
Cc: Marc Zyngier <marc.zyngier@....com>
Link: http://lkml.kernel.org/r/1445347435-2333-2-git-send-email-thomas.petazzoni@free-electrons.com
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
---
 include/linux/interrupt.h |  1 +
 kernel/irq/manage.c       | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index ad16809..cb30edb 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -195,6 +195,7 @@ extern void disable_irq(unsigned int irq);
 extern void disable_percpu_irq(unsigned int irq);
 extern void enable_irq(unsigned int irq);
 extern void enable_percpu_irq(unsigned int irq, unsigned int type);
+extern bool irq_percpu_is_enabled(unsigned int irq);
 extern void irq_wake_thread(unsigned int irq, void *dev_id);
 
 /* The following three functions are for the core kernel use only. */
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 0eebaee..c84670c 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -1743,6 +1743,31 @@ out:
 }
 EXPORT_SYMBOL_GPL(enable_percpu_irq);
 
+/**
+ * irq_percpu_is_enabled - Check whether the per cpu irq is enabled
+ * @irq:	Linux irq number to check for
+ *
+ * Must be called from a non migratable context. Returns the enable
+ * state of a per cpu interrupt on the current cpu.
+ */
+bool irq_percpu_is_enabled(unsigned int irq)
+{
+	unsigned int cpu = smp_processor_id();
+	struct irq_desc *desc;
+	unsigned long flags;
+	bool is_enabled;
+
+	desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_PERCPU);
+	if (!desc)
+		return false;
+
+	is_enabled = cpumask_test_cpu(cpu, desc->percpu_enabled);
+	irq_put_desc_unlock(desc, flags);
+
+	return is_enabled;
+}
+EXPORT_SYMBOL_GPL(irq_percpu_is_enabled);
+
 void disable_percpu_irq(unsigned int irq)
 {
 	unsigned int cpu = smp_processor_id();
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ