All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Tudor Ambarus <tudor.ambarus@linaro.org>
Cc: Magnus Damm <magnus.damm@gmail.com>,
	Marek Vasut <marek.vasut+renesas@gmail.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	linux-renesas-soc@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mtd@lists.infradead.org
Subject: Re: [PATCH/RFC] ARM: dts: marzen: Add FLASH node
Date: Thu, 31 Aug 2023 13:19:53 +0200	[thread overview]
Message-ID: <CAMuHMdU6cLnaxU3z5fMAc+JwXB8z531tN4YXzTYoUwWWyT3jNA@mail.gmail.com> (raw)
In-Reply-To: <CAMuHMdV0WqD1FGccKCm9pZQK9MukD3yfsr2krg9dD2D_i=2KXA@mail.gmail.com>

On Mon, Apr 10, 2023 at 11:25 AM Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> On Fri, Apr 7, 2023 at 9:16 AM Tudor Ambarus <tudor.ambarus@linaro.org> wrote:
> > On 4/3/23 17:29, Geert Uytterhoeven wrote:
> > > On Tue, Mar 21, 2023 at 4:01 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > >> On Mon, Mar 20, 2023 at 7:57 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > >>> On Mon, Mar 20, 2023 at 6:04 PM Tudor Ambarus <tudor.ambarus@linaro.org> wrote:
> > >>>> Vignesh used to review CFI code, maybe he can intervene. I've never
> > >>>> worked with CFI, but I can try to help. I'll need more debug data though.
> > >>>>
> > >>>> On 3/20/23 16:43, Geert Uytterhoeven wrote:
> > >>>>> Add a device node for the Spansion S29GL512N NOR FLASH on the Marzen
> > >>>>> development board.
> > >>>>>
> > >>>>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > >>>>> ---
> > >>>>> Although the S29GL512N is a CFI FLASH, using "cfi-flash" instead of
> > >>>>> "mtd-rom" does not work:
> > >>>>>   1. Probing fails with "physmap-flash 0.flash: map_probe failed",
> > >>>>
> > >>>> I would first try to understand why the probe fails.
> > >
> > >> I suddenly remembered I have a different board (APE6-EVM), where
> > >> the CFI-FLASH stopped working after adding support for secondary
> > >> CPUs. I always thought that was a hardware quirk...
> > >>
> > >> Turns out the CFI-FLASH on Marzen (quad Cortex-A9) is detected when
> > >> booting with "nosmp":
> > >
> > >> My first guess was that the probing process is migrated to a different
> > >> CPU core during probing, but printing smp_processor_id() didn't
> > >> confirm that; it's just running on a different CPU core than CPU0.
> > >> Wrapping the body of cfi_qry_mode_on() inside a get_cpu()/put_cpu()
> > >> pair to prevent migration also didn't fix it.
> > >>
> > >> Is CFI-FLASH known-broken on SMP?
> > >
> > > After actively looking for more boards with CFI FLASHes, and finding one
> > > more board where FLASH probing fails on SMP, I dug deeper.
> > > Turns out they all have in common that (a) the CFI FLASH is located at
> > > physical address zero, and (b) the secondary CPU bringup code relies
> > > on mapping (by special hardware) the region at address zero to the
> > > CPU boot code...
> > >
> > > Hence fixing this involves making sure that accessing FLASH and bringing
> > > CPU cores online do not happen concurrently...
> >
> > Would deferring probe for CFI work?
>
> Probe deferral of CFI FLASH would not help, as the FLASH is already
> probed after secondary CPU startup.
>
> Sequence of operations is:
>   1. Map first page(s) of physical address space to RAM containing
>      CPU startup code (not using the MMU, but using a special
>      register in the SoC),
>   2. Boot secondary CPU cores,
>   3. Probe CFI-FLASH: fails, as accesses to the first page(s) of
>      physical address space do not address the FLASH, but the CPU
>      startup code in RAM.
>   4. After boot, CPU cores can be offlined and onlined using CPU
>       hotplug through sysfs.
>
> When using "mtd-rom" instead of "cfi-flash", the system boots fine,
> but the first page of /dev/mtd0 does not contain the FLASH contents,
> but the CPU startup code, which I hadn't noticed originally...
>
> Disabling the special mapping for the CPU startup code after all cores
> have been brought up (in between steps 2 and 3) fixes the CFI-FLASH.
> However, if a CPU core is offlined and onlined at run-time, the special
> mapping has to be reinstantiated temporarily again, thus any FLASH
> accesses (by other CPUs) must be prevented temporarily, too.
>
> This issue is present on all Renesas SH/R-Mobile and R-Car SoCs
> that support SMP. I am wondering if there are any other SMP SoCS that
> suffer from similar issues, and that have solved them? I couldn't find
> any in-tree DTS for a board with CFI-FLASH or mtd-rom at address zero
> using an SMP ARM SoC...
>
> I guess the simplest "solution" is to disable in DT any device at address zero
> when SMP is used (when step 1 is executed)...

