xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Paul Durrant <paul.durrant@citrix.com>
To: xen-devel@lists.xen.org
Cc: Paul Durrant <paul.durrant@citrix.com>
Subject: [PATCH v3 2/6] ioreq-server: tidy up use of ioreq_t
Date: Wed, 5 Mar 2014 14:47:57 +0000	[thread overview]
Message-ID: <1394030881-5498-3-git-send-email-paul.durrant@citrix.com> (raw)
In-Reply-To: <1394030881-5498-1-git-send-email-paul.durrant@citrix.com>

This patch tidies up various occurences of single element ioreq_t
arrays on the stack and improves coding style.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
 xen/arch/x86/hvm/emulate.c |   36 ++++++++++++++++++------------------
 xen/arch/x86/hvm/hvm.c     |    2 ++
 xen/arch/x86/hvm/io.c      |   37 +++++++++++++++++--------------------
 3 files changed, 37 insertions(+), 38 deletions(-)

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 0ba2020..1c71902 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -57,7 +57,7 @@ static int hvmemul_do_io(
     int value_is_ptr = (p_data == NULL);
     struct vcpu *curr = current;
     struct hvm_vcpu_io *vio;
-    ioreq_t p[1];
+    ioreq_t p;
     unsigned long ram_gfn = paddr_to_pfn(ram_gpa);
     p2m_type_t p2mt;
     struct page_info *ram_page;
@@ -171,38 +171,38 @@ static int hvmemul_do_io(
     if ( vio->mmio_retrying )
         *reps = 1;
 
-    p->dir = dir;
-    p->data_is_ptr = value_is_ptr;
-    p->type = is_mmio ? IOREQ_TYPE_COPY : IOREQ_TYPE_PIO;
-    p->size = size;
-    p->addr = addr;
-    p->count = *reps;
-    p->df = df;
-    p->data = value;
+    p.dir = dir;
+    p.data_is_ptr = value_is_ptr;
+    p.type = is_mmio ? IOREQ_TYPE_COPY : IOREQ_TYPE_PIO;
+    p.size = size;
+    p.addr = addr;
+    p.count = *reps;
+    p.df = df;
+    p.data = value;
 
     if ( dir == IOREQ_WRITE )
-        hvmtrace_io_assist(is_mmio, p);
+        hvmtrace_io_assist(is_mmio, &p);
 
     if ( is_mmio )
     {
-        rc = hvm_mmio_intercept(p);
+        rc = hvm_mmio_intercept(&p);
         if ( rc == X86EMUL_UNHANDLEABLE )
-            rc = hvm_buffered_io_intercept(p);
+            rc = hvm_buffered_io_intercept(&p);
     }
     else
     {
-        rc = hvm_portio_intercept(p);
+        rc = hvm_portio_intercept(&p);
     }
 
     switch ( rc )
     {
     case X86EMUL_OKAY:
     case X86EMUL_RETRY:
-        *reps = p->count;
-        p->state = STATE_IORESP_READY;
+        *reps = p.count;
+        p.state = STATE_IORESP_READY;
         if ( !vio->mmio_retry )
         {
-            hvm_io_assist(p);
+            hvm_io_assist(&p);
             vio->io_state = HVMIO_none;
         }
         else
@@ -219,7 +219,7 @@ static int hvmemul_do_io(
         else
         {
             rc = X86EMUL_RETRY;
-            if ( !hvm_send_assist_req(curr, p) )
+            if ( !hvm_send_assist_req(curr, &p) )
                 vio->io_state = HVMIO_none;
             else if ( p_data == NULL )
                 rc = X86EMUL_OKAY;
@@ -238,7 +238,7 @@ static int hvmemul_do_io(
 
  finish_access:
     if ( dir == IOREQ_READ )
-        hvmtrace_io_assist(is_mmio, p);
+        hvmtrace_io_assist(is_mmio, &p);
 
     if ( p_data != NULL )
         memcpy(p_data, &vio->io_data, size);
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 0b2e57e..10b8e8c 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -349,7 +349,9 @@ static 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;
 }
 
diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c
index ba50c53..7aac61d 100644
--- a/xen/arch/x86/hvm/io.c
+++ b/xen/arch/x86/hvm/io.c
@@ -49,22 +49,19 @@
 void send_timeoffset_req(unsigned long timeoff)
 {
     struct vcpu *curr = current;
-    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(curr->domain, p) )
+    if ( !hvm_buffered_io_send(curr->domain, &p) )
         printk("Unsuccessful timeoffset update\n");
 }
 
@@ -72,14 +69,14 @@ void send_timeoffset_req(unsigned long timeoff)
 void send_invalidate_req(void)
 {
     struct vcpu *curr = current;
-    ioreq_t p[1];
-
-    p->type = IOREQ_TYPE_INVALIDATE;
-    p->size = 4;
-    p->dir = IOREQ_WRITE;
-    p->data = ~0UL; /* flush all */
-
-    (void)hvm_send_assist_req(curr, p);
+    ioreq_t p = {
+        .type = IOREQ_TYPE_INVALIDATE,
+        .size = 4,
+        .dir = IOREQ_WRITE,
+        .data = ~0UL, /* flush all */
+    };
+
+    (void)hvm_send_assist_req(curr, &p);
 }
 
 int handle_mmio(void)
-- 
1.7.10.4

  parent reply	other threads:[~2014-03-05 14:47 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-05 14:47 [PATCH v3 0/6] Support for running secondary emulators Paul Durrant
2014-03-05 14:47 ` [PATCH v3 1/6] ioreq-server: centralize access to ioreq structures Paul Durrant
2014-03-05 14:47 ` Paul Durrant [this message]
2014-03-10 15:43   ` [PATCH v3 2/6] ioreq-server: tidy up use of ioreq_t George Dunlap
2014-03-10 15:46     ` Paul Durrant
2014-03-10 15:53       ` George Dunlap
2014-03-10 16:04         ` Paul Durrant
2014-03-10 16:56           ` George Dunlap
2014-03-11 10:06             ` Paul Durrant
2014-03-05 14:47 ` [PATCH v3 3/6] ioreq-server: create basic ioreq server abstraction Paul Durrant
2014-03-05 14:47 ` [PATCH v3 4/6] ioreq-server: on-demand creation of ioreq server Paul Durrant
2014-03-10 17:46   ` George Dunlap
2014-03-11 10:54     ` Paul Durrant
2014-03-14 11:04       ` Ian Campbell
2014-03-14 13:28         ` Paul Durrant
2014-03-14 11:18   ` Ian Campbell
2014-03-14 13:30     ` Paul Durrant
2014-03-05 14:48 ` [PATCH v3 5/6] ioreq-server: add support for multiple servers Paul Durrant
2014-03-14 11:52   ` Ian Campbell
2014-03-17 11:45     ` George Dunlap
2014-03-17 12:25     ` Paul Durrant
2014-03-17 12:35       ` Ian Campbell
2014-03-17 12:51         ` Paul Durrant
2014-03-17 12:53           ` Ian Campbell
2014-03-17 13:56             ` Paul Durrant
2014-03-17 14:44               ` Ian Campbell
2014-03-17 14:52                 ` Paul Durrant
2014-03-17 14:55                   ` Ian Campbell
2014-03-18 11:33                     ` Paul Durrant
2014-03-18 13:24                       ` George Dunlap
2014-03-18 13:38                         ` Paul Durrant
2014-03-18 13:45                         ` Paul Durrant
2014-03-20 11:11                   ` Tim Deegan
2014-03-20 11:22                     ` Paul Durrant
2014-03-20 12:10                       ` Paul Durrant
2014-03-05 14:48 ` [PATCH v3 6/6] ioreq-server: bring the PCI hotplug controller implementation into Xen Paul Durrant
2014-03-14 11:57   ` Ian Campbell
2014-03-14 13:25     ` Paul Durrant
2014-03-14 14:08       ` Ian Campbell
2014-03-14 14:31         ` Paul Durrant
2014-03-14 15:01           ` Ian Campbell
2014-03-14 15:18             ` Paul Durrant
2014-03-14 18:06               ` Konrad Rzeszutek Wilk
2014-03-17 11:13                 ` Paul Durrant
2014-03-10 18:57 ` [PATCH v3 0/6] Support for running secondary emulators George Dunlap
2014-03-11 10:48   ` Paul Durrant
2014-03-14 11:02 ` Ian Campbell
2014-03-14 13:26   ` Paul Durrant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1394030881-5498-3-git-send-email-paul.durrant@citrix.com \
    --to=paul.durrant@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).