Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / s390 / include / asm / airq.h
blobfcf539efb32fb802d7c46030bda0a74c8df77639
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright IBM Corp. 2002, 2007
4 * Author(s): Ingo Adlung <adlung@de.ibm.com>
5 * Cornelia Huck <cornelia.huck@de.ibm.com>
6 * Arnd Bergmann <arndb@de.ibm.com>
7 * Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
8 */
10 #ifndef _ASM_S390_AIRQ_H
11 #define _ASM_S390_AIRQ_H
13 #include <linux/bit_spinlock.h>
15 struct airq_struct {
16 struct hlist_node list; /* Handler queueing. */
17 void (*handler)(struct airq_struct *); /* Thin-interrupt handler */
18 u8 *lsi_ptr; /* Local-Summary-Indicator pointer */
19 u8 lsi_mask; /* Local-Summary-Indicator mask */
20 u8 isc; /* Interrupt-subclass */
21 u8 flags;
24 #define AIRQ_PTR_ALLOCATED 0x01
26 int register_adapter_interrupt(struct airq_struct *airq);
27 void unregister_adapter_interrupt(struct airq_struct *airq);
29 /* Adapter interrupt bit vector */
30 struct airq_iv {
31 unsigned long *vector; /* Adapter interrupt bit vector */
32 unsigned long *avail; /* Allocation bit mask for the bit vector */
33 unsigned long *bitlock; /* Lock bit mask for the bit vector */
34 unsigned long *ptr; /* Pointer associated with each bit */
35 unsigned int *data; /* 32 bit value associated with each bit */
36 unsigned long bits; /* Number of bits in the vector */
37 unsigned long end; /* Number of highest allocated bit + 1 */
38 spinlock_t lock; /* Lock to protect alloc & free */
41 #define AIRQ_IV_ALLOC 1 /* Use an allocation bit mask */
42 #define AIRQ_IV_BITLOCK 2 /* Allocate the lock bit mask */
43 #define AIRQ_IV_PTR 4 /* Allocate the ptr array */
44 #define AIRQ_IV_DATA 8 /* Allocate the data array */
46 struct airq_iv *airq_iv_create(unsigned long bits, unsigned long flags);
47 void airq_iv_release(struct airq_iv *iv);
48 unsigned long airq_iv_alloc(struct airq_iv *iv, unsigned long num);
49 void airq_iv_free(struct airq_iv *iv, unsigned long bit, unsigned long num);
50 unsigned long airq_iv_scan(struct airq_iv *iv, unsigned long start,
51 unsigned long end);
53 static inline unsigned long airq_iv_alloc_bit(struct airq_iv *iv)
55 return airq_iv_alloc(iv, 1);
58 static inline void airq_iv_free_bit(struct airq_iv *iv, unsigned long bit)
60 airq_iv_free(iv, bit, 1);
63 static inline unsigned long airq_iv_end(struct airq_iv *iv)
65 return iv->end;
68 static inline void airq_iv_lock(struct airq_iv *iv, unsigned long bit)
70 const unsigned long be_to_le = BITS_PER_LONG - 1;
71 bit_spin_lock(bit ^ be_to_le, iv->bitlock);
74 static inline void airq_iv_unlock(struct airq_iv *iv, unsigned long bit)
76 const unsigned long be_to_le = BITS_PER_LONG - 1;
77 bit_spin_unlock(bit ^ be_to_le, iv->bitlock);
80 static inline void airq_iv_set_data(struct airq_iv *iv, unsigned long bit,
81 unsigned int data)
83 iv->data[bit] = data;
86 static inline unsigned int airq_iv_get_data(struct airq_iv *iv,
87 unsigned long bit)
89 return iv->data[bit];
92 static inline void airq_iv_set_ptr(struct airq_iv *iv, unsigned long bit,
93 unsigned long ptr)
95 iv->ptr[bit] = ptr;
98 static inline unsigned long airq_iv_get_ptr(struct airq_iv *iv,
99 unsigned long bit)
101 return iv->ptr[bit];
104 #endif /* _ASM_S390_AIRQ_H */