[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] ioreq-server: pre-series tidy up
commit e9ca7beec64e16e81b47233f701beb4ce3e9e8c0 Author: Paul Durrant <paul.durrant@xxxxxxxxxx> AuthorDate: Mon May 12 12:00:30 2014 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Mon May 12 12:00:30 2014 +0200 ioreq-server: pre-series tidy up This patch tidies up various parts of the code that following patches move around. If these modifications were combined with the code motion it would be easy to miss them. There's also some function renaming to reflect purpose and a single whitespace fix. Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx> Acked-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/arch/x86/hvm/emulate.c | 2 +- xen/arch/x86/hvm/hvm.c | 60 ++++++++++++++++++------------------ xen/arch/x86/hvm/io.c | 46 ++++++++++++---------------- xen/include/asm-x86/hvm/hvm.h | 2 +- xen/include/asm-x86/hvm/support.h | 2 + 5 files changed, 54 insertions(+), 58 deletions(-) diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index 868aa1d..6d3522a 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -241,7 +241,7 @@ static int hvmemul_do_io( else { rc = X86EMUL_RETRY; - if ( !hvm_send_assist_req(curr) ) + if ( !hvm_send_assist_req() ) vio->io_state = HVMIO_none; else if ( p_data == NULL ) rc = X86EMUL_OKAY; diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index b697b6c..43880c8 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -365,7 +365,7 @@ void hvm_migrate_pirqs(struct vcpu *v) void hvm_do_resume(struct vcpu *v) { - ioreq_t *p; + ioreq_t *p = get_ioreq(v); check_wakeup_from_wait(); @@ -373,30 +373,29 @@ void hvm_do_resume(struct vcpu *v) pt_restore_timer(v); /* NB. Optimised for common case (p->state == STATE_IOREQ_NONE). */ - if ( !(p = get_ioreq(v)) ) - goto check_inject_trap; - - while ( p->state != STATE_IOREQ_NONE ) + if ( p ) { - switch ( p->state ) + while ( p->state != STATE_IOREQ_NONE ) { - case STATE_IORESP_READY: /* IORESP_READY -> NONE */ - hvm_io_assist(p); - break; - case STATE_IOREQ_READY: /* IOREQ_{READY,INPROCESS} -> IORESP_READY */ - case STATE_IOREQ_INPROCESS: - wait_on_xen_event_channel(v->arch.hvm_vcpu.xen_port, - (p->state != STATE_IOREQ_READY) && - (p->state != STATE_IOREQ_INPROCESS)); - break; - default: - gdprintk(XENLOG_ERR, "Weird HVM iorequest state %d.\n", p->state); - domain_crash(v->domain); - return; /* bail */ + switch ( p->state ) + { + case STATE_IORESP_READY: /* IORESP_READY -> NONE */ + hvm_io_assist(p); + break; + case STATE_IOREQ_READY: /* IOREQ_{READY,INPROCESS} -> IORESP_READY */ + case STATE_IOREQ_INPROCESS: + wait_on_xen_event_channel(v->arch.hvm_vcpu.xen_port, + (p->state != STATE_IOREQ_READY) && + (p->state != STATE_IOREQ_INPROCESS)); + break; + default: + gdprintk(XENLOG_ERR, "Weird HVM iorequest state %d.\n", p->state); + domain_crash(v->domain); + return; /* bail */ + } } } - check_inject_trap: /* Inject pending hw/sw trap */ if ( v->arch.hvm_vcpu.inject_trap.vector != -1 ) { @@ -426,7 +425,7 @@ void destroy_ring_for_helper( } } -static void hvm_destroy_ioreq_page( +static void hvm_unmap_ioreq_page( struct domain *d, struct hvm_ioreq_page *iorp) { spin_lock(&iorp->lock); @@ -482,7 +481,7 @@ int prepare_ring_for_helper( return 0; } -static int hvm_set_ioreq_page( +static int hvm_map_ioreq_page( struct domain *d, struct hvm_ioreq_page *iorp, unsigned long gmfn) { struct page_info *page; @@ -652,8 +651,8 @@ void hvm_domain_relinquish_resources(struct domain *d) if ( hvm_funcs.nhvm_domain_relinquish_resources ) hvm_funcs.nhvm_domain_relinquish_resources(d); - hvm_destroy_ioreq_page(d, &d->arch.hvm_domain.ioreq); - hvm_destroy_ioreq_page(d, &d->arch.hvm_domain.buf_ioreq); + hvm_unmap_ioreq_page(d, &d->arch.hvm_domain.ioreq); + hvm_unmap_ioreq_page(d, &d->arch.hvm_domain.buf_ioreq); msixtbl_pt_cleanup(d); @@ -1425,14 +1424,15 @@ void hvm_vcpu_down(struct vcpu *v) } } -bool_t hvm_send_assist_req(struct vcpu *v) +bool_t hvm_send_assist_req(void) { - ioreq_t *p; + struct vcpu *v = current; + ioreq_t *p = get_ioreq(v); if ( unlikely(!vcpu_start_shutdown_deferral(v)) ) return 0; /* implicitly bins the i/o operation */ - if ( !(p = get_ioreq(v)) ) + if ( !p ) return 0; if ( unlikely(p->state != STATE_IOREQ_NONE) ) @@ -4129,7 +4129,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg) { case HVM_PARAM_IOREQ_PFN: iorp = &d->arch.hvm_domain.ioreq; - if ( (rc = hvm_set_ioreq_page(d, iorp, a.value)) != 0 ) + if ( (rc = hvm_map_ioreq_page(d, iorp, a.value)) != 0 ) break; spin_lock(&iorp->lock); if ( iorp->va != NULL ) @@ -4138,9 +4138,9 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg) get_ioreq(v)->vp_eport = v->arch.hvm_vcpu.xen_port; spin_unlock(&iorp->lock); break; - case HVM_PARAM_BUFIOREQ_PFN: + case HVM_PARAM_BUFIOREQ_PFN: iorp = &d->arch.hvm_domain.buf_ioreq; - rc = hvm_set_ioreq_page(d, iorp, a.value); + rc = hvm_map_ioreq_page(d, iorp, a.value); break; case HVM_PARAM_CALLBACK_IRQ: hvm_set_callback_via(d, a.value); diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c index bf6309d..44b4e20 100644 --- a/xen/arch/x86/hvm/io.c +++ b/xen/arch/x86/hvm/io.c @@ -49,9 +49,13 @@ int hvm_buffered_io_send(ioreq_t *p) { struct vcpu *v = current; - struct hvm_ioreq_page *iorp = &v->domain->arch.hvm_domain.buf_ioreq; + struct domain *d = v->domain; + struct hvm_ioreq_page *iorp = &d->arch.hvm_domain.buf_ioreq; buffered_iopage_t *pg = iorp->va; - buf_ioreq_t bp; + buf_ioreq_t bp = { .data = p->data, + .addr = p->addr, + .type = p->type, + .dir = p->dir }; /* Timeoffset sends 64b data, but no address. Use two consecutive slots. */ int qw = 0; @@ -69,8 +73,6 @@ int hvm_buffered_io_send(ioreq_t *p) if ( (p->addr > 0xffffful) || p->data_is_ptr || (p->count != 1) ) return 0; - bp.type = p->type; - bp.dir = p->dir; switch ( p->size ) { case 1: @@ -91,9 +93,6 @@ int hvm_buffered_io_send(ioreq_t *p) return 0; } - bp.data = p->data; - bp.addr = p->addr; - spin_lock(&iorp->lock); if ( (pg->write_pointer - pg->read_pointer) >= @@ -104,22 +103,20 @@ int hvm_buffered_io_send(ioreq_t *p) return 0; } - memcpy(&pg->buf_ioreq[pg->write_pointer % IOREQ_BUFFER_SLOT_NUM], - &bp, sizeof(bp)); + pg->buf_ioreq[pg->write_pointer % IOREQ_BUFFER_SLOT_NUM] = bp; if ( qw ) { bp.data = p->data >> 32; - memcpy(&pg->buf_ioreq[(pg->write_pointer+1) % IOREQ_BUFFER_SLOT_NUM], - &bp, sizeof(bp)); + pg->buf_ioreq[(pg->write_pointer+1) % IOREQ_BUFFER_SLOT_NUM] = bp; } /* Make the ioreq_t visible /before/ write_pointer. */ wmb(); pg->write_pointer += qw ? 2 : 1; - notify_via_xen_event_channel(v->domain, - v->domain->arch.hvm_domain.params[HVM_PARAM_BUFIOREQ_EVTCHN]); + notify_via_xen_event_channel(d, + d->arch.hvm_domain.params[HVM_PARAM_BUFIOREQ_EVTCHN]); spin_unlock(&iorp->lock); return 1; @@ -127,22 +124,19 @@ int hvm_buffered_io_send(ioreq_t *p) void send_timeoffset_req(unsigned long timeoff) { - ioreq_t p[1]; + ioreq_t p = { + .type = IOREQ_TYPE_TIMEOFFSET, + .size = 8, + .count = 1, + .dir = IOREQ_WRITE, + .data = timeoff, + .state = STATE_IOREQ_READY, + }; if ( timeoff == 0 ) return; - memset(p, 0, sizeof(*p)); - - p->type = IOREQ_TYPE_TIMEOFFSET; - p->size = 8; - p->count = 1; - p->dir = IOREQ_WRITE; - p->data = timeoff; - - p->state = STATE_IOREQ_READY; - - if ( !hvm_buffered_io_send(p) ) + if ( !hvm_buffered_io_send(&p) ) printk("Unsuccessful timeoffset update\n"); } @@ -168,7 +162,7 @@ void send_invalidate_req(void) p->dir = IOREQ_WRITE; p->data = ~0UL; /* flush all */ - (void)hvm_send_assist_req(v); + (void)hvm_send_assist_req(); } int handle_mmio(void) diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index b1c340e..4fb7e22 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -231,7 +231,7 @@ int prepare_ring_for_helper(struct domain *d, unsigned long gmfn, struct page_info **_page, void **_va); void destroy_ring_for_helper(void **_va, struct page_info *page); -bool_t hvm_send_assist_req(struct vcpu *v); +bool_t hvm_send_assist_req(void); void hvm_get_guest_pat(struct vcpu *v, u64 *guest_pat); int hvm_set_guest_pat(struct vcpu *v, u64 guest_pat); diff --git a/xen/include/asm-x86/hvm/support.h b/xen/include/asm-x86/hvm/support.h index 3529499..1dc2f2d 100644 --- a/xen/include/asm-x86/hvm/support.h +++ b/xen/include/asm-x86/hvm/support.h @@ -31,7 +31,9 @@ static inline ioreq_t *get_ioreq(struct vcpu *v) { struct domain *d = v->domain; shared_iopage_t *p = d->arch.hvm_domain.ioreq.va; + ASSERT((v == current) || spin_is_locked(&d->arch.hvm_domain.ioreq.lock)); + return p ? &p->vcpu_ioreq[v->vcpu_id] : NULL; } -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |