accel-blocker.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Accelerator blocking API, to prevent new ioctls from starting and wait the
  3. * running ones finish.
  4. * This mechanism differs from pause/resume_all_vcpus() in that it does not
  5. * release the BQL.
  6. *
  7. * Copyright (c) 2022 Red Hat Inc.
  8. *
  9. * Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
  10. *
  11. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  12. * See the COPYING file in the top-level directory.
  13. */
  14. #ifndef ACCEL_BLOCKER_H
  15. #define ACCEL_BLOCKER_H
  16. #include "system/cpus.h"
  17. void accel_blocker_init(void);
  18. /*
  19. * accel_{cpu_}ioctl_begin/end:
  20. * Mark when ioctl is about to run or just finished.
  21. *
  22. * accel_{cpu_}ioctl_begin will block after accel_ioctl_inhibit_begin() is
  23. * called, preventing new ioctls to run. They will continue only after
  24. * accel_ioctl_inibith_end().
  25. */
  26. void accel_ioctl_begin(void);
  27. void accel_ioctl_end(void);
  28. void accel_cpu_ioctl_begin(CPUState *cpu);
  29. void accel_cpu_ioctl_end(CPUState *cpu);
  30. /*
  31. * accel_ioctl_inhibit_begin: start critical section
  32. *
  33. * This function makes sure that:
  34. * 1) incoming accel_{cpu_}ioctl_begin() calls block
  35. * 2) wait that all ioctls that were already running reach
  36. * accel_{cpu_}ioctl_end(), kicking vcpus if necessary.
  37. *
  38. * This allows the caller to access shared data or perform operations without
  39. * worrying of concurrent vcpus accesses.
  40. */
  41. void accel_ioctl_inhibit_begin(void);
  42. /*
  43. * accel_ioctl_inhibit_end: end critical section started by
  44. * accel_ioctl_inhibit_begin()
  45. *
  46. * This function allows blocked accel_{cpu_}ioctl_begin() to continue.
  47. */
  48. void accel_ioctl_inhibit_end(void);
  49. #endif /* ACCEL_BLOCKER_H */