Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _XEN_MULTICALLS_H
0003 #define _XEN_MULTICALLS_H
0004 
0005 #include <trace/events/xen.h>
0006 
0007 #include "xen-ops.h"
0008 
0009 /* Multicalls */
0010 struct multicall_space
0011 {
0012     struct multicall_entry *mc;
0013     void *args;
0014 };
0015 
0016 /* Allocate room for a multicall and its args */
0017 struct multicall_space __xen_mc_entry(size_t args);
0018 
0019 DECLARE_PER_CPU(unsigned long, xen_mc_irq_flags);
0020 
0021 /* Call to start a batch of multiple __xen_mc_entry()s.  Must be
0022    paired with xen_mc_issue() */
0023 static inline void xen_mc_batch(void)
0024 {
0025     unsigned long flags;
0026 
0027     /* need to disable interrupts until this entry is complete */
0028     local_irq_save(flags);
0029     trace_xen_mc_batch(paravirt_get_lazy_mode());
0030     __this_cpu_write(xen_mc_irq_flags, flags);
0031 }
0032 
0033 static inline struct multicall_space xen_mc_entry(size_t args)
0034 {
0035     xen_mc_batch();
0036     return __xen_mc_entry(args);
0037 }
0038 
0039 /* Flush all pending multicalls */
0040 void xen_mc_flush(void);
0041 
0042 /* Issue a multicall if we're not in a lazy mode */
0043 static inline void xen_mc_issue(unsigned mode)
0044 {
0045     trace_xen_mc_issue(mode);
0046 
0047     if ((paravirt_get_lazy_mode() & mode) == 0)
0048         xen_mc_flush();
0049 
0050     /* restore flags saved in xen_mc_batch */
0051     local_irq_restore(this_cpu_read(xen_mc_irq_flags));
0052 }
0053 
0054 /* Set up a callback to be called when the current batch is flushed */
0055 void xen_mc_callback(void (*fn)(void *), void *data);
0056 
0057 /*
0058  * Try to extend the arguments of the previous multicall command.  The
0059  * previous command's op must match.  If it does, then it attempts to
0060  * extend the argument space allocated to the multicall entry by
0061  * arg_size bytes.
0062  *
0063  * The returned multicall_space will return with mc pointing to the
0064  * command on success, or NULL on failure, and args pointing to the
0065  * newly allocated space.
0066  */
0067 struct multicall_space xen_mc_extend_args(unsigned long op, size_t arg_size);
0068 
0069 #endif /* _XEN_MULTICALLS_H */