arm/aspeed: Watchdog and SDRAM fixes
Joel Stanley
maintainercover arm/aspeed: Watchdog and SDRAM fixes
Three of these are fixes for ast2600 models that I found when testing master. The forth is a usability improvement that is helpful when diagnosing why a watchdog is biting.
Joel Stanley (4):
aspeed/sdmc: Make ast2600 default 1G aspeed/scu: Fix W1C behavior watchdog/aspeed: Improve watchdog timeout message watchdog/aspeed: Fix AST2600 frequency behaviour
hw/misc/aspeed_scu.c | 11 ++++++++--- hw/misc/aspeed_sdmc.c | 6 +++--- hw/watchdog/wdt_aspeed.c | 24 +++++++++++++++++++----- include/hw/watchdog/wdt_aspeed.h | 1 + 4 files changed, 31 insertions(+), 11 deletions(-)
Signature · 1 line
2.24.0
Joel Stanley
maintainerPATCH 1/4 aspeed/sdmc: Make ast2600 default 1G
Most boards have this much.
--- hw/misc/aspeed_sdmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/misc/aspeed_sdmc.c +3 -3
@@ -208,10 +208,10 @@ static int ast2600_rambits(AspeedSDMCState *s) }/* use a common default */ -warn_report ("Invalid RAM size 0x%" PRIx64". Using default 512M" , +warn_report ("Invalid RAM size 0x%" PRIx64". Using default 1024M" , s->ram_size); - s->ram_size =512 <<20 ; -return ASPEED_SDMC_AST2600_512MB ; + s->ram_size =1024 <<20 ; +return ASPEED_SDMC_AST2600_1024MB ; }static void aspeed_sdmc_reset (DeviceState *dev)
Signature · 1 line
2.24.0
Re: [PATCH 1/4] aspeed/sdmc: Make ast2600 default 1G
Quoted 3 lines · Joel Stanley
Most boards have this much.
Signed-off-by Joel Stanley <[email protected]>
Quoted 23 lines
--- hw/misc/aspeed_sdmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)hw/misc/aspeed_sdmc.c +3
-3@@ -208,10 +208,10 @@ static int ast2600_rambits(AspeedSDMCState *s) }/* use a common default */ -warn_report ("Invalid RAM size 0x%" PRIx64". Using default 512M" , +warn_report ("Invalid RAM size 0x%" PRIx64". Using default 1024M" , s->ram_size); - s->ram_size =512 <<20 ; -return ASPEED_SDMC_AST2600_512MB ; + s->ram_size =1024 <<20 ; +return ASPEED_SDMC_AST2600_1024MB ; }static void aspeed_sdmc_reset (DeviceState *dev)
Joel Stanley
maintainerPATCH 2/4 aspeed/scu: Fix W1C behavior
In reply to Joel StanleyThis models the clock write one to clear registers, and fixes up some incorrect behavior in all of the write to clear registers.
There was also a typo in one of the register definitions.
--- hw/misc/aspeed_scu.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
hw/misc/aspeed_scu.c +8 -3
@@ -98,7 +98,7 @@#define AST2600_CLK_STOP_CTRL TO_REG(0x80)#define AST2600_CLK_STOP_CTRL_CLR TO_REG(0x84)#define AST2600_CLK_STOP_CTRL2 TO_REG(0x90) -#define AST2600_CLK_STOP_CTR2L_CLR TO_REG(0x94) +#define AST2600_CLK_STOP_CTRL2_CLR TO_REG(0x94)#define AST2600_SDRAM_HANDSHAKE TO_REG(0x100)#define AST2600_HPLL_PARAM TO_REG(0x200)#define AST2600_HPLL_EXT TO_REG(0x204)
@@ -532,11 +532,12 @@ static uint64_t aspeed_ast2600_scu_read(void *opaque, hwaddr offset,return s->regs[reg]; } -static void aspeed_ast2600_scu_write (void *opaque,hwaddr offset,uint64_t data, +static void aspeed_ast2600_scu_write (void *opaque,hwaddr offset,uint64_t data64,unsigned size) {AspeedSCUState *s =ASPEED_SCU (opaque);int reg =TO_REG (offset); +uint32_t data = data64;if (reg >=ASPEED_AST2600_SCU_NR_REGS ) { qemu_log_mask(LOG_GUEST_ERROR,
@@ -563,15 +564,19 @@ static void aspeed_ast2600_scu_write(void *opaque, hwaddr offset, uint64_t data,/* fall through */ case AST2600_SYS_RST_CTRL :case AST2600_SYS_RST_CTRL2 : +case AST2600_CLK_STOP_CTRL : +case AST2600_CLK_STOP_CTRL2 :/* W1S (Write 1 to set) registers */ s->regs[reg] |= data;return ;case AST2600_SYS_RST_CTRL_CLR :case AST2600_SYS_RST_CTRL2_CLR : +case AST2600_CLK_STOP_CTRL_CLR : +case AST2600_CLK_STOP_CTRL2_CLR :case AST2600_HW_STRAP1_CLR :case AST2600_HW_STRAP2_CLR :/* W1C (Write 1 to clear) registers */ - s->regs[reg] &= ~data; + s->regs[reg -1 ] &= ~data;return ;case AST2600_RNG_DATA :
Signature · 1 line
2.24.0
Re: [PATCH 2/4] aspeed/scu: Fix W1C behavior
Quoted 6 lines · Joel Stanley
This models the clock write one to clear registers, and fixes up some incorrect behavior in all of the write to clear registers.
There was also a typo in one of the register definitions.
Signed-off-by Joel Stanley <[email protected]>
Quoted 53 lines
--- hw/misc/aspeed_scu.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)hw/misc/aspeed_scu.c +8
-3@@ -98,7 +98,7 @@#define AST2600_CLK_STOP_CTRL TO_REG(0x80)#define AST2600_CLK_STOP_CTRL_CLR TO_REG(0x84)#define AST2600_CLK_STOP_CTRL2 TO_REG(0x90) -#define AST2600_CLK_STOP_CTR2L_CLR TO_REG(0x94) +#define AST2600_CLK_STOP_CTRL2_CLR TO_REG(0x94)#define AST2600_SDRAM_HANDSHAKE TO_REG(0x100)#define AST2600_HPLL_PARAM TO_REG(0x200)#define AST2600_HPLL_EXT TO_REG(0x204)@@ -532,11 +532,12 @@ static uint64_t aspeed_ast2600_scu_read(void *opaque, hwaddr offset,return s->regs[reg]; } -static void aspeed_ast2600_scu_write (void *opaque,hwaddr offset,uint64_t data, +static void aspeed_ast2600_scu_write (void *opaque,hwaddr offset,uint64_t data64,unsigned size) {AspeedSCUState *s =ASPEED_SCU (opaque);int reg =TO_REG (offset); +uint32_t data = data64;if (reg >=ASPEED_AST2600_SCU_NR_REGS ) { qemu_log_mask(LOG_GUEST_ERROR,@@ -563,15 +564,19 @@ static void aspeed_ast2600_scu_write(void *opaque, hwaddr offset, uint64_t data,/* fall through */ case AST2600_SYS_RST_CTRL :case AST2600_SYS_RST_CTRL2 : +case AST2600_CLK_STOP_CTRL : +case AST2600_CLK_STOP_CTRL2 :/* W1S (Write 1 to set) registers */ s->regs[reg] |= data;return ;case AST2600_SYS_RST_CTRL_CLR :case AST2600_SYS_RST_CTRL2_CLR : +case AST2600_CLK_STOP_CTRL_CLR : +case AST2600_CLK_STOP_CTRL2_CLR :case AST2600_HW_STRAP1_CLR :case AST2600_HW_STRAP2_CLR :/* W1C (Write 1 to clear) registers */ - s->regs[reg] &= ~data; + s->regs[reg -1 ] &= ~data;return ;case AST2600_RNG_DATA :
Joel Stanley
maintainerPATCH 3/4 watchdog/aspeed: Improve watchdog timeout message
In reply to Joel StanleyUsers benefit from knowing which watchdog timer has expired. The address of the watchdog's registers unambiguously indicates which has expired, so log that.
--- hw/watchdog/wdt_aspeed.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/watchdog/wdt_aspeed.c +2 -1
@@ -219,7 +219,8 @@ static void aspeed_wdt_timer_expired(void *dev)return ; } -qemu_log_mask (CPU_LOG_RESET ,"Watchdog timer expired.\n" ); +qemu_log_mask (CPU_LOG_RESET ,"Watchdog timer %08lx expired.\n" , + s->iomem.addr);watchdog_perform_action ();timer_del (s->timer); }
Signature · 1 line
2.24.0
Re: [PATCH 3/4] watchdog/aspeed: Improve watchdog timeout message
Quoted 5 lines · Joel Stanley
Users benefit from knowing which watchdog timer has expired. The address of the watchdog's registers unambiguously indicates which has expired, so log that.
Signed-off-by Joel Stanley <[email protected]>
The format below should be using HWADDR_PRIx. No need to resend. I will fix it.
C.
Quoted 19 lines
--- hw/watchdog/wdt_aspeed.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/watchdog/wdt_aspeed.c +2
-1@@ -219,7 +219,8 @@ static void aspeed_wdt_timer_expired(void *dev)return ; } -qemu_log_mask (CPU_LOG_RESET ,"Watchdog timer expired.\n" ); +qemu_log_mask (CPU_LOG_RESET ,"Watchdog timer %08lx expired.\n" , + s->iomem.addr);watchdog_perform_action ();timer_del (s->timer); }
Joel Stanley
maintainerPATCH 4/4 watchdog/aspeed: Fix AST2600 frequency behaviour
In reply to Joel StanleyThe AST2600 control register sneakily changed the meaning of bit 4 without anyone noticing. It no longer controls the 1MHz vs APB clock select, and instead always runs at 1MHz.
The AST2500 was always 1MHz too, but it retained bit 4, making it read only. We can model both using the same fixed 1MHz calculation.
--- hw/watchdog/wdt_aspeed.c | 21 +++++++++++++++++---- include/hw/watchdog/wdt_aspeed.h | 1 + 2 files changed, 18 insertions(+), 4 deletions(-)
hw/watchdog/wdt_aspeed.c +17 -4
@@ -93,11 +93,11 @@ static uint64_t aspeed_wdt_read(void *opaque, hwaddr offset, unsigned size) } -static void aspeed_wdt_reload (AspeedWDTState *s,bool pclk) +static void aspeed_wdt_reload (AspeedWDTState *s) {uint64_t reload; -if (pclk) { +if (!(s->regs[WDT_CTRL ] &WDT_CTRL_1MHZ_CLK )) { reload =muldiv64 (s->regs[WDT_RELOAD_VALUE ],NANOSECONDS_PER_SECOND , s->pclk_freq); }else {
@@ -109,6 +109,16 @@ static void aspeed_wdt_reload(AspeedWDTState *s, bool pclk) } } +static void aspeed_wdt_reload_1mhz (AspeedWDTState *s) +{ +uint64_t reload = s->regs[WDT_RELOAD_VALUE ] *1000ULL ; + +if (aspeed_wdt_is_enabled (s)) { +timer_mod (s->timer,qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ) + reload); + } +} + +static void aspeed_wdt_write (void *opaque,hwaddr offset,uint64_t data,unsigned size) {
@@ -130,13 +140,13 @@ static void aspeed_wdt_write(void *opaque, hwaddr offset, uint64_t data,case WDT_RESTART :if ((data &0xFFFF ) ==WDT_RESTART_MAGIC ) { s->regs[WDT_STATUS ] = s->regs[WDT_RELOAD_VALUE ]; -aspeed_wdt_reload (s, !(s->regs[WDT_CTRL ] &WDT_CTRL_1MHZ_CLK )); + awc->wdt_reload (s); }break ;case WDT_CTRL :if (enable && !aspeed_wdt_is_enabled (s)) { s->regs[WDT_CTRL ] = data; -aspeed_wdt_reload (s, !(data &WDT_CTRL_1MHZ_CLK )); + awc->wdt_reload (s); }else if (!enable &&aspeed_wdt_is_enabled (s)) { s->regs[WDT_CTRL ] = data;timer_del (s->timer);
@@ -283,6 +293,7 @@ static void aspeed_2400_wdt_class_init(ObjectClass *klass, void *data) awc->offset =0x20 ; awc->ext_pulse_width_mask =0xff ; awc->reset_ctrl_reg =SCU_RESET_CONTROL1 ; + awc->wdt_reload = aspeed_wdt_reload; }static const TypeInfo aspeed_2400_wdt_info = {
@@ -317,6 +328,7 @@ static void aspeed_2500_wdt_class_init(ObjectClass *klass, void *data) awc->ext_pulse_width_mask =0xfffff ; awc->reset_ctrl_reg =SCU_RESET_CONTROL1 ; awc->reset_pulse = aspeed_2500_wdt_reset_pulse; + awc->wdt_reload = aspeed_wdt_reload_1mhz; }static const TypeInfo aspeed_2500_wdt_info = {
@@ -336,6 +348,7 @@ static void aspeed_2600_wdt_class_init(ObjectClass *klass, void *data) awc->ext_pulse_width_mask =0xfffff ;/* TODO */ awc->reset_ctrl_reg =AST2600_SCU_RESET_CONTROL1 ; awc->reset_pulse = aspeed_2500_wdt_reset_pulse; + awc->wdt_reload = aspeed_wdt_reload_1mhz; }static const TypeInfo aspeed_2600_wdt_info = {
include/hw/watchdog/wdt_aspeed.h +1 -0
@@ -47,6 +47,7 @@ typedef struct AspeedWDTClass {uint32_t ext_pulse_width_mask;uint32_t reset_ctrl_reg;void (*reset_pulse)(AspeedWDTState *s,uint32_t property); + void (*wdt_reload)(AspeedWDTState *s); } AspeedWDTClass;#endif /* WDT_ASPEED_H */
Signature · 1 line
2.24.0
Re: [PATCH 4/4] watchdog/aspeed: Fix AST2600 frequency behaviour
Quoted 8 lines · Joel Stanley
The AST2600 control register sneakily changed the meaning of bit 4 without anyone noticing. It no longer controls the 1MHz vs APB clock select, and instead always runs at 1MHz.
The AST2500 was always 1MHz too, but it retained bit 4, making it read only. We can model both using the same fixed 1MHz calculation.
Fixes ea29711f467f ("watchdog/aspeed: Fix AST2600 control reg behaviour")
which commit is that ^ ? Did you mean :
Quoted 1 line
Signed-off-by Joel Stanley <[email protected]>
C.
Quoted 93 lines
--- hw/watchdog/wdt_aspeed.c | 21 +++++++++++++++++---- include/hw/watchdog/wdt_aspeed.h | 1 + 2 files changed, 18 insertions(+), 4 deletions(-)hw/watchdog/wdt_aspeed.c +17
-4@@ -93,11 +93,11 @@ static uint64_t aspeed_wdt_read(void *opaque, hwaddr offset, unsigned size) } -static void aspeed_wdt_reload (AspeedWDTState *s,bool pclk) +static void aspeed_wdt_reload (AspeedWDTState *s) {uint64_t reload; -if (pclk) { +if (!(s->regs[WDT_CTRL ] &WDT_CTRL_1MHZ_CLK )) { reload =muldiv64 (s->regs[WDT_RELOAD_VALUE ],NANOSECONDS_PER_SECOND , s->pclk_freq); }else {@@ -109,6 +109,16 @@ static void aspeed_wdt_reload(AspeedWDTState *s, bool pclk) } } +static void aspeed_wdt_reload_1mhz (AspeedWDTState *s) +{ +uint64_t reload = s->regs[WDT_RELOAD_VALUE ] *1000ULL ; + +if (aspeed_wdt_is_enabled (s)) { +timer_mod (s->timer,qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ) + reload); + } +} + +static void aspeed_wdt_write (void *opaque,hwaddr offset,uint64_t data,unsigned size) {@@ -130,13 +140,13 @@ static void aspeed_wdt_write(void *opaque, hwaddr offset, uint64_t data,case WDT_RESTART :if ((data &0xFFFF ) ==WDT_RESTART_MAGIC ) { s->regs[WDT_STATUS ] = s->regs[WDT_RELOAD_VALUE ]; -aspeed_wdt_reload (s, !(s->regs[WDT_CTRL ] &WDT_CTRL_1MHZ_CLK )); + awc->wdt_reload (s); }break ;case WDT_CTRL :if (enable && !aspeed_wdt_is_enabled (s)) { s->regs[WDT_CTRL ] = data; -aspeed_wdt_reload (s, !(data &WDT_CTRL_1MHZ_CLK )); + awc->wdt_reload (s); }else if (!enable &&aspeed_wdt_is_enabled (s)) { s->regs[WDT_CTRL ] = data;timer_del (s->timer);@@ -283,6 +293,7 @@ static void aspeed_2400_wdt_class_init(ObjectClass *klass, void *data) awc->offset =0x20 ; awc->ext_pulse_width_mask =0xff ; awc->reset_ctrl_reg =SCU_RESET_CONTROL1 ; + awc->wdt_reload = aspeed_wdt_reload; }static const TypeInfo aspeed_2400_wdt_info = {@@ -317,6 +328,7 @@ static void aspeed_2500_wdt_class_init(ObjectClass *klass, void *data) awc->ext_pulse_width_mask =0xfffff ; awc->reset_ctrl_reg =SCU_RESET_CONTROL1 ; awc->reset_pulse = aspeed_2500_wdt_reset_pulse; + awc->wdt_reload = aspeed_wdt_reload_1mhz; }static const TypeInfo aspeed_2500_wdt_info = {@@ -336,6 +348,7 @@ static void aspeed_2600_wdt_class_init(ObjectClass *klass, void *data) awc->ext_pulse_width_mask =0xfffff ;/* TODO */ awc->reset_ctrl_reg =AST2600_SCU_RESET_CONTROL1 ; awc->reset_pulse = aspeed_2500_wdt_reset_pulse; + awc->wdt_reload = aspeed_wdt_reload_1mhz; }static const TypeInfo aspeed_2600_wdt_info = {include/hw/watchdog/wdt_aspeed.h +1
-0@@ -47,6 +47,7 @@ typedef struct AspeedWDTClass {uint32_t ext_pulse_width_mask;uint32_t reset_ctrl_reg;void (*reset_pulse)(AspeedWDTState *s,uint32_t property); + void (*wdt_reload)(AspeedWDTState *s); } AspeedWDTClass;#endif /* WDT_ASPEED_H */
Joel Stanley
maintainerRe: [PATCH 4/4] watchdog/aspeed: Fix AST2600 frequency behaviour
Quoted 6 lines · Cédric Le Goater
Quoted 4 lines · Joel Stanley
The AST2600 control register sneakily changed the meaning of bit 4 without anyone noticing. It no longer controls the 1MHz vs APB clock select, and instead always runs at 1MHz.
Quoted 8 lines
Quoted 4 lines
The AST2500 was always 1MHz too, but it retained bit 4, making it read only. We can model both using the same fixed 1MHz calculation.
Fixes ea29711f467f ("watchdog/aspeed: Fix AST2600 control reg behaviour")which commit is that ^ ? Did you mean :
Fixes 6b2b2a703cad ("hw: wdt_aspeed: Add AST2600 support")
Yes. Thanks for catching that.
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#! /bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-mingw@fedora J=14 NETWORK=1
=== TEST SCRIPT END ===
CC qga/guest-agent-command-state.o
In file included from /tmp/qemu-test/src/hw/watchdog/wdt_aspeed.c:13:/tmp/qemu-test/src/hw/watchdog/wdt_aspeed.c: In function 'aspeed_wdt_timer_expired':/tmp/qemu-test/src/hw/watchdog/wdt_aspeed.c:232:34: error: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'hwaddr' {aka 'long long unsigned int'} [-Werror=format=]
qemu_log_mask(CPU_LOG_RESET, "Watchdog timer %08lx expired.\n",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s->iomem.addr);
---
^~~cc1: all warnings being treated as errors
BUILD pc-bios/optionrom/multiboot.img
make: *** [/tmp/qemu-test/src/rules.mak:69: hw/watchdog/wdt_aspeed.o] Error 1
make: *** Waiting for unfinished jobs....
CC qga/main.o
BUILD pc-bios/optionrom/linuxboot.img
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=f52d432b2dd64b048a6f416466c0033d', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-k6_g3bqv/src/docker-src.2019-11-12-10.02.49.13016:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-mingw']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=f52d432b2dd64b048a6f416466c0033d
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-k6_g3bqv/src'
make: *** [docker-run-test-mingw@fedora] Error 2
real 2m42.914s
user 0m7.862s
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]