Or reserve the boot area using request_mem_region().
I have posted an RFC patch series doing that:
"[PATCH/RFC 0/4] ARM: shmobile: Reserve boot area when SMP is enabled"
https://lore.kernel.org/all/cover.1693409184.git.geert+renesas@glider.be

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@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

WARNING: multiple messages have this Message-ID (diff)
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Tudor Ambarus <tudor.ambarus@linaro.org>
Cc: Magnus Damm <magnus.damm@gmail.com>,
	Marek Vasut <marek.vasut+renesas@gmail.com>,
	 Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	 Vignesh Raghavendra <vigneshr@ti.com>,
	linux-renesas-soc@vger.kernel.org,
	 linux-arm-kernel@lists.infradead.org,
	linux-mtd@lists.infradead.org
Subject: Re: [PATCH/RFC] ARM: dts: marzen: Add FLASH node
Date: Thu, 31 Aug 2023 13:19:53 +0200	[thread overview]
Message-ID: <CAMuHMdU6cLnaxU3z5fMAc+JwXB8z531tN4YXzTYoUwWWyT3jNA@mail.gmail.com> (raw)
In-Reply-To: <CAMuHMdV0WqD1FGccKCm9pZQK9MukD3yfsr2krg9dD2D_i=2KXA@mail.gmail.com>

On Mon, Apr 10, 2023 at 11:25 AM Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> On Fri, Apr 7, 2023 at 9:16 AM Tudor Ambarus <tudor.ambarus@linaro.org> wrote:
> > On 4/3/23 17:29, Geert Uytterhoeven wrote:
> > > On Tue, Mar 21, 2023 at 4:01 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > >> On Mon, Mar 20, 2023 at 7:57 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > >>> On Mon, Mar 20, 2023 at 6:04 PM Tudor Ambarus <tudor.ambarus@linaro.org> wrote:
> > >>>> Vignesh used to review CFI code, maybe he can intervene. I've never
> > >>>> worked with CFI, but I can try to help. I'll need more debug data though.
> > >>>>
> > >>>> On 3/20/23 16:43, Geert Uytterhoeven wrote:
> > >>>>> Add a device node for the Spansion S29GL512N NOR FLASH on the Marzen
> > >>>>> development board.
> > >>>>>
> > >>>>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > >>>>> ---
> > >>>>> Although the S29GL512N is a CFI FLASH, using "cfi-flash" instead of
> > >>>>> "mtd-rom" does not work:
> > >>>>>   1. Probing fails with "physmap-flash 0.flash: map_probe failed",
> > >>>>
> > >>>> I would first try to understand why the probe fails.
> > >
> > >> I suddenly remembered I have a different board (APE6-EVM), where
> > >> the CFI-FLASH stopped working after adding support for secondary
> > >> CPUs. I always thought that was a hardware quirk...
> > >>
> > >> Turns out the CFI-FLASH on Marzen (quad Cortex-A9) is detected when
> > >> booting with "nosmp":
> > >
> > >> My first guess was that the probing process is migrated to a different
> > >> CPU core during probing, but printing smp_processor_id() didn't
> > >> confirm that; it's just running on a different CPU core than CPU0.
> > >> Wrapping the body of cfi_qry_mode_on() inside a get_cpu()/put_cpu()
> > >> pair to prevent migration also didn't fix it.
> > >>
> > >> Is CFI-FLASH known-broken on SMP?
> > >
> > > After actively looking for more boards with CFI FLASHes, and finding one
> > > more board where FLASH probing fails on SMP, I dug deeper.
> > > Turns out they all have in common that (a) the CFI FLASH is located at
> > > physical address zero, and (b) the secondary CPU bringup code relies
> > > on mapping (by special hardware) the region at address zero to the
> > > CPU boot code...
> > >
> > > Hence fixing this involves making sure that accessing FLASH and bringing
> > > CPU cores online do not happen concurrently...
> >
> > Would deferring probe for CFI work?
>
> Probe deferral of CFI FLASH would not help, as the FLASH is already
> probed after secondary CPU startup.
>
> Sequence of operations is:
>   1. Map first page(s) of physical address space to RAM containing
>      CPU startup code (not using the MMU, but using a special
>      register in the SoC),
>   2. Boot secondary CPU cores,
>   3. Probe CFI-FLASH: fails, as accesses to the first page(s) of
>      physical address space do not address the FLASH, but the CPU
>      startup code in RAM.
>   4. After boot, CPU cores can be offlined and onlined using CPU
>       hotplug through sysfs.
>
> When using "mtd-rom" instead of "cfi-flash", the system boots fine,
> but the first page of /dev/mtd0 does not contain the FLASH contents,
> but the CPU startup code, which I hadn't noticed originally...
>
> Disabling the special mapping for the CPU startup code after all cores
> have been brought up (in between steps 2 and 3) fixes the CFI-FLASH.
> However, if a CPU core is offlined and onlined at run-time, the special
> mapping has to be reinstantiated temporarily again, thus any FLASH
> accesses (by other CPUs) must be prevented temporarily, too.
>
> This issue is present on all Renesas SH/R-Mobile and R-Car SoCs
> that support SMP. I am wondering if there are any other SMP SoCS that
> suffer from similar issues, and that have solved them? I couldn't find
> any in-tree DTS for a board with CFI-FLASH or mtd-rom at address zero
> using an SMP ARM SoC...
>
> I guess the simplest "solution" is to disable in DT any device at address zero
> when SMP is used (when step 1 is executed)...

