[PATCH v1 01/12] hw/arm/aspeed: Fix missing SPI IRQ connection causing DMA interrupt failure

Jamin Lin via posted 12 patches 1 week, 1 day ago
Maintainers: "Cédric Le Goater" <clg@kaod.org>, Peter Maydell <peter.maydell@linaro.org>, Steven Lee <steven_lee@aspeedtech.com>, Troy Lee <leetroy@gmail.com>, Jamin Lin <jamin_lin@aspeedtech.com>, Andrew Jeffery <andrew@codeconstruct.com.au>, Joel Stanley <joel@jms.id.au>, Alistair Francis <alistair@alistair23.me>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
There is a newer version of this series
[PATCH v1 01/12] hw/arm/aspeed: Fix missing SPI IRQ connection causing DMA interrupt failure
Posted by Jamin Lin via 1 week, 1 day ago
It did not connect SPI IRQ to the Interrupt Controller, so even the SPI
model raised the IRQ, the interrupt was not received. The CPU therefore
did not trigger an interrupt via the controller, and the firmware never
received the interrupt.

Fixes: 356b230ed13889e09d087a96498887de695df17e ("aspeed/soc: Add AST1030 support")
Fixes: f25c0ae1079dc0b9de02676eb3e3949a09df9f41 ("aspeed/soc: Add AST2600 support")
Fixes: 5dd883ab0635c9f715c77cc32622e458a0724581 ("aspeed/soc: Add AST2700 support")
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
 hw/arm/aspeed_ast10x0.c | 2 ++
 hw/arm/aspeed_ast2600.c | 2 ++
 hw/arm/aspeed_ast27x0.c | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/hw/arm/aspeed_ast10x0.c b/hw/arm/aspeed_ast10x0.c
index 7f49c13391..ca487774ae 100644
--- a/hw/arm/aspeed_ast10x0.c
+++ b/hw/arm/aspeed_ast10x0.c
@@ -372,6 +372,8 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)
                         sc->memmap[ASPEED_DEV_SPI1 + i]);
         aspeed_mmio_map(s->memory, SYS_BUS_DEVICE(&s->spi[i]), 1,
                         ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base);
+        sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
+                           aspeed_soc_ast1030_get_irq(s, ASPEED_DEV_SPI1 + i));
     }
 
     /* Secure Boot Controller */
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
index 498d1ecc07..4c5a42ea17 100644
--- a/hw/arm/aspeed_ast2600.c
+++ b/hw/arm/aspeed_ast2600.c
@@ -557,6 +557,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
                         sc->memmap[ASPEED_DEV_SPI1 + i]);
         aspeed_mmio_map(s->memory, SYS_BUS_DEVICE(&s->spi[i]), 1,
                         ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base);
+        sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
+                           aspeed_soc_ast2600_get_irq(s, ASPEED_DEV_SPI1 + i));
     }
 
     /* EHCI */
diff --git a/hw/arm/aspeed_ast27x0.c b/hw/arm/aspeed_ast27x0.c
index c484bcd4e2..e02a674b13 100644
--- a/hw/arm/aspeed_ast27x0.c
+++ b/hw/arm/aspeed_ast27x0.c
@@ -831,6 +831,8 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)
                         sc->memmap[ASPEED_DEV_SPI0 + i]);
         aspeed_mmio_map(s->memory, SYS_BUS_DEVICE(&s->spi[i]), 1,
                         ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base);
+        sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
+                           aspeed_soc_ast2700_get_irq(s, ASPEED_DEV_SPI0 + i));
     }
 
     /* EHCI */
