multicalls.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef _XEN_MULTICALLS_H
  2. #define _XEN_MULTICALLS_H
  3. #include "xen-ops.h"
  4. /* Multicalls */
  5. struct multicall_space
  6. {
  7. struct multicall_entry *mc;
  8. void *args;
  9. };
  10. /* Allocate room for a multicall and its args */
  11. struct multicall_space __xen_mc_entry(size_t args);
  12. DECLARE_PER_CPU(unsigned long, xen_mc_irq_flags);
  13. /* Call to start a batch of multiple __xen_mc_entry()s. Must be
  14. paired with xen_mc_issue() */
  15. static inline void xen_mc_batch(void)
  16. {
  17. unsigned long flags;
  18. /* need to disable interrupts until this entry is complete */
  19. local_irq_save(flags);
  20. __this_cpu_write(xen_mc_irq_flags, flags);
  21. }
  22. static inline struct multicall_space xen_mc_entry(size_t args)
  23. {
  24. xen_mc_batch();
  25. return __xen_mc_entry(args);
  26. }
  27. /* Flush all pending multicalls */
  28. void xen_mc_flush(void);
  29. /* Issue a multicall if we're not in a lazy mode */
  30. static inline void xen_mc_issue(unsigned mode)
  31. {
  32. if ((paravirt_get_lazy_mode() & mode) == 0)
  33. xen_mc_flush();
  34. /* restore flags saved in xen_mc_batch */
  35. local_irq_restore(percpu_read(xen_mc_irq_flags));
  36. }
  37. /* Set up a callback to be called when the current batch is flushed */
  38. void xen_mc_callback(void (*fn)(void *), void *data);
  39. /*
  40. * Try to extend the arguments of the previous multicall command. The
  41. * previous command's op must match. If it does, then it attempts to
  42. * extend the argument space allocated to the multicall entry by
  43. * arg_size bytes.
  44. *
  45. * The returned multicall_space will return with mc pointing to the
  46. * command on success, or NULL on failure, and args pointing to the
  47. * newly allocated space.
  48. */
  49. struct multicall_space xen_mc_extend_args(unsigned long op, size_t arg_size);
  50. #endif /* _XEN_MULTICALLS_H */