airq.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * drivers/s390/cio/airq.c
  3. * S/390 common I/O routines -- support for adapter interruptions
  4. *
  5. * $Revision: 1.12 $
  6. *
  7. * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
  8. * IBM Corporation
  9. * Author(s): Ingo Adlung (adlung@de.ibm.com)
  10. * Cornelia Huck (cohuck@de.ibm.com)
  11. * Arnd Bergmann (arndb@de.ibm.com)
  12. */
  13. #include <linux/init.h>
  14. #include <linux/module.h>
  15. #include <linux/slab.h>
  16. #include <linux/rcupdate.h>
  17. #include "cio_debug.h"
  18. #include "airq.h"
  19. static adapter_int_handler_t adapter_handler;
  20. /*
  21. * register for adapter interrupts
  22. *
  23. * With HiperSockets the zSeries architecture provides for
  24. * means of adapter interrups, pseudo I/O interrupts that are
  25. * not tied to an I/O subchannel, but to an adapter. However,
  26. * it doesn't disclose the info how to enable/disable them, but
  27. * to recognize them only. Perhaps we should consider them
  28. * being shared interrupts, and thus build a linked list
  29. * of adapter handlers ... to be evaluated ...
  30. */
  31. int
  32. s390_register_adapter_interrupt (adapter_int_handler_t handler)
  33. {
  34. int ret;
  35. char dbf_txt[15];
  36. CIO_TRACE_EVENT (4, "rgaint");
  37. if (handler == NULL)
  38. ret = -EINVAL;
  39. else
  40. ret = (cmpxchg(&adapter_handler, NULL, handler) ? -EBUSY : 0);
  41. if (!ret)
  42. synchronize_sched(); /* Allow interrupts to complete. */
  43. sprintf (dbf_txt, "ret:%d", ret);
  44. CIO_TRACE_EVENT (4, dbf_txt);
  45. return ret;
  46. }
  47. int
  48. s390_unregister_adapter_interrupt (adapter_int_handler_t handler)
  49. {
  50. int ret;
  51. char dbf_txt[15];
  52. CIO_TRACE_EVENT (4, "urgaint");
  53. if (handler == NULL)
  54. ret = -EINVAL;
  55. else {
  56. adapter_handler = NULL;
  57. synchronize_sched(); /* Allow interrupts to complete. */
  58. ret = 0;
  59. }
  60. sprintf (dbf_txt, "ret:%d", ret);
  61. CIO_TRACE_EVENT (4, dbf_txt);
  62. return ret;
  63. }
  64. void
  65. do_adapter_IO (void)
  66. {
  67. CIO_TRACE_EVENT (6, "doaio");
  68. if (adapter_handler)
  69. (*adapter_handler) ();
  70. }
  71. EXPORT_SYMBOL (s390_register_adapter_interrupt);
  72. EXPORT_SYMBOL (s390_unregister_adapter_interrupt);