airq.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright IBM Corp. 2002, 2007
  4. * Author(s): Ingo Adlung <[email protected]>
  5. * Cornelia Huck <[email protected]>
  6. * Arnd Bergmann <[email protected]>
  7. * Peter Oberparleiter <[email protected]>
  8. */
  9. #ifndef _ASM_S390_AIRQ_H
  10. #define _ASM_S390_AIRQ_H
  11. #include <linux/bit_spinlock.h>
  12. #include <linux/dma-mapping.h>
  13. #include <asm/tpi.h>
  14. struct airq_struct {
  15. struct hlist_node list; /* Handler queueing. */
  16. void (*handler)(struct airq_struct *airq, struct tpi_info *tpi_info);
  17. u8 *lsi_ptr; /* Local-Summary-Indicator pointer */
  18. u8 lsi_mask; /* Local-Summary-Indicator mask */
  19. u8 isc; /* Interrupt-subclass */
  20. u8 flags;
  21. };
  22. #define AIRQ_PTR_ALLOCATED 0x01
  23. int register_adapter_interrupt(struct airq_struct *airq);
  24. void unregister_adapter_interrupt(struct airq_struct *airq);
  25. /* Adapter interrupt bit vector */
  26. struct airq_iv {
  27. unsigned long *vector; /* Adapter interrupt bit vector */
  28. dma_addr_t vector_dma; /* Adapter interrupt bit vector dma */
  29. unsigned long *avail; /* Allocation bit mask for the bit vector */
  30. unsigned long *bitlock; /* Lock bit mask for the bit vector */
  31. unsigned long *ptr; /* Pointer associated with each bit */
  32. unsigned int *data; /* 32 bit value associated with each bit */
  33. unsigned long bits; /* Number of bits in the vector */
  34. unsigned long end; /* Number of highest allocated bit + 1 */
  35. unsigned long flags; /* Allocation flags */
  36. spinlock_t lock; /* Lock to protect alloc & free */
  37. };
  38. #define AIRQ_IV_ALLOC 1 /* Use an allocation bit mask */
  39. #define AIRQ_IV_BITLOCK 2 /* Allocate the lock bit mask */
  40. #define AIRQ_IV_PTR 4 /* Allocate the ptr array */
  41. #define AIRQ_IV_DATA 8 /* Allocate the data array */
  42. #define AIRQ_IV_CACHELINE 16 /* Cacheline alignment for the vector */
  43. #define AIRQ_IV_GUESTVEC 32 /* Vector is a pinned guest page */
  44. struct airq_iv *airq_iv_create(unsigned long bits, unsigned long flags,
  45. unsigned long *vec);
  46. void airq_iv_release(struct airq_iv *iv);
  47. unsigned long airq_iv_alloc(struct airq_iv *iv, unsigned long num);
  48. void airq_iv_free(struct airq_iv *iv, unsigned long bit, unsigned long num);
  49. unsigned long airq_iv_scan(struct airq_iv *iv, unsigned long start,
  50. unsigned long end);
  51. static inline unsigned long airq_iv_alloc_bit(struct airq_iv *iv)
  52. {
  53. return airq_iv_alloc(iv, 1);
  54. }
  55. static inline void airq_iv_free_bit(struct airq_iv *iv, unsigned long bit)
  56. {
  57. airq_iv_free(iv, bit, 1);
  58. }
  59. static inline unsigned long airq_iv_end(struct airq_iv *iv)
  60. {
  61. return iv->end;
  62. }
  63. static inline void airq_iv_lock(struct airq_iv *iv, unsigned long bit)
  64. {
  65. const unsigned long be_to_le = BITS_PER_LONG - 1;
  66. bit_spin_lock(bit ^ be_to_le, iv->bitlock);
  67. }
  68. static inline void airq_iv_unlock(struct airq_iv *iv, unsigned long bit)
  69. {
  70. const unsigned long be_to_le = BITS_PER_LONG - 1;
  71. bit_spin_unlock(bit ^ be_to_le, iv->bitlock);
  72. }
  73. static inline void airq_iv_set_data(struct airq_iv *iv, unsigned long bit,
  74. unsigned int data)
  75. {
  76. iv->data[bit] = data;
  77. }
  78. static inline unsigned int airq_iv_get_data(struct airq_iv *iv,
  79. unsigned long bit)
  80. {
  81. return iv->data[bit];
  82. }
  83. static inline void airq_iv_set_ptr(struct airq_iv *iv, unsigned long bit,
  84. unsigned long ptr)
  85. {
  86. iv->ptr[bit] = ptr;
  87. }
  88. static inline unsigned long airq_iv_get_ptr(struct airq_iv *iv,
  89. unsigned long bit)
  90. {
  91. return iv->ptr[bit];
  92. }
  93. #endif /* _ASM_S390_AIRQ_H */