Message ID | 1442333283-13119-45-git-send-email-marcandre.lureau@redhat.com |
---|---|
State | New |
Headers | show |
On 15.09.2015 18:08, marcandre.lureau@redhat.com wrote: > From: Marc-André Lureau <marcandre.lureau@redhat.com> > > No need to store an extra int for the vector number when it can be > computed easily by looking at the position in the array. > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> This one does not seem particularly valuable to me.. btw isn't it slightly easier to debug with the vector in the structure? > --- > hw/misc/ivshmem.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c > index ac90f0a..976fbea 100644 > --- a/hw/misc/ivshmem.c > +++ b/hw/misc/ivshmem.c > @@ -68,7 +68,6 @@ typedef struct Peer { > > typedef struct EventfdEntry { > PCIDevice *pdev; > - int vector; > } EventfdEntry; > > typedef struct IVShmemState { > @@ -287,9 +286,11 @@ static void fake_irqfd(void *opaque, const uint8_t *buf, int size) { > > EventfdEntry *entry = opaque; > PCIDevice *pdev = entry->pdev; > + IVShmemState *s = IVSHMEM(pdev); > + int vector = entry - s->eventfd_table; > > - IVSHMEM_DPRINTF("interrupt on vector %p %d\n", pdev, entry->vector); > - msix_notify(pdev, entry->vector); > + IVSHMEM_DPRINTF("interrupt on vector %p %d\n", pdev, vector); > + msix_notify(pdev, vector); > } > > static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier *n, > @@ -311,7 +312,6 @@ static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier * > /* if MSI is supported we need multiple interrupts */ > if (ivshmem_has_feature(s, IVSHMEM_MSI)) { > s->eventfd_table[vector].pdev = PCI_DEVICE(s); > - s->eventfd_table[vector].vector = vector; > > qemu_chr_add_handlers(chr, ivshmem_can_receive, fake_irqfd, > ivshmem_event, &s->eventfd_table[vector]); >
Hi
On Tue, Sep 22, 2015 at 4:59 PM, Claudio Fontana
<claudio.fontana@huawei.com> wrote:
> This one does not seem particularly valuable to me.. btw isn't it slightly easier to debug with the vector in the structure?
Yeah, it's just is a bit superflous to me store the vector index in
all the elements.
You get the vector index calculated and printed in debug, so I failed
to see what it removes for debugging.
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index ac90f0a..976fbea 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -68,7 +68,6 @@ typedef struct Peer { typedef struct EventfdEntry { PCIDevice *pdev; - int vector; } EventfdEntry; typedef struct IVShmemState { @@ -287,9 +286,11 @@ static void fake_irqfd(void *opaque, const uint8_t *buf, int size) { EventfdEntry *entry = opaque; PCIDevice *pdev = entry->pdev; + IVShmemState *s = IVSHMEM(pdev); + int vector = entry - s->eventfd_table; - IVSHMEM_DPRINTF("interrupt on vector %p %d\n", pdev, entry->vector); - msix_notify(pdev, entry->vector); + IVSHMEM_DPRINTF("interrupt on vector %p %d\n", pdev, vector); + msix_notify(pdev, vector); } static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier *n, @@ -311,7 +312,6 @@ static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier * /* if MSI is supported we need multiple interrupts */ if (ivshmem_has_feature(s, IVSHMEM_MSI)) { s->eventfd_table[vector].pdev = PCI_DEVICE(s); - s->eventfd_table[vector].vector = vector; qemu_chr_add_handlers(chr, ivshmem_can_receive, fake_irqfd, ivshmem_event, &s->eventfd_table[vector]);