allwinner-a10: Fix interrupt controller regression
cover allwinner-a10: Fix interrupt controller regression
In commit 2c5fa0778c3b430 we fixed an endianness bug in the Allwinner A10 PIC model; however in the process we introduced a regression. This is because the old code was robust against the incoming 'level' argument being something other than 0 or 1, whereas the new code was not.
In particular, the allwinner-sdhost code treats its IRQ line as 0-vs-non-0 rather than 0-vs-1, so when the SD controller set its IRQ line for any reason other than transmit the interrupt controller would ignore it. The observed effect was a guest timeout when rebooting the guest kernel.
Patch 1 in this series fixes the regression by restoring the old behaviour of aw_a10_pic_set_irq() for non-0 levels; it is stable material.
Patch 2 changes the SD controller to follow our usual convention that simple IRQ lines only send 0 or 1; this isn't strictly necessary with patch 1, but it avoids future surprises. It doesn't need to go to stable.
thanks
-- PMM
Peter Maydell (2):
hw/intc/allwinner-a10-pic: Handle IRQ levels other than 0 or 1 hw/sd/allwinner-sdhost: Don't send non-boolean IRQ line levels
hw/intc/allwinner-a10-pic.c | 2 +- hw/sd/allwinner-sdhost.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/2 hw/intc/allwinner-a10-pic: Handle IRQ levels other than 0 or 1
In commit 2c5fa0778c3b430 we fixed an endianness bug in the Allwinner A10 PIC model; however in the process we introduced a regression. This is because the old code was robust against the incoming 'level' argument being something other than 0 or 1, whereas the new code was not.
In particular, the allwinner-sdhost code treats its IRQ line as 0-vs-non-0 rather than 0-vs-1, so when the SD controller set its IRQ line for any reason other than transmit the interrupt controller would ignore it. The observed effect was a guest timeout when rebooting the guest kernel.
Handle level values other than 0 or 1, to restore the old behaviour.
--- hw/intc/allwinner-a10-pic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/allwinner-a10-pic.c +1 -1
@@ -51,7 +51,7 @@ static void aw_a10_pic_set_irq(void *opaque, int irq, int level)AwA10PICState *s = opaque;uint32_t *pending_reg = &s->irq_pending[irq /32 ]; - *pending_reg =deposit32 (*pending_reg, irq %32 ,1 , level); + *pending_reg =deposit32 (*pending_reg, irq %32 ,1 , !!level);aw_a10_pic_update (s); }
Signature · 1 line
2.34.1
Re: [PATCH 1/2] hw/intc/allwinner-a10-pic: Handle IRQ levels other than 0 or 1
Quoted 12 lines · Peter Maydell
In commit
2c5fa0778c3b430we fixed an endianness bug in the Allwinner A10 PIC model; however in the process we introduced a regression. This is because the old code was robust against the incoming 'level' argument being something other than 0 or 1, whereas the new code was not.In particular, the allwinner-sdhost code treats its IRQ line as 0-vs-non-0 rather than 0-vs-1, so when the SD controller set its IRQ line for any reason other than transmit the interrupt controller would ignore it. The observed effect was a guest timeout when rebooting the guest kernel.
Quoted 6 lines
Handle level values other than 0 or 1, to restore the old behaviour.
Fixes 2c5fa0778c3b430 ("hw/intc/allwinner-a10-pic: Don't use set_bit()/clear_bit()")Signed-off-by Peter Maydell <[email protected]>
Tested on top of 8.0.2, both this patch alone as well as this patch plus the second patch in the series.
Guenter
Quoted 20 lines
--- hw/intc/allwinner-a10-pic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/intc/allwinner-a10-pic.c +1
-1@@ -51,7 +51,7 @@ static void aw_a10_pic_set_irq(void *opaque, int irq, int level)AwA10PICState *s = opaque;uint32_t *pending_reg = &s->irq_pending[irq /32 ]; - *pending_reg =deposit32 (*pending_reg, irq %32 ,1 , level); + *pending_reg =deposit32 (*pending_reg, irq %32 ,1 , !!level);aw_a10_pic_update (s); }Signature · 1 line
2.34.1
PATCH 2/2 hw/sd/allwinner-sdhost: Don't send non-boolean IRQ line levels
In reply to Peter MaydellQEMU allows qemu_irq lines to transfer arbitrary integers. However the convention is that for a simple IRQ line the values transferred are always 0 and 1. The A10 SD controller device instead assumes a 0-vs-non-0 convention, which happens to work with the interrupt controller it is wired up to.
Coerce the value to boolean to follow our usual convention.
--- hw/sd/allwinner-sdhost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sd/allwinner-sdhost.c +1 -1
@@ -191,7 +191,7 @@ static void allwinner_sdhost_update_irq(AwSdHostState *s) }trace_allwinner_sdhost_update_irq (irq); -qemu_set_irq (s->irq, irq); +qemu_set_irq (s->irq, !!irq); } static void allwinner_sdhost_update_transfer_cnt(AwSdHostState *s,
Signature · 1 line
2.34.1
Re: [PATCH 2/2] hw/sd/allwinner-sdhost: Don't send non-boolean IRQ line levels
Hi Peter,
Quoted 7 lines · Peter Maydell
QEMU allows
qemu_irqlines to transfer arbitrary integers. However the convention is that for a simple IRQ line the values transferred are always 0 and 1. The A10 SD controller device instead assumes a 0-vs-non-0 convention, which happens to work with the interrupt controller it is wired up to.Coerce the value to boolean to follow our usual convention.
I remember once wanting to convert qemu_set_irq() to take a boolean argument but someone said using integer was more useful because ...? I searched a bit but can't find that in my mail archives, maybe this was on IRC. Any clue? (I find simpler to use a boolean rather than having a convention of using integers restricted to [0, 1] range).
Regards,
Phil.
Re: [PATCH 2/2] hw/sd/allwinner-sdhost: Don't send non-boolean IRQ line levels
Quoted 10 lines · Philippe Mathieu-Daudé
Hi Peter,
Quoted 6 lines · Peter Maydell
QEMU allows
qemu_irqlines to transfer arbitrary integers. However the convention is that for a simple IRQ line the values transferred are always 0 and 1. The A10 SD controller device instead assumes a 0-vs-non-0 convention, which happens to work with the interrupt controller it is wired up to.
Quoted 7 lines
Quoted 1 line
Coerce the value to boolean to follow our usual convention.
I remember once wanting to convert
qemu_set_irq()to take a boolean argument but someone said using integer was more useful because ...? I searched a bit but can't find that in my mail archives, maybe this was on IRC. Any clue? (I find simpler to use a boolean rather than having a convention of using integers restricted to [0, 1] range).
We have a lot of use cases where we just want to transfer a boolean value between two devices. We have a few use cases where we want to transfer an arbitrary integer across the channel between two devices. (For instance hw/intc/etraxfs_pic.c:pic_update() sends a vector number to the CPU via a qemu_irq -- see commit f4f643882d9dc467.)
At the moment we use qemu_irq() for both. In theory we could construct a parallel set of machinery for wiring up and setting values for the "want an integer" case and restrict qemu_irq() to bool only, but the lazy path is to use the same function for both. (If we had machinery that made it easy to construct arbitrary strongly-typed signal connections, that might perhaps be ideal. But it's probably not very easy especially in C.)
thanks
-- PMM
Re: [PATCH 2/2] hw/sd/allwinner-sdhost: Don't send non-boolean IRQ line levels
Quoted 19 lines · Peter Maydell
Quoted 10 lines · Philippe Mathieu-Daudé
Hi Peter,
Quoted 6 lines · Peter Maydell
QEMU allows
qemu_irqlines to transfer arbitrary integers. However the convention is that for a simple IRQ line the values transferred are always 0 and 1. The A10 SD controller device instead assumes a 0-vs-non-0 convention, which happens to work with the interrupt controller it is wired up to.Quoted 7 lines
Quoted 1 line
Coerce the value to boolean to follow our usual convention.
I remember once wanting to convert
qemu_set_irq()to take a boolean argument but someone said using integer was more useful because ...? I searched a bit but can't find that in my mail archives, maybe this was on IRC. Any clue? (I find simpler to use a boolean rather than having a convention of using integers restricted to [0, 1] range).
Quoted 5 lines
We have a lot of use cases where we just want to transfer a boolean value between two devices. We have a few use cases where we want to transfer an arbitrary integer across the channel between two devices. (For instance hw/intc/etraxfs_pic.c:pic_update() sends a vector number to the CPU via a
qemu_irq-- see commitf4f643882d9dc467.)
Thanks for this reference!
Quoted 7 lines
At the moment we use
qemu_irq()for both. In theory we could construct a parallel set of machinery for wiring up and setting values for the "want an integer" case and restrictqemu_irq()to bool only, but the lazy path is to use the same function for both. (If we had machinery that made it easy to construct arbitrary strongly-typed signal connections, that might perhaps be ideal. But it's probably not very easy especially in C.)
I see, thanks.
Re: [PATCH 2/2] hw/sd/allwinner-sdhost: Don't send non-boolean IRQ line levels
In reply to Peter MaydellQuoted 9 lines · Peter Maydell
QEMU allows
qemu_irqlines to transfer arbitrary integers. However the convention is that for a simple IRQ line the values transferred are always 0 and 1. The A10 SD controller device instead assumes a 0-vs-non-0 convention, which happens to work with the interrupt controller it is wired up to.Coerce the value to boolean to follow our usual convention.
Signed-off-by Peter Maydell <[email protected]>
Quoted 20 lines
--- hw/sd/allwinner-sdhost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/sd/allwinner-sdhost.c +1
-1@@ -191,7 +191,7 @@ static void allwinner_sdhost_update_irq(AwSdHostState *s) }trace_allwinner_sdhost_update_irq (irq); -qemu_set_irq (s->irq, irq); +qemu_set_irq (s->irq, !!irq); } static void allwinner_sdhost_update_transfer_cnt(AwSdHostState *s,Signature · 1 line
2.34.1
Quoted 3 lines · Peter Maydell
Peter Maydell (2):
hw/intc/allwinner-a10-pic: Handle IRQ levels other than 0 or 1 hw/sd/allwinner-sdhost: Don't send non-boolean IRQ line levels