From: geert@linux-m68k.org (Geert Uytterhoeven)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC 01/37] ARM: shmobile: Add watchdog support
Date: Fri, 26 Jan 2018 10:46:23 +0100 [thread overview]
Message-ID: <CAMuHMdWVvMJR5NHMFn6zx39jw2XdP5nteU3actUcen0dmoT-LQ@mail.gmail.com> (raw)
In-Reply-To: <1516903391-30467-2-git-send-email-fabrizio.castro@bp.renesas.com>
Hi Fabrizio,
On Thu, Jan 25, 2018 at 7:02 PM, Fabrizio Castro
<fabrizio.castro@bp.renesas.com> wrote:
> On R-Car Gen2 and RZ/G1 platforms, we use the SBAR registers to make non
> boot CPUs run a routine designed to bring up SMP and deal with hot plug.
> The value contained in the SBAR registers is not initialized by a WDT
> triggered reset, which means that after a WDT triggered reset we jump
> to the SMP bring up routine, preventing the system from executing the
> bootrom code.
Thanks for your patch!
> The purpose of this patch is to jump to the bootrom code in case of a
> WDT triggered reset, and keep the SMP functionality untouched.
> In order to tell if the code had been called due to the WDT overflowing
> we need to inspect flag WOVF from register RWTCSRA, however for this
> to work smoothly we need to make sure that RWDT clock is ON.
> Since it's not wise to interfere with the clock configuration from
> within this routine, a flag has been put in place
> (shmobile_wdt_clock_status) so that the watchdog driver can tell
> shmobile_boot_vector when the clock is ON, and therefore there is no
> need for shmobile_boot_vector to mess up with the clock registers.
>
> Bit WOVF survives a watchdog triggered reset, and it is usually cleared
> by the bootloader. Checking the MMU enable bit from register SCTLR
> allows us to make the code a little bit more robust (just in case the
> bit wasn't cleared up), as right after a reset the MMU is disabled,
> and when Linux is running the MMU is enabled. Also, accessing RWTCSRA
> physical address is safe when the MMU is down.
Checking a hardware register is indeed a better solution than my original
idea to let SMP bringup set a flag in RAM, as the former is less racy.
However, as you can probably imagine, I don't like the
shmobile_wdt_clock_status part ;-)
Isn't is sufficient to check the MMU enable bit?
However, that would precludes uClinux (do we care?).
Is there any other register/bit that's reset when the watchdog is
triggered, and always set by Linux?
> SMP bringup, CPU hot plug, and suspend to RAM work as normal.
shmobile_boot_vector is not only used for R-Car Gen2 and RZ/G1 SoCs, but
also for EMMA Mobile, SH/R-Mobile, and R-Car H1. Hence this breaks SMP
for the latter (and their build if ARCH_RENESAS=n, due to missing
shmobile_wdt_clock_status).
> Since shmobile_boot_vector has become bigger, "reg" property of nodes
> compatible with "renesas,smp-sram" now need to be set to "<0 0x64>".
This breaks backwards compatibility with old DTs declaring a too small
smp-sram area. If the area is too small, you should fallback to the old and
smaller code.
> --- a/arch/arm/mach-shmobile/headsmp.S
> +++ b/arch/arm/mach-shmobile/headsmp.S
> @@ -16,6 +16,13 @@
> #include <asm/assembler.h>
> #include <asm/memory.h>
>
> +#define RWDT_CLOCK_ON 0xdeadbeef
> +#define RWDT_CLOCK_OFF 0x00000000
> +#define SCTLR_MMU 0x01
> +#define BOOTROM_ADDRESS 0xE6340000
> +#define RWTCSRA_ADDRESS 0xE6020004
> +#define RWTCSRA_WOVF 0x10
> +
> /*
> * Reset vector for secondary CPUs.
> * This will be mapped at address 0 by SBAR register.
> @@ -24,11 +31,57 @@
> .arm
> .align 12
> ENTRY(shmobile_boot_vector)
This should become e.g. rcar_gen2_boot_vector_wdt
> +/*
> + if (SCTLR_MMU == 1)
> + goto shmobile_smp_continue;
> +*/
> + mrc p15, 0, r1, c1, c0, 0 @ r1 = SCTLR
> + and r0, r1, #SCTLR_MMU
> + cmp r0, #SCTLR_MMU
> + beq shmobile_smp_continue
> +/*
> + if (shmobile_wdt_clock_status != RWDT_CLOCK_ON)
> + goto shmobile_smp_continue;
> +*/
> + ldr r0, #shmobile_wdt_clock_status
> + ldr r1, #clock_on
> + cmp r0, r1
> + bne shmobile_smp_continue
> +
> +/*
> + if (RWTCSRA_WOVF == 0)
> + goto shmobile_smp_continue;
> +*/
> + ldr r0, rwtcsra
> + mov r1, #0
> + ldrb r1, [r0]
> + and r0, r1, #RWTCSRA_WOVF
> + cmp r0, #RWTCSRA_WOVF
> + bne shmobile_smp_continue
> +
> +/*
> + goto bootrom;
> +*/
> + ldr r0, bootrom
> + bx r0
> +
> +shmobile_smp_continue:
This should become
ENTRY(shmobile_boot_vector)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
next prev parent reply other threads:[~2018-01-26 9:46 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-25 18:02 [RFC 00/37] Fix watchdog on Renesas R-Car Gen2 and RZ/G1 Fabrizio Castro
2018-01-25 18:02 ` [RFC 01/37] ARM: shmobile: Add watchdog support Fabrizio Castro
2018-01-26 9:46 ` Geert Uytterhoeven [this message]
2018-01-26 9:49 ` Geert Uytterhoeven
2018-01-26 11:52 ` Fabrizio Castro
2018-01-26 12:10 ` Geert Uytterhoeven
2018-01-26 13:44 ` Fabrizio Castro
2018-01-26 16:08 ` [RFC v2 " Fabrizio Castro
2018-01-26 16:08 ` [RFC v2 23/37] ARM: shmobile: rcar-gen2: Export shmobile_set_wdt_clock_status function Fabrizio Castro
2018-01-26 16:16 ` [RFC v2 01/37] ARM: shmobile: Add watchdog support Fabrizio Castro
2018-01-25 18:02 ` [RFC 02/37] ARM: dts: r8a7743: Adjust SMP routine size Fabrizio Castro
2018-01-26 9:52 ` Geert Uytterhoeven
2018-01-25 18:02 ` [RFC 03/37] ARM: dts: r8a7745: " Fabrizio Castro
2018-01-26 9:52 ` Geert Uytterhoeven
2018-01-25 18:02 ` [RFC 04/37] ARM: dts: r8a7790: " Fabrizio Castro
2018-01-26 9:53 ` Geert Uytterhoeven
2018-01-25 18:02 ` [RFC 05/37] ARM: dts: r8a7791: " Fabrizio Castro
2018-01-26 9:53 ` Geert Uytterhoeven
2018-01-25 18:02 ` [RFC 06/37] ARM: dts: r8a7792: " Fabrizio Castro
2018-01-26 9:53 ` Geert Uytterhoeven
2018-01-25 18:02 ` [RFC 07/37] ARM: dts: r8a7793: " Fabrizio Castro
2018-01-26 9:53 ` Geert Uytterhoeven
2018-01-25 18:02 ` [RFC 08/37] ARM: dts: r8a7794: " Fabrizio Castro
2018-01-26 9:54 ` Geert Uytterhoeven
2018-01-25 18:02 ` [RFC 09/37] soc: renesas: rcar-rst: Add generic compatible strings Fabrizio Castro
2018-01-26 10:00 ` Geert Uytterhoeven
2018-01-25 18:02 ` [RFC 10/37] soc: renesas: rcar-rst: Enable watchdog as reset trigger for Gen2 Fabrizio Castro
2018-01-26 8:30 ` Sergei Shtylyov
2018-01-26 16:59 ` Fabrizio Castro
2018-01-26 10:05 ` Geert Uytterhoeven
2018-01-25 18:02 ` [RFC 11/37] soc: renesas: rcar-rst: Document generic compatible strings Fabrizio Castro
2018-01-26 10:06 ` Geert Uytterhoeven
2018-01-25 18:02 ` [RFC 12/37] ARM: dts: r8a7743: Use fallback rst compatible string Fabrizio Castro
2018-01-25 18:02 ` [RFC 13/37] ARM: dts: r8a7745: " Fabrizio Castro
2018-01-25 18:02 ` [RFC 14/37] ARM: dts: r8a7790: " Fabrizio Castro
2018-01-25 18:02 ` [RFC 15/37] ARM: dts: r8a7791: " Fabrizio Castro
2018-01-25 18:02 ` [RFC 16/37] ARM: dts: r8a7794: " Fabrizio Castro
2018-01-25 18:02 ` [RFC 17/37] arm64: dts: renesas: r8a7795: " Fabrizio Castro
2018-01-25 18:02 ` [RFC 18/37] arm64: dts: renesas: r8a7796: " Fabrizio Castro
2018-01-25 18:02 ` [RFC 19/37] arm64: dts: renesas: r8a77970: " Fabrizio Castro
2018-01-25 18:02 ` [RFC 20/37] arm64: dts: renesas: r8a77995: " Fabrizio Castro
2018-01-25 18:02 ` [RFC 21/37] dt-bindings: watchdog: renesas-wdt: Add R-Car Gen2 support Fabrizio Castro
2018-01-26 10:10 ` Geert Uytterhoeven
2018-01-25 18:02 ` [RFC 22/37] watchdog: renesas_wdt: Add restart support Fabrizio Castro
2018-01-26 10:11 ` Geert Uytterhoeven
2018-01-26 17:14 ` Guenter Roeck
2018-01-26 17:50 ` Fabrizio Castro
2018-01-25 18:02 ` [RFC 23/37] ARM: shmobile: rcar-gen2: Export shmobile_set_wdt_clock_status function Fabrizio Castro
2018-01-26 10:16 ` Geert Uytterhoeven
2018-01-25 18:02 ` [RFC 24/37] watchdog: renesas_wdt_gen2: Add Gen2 specific driver Fabrizio Castro
2018-01-26 10:22 ` Geert Uytterhoeven
2018-01-26 17:28 ` Guenter Roeck
2018-01-26 18:00 ` Fabrizio Castro
2018-01-25 18:02 ` [RFC 25/37] ARM: shmobile: defconfig: Enable RENESAS_WDT_GEN2 Fabrizio Castro
2018-01-25 18:03 ` [RFC 26/37] clk: renesas: r8a7743: Add rwdt clock Fabrizio Castro
2018-01-26 10:33 ` Geert Uytterhoeven
2018-01-25 18:03 ` [RFC 27/37] clk: renesas: r8a7745: " Fabrizio Castro
2018-01-26 10:24 ` Geert Uytterhoeven
2018-01-25 18:03 ` [RFC 28/37] clk: renesas: r8a7790: " Fabrizio Castro
2018-01-26 10:25 ` Geert Uytterhoeven
2018-01-25 18:03 ` [RFC 29/37] clk: renesas: r8a7791/r8a7793: " Fabrizio Castro
2018-01-26 10:25 ` Geert Uytterhoeven
2018-01-25 18:03 ` [RFC 30/37] clk: renesas: r8a7794: " Fabrizio Castro
2018-01-26 10:25 ` Geert Uytterhoeven
2018-01-25 18:03 ` [RFC 31/37] ARM: dts: r8a7743: Add watchdog support to SoC dtsi Fabrizio Castro
2018-01-26 10:27 ` Geert Uytterhoeven
2018-01-25 18:03 ` [RFC 32/37] ARM: dts: r8a7745: " Fabrizio Castro
2018-01-26 10:28 ` Geert Uytterhoeven
2018-01-25 18:03 ` [RFC 33/37] ARM: dts: r8a7790: " Fabrizio Castro
2018-01-26 10:30 ` Geert Uytterhoeven
2018-01-25 18:03 ` [RFC 34/37] ARM: dts: r8a7791: " Fabrizio Castro
2018-01-26 10:30 ` Geert Uytterhoeven
2018-01-25 18:03 ` [RFC 35/37] ARM: dts: r8a7794: " Fabrizio Castro
2018-01-26 10:31 ` Geert Uytterhoeven
2018-01-25 18:03 ` [RFC 36/37] ARM: dts: iwg20m: Add watchdog support to SoM dtsi Fabrizio Castro
2018-01-26 10:32 ` Geert Uytterhoeven
2018-01-25 18:03 ` [RFC 37/37] ARM: dts: iwg22m: " Fabrizio Castro
2018-01-26 10:32 ` Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAMuHMdWVvMJR5NHMFn6zx39jw2XdP5nteU3actUcen0dmoT-LQ@mail.gmail.com \
--to=geert@linux-m68k.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).