License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 14:07:57 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-16 22:20:36 +00:00
|
|
|
/* interrupt.h */
|
|
|
|
#ifndef _LINUX_INTERRUPT_H
|
|
|
|
#define _LINUX_INTERRUPT_H
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
#include <linux/cpumask.h>
|
2006-06-23 09:06:00 +00:00
|
|
|
#include <linux/irqreturn.h>
|
2008-10-16 16:20:58 +00:00
|
|
|
#include <linux/irqnr.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/hardirq.h>
|
2006-07-03 07:24:42 +00:00
|
|
|
#include <linux/irqflags.h>
|
2009-07-22 12:18:35 +00:00
|
|
|
#include <linux/hrtimer.h>
|
2011-01-19 21:01:44 +00:00
|
|
|
#include <linux/kref.h>
|
|
|
|
#include <linux/workqueue.h>
|
2008-12-12 10:26:39 +00:00
|
|
|
|
2011-07-26 23:09:06 +00:00
|
|
|
#include <linux/atomic.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/ptrace.h>
|
2013-09-05 13:49:45 +00:00
|
|
|
#include <asm/irq.h>
|
2017-08-03 02:38:21 +00:00
|
|
|
#include <asm/sections.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-07-02 02:29:03 +00:00
|
|
|
/*
|
|
|
|
* These correspond to the IORESOURCE_IRQ_* defines in
|
|
|
|
* linux/ioport.h to select the interrupt line behaviour. When
|
|
|
|
* requesting an interrupt without specifying a IRQF_TRIGGER, the
|
|
|
|
* setting should be assumed to be "as already configured", which
|
|
|
|
* may be as per machine or firmware initialisation.
|
|
|
|
*/
|
|
|
|
#define IRQF_TRIGGER_NONE 0x00000000
|
|
|
|
#define IRQF_TRIGGER_RISING 0x00000001
|
|
|
|
#define IRQF_TRIGGER_FALLING 0x00000002
|
|
|
|
#define IRQF_TRIGGER_HIGH 0x00000004
|
|
|
|
#define IRQF_TRIGGER_LOW 0x00000008
|
|
|
|
#define IRQF_TRIGGER_MASK (IRQF_TRIGGER_HIGH | IRQF_TRIGGER_LOW | \
|
|
|
|
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)
|
|
|
|
#define IRQF_TRIGGER_PROBE 0x00000010
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These flags used only by the kernel as part of the
|
|
|
|
* irq handling routines.
|
|
|
|
*
|
|
|
|
* IRQF_SHARED - allow sharing the irq among several devices
|
|
|
|
* IRQF_PROBE_SHARED - set by callers when they expect sharing mismatches to occur
|
|
|
|
* IRQF_TIMER - Flag to mark this interrupt as timer interrupt
|
2007-02-16 09:27:24 +00:00
|
|
|
* IRQF_PERCPU - Interrupt is per cpu
|
|
|
|
* IRQF_NOBALANCING - Flag to exclude this interrupt from irq balancing
|
2007-05-08 07:35:24 +00:00
|
|
|
* IRQF_IRQPOLL - Interrupt is used for polling (only the interrupt that is
|
2018-10-08 11:17:26 +00:00
|
|
|
* registered first in a shared interrupt is considered for
|
2007-05-08 07:35:24 +00:00
|
|
|
* performance reasons)
|
2009-08-13 10:17:22 +00:00
|
|
|
* IRQF_ONESHOT - Interrupt is not reenabled after the hardirq handler finished.
|
|
|
|
* Used by threaded interrupts which need to keep the
|
|
|
|
* irq line disabled until the threaded handler has been run.
|
2015-02-20 14:53:46 +00:00
|
|
|
* IRQF_NO_SUSPEND - Do not disable this IRQ during suspend. Does not guarantee
|
|
|
|
* that this interrupt will wake the system from a suspended
|
2019-06-13 10:10:36 +00:00
|
|
|
* state. See Documentation/power/suspend-and-interrupts.rst
|
2011-02-04 12:19:20 +00:00
|
|
|
* IRQF_FORCE_RESUME - Force enable it on resume even if IRQF_NO_SUSPEND is set
|
2011-02-23 23:52:18 +00:00
|
|
|
* IRQF_NO_THREAD - Interrupt cannot be threaded
|
2011-10-03 14:37:00 +00:00
|
|
|
* IRQF_EARLY_RESUME - Resume IRQ early during syscore instead of at device
|
|
|
|
* resume time.
|
genirq / PM: Add flag for shared NO_SUSPEND interrupt lines
It currently is required that all users of NO_SUSPEND interrupt
lines pass the IRQF_NO_SUSPEND flag when requesting the IRQ or the
WARN_ON_ONCE() in irq_pm_install_action() will trigger. That is
done to warn about situations in which unprepared interrupt handlers
may be run unnecessarily for suspended devices and may attempt to
access those devices by mistake. However, it may cause drivers
that have no technical reasons for using IRQF_NO_SUSPEND to set
that flag just because they happen to share the interrupt line
with something like a timer.
Moreover, the generic handling of wakeup interrupts introduced by
commit 9ce7a25849e8 (genirq: Simplify wakeup mechanism) only works
for IRQs without any NO_SUSPEND users, so the drivers of wakeup
devices needing to use shared NO_SUSPEND interrupt lines for
signaling system wakeup generally have to detect wakeup in their
interrupt handlers. Thus if they happen to share an interrupt line
with a NO_SUSPEND user, they also need to request that their
interrupt handlers be run after suspend_device_irqs().
In both cases the reason for using IRQF_NO_SUSPEND is not because
the driver in question has a genuine need to run its interrupt
handler after suspend_device_irqs(), but because it happens to
share the line with some other NO_SUSPEND user. Otherwise, the
driver would do without IRQF_NO_SUSPEND just fine.
To make it possible to specify that condition explicitly, introduce
a new IRQ action handler flag for shared IRQs, IRQF_COND_SUSPEND,
that, when set, will indicate to the IRQ core that the interrupt
user is generally fine with suspending the IRQ, but it also can
tolerate handler invocations after suspend_device_irqs() and, in
particular, it is capable of detecting system wakeup and triggering
it as appropriate from its interrupt handler.
That will allow us to work around a problem with a shared timer
interrupt line on at91 platforms.
Link: http://marc.info/?l=linux-kernel&m=142252777602084&w=2
Link: http://marc.info/?t=142252775300011&r=1&w=2
Link: https://lkml.org/lkml/2014/12/15/552
Reported-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
2015-02-26 23:07:55 +00:00
|
|
|
* IRQF_COND_SUSPEND - If the IRQ is shared with a NO_SUSPEND user, execute this
|
|
|
|
* interrupt handler after suspending interrupts. For system
|
|
|
|
* wakeup devices users need to implement wakeup detection in
|
|
|
|
* their interrupt handlers.
|
2006-07-02 02:29:03 +00:00
|
|
|
*/
|
|
|
|
#define IRQF_SHARED 0x00000080
|
|
|
|
#define IRQF_PROBE_SHARED 0x00000100
|
2010-07-29 10:16:32 +00:00
|
|
|
#define __IRQF_TIMER 0x00000200
|
2006-07-03 00:20:32 +00:00
|
|
|
#define IRQF_PERCPU 0x00000400
|
2007-02-16 09:27:24 +00:00
|
|
|
#define IRQF_NOBALANCING 0x00000800
|
2007-05-08 07:35:24 +00:00
|
|
|
#define IRQF_IRQPOLL 0x00001000
|
2009-08-13 10:17:22 +00:00
|
|
|
#define IRQF_ONESHOT 0x00002000
|
2010-07-29 10:16:32 +00:00
|
|
|
#define IRQF_NO_SUSPEND 0x00004000
|
2011-02-04 12:19:20 +00:00
|
|
|
#define IRQF_FORCE_RESUME 0x00008000
|
2011-02-23 23:52:18 +00:00
|
|
|
#define IRQF_NO_THREAD 0x00010000
|
2011-10-03 14:37:00 +00:00
|
|
|
#define IRQF_EARLY_RESUME 0x00020000
|
genirq / PM: Add flag for shared NO_SUSPEND interrupt lines
It currently is required that all users of NO_SUSPEND interrupt
lines pass the IRQF_NO_SUSPEND flag when requesting the IRQ or the
WARN_ON_ONCE() in irq_pm_install_action() will trigger. That is
done to warn about situations in which unprepared interrupt handlers
may be run unnecessarily for suspended devices and may attempt to
access those devices by mistake. However, it may cause drivers
that have no technical reasons for using IRQF_NO_SUSPEND to set
that flag just because they happen to share the interrupt line
with something like a timer.
Moreover, the generic handling of wakeup interrupts introduced by
commit 9ce7a25849e8 (genirq: Simplify wakeup mechanism) only works
for IRQs without any NO_SUSPEND users, so the drivers of wakeup
devices needing to use shared NO_SUSPEND interrupt lines for
signaling system wakeup generally have to detect wakeup in their
interrupt handlers. Thus if they happen to share an interrupt line
with a NO_SUSPEND user, they also need to request that their
interrupt handlers be run after suspend_device_irqs().
In both cases the reason for using IRQF_NO_SUSPEND is not because
the driver in question has a genuine need to run its interrupt
handler after suspend_device_irqs(), but because it happens to
share the line with some other NO_SUSPEND user. Otherwise, the
driver would do without IRQF_NO_SUSPEND just fine.
To make it possible to specify that condition explicitly, introduce
a new IRQ action handler flag for shared IRQs, IRQF_COND_SUSPEND,
that, when set, will indicate to the IRQ core that the interrupt
user is generally fine with suspending the IRQ, but it also can
tolerate handler invocations after suspend_device_irqs() and, in
particular, it is capable of detecting system wakeup and triggering
it as appropriate from its interrupt handler.
That will allow us to work around a problem with a shared timer
interrupt line on at91 platforms.
Link: http://marc.info/?l=linux-kernel&m=142252777602084&w=2
Link: http://marc.info/?t=142252775300011&r=1&w=2
Link: https://lkml.org/lkml/2014/12/15/552
Reported-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
2015-02-26 23:07:55 +00:00
|
|
|
#define IRQF_COND_SUSPEND 0x00040000
|
2010-07-29 10:16:32 +00:00
|
|
|
|
2011-02-23 23:52:18 +00:00
|
|
|
#define IRQF_TIMER (__IRQF_TIMER | IRQF_NO_SUSPEND | IRQF_NO_THREAD)
|
2009-03-23 17:28:15 +00:00
|
|
|
|
2010-05-21 16:03:01 +00:00
|
|
|
/*
|
genirq: Introduce request_any_context_irq()
Now that we enjoy threaded interrupts, we're starting to see irq_chip
implementations (wm831x, pca953x) that make use of threaded interrupts
for the controller, and nested interrupts for the client interrupt. It
all works very well, with one drawback:
Drivers requesting an IRQ must now know whether the handler will
run in a thread context or not, and call request_threaded_irq() or
request_irq() accordingly.
The problem is that the requesting driver sometimes doesn't know
about the nature of the interrupt, specially when the interrupt
controller is a discrete chip (typically a GPIO expander connected
over I2C) that can be connected to a wide variety of otherwise perfectly
supported hardware.
This patch introduces the request_any_context_irq() function that mostly
mimics the usual request_irq(), except that it checks whether the irq
level is configured as nested or not, and calls the right backend.
On success, it also returns either IRQC_IS_HARDIRQ or IRQC_IS_NESTED.
[ tglx: Made return value an enum, simplified code and made the export
of request_any_context_irq GPL ]
Signed-off-by: Marc Zyngier <maz@misterjones.org>
Cc: <joachim.eastwood@jotron.com>
LKML-Reference: <927ea285bd0c68934ddae1a47e44a9ba@localhost>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2010-03-15 22:56:33 +00:00
|
|
|
* These values can be returned by request_any_context_irq() and
|
|
|
|
* describe the context the interrupt will be run in.
|
|
|
|
*
|
|
|
|
* IRQC_IS_HARDIRQ - interrupt runs in hardirq context
|
|
|
|
* IRQC_IS_NESTED - interrupt runs in a nested threaded context
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
IRQC_IS_HARDIRQ = 0,
|
|
|
|
IRQC_IS_NESTED,
|
|
|
|
};
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
typedef irqreturn_t (*irq_handler_t)(int, void *);
|
2006-10-05 12:06:34 +00:00
|
|
|
|
2009-03-03 15:58:16 +00:00
|
|
|
/**
|
|
|
|
* struct irqaction - per interrupt action descriptor
|
|
|
|
* @handler: interrupt handler function
|
|
|
|
* @name: name of the device
|
|
|
|
* @dev_id: cookie to identify the device
|
genirq: Add support for per-cpu dev_id interrupts
The ARM GIC interrupt controller offers per CPU interrupts (PPIs),
which are usually used to connect local timers to each core. Each CPU
has its own private interface to the GIC, and only sees the PPIs that
are directly connect to it.
While these timers are separate devices and have a separate interrupt
line to a core, they all use the same IRQ number.
For these devices, request_irq() is not the right API as it assumes
that an IRQ number is visible by a number of CPUs (through the
affinity setting), but makes it very awkward to express that an IRQ
number can be handled by all CPUs, and yet be a different interrupt
line on each CPU, requiring a different dev_id cookie to be passed
back to the handler.
The *_percpu_irq() functions is designed to overcome these
limitations, by providing a per-cpu dev_id vector:
int request_percpu_irq(unsigned int irq, irq_handler_t handler,
const char *devname, void __percpu *percpu_dev_id);
void free_percpu_irq(unsigned int, void __percpu *);
int setup_percpu_irq(unsigned int irq, struct irqaction *new);
void remove_percpu_irq(unsigned int irq, struct irqaction *act);
void enable_percpu_irq(unsigned int irq);
void disable_percpu_irq(unsigned int irq);
The API has a number of limitations:
- no interrupt sharing
- no threading
- common handler across all the CPUs
Once the interrupt is requested using setup_percpu_irq() or
request_percpu_irq(), it must be enabled by each core that wishes its
local interrupt to be delivered.
Based on an initial patch by Thomas Gleixner.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/1316793788-14500-2-git-send-email-marc.zyngier@arm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2011-09-23 16:03:06 +00:00
|
|
|
* @percpu_dev_id: cookie to identify the device
|
2009-03-03 15:58:16 +00:00
|
|
|
* @next: pointer to the next irqaction for shared interrupts
|
|
|
|
* @irq: interrupt number
|
2012-04-19 09:53:25 +00:00
|
|
|
* @flags: flags (see IRQF_* above)
|
2011-03-31 01:57:33 +00:00
|
|
|
* @thread_fn: interrupt handler function for threaded interrupts
|
2009-03-23 17:28:15 +00:00
|
|
|
* @thread: thread pointer for threaded interrupts
|
2015-09-21 09:01:10 +00:00
|
|
|
* @secondary: pointer to secondary irqaction (force threading)
|
2009-03-23 17:28:15 +00:00
|
|
|
* @thread_flags: flags related to @thread
|
2011-02-23 23:52:13 +00:00
|
|
|
* @thread_mask: bitmask for keeping track of @thread activity
|
2012-04-19 09:53:25 +00:00
|
|
|
* @dir: pointer to the proc/irq/NN/name entry
|
2009-03-03 15:58:16 +00:00
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
struct irqaction {
|
genirq: Add support for per-cpu dev_id interrupts
The ARM GIC interrupt controller offers per CPU interrupts (PPIs),
which are usually used to connect local timers to each core. Each CPU
has its own private interface to the GIC, and only sees the PPIs that
are directly connect to it.
While these timers are separate devices and have a separate interrupt
line to a core, they all use the same IRQ number.
For these devices, request_irq() is not the right API as it assumes
that an IRQ number is visible by a number of CPUs (through the
affinity setting), but makes it very awkward to express that an IRQ
number can be handled by all CPUs, and yet be a different interrupt
line on each CPU, requiring a different dev_id cookie to be passed
back to the handler.
The *_percpu_irq() functions is designed to overcome these
limitations, by providing a per-cpu dev_id vector:
int request_percpu_irq(unsigned int irq, irq_handler_t handler,
const char *devname, void __percpu *percpu_dev_id);
void free_percpu_irq(unsigned int, void __percpu *);
int setup_percpu_irq(unsigned int irq, struct irqaction *new);
void remove_percpu_irq(unsigned int irq, struct irqaction *act);
void enable_percpu_irq(unsigned int irq);
void disable_percpu_irq(unsigned int irq);
The API has a number of limitations:
- no interrupt sharing
- no threading
- common handler across all the CPUs
Once the interrupt is requested using setup_percpu_irq() or
request_percpu_irq(), it must be enabled by each core that wishes its
local interrupt to be delivered.
Based on an initial patch by Thomas Gleixner.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/1316793788-14500-2-git-send-email-marc.zyngier@arm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2011-09-23 16:03:06 +00:00
|
|
|
irq_handler_t handler;
|
|
|
|
void *dev_id;
|
|
|
|
void __percpu *percpu_dev_id;
|
|
|
|
struct irqaction *next;
|
|
|
|
irq_handler_t thread_fn;
|
|
|
|
struct task_struct *thread;
|
2015-09-21 09:01:10 +00:00
|
|
|
struct irqaction *secondary;
|
2012-04-19 09:53:25 +00:00
|
|
|
unsigned int irq;
|
|
|
|
unsigned int flags;
|
genirq: Add support for per-cpu dev_id interrupts
The ARM GIC interrupt controller offers per CPU interrupts (PPIs),
which are usually used to connect local timers to each core. Each CPU
has its own private interface to the GIC, and only sees the PPIs that
are directly connect to it.
While these timers are separate devices and have a separate interrupt
line to a core, they all use the same IRQ number.
For these devices, request_irq() is not the right API as it assumes
that an IRQ number is visible by a number of CPUs (through the
affinity setting), but makes it very awkward to express that an IRQ
number can be handled by all CPUs, and yet be a different interrupt
line on each CPU, requiring a different dev_id cookie to be passed
back to the handler.
The *_percpu_irq() functions is designed to overcome these
limitations, by providing a per-cpu dev_id vector:
int request_percpu_irq(unsigned int irq, irq_handler_t handler,
const char *devname, void __percpu *percpu_dev_id);
void free_percpu_irq(unsigned int, void __percpu *);
int setup_percpu_irq(unsigned int irq, struct irqaction *new);
void remove_percpu_irq(unsigned int irq, struct irqaction *act);
void enable_percpu_irq(unsigned int irq);
void disable_percpu_irq(unsigned int irq);
The API has a number of limitations:
- no interrupt sharing
- no threading
- common handler across all the CPUs
Once the interrupt is requested using setup_percpu_irq() or
request_percpu_irq(), it must be enabled by each core that wishes its
local interrupt to be delivered.
Based on an initial patch by Thomas Gleixner.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/1316793788-14500-2-git-send-email-marc.zyngier@arm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2011-09-23 16:03:06 +00:00
|
|
|
unsigned long thread_flags;
|
|
|
|
unsigned long thread_mask;
|
|
|
|
const char *name;
|
|
|
|
struct proc_dir_entry *dir;
|
2010-11-04 10:13:48 +00:00
|
|
|
} ____cacheline_internodealigned_in_smp;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
extern irqreturn_t no_action(int cpl, void *dev_id);
|
2009-03-23 17:28:15 +00:00
|
|
|
|
x86/ACPI/PCI: Recognize that Interrupt Line 255 means "not connected"
Per the x86-specific footnote to PCI spec r3.0, sec 6.2.4, the value 255 in
the Interrupt Line register means "unknown" or "no connection."
Previously, when we couldn't derive an IRQ from the _PRT, we fell back to
using the value from Interrupt Line as an IRQ. It's questionable whether
we should do that at all, but the spec clearly suggests we shouldn't do it
for the value 255 on x86.
Calling request_irq() with IRQ 255 may succeed, but the driver won't
receive any interrupts. Or, if IRQ 255 is shared with another device, it
may succeed, and the driver's ISR will be called at random times when the
*other* device interrupts. Or it may fail if another device is using IRQ
255 with incompatible flags. What we *want* is for request_irq() to fail
predictably so the driver can fall back to polling.
On x86, assume 255 in the Interrupt Line means the INTx line is not
connected. In that case, set dev->irq to IRQ_NOTCONNECTED so request_irq()
will fail gracefully with -ENOTCONN.
We found this problem on a system where Secure Boot firmware assigned
Interrupt Line 255 to an i801_smbus device and another device was already
using MSI-X IRQ 255. This was in v3.10, where i801_probe() fails if
request_irq() fails:
i801_smbus 0000:00:1f.3: enabling device (0140 -> 0143)
i801_smbus 0000:00:1f.3: can't derive routing for PCI INT C
i801_smbus 0000:00:1f.3: PCI INT C: no GSI
genirq: Flags mismatch irq 255. 00000080 (i801_smbus) vs. 00000000 (megasa)
CPU: 0 PID: 2487 Comm: kworker/0:1 Not tainted 3.10.0-229.el7.x86_64 #1
Hardware name: FUJITSU PRIMEQUEST 2800E2/D3736, BIOS PRIMEQUEST 2000 Serie5
Call Trace:
dump_stack+0x19/0x1b
__setup_irq+0x54a/0x570
request_threaded_irq+0xcc/0x170
i801_probe+0x32f/0x508 [i2c_i801]
local_pci_probe+0x45/0xa0
i801_smbus 0000:00:1f.3: Failed to allocate irq 255: -16
i801_smbus: probe of 0000:00:1f.3 failed with error -16
After aeb8a3d16ae0 ("i2c: i801: Check if interrupts are disabled"),
i801_probe() will fall back to polling if request_irq() fails. But we
still need this patch because request_irq() may succeed or fail depending
on other devices in the system. If request_irq() fails, i801_smbus will
work by falling back to polling, but if it succeeds, i801_smbus won't work
because it expects interrupts that it may not receive.
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-02-15 04:52:01 +00:00
|
|
|
/*
|
|
|
|
* If a (PCI) device interrupt is not connected we set dev->irq to
|
|
|
|
* IRQ_NOTCONNECTED. This causes request_irq() to fail with -ENOTCONN, so we
|
|
|
|
* can distingiush that case from other error returns.
|
|
|
|
*
|
|
|
|
* 0x80000000 is guaranteed to be outside the available range of interrupts
|
|
|
|
* and easy to distinguish from other possible incorrect values.
|
|
|
|
*/
|
|
|
|
#define IRQ_NOTCONNECTED (1U << 31)
|
|
|
|
|
2009-03-23 17:28:15 +00:00
|
|
|
extern int __must_check
|
|
|
|
request_threaded_irq(unsigned int irq, irq_handler_t handler,
|
|
|
|
irq_handler_t thread_fn,
|
|
|
|
unsigned long flags, const char *name, void *dev);
|
|
|
|
|
2019-10-04 16:39:55 +00:00
|
|
|
/**
|
|
|
|
* request_irq - Add a handler for an interrupt line
|
|
|
|
* @irq: The interrupt line to allocate
|
|
|
|
* @handler: Function to be called when the IRQ occurs.
|
|
|
|
* Primary handler for threaded interrupts
|
|
|
|
* If NULL, the default primary handler is installed
|
|
|
|
* @flags: Handling flags
|
|
|
|
* @name: Name of the device generating this interrupt
|
|
|
|
* @dev: A cookie passed to the handler function
|
|
|
|
*
|
|
|
|
* This call allocates an interrupt and establishes a handler; see
|
|
|
|
* the documentation for request_threaded_irq() for details.
|
|
|
|
*/
|
2009-03-23 17:28:15 +00:00
|
|
|
static inline int __must_check
|
|
|
|
request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
|
|
|
|
const char *name, void *dev)
|
|
|
|
{
|
|
|
|
return request_threaded_irq(irq, handler, NULL, flags, name, dev);
|
|
|
|
}
|
|
|
|
|
genirq: Introduce request_any_context_irq()
Now that we enjoy threaded interrupts, we're starting to see irq_chip
implementations (wm831x, pca953x) that make use of threaded interrupts
for the controller, and nested interrupts for the client interrupt. It
all works very well, with one drawback:
Drivers requesting an IRQ must now know whether the handler will
run in a thread context or not, and call request_threaded_irq() or
request_irq() accordingly.
The problem is that the requesting driver sometimes doesn't know
about the nature of the interrupt, specially when the interrupt
controller is a discrete chip (typically a GPIO expander connected
over I2C) that can be connected to a wide variety of otherwise perfectly
supported hardware.
This patch introduces the request_any_context_irq() function that mostly
mimics the usual request_irq(), except that it checks whether the irq
level is configured as nested or not, and calls the right backend.
On success, it also returns either IRQC_IS_HARDIRQ or IRQC_IS_NESTED.
[ tglx: Made return value an enum, simplified code and made the export
of request_any_context_irq GPL ]
Signed-off-by: Marc Zyngier <maz@misterjones.org>
Cc: <joachim.eastwood@jotron.com>
LKML-Reference: <927ea285bd0c68934ddae1a47e44a9ba@localhost>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2010-03-15 22:56:33 +00:00
|
|
|
extern int __must_check
|
|
|
|
request_any_context_irq(unsigned int irq, irq_handler_t handler,
|
|
|
|
unsigned long flags, const char *name, void *dev_id);
|
|
|
|
|
genirq: Add support for per-cpu dev_id interrupts
The ARM GIC interrupt controller offers per CPU interrupts (PPIs),
which are usually used to connect local timers to each core. Each CPU
has its own private interface to the GIC, and only sees the PPIs that
are directly connect to it.
While these timers are separate devices and have a separate interrupt
line to a core, they all use the same IRQ number.
For these devices, request_irq() is not the right API as it assumes
that an IRQ number is visible by a number of CPUs (through the
affinity setting), but makes it very awkward to express that an IRQ
number can be handled by all CPUs, and yet be a different interrupt
line on each CPU, requiring a different dev_id cookie to be passed
back to the handler.
The *_percpu_irq() functions is designed to overcome these
limitations, by providing a per-cpu dev_id vector:
int request_percpu_irq(unsigned int irq, irq_handler_t handler,
const char *devname, void __percpu *percpu_dev_id);
void free_percpu_irq(unsigned int, void __percpu *);
int setup_percpu_irq(unsigned int irq, struct irqaction *new);
void remove_percpu_irq(unsigned int irq, struct irqaction *act);
void enable_percpu_irq(unsigned int irq);
void disable_percpu_irq(unsigned int irq);
The API has a number of limitations:
- no interrupt sharing
- no threading
- common handler across all the CPUs
Once the interrupt is requested using setup_percpu_irq() or
request_percpu_irq(), it must be enabled by each core that wishes its
local interrupt to be delivered.
Based on an initial patch by Thomas Gleixner.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/1316793788-14500-2-git-send-email-marc.zyngier@arm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2011-09-23 16:03:06 +00:00
|
|
|
extern int __must_check
|
2017-07-06 12:29:04 +00:00
|
|
|
__request_percpu_irq(unsigned int irq, irq_handler_t handler,
|
|
|
|
unsigned long flags, const char *devname,
|
|
|
|
void __percpu *percpu_dev_id);
|
|
|
|
|
2019-01-31 14:53:58 +00:00
|
|
|
extern int __must_check
|
|
|
|
request_nmi(unsigned int irq, irq_handler_t handler, unsigned long flags,
|
|
|
|
const char *name, void *dev);
|
|
|
|
|
2017-07-06 12:29:04 +00:00
|
|
|
static inline int __must_check
|
genirq: Add support for per-cpu dev_id interrupts
The ARM GIC interrupt controller offers per CPU interrupts (PPIs),
which are usually used to connect local timers to each core. Each CPU
has its own private interface to the GIC, and only sees the PPIs that
are directly connect to it.
While these timers are separate devices and have a separate interrupt
line to a core, they all use the same IRQ number.
For these devices, request_irq() is not the right API as it assumes
that an IRQ number is visible by a number of CPUs (through the
affinity setting), but makes it very awkward to express that an IRQ
number can be handled by all CPUs, and yet be a different interrupt
line on each CPU, requiring a different dev_id cookie to be passed
back to the handler.
The *_percpu_irq() functions is designed to overcome these
limitations, by providing a per-cpu dev_id vector:
int request_percpu_irq(unsigned int irq, irq_handler_t handler,
const char *devname, void __percpu *percpu_dev_id);
void free_percpu_irq(unsigned int, void __percpu *);
int setup_percpu_irq(unsigned int irq, struct irqaction *new);
void remove_percpu_irq(unsigned int irq, struct irqaction *act);
void enable_percpu_irq(unsigned int irq);
void disable_percpu_irq(unsigned int irq);
The API has a number of limitations:
- no interrupt sharing
- no threading
- common handler across all the CPUs
Once the interrupt is requested using setup_percpu_irq() or
request_percpu_irq(), it must be enabled by each core that wishes its
local interrupt to be delivered.
Based on an initial patch by Thomas Gleixner.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/1316793788-14500-2-git-send-email-marc.zyngier@arm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2011-09-23 16:03:06 +00:00
|
|
|
request_percpu_irq(unsigned int irq, irq_handler_t handler,
|
2017-07-06 12:29:04 +00:00
|
|
|
const char *devname, void __percpu *percpu_dev_id)
|
|
|
|
{
|
|
|
|
return __request_percpu_irq(irq, handler, 0,
|
|
|
|
devname, percpu_dev_id);
|
|
|
|
}
|
2009-03-23 17:28:15 +00:00
|
|
|
|
2019-01-31 14:53:59 +00:00
|
|
|
extern int __must_check
|
|
|
|
request_percpu_nmi(unsigned int irq, irq_handler_t handler,
|
|
|
|
const char *devname, void __percpu *dev);
|
|
|
|
|
2017-04-13 07:06:41 +00:00
|
|
|
extern const void *free_irq(unsigned int, void *);
|
genirq: Add support for per-cpu dev_id interrupts
The ARM GIC interrupt controller offers per CPU interrupts (PPIs),
which are usually used to connect local timers to each core. Each CPU
has its own private interface to the GIC, and only sees the PPIs that
are directly connect to it.
While these timers are separate devices and have a separate interrupt
line to a core, they all use the same IRQ number.
For these devices, request_irq() is not the right API as it assumes
that an IRQ number is visible by a number of CPUs (through the
affinity setting), but makes it very awkward to express that an IRQ
number can be handled by all CPUs, and yet be a different interrupt
line on each CPU, requiring a different dev_id cookie to be passed
back to the handler.
The *_percpu_irq() functions is designed to overcome these
limitations, by providing a per-cpu dev_id vector:
int request_percpu_irq(unsigned int irq, irq_handler_t handler,
const char *devname, void __percpu *percpu_dev_id);
void free_percpu_irq(unsigned int, void __percpu *);
int setup_percpu_irq(unsigned int irq, struct irqaction *new);
void remove_percpu_irq(unsigned int irq, struct irqaction *act);
void enable_percpu_irq(unsigned int irq);
void disable_percpu_irq(unsigned int irq);
The API has a number of limitations:
- no interrupt sharing
- no threading
- common handler across all the CPUs
Once the interrupt is requested using setup_percpu_irq() or
request_percpu_irq(), it must be enabled by each core that wishes its
local interrupt to be delivered.
Based on an initial patch by Thomas Gleixner.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/1316793788-14500-2-git-send-email-marc.zyngier@arm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2011-09-23 16:03:06 +00:00
|
|
|
extern void free_percpu_irq(unsigned int, void __percpu *);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2019-01-31 14:53:58 +00:00
|
|
|
extern const void *free_nmi(unsigned int irq, void *dev_id);
|
2019-01-31 14:53:59 +00:00
|
|
|
extern void free_percpu_nmi(unsigned int irq, void __percpu *percpu_dev_id);
|
2019-01-31 14:53:58 +00:00
|
|
|
|
2007-07-27 13:24:33 +00:00
|
|
|
struct device;
|
|
|
|
|
2009-03-23 17:28:16 +00:00
|
|
|
extern int __must_check
|
|
|
|
devm_request_threaded_irq(struct device *dev, unsigned int irq,
|
|
|
|
irq_handler_t handler, irq_handler_t thread_fn,
|
|
|
|
unsigned long irqflags, const char *devname,
|
|
|
|
void *dev_id);
|
|
|
|
|
|
|
|
static inline int __must_check
|
|
|
|
devm_request_irq(struct device *dev, unsigned int irq, irq_handler_t handler,
|
|
|
|
unsigned long irqflags, const char *devname, void *dev_id)
|
|
|
|
{
|
|
|
|
return devm_request_threaded_irq(dev, irq, handler, NULL, irqflags,
|
|
|
|
devname, dev_id);
|
|
|
|
}
|
|
|
|
|
2014-01-03 00:37:32 +00:00
|
|
|
extern int __must_check
|
|
|
|
devm_request_any_context_irq(struct device *dev, unsigned int irq,
|
|
|
|
irq_handler_t handler, unsigned long irqflags,
|
|
|
|
const char *devname, void *dev_id);
|
|
|
|
|
devres: device resource management
Implement device resource management, in short, devres. A device
driver can allocate arbirary size of devres data which is associated
with a release function. On driver detach, release function is
invoked on the devres data, then, devres data is freed.
devreses are typed by associated release functions. Some devreses are
better represented by single instance of the type while others need
multiple instances sharing the same release function. Both usages are
supported.
devreses can be grouped using devres group such that a device driver
can easily release acquired resources halfway through initialization
or selectively release resources (e.g. resources for port 1 out of 4
ports).
This patch adds devres core including documentation and the following
managed interfaces.
* alloc/free : devm_kzalloc(), devm_kzfree()
* IO region : devm_request_region(), devm_release_region()
* IRQ : devm_request_irq(), devm_free_irq()
* DMA : dmam_alloc_coherent(), dmam_free_coherent(),
dmam_declare_coherent_memory(), dmam_pool_create(),
dmam_pool_destroy()
* PCI : pcim_enable_device(), pcim_pin_device(), pci_is_managed()
* iomap : devm_ioport_map(), devm_ioport_unmap(), devm_ioremap(),
devm_ioremap_nocache(), devm_iounmap(), pcim_iomap_table(),
pcim_iomap(), pcim_iounmap()
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-01-20 07:00:26 +00:00
|
|
|
extern void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id);
|
|
|
|
|
2006-07-03 07:24:27 +00:00
|
|
|
/*
|
|
|
|
* On lockdep we dont want to enable hardirqs in hardirq
|
|
|
|
* context. Use local_irq_enable_in_hardirq() to annotate
|
|
|
|
* kernel code that has to do this nevertheless (pretty much
|
|
|
|
* the only valid case is for old/broken hardware that is
|
|
|
|
* insanely slow).
|
|
|
|
*
|
|
|
|
* NOTE: in theory this might break fragile code that relies
|
|
|
|
* on hardirq delivery - in practice we dont seem to have such
|
|
|
|
* places left. So the only effect should be slightly increased
|
|
|
|
* irqs-off latencies.
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_LOCKDEP
|
|
|
|
# define local_irq_enable_in_hardirq() do { } while (0)
|
|
|
|
#else
|
|
|
|
# define local_irq_enable_in_hardirq() local_irq_enable()
|
|
|
|
#endif
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-12-10 19:25:37 +00:00
|
|
|
bool irq_has_action(unsigned int irq);
|
2005-04-16 22:20:36 +00:00
|
|
|
extern void disable_irq_nosync(unsigned int irq);
|
2015-02-05 13:06:23 +00:00
|
|
|
extern bool disable_hardirq(unsigned int irq);
|
2005-04-16 22:20:36 +00:00
|
|
|
extern void disable_irq(unsigned int irq);
|
genirq: Add support for per-cpu dev_id interrupts
The ARM GIC interrupt controller offers per CPU interrupts (PPIs),
which are usually used to connect local timers to each core. Each CPU
has its own private interface to the GIC, and only sees the PPIs that
are directly connect to it.
While these timers are separate devices and have a separate interrupt
line to a core, they all use the same IRQ number.
For these devices, request_irq() is not the right API as it assumes
that an IRQ number is visible by a number of CPUs (through the
affinity setting), but makes it very awkward to express that an IRQ
number can be handled by all CPUs, and yet be a different interrupt
line on each CPU, requiring a different dev_id cookie to be passed
back to the handler.
The *_percpu_irq() functions is designed to overcome these
limitations, by providing a per-cpu dev_id vector:
int request_percpu_irq(unsigned int irq, irq_handler_t handler,
const char *devname, void __percpu *percpu_dev_id);
void free_percpu_irq(unsigned int, void __percpu *);
int setup_percpu_irq(unsigned int irq, struct irqaction *new);
void remove_percpu_irq(unsigned int irq, struct irqaction *act);
void enable_percpu_irq(unsigned int irq);
void disable_percpu_irq(unsigned int irq);
The API has a number of limitations:
- no interrupt sharing
- no threading
- common handler across all the CPUs
Once the interrupt is requested using setup_percpu_irq() or
request_percpu_irq(), it must be enabled by each core that wishes its
local interrupt to be delivered.
Based on an initial patch by Thomas Gleixner.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/1316793788-14500-2-git-send-email-marc.zyngier@arm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2011-09-23 16:03:06 +00:00
|
|
|
extern void disable_percpu_irq(unsigned int irq);
|
2005-04-16 22:20:36 +00:00
|
|
|
extern void enable_irq(unsigned int irq);
|
2011-09-30 09:48:47 +00:00
|
|
|
extern void enable_percpu_irq(unsigned int irq, unsigned int type);
|
2015-10-20 13:23:51 +00:00
|
|
|
extern bool irq_percpu_is_enabled(unsigned int irq);
|
2014-02-15 00:55:19 +00:00
|
|
|
extern void irq_wake_thread(unsigned int irq, void *dev_id);
|
2006-06-29 09:24:55 +00:00
|
|
|
|
2019-01-31 14:53:58 +00:00
|
|
|
extern void disable_nmi_nosync(unsigned int irq);
|
2019-01-31 14:53:59 +00:00
|
|
|
extern void disable_percpu_nmi(unsigned int irq);
|
2019-01-31 14:53:58 +00:00
|
|
|
extern void enable_nmi(unsigned int irq);
|
2019-01-31 14:53:59 +00:00
|
|
|
extern void enable_percpu_nmi(unsigned int irq, unsigned int type);
|
|
|
|
extern int prepare_percpu_nmi(unsigned int irq);
|
|
|
|
extern void teardown_percpu_nmi(unsigned int irq);
|
2019-01-31 14:53:58 +00:00
|
|
|
|
2020-03-06 13:03:47 +00:00
|
|
|
extern int irq_inject_interrupt(unsigned int irq);
|
|
|
|
|
2009-03-16 21:33:49 +00:00
|
|
|
/* The following three functions are for the core kernel use only. */
|
|
|
|
extern void suspend_device_irqs(void);
|
|
|
|
extern void resume_device_irqs(void);
|
2019-07-15 11:03:20 +00:00
|
|
|
extern void rearm_wake_irq(unsigned int irq);
|
2009-03-16 21:33:49 +00:00
|
|
|
|
2014-05-20 14:57:00 +00:00
|
|
|
/**
|
|
|
|
* struct irq_affinity_notify - context for notification of IRQ affinity changes
|
|
|
|
* @irq: Interrupt to which notification applies
|
|
|
|
* @kref: Reference count, for internal use
|
|
|
|
* @work: Work item, for internal use
|
|
|
|
* @notify: Function to be called on change. This will be
|
|
|
|
* called in process context.
|
|
|
|
* @release: Function to be called on release. This will be
|
|
|
|
* called in process context. Once registered, the
|
|
|
|
* structure must only be freed when this function is
|
|
|
|
* called or later.
|
|
|
|
*/
|
|
|
|
struct irq_affinity_notify {
|
|
|
|
unsigned int irq;
|
|
|
|
struct kref kref;
|
|
|
|
struct work_struct work;
|
|
|
|
void (*notify)(struct irq_affinity_notify *, const cpumask_t *mask);
|
|
|
|
void (*release)(struct kref *ref);
|
|
|
|
};
|
|
|
|
|
genirq/affinity: Store interrupt sets size in struct irq_affinity
The interrupt affinity spreading mechanism supports to spread out
affinities for one or more interrupt sets. A interrupt set contains one
or more interrupts. Each set is mapped to a specific functionality of a
device, e.g. general I/O queues and read I/O queus of multiqueue block
devices.
The number of interrupts per set is defined by the driver. It depends on
the total number of available interrupts for the device, which is
determined by the PCI capabilites and the availability of underlying CPU
resources, and the number of queues which the device provides and the
driver wants to instantiate.
The driver passes initial configuration for the interrupt allocation via
a pointer to struct irq_affinity.
Right now the allocation mechanism is complex as it requires to have a
loop in the driver to determine the maximum number of interrupts which
are provided by the PCI capabilities and the underlying CPU resources.
This loop would have to be replicated in every driver which wants to
utilize this mechanism. That's unwanted code duplication and error
prone.
In order to move this into generic facilities it is required to have a
mechanism, which allows the recalculation of the interrupt sets and
their size, in the core code. As the core code does not have any
knowledge about the underlying device, a driver specific callback will
be added to struct affinity_desc, which will be invoked by the core
code. The callback will get the number of available interupts as an
argument, so the driver can calculate the corresponding number and size
of interrupt sets.
To support this, two modifications for the handling of struct irq_affinity
are required:
1) The (optional) interrupt sets size information is contained in a
separate array of integers and struct irq_affinity contains a
pointer to it.
This is cumbersome and as the maximum number of interrupt sets is small,
there is no reason to have separate storage. Moving the size array into
struct affinity_desc avoids indirections and makes the code simpler.
2) At the moment the struct irq_affinity pointer which is handed in from
the driver and passed through to several core functions is marked
'const'.
With the upcoming callback to recalculate the number and size of
interrupt sets, it's necessary to remove the 'const'
qualifier. Otherwise the callback would not be able to update the data.
Implement #1 and store the interrupt sets size in 'struct irq_affinity'.
No functional change.
[ tglx: Fixed the memcpy() size so it won't copy beyond the size of the
source. Fixed the kernel doc comments for struct irq_affinity and
de-'This patch'-ed the changelog ]
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Bjorn Helgaas <helgaas@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org
Cc: linux-pci@vger.kernel.org
Cc: Keith Busch <keith.busch@intel.com>
Cc: Sumit Saxena <sumit.saxena@broadcom.com>
Cc: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: Shivasharan Srikanteshwara <shivasharan.srikanteshwara@broadcom.com>
Link: https://lkml.kernel.org/r/20190216172228.423723127@linutronix.de
2019-02-16 17:13:08 +00:00
|
|
|
#define IRQ_AFFINITY_MAX_SETS 4
|
|
|
|
|
2016-11-09 01:15:01 +00:00
|
|
|
/**
|
|
|
|
* struct irq_affinity - Description for automatic irq affinity assignements
|
|
|
|
* @pre_vectors: Don't apply affinity to @pre_vectors at beginning of
|
|
|
|
* the MSI(-X) vector space
|
|
|
|
* @post_vectors: Don't apply affinity to @post_vectors at end of
|
|
|
|
* the MSI(-X) vector space
|
genirq/affinity: Store interrupt sets size in struct irq_affinity
The interrupt affinity spreading mechanism supports to spread out
affinities for one or more interrupt sets. A interrupt set contains one
or more interrupts. Each set is mapped to a specific functionality of a
device, e.g. general I/O queues and read I/O queus of multiqueue block
devices.
The number of interrupts per set is defined by the driver. It depends on
the total number of available interrupts for the device, which is
determined by the PCI capabilites and the availability of underlying CPU
resources, and the number of queues which the device provides and the
driver wants to instantiate.
The driver passes initial configuration for the interrupt allocation via
a pointer to struct irq_affinity.
Right now the allocation mechanism is complex as it requires to have a
loop in the driver to determine the maximum number of interrupts which
are provided by the PCI capabilities and the underlying CPU resources.
This loop would have to be replicated in every driver which wants to
utilize this mechanism. That's unwanted code duplication and error
prone.
In order to move this into generic facilities it is required to have a
mechanism, which allows the recalculation of the interrupt sets and
their size, in the core code. As the core code does not have any
knowledge about the underlying device, a driver specific callback will
be added to struct affinity_desc, which will be invoked by the core
code. The callback will get the number of available interupts as an
argument, so the driver can calculate the corresponding number and size
of interrupt sets.
To support this, two modifications for the handling of struct irq_affinity
are required:
1) The (optional) interrupt sets size information is contained in a
separate array of integers and struct irq_affinity contains a
pointer to it.
This is cumbersome and as the maximum number of interrupt sets is small,
there is no reason to have separate storage. Moving the size array into
struct affinity_desc avoids indirections and makes the code simpler.
2) At the moment the struct irq_affinity pointer which is handed in from
the driver and passed through to several core functions is marked
'const'.
With the upcoming callback to recalculate the number and size of
interrupt sets, it's necessary to remove the 'const'
qualifier. Otherwise the callback would not be able to update the data.
Implement #1 and store the interrupt sets size in 'struct irq_affinity'.
No functional change.
[ tglx: Fixed the memcpy() size so it won't copy beyond the size of the
source. Fixed the kernel doc comments for struct irq_affinity and
de-'This patch'-ed the changelog ]
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Bjorn Helgaas <helgaas@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org
Cc: linux-pci@vger.kernel.org
Cc: Keith Busch <keith.busch@intel.com>
Cc: Sumit Saxena <sumit.saxena@broadcom.com>
Cc: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: Shivasharan Srikanteshwara <shivasharan.srikanteshwara@broadcom.com>
Link: https://lkml.kernel.org/r/20190216172228.423723127@linutronix.de
2019-02-16 17:13:08 +00:00
|
|
|
* @nr_sets: The number of interrupt sets for which affinity
|
|
|
|
* spreading is required
|
|
|
|
* @set_size: Array holding the size of each interrupt set
|
genirq/affinity: Add new callback for (re)calculating interrupt sets
The interrupt affinity spreading mechanism supports to spread out
affinities for one or more interrupt sets. A interrupt set contains one or
more interrupts. Each set is mapped to a specific functionality of a
device, e.g. general I/O queues and read I/O queus of multiqueue block
devices.
The number of interrupts per set is defined by the driver. It depends on
the total number of available interrupts for the device, which is
determined by the PCI capabilites and the availability of underlying CPU
resources, and the number of queues which the device provides and the
driver wants to instantiate.
The driver passes initial configuration for the interrupt allocation via a
pointer to struct irq_affinity.
Right now the allocation mechanism is complex as it requires to have a loop
in the driver to determine the maximum number of interrupts which are
provided by the PCI capabilities and the underlying CPU resources. This
loop would have to be replicated in every driver which wants to utilize
this mechanism. That's unwanted code duplication and error prone.
In order to move this into generic facilities it is required to have a
mechanism, which allows the recalculation of the interrupt sets and their
size, in the core code. As the core code does not have any knowledge about the
underlying device, a driver specific callback is required in struct
irq_affinity, which can be invoked by the core code. The callback gets the
number of available interupts as an argument, so the driver can calculate the
corresponding number and size of interrupt sets.
At the moment the struct irq_affinity pointer which is handed in from the
driver and passed through to several core functions is marked 'const', but for
the callback to be able to modify the data in the struct it's required to
remove the 'const' qualifier.
Add the optional callback to struct irq_affinity, which allows drivers to
recalculate the number and size of interrupt sets and remove the 'const'
qualifier.
For simple invocations, which do not supply a callback, a default callback
is installed, which just sets nr_sets to 1 and transfers the number of
spreadable vectors to the set_size array at index 0.
This is for now guarded by a check for nr_sets != 0 to keep the NVME driver
working until it is converted to the callback mechanism.
To make sure that the driver configuration is correct under all circumstances
the callback is invoked even when there are no interrupts for queues left,
i.e. the pre/post requirements already exhaust the numner of available
interrupts.
At the PCI layer irq_create_affinity_masks() has to be invoked even for the
case where the legacy interrupt is used. That ensures that the callback is
invoked and the device driver can adjust to that situation.
[ tglx: Fixed the simple case (no sets required). Moved the sanity check
for nr_sets after the invocation of the callback so it catches
broken drivers. Fixed the kernel doc comments for struct
irq_affinity and de-'This patch'-ed the changelog ]
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Bjorn Helgaas <helgaas@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org
Cc: linux-pci@vger.kernel.org
Cc: Keith Busch <keith.busch@intel.com>
Cc: Sumit Saxena <sumit.saxena@broadcom.com>
Cc: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: Shivasharan Srikanteshwara <shivasharan.srikanteshwara@broadcom.com>
Link: https://lkml.kernel.org/r/20190216172228.512444498@linutronix.de
2019-02-16 17:13:09 +00:00
|
|
|
* @calc_sets: Callback for calculating the number and size
|
|
|
|
* of interrupt sets
|
|
|
|
* @priv: Private data for usage by @calc_sets, usually a
|
|
|
|
* pointer to driver/device specific data.
|
2016-11-09 01:15:01 +00:00
|
|
|
*/
|
|
|
|
struct irq_affinity {
|
2019-02-16 17:13:07 +00:00
|
|
|
unsigned int pre_vectors;
|
|
|
|
unsigned int post_vectors;
|
|
|
|
unsigned int nr_sets;
|
genirq/affinity: Store interrupt sets size in struct irq_affinity
The interrupt affinity spreading mechanism supports to spread out
affinities for one or more interrupt sets. A interrupt set contains one
or more interrupts. Each set is mapped to a specific functionality of a
device, e.g. general I/O queues and read I/O queus of multiqueue block
devices.
The number of interrupts per set is defined by the driver. It depends on
the total number of available interrupts for the device, which is
determined by the PCI capabilites and the availability of underlying CPU
resources, and the number of queues which the device provides and the
driver wants to instantiate.
The driver passes initial configuration for the interrupt allocation via
a pointer to struct irq_affinity.
Right now the allocation mechanism is complex as it requires to have a
loop in the driver to determine the maximum number of interrupts which
are provided by the PCI capabilities and the underlying CPU resources.
This loop would have to be replicated in every driver which wants to
utilize this mechanism. That's unwanted code duplication and error
prone.
In order to move this into generic facilities it is required to have a
mechanism, which allows the recalculation of the interrupt sets and
their size, in the core code. As the core code does not have any
knowledge about the underlying device, a driver specific callback will
be added to struct affinity_desc, which will be invoked by the core
code. The callback will get the number of available interupts as an
argument, so the driver can calculate the corresponding number and size
of interrupt sets.
To support this, two modifications for the handling of struct irq_affinity
are required:
1) The (optional) interrupt sets size information is contained in a
separate array of integers and struct irq_affinity contains a
pointer to it.
This is cumbersome and as the maximum number of interrupt sets is small,
there is no reason to have separate storage. Moving the size array into
struct affinity_desc avoids indirections and makes the code simpler.
2) At the moment the struct irq_affinity pointer which is handed in from
the driver and passed through to several core functions is marked
'const'.
With the upcoming callback to recalculate the number and size of
interrupt sets, it's necessary to remove the 'const'
qualifier. Otherwise the callback would not be able to update the data.
Implement #1 and store the interrupt sets size in 'struct irq_affinity'.
No functional change.
[ tglx: Fixed the memcpy() size so it won't copy beyond the size of the
source. Fixed the kernel doc comments for struct irq_affinity and
de-'This patch'-ed the changelog ]
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Bjorn Helgaas <helgaas@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org
Cc: linux-pci@vger.kernel.org
Cc: Keith Busch <keith.busch@intel.com>
Cc: Sumit Saxena <sumit.saxena@broadcom.com>
Cc: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: Shivasharan Srikanteshwara <shivasharan.srikanteshwara@broadcom.com>
Link: https://lkml.kernel.org/r/20190216172228.423723127@linutronix.de
2019-02-16 17:13:08 +00:00
|
|
|
unsigned int set_size[IRQ_AFFINITY_MAX_SETS];
|
genirq/affinity: Add new callback for (re)calculating interrupt sets
The interrupt affinity spreading mechanism supports to spread out
affinities for one or more interrupt sets. A interrupt set contains one or
more interrupts. Each set is mapped to a specific functionality of a
device, e.g. general I/O queues and read I/O queus of multiqueue block
devices.
The number of interrupts per set is defined by the driver. It depends on
the total number of available interrupts for the device, which is
determined by the PCI capabilites and the availability of underlying CPU
resources, and the number of queues which the device provides and the
driver wants to instantiate.
The driver passes initial configuration for the interrupt allocation via a
pointer to struct irq_affinity.
Right now the allocation mechanism is complex as it requires to have a loop
in the driver to determine the maximum number of interrupts which are
provided by the PCI capabilities and the underlying CPU resources. This
loop would have to be replicated in every driver which wants to utilize
this mechanism. That's unwanted code duplication and error prone.
In order to move this into generic facilities it is required to have a
mechanism, which allows the recalculation of the interrupt sets and their
size, in the core code. As the core code does not have any knowledge about the
underlying device, a driver specific callback is required in struct
irq_affinity, which can be invoked by the core code. The callback gets the
number of available interupts as an argument, so the driver can calculate the
corresponding number and size of interrupt sets.
At the moment the struct irq_affinity pointer which is handed in from the
driver and passed through to several core functions is marked 'const', but for
the callback to be able to modify the data in the struct it's required to
remove the 'const' qualifier.
Add the optional callback to struct irq_affinity, which allows drivers to
recalculate the number and size of interrupt sets and remove the 'const'
qualifier.
For simple invocations, which do not supply a callback, a default callback
is installed, which just sets nr_sets to 1 and transfers the number of
spreadable vectors to the set_size array at index 0.
This is for now guarded by a check for nr_sets != 0 to keep the NVME driver
working until it is converted to the callback mechanism.
To make sure that the driver configuration is correct under all circumstances
the callback is invoked even when there are no interrupts for queues left,
i.e. the pre/post requirements already exhaust the numner of available
interrupts.
At the PCI layer irq_create_affinity_masks() has to be invoked even for the
case where the legacy interrupt is used. That ensures that the callback is
invoked and the device driver can adjust to that situation.
[ tglx: Fixed the simple case (no sets required). Moved the sanity check
for nr_sets after the invocation of the callback so it catches
broken drivers. Fixed the kernel doc comments for struct
irq_affinity and de-'This patch'-ed the changelog ]
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Bjorn Helgaas <helgaas@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org
Cc: linux-pci@vger.kernel.org
Cc: Keith Busch <keith.busch@intel.com>
Cc: Sumit Saxena <sumit.saxena@broadcom.com>
Cc: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: Shivasharan Srikanteshwara <shivasharan.srikanteshwara@broadcom.com>
Link: https://lkml.kernel.org/r/20190216172228.512444498@linutronix.de
2019-02-16 17:13:09 +00:00
|
|
|
void (*calc_sets)(struct irq_affinity *, unsigned int nvecs);
|
|
|
|
void *priv;
|
2016-11-09 01:15:01 +00:00
|
|
|
};
|
|
|
|
|
2018-12-04 15:51:20 +00:00
|
|
|
/**
|
|
|
|
* struct irq_affinity_desc - Interrupt affinity descriptor
|
|
|
|
* @mask: cpumask to hold the affinity assignment
|
2019-01-09 00:04:32 +00:00
|
|
|
* @is_managed: 1 if the interrupt is managed internally
|
2018-12-04 15:51:20 +00:00
|
|
|
*/
|
|
|
|
struct irq_affinity_desc {
|
|
|
|
struct cpumask mask;
|
2018-12-04 15:51:21 +00:00
|
|
|
unsigned int is_managed : 1;
|
2018-12-04 15:51:20 +00:00
|
|
|
};
|
|
|
|
|
2013-08-30 07:39:53 +00:00
|
|
|
#if defined(CONFIG_SMP)
|
[S390] genirq/clockevents: move irq affinity prototypes/inlines to interrupt.h
> Generic code is not supposed to include irq.h. Replace this include
> by linux/hardirq.h instead and add/replace an include of linux/irq.h
> in asm header files where necessary.
> This change should only matter for architectures that make use of
> GENERIC_CLOCKEVENTS.
> Architectures in question are mips, x86, arm, sh, powerpc, uml and sparc64.
>
> I did some cross compile tests for mips, x86_64, arm, powerpc and sparc64.
> This patch fixes also build breakages caused by the include replacement in
> tick-common.h.
I generally dislike adding optional linux/* includes in asm/* includes -
I'm nervous about this causing include loops.
However, there's a separate point to be discussed here.
That is, what interfaces are expected of every architecture in the kernel.
If generic code wants to be able to set the affinity of interrupts, then
that needs to become part of the interfaces listed in linux/interrupt.h
rather than linux/irq.h.
So what I suggest is this approach instead (against Linus' tree of a
couple of days ago) - we move irq_set_affinity() and irq_can_set_affinity()
to linux/interrupt.h, change the linux/irq.h includes to linux/interrupt.h
and include asm/irq_regs.h where needed (asm/irq_regs.h is supposed to be
rarely used include since not much touches the stacked parent context
registers.)
Build tested on ARM PXA family kernels and ARM's Realview platform
kernels which both use genirq.
[ tglx@linutronix.de: add GENERIC_HARDIRQ dependencies ]
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2008-04-17 05:46:24 +00:00
|
|
|
|
2008-12-31 23:42:26 +00:00
|
|
|
extern cpumask_var_t irq_default_affinity;
|
2008-05-29 18:02:52 +00:00
|
|
|
|
2014-04-16 14:36:44 +00:00
|
|
|
/* Internal implementation. Use the helpers below */
|
|
|
|
extern int __irq_set_affinity(unsigned int irq, const struct cpumask *cpumask,
|
|
|
|
bool force);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* irq_set_affinity - Set the irq affinity of a given irq
|
|
|
|
* @irq: Interrupt to set affinity
|
2014-04-28 04:03:09 +00:00
|
|
|
* @cpumask: cpumask
|
2014-04-16 14:36:44 +00:00
|
|
|
*
|
|
|
|
* Fails if cpumask does not contain an online CPU
|
|
|
|
*/
|
|
|
|
static inline int
|
|
|
|
irq_set_affinity(unsigned int irq, const struct cpumask *cpumask)
|
|
|
|
{
|
|
|
|
return __irq_set_affinity(irq, cpumask, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* irq_force_affinity - Force the irq affinity of a given irq
|
|
|
|
* @irq: Interrupt to set affinity
|
2014-04-28 04:03:09 +00:00
|
|
|
* @cpumask: cpumask
|
2014-04-16 14:36:44 +00:00
|
|
|
*
|
|
|
|
* Same as irq_set_affinity, but without checking the mask against
|
|
|
|
* online cpus.
|
|
|
|
*
|
|
|
|
* Solely for low level cpu hotplug code, where we need to make per
|
|
|
|
* cpu interrupts affine before the cpu becomes online.
|
|
|
|
*/
|
|
|
|
static inline int
|
|
|
|
irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
|
|
|
|
{
|
|
|
|
return __irq_set_affinity(irq, cpumask, true);
|
|
|
|
}
|
|
|
|
|
[S390] genirq/clockevents: move irq affinity prototypes/inlines to interrupt.h
> Generic code is not supposed to include irq.h. Replace this include
> by linux/hardirq.h instead and add/replace an include of linux/irq.h
> in asm header files where necessary.
> This change should only matter for architectures that make use of
> GENERIC_CLOCKEVENTS.
> Architectures in question are mips, x86, arm, sh, powerpc, uml and sparc64.
>
> I did some cross compile tests for mips, x86_64, arm, powerpc and sparc64.
> This patch fixes also build breakages caused by the include replacement in
> tick-common.h.
I generally dislike adding optional linux/* includes in asm/* includes -
I'm nervous about this causing include loops.
However, there's a separate point to be discussed here.
That is, what interfaces are expected of every architecture in the kernel.
If generic code wants to be able to set the affinity of interrupts, then
that needs to become part of the interfaces listed in linux/interrupt.h
rather than linux/irq.h.
So what I suggest is this approach instead (against Linus' tree of a
couple of days ago) - we move irq_set_affinity() and irq_can_set_affinity()
to linux/interrupt.h, change the linux/irq.h includes to linux/interrupt.h
and include asm/irq_regs.h where needed (asm/irq_regs.h is supposed to be
rarely used include since not much touches the stacked parent context
registers.)
Build tested on ARM PXA family kernels and ARM's Realview platform
kernels which both use genirq.
[ tglx@linutronix.de: add GENERIC_HARDIRQ dependencies ]
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2008-04-17 05:46:24 +00:00
|
|
|
extern int irq_can_set_affinity(unsigned int irq);
|
2008-05-29 18:02:52 +00:00
|
|
|
extern int irq_select_affinity(unsigned int irq);
|
[S390] genirq/clockevents: move irq affinity prototypes/inlines to interrupt.h
> Generic code is not supposed to include irq.h. Replace this include
> by linux/hardirq.h instead and add/replace an include of linux/irq.h
> in asm header files where necessary.
> This change should only matter for architectures that make use of
> GENERIC_CLOCKEVENTS.
> Architectures in question are mips, x86, arm, sh, powerpc, uml and sparc64.
>
> I did some cross compile tests for mips, x86_64, arm, powerpc and sparc64.
> This patch fixes also build breakages caused by the include replacement in
> tick-common.h.
I generally dislike adding optional linux/* includes in asm/* includes -
I'm nervous about this causing include loops.
However, there's a separate point to be discussed here.
That is, what interfaces are expected of every architecture in the kernel.
If generic code wants to be able to set the affinity of interrupts, then
that needs to become part of the interfaces listed in linux/interrupt.h
rather than linux/irq.h.
So what I suggest is this approach instead (against Linus' tree of a
couple of days ago) - we move irq_set_affinity() and irq_can_set_affinity()
to linux/interrupt.h, change the linux/irq.h includes to linux/interrupt.h
and include asm/irq_regs.h where needed (asm/irq_regs.h is supposed to be
rarely used include since not much touches the stacked parent context
registers.)
Build tested on ARM PXA family kernels and ARM's Realview platform
kernels which both use genirq.
[ tglx@linutronix.de: add GENERIC_HARDIRQ dependencies ]
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2008-04-17 05:46:24 +00:00
|
|
|
|
2010-04-30 21:44:50 +00:00
|
|
|
extern int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m);
|
2020-12-02 10:36:53 +00:00
|
|
|
extern int irq_update_affinity_desc(unsigned int irq,
|
|
|
|
struct irq_affinity_desc *affinity);
|
2011-01-19 21:01:44 +00:00
|
|
|
|
|
|
|
extern int
|
|
|
|
irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify);
|
|
|
|
|
2018-12-04 15:51:20 +00:00
|
|
|
struct irq_affinity_desc *
|
genirq/affinity: Add new callback for (re)calculating interrupt sets
The interrupt affinity spreading mechanism supports to spread out
affinities for one or more interrupt sets. A interrupt set contains one or
more interrupts. Each set is mapped to a specific functionality of a
device, e.g. general I/O queues and read I/O queus of multiqueue block
devices.
The number of interrupts per set is defined by the driver. It depends on
the total number of available interrupts for the device, which is
determined by the PCI capabilites and the availability of underlying CPU
resources, and the number of queues which the device provides and the
driver wants to instantiate.
The driver passes initial configuration for the interrupt allocation via a
pointer to struct irq_affinity.
Right now the allocation mechanism is complex as it requires to have a loop
in the driver to determine the maximum number of interrupts which are
provided by the PCI capabilities and the underlying CPU resources. This
loop would have to be replicated in every driver which wants to utilize
this mechanism. That's unwanted code duplication and error prone.
In order to move this into generic facilities it is required to have a
mechanism, which allows the recalculation of the interrupt sets and their
size, in the core code. As the core code does not have any knowledge about the
underlying device, a driver specific callback is required in struct
irq_affinity, which can be invoked by the core code. The callback gets the
number of available interupts as an argument, so the driver can calculate the
corresponding number and size of interrupt sets.
At the moment the struct irq_affinity pointer which is handed in from the
driver and passed through to several core functions is marked 'const', but for
the callback to be able to modify the data in the struct it's required to
remove the 'const' qualifier.
Add the optional callback to struct irq_affinity, which allows drivers to
recalculate the number and size of interrupt sets and remove the 'const'
qualifier.
For simple invocations, which do not supply a callback, a default callback
is installed, which just sets nr_sets to 1 and transfers the number of
spreadable vectors to the set_size array at index 0.
This is for now guarded by a check for nr_sets != 0 to keep the NVME driver
working until it is converted to the callback mechanism.
To make sure that the driver configuration is correct under all circumstances
the callback is invoked even when there are no interrupts for queues left,
i.e. the pre/post requirements already exhaust the numner of available
interrupts.
At the PCI layer irq_create_affinity_masks() has to be invoked even for the
case where the legacy interrupt is used. That ensures that the callback is
invoked and the device driver can adjust to that situation.
[ tglx: Fixed the simple case (no sets required). Moved the sanity check
for nr_sets after the invocation of the callback so it catches
broken drivers. Fixed the kernel doc comments for struct
irq_affinity and de-'This patch'-ed the changelog ]
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Bjorn Helgaas <helgaas@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org
Cc: linux-pci@vger.kernel.org
Cc: Keith Busch <keith.busch@intel.com>
Cc: Sumit Saxena <sumit.saxena@broadcom.com>
Cc: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: Shivasharan Srikanteshwara <shivasharan.srikanteshwara@broadcom.com>
Link: https://lkml.kernel.org/r/20190216172228.512444498@linutronix.de
2019-02-16 17:13:09 +00:00
|
|
|
irq_create_affinity_masks(unsigned int nvec, struct irq_affinity *affd);
|
2018-12-04 15:51:20 +00:00
|
|
|
|
2019-02-16 17:13:07 +00:00
|
|
|
unsigned int irq_calc_affinity_vectors(unsigned int minvec, unsigned int maxvec,
|
|
|
|
const struct irq_affinity *affd);
|
2016-07-04 08:39:27 +00:00
|
|
|
|
[S390] genirq/clockevents: move irq affinity prototypes/inlines to interrupt.h
> Generic code is not supposed to include irq.h. Replace this include
> by linux/hardirq.h instead and add/replace an include of linux/irq.h
> in asm header files where necessary.
> This change should only matter for architectures that make use of
> GENERIC_CLOCKEVENTS.
> Architectures in question are mips, x86, arm, sh, powerpc, uml and sparc64.
>
> I did some cross compile tests for mips, x86_64, arm, powerpc and sparc64.
> This patch fixes also build breakages caused by the include replacement in
> tick-common.h.
I generally dislike adding optional linux/* includes in asm/* includes -
I'm nervous about this causing include loops.
However, there's a separate point to be discussed here.
That is, what interfaces are expected of every architecture in the kernel.
If generic code wants to be able to set the affinity of interrupts, then
that needs to become part of the interfaces listed in linux/interrupt.h
rather than linux/irq.h.
So what I suggest is this approach instead (against Linus' tree of a
couple of days ago) - we move irq_set_affinity() and irq_can_set_affinity()
to linux/interrupt.h, change the linux/irq.h includes to linux/interrupt.h
and include asm/irq_regs.h where needed (asm/irq_regs.h is supposed to be
rarely used include since not much touches the stacked parent context
registers.)
Build tested on ARM PXA family kernels and ARM's Realview platform
kernels which both use genirq.
[ tglx@linutronix.de: add GENERIC_HARDIRQ dependencies ]
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2008-04-17 05:46:24 +00:00
|
|
|
#else /* CONFIG_SMP */
|
|
|
|
|
2008-12-13 10:50:26 +00:00
|
|
|
static inline int irq_set_affinity(unsigned int irq, const struct cpumask *m)
|
[S390] genirq/clockevents: move irq affinity prototypes/inlines to interrupt.h
> Generic code is not supposed to include irq.h. Replace this include
> by linux/hardirq.h instead and add/replace an include of linux/irq.h
> in asm header files where necessary.
> This change should only matter for architectures that make use of
> GENERIC_CLOCKEVENTS.
> Architectures in question are mips, x86, arm, sh, powerpc, uml and sparc64.
>
> I did some cross compile tests for mips, x86_64, arm, powerpc and sparc64.
> This patch fixes also build breakages caused by the include replacement in
> tick-common.h.
I generally dislike adding optional linux/* includes in asm/* includes -
I'm nervous about this causing include loops.
However, there's a separate point to be discussed here.
That is, what interfaces are expected of every architecture in the kernel.
If generic code wants to be able to set the affinity of interrupts, then
that needs to become part of the interfaces listed in linux/interrupt.h
rather than linux/irq.h.
So what I suggest is this approach instead (against Linus' tree of a
couple of days ago) - we move irq_set_affinity() and irq_can_set_affinity()
to linux/interrupt.h, change the linux/irq.h includes to linux/interrupt.h
and include asm/irq_regs.h where needed (asm/irq_regs.h is supposed to be
rarely used include since not much touches the stacked parent context
registers.)
Build tested on ARM PXA family kernels and ARM's Realview platform
kernels which both use genirq.
[ tglx@linutronix.de: add GENERIC_HARDIRQ dependencies ]
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2008-04-17 05:46:24 +00:00
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-04-23 12:49:17 +00:00
|
|
|
static inline int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
[S390] genirq/clockevents: move irq affinity prototypes/inlines to interrupt.h
> Generic code is not supposed to include irq.h. Replace this include
> by linux/hardirq.h instead and add/replace an include of linux/irq.h
> in asm header files where necessary.
> This change should only matter for architectures that make use of
> GENERIC_CLOCKEVENTS.
> Architectures in question are mips, x86, arm, sh, powerpc, uml and sparc64.
>
> I did some cross compile tests for mips, x86_64, arm, powerpc and sparc64.
> This patch fixes also build breakages caused by the include replacement in
> tick-common.h.
I generally dislike adding optional linux/* includes in asm/* includes -
I'm nervous about this causing include loops.
However, there's a separate point to be discussed here.
That is, what interfaces are expected of every architecture in the kernel.
If generic code wants to be able to set the affinity of interrupts, then
that needs to become part of the interfaces listed in linux/interrupt.h
rather than linux/irq.h.
So what I suggest is this approach instead (against Linus' tree of a
couple of days ago) - we move irq_set_affinity() and irq_can_set_affinity()
to linux/interrupt.h, change the linux/irq.h includes to linux/interrupt.h
and include asm/irq_regs.h where needed (asm/irq_regs.h is supposed to be
rarely used include since not much touches the stacked parent context
registers.)
Build tested on ARM PXA family kernels and ARM's Realview platform
kernels which both use genirq.
[ tglx@linutronix.de: add GENERIC_HARDIRQ dependencies ]
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2008-04-17 05:46:24 +00:00
|
|
|
static inline int irq_can_set_affinity(unsigned int irq)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-05-29 18:02:52 +00:00
|
|
|
static inline int irq_select_affinity(unsigned int irq) { return 0; }
|
|
|
|
|
2010-04-30 21:44:50 +00:00
|
|
|
static inline int irq_set_affinity_hint(unsigned int irq,
|
2011-01-19 21:01:44 +00:00
|
|
|
const struct cpumask *m)
|
2010-04-30 21:44:50 +00:00
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2014-05-20 14:57:00 +00:00
|
|
|
|
2020-12-02 10:36:53 +00:00
|
|
|
static inline int irq_update_affinity_desc(unsigned int irq,
|
|
|
|
struct irq_affinity_desc *affinity)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-05-20 14:57:00 +00:00
|
|
|
static inline int
|
|
|
|
irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2016-07-04 08:39:27 +00:00
|
|
|
|
2018-12-04 15:51:20 +00:00
|
|
|
static inline struct irq_affinity_desc *
|
genirq/affinity: Add new callback for (re)calculating interrupt sets
The interrupt affinity spreading mechanism supports to spread out
affinities for one or more interrupt sets. A interrupt set contains one or
more interrupts. Each set is mapped to a specific functionality of a
device, e.g. general I/O queues and read I/O queus of multiqueue block
devices.
The number of interrupts per set is defined by the driver. It depends on
the total number of available interrupts for the device, which is
determined by the PCI capabilites and the availability of underlying CPU
resources, and the number of queues which the device provides and the
driver wants to instantiate.
The driver passes initial configuration for the interrupt allocation via a
pointer to struct irq_affinity.
Right now the allocation mechanism is complex as it requires to have a loop
in the driver to determine the maximum number of interrupts which are
provided by the PCI capabilities and the underlying CPU resources. This
loop would have to be replicated in every driver which wants to utilize
this mechanism. That's unwanted code duplication and error prone.
In order to move this into generic facilities it is required to have a
mechanism, which allows the recalculation of the interrupt sets and their
size, in the core code. As the core code does not have any knowledge about the
underlying device, a driver specific callback is required in struct
irq_affinity, which can be invoked by the core code. The callback gets the
number of available interupts as an argument, so the driver can calculate the
corresponding number and size of interrupt sets.
At the moment the struct irq_affinity pointer which is handed in from the
driver and passed through to several core functions is marked 'const', but for
the callback to be able to modify the data in the struct it's required to
remove the 'const' qualifier.
Add the optional callback to struct irq_affinity, which allows drivers to
recalculate the number and size of interrupt sets and remove the 'const'
qualifier.
For simple invocations, which do not supply a callback, a default callback
is installed, which just sets nr_sets to 1 and transfers the number of
spreadable vectors to the set_size array at index 0.
This is for now guarded by a check for nr_sets != 0 to keep the NVME driver
working until it is converted to the callback mechanism.
To make sure that the driver configuration is correct under all circumstances
the callback is invoked even when there are no interrupts for queues left,
i.e. the pre/post requirements already exhaust the numner of available
interrupts.
At the PCI layer irq_create_affinity_masks() has to be invoked even for the
case where the legacy interrupt is used. That ensures that the callback is
invoked and the device driver can adjust to that situation.
[ tglx: Fixed the simple case (no sets required). Moved the sanity check
for nr_sets after the invocation of the callback so it catches
broken drivers. Fixed the kernel doc comments for struct
irq_affinity and de-'This patch'-ed the changelog ]
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Bjorn Helgaas <helgaas@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org
Cc: linux-pci@vger.kernel.org
Cc: Keith Busch <keith.busch@intel.com>
Cc: Sumit Saxena <sumit.saxena@broadcom.com>
Cc: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: Shivasharan Srikanteshwara <shivasharan.srikanteshwara@broadcom.com>
Link: https://lkml.kernel.org/r/20190216172228.512444498@linutronix.de
2019-02-16 17:13:09 +00:00
|
|
|
irq_create_affinity_masks(unsigned int nvec, struct irq_affinity *affd)
|
2016-09-14 14:18:48 +00:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-02-16 17:13:07 +00:00
|
|
|
static inline unsigned int
|
|
|
|
irq_calc_affinity_vectors(unsigned int minvec, unsigned int maxvec,
|
|
|
|
const struct irq_affinity *affd)
|
2016-09-14 14:18:48 +00:00
|
|
|
{
|
|
|
|
return maxvec;
|
|
|
|
}
|
|
|
|
|
2013-08-30 07:39:53 +00:00
|
|
|
#endif /* CONFIG_SMP */
|
[S390] genirq/clockevents: move irq affinity prototypes/inlines to interrupt.h
> Generic code is not supposed to include irq.h. Replace this include
> by linux/hardirq.h instead and add/replace an include of linux/irq.h
> in asm header files where necessary.
> This change should only matter for architectures that make use of
> GENERIC_CLOCKEVENTS.
> Architectures in question are mips, x86, arm, sh, powerpc, uml and sparc64.
>
> I did some cross compile tests for mips, x86_64, arm, powerpc and sparc64.
> This patch fixes also build breakages caused by the include replacement in
> tick-common.h.
I generally dislike adding optional linux/* includes in asm/* includes -
I'm nervous about this causing include loops.
However, there's a separate point to be discussed here.
That is, what interfaces are expected of every architecture in the kernel.
If generic code wants to be able to set the affinity of interrupts, then
that needs to become part of the interfaces listed in linux/interrupt.h
rather than linux/irq.h.
So what I suggest is this approach instead (against Linus' tree of a
couple of days ago) - we move irq_set_affinity() and irq_can_set_affinity()
to linux/interrupt.h, change the linux/irq.h includes to linux/interrupt.h
and include asm/irq_regs.h where needed (asm/irq_regs.h is supposed to be
rarely used include since not much touches the stacked parent context
registers.)
Build tested on ARM PXA family kernels and ARM's Realview platform
kernels which both use genirq.
[ tglx@linutronix.de: add GENERIC_HARDIRQ dependencies ]
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2008-04-17 05:46:24 +00:00
|
|
|
|
2006-07-03 07:24:27 +00:00
|
|
|
/*
|
|
|
|
* Special lockdep variants of irq disabling/enabling.
|
|
|
|
* These should be used for locking constructs that
|
|
|
|
* know that a particular irq context which is disabled,
|
|
|
|
* and which is the only irq-context user of a lock,
|
|
|
|
* that it's safe to take the lock in the irq-disabled
|
|
|
|
* section without disabling hardirqs.
|
|
|
|
*
|
|
|
|
* On !CONFIG_LOCKDEP they are equivalent to the normal
|
|
|
|
* irq disable/enable methods.
|
|
|
|
*/
|
|
|
|
static inline void disable_irq_nosync_lockdep(unsigned int irq)
|
|
|
|
{
|
|
|
|
disable_irq_nosync(irq);
|
|
|
|
#ifdef CONFIG_LOCKDEP
|
|
|
|
local_irq_disable();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:01:08 +00:00
|
|
|
static inline void disable_irq_nosync_lockdep_irqsave(unsigned int irq, unsigned long *flags)
|
|
|
|
{
|
|
|
|
disable_irq_nosync(irq);
|
|
|
|
#ifdef CONFIG_LOCKDEP
|
|
|
|
local_irq_save(*flags);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2006-07-03 07:24:27 +00:00
|
|
|
static inline void disable_irq_lockdep(unsigned int irq)
|
|
|
|
{
|
|
|
|
disable_irq(irq);
|
|
|
|
#ifdef CONFIG_LOCKDEP
|
|
|
|
local_irq_disable();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void enable_irq_lockdep(unsigned int irq)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_LOCKDEP
|
|
|
|
local_irq_enable();
|
|
|
|
#endif
|
|
|
|
enable_irq(irq);
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:01:08 +00:00
|
|
|
static inline void enable_irq_lockdep_irqrestore(unsigned int irq, unsigned long *flags)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_LOCKDEP
|
|
|
|
local_irq_restore(*flags);
|
|
|
|
#endif
|
|
|
|
enable_irq(irq);
|
|
|
|
}
|
|
|
|
|
2006-06-29 09:24:55 +00:00
|
|
|
/* IRQ wakeup (PM) control: */
|
2011-02-10 10:36:33 +00:00
|
|
|
extern int irq_set_irq_wake(unsigned int irq, unsigned int on);
|
|
|
|
|
2006-06-29 09:24:55 +00:00
|
|
|
static inline int enable_irq_wake(unsigned int irq)
|
|
|
|
{
|
2011-02-10 10:36:33 +00:00
|
|
|
return irq_set_irq_wake(irq, 1);
|
2006-06-29 09:24:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int disable_irq_wake(unsigned int irq)
|
|
|
|
{
|
2011-02-10 10:36:33 +00:00
|
|
|
return irq_set_irq_wake(irq, 0);
|
2006-06-29 09:24:55 +00:00
|
|
|
}
|
|
|
|
|
2015-03-18 11:01:22 +00:00
|
|
|
/*
|
|
|
|
* irq_get_irqchip_state/irq_set_irqchip_state specific flags
|
|
|
|
*/
|
|
|
|
enum irqchip_irq_state {
|
|
|
|
IRQCHIP_STATE_PENDING, /* Is interrupt pending? */
|
|
|
|
IRQCHIP_STATE_ACTIVE, /* Is interrupt in progress? */
|
|
|
|
IRQCHIP_STATE_MASKED, /* Is interrupt masked? */
|
|
|
|
IRQCHIP_STATE_LINE_LEVEL, /* Is IRQ line high? */
|
|
|
|
};
|
|
|
|
|
|
|
|
extern int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which,
|
|
|
|
bool *state);
|
|
|
|
extern int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which,
|
|
|
|
bool state);
|
2011-02-23 23:52:23 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_IRQ_FORCED_THREADING
|
2019-08-16 16:09:23 +00:00
|
|
|
# ifdef CONFIG_PREEMPT_RT
|
|
|
|
# define force_irqthreads (true)
|
|
|
|
# else
|
2011-02-23 23:52:23 +00:00
|
|
|
extern bool force_irqthreads;
|
2019-08-16 16:09:23 +00:00
|
|
|
# endif
|
2011-02-23 23:52:23 +00:00
|
|
|
#else
|
|
|
|
#define force_irqthreads (0)
|
|
|
|
#endif
|
|
|
|
|
2018-05-08 13:38:20 +00:00
|
|
|
#ifndef local_softirq_pending
|
|
|
|
|
|
|
|
#ifndef local_softirq_pending_ref
|
|
|
|
#define local_softirq_pending_ref irq_stat.__softirq_pending
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define local_softirq_pending() (__this_cpu_read(local_softirq_pending_ref))
|
|
|
|
#define set_softirq_pending(x) (__this_cpu_write(local_softirq_pending_ref, (x)))
|
|
|
|
#define or_softirq_pending(x) (__this_cpu_or(local_softirq_pending_ref, (x)))
|
|
|
|
|
|
|
|
#endif /* local_softirq_pending */
|
|
|
|
|
Add hard_irq_disable()
Some architectures, like powerpc, implement lazy disabling of interrupts.
That means that on those, local_irq_disable() doesn't actually disable
interrupts on the CPU, but only sets some per CPU flag which cause them to be
disabled only if an interrupt actually occurs.
However, in some cases, such as stop_machine, we really want interrupts to be
fully disabled. For example, I have code using stop machine to do ECC error
injection, used to verify operations of the ECC hardware, that sort of thing.
It really needs to make sure that nothing is actually writing to memory while
the injection happens. Similar examples can be found in other low level bits
and pieces.
This patch implements a generic hard_irq_disable() function which is meant to
be called -after- local_irq_disable() and ensures that interrupts are fully
disabled on that CPU. The default implementation is a nop, though powerpc
does already provide an appropriate one.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-11 05:22:46 +00:00
|
|
|
/* Some architectures might implement lazy enabling/disabling of
|
|
|
|
* interrupts. In some cases, such as stop_machine, we might want
|
|
|
|
* to ensure that after a local_irq_disable(), interrupts have
|
|
|
|
* really been disabled in hardware. Such architectures need to
|
|
|
|
* implement the following hook.
|
|
|
|
*/
|
|
|
|
#ifndef hard_irq_disable
|
|
|
|
#define hard_irq_disable() do { } while(0)
|
|
|
|
#endif
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
|
|
|
|
frequency threaded job scheduling. For almost all the purposes
|
|
|
|
tasklets are more than enough. F.e. all serial device BHs et
|
|
|
|
al. should be converted to tasklets, not to softirqs.
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
HI_SOFTIRQ=0,
|
|
|
|
TIMER_SOFTIRQ,
|
|
|
|
NET_TX_SOFTIRQ,
|
|
|
|
NET_RX_SOFTIRQ,
|
2006-01-09 15:02:34 +00:00
|
|
|
BLOCK_SOFTIRQ,
|
2015-11-10 13:56:14 +00:00
|
|
|
IRQ_POLL_SOFTIRQ,
|
2006-12-10 10:20:25 +00:00
|
|
|
TASKLET_SOFTIRQ,
|
|
|
|
SCHED_SOFTIRQ,
|
2019-11-07 09:19:24 +00:00
|
|
|
HRTIMER_SOFTIRQ,
|
rcu: Use softirq to address performance regression
Commit a26ac2455ffcf3(rcu: move TREE_RCU from softirq to kthread)
introduced performance regression. In an AIM7 test, this commit degraded
performance by about 40%.
The commit runs rcu callbacks in a kthread instead of softirq. We observed
high rate of context switch which is caused by this. Out test system has
64 CPUs and HZ is 1000, so we saw more than 64k context switch per second
which is caused by RCU's per-CPU kthread. A trace showed that most of
the time the RCU per-CPU kthread doesn't actually handle any callbacks,
but instead just does a very small amount of work handling grace periods.
This means that RCU's per-CPU kthreads are making the scheduler do quite
a bit of work in order to allow a very small amount of RCU-related
processing to be done.
Alex Shi's analysis determined that this slowdown is due to lock
contention within the scheduler. Unfortunately, as Peter Zijlstra points
out, the scheduler's real-time semantics require global action, which
means that this contention is inherent in real-time scheduling. (Yes,
perhaps someone will come up with a workaround -- otherwise, -rt is not
going to do well on large SMP systems -- but this patch will work around
this issue in the meantime. And "the meantime" might well be forever.)
This patch therefore re-introduces softirq processing to RCU, but only
for core RCU work. RCU callbacks are still executed in kthread context,
so that only a small amount of RCU work runs in softirq context in the
common case. This should minimize ksoftirqd execution, allowing us to
skip boosting of ksoftirqd for CONFIG_RCU_BOOST=y kernels.
Signed-off-by: Shaohua Li <shaohua.li@intel.com>
Tested-by: "Alex,Shi" <alex.shi@intel.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
2011-06-14 05:26:25 +00:00
|
|
|
RCU_SOFTIRQ, /* Preferable RCU should always be the last softirq */
|
2008-09-06 18:04:36 +00:00
|
|
|
|
|
|
|
NR_SOFTIRQS
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2012-08-23 15:34:07 +00:00
|
|
|
#define SOFTIRQ_STOP_IDLE_MASK (~(1 << RCU_SOFTIRQ))
|
|
|
|
|
2009-03-12 18:33:36 +00:00
|
|
|
/* map softirq index to softirq name. update 'softirq_to_name' in
|
|
|
|
* kernel/softirq.c when adding a new softirq.
|
|
|
|
*/
|
2014-01-28 01:07:16 +00:00
|
|
|
extern const char * const softirq_to_name[NR_SOFTIRQS];
|
2009-03-12 18:33:36 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* softirq mask and active fields moved to irq_cpustat_t in
|
|
|
|
* asm/hardirq.h to get better cache usage. KAO
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct softirq_action
|
|
|
|
{
|
|
|
|
void (*action)(struct softirq_action *);
|
|
|
|
};
|
|
|
|
|
|
|
|
asmlinkage void do_softirq(void);
|
2008-04-29 07:59:12 +00:00
|
|
|
asmlinkage void __do_softirq(void);
|
2013-09-05 13:49:45 +00:00
|
|
|
|
Remove argument from open_softirq which is always NULL
As git-grep shows, open_softirq() is always called with the last argument
being NULL
block/blk-core.c: open_softirq(BLOCK_SOFTIRQ, blk_done_softirq, NULL);
kernel/hrtimer.c: open_softirq(HRTIMER_SOFTIRQ, run_hrtimer_softirq, NULL);
kernel/rcuclassic.c: open_softirq(RCU_SOFTIRQ, rcu_process_callbacks, NULL);
kernel/rcupreempt.c: open_softirq(RCU_SOFTIRQ, rcu_process_callbacks, NULL);
kernel/sched.c: open_softirq(SCHED_SOFTIRQ, run_rebalance_domains, NULL);
kernel/softirq.c: open_softirq(TASKLET_SOFTIRQ, tasklet_action, NULL);
kernel/softirq.c: open_softirq(HI_SOFTIRQ, tasklet_hi_action, NULL);
kernel/timer.c: open_softirq(TIMER_SOFTIRQ, run_timer_softirq, NULL);
net/core/dev.c: open_softirq(NET_TX_SOFTIRQ, net_tx_action, NULL);
net/core/dev.c: open_softirq(NET_RX_SOFTIRQ, net_rx_action, NULL);
This observation has already been made by Matthew Wilcox in June 2002
(http://www.cs.helsinki.fi/linux/linux-kernel/2002-25/0687.html)
"I notice that none of the current softirq routines use the data element
passed to them."
and the situation hasn't changed since them. So it appears we can safely
remove that extra argument to save 128 (54) bytes of kernel data (text).
Signed-off-by: Carlos R. Mafra <crmafra@ift.unesp.br>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-15 14:15:37 +00:00
|
|
|
extern void open_softirq(int nr, void (*action)(struct softirq_action *));
|
2005-04-16 22:20:36 +00:00
|
|
|
extern void softirq_init(void);
|
2012-01-26 01:18:55 +00:00
|
|
|
extern void __raise_softirq_irqoff(unsigned int nr);
|
2010-08-23 09:42:48 +00:00
|
|
|
|
2008-02-13 23:03:15 +00:00
|
|
|
extern void raise_softirq_irqoff(unsigned int nr);
|
|
|
|
extern void raise_softirq(unsigned int nr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-12-22 01:09:00 +00:00
|
|
|
DECLARE_PER_CPU(struct task_struct *, ksoftirqd);
|
|
|
|
|
|
|
|
static inline struct task_struct *this_cpu_ksoftirqd(void)
|
|
|
|
{
|
|
|
|
return this_cpu_read(ksoftirqd);
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Tasklets --- multithreaded analogue of BHs.
|
|
|
|
|
tasklet: Introduce new initialization API
Nowadays, modern kernel subsystems that use callbacks pass the data
structure associated with a given callback as argument to the callback.
The tasklet subsystem remains one which passes an arbitrary unsigned
long to the callback function. This has several problems:
- This keeps an extra field for storing the argument in each tasklet
data structure, it bloats the tasklet_struct structure with a redundant
.data field
- No type checking can be performed on this argument. Instead of
using container_of() like other callback subsystems, it forces callbacks
to do explicit type cast of the unsigned long argument into the required
object type.
- Buffer overflows can overwrite the .func and the .data field, so
an attacker can easily overwrite the function and its first argument
to whatever it wants.
Add a new tasklet initialization API, via DECLARE_TASKLET() and
tasklet_setup(), which will replace the existing ones.
This work is greatly inspired by the timer_struct conversion series,
see commit e99e88a9d2b0 ("treewide: setup_timer() -> timer_setup()")
To avoid problems with both -Wcast-function-type (which is enabled in
the kernel via -Wextra is several subsystems), and with mismatched
function prototypes when build with Control Flow Integrity enabled,
this adds the "use_callback" member to let the tasklet caller choose
which union member to call through. Once all old API uses are removed,
this and the .data member will be removed as well. (On 64-bit this does
not grow the struct size as the new member fills the hole after atomic_t,
which is also "int" sized.)
Signed-off-by: Romain Perier <romain.perier@gmail.com>
Co-developed-by: Allen Pais <allen.lkml@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Co-developed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
2019-09-29 16:30:13 +00:00
|
|
|
This API is deprecated. Please consider using threaded IRQs instead:
|
|
|
|
https://lore.kernel.org/lkml/20200716081538.2sivhkj4hcyrusem@linutronix.de
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
Main feature differing them of generic softirqs: tasklet
|
|
|
|
is running only on one CPU simultaneously.
|
|
|
|
|
|
|
|
Main feature differing them of BHs: different tasklets
|
|
|
|
may be run simultaneously on different CPUs.
|
|
|
|
|
|
|
|
Properties:
|
|
|
|
* If tasklet_schedule() is called, then tasklet is guaranteed
|
|
|
|
to be executed on some cpu at least once after this.
|
2011-03-31 01:57:33 +00:00
|
|
|
* If the tasklet is already scheduled, but its execution is still not
|
2005-04-16 22:20:36 +00:00
|
|
|
started, it will be executed only once.
|
|
|
|
* If this tasklet is already running on another CPU (or schedule is called
|
|
|
|
from tasklet itself), it is rescheduled for later.
|
|
|
|
* Tasklet is strictly serialized wrt itself, but not
|
|
|
|
wrt another tasklets. If client needs some intertask synchronization,
|
|
|
|
he makes it with spinlocks.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct tasklet_struct
|
|
|
|
{
|
|
|
|
struct tasklet_struct *next;
|
|
|
|
unsigned long state;
|
|
|
|
atomic_t count;
|
tasklet: Introduce new initialization API
Nowadays, modern kernel subsystems that use callbacks pass the data
structure associated with a given callback as argument to the callback.
The tasklet subsystem remains one which passes an arbitrary unsigned
long to the callback function. This has several problems:
- This keeps an extra field for storing the argument in each tasklet
data structure, it bloats the tasklet_struct structure with a redundant
.data field
- No type checking can be performed on this argument. Instead of
using container_of() like other callback subsystems, it forces callbacks
to do explicit type cast of the unsigned long argument into the required
object type.
- Buffer overflows can overwrite the .func and the .data field, so
an attacker can easily overwrite the function and its first argument
to whatever it wants.
Add a new tasklet initialization API, via DECLARE_TASKLET() and
tasklet_setup(), which will replace the existing ones.
This work is greatly inspired by the timer_struct conversion series,
see commit e99e88a9d2b0 ("treewide: setup_timer() -> timer_setup()")
To avoid problems with both -Wcast-function-type (which is enabled in
the kernel via -Wextra is several subsystems), and with mismatched
function prototypes when build with Control Flow Integrity enabled,
this adds the "use_callback" member to let the tasklet caller choose
which union member to call through. Once all old API uses are removed,
this and the .data member will be removed as well. (On 64-bit this does
not grow the struct size as the new member fills the hole after atomic_t,
which is also "int" sized.)
Signed-off-by: Romain Perier <romain.perier@gmail.com>
Co-developed-by: Allen Pais <allen.lkml@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Co-developed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
2019-09-29 16:30:13 +00:00
|
|
|
bool use_callback;
|
|
|
|
union {
|
|
|
|
void (*func)(unsigned long data);
|
|
|
|
void (*callback)(struct tasklet_struct *t);
|
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned long data;
|
|
|
|
};
|
|
|
|
|
tasklet: Introduce new initialization API
Nowadays, modern kernel subsystems that use callbacks pass the data
structure associated with a given callback as argument to the callback.
The tasklet subsystem remains one which passes an arbitrary unsigned
long to the callback function. This has several problems:
- This keeps an extra field for storing the argument in each tasklet
data structure, it bloats the tasklet_struct structure with a redundant
.data field
- No type checking can be performed on this argument. Instead of
using container_of() like other callback subsystems, it forces callbacks
to do explicit type cast of the unsigned long argument into the required
object type.
- Buffer overflows can overwrite the .func and the .data field, so
an attacker can easily overwrite the function and its first argument
to whatever it wants.
Add a new tasklet initialization API, via DECLARE_TASKLET() and
tasklet_setup(), which will replace the existing ones.
This work is greatly inspired by the timer_struct conversion series,
see commit e99e88a9d2b0 ("treewide: setup_timer() -> timer_setup()")
To avoid problems with both -Wcast-function-type (which is enabled in
the kernel via -Wextra is several subsystems), and with mismatched
function prototypes when build with Control Flow Integrity enabled,
this adds the "use_callback" member to let the tasklet caller choose
which union member to call through. Once all old API uses are removed,
this and the .data member will be removed as well. (On 64-bit this does
not grow the struct size as the new member fills the hole after atomic_t,
which is also "int" sized.)
Signed-off-by: Romain Perier <romain.perier@gmail.com>
Co-developed-by: Allen Pais <allen.lkml@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Co-developed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
2019-09-29 16:30:13 +00:00
|
|
|
#define DECLARE_TASKLET(name, _callback) \
|
|
|
|
struct tasklet_struct name = { \
|
|
|
|
.count = ATOMIC_INIT(0), \
|
|
|
|
.callback = _callback, \
|
|
|
|
.use_callback = true, \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DECLARE_TASKLET_DISABLED(name, _callback) \
|
|
|
|
struct tasklet_struct name = { \
|
|
|
|
.count = ATOMIC_INIT(1), \
|
|
|
|
.callback = _callback, \
|
|
|
|
.use_callback = true, \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define from_tasklet(var, callback_tasklet, tasklet_fieldname) \
|
|
|
|
container_of(callback_tasklet, typeof(*var), tasklet_fieldname)
|
|
|
|
|
2020-07-13 22:01:26 +00:00
|
|
|
#define DECLARE_TASKLET_OLD(name, _func) \
|
|
|
|
struct tasklet_struct name = { \
|
|
|
|
.count = ATOMIC_INIT(0), \
|
|
|
|
.func = _func, \
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-07-13 22:01:26 +00:00
|
|
|
#define DECLARE_TASKLET_DISABLED_OLD(name, _func) \
|
|
|
|
struct tasklet_struct name = { \
|
|
|
|
.count = ATOMIC_INIT(1), \
|
|
|
|
.func = _func, \
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
TASKLET_STATE_SCHED, /* Tasklet is scheduled for execution */
|
|
|
|
TASKLET_STATE_RUN /* Tasklet is running (SMP only) */
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
static inline int tasklet_trylock(struct tasklet_struct *t)
|
|
|
|
{
|
|
|
|
return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void tasklet_unlock(struct tasklet_struct *t)
|
|
|
|
{
|
2014-03-17 17:06:10 +00:00
|
|
|
smp_mb__before_atomic();
|
2005-04-16 22:20:36 +00:00
|
|
|
clear_bit(TASKLET_STATE_RUN, &(t)->state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void tasklet_unlock_wait(struct tasklet_struct *t)
|
|
|
|
{
|
|
|
|
while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define tasklet_trylock(t) 1
|
|
|
|
#define tasklet_unlock_wait(t) do { } while (0)
|
|
|
|
#define tasklet_unlock(t) do { } while (0)
|
|
|
|
#endif
|
|
|
|
|
2008-02-13 23:03:15 +00:00
|
|
|
extern void __tasklet_schedule(struct tasklet_struct *t);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static inline void tasklet_schedule(struct tasklet_struct *t)
|
|
|
|
{
|
|
|
|
if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
|
|
|
|
__tasklet_schedule(t);
|
|
|
|
}
|
|
|
|
|
2008-02-13 23:03:15 +00:00
|
|
|
extern void __tasklet_hi_schedule(struct tasklet_struct *t);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static inline void tasklet_hi_schedule(struct tasklet_struct *t)
|
|
|
|
{
|
|
|
|
if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
|
|
|
|
__tasklet_hi_schedule(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void tasklet_disable_nosync(struct tasklet_struct *t)
|
|
|
|
{
|
|
|
|
atomic_inc(&t->count);
|
2014-03-17 17:06:10 +00:00
|
|
|
smp_mb__after_atomic();
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void tasklet_disable(struct tasklet_struct *t)
|
|
|
|
{
|
|
|
|
tasklet_disable_nosync(t);
|
|
|
|
tasklet_unlock_wait(t);
|
|
|
|
smp_mb();
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void tasklet_enable(struct tasklet_struct *t)
|
|
|
|
{
|
2014-03-17 17:06:10 +00:00
|
|
|
smp_mb__before_atomic();
|
2005-04-16 22:20:36 +00:00
|
|
|
atomic_dec(&t->count);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern void tasklet_kill(struct tasklet_struct *t);
|
|
|
|
extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
|
|
|
|
extern void tasklet_init(struct tasklet_struct *t,
|
|
|
|
void (*func)(unsigned long), unsigned long data);
|
tasklet: Introduce new initialization API
Nowadays, modern kernel subsystems that use callbacks pass the data
structure associated with a given callback as argument to the callback.
The tasklet subsystem remains one which passes an arbitrary unsigned
long to the callback function. This has several problems:
- This keeps an extra field for storing the argument in each tasklet
data structure, it bloats the tasklet_struct structure with a redundant
.data field
- No type checking can be performed on this argument. Instead of
using container_of() like other callback subsystems, it forces callbacks
to do explicit type cast of the unsigned long argument into the required
object type.
- Buffer overflows can overwrite the .func and the .data field, so
an attacker can easily overwrite the function and its first argument
to whatever it wants.
Add a new tasklet initialization API, via DECLARE_TASKLET() and
tasklet_setup(), which will replace the existing ones.
This work is greatly inspired by the timer_struct conversion series,
see commit e99e88a9d2b0 ("treewide: setup_timer() -> timer_setup()")
To avoid problems with both -Wcast-function-type (which is enabled in
the kernel via -Wextra is several subsystems), and with mismatched
function prototypes when build with Control Flow Integrity enabled,
this adds the "use_callback" member to let the tasklet caller choose
which union member to call through. Once all old API uses are removed,
this and the .data member will be removed as well. (On 64-bit this does
not grow the struct size as the new member fills the hole after atomic_t,
which is also "int" sized.)
Signed-off-by: Romain Perier <romain.perier@gmail.com>
Co-developed-by: Allen Pais <allen.lkml@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Co-developed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
2019-09-29 16:30:13 +00:00
|
|
|
extern void tasklet_setup(struct tasklet_struct *t,
|
|
|
|
void (*callback)(struct tasklet_struct *));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Autoprobing for irqs:
|
|
|
|
*
|
|
|
|
* probe_irq_on() and probe_irq_off() provide robust primitives
|
|
|
|
* for accurate IRQ probing during kernel initialization. They are
|
|
|
|
* reasonably simple to use, are not "fooled" by spurious interrupts,
|
|
|
|
* and, unlike other attempts at IRQ probing, they do not get hung on
|
|
|
|
* stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards).
|
|
|
|
*
|
|
|
|
* For reasonably foolproof probing, use them as follows:
|
|
|
|
*
|
|
|
|
* 1. clear and/or mask the device's internal interrupt.
|
|
|
|
* 2. sti();
|
|
|
|
* 3. irqs = probe_irq_on(); // "take over" all unassigned idle IRQs
|
|
|
|
* 4. enable the device and cause it to trigger an interrupt.
|
|
|
|
* 5. wait for the device to interrupt, using non-intrusive polling or a delay.
|
|
|
|
* 6. irq = probe_irq_off(irqs); // get IRQ number, 0=none, negative=multiple
|
|
|
|
* 7. service the device to clear its pending interrupt.
|
|
|
|
* 8. loop again if paranoia is required.
|
|
|
|
*
|
|
|
|
* probe_irq_on() returns a mask of allocated irq's.
|
|
|
|
*
|
|
|
|
* probe_irq_off() takes the mask as a parameter,
|
|
|
|
* and returns the irq number which occurred,
|
|
|
|
* or zero if none occurred, or a negative irq number
|
|
|
|
* if more than one irq occurred.
|
|
|
|
*/
|
|
|
|
|
2013-08-30 07:39:53 +00:00
|
|
|
#if !defined(CONFIG_GENERIC_IRQ_PROBE)
|
2005-04-16 22:20:36 +00:00
|
|
|
static inline unsigned long probe_irq_on(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline int probe_irq_off(unsigned long val)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline unsigned int probe_irq_mask(unsigned long val)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
extern unsigned long probe_irq_on(void); /* returns 0 on failure */
|
|
|
|
extern int probe_irq_off(unsigned long); /* returns 0 or negative on failure */
|
|
|
|
extern unsigned int probe_irq_mask(unsigned long); /* returns mask of ISA interrupts */
|
|
|
|
#endif
|
|
|
|
|
2007-02-18 05:22:39 +00:00
|
|
|
#ifdef CONFIG_PROC_FS
|
|
|
|
/* Initialize /proc/irq/ */
|
|
|
|
extern void init_irq_proc(void);
|
|
|
|
#else
|
|
|
|
static inline void init_irq_proc(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-06-23 14:11:07 +00:00
|
|
|
#ifdef CONFIG_IRQ_TIMINGS
|
|
|
|
void irq_timings_enable(void);
|
|
|
|
void irq_timings_disable(void);
|
2017-06-23 14:11:08 +00:00
|
|
|
u64 irq_timings_next_event(u64 now);
|
2017-06-23 14:11:07 +00:00
|
|
|
#endif
|
|
|
|
|
2009-10-07 13:09:06 +00:00
|
|
|
struct seq_file;
|
2008-02-06 09:36:35 +00:00
|
|
|
int show_interrupts(struct seq_file *p, void *v);
|
2010-12-16 16:21:47 +00:00
|
|
|
int arch_show_interrupts(struct seq_file *p, int prec);
|
2008-02-06 09:36:35 +00:00
|
|
|
|
2008-12-29 00:01:13 +00:00
|
|
|
extern int early_irq_init(void);
|
2009-01-13 01:39:24 +00:00
|
|
|
extern int arch_probe_nr_irqs(void);
|
2008-12-29 00:01:13 +00:00
|
|
|
extern int arch_early_irq_init(void);
|
|
|
|
|
2016-03-25 21:22:05 +00:00
|
|
|
/*
|
|
|
|
* We want to know which function is an entrypoint of a hardirq or a softirq.
|
|
|
|
*/
|
2020-06-10 06:37:01 +00:00
|
|
|
#ifndef __irq_entry
|
2020-10-22 02:36:07 +00:00
|
|
|
# define __irq_entry __section(".irqentry.text")
|
2020-06-10 06:37:01 +00:00
|
|
|
#endif
|
|
|
|
|
2020-10-22 02:36:07 +00:00
|
|
|
#define __softirq_entry __section(".softirqentry.text")
|
2016-03-25 21:22:05 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|