multicalls.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. /* need to disable interrupts until this entry is complete */
  18. local_irq_save(__get_cpu_var(xen_mc_irq_flags));
  19. }
  20. static inline struct multicall_space xen_mc_entry(size_t args)
  21. {
  22. xen_mc_batch();
  23. return __xen_mc_entry(args);
  24. }
  25. /* Flush all pending multicalls */
  26. void xen_mc_flush(void);
  27. /* Issue a multicall if we're not in a lazy mode */
  28. static inline void xen_mc_issue(unsigned mode)
  29. {
  30. if ((paravirt_get_lazy_mode() & mode) == 0)
  31. xen_mc_flush();
  32. /* restore flags saved in xen_mc_batch */
  33. local_irq_restore(x86_read_percpu(xen_mc_irq_flags));
  34. }
  35. /* Set up a callback to be called when the current batch is flushed */
  36. void xen_mc_callback(void (*fn)(void *), void *data);
  37. /*
  38. * Try to extend the arguments of the previous multicall command. The
  39. * previous command's op must match. If it does, then it attempts to
  40. * extend the argument space allocated to the multicall entry by
  41. * arg_size bytes.
  42. *
  43. * The returned multicall_space will return with mc pointing to the
  44. * command on success, or NULL on failure, and args pointing to the
  45. * newly allocated space.
  46. */
  47. struct multicall_space xen_mc_extend_args(unsigned long op, size_t arg_size);
  48. #endif /* _XEN_MULTICALLS_H */