Or reserve the boot area using request_mem_region().
I have posted an RFC patch series doing that:
"[PATCH/RFC 0/4] ARM: shmobile: Reserve boot area when SMP is enabled"
https://lore.kernel.org/all/cover.1693409184.git.geert+renesas@glider.be

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@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

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

WARNING: multiple messages have this Message-ID (diff)
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Tudor Ambarus <tudor.ambarus@linaro.org>
Cc: Magnus Damm <magnus.damm@gmail.com>,
	Marek Vasut <marek.vasut+renesas@gmail.com>,
	 Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	 Vignesh Raghavendra <vigneshr@ti.com>,
	linux-renesas-soc@vger.kernel.org,
	 linux-arm-kernel@lists.infradead.org,
	linux-mtd@lists.infradead.org
Subject: Re: [PATCH/RFC] ARM: dts: marzen: Add FLASH node
Date: Thu, 31 Aug 2023 13:19:53 +0200	[thread overview]
Message-ID: <CAMuHMdU6cLnaxU3z5fMAc+JwXB8z531tN4YXzTYoUwWWyT3jNA@mail.gmail.com> (raw)
In-Reply-To: <CAMuHMdV0WqD1FGccKCm9pZQK9MukD3yfsr2krg9dD2D_i=2KXA@mail.gmail.com>

