Skip to content

Commit 1f6e051

Browse files
committed
Merge branch 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
* 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: genirq: Add IRQF_RESUME_EARLY and resume such IRQs earlier genirq: Fix fatfinered fixup really genirq: percpu: allow interrupt type to be set at enable time genirq: Add support for per-cpu dev_id interrupts genirq: Add IRQCHIP_SKIP_SET_WAKE flag
2 parents 19b4a8d + 9bab0b7 commit 1f6e051

10 files changed

Lines changed: 408 additions & 42 deletions

File tree

‎drivers/xen/events.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,
10491049
if (irq < 0)
10501050
return irq;
10511051

1052-
irqflags |= IRQF_NO_SUSPEND | IRQF_FORCE_RESUME;
1052+
irqflags |= IRQF_NO_SUSPEND | IRQF_FORCE_RESUME | IRQF_EARLY_RESUME;
10531053
retval = request_irq(irq, handler, irqflags, devname, dev_id);
10541054
if (retval != 0) {
10551055
unbind_from_irq(irq);

‎include/linux/interrupt.h‎

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
* IRQF_NO_SUSPEND - Do not disable this IRQ during suspend
6060
* IRQF_FORCE_RESUME - Force enable it on resume even if IRQF_NO_SUSPEND is set
6161
* IRQF_NO_THREAD - Interrupt cannot be threaded
62+
* IRQF_EARLY_RESUME - Resume IRQ early during syscore instead of at device
63+
* resume time.
6264
*/
6365
#define IRQF_DISABLED 0x00000020
6466
#define IRQF_SAMPLE_RANDOM 0x00000040
@@ -72,6 +74,7 @@
7274
#define IRQF_NO_SUSPEND 0x00004000
7375
#define IRQF_FORCE_RESUME 0x00008000
7476
#define IRQF_NO_THREAD 0x00010000
77+
#define IRQF_EARLY_RESUME 0x00020000
7578

7679
#define IRQF_TIMER (__IRQF_TIMER | IRQF_NO_SUSPEND | IRQF_NO_THREAD)
7780

@@ -95,6 +98,7 @@ typedef irqreturn_t (*irq_handler_t)(int, void *);
9598
* @flags: flags (see IRQF_* above)
9699
* @name: name of the device
97100
* @dev_id: cookie to identify the device
101+
* @percpu_dev_id: cookie to identify the device
98102
* @next: pointer to the next irqaction for shared interrupts
99103
* @irq: interrupt number
100104
* @dir: pointer to the proc/irq/NN/name entry
@@ -104,17 +108,18 @@ typedef irqreturn_t (*irq_handler_t)(int, void *);
104108
* @thread_mask: bitmask for keeping track of @thread activity
105109
*/
106110
struct irqaction {
107-
irq_handler_t handler;
108-
unsigned long flags;
109-
void *dev_id;
110-
struct irqaction *next;
111-
int irq;
112-
irq_handler_t thread_fn;
113-
struct task_struct *thread;
114-
unsigned long thread_flags;
115-
unsigned long thread_mask;
116-
const char *name;
117-
struct proc_dir_entry *dir;
111+
irq_handler_t handler;
112+
unsigned long flags;
113+
void *dev_id;
114+
void __percpu *percpu_dev_id;
115+
struct irqaction *next;
116+
int irq;
117+
irq_handler_t thread_fn;
118+
struct task_struct *thread;
119+
unsigned long thread_flags;
120+
unsigned long thread_mask;
121+
const char *name;
122+
struct proc_dir_entry *dir;
118123
} ____cacheline_internodealigned_in_smp;
119124

120125
extern irqreturn_t no_action(int cpl, void *dev_id);
@@ -136,6 +141,10 @@ extern int __must_check
136141
request_any_context_irq(unsigned int irq, irq_handler_t handler,
137142
unsigned long flags, const char *name, void *dev_id);
138143

144+
extern int __must_check
145+
request_percpu_irq(unsigned int irq, irq_handler_t handler,
146+
const char *devname, void __percpu *percpu_dev_id);
147+
139148
extern void exit_irq_thread(void);
140149
#else
141150

@@ -164,10 +173,18 @@ request_any_context_irq(unsigned int irq, irq_handler_t handler,
164173
return request_irq(irq, handler, flags, name, dev_id);
165174
}
166175

176+
static inline int __must_check
177+
request_percpu_irq(unsigned int irq, irq_handler_t handler,
178+
const char *devname, void __percpu *percpu_dev_id)
179+
{
180+
return request_irq(irq, handler, 0, devname, percpu_dev_id);
181+
}
182+
167183
static inline void exit_irq_thread(void) { }
168184
#endif
169185

170186
extern void free_irq(unsigned int, void *);
187+
extern void free_percpu_irq(unsigned int, void __percpu *);
171188

172189
struct device;
173190

@@ -207,7 +224,9 @@ extern void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id);
207224

