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