On Mon, Apr 10, 2023 at 11:25 AM Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> On Fri, Apr 7, 2023 at 9:16 AM Tudor Ambarus <tudor.ambarus@linaro.org> wrote:
> > On 4/3/23 17:29, Geert Uytterhoeven wrote:
> > > On Tue, Mar 21, 2023 at 4:01 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > >> On Mon, Mar 20, 2023 at 7:57 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > >>> On Mon, Mar 20, 2023 at 6:04 PM Tudor Ambarus <tudor.ambarus@linaro.org> wrote:
> > >>>> Vignesh used to review CFI code, maybe he can intervene. I've never
> > >>>> worked with CFI, but I can try to help. I'll need more debug data though.
> > >>>>
> > >>>> On 3/20/23 16:43, Geert Uytterhoeven wrote:
> > >>>>> Add a device node for the Spansion S29GL512N NOR FLASH on the Marzen
> > >>>>> development board.
> > >>>>>
> > >>>>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > >>>>> ---
> > >>>>> Although the S29GL512N is a CFI FLASH, using "cfi-flash" instead of
> > >>>>> "mtd-rom" does not work:
> > >>>>>   1. Probing fails with "physmap-flash 0.flash: map_probe failed",
> > >>>>
> > >>>> I would first try to understand why the probe fails.
> > >
> > >> I suddenly remembered I have a different board (APE6-EVM), where
> > >> the CFI-FLASH stopped working after adding support for secondary
> > >> CPUs. I always thought that was a hardware quirk...
> > >>
> > >> Turns out the CFI-FLASH on Marzen (quad Cortex-A9) is detected when
> > >> booting with "nosmp":
> > >
> > >> My first guess was that the probing process is migrated to a different
> > >> CPU core during probing, but printing smp_processor_id() didn't
> > >> confirm that; it's just running on a different CPU core than CPU0.
> > >> Wrapping the body of cfi_qry_mode_on() inside a get_cpu()/put_cpu()
> > >> pair to prevent migration also didn't fix it.
> > >>
> > >> Is CFI-FLASH known-broken on SMP?
> > >
> > > After actively looking for more boards with CFI FLASHes, and finding one
> > > more board where FLASH probing fails on SMP, I dug deeper.
> > > Turns out they all have in common that (a) the CFI FLASH is located at
> > > physical address zero, and (b) the secondary CPU bringup code relies
> > > on mapping (by special hardware) the region at address zero to the
> > > CPU boot code...
> > >
> > > Hence fixing this involves making sure that accessing FLASH and bringing
> > > CPU cores online do not happen concurrently...
> >
> > Would deferring probe for CFI work?
>
> Probe deferral of CFI FLASH would not help, as the FLASH is already
> probed after secondary CPU startup.
>
> Sequence of operations is:
>   1. Map first page(s) of physical address space to RAM containing
>      CPU startup code (not using the MMU, but using a special
>      register in the SoC),
>   2. Boot secondary CPU cores,
>   3. Probe CFI-FLASH: fails, as accesses to the first page(s) of
>      physical address space do not address the FLASH, but the CPU
>      startup code in RAM.
>   4. After boot, CPU cores can be offlined and onlined using CPU
>       hotplug through sysfs.
>
> When using "mtd-rom" instead of "cfi-flash", the system boots fine,
> but the first page of /dev/mtd0 does not contain the FLASH contents,
> but the CPU startup code, which I hadn't noticed originally...
>
> Disabling the special mapping for the CPU startup code after all cores
> have been brought up (in between steps 2 and 3) fixes the CFI-FLASH.
> However, if a CPU core is offlined and onlined at run-time, the special
> mapping has to be reinstantiated temporarily again, thus any FLASH
> accesses (by other CPUs) must be prevented temporarily, too.
>
> This issue is present on all Renesas SH/R-Mobile and R-Car SoCs
> that support SMP. I am wondering if there are any other SMP SoCS that
> suffer from similar issues, and that have solved them? I couldn't find
> any in-tree DTS for a board with CFI-FLASH or mtd-rom at address zero
> using an SMP ARM SoC...
>
> I guess the simplest "solution" is to disable in DT any device at address zero
> when SMP is used (when step 1 is executed)...

Or reserve the boot area using request_mem_region().
I have posted an RFC patch series doing that:
"[PATCH/RFC 0/4] ARM: shmobile: Reserve boot area when SMP is enabled"
https://lore.kernel.org/all/cover.1693409184.git.geert+renesas@glider.be

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-08-31 11:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20 16:43 [PATCH/RFC] ARM: dts: marzen: Add FLASH node Geert Uytterhoeven
2023-03-20 16:43 ` Geert Uytterhoeven
2023-03-20 16:43 ` Geert Uytterhoeven
2023-03-20 17:04 ` Tudor Ambarus
2023-03-20 17:04   ` Tudor Ambarus
2023-03-20 17:04   ` Tudor Ambarus
2023-03-20 18:57   ` Geert Uytterhoeven
2023-03-20 18:57     ` Geert Uytterhoeven
2023-03-20 18:57     ` Geert Uytterhoeven
2023-03-21 15:01     ` Geert Uytterhoeven
2023-03-21 15:01       ` Geert Uytterhoeven
2023-03-21 15:01       ` Geert Uytterhoeven
2023-04-03 16:29       ` Geert Uytterhoeven
2023-04-03 16:29         ` Geert Uytterhoeven
2023-04-03 16:29         ` Geert Uytterhoeven
2023-04-07  7:16         ` Tudor Ambarus
2023-04-07  7:16           ` Tudor Ambarus
2023-04-07  7:16           ` Tudor Ambarus
2023-04-10  9:25           ` Geert Uytterhoeven
2023-04-10  9:25             ` Geert Uytterhoeven
2023-04-10  9:25             ` Geert Uytterhoeven
2023-08-31 11:19             ` Geert Uytterhoeven [this message]
2023-08-31 11:19               ` Geert Uytterhoeven
2023-08-31 11:19               ` 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=CAMuHMdU6cLnaxU3z5fMAc+JwXB8z531tN4YXzTYoUwWWyT3jNA@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=marek.vasut+renesas@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=tudor.ambarus@linaro.org \
    --cc=vigneshr@ti.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.