Patchwork [RFC,v4,05/12] isa: Allow to un-associate an IRQ

login
register
mail settings
Submitter Andreas Färber
Date June 8, 2011, 6:55 p.m.
Message ID <1307559319-16183-6-git-send-email-andreas.faerber@web.de>
Download mbox | patch
Permalink /patch/99545/
State New
Headers show

Comments

Andreas Färber - June 8, 2011, 6:55 p.m.
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 hw/isa-bus.c |   14 ++++++++++++++
 hw/isa.h     |    1 +
 2 files changed, 15 insertions(+), 0 deletions(-)
Markus Armbruster - June 9, 2011, 3:04 p.m.
Andreas Färber <andreas.faerber@web.de> writes:

> Signed-off-by: Andreas Färber <andreas.faerber@web.de>
> ---
>  hw/isa-bus.c |   14 ++++++++++++++
>  hw/isa.h     |    1 +
>  2 files changed, 15 insertions(+), 0 deletions(-)
>
> diff --git a/hw/isa-bus.c b/hw/isa-bus.c
> index 1f64673..6ac3e61 100644
> --- a/hw/isa-bus.c
> +++ b/hw/isa-bus.c
> @@ -80,6 +80,20 @@ void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq)
>      dev->nirqs++;
>  }
>  
> +void isa_discard_irq(ISADevice *dev, int isairq)
> +{
> +    int i, j;
> +    for (i = 0; i < dev->nirqs; i++) {
> +        if (dev->isairq[i] == isairq) {
> +            for (j = i + 1; j < dev->nirqs; j++) {
> +                dev->isairq[j - 1] = dev->isairq[j];
> +            }
> +            dev->nirqs--;
> +            break;
> +        }
> +    }
> +}

Comment to 04/12 applies.

[...]
Markus Armbruster - June 9, 2011, 3:12 p.m.
Markus Armbruster <armbru@redhat.com> writes:

> Andreas Färber <andreas.faerber@web.de> writes:
>
>> Signed-off-by: Andreas Färber <andreas.faerber@web.de>
>> ---
>>  hw/isa-bus.c |   14 ++++++++++++++
>>  hw/isa.h     |    1 +
>>  2 files changed, 15 insertions(+), 0 deletions(-)
>>
>> diff --git a/hw/isa-bus.c b/hw/isa-bus.c
>> index 1f64673..6ac3e61 100644
>> --- a/hw/isa-bus.c
>> +++ b/hw/isa-bus.c
>> @@ -80,6 +80,20 @@ void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq)
>>      dev->nirqs++;
>>  }
>>  
>> +void isa_discard_irq(ISADevice *dev, int isairq)
>> +{
>> +    int i, j;
>> +    for (i = 0; i < dev->nirqs; i++) {
>> +        if (dev->isairq[i] == isairq) {
>> +            for (j = i + 1; j < dev->nirqs; j++) {
>> +                dev->isairq[j - 1] = dev->isairq[j];
>> +            }
>> +            dev->nirqs--;
>> +            break;
>> +        }
>> +    }
>> +}
>
> Comment to 04/12 applies.

Sorry, misleading.

The comment about the naming applies.

The comment about the use of the function doesn't apply: isa_init_irq()
does the complete job, unlike isa_init_ioport_range().

Your isa_discard_irq() keeps the qemu_irq that was set by isa_init_irq()
around, which is perhaps not perfectly clean, but should work.

> [...]
Andreas Färber - June 12, 2011, 12:05 p.m.
Am 09.06.2011 um 17:12 schrieb Markus Armbruster:

> Markus Armbruster <armbru@redhat.com> writes:
>
>> Andreas Färber <andreas.faerber@web.de> writes:
>>
>>> Signed-off-by: Andreas Färber <andreas.faerber@web.de>
>>> ---
>>> hw/isa-bus.c |   14 ++++++++++++++
>>> hw/isa.h     |    1 +
>>> 2 files changed, 15 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/hw/isa-bus.c b/hw/isa-bus.c
>>> index 1f64673..6ac3e61 100644
>>> --- a/hw/isa-bus.c
>>> +++ b/hw/isa-bus.c
>>> @@ -80,6 +80,20 @@ void isa_init_irq(ISADevice *dev, qemu_irq *p,  
>>> int isairq)
>>>     dev->nirqs++;
>>> }
>>>
>>> +void isa_discard_irq(ISADevice *dev, int isairq)
>>> +{
>>> +    int i, j;
>>> +    for (i = 0; i < dev->nirqs; i++) {
>>> +        if (dev->isairq[i] == isairq) {
>>> +            for (j = i + 1; j < dev->nirqs; j++) {
>>> +                dev->isairq[j - 1] = dev->isairq[j];
>>> +            }
>>> +            dev->nirqs--;
>>> +            break;
>>> +        }
>>> +    }
>>> +}

> Your isa_discard_irq() keeps the qemu_irq that was set by  
> isa_init_irq()
> around, which is perhaps not perfectly clean, but should work.

We could NULL it and hope that no one uses it unchecked from some  
bottom-half or I/O thread.
Or do we have some global no-op qemu_irq?

Andreas

Patch

diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 1f64673..6ac3e61 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -80,6 +80,20 @@  void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq)
     dev->nirqs++;
 }
 
+void isa_discard_irq(ISADevice *dev, int isairq)
+{
+    int i, j;
+    for (i = 0; i < dev->nirqs; i++) {
+        if (dev->isairq[i] == isairq) {
+            for (j = i + 1; j < dev->nirqs; j++) {
+                dev->isairq[j - 1] = dev->isairq[j];
+            }
+            dev->nirqs--;
+            break;
+        }
+    }
+}
+
 static void isa_init_ioport_one(ISADevice *dev, uint16_t ioport)
 {
     assert(dev->nioports < ARRAY_SIZE(dev->ioports));
diff --git a/hw/isa.h b/hw/isa.h
index ba7a696..46b35f3 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -31,6 +31,7 @@  ISABus *isa_bus_new(DeviceState *dev);
 void isa_bus_irqs(qemu_irq *irqs);
 qemu_irq isa_get_irq(int isairq);
 void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
+void isa_discard_irq(ISADevice *dev, int isairq);
 void isa_init_ioport(ISADevice *dev, uint16_t ioport);
 void isa_init_ioport_range(ISADevice *dev, uint16_t start, uint16_t length);
 void isa_discard_ioport_range(ISADevice *dev, uint16_t start, uint16_t length);