diff mbox

[v3,3/3] spapr: make irq customizable via qdev

Message ID 1307369780-28189-4-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini June 6, 2011, 2:16 p.m. UTC
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/spapr_vio.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

Comments

Markus Armbruster June 7, 2011, 7:51 a.m. UTC | #1
Paolo Bonzini <pbonzini@redhat.com> writes:

> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/spapr_vio.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c
> index 6f34159..a193caa 100644
> --- a/hw/spapr_vio.c
> +++ b/hw/spapr_vio.c
> @@ -52,6 +52,10 @@
>  static struct BusInfo spapr_vio_bus_info = {
>      .name       = "spapr-vio",
>      .size       = sizeof(VIOsPAPRBus),
> +    .props = (Property[]) {
> +        DEFINE_PROP_UINT32("irq", VIOsPAPRDevice, vio_irq_num, 0), \
> +        DEFINE_PROP_END_OF_LIST(),
> +    },
>  };

Out of this patch's scope, but I need to ask anyway: do devices on a
spapr-vio bus have a unique address?  If yes, what is it?

>  
>  VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg)
> @@ -603,7 +607,9 @@ static int spapr_vio_busdev_init(DeviceState *qdev, DeviceInfo *qinfo)
>      }
>  
>      dev->qdev.id = id;
> -    dev->vio_irq_num = spapr_allocate_irq (spapr);
> +    if (!dev->vio_irq_num) {
> +        dev->vio_irq_num = spapr_allocate_irq (spapr);
> +    }
>      dev->qirq = xics_find_qirq(spapr->icp, dev->vio_irq_num);
>  
>      rtce_init(dev);

Is it okay to share interrupts?  I'm asking because spapr_allocate_irq()
will happily assign IRQs already used via property.  From PATCH 1/1:

static inline int spapr_allocate_irq(sPAPREnvironment *spapr)
{
    return spapr->next_irq++;
}
Paolo Bonzini June 7, 2011, 9:05 a.m. UTC | #2
On 06/07/2011 09:51 AM, Markus Armbruster wrote:
>> >  diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c
>> >  index 6f34159..a193caa 100644
>> >  --- a/hw/spapr_vio.c
>> >  +++ b/hw/spapr_vio.c
>> >  @@ -52,6 +52,10 @@
>> >    static struct BusInfo spapr_vio_bus_info = {
>> >        .name       = "spapr-vio",
>> >        .size       = sizeof(VIOsPAPRBus),
>> >  +    .props = (Property[]) {
>> >  +        DEFINE_PROP_UINT32("irq", VIOsPAPRDevice, vio_irq_num, 0), \
>> >  +        DEFINE_PROP_END_OF_LIST(),
>> >  +    },
>> >    };
>
> Out of this patch's scope, but I need to ask anyway: do devices on a
> spapr-vio bus have a unique address?  If yes, what is it?

That would be the "reg" value in DEFINE_SPAPR_PROPERTIES (patch 2).  I 
didn't make it a bus property because the default values varies 
according to the device type.

> Is it okay to share interrupts?

Seems to work. :)

Paolo
Markus Armbruster June 7, 2011, 9:19 a.m. UTC | #3
Paolo Bonzini <pbonzini@redhat.com> writes:

> On 06/07/2011 09:51 AM, Markus Armbruster wrote:
>>> >  diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c
>>> >  index 6f34159..a193caa 100644
>>> >  --- a/hw/spapr_vio.c
>>> >  +++ b/hw/spapr_vio.c
>>> >  @@ -52,6 +52,10 @@
>>> >    static struct BusInfo spapr_vio_bus_info = {
>>> >        .name       = "spapr-vio",
>>> >        .size       = sizeof(VIOsPAPRBus),
>>> >  +    .props = (Property[]) {
>>> >  +        DEFINE_PROP_UINT32("irq", VIOsPAPRDevice, vio_irq_num, 0), \
>>> >  +        DEFINE_PROP_END_OF_LIST(),
>>> >  +    },
>>> >    };
>>
>> Out of this patch's scope, but I need to ask anyway: do devices on a
>> spapr-vio bus have a unique address?  If yes, what is it?
>
> That would be the "reg" value in DEFINE_SPAPR_PROPERTIES (patch 2).  I
> didn't make it a bus property because the default values varies
> according to the device type.

Hmm.  Explain that in a comment where the bus property would go?

>> Is it okay to share interrupts?
>
> Seems to work. :)

Fair enough.
Paolo Bonzini June 7, 2011, 11:14 a.m. UTC | #4
On 06/07/2011 11:19 AM, Markus Armbruster wrote:
> >  That would be the "reg" value in DEFINE_SPAPR_PROPERTIES (patch 2).  I
> >  didn't make it a bus property because the default values varies
>
> Hmm.  Explain that in a comment where the bus property would go?

qdev.txt is probably a better place to document the possible approaches...

Paolo
diff mbox

Patch

diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c
index 6f34159..a193caa 100644
--- a/hw/spapr_vio.c
+++ b/hw/spapr_vio.c
@@ -52,6 +52,10 @@ 
 static struct BusInfo spapr_vio_bus_info = {
     .name       = "spapr-vio",
     .size       = sizeof(VIOsPAPRBus),
+    .props = (Property[]) {
+        DEFINE_PROP_UINT32("irq", VIOsPAPRDevice, vio_irq_num, 0), \
+        DEFINE_PROP_END_OF_LIST(),
+    },
 };
 
 VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg)
@@ -603,7 +607,9 @@  static int spapr_vio_busdev_init(DeviceState *qdev, DeviceInfo *qinfo)
     }
 
     dev->qdev.id = id;
-    dev->vio_irq_num = spapr_allocate_irq (spapr);
+    if (!dev->vio_irq_num) {
+        dev->vio_irq_num = spapr_allocate_irq (spapr);
+    }
     dev->qirq = xics_find_qirq(spapr->icp, dev->vio_irq_num);
 
     rtce_init(dev);