Misc sam460ex fixes (was: Clean up sam460ex irq mapping)
v3 cover Misc sam460ex fixes (was: Clean up sam460ex irq mapping)
So this is v3 of a series that started to fix a potential problem with irq mapping in pci440_pcix (used by sam460ex) that got some other fixes along the way as by-products. But it turns out the irq issue this was trying to fix is not really a problem so finally we just update the comment for now documenting why it works and only the by-products remain in this series. Of which there are two more in this v3 finally fixing a long standing problem booting MorphOS on sam460ex (which I've got after debugging similar problem with pegasos2/vt8231 that gave me an idea how to debug this.)
Regards,
BALATON Zoltan
BALATON Zoltan (5):
ppc4xx: Move common dependency on serial to common option
sam460ex: Remove FDT_PPC dependency from KConfig
ppc440_pcix: Improve comment for IRQ mapping
ppc440_pcix: Fix register write trace event
ppc440_pcix: Fix up pci config access
hw/ppc/Kconfig | 6 +----- hw/ppc/ppc440_pcix.c | 50 ++++++++++++++++++++++++++++---------------- hw/ppc/trace-events | 1 + 3 files changed, 34 insertions(+), 23 deletions(-)
Signature · 1 line
2.21.3
PATCH v3 1/5 ppc4xx: Move common dependency on serial to common option
All machines that select SERIAL also select PPC4XX so we can just add this common dependency there once.
--- hw/ppc/Kconfig | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
hw/ppc/Kconfig +1 -4
@@ -37,7 +37,6 @@ config PPC405 select M48T59 select PFLASH_CFI02 select PPC4XX - select SERIAL config PPC440 bool
@@ -46,13 +45,13 @@ config PPC440 imply E1000_PCI select PCI_EXPRESS select PPC4XX - select SERIAL select FDT_PPC config PPC4XX bool select BITBANG_I2C select PCI + select SERIAL config SAM460EX bool
@@ -61,7 +60,6 @@ config SAM460EX select IDE_SII3112 select M41T80 select PPC440 - select SERIAL select SM501 select SMBUS_EEPROM select USB_EHCI_SYSBUS
@@ -123,7 +121,6 @@ config VIRTEX bool select PPC4XX select PFLASH_CFI01 - select SERIAL select XILINX select XILINX_ETHLITE select FDT_PPC
Signature · 1 line
2.21.3
Re: [PATCH v3 1/5] ppc4xx: Move common dependency on serial to common option
Quoted 22 lines · BALATON Zoltan via
All machines that select SERIAL also select PPC4XX so we can just add this common dependency there once.
Signed-off-by BALATON Zoltan <[email protected]>--- hw/ppc/Kconfig | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)hw/ppc/Kconfig +0
-1@@ -37,7 +37,6 @@ config PPC405 select M48T59 select PFLASH_CFI02 select PPC4XX - select SERIAL config PPC440 bool@@ -46,13 +45,13 @@ config PPC440 imply E1000_PCI
hw/ppc/Kconfig config PPC440 · line 54
Quoted 10 lines
hw/ppc/Kconfig +1
-1select PCI_EXPRESS select PPC4XX - select SERIAL select FDT_PPC config PPC4XX bool select BITBANG_I2C select PCI + select SERIAL
Not sure whether this is really the right way to go... serial_hd() and serial_mm_init() are only used in ppc405_uc.c and ppc440_bamboo.c, so IMHO it does make sense to keep the SERIAL setting with PPC405 and PPC440.
hw/ppc/Kconfig config SAM460EX · line 64
Quoted 7 lines
hw/ppc/Kconfig +0
-1config SAM460EX bool@@ -61,7 +60,6 @@ config SAM460EX select IDE_SII3112 select M41T80 select PPC440 - select SERIAL
But this hunk here should be fine, I think, since PPC440 already includes the SERIAL switch.
Thomas
Quoted 12 lines
hw/ppc/Kconfig +0
-1select SM501 select SMBUS_EEPROM select USB_EHCI_SYSBUS@@ -123,7 +121,6 @@ config VIRTEX bool select PPC4XX select PFLASH_CFI01 - select SERIAL select XILINX select XILINX_ETHLITE select FDT_PPC
Re: [PATCH v3 1/5] ppc4xx: Move common dependency on serial to common option
Quoted 36 lines · Thomas Huth
Quoted 20 lines · BALATON Zoltan via
All machines that select SERIAL also select PPC4XX so we can just add this common dependency there once.
Signed-off-by BALATON Zoltan <[email protected]>--- hw/ppc/Kconfig | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)hw/ppc/Kconfig +0
-1@@ -37,7 +37,6 @@ config PPC405 select M48T59 select PFLASH_CFI02 select PPC4XX - select SERIAL config PPC440 boolhw/ppc/Kconfig config PPC440 · line 53
Quoted 10 lines
hw/ppc/Kconfig +1
-1@@ -46,13 +45,13 @@ config PPC440 imply E1000_PCI select PCI_EXPRESS select PPC4XX - select SERIAL select FDT_PPC config PPC4XX bool select BITBANG_I2C select PCI + select SERIALNot sure whether this is really the right way to go...
serial_hd()andserial_mm_init()are only used inppc405_uc.candppc440_bamboo.c, so IMHO it does make sense to keep the SERIAL setting with PPC405 and PPC440.
Quoted 9 lines
hw/ppc/Kconfig config SAM460EX · line 64
Quoted 7 lines
hw/ppc/Kconfig +0
-1config SAM460EX bool@@ -61,7 +60,6 @@ config SAM460EX select IDE_SII3112 select M41T80 select PPC440 - select SERIALBut this hunk here should be fine, I think, since PPC440 already includes the SERIAL switch.
If it's OK in this case why doesn't the same argument apply in case of PPC440 including PPC4XX which then includes SERIAL. All these boards use serial_mm_init but they also all include PPC4XX either directly or indirectly via an intermeriate option such as PPC440 or PPC405.
Regards,
BALATON Zoltan
Quoted 17 lines
Thomas
Quoted 12 lines
hw/ppc/Kconfig +0
-1select SM501 select SMBUS_EEPROM select USB_EHCI_SYSBUS@@ -123,7 +121,6 @@ config VIRTEX bool select PPC4XX select PFLASH_CFI01 - select SERIAL select XILINX select XILINX_ETHLITE select FDT_PPC
Re: [PATCH v3 1/5] ppc4xx: Move common dependency on serial to common option
Quoted 47 lines · BALATON Zoltan via
Quoted 36 lines · Thomas Huth
Quoted 22 lines · BALATON Zoltan via
All machines that select SERIAL also select PPC4XX so we can just add this common dependency there once.
Signed-off-by BALATON Zoltan <[email protected]>---
hw/ppc/Kconfig | 5 +----1 file changed, 1 insertion(+), 4 deletions(-)hw/ppc/Kconfig +0
-0@@ -37,7 +37,6 @@ config PPC405select M48T59
selectPFLASH_CFI02
select PPC4XX
- select SERIAL
config PPC440
boolhw/ppc/Kconfig +0
-0@@ -46,13 +45,13 @@ config PPC440imply
E1000_PCI
selectPCI_EXPRESSQuoted 8 lines
select PPC4XX
- select SERIAL
selectFDT_PPC
config PPC4XX
bool
selectBITBANG_I2C
select PCI
+ select SERIALNot sure whether this is really the right way to go...
serial_hd()andserial_mm_init()are only used inppc405_uc.candppc440_bamboo.c, so IMHO it does make sense to keep the SERIAL setting with PPC405 and PPC440.Quoted 9 lines
Quoted 7 lines
config SAM460EX
boolhw/ppc/Kconfig +0
-0@@ -61,7 +60,6 @@ config SAM460EXselect
IDE_SII3112
select M41T80
select PPC440
- select SERIALBut this hunk here should be fine, I think, since PPC440 already includes the SERIAL switch.
Quoted 1 line
If it's OK in this case why doesn't the same argument apply in case of PPC440 including PPC4XX which then includes SERIAL. All these boards use
serial_mm_initbut they also all include PPC4XX either directly or indirectly via an intermeriate option such as PPC440 or PPC405.
Yeah, it's likely cleaner if you keep the "select SERIAL" here, too, since sam460ex.c uses serial_hd() and serial_mm_init() directly, too.
I guess we should rather have a separate switch for the bamboo board, and then move the "select SERIAL" from the PPC440 section into the BAMBOO section...
Thomas
PATCH v3 2/5 sam460ex: Remove FDT_PPC dependency from KConfig
In reply to BALATON Zoltan viaDependency on FDT_PPC was added in commit b0048f76095 ("hw/ppc/Kconfig: Only select FDT helper for machines using it") but it does not seem to be really necessary so remove it again.
--- hw/ppc/Kconfig | 1 - 1 file changed, 1 deletion(-)
hw/ppc/Kconfig +0 -1
@@ -64,7 +64,6 @@ config SAM460EX select SMBUS_EEPROM select USB_EHCI_SYSBUS select USB_OHCI - select FDT_PPC config PREP bool
Signature · 1 line
2.21.3
PATCH v3 3/5 ppc440_pcix: Improve comment for IRQ mapping
In reply to BALATON Zoltan viaThe code mapping all PCI interrupts to a single CPU IRQ works but is not trivial so document it in a comment.
--- hw/ppc/ppc440_pcix.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
hw/ppc/ppc440_pcix.c +9 -2
@@ -415,8 +415,15 @@ static void ppc440_pcix_reset(DeviceState *dev) s->sts =0 ; } -/* All pins from each slot are tied to a single board IRQ. -* This may need further refactoring for other boards. */ +/* +* All four IRQ[ABCD] pins from all slots are tied to a single board +* IRQ, so our mapping function here maps everything to IRQ 0. +* The code in pci_change_irq_level() tracks the number of times +* the mapped IRQ is asserted and deasserted, so if multiple devices +* assert an IRQ at the same time the behaviour is correct. +* +* This may need further refactoring for boards that use multiple IRQ lines. +*/ static int ppc440_pcix_map_irq (PCIDevice *pci_dev,int irq_num) {trace_ppc440_pcix_map_irq (pci_dev->devfn, irq_num,0 );
Signature · 1 line
2.21.3
PATCH v3 4/5 ppc440_pcix: Fix register write trace event
In reply to BALATON Zoltan viaThe trace event for pci_host_config_write() was also using the trace event for read. Add corresponding trace and correct this.
--- hw/ppc/ppc440_pcix.c | 2 +- hw/ppc/trace-events | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
hw/ppc/ppc440_pcix.c +1 -1
@@ -169,7 +169,7 @@ static void ppc440_pcix_reg_write4(void *opaque, hwaddr addr, {struct PPC440PCIXState *s = opaque; -trace_ppc440_pcix_reg_read (addr, val); +trace_ppc440_pcix_reg_write (addr, val, size);switch (addr) { case PCI_VENDOR_ID ... PCI_MAX_LAT:stl_le_p (s->dev->config + addr, val);
hw/ppc/trace-events +1 -0
@@ -117,3 +117,4 @@ ppc440_pcix_set_irq(int irq_num) "PCI irq %d" ppc440_pcix_update_pim(int idx, uint64_t size, uint64_t la) "Added window %d of size=0x%" PRIx64 " to CPU=0x%" PRIx64 ppc440_pcix_update_pom(int idx, uint32_t size, uint64_t la, uint64_t pcia) "Added window %d of size=0x%x from CPU=0x%" PRIx64 " to PCI=0x%" PRIx64 ppc440_pcix_reg_read(uint64_t addr, uint32_t val) "addr 0x%" PRIx64 " = 0x%" PRIx32 +ppc440_pcix_reg_write(uint64_t addr, uint32_t val, uint32_t size) "addr 0x%" PRIx64 " = 0x%" PRIx32 " size 0x%" PRIx32
Signature · 1 line
2.21.3
Re: [PATCH v3 4/5] ppc440_pcix: Fix register write trace event
Quoted 8 lines · BALATON Zoltan via
The trace event for
pci_host_config_write()was also using the trace event for read. Add corresponding trace and correct this.Signed-off-by BALATON Zoltan <[email protected]>--- hw/ppc/ppc440_pcix.c | 2 +- hw/ppc/trace-events | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
PATCH v3 5/5 ppc440_pcix: Fix up pci config access
In reply to BALATON Zoltan viaThis fixes a long standing issue with MorphOS booting on sam460ex which turns out to be because of suspicious values written to PCI config address that apparently works on real machine but caused wrong access on this device model. This replaces a previous work around for this with a better fix that makes it work.
--- hw/ppc/ppc440_pcix.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-)
hw/ppc/ppc440_pcix.c +22 -15
@@ -449,28 +449,35 @@ static AddressSpace *ppc440_pcix_set_iommu(PCIBus *b, void *opaque, int devfn)return &s->bm_as; } -/* The default pci_host_data_{read,write} functions in pci/pci_host.c -* deny access to registers without bit 31 set but our clients want -* this to work so we have to override these here */ -static void pci_host_data_write (void *opaque,hwaddr addr, -uint64_t val,unsigned len) +/* +* Some guests on sam460ex write all kinds of garbage here such as +* missing enable bit and low bits set and still expect this to work +* (apparently it does on real hardware because these boot there) so +* we have to override these ops here and fix it up +*/ +static void pci_host_config_write (void *opaque,hwaddr addr, +uint64_t val,unsigned len) {PCIHostState *s = opaque; -pci_data_write (s->bus, s->config_reg | (addr &3 ), val, len); + +if (addr !=0 || len !=4 ) { +return ; + } + s->config_reg = (val &0xfffffffcULL ) | (1UL <<31 ); } -static uint64_t pci_host_data_read (void *opaque, -hwaddr addr,unsigned len) +static uint64_t pci_host_config_read (void *opaque,hwaddr addr, +unsigned len) {PCIHostState *s = opaque; -uint32_t val; - val =pci_data_read (s->bus, s->config_reg | (addr &3 ), len); +uint32_t val = s->config_reg; +return val; } -const MemoryRegionOps ppc440_pcix_host_data_ops = { - .read = pci_host_data_read, - .write = pci_host_data_write, +const MemoryRegionOps ppc440_pcix_host_conf_ops = { + .read = pci_host_config_read, + .write = pci_host_config_write, .endianness =DEVICE_LITTLE_ENDIAN , };
@@ -497,9 +504,9 @@ static void ppc440_pcix_realize(DeviceState *dev, Error **errp)pci_setup_iommu (h->bus, ppc440_pcix_set_iommu, s);memory_region_init (&s->container,OBJECT (s),"pci-container" ,PCI_ALL_SIZE ); -memory_region_init_io (&h->conf_mem,OBJECT (s), &pci_host_conf_le_ops, +memory_region_init_io (&h->conf_mem,OBJECT (s), &ppc440_pcix_host_conf_ops, h,"pci-conf-idx" ,4 ); -memory_region_init_io (&h->data_mem,OBJECT (s), &ppc440_pcix_host_data_ops, +memory_region_init_io (&h->data_mem,OBJECT (s), &pci_host_data_le_ops, h,"pci-conf-data" ,4 );memory_region_init_io (&s->iomem,OBJECT (s), &pci_reg_ops, s,"pci.reg" ,PPC440_REG_SIZE );
Signature · 1 line
2.21.3
David Gibson
AppliedQuoted 9 lines · BALATON Zoltan via
So this is v3 of a series that started to fix a potential problem with irq mapping in
pci440_pcix(used by sam460ex) that got some other fixes along the way as by-products. But it turns out the irq issue this was trying to fix is not really a problem so finally we just update the comment for now documenting why it works and only the by-products remain in this series. Of which there are two more in this v3 finally fixing a long standing problem booting MorphOS on sam460ex (which I've got after debugging similar problem with pegasos2/vt8231 that gave me an idea how to debug this.)
Applied to ppc-for-6.0.
So.. you're pretty much the only person who's shown any interest in the embedded ppc stuff in qemu for a pretty long time. Any chance I could convince you to be ppc4xx submaintainer?
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
Quoted 11 lines · David Gibson
Quoted 9 lines · BALATON Zoltan via
So this is v3 of a series that started to fix a potential problem with irq mapping in
pci440_pcix(used by sam460ex) that got some other fixes along the way as by-products. But it turns out the irq issue this was trying to fix is not really a problem so finally we just update the comment for now documenting why it works and only the by-products remain in this series. Of which there are two more in this v3 finally fixing a long standing problem booting MorphOS on sam460ex (which I've got after debugging similar problem with pegasos2/vt8231 that gave me an idea how to debug this.)
Quoted 5 lines
Applied to ppc-for-6.0.
So.. you're pretty much the only person who's shown any interest in the embedded ppc stuff in qemu for a pretty long time. Any chance I could convince you to be ppc4xx submaintainer?
Not if it involves testing or sending pull requests because I don't have time for that. I'm already listed as maintainer for stuff I contributed and try to review and test changes to that (i.e. sam460ex) but I'm afraid that's all I can do.
Regards,
BALATON Zoltan