1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright IBM Corp. 2002, 2007
10 #ifndef _ASM_S390_AIRQ_H
11 #define _ASM_S390_AIRQ_H
13 #include <linux/bit_spinlock.h>
14 #include <linux/dma-mapping.h>
17 struct hlist_node list; /* Handler queueing. */
18 void (*handler)(struct airq_struct *airq, bool floating);
19 u8 *lsi_ptr; /* Local-Summary-Indicator pointer */
20 u8 lsi_mask; /* Local-Summary-Indicator mask */
21 u8 isc; /* Interrupt-subclass */
25 #define AIRQ_PTR_ALLOCATED 0x01
27 int register_adapter_interrupt(struct airq_struct *airq);
28 void unregister_adapter_interrupt(struct airq_struct *airq);
30 /* Adapter interrupt bit vector */
32 unsigned long *vector; /* Adapter interrupt bit vector */
33 dma_addr_t vector_dma; /* Adapter interrupt bit vector dma */
34 unsigned long *avail; /* Allocation bit mask for the bit vector */
35 unsigned long *bitlock; /* Lock bit mask for the bit vector */
36 unsigned long *ptr; /* Pointer associated with each bit */
37 unsigned int *data; /* 32 bit value associated with each bit */
38 unsigned long bits; /* Number of bits in the vector */
39 unsigned long end; /* Number of highest allocated bit + 1 */
40 unsigned long flags; /* Allocation flags */
41 spinlock_t lock; /* Lock to protect alloc & free */
44 #define AIRQ_IV_ALLOC 1 /* Use an allocation bit mask */
45 #define AIRQ_IV_BITLOCK 2 /* Allocate the lock bit mask */
46 #define AIRQ_IV_PTR 4 /* Allocate the ptr array */
47 #define AIRQ_IV_DATA 8 /* Allocate the data array */
48 #define AIRQ_IV_CACHELINE 16 /* Cacheline alignment for the vector */
50 struct airq_iv *airq_iv_create(unsigned long bits, unsigned long flags);
51 void airq_iv_release(struct airq_iv *iv);
52 unsigned long airq_iv_alloc(struct airq_iv *iv, unsigned long num);
53 void airq_iv_free(struct airq_iv *iv, unsigned long bit, unsigned long num);
54 unsigned long airq_iv_scan(struct airq_iv *iv, unsigned long start,
57 static inline unsigned long airq_iv_alloc_bit(struct airq_iv *iv)
59 return airq_iv_alloc(iv, 1);
62 static inline void airq_iv_free_bit(struct airq_iv *iv, unsigned long bit)
64 airq_iv_free(iv, bit, 1);
67 static inline unsigned long airq_iv_end(struct airq_iv *iv)
72 static inline void airq_iv_lock(struct airq_iv *iv, unsigned long bit)
74 const unsigned long be_to_le = BITS_PER_LONG - 1;
75 bit_spin_lock(bit ^ be_to_le, iv->bitlock);
78 static inline void airq_iv_unlock(struct airq_iv *iv, unsigned long bit)
80 const unsigned long be_to_le = BITS_PER_LONG - 1;
81 bit_spin_unlock(bit ^ be_to_le, iv->bitlock);
84 static inline void airq_iv_set_data(struct airq_iv *iv, unsigned long bit,
90 static inline unsigned int airq_iv_get_data(struct airq_iv *iv,
96 static inline void airq_iv_set_ptr(struct airq_iv *iv, unsigned long bit,
102 static inline unsigned long airq_iv_get_ptr(struct airq_iv *iv,
108 #endif /* _ASM_S390_AIRQ_H */