airq.c 1.9 KB

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