-- 
2.43.0
Re: [PATCH v1 01/12] hw/arm/aspeed: Fix missing SPI IRQ connection causing DMA interrupt failure
Posted by Cédric Le Goater 4 days, 5 hours ago
On 11/6/25 09:49, Jamin Lin wrote:
> It did not connect SPI IRQ to the Interrupt Controller, so even the SPI
> model raised the IRQ, the interrupt was not received. The CPU therefore
> did not trigger an interrupt via the controller, and the firmware never
> received the interrupt.
> 
> Fixes: 356b230ed13889e09d087a96498887de695df17e ("aspeed/soc: Add AST1030 support")
> Fixes: f25c0ae1079dc0b9de02676eb3e3949a09df9f41 ("aspeed/soc: Add AST2600 support")
> Fixes: 5dd883ab0635c9f715c77cc32622e458a0724581 ("aspeed/soc: Add AST2700 support")

QEMU 7.2 and above should be updated

> Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
> ---
>   hw/arm/aspeed_ast10x0.c | 2 ++
>   hw/arm/aspeed_ast2600.c | 2 ++
>   hw/arm/aspeed_ast27x0.c | 2 ++
>   3 files changed, 6 insertions(+)


Reviewed-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.



> diff --git a/hw/arm/aspeed_ast10x0.c b/hw/arm/aspeed_ast10x0.c
> index 7f49c13391..ca487774ae 100644
> --- a/hw/arm/aspeed_ast10x0.c
> +++ b/hw/arm/aspeed_ast10x0.c
> @@ -372,6 +372,8 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)
>                           sc->memmap[ASPEED_DEV_SPI1 + i]);
>           aspeed_mmio_map(s->memory, SYS_BUS_DEVICE(&s->spi[i]), 1,
>                           ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base);
> +        sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
> +                           aspeed_soc_ast1030_get_irq(s, ASPEED_DEV_SPI1 + i));
>       }
>   
>       /* Secure Boot Controller */
> diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
> index 498d1ecc07..4c5a42ea17 100644
> --- a/hw/arm/aspeed_ast2600.c
> +++ b/hw/arm/aspeed_ast2600.c
> @@ -557,6 +557,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
>                           sc->memmap[ASPEED_DEV_SPI1 + i]);
>           aspeed_mmio_map(s->memory, SYS_BUS_DEVICE(&s->spi[i]), 1,
>                           ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base);
> +        sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
> +                           aspeed_soc_ast2600_get_irq(s, ASPEED_DEV_SPI1 + i));
>       }
>   
>       /* EHCI */
> diff --git a/hw/arm/aspeed_ast27x0.c b/hw/arm/aspeed_ast27x0.c
> index c484bcd4e2..e02a674b13 100644
> --- a/hw/arm/aspeed_ast27x0.c
> +++ b/hw/arm/aspeed_ast27x0.c
> @@ -831,6 +831,8 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)
>                           sc->memmap[ASPEED_DEV_SPI0 + i]);
>           aspeed_mmio_map(s->memory, SYS_BUS_DEVICE(&s->spi[i]), 1,
>                           ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base);
> +        sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
> +                           aspeed_soc_ast2700_get_irq(s, ASPEED_DEV_SPI0 + i));
>       }
>   
>       /* EHCI */



Re: [PATCH v1 01/12] hw/arm/aspeed: Fix missing SPI IRQ connection causing DMA interrupt failure
Posted by Cédric Le Goater 1 week ago
Hello Jamin,

On 11/6/25 09:49, Jamin Lin wrote:
> It did not connect SPI IRQ to the Interrupt Controller, so even the SPI
> model raised the IRQ, the interrupt was not received. The CPU therefore
> did not trigger an interrupt via the controller, and the firmware never
> received the interrupt.
> 
> Fixes: 356b230ed13889e09d087a96498887de695df17e ("aspeed/soc: Add AST1030 support")
> Fixes: f25c0ae1079dc0b9de02676eb3e3949a09df9f41 ("aspeed/soc: Add AST2600 support")
> Fixes: 5dd883ab0635c9f715c77cc32622e458a0724581 ("aspeed/soc: Add AST2700 support")


AFAIR, the IRQ is for DMA which the drivers don't support yet.
Am I wrong ? When was it added ?

The code is fine and I am asking because of the fixes tags above.
It would mean propagating the fixes to the stable branches too.


