Skip to contentSkip to conversation

ppc: Make uninorth interrupt swizzling identical to Grackle

PATCH Applied BALATON Zoltan 5 participants 6 messages Nov 20, 2016 – Nov 22, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppc: Make uninorth interrupt swizzling identical to Grackle

From: Benjamin Herrenschmidt <[email protected]>

It's currently broken as it uses an incorrect shift, it tries to use the slot number but uses the top bits of the bus number instead.

Note: Neither implementation matches what OpenBIOS ends up putting in the device-tree either, which will have to be fixed separately.

This is not quite correct for modelling a real Mac since Apple tend to tie all 4 interrupt lines of a slot together and have separate interrupts for every slot and every motherboard devices going straight to the PIC but we'll sort that out later.

---
 hw/pci-host/uninorth.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

This needs a corresponding fix in OpenBIOS but this has to be committed first for that. As this is already broken making this change should not make things worse as they are now. Could we get this in now as a bugfix commit?

hw/pci-host/uninorth.c +1 -3
index 7aac4d6..df342ac 100644
@@ -62,9 +62,7 @@ typedef struct UNINState {
 
 static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num)
 {
-    int devfn = pci_dev->devfn & 0x00FFFFFF;
-
-    return (((devfn >> 11) & 0x1F) + irq_num) & 3;
+    return (irq_num + (pci_dev->devfn >> 3)) & 3;
 }
 
 static void pci_unin_set_irq(void *opaque, int irq_num, int level)
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 30 lines · BALATON Zoltan

From: Benjamin Herrenschmidt <[email protected]>

It's currently broken as it uses an incorrect shift, it tries to use the slot number but uses the top bits of the bus number instead.

Note: Neither implementation matches what OpenBIOS ends up putting in the device-tree either, which will have to be fixed separately.

This is not quite correct for modelling a real Mac since Apple tend to tie all 4 interrupt lines of a slot together and have separate interrupts for every slot and every motherboard devices going straight to the PIC but we'll sort that out later.

---
 hw/pci-host/uninorth.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

This needs a corresponding fix in OpenBIOS but this has to be committed first for that. As this is already broken making this change should not make things worse as they are now. Could we get this in now as a bugfix commit?

hw/pci-host/uninorth.c +0 -0
index 7aac4d6..df342ac 100644

