From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiaofeng Ling Subject: [PATCH][5/6] inject call back irq when there are event pending Date: Mon, 05 Sep 2005 18:41:26 +0800 Message-ID: <431C20D6.4060106@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Pratt , Keir Fraser Cc: xen-devel List-Id: xen-devel@lists.xenproject.org Inject call back irq when there are event pending. If there are still event pending after dealing with the device model evtchn, then these are for virtual device(ctrl_if, xenbus, blfront,etc) so inject the call back irq. The irq handler in event channel pci device will deliver the event to frontend driver. Signed-off-by: Xiaofeng Ling Signed-off-by: Arun Sharma diff -r 287d36b46fa3 xen/arch/x86/vmx_io.c --- a/xen/arch/x86/vmx_io.c Tue Aug 30 20:36:49 2005 +++ b/xen/arch/x86/vmx_io.c Fri Sep 2 22:46:13 2005 @@ -631,6 +631,51 @@ return ((eflags & X86_EFLAGS_IF) == 0); } +int vmx_event_to_irq(struct vcpu *v) +{ + + global_iodata_t *spg; + unsigned long callback_irq; + + spg = &get_sp(v->domain)->sp_global; + + callback_irq = v->domain->arch.vmx_platform.callback_irq; + if(unlikely( callback_irq == 0)) { + printk("try to inject callback =0!!!\n"); + printk("pending: %x, sel: %x, pending[0]:%x\n", + v->vcpu_info->evtchn_upcall_pending, + v->vcpu_info->evtchn_pending_sel, + v->domain->shared_info->evtchn_pending[0]); + return 0; + } + + /* + * the event is only for guest, just set callback interrupt + * bit and return + */ + + return test_and_set_bit(callback_irq, &spg->pic_intr[0]); + +} + +void vmx_check_guest_event(struct vcpu *v) +{ + + int port = iopacket_port(v->domain); + + if (!v->domain->shared_info->evtchn_pending[port>>5]) + clear_bit(port>>5, &v->vcpu_info->evtchn_pending_sel); + + /* Note: VMX domains may need upcalls as well */ + if (!v->vcpu_info->evtchn_pending_sel) + v->vcpu_info->evtchn_upcall_pending = 0; + + if(event_pending(v) && !v->vcpu_info->callback_mask && + !test_bit(port, &v->domain->shared_info->evtchn_pending[0]) ) + vmx_event_to_irq(v); +} + + asmlinkage void vmx_intr_assist(void) { int intr_type = 0; @@ -640,6 +685,10 @@ highest_vector = find_highest_pending_irq(v, &intr_type); __vmread(CPU_BASED_VM_EXEC_CONTROL, &cpu_exec_control); + + vmx_check_guest_event(v); /*inject para-device call back irq*/ + + highest_vector = find_highest_pending_irq(v, &intr_type); if (highest_vector == -1) { disable_irq_window(cpu_exec_control);