[PATCH v4] drivers/soc/litex: Add restart handler

Stafford Horne shorne at gmail.com
Tue Jan 19 17:11:10 EST 2021


On Wed, Jan 20, 2021 at 06:34:44AM +0900, Stafford Horne wrote:
> On Tue, Jan 19, 2021 at 09:09:38AM +0100, Geert Uytterhoeven wrote:
> > Let the LiteX SoC Controller register a restart handler, which resets
> > the LiteX SoC by writing 1 to CSR_CTRL_RESET_ADDR.
> > 
> > Signed-off-by: Geert Uytterhoeven <geert at linux-m68k.org>
> 
> Thanks, this looks good to me, queued to my linux-next branch.
> 
> -Stafford
> 
> > @@ -66,8 +71,19 @@ static int litex_check_csr_access(void __iomem *reg_addr)
> >  
> >  struct litex_soc_ctrl_device {
> >  	void __iomem *base;
> > +	struct notifier_block reset_nb;
> >  };
> >  
> > +static int litex_reset_handler(struct notifier_block *this, unsigned long mode,
> > +			       void *cmd)
> > +{
> > +	struct litex_soc_ctrl_device *soc_ctrl_dev =
> > +		container_of(this, struct litex_soc_ctrl_device, reset_nb);
> 
> Nice.
> 
> > +	litex_write32(soc_ctrl_dev->base + RESET_REG_OFF, RESET_REG_VALUE);
> > +	return NOTIFY_DONE;
> > +}
> > +

Actually, I tested this out on the latest (2-weeks ago) Litex and
openrisc/for-next and it didn't seem to work correctly.

I will look into it a bit closer, but if you see or can think of anything let
me know.  Note There are a few failures below related to network services as my
for-next kernel doesnt have a network driver (yet).

Using my buildroot rootfs: http://shorne.noip.me/downloads/or1k-glibc-rootfs.cpio.gz

    # shutdown -r now

    Broadcast message from root at buildroot (console) (Thu Jan  1 00:00:48 1970):
    The system is going down for reboot NOW!
    INIT: Switching to runlevel: 6
    # mounting home work nfs ...
    mount: mounting 10.0.0.27:/home/shorne/work on /home/shorne/work failed: No such device
    enabling login for shorne ...
    setting coredumps ...
    Stopping dropbear sshd: FAIL
    Stopping ntpd: FAIL
    Nothing to do, sntp is not a daemon.
    Stopping network: ifdown: interface lo not configured
    ifdown: interface eth0 not configured
    OK
    Saving random seed: [   52.020000] random: dd: uninitialized urandom read (512 bytes read)
    OK
    Stopping klogd: OK
    Stopping syslogd: start-stop-daemon: warning: killing process 51: No such process
    FAIL
    umount: devtmpfs busy - remounted read-only
    umount: can't unmount /: Invalid argument
    [   53.710000] reboot: Restarting system
    [   54.710000] Reboot failed -- System halted
    [   76.040000] watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [reboot:131]
    [   76.040000] CPU: 0 PID: 131 Comm: reboot Not tainted 5.11.0-rc1-00009-gff28dae0bc90 #418
    [   76.040000] CPU #: 0
    [   76.040000]    PC: c00050b8    SR: 0000827f    SP: c180fdb0
    [   76.040000] GPR00: 00000000 GPR01: c180fdb0 GPR02: c180fdc0 GPR03: 0000827f
    [   76.040000] GPR04: c0348944 GPR05: 00000000 GPR06: c180fc70 GPR07: 00000000
    [   76.040000] GPR08: c180fdb0 GPR09: c00050b8 GPR10: c180e000 GPR11: 0000001e
    [   76.040000] GPR12: 00000000 GPR13: 00000020 GPR14: 00000001 GPR15: 00000000
    [   76.040000] GPR16: 00000000 GPR17: c02e48d4 GPR18: 00418958 GPR19: c02e48d4
    [   76.040000] GPR20: 00000000 GPR21: 00000000 GPR22: c02e4018 GPR23: fffffffe
    [   76.040000] GPR24: ffffffff GPR25: 00000000 GPR26: 00000000 GPR27: 00000000
    [   76.040000] GPR28: 00000000 GPR29: ffffffff GPR30: 00000000 GPR31: ffffffff
    [   76.040000]   RES: 0000001e oGPR11: ffffffff
    [   76.040000] Process reboot (pid: 131, stackpage=c180a000)
    [   76.040000]
    [   76.040000] Stack:
    [   76.040000] Call trace:
    [   76.040000] [<(ptrval)>] machine_restart+0x44/0x5c
    [   76.040000] [<(ptrval)>] kernel_restart+0x78/0xa4
    [   76.040000] [<(ptrval)>] ? mutex_lock+0x24/0x50
    [   76.040000] [<(ptrval)>] __do_sys_reboot+0x1a8/0x21c
    [   76.040000] [<(ptrval)>] ? do_filp_open+0x40/0xa0
    [   76.040000] [<(ptrval)>] ? slab_free_freelist_hook+0x6c/0x14c
    [   76.040000] [<(ptrval)>] ? arch_local_irq_save+0x24/0x3c
    [   76.040000] [<(ptrval)>] ? kmem_cache_free+0x130/0x194
    [   76.040000] [<(ptrval)>] ? call_rcu+0x50/0x8c
    [   76.040000] [<(ptrval)>] ? __fput+0x2d0/0x2f4
    [   76.040000] [<(ptrval)>] ? do_sys_openat2+0xd8/0x134
    [   76.040000] [<(ptrval)>] ? task_work_run+0xbc/0xf4
    [   76.040000] [<(ptrval)>] ? do_work_pending+0x60/0x12c
    [   76.040000] [<(ptrval)>] sys_reboot+0x14/0x24
    [   76.040000] [<(ptrval)>] ? _syscall_return+0x0/0x4


-Stafford



More information about the linux-riscv mailing list