Thanks,

C.

  

> Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
> ---
>   hw/arm/aspeed_ast10x0.c | 2 ++
>   hw/arm/aspeed_ast2600.c | 2 ++
>   hw/arm/aspeed_ast27x0.c | 2 ++
>   3 files changed, 6 insertions(+)
> 
> diff --git a/hw/arm/aspeed_ast10x0.c b/hw/arm/aspeed_ast10x0.c
> index 7f49c13391..ca487774ae 100644
> --- a/hw/arm/aspeed_ast10x0.c
> +++ b/hw/arm/aspeed_ast10x0.c
> @@ -372,6 +372,8 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)
>                           sc->memmap[ASPEED_DEV_SPI1 + i]);
>           aspeed_mmio_map(s->memory, SYS_BUS_DEVICE(&s->spi[i]), 1,
>                           ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base);
> +        sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
> +                           aspeed_soc_ast1030_get_irq(s, ASPEED_DEV_SPI1 + i));
>       }
>   
>       /* Secure Boot Controller */
> diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
> index 498d1ecc07..4c5a42ea17 100644
> --- a/hw/arm/aspeed_ast2600.c
> +++ b/hw/arm/aspeed_ast2600.c
> @@ -557,6 +557,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
>                           sc->memmap[ASPEED_DEV_SPI1 + i]);
>           aspeed_mmio_map(s->memory, SYS_BUS_DEVICE(&s->spi[i]), 1,
>                           ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base);
> +        sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
> +                           aspeed_soc_ast2600_get_irq(s, ASPEED_DEV_SPI1 + i));
>       }
>   
>       /* EHCI */
> diff --git a/hw/arm/aspeed_ast27x0.c b/hw/arm/aspeed_ast27x0.c
> index c484bcd4e2..e02a674b13 100644
> --- a/hw/arm/aspeed_ast27x0.c
> +++ b/hw/arm/aspeed_ast27x0.c
> @@ -831,6 +831,8 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)
>                           sc->memmap[ASPEED_DEV_SPI0 + i]);
>           aspeed_mmio_map(s->memory, SYS_BUS_DEVICE(&s->spi[i]), 1,
>                           ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base);
> +        sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
> +                           aspeed_soc_ast2700_get_irq(s, ASPEED_DEV_SPI0 + i));
>       }
>   
>       /* EHCI */
RE: [PATCH v1 01/12] hw/arm/aspeed: Fix missing SPI IRQ connection causing DMA interrupt failure
Posted by Jamin Lin 4 days, 13 hours ago
Hi Cédric,

