Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 1 | #ifndef _XEN_MULTICALLS_H |
| 2 | #define _XEN_MULTICALLS_H |
| 3 | |
| 4 | #include "xen-ops.h" |
| 5 | |
| 6 | /* Multicalls */ |
| 7 | struct multicall_space |
| 8 | { |
| 9 | struct multicall_entry *mc; |
| 10 | void *args; |
| 11 | }; |
| 12 | |
| 13 | /* Allocate room for a multicall and its args */ |
| 14 | struct multicall_space __xen_mc_entry(size_t args); |
| 15 | |
| 16 | DECLARE_PER_CPU(unsigned long, xen_mc_irq_flags); |
| 17 | |
| 18 | /* Call to start a batch of multiple __xen_mc_entry()s. Must be |
| 19 | paired with xen_mc_issue() */ |
| 20 | static inline void xen_mc_batch(void) |
| 21 | { |
Jeremy Fitzhardinge | 06fc732 | 2009-02-03 16:01:46 -0800 | [diff] [blame] | 22 | unsigned long flags; |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 23 | /* need to disable interrupts until this entry is complete */ |
Jeremy Fitzhardinge | 06fc732 | 2009-02-03 16:01:46 -0800 | [diff] [blame] | 24 | local_irq_save(flags); |
| 25 | __get_cpu_var(xen_mc_irq_flags) = flags; |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | static inline struct multicall_space xen_mc_entry(size_t args) |
| 29 | { |
| 30 | xen_mc_batch(); |
| 31 | return __xen_mc_entry(args); |
| 32 | } |
| 33 | |
| 34 | /* Flush all pending multicalls */ |
| 35 | void xen_mc_flush(void); |
| 36 | |
| 37 | /* Issue a multicall if we're not in a lazy mode */ |
| 38 | static inline void xen_mc_issue(unsigned mode) |
| 39 | { |
Jeremy Fitzhardinge | 8965c1c | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 40 | if ((paravirt_get_lazy_mode() & mode) == 0) |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 41 | xen_mc_flush(); |
| 42 | |
| 43 | /* restore flags saved in xen_mc_batch */ |
Ingo Molnar | 6dbde35 | 2009-01-15 22:15:53 +0900 | [diff] [blame] | 44 | local_irq_restore(percpu_read(xen_mc_irq_flags)); |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 45 | } |
| 46 | |
Jeremy Fitzhardinge | 91e0c5f | 2007-10-16 11:51:30 -0700 | [diff] [blame] | 47 | /* Set up a callback to be called when the current batch is flushed */ |
| 48 | void xen_mc_callback(void (*fn)(void *), void *data); |
| 49 | |
Jeremy Fitzhardinge | 400d349 | 2008-06-16 04:30:03 -0700 | [diff] [blame] | 50 | /* |
| 51 | * Try to extend the arguments of the previous multicall command. The |
| 52 | * previous command's op must match. If it does, then it attempts to |
| 53 | * extend the argument space allocated to the multicall entry by |
| 54 | * arg_size bytes. |
| 55 | * |
| 56 | * The returned multicall_space will return with mc pointing to the |
| 57 | * command on success, or NULL on failure, and args pointing to the |
| 58 | * newly allocated space. |
| 59 | */ |
| 60 | struct multicall_space xen_mc_extend_args(unsigned long op, size_t arg_size); |
| 61 | |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 62 | #endif /* _XEN_MULTICALLS_H */ |