summaryrefslogtreecommitdiffstats
path: root/kernel/include/linux/rwlock_rt.h
blob: 49ed2d45d3be70540e7ad7064356dabd2b979af9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef __LINUX_RWLOCK_RT_H
#define __LINUX_RWLOCK_RT_H

#ifndef __LINUX_SPINLOCK_H
#error Do not include directly. Use spinlock.h
#endif

#define rwlock_init(rwl)				\
do {							\
	static struct lock_class_key __key;		\
							\
	rt_mutex_init(&(rwl)->lock);			\
	__rt_rwlock_init(rwl, #rwl, &__key);		\
} while (0)

extern void __lockfunc rt_write_lock(rwlock_t *rwlock);
extern void __lockfunc rt_read_lock(rwlock_t *rwlock);
extern int __lockfunc rt_write_trylock(rwlock_t *rwlock);
extern int __lockfunc rt_write_trylock_irqsave(rwlock_t *trylock, unsigned long *flags);
extern int __lockfunc rt_read_trylock(rwlock_t *rwlock);
extern void __lockfunc rt_write_unlock(rwlock_t *rwlock);
extern void __lockfunc rt_read_unlock(rwlock_t *rwlock);
extern unsigned long __lockfunc rt_write_lock_irqsave(rwlock_t *rwlock);
extern unsigned long __lockfunc rt_read_lock_irqsave(rwlock_t *rwlock);
extern void __rt_rwlock_init(rwlock_t *rwlock, char *name, struct lock_class_key *key);

#define read_trylock(lock)	__cond_lock(lock, rt_read_trylock(lock))
#define write_trylock(lock)	__cond_lock(lock, rt_write_trylock(lock))

#define write_trylock_irqsave(lock, flags)	\
	__cond_lock(lock, rt_write_trylock_irqsave(lock, &flags))

#define read_lock_irqsave(lock, flags)			\
	do {						\
		typecheck(unsigned long, flags);	\
		flags = rt_read_lock_irqsave(lock);	\
	} while (0)

#define write_lock_irqsave(lock, flags)			\
	do {						\
		typecheck(unsigned long, flags);	\
		flags = rt_write_lock_irqsave(lock);	\
	} while (0)

#define read_lock(lock)		rt_read_lock(lock)

#define read_lock_bh(lock)				\
	do {						\
		local_bh_disable();			\
		rt_read_lock(lock);			\
	} while (0)

#define read_lock_irq(lock)	read_lock(lock)

#define write_lock(lock)	rt_write_lock(lock)

#define write_lock_bh(lock)				\
	do {						\
		local_bh_disable();			\
		rt_write_lock(lock);			\
	} while (0)

#define write_lock_irq(lock)	write_lock(lock)

#define read_unlock(lock)	rt_read_unlock(lock)

#define read_unlock_bh(lock)				\
	do {						\
		rt_read_unlock(lock);			\
		local_bh_enable();			\
	} while (0)

#define read_unlock_irq(lock)	read_unlock(lock)

#define write_unlock(lock)	rt_write_unlock(lock)

#define write_unlock_bh(lock)				\
	do {						\
		rt_write_unlock(lock);			\
		local_bh_enable();			\
	} while (0)

#define write_unlock_irq(lock)	write_unlock(lock)

#define read_unlock_irqrestore(lock, flags)		\
	do {						\
		typecheck(unsigned long, flags);	\
		(void) flags;				\
		rt_read_unlock(lock);			\
	} while (0)

#define write_unlock_irqrestore(lock, flags) \
	do {						\
		typecheck(unsigned long, flags);	\
		(void) flags;				\
		rt_write_unlock(lock);			\
	} while (0)

#endif
low_handler; #endif struct irqaction *action; /* IRQ action list */ unsigned int status_use_accessors; unsigned int core_internal_state__do_not_mess_with_it; unsigned int depth; /* nested irq disables */ unsigned int wake_depth; /* nested wake enables */ unsigned int irq_count; /* For detecting broken IRQs */ unsigned long last_unhandled; /* Aging timer for unhandled count */ unsigned int irqs_unhandled; atomic_t threads_handled; int threads_handled_last; u64 random_ip; raw_spinlock_t lock; struct cpumask *percpu_enabled; #ifdef CONFIG_SMP const struct cpumask *affinity_hint; struct irq_affinity_notify *affinity_notify; #ifdef CONFIG_GENERIC_PENDING_IRQ cpumask_var_t pending_mask; #endif #endif unsigned long threads_oneshot; atomic_t threads_active; wait_queue_head_t wait_for_threads; #ifdef CONFIG_PM_SLEEP unsigned int nr_actions; unsigned int no_suspend_depth; unsigned int cond_suspend_depth; unsigned int force_resume_depth; #endif #ifdef CONFIG_PROC_FS struct proc_dir_entry *dir; #endif int parent_irq; struct module *owner; const char *name; } ____cacheline_internodealigned_in_smp; #ifndef CONFIG_SPARSE_IRQ extern struct irq_desc irq_desc[NR_IRQS]; #endif static inline struct irq_data *irq_desc_get_irq_data(struct irq_desc *desc) { return &desc->irq_data; } static inline struct irq_chip *irq_desc_get_chip(struct irq_desc *desc) { return desc->irq_data.chip; } static inline void *irq_desc_get_chip_data(struct irq_desc *desc) { return desc->irq_data.chip_data; } static inline void *irq_desc_get_handler_data(struct irq_desc *desc) { return desc->irq_data.handler_data; } static inline struct msi_desc *irq_desc_get_msi_desc(struct irq_desc *desc) { return desc->irq_data.msi_desc; } /* * Architectures call this to let the generic IRQ layer * handle an interrupt. If the descriptor is attached to an * irqchip-style controller then we call the ->handle_irq() handler, * and it calls __do_IRQ() if it's attached to an irqtype-style controller. */ static inline void generic_handle_irq_desc(unsigned int irq, struct irq_desc *desc) { desc->handle_irq(irq, desc); } int generic_handle_irq(unsigned int irq); #ifdef CONFIG_HANDLE_DOMAIN_IRQ /* * Convert a HW interrupt number to a logical one using a IRQ domain, * and handle the result interrupt number. Return -EINVAL if * conversion failed. Providing a NULL domain indicates that the * conversion has already been done. */ int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq, bool lookup, struct pt_regs *regs); static inline int handle_domain_irq(struct irq_domain *domain, unsigned int hwirq, struct pt_regs *regs) { return __handle_domain_irq(domain, hwirq, true, regs); } #endif /* Test to see if a driver has successfully requested an irq */ static inline int irq_has_action(unsigned int irq) { struct irq_desc *desc = irq_to_desc(irq); return desc->action != NULL; } /* caller has locked the irq_desc and both params are valid */ static inline void __irq_set_handler_locked(unsigned int irq, irq_flow_handler_t handler) { struct irq_desc *desc; desc = irq_to_desc(irq); desc->handle_irq = handler; } /* caller has locked the irq_desc and both params are valid */ static inline void __irq_set_chip_handler_name_locked(unsigned int irq, struct irq_chip *chip, irq_flow_handler_t handler, const char *name) { struct irq_desc *desc; desc = irq_to_desc(irq); irq_desc_get_irq_data(desc)->chip = chip; desc->handle_irq = handler; desc->name = name; } static inline int irq_balancing_disabled(unsigned int irq) { struct irq_desc *desc; desc = irq_to_desc(irq); return desc->status_use_accessors & IRQ_NO_BALANCING_MASK; } static inline int irq_is_percpu(unsigned int irq) { struct irq_desc *desc; desc = irq_to_desc(irq); return desc->status_use_accessors & IRQ_PER_CPU; } static inline void irq_set_lockdep_class(unsigned int irq, struct lock_class_key *class) { struct irq_desc *desc = irq_to_desc(irq); if (desc) lockdep_set_class(&desc->lock, class); } #ifdef CONFIG_IRQ_PREFLOW_FASTEOI static inline void __irq_set_preflow_handler(unsigned int irq, irq_preflow_handler_t handler) { struct irq_desc *desc; desc = irq_to_desc(irq); desc->preflow_handler = handler; } #endif #endif