208225
extern void disable_irq_nosync(unsigned int irq);
209226
extern void disable_irq(unsigned int irq);
227+
extern void disable_percpu_irq(unsigned int irq);
210228
extern void enable_irq(unsigned int irq);
229+
extern void enable_percpu_irq(unsigned int irq, unsigned int type);
211230

212231
/* The following three functions are for the core kernel use only. */
213232
#ifdef CONFIG_GENERIC_HARDIRQS

‎include/linux/irq.h‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ typedef void (*irq_preflow_handler_t)(struct irq_data *data);
6666
* IRQ_NO_BALANCING - Interrupt cannot be balanced (affinity set)
6767
* IRQ_MOVE_PCNTXT - Interrupt can be migrated from process context
6868
* IRQ_NESTED_TRHEAD - Interrupt nests into another thread
69+
* IRQ_PER_CPU_DEVID - Dev_id is a per-cpu variable
6970
*/
7071
enum {
7172
IRQ_TYPE_NONE = 0x00000000,
@@ -88,12 +89,13 @@ enum {
8889
IRQ_MOVE_PCNTXT = (1 << 14),
8990
IRQ_NESTED_THREAD = (1 << 15),
9091
IRQ_NOTHREAD = (1 << 16),
92+
IRQ_PER_CPU_DEVID = (1 << 17),
9193
};
9294

9395
#define IRQF_MODIFY_MASK \
9496
(IRQ_TYPE_SENSE_MASK | IRQ_NOPROBE | IRQ_NOREQUEST | \
9597
IRQ_NOAUTOEN | IRQ_MOVE_PCNTXT | IRQ_LEVEL | IRQ_NO_BALANCING | \
96-
IRQ_PER_CPU | IRQ_NESTED_THREAD)
98+
IRQ_PER_CPU | IRQ_NESTED_THREAD | IRQ_NOTHREAD | IRQ_PER_CPU_DEVID)
9799

98100
#define IRQ_NO_BALANCING_MASK (IRQ_PER_CPU | IRQ_NO_BALANCING)
99101

@@ -336,12 +338,14 @@ struct irq_chip {
336338
* IRQCHIP_MASK_ON_SUSPEND: Mask non wake irqs in the suspend path
337339
* IRQCHIP_ONOFFLINE_ENABLED: Only call irq_on/off_line callbacks
338340
* when irq enabled
341+
* IRQCHIP_SKIP_SET_WAKE: Skip chip.irq_set_wake(), for this irq chip
339342
*/
340343
enum {
341344
IRQCHIP_SET_TYPE_MASKED = (1 << 0),
342345
IRQCHIP_EOI_IF_HANDLED = (1 << 1),
343346
IRQCHIP_MASK_ON_SUSPEND = (1 << 2),
344347
IRQCHIP_ONOFFLINE_ENABLED = (1 << 3),
348+
IRQCHIP_SKIP_SET_WAKE = (1 << 4),
345349
};
346350

347351
/* This include will go away once we isolated irq_desc usage to core code */
@@ -365,6 +369,8 @@ enum {
365369
struct irqaction;
366370
extern int setup_irq(unsigned int irq, struct irqaction *new);
367371
extern void remove_irq(unsigned int irq, struct irqaction *act);
372+
extern int setup_percpu_irq(unsigned int irq, struct irqaction *new);
373+
extern void remove_percpu_irq(unsigned int irq, struct irqaction *act);
368374

369375
extern void irq_cpu_online(void);
370376
extern void irq_cpu_offline(void);
@@ -392,6 +398,7 @@ extern void handle_edge_irq(unsigned int irq, struct irq_desc *desc);
392398
extern void handle_edge_eoi_irq(unsigned int irq, struct irq_desc *desc);
393399
extern void handle_simple_irq(unsigned int irq, struct irq_desc *desc);
394400
extern void handle_percpu_irq(unsigned int irq, struct irq_desc *desc);
401+
extern void handle_percpu_devid_irq(unsigned int irq, struct irq_desc *desc);
395402
extern void handle_bad_irq(unsigned int irq, struct irq_desc *desc);
396403
extern void handle_nested_irq(unsigned int irq);
397404

@@ -420,6 +427,8 @@ static inline void irq_set_chip_and_handler(unsigned int irq, struct irq_chip *c
420427
irq_set_chip_and_handler_name(irq, chip, handle, NULL);
421428
}
422429

430+
extern int irq_set_percpu_devid(unsigned int irq);
431+
423432
extern void
424433
__irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
425434
const char *name);
@@ -481,6 +490,13 @@ static inline void irq_set_nested_thread(unsigned int irq, bool nest)
481490
irq_clear_status_flags(irq, IRQ_NESTED_THREAD);
482491
}
483492

