Patchwork [v2,2/6] ivshmem: Convert to msix_init_exclusive_bar() interface

login
register
mail settings
Submitter Alex Williamson
Date June 14, 2012, 4:51 a.m.
Message ID <20120614045127.11034.9983.stgit@bling.home>
Download mbox | patch
Permalink /patch/164810/
State New
Headers show

Comments

Alex Williamson - June 14, 2012, 4:51 a.m.
Trivial conversion, failed to have an uninit before and after.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 hw/ivshmem.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
Jan Kiszka - June 14, 2012, 6:01 a.m.
On 2012-06-14 06:51, Alex Williamson wrote:
> Trivial conversion, failed to have an uninit before and after.

Need not be in this series, but we should fix that trivial bug nevertheless.

Jan

> 
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
> 
>  hw/ivshmem.c |   10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/ivshmem.c b/hw/ivshmem.c
> index 05559b6..8b49eee 100644
> --- a/hw/ivshmem.c
> +++ b/hw/ivshmem.c
> @@ -70,7 +70,6 @@ typedef struct IVShmemState {
>       */
>      MemoryRegion bar;
>      MemoryRegion ivshmem;
> -    MemoryRegion msix_bar;
>      uint64_t ivshmem_size; /* size of shared memory region */
>      int shm_fd; /* shared memory file descriptor */
>  
> @@ -563,16 +562,13 @@ static uint64_t ivshmem_get_size(IVShmemState * s) {
>  
>  static void ivshmem_setup_msi(IVShmemState * s)
>  {
> -    memory_region_init(&s->msix_bar, "ivshmem-msix", 4096);
> -    if (!msix_init(&s->dev, s->vectors, &s->msix_bar, 1, 0)) {
> -        pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY,
> -                         &s->msix_bar);
> -        IVSHMEM_DPRINTF("msix initialized (%d vectors)\n", s->vectors);
> -    } else {
> +    if (msix_init_exclusive_bar(&s->dev, s->vectors, 1)) {
>          IVSHMEM_DPRINTF("msix initialization failed\n");
>          exit(1);
>      }
>  
> +    IVSHMEM_DPRINTF("msix initialized (%d vectors)\n", s->vectors);
> +
>      /* allocate QEMU char devices for receiving interrupts */
>      s->eventfd_table = g_malloc0(s->vectors * sizeof(EventfdEntry));
>  
>
Alex Williamson - June 14, 2012, 1:54 p.m.
On Thu, 2012-06-14 at 08:01 +0200, Jan Kiszka wrote:
> On 2012-06-14 06:51, Alex Williamson wrote:
> > Trivial conversion, failed to have an uninit before and after.
> 
> Need not be in this series, but we should fix that trivial bug nevertheless.

Given the exit(1) on failure to setup msix, I'm guessing ivshmem isn't
well tuned of hotplug, so I'm not sure how trivial it is.  Thanks,

Alex

> > 
> > Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> > ---
> > 
> >  hw/ivshmem.c |   10 +++-------
> >  1 file changed, 3 insertions(+), 7 deletions(-)
> > 
> > diff --git a/hw/ivshmem.c b/hw/ivshmem.c
> > index 05559b6..8b49eee 100644
> > --- a/hw/ivshmem.c
> > +++ b/hw/ivshmem.c
> > @@ -70,7 +70,6 @@ typedef struct IVShmemState {
> >       */
> >      MemoryRegion bar;
> >      MemoryRegion ivshmem;
> > -    MemoryRegion msix_bar;
> >      uint64_t ivshmem_size; /* size of shared memory region */
> >      int shm_fd; /* shared memory file descriptor */
> >  
> > @@ -563,16 +562,13 @@ static uint64_t ivshmem_get_size(IVShmemState * s) {
> >  
> >  static void ivshmem_setup_msi(IVShmemState * s)
> >  {
> > -    memory_region_init(&s->msix_bar, "ivshmem-msix", 4096);
> > -    if (!msix_init(&s->dev, s->vectors, &s->msix_bar, 1, 0)) {
> > -        pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY,
> > -                         &s->msix_bar);
> > -        IVSHMEM_DPRINTF("msix initialized (%d vectors)\n", s->vectors);
> > -    } else {
> > +    if (msix_init_exclusive_bar(&s->dev, s->vectors, 1)) {
> >          IVSHMEM_DPRINTF("msix initialization failed\n");
> >          exit(1);
> >      }
> >  
> > +    IVSHMEM_DPRINTF("msix initialized (%d vectors)\n", s->vectors);
> > +
> >      /* allocate QEMU char devices for receiving interrupts */
> >      s->eventfd_table = g_malloc0(s->vectors * sizeof(EventfdEntry));
> >  
> > 
>

Patch

diff --git a/hw/ivshmem.c b/hw/ivshmem.c
index 05559b6..8b49eee 100644
--- a/hw/ivshmem.c
+++ b/hw/ivshmem.c
@@ -70,7 +70,6 @@  typedef struct IVShmemState {
      */
     MemoryRegion bar;
     MemoryRegion ivshmem;
-    MemoryRegion msix_bar;
     uint64_t ivshmem_size; /* size of shared memory region */
     int shm_fd; /* shared memory file descriptor */
 
@@ -563,16 +562,13 @@  static uint64_t ivshmem_get_size(IVShmemState * s) {
 
 static void ivshmem_setup_msi(IVShmemState * s)
 {
-    memory_region_init(&s->msix_bar, "ivshmem-msix", 4096);
-    if (!msix_init(&s->dev, s->vectors, &s->msix_bar, 1, 0)) {
-        pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY,
-                         &s->msix_bar);
-        IVSHMEM_DPRINTF("msix initialized (%d vectors)\n", s->vectors);
-    } else {
+    if (msix_init_exclusive_bar(&s->dev, s->vectors, 1)) {
         IVSHMEM_DPRINTF("msix initialization failed\n");
         exit(1);
     }
 
+    IVSHMEM_DPRINTF("msix initialized (%d vectors)\n", s->vectors);
+
     /* allocate QEMU char devices for receiving interrupts */
     s->eventfd_table = g_malloc0(s->vectors * sizeof(EventfdEntry));