> Subject: Re: [PATCH v1 01/12] hw/arm/aspeed: Fix missing SPI IRQ connection
> causing DMA interrupt failure
> 
> Hello Jamin,
> 
> On 11/6/25 09:49, Jamin Lin wrote:
> > It did not connect SPI IRQ to the Interrupt Controller, so even the
> > SPI model raised the IRQ, the interrupt was not received. The CPU
> > therefore did not trigger an interrupt via the controller, and the
> > firmware never received the interrupt.
> >
> > Fixes: 356b230ed13889e09d087a96498887de695df17e ("aspeed/soc: Add
> > AST1030 support")
> > Fixes: f25c0ae1079dc0b9de02676eb3e3949a09df9f41 ("aspeed/soc: Add
> > AST2600 support")
> > Fixes: 5dd883ab0635c9f715c77cc32622e458a0724581 ("aspeed/soc: Add
> > AST2700 support")
> 
> 
> AFAIR, the IRQ is for DMA which the drivers don't support yet.
> Am I wrong ? When was it added ?
> 
> The code is fine and I am asking because of the fixes tags above.
> It would mean propagating the fixes to the stable branches too.
> 

The reason is that the AST2500 supports FMC DMA but not SPI DMA.
For AST2600, AST1030, and AST2700, both FMC and SPI DMA are supported, but we missed connecting their IRQs to the interrupt controller.
"""I guess this happened because we copied the AST2500 SPI/FMC model when creating the AST2600 model, 
and then the AST1030 and AST2700 SoC models were copied from AST2600"""

Please see the drivers here:
Linux (AST2600 / AST2700)
https://github.com/AspeedTech-BMC/linux/blob/aspeed-master-v6.6/drivers/spi/spi-aspeed-smc.c 
AST2600:
static ssize_t aspeed_2600_spi_dirmap_dma_read(struct spi_mem_dirmap_desc *desc,
                                               u64 offs, size_t len, void *buf);

AST27x0:
static ssize_t aspeed_2700_spi_dirmap_dma_read(struct spi_mem_dirmap_desc *desc,
                                               u64 offs, size_t len, void *buf);
Zephyr (AST10x0)
https://github.com/AspeedTech-BMC/zephyr/blob/aspeed-main-v3.7.0/drivers/spi/spi_aspeed.c#L474 
#ifdef CONFIG_SPI_DMA_SUPPORT_ASPEED
static void aspeed_dma_irq_enable(const struct device *dev)

Thanks-Jamin

> 
> Thanks,
> 
> C.
> 
> 
> 
> > Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
> > ---
> >   hw/arm/aspeed_ast10x0.c | 2 ++
> >   hw/arm/aspeed_ast2600.c | 2 ++
> >   hw/arm/aspeed_ast27x0.c | 2 ++
> >   3 files changed, 6 insertions(+)
> >
> > diff --git a/hw/arm/aspeed_ast10x0.c b/hw/arm/aspeed_ast10x0.c index
> > 7f49c13391..ca487774ae 100644
> > --- a/hw/arm/aspeed_ast10x0.c
> > +++ b/hw/arm/aspeed_ast10x0.c
> > @@ -372,6 +372,8 @@ static void aspeed_soc_ast1030_realize(DeviceState
> *dev_soc, Error **errp)
> >                           sc->memmap[ASPEED_DEV_SPI1 + i]);
> >           aspeed_mmio_map(s->memory, SYS_BUS_DEVICE(&s->spi[i]),
> 1,
> >
> > ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base);
> > +        sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
> > +                           aspeed_soc_ast1030_get_irq(s,
> > + ASPEED_DEV_SPI1 + i));
> >       }
> >
> >       /* Secure Boot Controller */
> > diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c index
> > 498d1ecc07..4c5a42ea17 100644
> > --- a/hw/arm/aspeed_ast2600.c
> > +++ b/hw/arm/aspeed_ast2600.c
> > @@ -557,6 +557,8 @@ static void aspeed_soc_ast2600_realize(DeviceState
> *dev, Error **errp)
> >                           sc->memmap[ASPEED_DEV_SPI1 + i]);
> >           aspeed_mmio_map(s->memory, SYS_BUS_DEVICE(&s->spi[i]),
> 1,
> >
> > ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base);
> > +        sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
> > +                           aspeed_soc_ast2600_get_irq(s,
> > + ASPEED_DEV_SPI1 + i));
> >       }
> >
> >       /* EHCI */
> > diff --git a/hw/arm/aspeed_ast27x0.c b/hw/arm/aspeed_ast27x0.c index
> > c484bcd4e2..e02a674b13 100644
> > --- a/hw/arm/aspeed_ast27x0.c
> > +++ b/hw/arm/aspeed_ast27x0.c
> > @@ -831,6 +831,8 @@ static void aspeed_soc_ast2700_realize(DeviceState
> *dev, Error **errp)
> >                           sc->memmap[ASPEED_DEV_SPI0 + i]);
> >           aspeed_mmio_map(s->memory, SYS_BUS_DEVICE(&s->spi[i]),
> 1,
> >
> > ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base);
> > +        sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
> > +                           aspeed_soc_ast2700_get_irq(s,
> > + ASPEED_DEV_SPI0 + i));
> >       }
> >
> >       /* EHCI */