hw/pci-host/uninorth.c typedef struct UNINState { · line 68

Quoted 10 lines
hw/pci-host/uninorth.c +1 -3
@@ -62,9 +62,7 @@ typedef struct UNINState {
 
 static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num)
 {
-    int devfn = pci_dev->devfn & 0x00FFFFFF;
-
-    return (((devfn >> 11) & 0x1F) + irq_num) & 3;
+    return (irq_num + (pci_dev->devfn >> 3)) & 3;
 }
 
 static void pci_unin_set_irq(void *opaque, int irq_num, int level)

Looks reasonable.

Applied
#2 lore raw
In reply to BALATON Zoltan
Quoted 15 lines · BALATON Zoltan

From: Benjamin Herrenschmidt <[email protected]>

It's currently broken as it uses an incorrect shift, it tries to use the slot number but uses the top bits of the bus number instead.

Note: Neither implementation matches what OpenBIOS ends up putting in the device-tree either, which will have to be fixed separately.

This is not quite correct for modelling a real Mac since Apple tend to tie all 4 interrupt lines of a slot together and have separate interrupts for every slot and every motherboard devices going straight to the PIC but we'll sort that out later.

Quoted 8 lines
---
 hw/pci-host/uninorth.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

This needs a corresponding fix in OpenBIOS but this has to be committed first for that. As this is already broken making this change should not make things worse as they are now. Could we get this in now as a bugfix commit?

Applied to ppc-for-2.8.

Quoted 16 lines
hw/pci-host/uninorth.c +1 -3
index 7aac4d6..df342ac 100644
@@ -62,9 +62,7 @@ typedef struct UNINState {
 
 static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num)
 {
-    int devfn = pci_dev->devfn & 0x00FFFFFF;
-
-    return (((devfn >> 11) & 0x1F) + irq_num) & 3;
+    return (irq_num + (pci_dev->devfn >> 3)) & 3;
 }
 
 static void pci_unin_set_irq(void *opaque, int irq_num, int level)
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#3 lore raw
Quoted 20 lines · David Gibson
Quoted 19 lines · BALATON Zoltan

From: Benjamin Herrenschmidt <[email protected]>

It's currently broken as it uses an incorrect shift, it tries to use the slot number but uses the top bits of the bus number instead.

Note: Neither implementation matches what OpenBIOS ends up putting in the device-tree either, which will have to be fixed separately.

This is not quite correct for modelling a real Mac since Apple tend to tie all 4 interrupt lines of a slot together and have separate interrupts for every slot and every motherboard devices going straight to the PIC but we'll sort that out later.

---
 hw/pci-host/uninorth.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
Quoted 6 lines
Quoted 4 lines

This needs a corresponding fix in OpenBIOS but this has to be committed first for that. As this is already broken making this change should not make things worse as they are now. Could we get this in now as a bugfix commit?

Applied to ppc-for-2.8.

Is this going in for 2.8? If so, I'll need to apply the corresponding patch to OpenBIOS to match and also do a PPC testing cycle to make sure that there are no regressions on other OSs. Plus it would be useful to get both pull requests in close proximity as this will break bisection.

ATB,

Mark.

#4 lore raw
Quoted 26 lines · Mark Cave-Ayland
Quoted 25 lines · David Gibson
Quoted 23 lines · BALATON Zoltan

From: Benjamin Herrenschmidt <[email protected]>

It's currently broken as it uses an incorrect shift, it tries to use the slot number but uses the top bits of the bus number instead.

Note: Neither implementation matches what OpenBIOS ends up putting in the device-tree either, which will have to be fixed separately.

This is not quite correct for modelling a real Mac since Apple tend to tie all 4 interrupt lines of a slot together and have separate interrupts for every slot and every motherboard devices going straight to the PIC but we'll sort that out later.

---
 hw/pci-host/uninorth.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

This needs a corresponding fix in OpenBIOS but this has to be committed first for that. As this is already broken making this change should not make things worse as they are now. Could we get this in now as a bugfix commit?

Quoted 6 lines
Quoted 1 line

Applied to ppc-for-2.8.

Is this going in for 2.8? If so, I'll need to apply the corresponding patch to OpenBIOS to match and also do a PPC testing cycle to make sure that there are no regressions on other OSs. Plus it would be useful to get both pull requests in close proximity as this will break bisection.

(Adding BenH as these are his patches I just apparently forgot the cc.)

I'd appreciate if this could get in 2.8. As this is a bugfix this should be OK during the freeze. Likely there will be more rc cycles where it could be reverted if found to cause problems. But since it's already broken, applying this patch to QEMU should not break it more and adding the fix on the OpenBIOS side (patch 4/4) would complete the fix and may actually make it work. This should only affect mac99 and this one patch is independent from the other three I've sent to OpenBIOS so this could be applied independently to get at least the interrupts fixed if you can't test and apply the other three until the next pull.

Regards,
BALATON Zoltan

#5 lore raw
Quoted 7 lines · BALATON Zoltan
Quoted 4 lines

Is this going in for 2.8? If so, I'll need to apply the corresponding patch to OpenBIOS to match and also do a PPC testing cycle to make sure that there are no regressions on other OSs. Plus it would be useful to get both pull requests in close proximity as this will break bisection.

(Adding BenH as these are his patches I just apparently forgot the cc.)

Quoted 9 lines

I'd appreciate if this could get in 2.8. As this is a bugfix this should be OK during the freeze. Likely there will be more rc cycles where it could be reverted if found to cause problems. But since it's already broken, applying this patch to QEMU should not break it more and adding the fix on the OpenBIOS side (patch 4/4) would complete the fix and may actually make it work. This should only affect mac99 and this one patch is independent from the other three I've sent to OpenBIOS so this could be applied independently to get at least the interrupts fixed  if you can't test and apply the other three until the next pull.

Right, PCI IRQs are terminally broken already. This patch without the OpenBIOS change won't hurt. With the OpenBIOS change, things start working better :-)

I appologize for being basically MIA these days, way too busy with other things. Feel free to pick up ownership of my patches if you want to get them into upstreamable state, such as the SunGEM one.

I don't know if I'll have any bandwidth to work on that stuff again until later next year.

Cheers,
Ben.