493+
static inline void irq_set_percpu_devid_flags(unsigned int irq)
494+
{
495+
irq_set_status_flags(irq,
496+
IRQ_NOAUTOEN | IRQ_PER_CPU | IRQ_NOTHREAD |
497+
IRQ_NOPROBE | IRQ_PER_CPU_DEVID);
498+
}
499+
484500
/* Handle dynamic irq creation and destruction */
485501
extern unsigned int create_irq_nr(unsigned int irq_want, int node);
486502
extern int create_irq(void);

‎include/linux/irqdesc.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct irq_desc {
5353
unsigned long last_unhandled; /* Aging timer for unhandled count */
5454
unsigned int irqs_unhandled;
5555
raw_spinlock_t lock;
56+
struct cpumask *percpu_enabled;
5657
#ifdef CONFIG_SMP
5758
const struct cpumask *affinity_hint;
5859
struct irq_affinity_notify *affinity_notify;

‎kernel/irq/chip.c‎

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
int irq_set_chip(unsigned int irq, struct irq_chip *chip)
2727
{
2828
unsigned long flags;
29-
struct irq_desc *desc = irq_get_desc_lock(irq, &flags);
29+
struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
3030

3131
if (!desc)
3232
return -EINVAL;
@@ -54,7 +54,7 @@ EXPORT_SYMBOL(irq_set_chip);
5454
int irq_set_irq_type(unsigned int irq, unsigned int type)
5555
{
5656
unsigned long flags;
57-
struct irq_desc *desc = irq_get_desc_buslock(irq, &flags);
57+
struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
5858
int ret = 0;
5959

6060
if (!desc)
@@ -78,7 +78,7 @@ EXPORT_SYMBOL(irq_set_irq_type);
7878
int irq_set_handler_data(unsigned int irq, void *data)
7979
{
8080
unsigned long flags;
81-
struct irq_desc *desc = irq_get_desc_lock(irq, &flags);
81+
struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
8282

8383
if (!desc)
8484
return -EINVAL;
@@ -98,7 +98,7 @@ EXPORT_SYMBOL(irq_set_handler_data);
9898
int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
9999
{
100100
unsigned long flags;
101-
struct irq_desc *desc = irq_get_desc_lock(irq, &flags);
101+
struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
102102

103103
if (!desc)
104104
return -EINVAL;
@@ -119,7 +119,7 @@ int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
119119
int irq_set_chip_data(unsigned int irq, void *data)
120120
{
121121
unsigned long flags;
122-
struct irq_desc *desc = irq_get_desc_lock(irq, &flags);
122+
struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
123123

124124
if (!desc)
125125
return -EINVAL;
@@ -204,6 +204,24 @@ void irq_disable(struct irq_desc *desc)
204204
}
205205
}
206206

207+
void irq_percpu_enable(struct irq_desc *desc, unsigned int cpu)
208+
{
209+
if (desc->irq_data.chip->irq_enable)
210+
desc->irq_data.chip->irq_enable(&desc->irq_data);
211+
else
212+
desc->irq_data.chip->irq_unmask(&desc->irq_data);
213+
cpumask_set_cpu(cpu, desc->percpu_enabled);
214+
}
215+
216+
void irq_percpu_disable(struct irq_desc *desc, unsigned int cpu)
217+
{
218+
if (desc->irq_data.chip->irq_disable)
219+
desc->irq_data.chip->irq_disable(&desc->irq_data);
220+
else
221+
desc->irq_data.chip->irq_mask(&desc->irq_data);
222+
cpumask_clear_cpu(cpu, desc->percpu_enabled);
223+
}
224+
207225
static inline void mask_ack_irq(struct irq_desc *desc)
208226
{
209227
if (desc->irq_data.chip->irq_mask_ack)
@@ -544,12 +562,44 @@ handle_percpu_irq(unsigned int irq, struct irq_desc *desc)
544562
chip->irq_eoi(&desc->irq_data);
545563
}
546564

565+
/**
566+
* handle_percpu_devid_irq - Per CPU local irq handler with per cpu dev ids
567+
* @irq: the interrupt number
568+
* @desc: the interrupt description structure for this irq
569+
*
570+
* Per CPU interrupts on SMP machines without locking requirements. Same as
571+
* handle_percpu_irq() above but with the following extras:
572+
*
573+
* action->percpu_dev_id is a pointer to percpu variables which
574+
* contain the real device id for the cpu on which this handler is
575+
* called
576+
*/
577+
void handle_percpu_devid_irq(unsigned int irq, struct irq_desc *desc)
578+
{
579+
struct irq_chip *chip = irq_desc_get_chip(desc);
580+
struct irqaction *action = desc->action;
581+
void *dev_id = __this_cpu_ptr(action->percpu_dev_id);
582+
irqreturn_t res;
583+
584+
kstat_incr_irqs_this_cpu(irq, desc);
585+
586+
if (chip->irq_ack)
587+
chip->irq_ack(&desc->irq_data);
588+
589+
trace_irq_handler_entry(irq, action);
590+
res = action->handler(irq, dev_id);
591+
trace_irq_handler_exit(irq, action, res);
592+
593+
if (chip->irq_eoi)
594+
chip->irq_eoi(&desc->irq_data);
595+
}
596+
547597
void
548598
__irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
549599
const char *name)
550600
{
551601
unsigned long flags;
552-
struct irq_desc *desc = irq_get_desc_buslock(irq, &flags);
602+
struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, 0);
553603

554604
if (!desc)
555605
return;
@@ -593,7 +643,7 @@ irq_set_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
593643
void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
594644
{
595645
unsigned long flags;
596-
struct irq_desc *desc = irq_get_desc_lock(irq, &flags);
646+
struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
597647

598648
if (!desc)
599649
return;

‎kernel/irq/internals.h‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ extern int irq_startup(struct irq_desc *desc);
7171
extern void irq_shutdown(struct irq_desc *desc);
7272
extern void irq_enable(struct irq_desc *desc);
7373
extern void irq_disable(struct irq_desc *desc);
74+
extern void irq_percpu_enable(struct irq_desc *desc, unsigned int cpu);
75+
extern void irq_percpu_disable(struct irq_desc *desc, unsigned int cpu);
7476
extern void mask_irq(struct irq_desc *desc);
7577
extern void unmask_irq(struct irq_desc *desc);
7678

@@ -114,14 +116,21 @@ static inline void chip_bus_sync_unlock(struct irq_desc *desc)
114116
desc->irq_data.chip->irq_bus_sync_unlock(&desc->irq_data);
115117
}
116118

119+
#define _IRQ_DESC_CHECK (1 << 0)
120+
#define _IRQ_DESC_PERCPU (1 << 1)
121+
122+
#define IRQ_GET_DESC_CHECK_GLOBAL (_IRQ_DESC_CHECK)
123+
#define IRQ_GET_DESC_CHECK_PERCPU (_IRQ_DESC_CHECK | _IRQ_DESC_PERCPU)
124+
117125
struct irq_desc *
118-
__irq_get_desc_lock(unsigned int irq, unsigned long *flags, bool bus);
126+
__irq_get_desc_lock(unsigned int irq, unsigned long *flags, bool bus,
127+
unsigned int check);
119128
void __irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags, bool bus);
120129

121130
static inline struct irq_desc *
122-
irq_get_desc_buslock(unsigned int irq, unsigned long *flags)
131+
irq_get_desc_buslock(unsigned int irq, unsigned long *flags, unsigned int check)
123132
{
124-
return __irq_get_desc_lock(irq, flags, true);
133+
return __irq_get_desc_lock(irq, flags, true, check);
125134
}
126135

127136
static inline void
@@ -131,9 +140,9 @@ irq_put_desc_busunlock(struct irq_desc *desc, unsigned long flags)
131140
}
132141

133142
static inline struct irq_desc *
134-
irq_get_desc_lock(unsigned int irq, unsigned long *flags)
143+
irq_get_desc_lock(unsigned int irq, unsigned long *flags, unsigned int check)
135144
{
136-
return __irq_get_desc_lock(irq, flags, false);
145+
return __irq_get_desc_lock(irq, flags, false, check);
137146
}
138147

139148
static inline void

0 commit comments

Comments
 (0)