Skip to contentSkip to conversation

ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

PATCH New Nico Becker 5 participants 34 messages Feb 6, 2020 – Mar 31, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Hello,
after removing the function socfpga_sdram_apply_static_cfg() in misc_gen5 we can not use the FPGA2SDRAM bridge.

Without the apply static cfg the kernel crash every time, if we try to write @ the fpga2sdram bridge. After an soft reset everything is working.

If we add the socfpga_sdram_apply_static_cfg() in the u-boot source code, everything is fine.
Now we can use the fpga2sdram bridge after power on.

Our setup:
- u-boot v2020.01
- load and write fpga firmware
- enable bridges
- boot linux

I have found some information at
<https://support.criticallink.com/redmine/projects/mityarm-5cs/wiki/Important_Note_about_FPGAHPS_SDRAM_Bridge>
<http://u-boot.10912.n7.nabble.com/WG-Linux-hang-td314276.html>

Signature · 2 lines
Best regards
Nico Becker
#1 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 1 line · Nico Becker

Hello,

Hi,

Quoted 17 lines

after removing the function socfpga_sdram_apply_static_cfg() in misc_gen5 we can not use the FPGA2SDRAM bridge.

Without the apply static cfg the kernel crash every time, if we try to write @ the fpga2sdram bridge. After an soft reset everything is working.

If we add the socfpga_sdram_apply_static_cfg() in the u-boot source code, everything is fine.
Now we can use the fpga2sdram bridge after power on.

Our setup:
- u-boot v2020.01
  - load and write fpga firmware
  - enable bridges
- boot linux

Quoted 4 lines

I have found some information at
<https://support.criticallink.com/redmine/projects/mityarm-5cs/wiki/Important_Note_about_FPGAHPS_SDRAM_Bridge>

<http://u-boot.10912.n7.nabble.com/WG-Linux-hang-td314276.html>

Can you send a patch which fixes this for you, with Fixes: tag ? Then it would be clear what you changed.

Thanks

#2 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Am 06.02.2020 um 12:53 schrieb Marek Vasut:

Quoted 25 lines · Nico Becker
Quoted 1 line

Hello,

Hi,

Quoted 20 lines

after removing the function socfpga_sdram_apply_static_cfg() in misc_gen5 we can not use the FPGA2SDRAM bridge.

Without the apply static cfg the kernel crash every time, if we try to write @ the fpga2sdram bridge. After an soft reset everything is working.

If we add the socfpga_sdram_apply_static_cfg() in the u-boot source code, everything is fine.
Now we can use the fpga2sdram bridge after power on.

Our setup:
- u-boot v2020.01
  - load and write fpga firmware
  - enable bridges
- boot linux

I have found some information at
<https://support.criticallink.com/redmine/projects/mityarm-5cs/wiki/Important_Note_about_FPGAHPS_SDRAM_Bridge>

Quoted 7 lines
Quoted 1 line

<http://u-boot.10912.n7.nabble.com/WG-Linux-hang-td314276.html>

Can you send a patch which fixes this for you, with Fixes: tag ? Then it would be clear what you changed.

Thanks

Hello,
the code was removed @ commit c5f4b805.

I attached my patch, sorry for the format, i am new in this.

Thanks a lot

---
  arch/arm/mach-socfpga/misc_gen5.c | 31 +++++++++++++++++++++++++++++++
  1 file changed, 31 insertions(+)
(quoted diff) +0 -0

b/arch/arm/mach-socfpga/misc_gen5.c
index 22042d0de0..19c6d24170 100644

arch/arm/mach-socfpga/misc_gen5.c +0 -0
@@ -213,6 +213,35 @@ static struct socfpga_reset_manager 

*reset_manager_base =
static struct socfpga_sdr_ctrl *sdr_ctrl =
(struct socfpga_sdr_ctrl *)SDR_CTRLGRP_ADDRESS;

+static void socfpga_sdram_apply_static_cfg(void)
+{
+ const u32 applymask = 0x8;
+ u32 val = readl(&sdr_ctrl->static_cfg) | applymask;
+
+ /*
+ * SDRAM staticcfg register specific:
+ * When applying the register setting, the CPU must not access
+ * SDRAM. Luckily for us, we can abuse i-cache here to help us
+ * circumvent the SDRAM access issue. The idea is to make sure
+ * that the code is in one full i-cache line by branching past
+ * it and back. Once it is in the i-cache, we execute the core
+ * of the code and apply the register settings.
+ *
+ * The code below uses 7 instructions, while the Cortex-A9 has
+ * 32-byte cachelines, thus the limit is 8 instructions total.
+ */
+ asm volatile(
+ ".align 5 \n"
+ " b 2f \n"
+ "1: str %0, [%1] \n"
+ " dsb \n"
+ " isb \n"
+ " b 3f \n"
+ "2: b 1b \n"
+ "3: nop \n"
+ : : "r"(val), "r"(&sdr_ctrl->static_cfg) : "memory", "cc");
+}
+
void do_bridge_reset(int enable, unsigned int mask)
{
int i;
@@ -227,6 +256,7 @@ void do_bridge_reset(int enable, unsigned int mask)
}

writel(iswgrp_handoff[2], &sysmgr_regs->fpgaintfgrp_module);
+ socfpga_sdram_apply_static_cfg();
writel(iswgrp_handoff[3], &sdr_ctrl->fpgaport_rst); writel(iswgrp_handoff[0], &reset_manager_base->brg_mod_reset); writel(iswgrp_handoff[1], &nic301_regs->remap);
@@ -236,6 +266,7 @@ void do_bridge_reset(int enable, unsigned int mask)
} else {
writel(0, &sysmgr_regs->fpgaintfgrp_module); writel(0, &sdr_ctrl->fpgaport_rst);
+ socfpga_sdram_apply_static_cfg();
writel(0x7, &reset_manager_base->brg_mod_reset); writel(1, &nic301_regs->remap);
}

Signature · 1 line
2.20.1
#3 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 29 lines · Nico Becker

Am 06.02.2020 um 12:53 schrieb Marek Vasut:

Quoted 28 lines · Nico Becker
Quoted 1 line

Hello,

Hi,

Quoted 22 lines

after removing the function socfpga_sdram_apply_static_cfg() in misc_gen5 we can not use the FPGA2SDRAM bridge.

Without the apply static cfg the kernel crash every time, if we try to write @ the fpga2sdram bridge. After an soft reset everything is working.

If we add the socfpga_sdram_apply_static_cfg() in the u-boot source code, everything is fine.
Now we can use the fpga2sdram bridge after power on.

Our setup:
- u-boot v2020.01
   - load and write fpga firmware
   - enable bridges
- boot linux

I have found some information at
<https://support.criticallink.com/redmine/projects/mityarm-5cs/wiki/Important_Note_about_FPGAHPS_SDRAM_Bridge>

<http://u-boot.10912.n7.nabble.com/WG-Linux-hang-td314276.html>

Quoted 8 lines
Quoted 5 lines

Can you send a patch which fixes this for you, with Fixes: tag ? Then it would be clear what you changed.

Thanks

Hello,
the code was removed @ commit c5f4b805.

Did you read the commit message of that commit and what problem that was solving ? Clearly, reverting the commit isn't the way to go. We need to find a way to unbreak this for you, while not break other platforms.

Quoted 1 line

I attached my patch, sorry for the format, i am new in this.

[...]

#4 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Am 06.02.2020 um 14:00 schrieb Marek Vasut:

Quoted 39 lines · Nico Becker
Quoted 29 lines

Am 06.02.2020 um 12:53 schrieb Marek Vasut:

Quoted 28 lines · Nico Becker
Quoted 1 line

Hello,

Hi,

Quoted 22 lines

after removing the function socfpga_sdram_apply_static_cfg() in misc_gen5 we can not use the FPGA2SDRAM bridge.

Without the apply static cfg the kernel crash every time, if we try to write @ the fpga2sdram bridge. After an soft reset everything is working.

If we add the socfpga_sdram_apply_static_cfg() in the u-boot source code, everything is fine.
Now we can use the fpga2sdram bridge after power on.

Our setup:
- u-boot v2020.01
   - load and write fpga firmware
   - enable bridges
- boot linux

I have found some information at
<https://support.criticallink.com/redmine/projects/mityarm-5cs/wiki/Important_Note_about_FPGAHPS_SDRAM_Bridge>

<http://u-boot.10912.n7.nabble.com/WG-Linux-hang-td314276.html>

Quoted 8 lines
Quoted 5 lines

Can you send a patch which fixes this for you, with Fixes: tag ? Then it would be clear what you changed.

Thanks

Hello,
the code was removed @ commit c5f4b805.

Quoted 8 lines

Did you read the commit message of that commit and what problem that was solving ? Clearly, reverting the commit isn't the way to go. We need to find a way to unbreak this for you, while not break other platforms.

Quoted 1 line

I attached my patch, sorry for the format, i am new in this.

[...]

Hi,
yes i read the commit message.

but i found no other option to enable the sdram bridges, without crashes/hanging up linux, with the removed source code.

i ve found some more information @intel
<https://www.intel.com/content/www/us/en/programmable/support/support-resources/knowledge-base/embedded/2016/how-and-when-can-i-enable-the-fpga2sdram-bridge-on-cyclone-v-soc.html>

Intel talk about an bridge_enable_handoff in my opionion the cmd set the sram aply cfg

/* add signle command to enable all bridges based on handoff */ setenv("bridge_enable_handoff",

	"mw $fpgaintf ${fpgaintf_handoff}; "
	"go $fpga2sdram_apply; "
	"mw $fpga2sdram ${fpga2sdram_handoff}; "
	"mw $axibridge ${axibridge_handoff}; "
	"mw $l3remap ${l3remap_handoff} ");

setenv_addr("fpga2sdram_apply", (void *)sdram_applycfg_uboot);

/*
* Relocate the sdram_applycfg_ocram function to OCRAM and call it */
ENTRY(sdram_applycfg_uboot)

	PUSH	{r4-r11, lr}		/* save registers per AAPCS */

	ldr	r1, =sdram_applycfg_ocram
	ldr	r2, =CONFIG_SYS_INIT_RAM_ADDR
	mov	r3, r2
	ldmia	r1!, {r4 - r11}
	stmia	r3!, {r4 - r11}
	ldmia	r1!, {r4 - r11}		/* copy more in case code added */
	stmia	r3!, {r4 - r11}		/* in the future */
	ldmia	r1!, {r4 - r11}		/* copy more in case code added */
	stmia	r3!, {r4 - r11}		/* in the future */
	dsb
	isb
	blx	r2			/* jump to OCRAM */
	POP	{r4-r11, pc}

ENDPROC(sdram_applycfg_uboot)

it could be an option to write the fpga firmware with u-boot, and do a soft reset.
boot u-boot
check fpga configuration state
not configured write firmware reset
if configured boot linux

i ll check howto to determine the fpga configuration state and try this.

Thanks

Signature · 12 lines
Nico Becker
ic-automation GmbH
Alexander-Diehl-Straße 2a
D-55130 Mainz

Tel:    +49-(0)6131-62718-24
Fax:    +49-(0)6131-62718-10
email:  n.becker at ic-automation.de
Web:    http://www.ic-automation.de

Geschäftsführer: Dr. Stefan Becker
HRB 7283, Amtsgericht Mainz
#5 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 100 lines · Nico Becker

Am 06.02.2020 um 14:00 schrieb Marek Vasut:

Quoted 39 lines · Nico Becker
Quoted 29 lines

Am 06.02.2020 um 12:53 schrieb Marek Vasut:

Quoted 28 lines · Nico Becker
Quoted 1 line

Hello,

Hi,

Quoted 22 lines

after removing the function socfpga_sdram_apply_static_cfg() in misc_gen5 we can not use the FPGA2SDRAM bridge.

Without the apply static cfg the kernel crash every time, if we try to write @ the fpga2sdram bridge. After an soft reset everything is working.

If we add the socfpga_sdram_apply_static_cfg() in the u-boot source code, everything is fine.
Now we can use the fpga2sdram bridge after power on.

Our setup:
- u-boot v2020.01
- load and write fpga firmware
- enable bridges
- boot linux

I have found some information at
<https://support.criticallink.com/redmine/projects/mityarm-5cs/wiki/Important_Note_about_FPGAHPS_SDRAM_Bridge>

<http://u-boot.10912.n7.nabble.com/WG-Linux-hang-td314276.html>

Quoted 8 lines
Quoted 5 lines

Can you send a patch which fixes this for you, with Fixes: tag ? Then it would be clear what you changed.

Thanks

Hello,
the code was removed @ commit c5f4b805.

Quoted 8 lines

Did you read the commit message of that commit and what problem that was solving ? Clearly, reverting the commit isn't the way to go. We need to find a way to unbreak this for you, while not break other platforms.

Quoted 1 line

I attached my patch, sorry for the format, i am new in this.

[...]

Hi,
yes i read the commit message.

but i found no other option to enable the sdram bridges, without crashes/hanging up linux, with the removed source code.

i ve found some more information @intel
<https://www.intel.com/content/www/us/en/programmable/support/support-resources/knowledge-base/embedded/2016/how-and-when-can-i-enable-the-fpga2sdram-bridge-on-cyclone-v-soc.html>

Intel talk about an bridge_enable_handoff in my opionion the cmd set the sram aply cfg

/* add signle command to enable all bridges based on handoff */ setenv("bridge_enable_handoff",

        "mw $fpgaintf ${fpgaintf_handoff}; "
        "go $fpga2sdram_apply; "
        "mw $fpga2sdram ${fpga2sdram_handoff}; "
        "mw $axibridge ${axibridge_handoff}; "
        "mw $l3remap ${l3remap_handoff} ");

setenv_addr("fpga2sdram_apply", (void *)sdram_applycfg_uboot);

/*
* Relocate the sdram_applycfg_ocram function to OCRAM and call it */
ENTRY(sdram_applycfg_uboot)
PUSH {r4-r11, lr} /* save registers per AAPCS */

ldr r1, =sdram_applycfg_ocram
ldr r2, =CONFIG_SYS_INIT_RAM_ADDR
mov r3, r2
ldmia r1!, {r4 - r11}
stmia r3!, {r4 - r11}
ldmia r1!, {r4 - r11} /* copy more in case code added */
stmia r3!, {r4 - r11} /* in the future */
ldmia r1!, {r4 - r11} /* copy more in case code added */
stmia r3!, {r4 - r11} /* in the future */
dsb
isb
blx r2 /* jump to OCRAM */
POP {r4-r11, pc}
ENDPROC(sdram_applycfg_uboot)

it could be an option to write the fpga firmware with u-boot, and do a soft reset.
boot u-boot
check fpga configuration state
not configured write firmware reset
if configured boot linux

Quoted 2 lines

i ll check howto to determine the fpga configuration state and try this.

That doesn't look like a safe plan: what if you explicitly *want* a reboot and want to reconfigure the FPGA then to ensure it is in a well-known state?

Marek, what were the problems why this has been removed? Aside from "is confirmed to lead to a rare system hang when enabling bridges", the commit message stays rather vague. Maybe that "apply config" bit should only be written if explicitly configured so, but that would mean we need some kind of config options included/coming with the FPGA image we program.

Oh, and by now I'm glad our own design connects to DDR via the main bus ;-)

Regards,
Simon

#6 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 104 lines · Simon Goldschmidt
Quoted 100 lines · Nico Becker

Am 06.02.2020 um 14:00 schrieb Marek Vasut:

Quoted 39 lines · Nico Becker
Quoted 29 lines

Am 06.02.2020 um 12:53 schrieb Marek Vasut:

Quoted 28 lines · Nico Becker
Quoted 1 line

Hello,

Hi,

Quoted 22 lines

after removing the function socfpga_sdram_apply_static_cfg() in misc_gen5 we can not use the FPGA2SDRAM bridge.

Without the apply static cfg the kernel crash every time, if we try to write @ the fpga2sdram bridge. After an soft reset everything is working.

If we add the socfpga_sdram_apply_static_cfg() in the u-boot source code, everything is fine.
Now we can use the fpga2sdram bridge after power on.

Our setup:
- u-boot v2020.01
- load and write fpga firmware
- enable bridges
- boot linux

I have found some information at
<https://support.criticallink.com/redmine/projects/mityarm-5cs/wiki/Important_Note_about_FPGAHPS_SDRAM_Bridge>

<http://u-boot.10912.n7.nabble.com/WG-Linux-hang-td314276.html>

Quoted 8 lines
Quoted 5 lines

Can you send a patch which fixes this for you, with Fixes: tag ? Then it would be clear what you changed.

Thanks

Hello,
the code was removed @ commit c5f4b805.

Quoted 8 lines

Did you read the commit message of that commit and what problem that was solving ? Clearly, reverting the commit isn't the way to go. We need to find a way to unbreak this for you, while not break other platforms.

Quoted 1 line

I attached my patch, sorry for the format, i am new in this.

[...]

Hi,
yes i read the commit message.

but i found no other option to enable the sdram bridges, without crashes/hanging up linux, with the removed source code.

i ve found some more information @intel
<https://www.intel.com/content/www/us/en/programmable/support/support-resources/knowledge-base/embedded/2016/how-and-when-can-i-enable-the-fpga2sdram-bridge-on-cyclone-v-soc.html>

Intel talk about an bridge_enable_handoff in my opionion the cmd set the sram aply cfg

/* add signle command to enable all bridges based on handoff */ setenv("bridge_enable_handoff",

        "mw $fpgaintf ${fpgaintf_handoff}; "
        "go $fpga2sdram_apply; "
        "mw $fpga2sdram ${fpga2sdram_handoff}; "
        "mw $axibridge ${axibridge_handoff}; "
        "mw $l3remap ${l3remap_handoff} ");

setenv_addr("fpga2sdram_apply", (void *)sdram_applycfg_uboot);

/*
* Relocate the sdram_applycfg_ocram function to OCRAM and call it */
ENTRY(sdram_applycfg_uboot)
PUSH {r4-r11, lr} /* save registers per AAPCS */

ldr r1, =sdram_applycfg_ocram
ldr r2, =CONFIG_SYS_INIT_RAM_ADDR
mov r3, r2
ldmia r1!, {r4 - r11}
stmia r3!, {r4 - r11}
ldmia r1!, {r4 - r11} /* copy more in case code added */
stmia r3!, {r4 - r11} /* in the future */
ldmia r1!, {r4 - r11} /* copy more in case code added */
stmia r3!, {r4 - r11} /* in the future */
dsb
isb
blx r2 /* jump to OCRAM */
POP {r4-r11, pc}
ENDPROC(sdram_applycfg_uboot)

it could be an option to write the fpga firmware with u-boot, and do a soft reset.
boot u-boot
check fpga configuration state
not configured write firmware reset
if configured boot linux

Quoted 2 lines

i ll check howto to determine the fpga configuration state and try this.

Quoted 6 lines

That doesn't look like a safe plan: what if you explicitly *want* a reboot and want to reconfigure the FPGA then to ensure it is in a well-known state?

Marek, what were the problems why this has been removed? Aside from "is confirmed to lead to a rare system hang when enabling bridges", the commit message stays rather vague.

That's exactly what the problem was. I didn't manage to get further details from Altera on this.

Quoted 3 lines

Maybe that "apply config" bit should only be written
if explicitly configured so, but that would mean we need some kind of config options included/coming with the FPGA image we program.

Maybe the apply config should only be used if the F2S bridge is being used ?

Quoted 1 line

Oh, and by now I'm glad our own design connects to DDR via the main bus ;-)

Right.

Signature · 2 lines
Best regards,
Marek Vasut
#7 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 109 lines · Marek Vasut
Quoted 107 lines · Simon Goldschmidt
Quoted 100 lines · Nico Becker

Am 06.02.2020 um 14:00 schrieb Marek Vasut:

Quoted 39 lines · Nico Becker
Quoted 29 lines

Am 06.02.2020 um 12:53 schrieb Marek Vasut:

Quoted 28 lines · Nico Becker
Quoted 1 line

Hello,

Hi,

Quoted 22 lines

after removing the function socfpga_sdram_apply_static_cfg() in misc_gen5 we can not use the FPGA2SDRAM bridge.

Without the apply static cfg the kernel crash every time, if we try to write @ the fpga2sdram bridge. After an soft reset everything is working.

If we add the socfpga_sdram_apply_static_cfg() in the u-boot source code, everything is fine.
Now we can use the fpga2sdram bridge after power on.

Our setup:
- u-boot v2020.01
- load and write fpga firmware
- enable bridges
- boot linux

I have found some information at
<https://support.criticallink.com/redmine/projects/mityarm-5cs/wiki/Important_Note_about_FPGAHPS_SDRAM_Bridge>

<http://u-boot.10912.n7.nabble.com/WG-Linux-hang-td314276.html>

Quoted 8 lines
Quoted 5 lines

Can you send a patch which fixes this for you, with Fixes: tag ? Then it would be clear what you changed.

Thanks

Hello,
the code was removed @ commit c5f4b805.

Quoted 8 lines

Did you read the commit message of that commit and what problem that was solving ? Clearly, reverting the commit isn't the way to go. We need to find a way to unbreak this for you, while not break other platforms.

Quoted 1 line

I attached my patch, sorry for the format, i am new in this.

[...]

Hi,
yes i read the commit message.

but i found no other option to enable the sdram bridges, without crashes/hanging up linux, with the removed source code.

i ve found some more information @intel
<https://www.intel.com/content/www/us/en/programmable/support/support-resources/knowledge-base/embedded/2016/how-and-when-can-i-enable-the-fpga2sdram-bridge-on-cyclone-v-soc.html>

Intel talk about an bridge_enable_handoff in my opionion the cmd set the sram aply cfg

/* add signle command to enable all bridges based on handoff */ setenv("bridge_enable_handoff",

        "mw $fpgaintf ${fpgaintf_handoff}; "
        "go $fpga2sdram_apply; "
        "mw $fpga2sdram ${fpga2sdram_handoff}; "
        "mw $axibridge ${axibridge_handoff}; "
        "mw $l3remap ${l3remap_handoff} ");

setenv_addr("fpga2sdram_apply", (void *)sdram_applycfg_uboot);

/*
* Relocate the sdram_applycfg_ocram function to OCRAM and call it */
ENTRY(sdram_applycfg_uboot)
PUSH {r4-r11, lr} /* save registers per AAPCS */

ldr r1, =sdram_applycfg_ocram
ldr r2, =CONFIG_SYS_INIT_RAM_ADDR
mov r3, r2
ldmia r1!, {r4 - r11}
stmia r3!, {r4 - r11}
ldmia r1!, {r4 - r11} /* copy more in case code added */
stmia r3!, {r4 - r11} /* in the future */
ldmia r1!, {r4 - r11} /* copy more in case code added */
stmia r3!, {r4 - r11} /* in the future */
dsb
isb
blx r2 /* jump to OCRAM */
POP {r4-r11, pc}
ENDPROC(sdram_applycfg_uboot)

it could be an option to write the fpga firmware with u-boot, and do a soft reset.
boot u-boot
check fpga configuration state
not configured write firmware reset
if configured boot linux

Quoted 2 lines

i ll check howto to determine the fpga configuration state and try this.

That doesn't look like a safe plan: what if you explicitly *want* a reboot and want to reconfigure the FPGA then to ensure it is in a well-known state?

Quoted 6 lines
Quoted 3 lines

Marek, what were the problems why this has been removed? Aside from "is confirmed to lead to a rare system hang when enabling bridges", the commit message stays rather vague.

That's exactly what the problem was. I didn't manage to get further details from Altera on this.

Hrmpf :-(

Quoted 6 lines
Quoted 4 lines

Maybe that "apply config" bit should only be written
if explicitly configured so, but that would mean we need some kind of config options included/coming with the FPGA image we program.

Maybe the apply config should only be used if the F2S bridge is being used ?

Yes, well how do you know after programming an FPGA that this bridge is in use? This depends on the FPGA image, while currently the Altera work flow compiles it into the U-Boot binary.While I'm still working on moving this into the U-Boot dts (I still have size issues there), it's still not encoded with the FPGA.

What we would need is some kind of meta info with the FPGA image that tells us how to configure the bridges (and maybe some clocks or hardware handed off into the FPGA) after programming the FPGA.

Only then, we could write the apply config bit after programming the FPGA.

As to the "SDRAM access must be idle", I think that should work from U-Boot. All peripherals should be idle, unless the FPGA accesses SDRAM right after being configured. Maybe we'd need to wait a bit in case the cache is filling a line or so...

Regards,
Simon

Quoted 8 lines
Quoted 2 lines

Oh, and by now I'm glad our own design connects to DDR via the main bus ;-)

Right.

--
Best regards,
Marek Vasut

#8 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 120 lines · Simon Goldschmidt
Quoted 109 lines · Marek Vasut
Quoted 107 lines · Simon Goldschmidt
Quoted 100 lines · Nico Becker

Am 06.02.2020 um 14:00 schrieb Marek Vasut:

Quoted 39 lines · Nico Becker
Quoted 29 lines

Am 06.02.2020 um 12:53 schrieb Marek Vasut:

Quoted 28 lines · Nico Becker
Quoted 1 line

Hello,

Hi,

Quoted 22 lines

after removing the function socfpga_sdram_apply_static_cfg() in misc_gen5 we can not use the FPGA2SDRAM bridge.

Without the apply static cfg the kernel crash every time, if we try to write @ the fpga2sdram bridge. After an soft reset everything is working.

If we add the socfpga_sdram_apply_static_cfg() in the u-boot source code, everything is fine.
Now we can use the fpga2sdram bridge after power on.

Our setup:
- u-boot v2020.01
- load and write fpga firmware
- enable bridges
- boot linux

I have found some information at
<https://support.criticallink.com/redmine/projects/mityarm-5cs/wiki/Important_Note_about_FPGAHPS_SDRAM_Bridge>

<http://u-boot.10912.n7.nabble.com/WG-Linux-hang-td314276.html>

Quoted 8 lines
Quoted 5 lines

Can you send a patch which fixes this for you, with Fixes: tag ? Then it would be clear what you changed.

Thanks

Hello,
the code was removed @ commit c5f4b805.

Quoted 8 lines

Did you read the commit message of that commit and what problem that was solving ? Clearly, reverting the commit isn't the way to go. We need to find a way to unbreak this for you, while not break other platforms.

Quoted 1 line

I attached my patch, sorry for the format, i am new in this.

[...]

Hi,
yes i read the commit message.

but i found no other option to enable the sdram bridges, without crashes/hanging up linux, with the removed source code.

i ve found some more information @intel
<https://www.intel.com/content/www/us/en/programmable/support/support-resources/knowledge-base/embedded/2016/how-and-when-can-i-enable-the-fpga2sdram-bridge-on-cyclone-v-soc.html>

Intel talk about an bridge_enable_handoff in my opionion the cmd set the sram aply cfg

/* add signle command to enable all bridges based on handoff */ setenv("bridge_enable_handoff",

        "mw $fpgaintf ${fpgaintf_handoff}; "
        "go $fpga2sdram_apply; "
        "mw $fpga2sdram ${fpga2sdram_handoff}; "
        "mw $axibridge ${axibridge_handoff}; "
        "mw $l3remap ${l3remap_handoff} ");

setenv_addr("fpga2sdram_apply", (void *)sdram_applycfg_uboot);

/*
* Relocate the sdram_applycfg_ocram function to OCRAM and call it */
ENTRY(sdram_applycfg_uboot)
PUSH {r4-r11, lr} /* save registers per AAPCS */

ldr r1, =sdram_applycfg_ocram
ldr r2, =CONFIG_SYS_INIT_RAM_ADDR
mov r3, r2
ldmia r1!, {r4 - r11}
stmia r3!, {r4 - r11}
ldmia r1!, {r4 - r11} /* copy more in case code added */
stmia r3!, {r4 - r11} /* in the future */
ldmia r1!, {r4 - r11} /* copy more in case code added */
stmia r3!, {r4 - r11} /* in the future */
dsb
isb
blx r2 /* jump to OCRAM */
POP {r4-r11, pc}
ENDPROC(sdram_applycfg_uboot)

it could be an option to write the fpga firmware with u-boot, and do a soft reset.
boot u-boot
check fpga configuration state
not configured write firmware reset
if configured boot linux

Quoted 2 lines

i ll check howto to determine the fpga configuration state and try this.

That doesn't look like a safe plan: what if you explicitly *want* a reboot and want to reconfigure the FPGA then to ensure it is in a well-known state?

Quoted 6 lines
Quoted 3 lines

Marek, what were the problems why this has been removed? Aside from "is confirmed to lead to a rare system hang when enabling bridges", the commit message stays rather vague.

That's exactly what the problem was. I didn't manage to get further details from Altera on this.

Hrmpf :-(

Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Maybe that "apply config" bit should only be written
if explicitly configured so, but that would mean we need some kind of config options included/coming with the FPGA image we program.

Maybe the apply config should only be used if the F2S bridge is being used ?

Yes, well how do you know after programming an FPGA that this bridge is in use?

From the handoff files ?

Quoted 3 lines

This depends on the FPGA image, while currently the Altera work flow compiles it into the U-Boot binary.While I'm still working on moving this into the U-Boot dts (I still have size issues there), it's still not encoded with the FPGA.

Well you can dig this information out of the handoff files , so you can also make this somehow configurable via either DT or bridge command args.

Quoted 3 lines

What we would need is some kind of meta info with the FPGA image that tells us how to configure the bridges (and maybe some clocks or hardware handed off into the FPGA) after programming the FPGA.

fitImage ? :)

Quoted 6 lines

Only then, we could write the apply config bit after programming the FPGA.

As to the "SDRAM access must be idle", I think that should work from U-Boot. All peripherals should be idle, unless the FPGA accesses SDRAM right after being configured. Maybe we'd need to wait a bit in case the cache is filling a line or so...

... or something is queued up in some buffer somewhere in the bridge.

#9 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 126 lines · Marek Vasut
Quoted 124 lines · Simon Goldschmidt
Quoted 109 lines · Marek Vasut
Quoted 107 lines · Simon Goldschmidt
Quoted 100 lines · Nico Becker

Am 06.02.2020 um 14:00 schrieb Marek Vasut:

Quoted 39 lines · Nico Becker
Quoted 29 lines

Am 06.02.2020 um 12:53 schrieb Marek Vasut:

Quoted 28 lines · Nico Becker
Quoted 1 line

Hello,

Hi,

Quoted 22 lines

after removing the function socfpga_sdram_apply_static_cfg() in misc_gen5 we can not use the FPGA2SDRAM bridge.

Without the apply static cfg the kernel crash every time, if we try to write @ the fpga2sdram bridge. After an soft reset everything is working.

If we add the socfpga_sdram_apply_static_cfg() in the u-boot source code, everything is fine.
Now we can use the fpga2sdram bridge after power on.

Our setup:
- u-boot v2020.01
- load and write fpga firmware
- enable bridges
- boot linux

I have found some information at
<https://support.criticallink.com/redmine/projects/mityarm-5cs/wiki/Important_Note_about_FPGAHPS_SDRAM_Bridge>

<http://u-boot.10912.n7.nabble.com/WG-Linux-hang-td314276.html>

Quoted 8 lines
Quoted 5 lines

Can you send a patch which fixes this for you, with Fixes: tag ? Then it would be clear what you changed.

Thanks

Hello,
the code was removed @ commit c5f4b805.

Quoted 8 lines

Did you read the commit message of that commit and what problem that was solving ? Clearly, reverting the commit isn't the way to go. We need to find a way to unbreak this for you, while not break other platforms.

Quoted 1 line

I attached my patch, sorry for the format, i am new in this.

[...]

Hi,
yes i read the commit message.

but i found no other option to enable the sdram bridges, without crashes/hanging up linux, with the removed source code.

i ve found some more information @intel
<https://www.intel.com/content/www/us/en/programmable/support/support-resources/knowledge-base/embedded/2016/how-and-when-can-i-enable-the-fpga2sdram-bridge-on-cyclone-v-soc.html>

Intel talk about an bridge_enable_handoff in my opionion the cmd set the sram aply cfg

/* add signle command to enable all bridges based on handoff */ setenv("bridge_enable_handoff",

        "mw $fpgaintf ${fpgaintf_handoff}; "
        "go $fpga2sdram_apply; "
        "mw $fpga2sdram ${fpga2sdram_handoff}; "
        "mw $axibridge ${axibridge_handoff}; "
        "mw $l3remap ${l3remap_handoff} ");

setenv_addr("fpga2sdram_apply", (void *)sdram_applycfg_uboot);

/*
* Relocate the sdram_applycfg_ocram function to OCRAM and call it */
ENTRY(sdram_applycfg_uboot)
PUSH {r4-r11, lr} /* save registers per AAPCS */

ldr r1, =sdram_applycfg_ocram
ldr r2, =CONFIG_SYS_INIT_RAM_ADDR
mov r3, r2
ldmia r1!, {r4 - r11}
stmia r3!, {r4 - r11}
ldmia r1!, {r4 - r11} /* copy more in case code added */
stmia r3!, {r4 - r11} /* in the future */
ldmia r1!, {r4 - r11} /* copy more in case code added */
stmia r3!, {r4 - r11} /* in the future */
dsb
isb
blx r2 /* jump to OCRAM */
POP {r4-r11, pc}
ENDPROC(sdram_applycfg_uboot)

it could be an option to write the fpga firmware with u-boot, and do a soft reset.
boot u-boot
check fpga configuration state
not configured write firmware reset
if configured boot linux

Quoted 2 lines

i ll check howto to determine the fpga configuration state and try this.

That doesn't look like a safe plan: what if you explicitly *want* a reboot and want to reconfigure the FPGA then to ensure it is in a well-known state?

Quoted 6 lines
Quoted 3 lines

Marek, what were the problems why this has been removed? Aside from "is confirmed to lead to a rare system hang when enabling bridges", the commit message stays rather vague.

That's exactly what the problem was. I didn't manage to get further details from Altera on this.

Hrmpf :-(

Quoted 5 lines
Quoted 4 lines

Maybe that "apply config" bit should only be written
if explicitly configured so, but that would mean we need some kind of config options included/coming with the FPGA image we program.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Maybe the apply config should only be used if the F2S bridge is being used ?

Yes, well how do you know after programming an FPGA that this bridge is in use?

From the handoff files ?

Yeah, well, I know that. I meant this is not available in U-Boot, see below.

Quoted 7 lines
Quoted 4 lines

This depends on the FPGA image, while currently the Altera work flow compiles it into the U-Boot binary.While I'm still working on moving this into the U-Boot dts (I still have size issues there), it's still not encoded with the FPGA.

Well you can dig this information out of the handoff files , so you can also make this somehow configurable via either DT or bridge command args.

My point was this can differ between FPGA images. Once you load an FPGA image that doesn't match what you expected when building (or flashing) U-Boot, the system may lock up again.

DT is not an option, as you hard-code it when flashing U-Boot. The loaded FPGA image can still change.Bridge command args is a way of how to get this info into the code that runs, but from where do these command args come? You need to somehow parse this info from an FPGA image file read from storage.

Quoted 6 lines
Quoted 4 lines

What we would need is some kind of meta info with the FPGA image that tells us how to configure the bridges (and maybe some clocks or hardware handed off into the FPGA) after programming the FPGA.

fitImage ? :)

I thought of that, too. Maybe a short dts (maybe overlay) beside the FPGA. But then it would again not work when loading a pure rbf. But then again, that might be ok...

So I could imagine this to "just work" when someday I finally have finished my series of moving this handoff info into dts and then including an overlay dts into a fit image that gets applied after programming the FPGA (and by/after applying it, the code that applies bridge settings would run). Would that work?

Regards,
Simon

Quoted 9 lines
Quoted 7 lines

Only then, we could write the apply config bit after programming the FPGA.

As to the "SDRAM access must be idle", I think that should work from U-Boot. All peripherals should be idle, unless the FPGA accesses SDRAM right after being configured. Maybe we'd need to wait a bit in case the cache is filling a line or so...

... or something is queued up in some buffer somewhere in the bridge.

#10 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

On 2/7/20 2:44 PM, Simon Goldschmidt wrote:

[...]

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

This depends on the FPGA image, while currently the Altera work flow compiles it into the U-Boot binary.While I'm still working on moving this into the U-Boot dts (I still have size issues there), it's still not encoded with the FPGA.

Well you can dig this information out of the handoff files , so you can also make this somehow configurable via either DT or bridge command args.

Quoted 5 lines

My point was this can differ between FPGA images. Once you load an FPGA image that doesn't match what you expected when building (or flashing) U-Boot, the system may lock up again.

DT is not an option, as you hard-code it when flashing U-Boot.

You can apply a DTO on the U-Boot DT :-)

Quoted 4 lines

The loaded FPGA
image can still change.Bridge command args is a way of how to get this info into the code that runs, but from where do these command args come? You need to somehow parse this info from an FPGA image file read from storage.

Maybe this could be part of a fitImage or DTO bundled with the FPGA image ?

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

What we would need is some kind of meta info with the FPGA image that tells us how to configure the bridges (and maybe some clocks or hardware handed off into the FPGA) after programming the FPGA.

fitImage ? :)

I thought of that, too. Maybe a short dts (maybe overlay) beside the FPGA. But then it would again not work when loading a pure rbf. But then again, that might be ok...

That's probably OK. If you're loading pure RBF, then you know what you're doing.

Quoted 4 lines

So I could imagine this to "just work" when someday I finally have finished my series of moving this handoff info into dts and then including an overlay dts into a fit image that gets applied after programming the FPGA (and by/after applying it, the code that applies bridge settings would run). Would that work?

I think so.

#11 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

I am reading through this thread, and want to point out that it is not that the FPGA bridge need be actively used in the fpga, but
rather that this port be configured in the FPGA configuration. This is an important distinction, ecery FPGA design that
instantiates the HPS does configure the F2S Bridge. it drives select pins, control pins, data pins, etc, on the interface to known values,
and so the apply can always be done as all SoC FPGA designs have the soc instantiated. If someone boots the arm, and uses an
FPGA design without having the soc instantiated, it may then cause issues, but i would argue that is not a supported use
in the first place.

--dalon

Quoted 45 lines · Marek Vasut

On 2/7/20 2:44 PM, Simon Goldschmidt wrote:

[...]

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

This depends on the FPGA image, while currently the Altera work flow compiles it into the U-Boot binary.While I'm still working on moving this into the U-Boot dts (I still have size issues there), it's still not encoded with the FPGA.

Well you can dig this information out of the handoff files , so you can also make this somehow configurable via either DT or bridge command args.

Quoted 5 lines

My point was this can differ between FPGA images. Once you load an FPGA image that doesn't match what you expected when building (or flashing) U-Boot, the system may lock up again.

DT is not an option, as you hard-code it when flashing U-Boot.

You can apply a DTO on the U-Boot DT :-)

Quoted 4 lines

The loaded FPGA
image can still change.Bridge command args is a way of how to get this info into the code that runs, but from where do these command args come? You need to somehow parse this info from an FPGA image file read from storage.

Maybe this could be part of a fitImage or DTO bundled with the FPGA image ?

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

What we would need is some kind of meta info with the FPGA image that tells us how to configure the bridges (and maybe some clocks or hardware handed off into the FPGA) after programming the FPGA.

fitImage ? :)

I thought of that, too. Maybe a short dts (maybe overlay) beside the FPGA. But then it would again not work when loading a pure rbf. But then again, that might be ok...

That's probably OK. If you're loading pure RBF, then you know what you're doing.

Quoted 4 lines

So I could imagine this to "just work" when someday I finally have finished my series of moving this handoff info into dts and then including an overlay dts into a fit image that gets applied after programming the FPGA (and by/after applying it, the code that applies bridge settings would run). Would that work?

I think so.

#12 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 13 lines · Dalon L Westergreen

I am reading through this thread, and want to point out that it is not that the FPGA bridge need be actively used in the fpga, but
rather that this port be configured in the FPGA configuration. This is an important distinction, ecery FPGA design that
instantiates the HPS does configure the F2S Bridge. it drives select pins, control pins, data pins, etc, on the interface to known values,
and so the apply can always be done as all SoC FPGA designs have the soc instantiated. If someone boots the arm, and uses an
FPGA design without having the soc instantiated, it may then cause issues, but i would argue that is not a supported use
in the first place.

Quoted 2 lines

--dalon

I can reproduce the issue if without setting applycfg bit. Access to F2sdram interface will cause system hang.

From the Cyclone 5 Soc datasheet:
applycfg - Write with this bit set to apply all the settings loaded in SDR registers to the memory interface. This bit is write-only and always returns 0 if read.

Software should set applycfg bit if change any register under SDR register range. SW is allowed to set this bit multiple times, the only condition is SDRAM need to be idle.
My suggestion is we add back socfpga_sdram_apply_static_cfg(), but change the sequence to below:
writel(iswgrp_handoff[3], &sdr_ctrl->fpgaport_rst); socfpga_sdram_apply_static_cfg();

Marek and Simon, are you okay with this? If yes, I will submit patch for this.

Thanks.

Regards
Ley Foon

#13 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 34 lines · Ley Foon Tan
Quoted 13 lines · Dalon L Westergreen

I am reading through this thread, and want to point out that it is not that the FPGA bridge need be actively used in the fpga, but
rather that this port be configured in the FPGA configuration. This is an important distinction, ecery FPGA design that
instantiates the HPS does configure the F2S Bridge. it drives select pins, control pins, data pins, etc, on the interface to known values,
and so the apply can always be done as all SoC FPGA designs have the soc instantiated. If someone boots the arm, and uses an
FPGA design without having the soc instantiated, it may then cause issues, but i would argue that is not a supported use
in the first place.

Quoted 2 lines

--dalon

I can reproduce the issue if without setting applycfg bit. Access to F2sdram interface will cause system hang.

From the Cyclone 5 Soc datasheet:
applycfg - Write with this bit set to apply all the settings loaded in SDR registers to the memory interface. This bit is write-only and always returns 0 if read.

Software should set applycfg bit if change any register under SDR register range. SW is allowed to set this bit multiple times, the only condition is SDRAM need to be idle.
My suggestion is we add back socfpga_sdram_apply_static_cfg(), but change the sequence to below:
writel(iswgrp_handoff[3], &sdr_ctrl->fpgaport_rst); socfpga_sdram_apply_static_cfg();

Quoted 1 line

Marek and Simon, are you okay with this? If yes, I will submit patch for this.

The problem was that this was causing weird sporadic hangs on Gen5, which is why it was removed. So until there is an explanation for those hangs, I'm not really OK with this.

Maybe the application of static config should happen in SPL, before the DRAM is running, or something like that ?

#14 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 36 lines · Marek Vasut
Quoted 34 lines · Ley Foon Tan
Quoted 13 lines · Dalon L Westergreen

I am reading through this thread, and want to point out that it is not that the FPGA bridge need be actively used in the fpga, but
rather that this port be configured in the FPGA configuration. This is an important distinction, ecery FPGA design that
instantiates the HPS does configure the F2S Bridge. it drives select pins, control pins, data pins, etc, on the interface to known values,
and so the apply can always be done as all SoC FPGA designs have the soc instantiated. If someone boots the arm, and uses an
FPGA design without having the soc instantiated, it may then cause issues, but i would argue that is not a supported use
in the first place.

Quoted 2 lines

--dalon

I can reproduce the issue if without setting applycfg bit. Access to F2sdram interface will cause system hang.

From the Cyclone 5 Soc datasheet:
applycfg - Write with this bit set to apply all the settings loaded in SDR registers to the memory interface. This bit is write-only and always returns 0 if read.

Software should set applycfg bit if change any register under SDR register range. SW is allowed to set this bit multiple times, the only condition is SDRAM need to be idle.
My suggestion is we add back socfpga_sdram_apply_static_cfg(), but change the sequence to below:
writel(iswgrp_handoff[3], &sdr_ctrl->fpgaport_rst); socfpga_sdram_apply_static_cfg();

Quoted 5 lines
Quoted 1 line

Marek and Simon, are you okay with this? If yes, I will submit patch for this.

The problem was that this was causing weird sporadic hangs on Gen5, which is why it was removed. So until there is an explanation for those hangs, I'm not really OK with this.

These sporadic hangs you saw were on devices without an FPGA image directly accessing the SDRAM ports, right?

Quoted 3 lines

Maybe the application of static config should happen in SPL, before the DRAM is running, or something like that ?

Thinking this further, limiting it to applying in SPL is not a good idea since that prevents us from implementing different FPGA images/configs by loading a config later in the boot (i.e. in U-Boot from a FIT-image).

Would it work to make setting this optional, i.e. only write the bit if an FPGA config actually uses these ports? Then it couldn't lead to problems on other hardware...

Regards,
Simon

#15 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 37 lines · Simon Goldschmidt
Quoted 36 lines · Marek Vasut
Quoted 34 lines · Ley Foon Tan
Quoted 13 lines · Dalon L Westergreen

I am reading through this thread, and want to point out that it is not that the FPGA bridge need be actively used in the fpga, but
rather that this port be configured in the FPGA configuration. This is an important distinction, ecery FPGA design that
instantiates the HPS does configure the F2S Bridge. it drives select pins, control pins, data pins, etc, on the interface to known values,
and so the apply can always be done as all SoC FPGA designs have the soc instantiated. If someone boots the arm, and uses an
FPGA design without having the soc instantiated, it may then cause issues, but i would argue that is not a supported use
in the first place.

Quoted 2 lines

--dalon

I can reproduce the issue if without setting applycfg bit. Access to F2sdram interface will cause system hang.

From the Cyclone 5 Soc datasheet:
applycfg - Write with this bit set to apply all the settings loaded in SDR registers to the memory interface. This bit is write-only and always returns 0 if read.

Software should set applycfg bit if change any register under SDR register range. SW is allowed to set this bit multiple times, the only condition is SDRAM need to be idle.
My suggestion is we add back socfpga_sdram_apply_static_cfg(), but change the sequence to below:
writel(iswgrp_handoff[3], &sdr_ctrl->fpgaport_rst); socfpga_sdram_apply_static_cfg();

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Marek and Simon, are you okay with this? If yes, I will submit patch for this.

The problem was that this was causing weird sporadic hangs on Gen5, which is why it was removed. So until there is an explanation for those hangs, I'm not really OK with this.

These sporadic hangs you saw were on devices without an FPGA image directly accessing the SDRAM ports, right?

Yes

Quoted 6 lines
Quoted 2 lines

Maybe the application of static config should happen in SPL, before the DRAM is running, or something like that ?

Thinking this further, limiting it to applying in SPL is not a good idea since that prevents us from implementing different FPGA images/configs by loading a config later in the boot (i.e. in U-Boot from a FIT-image).

Well, but later we have SDRAM running and we cannot make it go idle, can we?

Quoted 3 lines

Would it work to make setting this optional, i.e. only write the bit if an FPGA config actually uses these ports? Then it couldn't lead to problems on other hardware...

Can you make SDRAM bus really idle ?

#16 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 57 lines · Marek Vasut
Quoted 37 lines · Simon Goldschmidt
Quoted 36 lines · Marek Vasut
Quoted 34 lines · Ley Foon Tan
Quoted 13 lines · Dalon L Westergreen

I am reading through this thread, and want to point out that it is not that the FPGA bridge need be actively used in the fpga, but
rather that this port be configured in the FPGA configuration. This is an important distinction, ecery FPGA design that
instantiates the HPS does configure the F2S Bridge. it drives select pins, control pins, data pins, etc, on the interface to known values,
and so the apply can always be done as all SoC FPGA designs have the soc instantiated. If someone boots the arm, and uses an
FPGA design without having the soc instantiated, it may then cause issues, but i would argue that is not a supported use
in the first place.

Quoted 2 lines

--dalon

I can reproduce the issue if without setting applycfg bit. Access to F2sdram interface will cause system hang.

From the Cyclone 5 Soc datasheet:
applycfg - Write with this bit set to apply all the settings loaded in SDR registers to the memory interface. This bit is write-only and always returns 0 if read.

Software should set applycfg bit if change any register under SDR register range. SW is allowed to set this bit multiple times, the only condition is SDRAM need to be idle.
My suggestion is we add back socfpga_sdram_apply_static_cfg(), but change the sequence to below:
writel(iswgrp_handoff[3], &sdr_ctrl->fpgaport_rst); socfpga_sdram_apply_static_cfg();

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Marek and Simon, are you okay with this? If yes, I will submit patch for this.

The problem was that this was causing weird sporadic hangs on Gen5, which is why it was removed. So until there is an explanation for those hangs, I'm not really OK with this.

These sporadic hangs you saw were on devices without an FPGA image directly accessing the SDRAM ports, right?

Yes

Quoted 6 lines
Quoted 2 lines

Maybe the application of static config should happen in SPL, before the DRAM is running, or something like that ?

Thinking this further, limiting it to applying in SPL is not a good idea since that prevents us from implementing different FPGA images/configs by loading a config later in the boot (i.e. in U-Boot from a FIT-image).

Quoted 7 lines

Well, but later we have SDRAM running and we cannot make it go idle, can we?

Quoted 3 lines

Would it work to make setting this optional, i.e. only write the bit if an FPGA config actually uses these ports? Then it couldn't lead to problems on other hardware...

Can you make SDRAM bus really idle ?

From the CPU side, that should work, no? Of course you have to make sure no other peripheraly (including FPGA!) are using the RAM.

And if this would be an explicit command, people needing this could experiment with it - and hopefully give better hints as to what's going wrong if we *do* see problems again.

Regards,
Simon

#17 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 64 lines · Simon Goldschmidt
Quoted 63 lines · Marek Vasut
Quoted 37 lines · Simon Goldschmidt
Quoted 36 lines · Marek Vasut
Quoted 34 lines · Ley Foon Tan
Quoted 13 lines · Dalon L Westergreen

I am reading through this thread, and want to point out that it is not that the FPGA bridge need be actively used in the fpga, but
rather that this port be configured in the FPGA configuration. This is an important distinction, ecery FPGA design that
instantiates the HPS does configure the F2S Bridge. it drives select pins, control pins, data pins, etc, on the interface to known values,
and so the apply can always be done as all SoC FPGA designs have the soc instantiated. If someone boots the arm, and uses an
FPGA design without having the soc instantiated, it may then cause issues, but i would argue that is not a supported use
in the first place.

Quoted 2 lines

--dalon

I can reproduce the issue if without setting applycfg bit. Access to F2sdram interface will cause system hang.

From the Cyclone 5 Soc datasheet:
applycfg - Write with this bit set to apply all the settings loaded in SDR registers to the memory interface. This bit is write-only and always returns 0 if read.

Software should set applycfg bit if change any register under SDR register range. SW is allowed to set this bit multiple times, the only condition is SDRAM need to be idle.
My suggestion is we add back socfpga_sdram_apply_static_cfg(), but change the sequence to below:
writel(iswgrp_handoff[3], &sdr_ctrl->fpgaport_rst); socfpga_sdram_apply_static_cfg();

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Marek and Simon, are you okay with this? If yes, I will submit patch for this.

The problem was that this was causing weird sporadic hangs on Gen5, which is why it was removed. So until there is an explanation for those hangs, I'm not really OK with this.

These sporadic hangs you saw were on devices without an FPGA image directly accessing the SDRAM ports, right?

Yes

Quoted 6 lines
Quoted 2 lines

Maybe the application of static config should happen in SPL, before the DRAM is running, or something like that ?

Thinking this further, limiting it to applying in SPL is not a good idea since that prevents us from implementing different FPGA images/configs by loading a config later in the boot (i.e. in U-Boot from a FIT-image).

Well, but later we have SDRAM running and we cannot make it go idle, can we?

Quoted 3 lines

Would it work to make setting this optional, i.e. only write the bit if an FPGA config actually uses these ports? Then it couldn't lead to problems on other hardware...

Quoted 8 lines
Quoted 1 line

Can you make SDRAM bus really idle ?

From the CPU side, that should work, no? Of course you have to make sure no other peripheraly (including FPGA!) are using the RAM.

And if this would be an explicit command, people needing this could experiment with it - and hopefully give better hints as to what's going wrong if we *do* see problems again.

Maybe altera has something hidden somewhere in the bus tunables ? :)

#18 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 69 lines · Marek Vasut
Quoted 68 lines · Simon Goldschmidt
Quoted 67 lines · Marek Vasut
Quoted 45 lines · Simon Goldschmidt
Quoted 44 lines · Marek Vasut
Quoted 42 lines · Ley Foon Tan
Quoted 17 lines · Dalon L Westergreen

I am reading through this thread, and want to point out that it is not that the
FPGA bridge need be actively used in the fpga, but rather that this port be configured in the FPGA configuration. This is an
important distinction, ecery FPGA design that instantiates the HPS does configure the F2S Bridge. it drives select pins,
control pins, data pins, etc, on the interface to known values, and so the apply can always be done as all SoC FPGA designs have the soc
instantiated. If someone boots the arm, and uses an FPGA design without having the soc instantiated, it may then cause issues, but i
would argue that is not a supported use
in the first place.

Quoted 2 lines

--dalon

I can reproduce the issue if without setting applycfg bit. Access to F2sdram interface will cause system hang.

From the Cyclone 5 Soc datasheet:
applycfg - Write with this bit set to apply all the settings loaded in
SDR registers to the memory interface. This bit is write-only and always returns 0 if read.

Software should set applycfg bit if change any register under SDR register range. SW is allowed to set this bit multiple times, the only
condition is SDRAM need to be idle.
My suggestion is we add back socfpga_sdram_apply_static_cfg(), but change the sequence to below:
writel(iswgrp_handoff[3], &sdr_ctrl->fpgaport_rst); socfpga_sdram_apply_static_cfg();

Marek and Simon, are you okay with this? If yes, I will submit patch for this.

Quoted 8 lines
Quoted 4 lines

The problem was that this was causing weird sporadic hangs on Gen5, which is why it was removed. So until there is an explanation for those
hangs, I'm not really OK with this.

These sporadic hangs you saw were on devices without an FPGA image directly
accessing the SDRAM ports, right?

Yes

Quoted 9 lines
Quoted 3 lines

Maybe the application of static config should happen in SPL, before the
DRAM is running, or something like that ?

Thinking this further, limiting it to applying in SPL is not a good idea since
that prevents us from implementing different FPGA images/configs by loading a
config later in the boot (i.e. in U-Boot from a FIT-image).

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Well, but later we have SDRAM running and we cannot make it go idle, can we?

Unfortunately the sdram cfg apply must occur AFTER the fpga is configured. This is because the FPGA drives configuration bits, around the interfaces datawidth for example, that are used in setting up the dram interface. I believe the intent is for the command to only run when the ridge enable function is called.

Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines

Would it work to make setting this optional, i.e. only write the bit if an FPGA
config actually uses these ports? Then it couldn't lead to problems on other
hardware...

Can you make SDRAM bus really idle ?

From the CPU side, that should work, no? Of course you have to make sure no other peripheraly (including FPGA!) are using the RAM.

Quoted 6 lines
Quoted 4 lines

And if this would be an explicit command, people needing this could experiment with it - and hopefully give better hints as to what's going wrong
if we *do* see problems again.

Maybe altera has something hidden somewhere in the bus tunables ? :)

The only trick i am aware of, and Ley Foon, please comment, is isolating relevant code to the caches before executing.

--dalon

#19 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

On 3/12/20 4:54 PM, Dalon L Westergreen wrote:
[...]

(thanks for fixing your mailer :))

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 9 lines
Quoted 5 lines

The problem was that this was causing weird sporadic hangs on Gen5, which is why it was removed. So until there is an explanation for those
hangs, I'm not really OK with this.

These sporadic hangs you saw were on devices without an FPGA image directly
accessing the SDRAM ports, right?

Yes

Quoted 9 lines
Quoted 3 lines

Maybe the application of static config should happen in SPL, before the
DRAM is running, or something like that ?

Thinking this further, limiting it to applying in SPL is not a good idea since
that prevents us from implementing different FPGA images/configs by loading a
config later in the boot (i.e. in U-Boot from a FIT-image).

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Well, but later we have SDRAM running and we cannot make it go idle, can we?

Unfortunately the sdram cfg apply must occur AFTER the fpga is configured. This is because the FPGA drives configuration bits, around the interfaces datawidth for example, that are used in setting up the dram interface. I believe the intent is for the command to only run when the ridge enable function is called.

So that's one part of the fix -- only run this apply_static_cfg if the bitstream uses the F2S bridge.

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 7 lines
Quoted 5 lines

Would it work to make setting this optional, i.e. only write the bit if an FPGA
config actually uses these ports? Then it couldn't lead to problems on other
hardware...

Can you make SDRAM bus really idle ?

From the CPU side, that should work, no? Of course you have to make sure no other peripheraly (including FPGA!) are using the RAM.

And if this would be an explicit command, people needing this could experiment with it - and hopefully give better hints as to what's going wrong
if we *do* see problems again.

Quoted 4 lines
Quoted 1 line

Maybe altera has something hidden somewhere in the bus tunables ? :)

The only trick i am aware of, and Ley Foon, please comment, is isolating relevant code to the caches before executing.

How do you make sure some DMA doesn't do something funny or some pending write doesn't trigger DRAM write ? There is more than the CPU that can access the DRAM and cause bus traffic.

#20 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 42 lines · Marek Vasut

On 3/12/20 4:54 PM, Dalon L Westergreen wrote:
[...]

(thanks for fixing your mailer :))

Quoted 29 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 9 lines
Quoted 5 lines

The problem was that this was causing weird sporadic hangs on Gen5,
which is why it was removed. So until there is an explanation for those
hangs, I'm not really OK with this.

These sporadic hangs you saw were on devices without an FPGA image directly
accessing the SDRAM ports, right?

Yes

Quoted 11 lines
Quoted 4 lines

Maybe the application of static config should happen in SPL, before
the
DRAM is running, or something like that ?

Thinking this further, limiting it to applying in SPL is not a good idea
since
that prevents us from implementing different FPGA images/configs by loading a
config later in the boot (i.e. in U-Boot from a FIT-image).

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Well, but later we have SDRAM running and we cannot make it go idle, can
we?

Quoted 7 lines

Unfortunately the sdram cfg apply must occur AFTER the fpga is configured. This
is because the FPGA drives configuration bits, around the interfaces datawidth
for example, that are used in setting up the dram interface. I believe the intent is for the command to only run when the ridge enable function is called.

Quoted 2 lines

So that's one part of the fix -- only run this apply_static_cfg if the bitstream uses the F2S bridge.

actually, the restriction is to apply this only if the FPGA is configured, whether the bridge is used is irrelevant. you can further restrict this to only when the bridge is used, but to me that means devicetree entries or something to determine whether it is used.

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 10 lines
Quoted 8 lines

Would it work to make setting this optional, i.e. only write the bit if
an FPGA
config actually uses these ports? Then it couldn't lead to problems on
other
hardware...

Can you make SDRAM bus really idle ?

From the CPU side, that should work, no? Of course you have to make sure no
other peripheraly (including FPGA!) are using the RAM.

And if this would be an explicit command, people needing this could experiment with it - and hopefully give better hints as to what's going wrong
if we *do* see problems again.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Maybe altera has something hidden somewhere in the bus tunables ? :)

The only trick i am aware of, and Ley Foon, please comment, is isolating relevant code to the caches before executing.

How do you make sure some DMA doesn't do something funny or some pending write doesn't trigger DRAM write ? There is more than the CPU that can access the DRAM and cause bus traffic.

True, and it is unclear how we could ensure there is absolutely no traffic.

--dalon

#21 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Am 16.03.2020 um 19:04 schrieb Dalon L Westergreen:

Quoted 45 lines · Marek Vasut
Quoted 42 lines · Dalon L Westergreen

[...]

(thanks for fixing your mailer :))

Quoted 36 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 9 lines
Quoted 5 lines

The problem was that this was causing weird sporadic hangs on Gen5,
which is why it was removed. So until there is an explanation for those
hangs, I'm not really OK with this.

These sporadic hangs you saw were on devices without an FPGA image directly
accessing the SDRAM ports, right?

Yes

Quoted 11 lines
Quoted 4 lines

Maybe the application of static config should happen in SPL, before
the
DRAM is running, or something like that ?

Thinking this further, limiting it to applying in SPL is not a good idea
since
that prevents us from implementing different FPGA images/configs by loading a
config later in the boot (i.e. in U-Boot from a FIT-image).

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Well, but later we have SDRAM running and we cannot make it go idle, can
we?

Unfortunately the sdram cfg apply must occur AFTER the fpga is configured. This
is because the FPGA drives configuration bits, around the interfaces datawidth
for example, that are used in setting up the dram interface. I believe the intent is for the command to only run when the ridge enable function is called.

Quoted 7 lines
Quoted 2 lines

So that's one part of the fix -- only run this apply_static_cfg if the bitstream uses the F2S bridge.

actually, the restriction is to apply this only if the FPGA is configured, whether the bridge is used is irrelevant. you can further restrict this to only when the bridge is used, but to me that means devicetree entries or something to determine whether it is used.

In my opinion, we need an FPGA-specific devicetree (or something similar) to describe the FPGA image, anyway. Today, too much configuration is applied at compile time (or when programming SPL to flash at latest) - there's currently no way to switch peripherals to FPGA for one image but not for another, for example.

Worse: if you enable bridges but there's no slave attached, the CPU can be stuck. That would need to be described with the FPGA image as well.

Regards,
Simon

Quoted 35 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 11 lines
Quoted 9 lines

Would it work to make setting this optional, i.e. only write the bit if
an FPGA
config actually uses these ports? Then it couldn't lead to problems on
other
hardware...

Can you make SDRAM bus really idle ?

From the CPU side, that should work, no? Of course you have to make sure no
other peripheraly (including FPGA!) are using the RAM.

And if this would be an explicit command, people needing this could experiment with it - and hopefully give better hints as to what's going wrong
if we *do* see problems again.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Maybe altera has something hidden somewhere in the bus tunables ? :)

The only trick i am aware of, and Ley Foon, please comment, is isolating relevant code to the caches before executing.

How do you make sure some DMA doesn't do something funny or some pending write doesn't trigger DRAM write ? There is more than the CPU that can access the DRAM and cause bus traffic.

True, and it is unclear how we could ensure there is absolutely no traffic.

--dalon

#22 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 49 lines · Simon Goldschmidt

Am 16.03.2020 um 19:04 schrieb Dalon L Westergreen:

Quoted 48 lines · Marek Vasut
Quoted 44 lines · Dalon L Westergreen

[...]

(thanks for fixing your mailer :))

Quoted 29 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 9 lines
Quoted 5 lines

The problem was that this was causing weird sporadic hangs on Gen5,
which is why it was removed. So until there is an explanation for those
hangs, I'm not really OK with this.

These sporadic hangs you saw were on devices without an FPGA image directly
accessing the SDRAM ports, right?

Yes

Quoted 11 lines
Quoted 4 lines

Maybe the application of static config should happen in SPL, before
the
DRAM is running, or something like that ?

Thinking this further, limiting it to applying in SPL is not a good idea
since
that prevents us from implementing different FPGA images/configs by loading a
config later in the boot (i.e. in U-Boot from a FIT-image).

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Well, but later we have SDRAM running and we cannot make it go idle, can
we?

Quoted 7 lines

Unfortunately the sdram cfg apply must occur AFTER the fpga is configured. This
is because the FPGA drives configuration bits, around the interfaces datawidth
for example, that are used in setting up the dram interface. I believe the intent is for the command to only run when the ridge enable function is called.

So that's one part of the fix -- only run this apply_static_cfg if the bitstream uses the F2S bridge.

Quoted 7 lines
Quoted 4 lines

actually, the restriction is to apply this only if the FPGA is configured, whether the bridge is used is irrelevant. you can further restrict this to only when the bridge is used, but to me that means devicetree entries or something to determine whether it is used.

In my opinion, we need an FPGA-specific devicetree (or something similar) to describe the FPGA image, anyway.

Like a DTO ?

Quoted 4 lines

Today, too much
configuration is applied at compile time (or when programming SPL to flash at latest) - there's currently no way to switch peripherals to FPGA for one image but not for another, for example.

Yes

Quoted 2 lines

Worse: if you enable bridges but there's no slave attached, the CPU can be stuck. That would need to be described with the FPGA image as well.

Can you propose a patch ?

Signature · 2 lines
Best regards,
Marek Vasut
#23 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Am 16.03.2020 um 20:06 schrieb Marek Vasut:

Quoted 65 lines · Simon Goldschmidt
Quoted 49 lines

Am 16.03.2020 um 19:04 schrieb Dalon L Westergreen:

Quoted 48 lines · Marek Vasut
Quoted 44 lines · Dalon L Westergreen

[...]

(thanks for fixing your mailer :))

Quoted 29 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 9 lines
Quoted 5 lines

The problem was that this was causing weird sporadic hangs on Gen5,
which is why it was removed. So until there is an explanation for those
hangs, I'm not really OK with this.

These sporadic hangs you saw were on devices without an FPGA image directly
accessing the SDRAM ports, right?

Yes

Quoted 11 lines
Quoted 4 lines

Maybe the application of static config should happen in SPL, before
the
DRAM is running, or something like that ?

Thinking this further, limiting it to applying in SPL is not a good idea
since
that prevents us from implementing different FPGA images/configs by loading a
config later in the boot (i.e. in U-Boot from a FIT-image).

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Well, but later we have SDRAM running and we cannot make it go idle, can
we?

Quoted 7 lines

Unfortunately the sdram cfg apply must occur AFTER the fpga is configured. This
is because the FPGA drives configuration bits, around the interfaces datawidth
for example, that are used in setting up the dram interface. I believe the intent is for the command to only run when the ridge enable function is called.

So that's one part of the fix -- only run this apply_static_cfg if the bitstream uses the F2S bridge.

Quoted 7 lines
Quoted 4 lines

actually, the restriction is to apply this only if the FPGA is configured, whether the bridge is used is irrelevant. you can further restrict this to only when the bridge is used, but to me that means devicetree entries or something to determine whether it is used.

In my opinion, we need an FPGA-specific devicetree (or something similar) to describe the FPGA image, anyway.

Like a DTO ?

Quoted 4 lines

Today, too much
configuration is applied at compile time (or when programming SPL to flash at latest) - there's currently no way to switch peripherals to FPGA for one image but not for another, for example.

Quoted 6 lines

Yes

Quoted 2 lines

Worse: if you enable bridges but there's no slave attached, the CPU can be stuck. That would need to be described with the FPGA image as well.

Can you propose a patch ?

In corona times and with kids now at home, I don't know if I can soon :-(

Regards,
Simon

#24 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

On 3/16/20 8:09 PM, Simon Goldschmidt wrote:
[...]

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Today, too much
configuration is applied at compile time (or when programming SPL to flash at latest) - there's currently no way to switch peripherals to FPGA for one image but not for another, for example.

Quoted 8 lines
Quoted 6 lines

Yes

Quoted 2 lines

Worse: if you enable bridges but there's no slave attached, the CPU can be stuck. That would need to be described with the FPGA image as well.

Can you propose a patch ?

In corona times and with kids now at home, I don't know if I can soon :-(

The release is far away anyway :)

We're already on full lockdown, hopefully it goes away soon.

Signature · 2 lines
Best regards,
Marek Vasut
#25 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

In reply to Marek Vasut
Quoted 62 lines · Marek Vasut
Quoted 61 lines · Simon Goldschmidt

Am 16.03.2020 um 19:04 schrieb Dalon L Westergreen:

Quoted 59 lines · Marek Vasut
Quoted 50 lines · Dalon L Westergreen

[...]

(thanks for fixing your mailer :))

Quoted 35 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 8 lines
Quoted 7 lines

The problem was that this was causing weird sporadic hangs on
Gen5,
which is why it was removed. So until there is an explanation for
those
hangs, I'm not really OK with this.

Quoted 4 lines

These sporadic hangs you saw were on devices without an FPGA image
directly
accessing the SDRAM ports, right?

Yes

Quoted 13 lines
Quoted 4 lines

Maybe the application of static config should happen in SPL, before
the
DRAM is running, or something like that ?

Thinking this further, limiting it to applying in SPL is not a good
idea
since
that prevents us from implementing different FPGA images/configs by
loading a
config later in the boot (i.e. in U-Boot from a FIT-image).

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Well, but later we have SDRAM running and we cannot make it go idle,
can
we?

Quoted 9 lines

Unfortunately the sdram cfg apply must occur AFTER the fpga is configured. This
is because the FPGA drives configuration bits, around the interfaces datawidth
for example, that are used in setting up the dram interface. I believe the
intent is for the command to only run when the ridge enable function is
called.

Quoted 2 lines

So that's one part of the fix -- only run this apply_static_cfg if the bitstream uses the F2S bridge.

actually, the restriction is to apply this only if the FPGA is configured, whether the bridge is used is irrelevant. you can further restrict this to only when the bridge is used, but to me that means devicetree entries or something to determine whether it is used.

Quoted 4 lines
Quoted 2 lines

In my opinion, we need an FPGA-specific devicetree (or something similar) to describe the FPGA image, anyway.

Like a DTO ?

DTOs are how i suggest solving this in linux, so i would assume a dto would be best here too.

Quoted 13 lines
Quoted 5 lines

Today, too much
configuration is applied at compile time (or when programming SPL to flash at latest) - there's currently no way to switch peripherals to FPGA for one image but not for another, for example.

Yes

Quoted 2 lines

Worse: if you enable bridges but there's no slave attached, the CPU can be stuck. That would need to be described with the FPGA image as well.

Can you propose a patch ?

#26 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Am 16.03.2020 um 20:55 schrieb Dalon L Westergreen:

Quoted 65 lines · Marek Vasut
Quoted 62 lines · Simon Goldschmidt
Quoted 61 lines

Am 16.03.2020 um 19:04 schrieb Dalon L Westergreen:

Quoted 59 lines · Marek Vasut
Quoted 50 lines · Dalon L Westergreen

[...]

(thanks for fixing your mailer :))

Quoted 35 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 8 lines
Quoted 7 lines

The problem was that this was causing weird sporadic hangs on
Gen5,
which is why it was removed. So until there is an explanation for
those
hangs, I'm not really OK with this.

Quoted 4 lines

These sporadic hangs you saw were on devices without an FPGA image
directly
accessing the SDRAM ports, right?

Yes

Quoted 13 lines
Quoted 4 lines

Maybe the application of static config should happen in SPL, before
the
DRAM is running, or something like that ?

Thinking this further, limiting it to applying in SPL is not a good
idea
since
that prevents us from implementing different FPGA images/configs by
loading a
config later in the boot (i.e. in U-Boot from a FIT-image).

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Well, but later we have SDRAM running and we cannot make it go idle,
can
we?

Quoted 9 lines

Unfortunately the sdram cfg apply must occur AFTER the fpga is configured. This
is because the FPGA drives configuration bits, around the interfaces datawidth
for example, that are used in setting up the dram interface. I believe the
intent is for the command to only run when the ridge enable function is
called.

Quoted 2 lines

So that's one part of the fix -- only run this apply_static_cfg if the bitstream uses the F2S bridge.

actually, the restriction is to apply this only if the FPGA is configured, whether the bridge is used is irrelevant. you can further restrict this to only when the bridge is used, but to me that means devicetree entries or something to determine whether it is used.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

In my opinion, we need an FPGA-specific devicetree (or something similar) to describe the FPGA image, anyway.

Like a DTO ?

DTOs are how i suggest solving this in linux, so i would assume a dto would be best here too.

Yes. That DTO should be beside the FPGA image, either in a FIT image or just loaded separately. It should contain pin settings, bridge settings etc.

However, to ensure the bus is idle, we still would have to limit applying that config bit to before RAM is set up, so quite early in SPL, right? I cannot see how that would work, given the limit of 64K. Plus it's kind of a bad boot flow to configure the FPGA before even starting U-Boot...

Regards,
Simon

Quoted 15 lines
Quoted 14 lines
Quoted 6 lines

Today, too much
configuration is applied at compile time (or when programming SPL to flash at latest) - there's currently no way to switch peripherals to FPGA for one image but not for another, for example.

Yes

Quoted 2 lines

Worse: if you enable bridges but there's no slave attached, the CPU can be stuck. That would need to be described with the FPGA image as well.

Can you propose a patch ?

#27 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 75 lines · Simon Goldschmidt

Am 16.03.2020 um 20:55 schrieb Dalon L Westergreen:

Quoted 65 lines · Marek Vasut
Quoted 62 lines · Simon Goldschmidt
Quoted 61 lines

Am 16.03.2020 um 19:04 schrieb Dalon L Westergreen:

Quoted 59 lines · Marek Vasut
Quoted 50 lines · Dalon L Westergreen

[...]

(thanks for fixing your mailer :))

Quoted 35 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 8 lines
Quoted 7 lines

The problem was that this was causing weird sporadic hangs on
Gen5,
which is why it was removed. So until there is an explanation for
those
hangs, I'm not really OK with this.

Quoted 4 lines

These sporadic hangs you saw were on devices without an FPGA image
directly
accessing the SDRAM ports, right?

Yes

Quoted 13 lines
Quoted 4 lines

Maybe the application of static config should happen in SPL, before
the
DRAM is running, or something like that ?

Thinking this further, limiting it to applying in SPL is not a good
idea
since
that prevents us from implementing different FPGA images/configs by
loading a
config later in the boot (i.e. in U-Boot from a FIT-image).

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Well, but later we have SDRAM running and we cannot make it go idle,
can
we?

Quoted 9 lines

Unfortunately the sdram cfg apply must occur AFTER the fpga is configured. This
is because the FPGA drives configuration bits, around the interfaces datawidth
for example, that are used in setting up the dram interface. I believe the
intent is for the command to only run when the ridge enable function is
called.

Quoted 2 lines

So that's one part of the fix -- only run this apply_static_cfg if the bitstream uses the F2S bridge.

actually, the restriction is to apply this only if the FPGA is configured, whether the bridge is used is irrelevant. you can further restrict this to only when the bridge is used, but to me that means devicetree entries or something to determine whether it is used.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

In my opinion, we need an FPGA-specific devicetree (or something similar) to describe the FPGA image, anyway.

Like a DTO ?

DTOs are how i suggest solving this in linux, so i would assume a dto would be best here too.

Quoted 8 lines

Yes. That DTO should be beside the FPGA image, either in a FIT image or just loaded separately. It should contain pin settings, bridge settings etc.

However, to ensure the bus is idle, we still would have to limit applying that config bit to before RAM is set up, so quite early in SPL, right? I cannot see how that would work, given the limit of 64K. Plus it's kind of a bad boot flow to configure the FPGA before even starting U-Boot...

There is usecase user may want to program fpga image in Uboot command prompt. It will have problem too.

socfpga_sdram_apply_static_cfg() is written in assembly code and the code is fit to one cacheline size (32 bytes). This at least make sure CPU no access to SDRAM when run apply static cfg code in uboot. Frankly, this can't prevent external master access to SDRAM.

Marek,
I found code in drivers/fpga/socfpga_gen5.c:socfpga_load() write to SDR_CTRLGRP_FPGAPORTRST_ADDRESS register, but doesn't write to call to socfpga_sdram_apply_static_cfg() function. This means FPGA port is not put into reset before program fpga image. Suspect this might reason it cause sporadic hangs.

Stay safe everyone.

Regards
Ley Foon

#28 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 48 lines · Ley Foon Tan
Quoted 25 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 11 lines
Quoted 8 lines

configured. This
is because the FPGA drives configuration bits, around the interfaces datawidth
for example, that are used in setting up the dram interface. I believe the
intent is for the command to only run when the ridge enable function is
called.

So that's one part of the fix -- only run this apply_static_cfg if the bitstream uses the F2S bridge.

actually, the restriction is to apply this only if the FPGA is configured, whether the bridge is used is irrelevant. you can further restrict this to only when the bridge is used, but to me that means devicetree entries or something to determine whether it is used.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

In my opinion, we need an FPGA-specific devicetree (or something similar) to describe the FPGA image, anyway.

Like a DTO ?

DTOs are how i suggest solving this in linux, so i would assume a dto would be best here too.

Quoted 8 lines

Yes. That DTO should be beside the FPGA image, either in a FIT image or just loaded separately. It should contain pin settings, bridge settings etc.

However, to ensure the bus is idle, we still would have to limit applying that config bit to before RAM is set up, so quite early in SPL, right? I cannot see how that would work, given the limit of 64K. Plus it's kind of a bad boot flow to configure the FPGA before even starting U-Boot...

There is usecase user may want to program fpga image in Uboot command prompt. It will have problem too.

socfpga_sdram_apply_static_cfg() is written in assembly code and the code is fit to one cacheline size (32 bytes). This at least make sure CPU no access to SDRAM when run apply static cfg code in uboot. Frankly, this can't prevent external master access to SDRAM.

Marek,
I found code in drivers/fpga/socfpga_gen5.c:socfpga_load() write to SDR_CTRLGRP_FPGAPORTRST_ADDRESS register, but doesn't write to call to socfpga_sdram_apply_static_cfg() function. This means FPGA port is not put into reset before program fpga image. Suspect this might reason it cause sporadic hangs.

Quoted 4 lines

Stay safe everyone.

Regards
Ley Foon

Hi

Cyclone5 F2sdram interface is totally broken in uboot now, can we revert back the socfpga_sdram_apply_static_cfg() but add checking if f2sdram bridge is enabled. Also add call to socfpga_sdram_apply_static_cfg() in socfpga_load(). Simon's enhancement for DTO might not getting in soon.

Thanks.

Regards
Ley Foon

#29 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 55 lines · Ley Foon Tan
Quoted 48 lines · Ley Foon Tan
Quoted 25 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 11 lines
Quoted 8 lines

configured. This
is because the FPGA drives configuration bits, around the interfaces datawidth
for example, that are used in setting up the dram interface. I believe the
intent is for the command to only run when the ridge enable function is
called.

So that's one part of the fix -- only run this apply_static_cfg if the bitstream uses the F2S bridge.

actually, the restriction is to apply this only if the FPGA is configured, whether the bridge is used is irrelevant. you can further restrict this to only when the bridge is used, but to me that means devicetree entries or something to determine whether it is used.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

In my opinion, we need an FPGA-specific devicetree (or something similar) to describe the FPGA image, anyway.

Like a DTO ?

DTOs are how i suggest solving this in linux, so i would assume a dto would be best here too.

Quoted 8 lines

Yes. That DTO should be beside the FPGA image, either in a FIT image or just loaded separately. It should contain pin settings, bridge settings etc.

However, to ensure the bus is idle, we still would have to limit applying that config bit to before RAM is set up, so quite early in SPL, right? I cannot see how that would work, given the limit of 64K. Plus it's kind of a bad boot flow to configure the FPGA before even starting U-Boot...

There is usecase user may want to program fpga image in Uboot command prompt. It will have problem too.

socfpga_sdram_apply_static_cfg() is written in assembly code and the code is fit to one cacheline size (32 bytes). This at least make sure CPU no access to SDRAM when run apply static cfg code in uboot. Frankly, this can't prevent external master access to SDRAM.

Marek,
I found code in drivers/fpga/socfpga_gen5.c:socfpga_load() write to SDR_CTRLGRP_FPGAPORTRST_ADDRESS register, but doesn't write to call to socfpga_sdram_apply_static_cfg() function. This means FPGA port is not put into reset before program fpga image. Suspect this might reason it cause sporadic hangs.

Quoted 4 lines

Stay safe everyone.

Regards
Ley Foon

Quoted 7 lines

Hi

Cyclone5 F2sdram interface is totally broken in uboot now, can we revert back the socfpga_sdram_apply_static_cfg() but add checking if f2sdram bridge is enabled. Also add call to socfpga_sdram_apply_static_cfg() in socfpga_load(). Simon's enhancement for DTO might not getting in soon.

Is it better if it's totally and visibly broken, or if every 500 or so reboots the machine randomly and inobviously hangs when enabling bridges ?

Also, there is still the problem where we are not able to guarantee that the DRAM bus will be completely idle before running the apply static cfg, or did that get sorted out somehow ?

I think we shouldn't revert it, but rather make it somehow conditional, maybe by adding argument to the 'bridge' command or an environment variable (probably better), at least for this release.

#30 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

In reply to Simon Goldschmidt
Quoted 35 lines · Simon Goldschmidt
Quoted 20 lines · Marek Vasut
Quoted 20 lines
Quoted 3 lines

I can reproduce the issue if without setting applycfg bit. Access to F2sdram interface will cause system hang.

From the Cyclone 5 Soc datasheet:
applycfg - Write with this bit set to apply all the settings loaded in SDR registers to the memory interface. This bit is write-only and always returns 0 if read.

Software should set applycfg bit if change any register under SDR register range. SW is allowed to set this bit multiple times, the only condition is SDRAM need to be idle.
My suggestion is we add back socfpga_sdram_apply_static_cfg(), but change the sequence to below:
writel(iswgrp_handoff[3], &sdr_ctrl->fpgaport_rst); socfpga_sdram_apply_static_cfg();

Quoted 5 lines
Quoted 1 line

Marek and Simon, are you okay with this? If yes, I will submit patch for this.

The problem was that this was causing weird sporadic hangs on Gen5, which is why it was removed. So until there is an explanation for those hangs, I'm not really OK with this.

These sporadic hangs you saw were on devices without an FPGA image directly accessing the SDRAM ports, right?

Quoted 3 lines

Maybe the application of static config should happen in SPL, before the DRAM is running, or something like that ?

Quoted 7 lines

Thinking this further, limiting it to applying in SPL is not a good idea since that prevents us from implementing different FPGA images/configs by loading a config later in the boot (i.e. in U-Boot from a FIT-image).

Would it work to make setting this optional, i.e. only write the bit if an FPGA config actually uses these ports? Then it couldn't lead to problems on other hardware...

If the sporadic hangs issue happen on FPGA image that doesn't connect to f2sdram interface, we can add the checking to only apply static cfg when it has f2sdram port enabled.
It can send a patch with this checking for you to try if want.

Regards
Ley Foon

#31 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 41 lines · Ley Foon Tan
Quoted 39 lines · Simon Goldschmidt
Quoted 20 lines · Marek Vasut
Quoted 20 lines
Quoted 3 lines

I can reproduce the issue if without setting applycfg bit. Access to F2sdram interface will cause system hang.

From the Cyclone 5 Soc datasheet:
applycfg - Write with this bit set to apply all the settings loaded in SDR registers to the memory interface. This bit is write-only and always returns 0 if read.

Software should set applycfg bit if change any register under SDR register range. SW is allowed to set this bit multiple times, the only condition is SDRAM need to be idle.
My suggestion is we add back socfpga_sdram_apply_static_cfg(), but change the sequence to below:
writel(iswgrp_handoff[3], &sdr_ctrl->fpgaport_rst); socfpga_sdram_apply_static_cfg();

Quoted 5 lines
Quoted 1 line

Marek and Simon, are you okay with this? If yes, I will submit patch for this.

The problem was that this was causing weird sporadic hangs on Gen5, which is why it was removed. So until there is an explanation for those hangs, I'm not really OK with this.

These sporadic hangs you saw were on devices without an FPGA image directly accessing the SDRAM ports, right?

Quoted 3 lines

Maybe the application of static config should happen in SPL, before the DRAM is running, or something like that ?

Thinking this further, limiting it to applying in SPL is not a good idea since that prevents us from implementing different FPGA images/configs by loading a config later in the boot (i.e. in U-Boot from a FIT-image).

Quoted 8 lines
Quoted 3 lines

Would it work to make setting this optional, i.e. only write the bit if an FPGA config actually uses these ports? Then it couldn't lead to problems on other hardware...

If the sporadic hangs issue happen on FPGA image that doesn't connect to f2sdram interface, we can add the checking to only apply static cfg when it has f2sdram port enabled.
It can send a patch with this checking for you to try if want.

Well, what could cause that sporadic hang ?
Yes, the hang happens on image which doesn't access the SDRAM IIRC.

Signature · 2 lines
Best regards,
Marek Vasut
#32 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 47 lines · Marek Vasut
Quoted 45 lines · Ley Foon Tan
Quoted 42 lines · Simon Goldschmidt
Quoted 20 lines · Marek Vasut
Quoted 20 lines
Quoted 3 lines

I can reproduce the issue if without setting applycfg bit. Access to F2sdram interface will cause system hang.

From the Cyclone 5 Soc datasheet:
applycfg - Write with this bit set to apply all the settings loaded in SDR registers to the memory interface. This bit is write-only and always returns 0 if read.

Software should set applycfg bit if change any register under SDR register range. SW is allowed to set this bit multiple times, the only condition is SDRAM need to be idle.
My suggestion is we add back socfpga_sdram_apply_static_cfg(), but change the sequence to below:
writel(iswgrp_handoff[3], &sdr_ctrl->fpgaport_rst); socfpga_sdram_apply_static_cfg();

Quoted 5 lines
Quoted 1 line

Marek and Simon, are you okay with this? If yes, I will submit patch for this.

The problem was that this was causing weird sporadic hangs on Gen5, which is why it was removed. So until there is an explanation for those hangs, I'm not really OK with this.

These sporadic hangs you saw were on devices without an FPGA image directly accessing the SDRAM ports, right?

Quoted 3 lines

Maybe the application of static config should happen in SPL, before the DRAM is running, or something like that ?

Thinking this further, limiting it to applying in SPL is not a good idea since that prevents us from implementing different FPGA images/configs by loading a config later in the boot (i.e. in U-Boot from a FIT-image).

Would it work to make setting this optional, i.e. only write the bit if an FPGA config actually uses these ports? Then it couldn't lead to problems on other hardware...

Quoted 7 lines
Quoted 4 lines

If the sporadic hangs issue happen on FPGA image that doesn't connect to f2sdram interface, we can add the checking to only apply static cfg when it has f2sdram port enabled.
It can send a patch with this checking for you to try if want.

Well, what could cause that sporadic hang ?
Yes, the hang happens on image which doesn't access the SDRAM IIRC.

Do you remember if the hang happen when run bridge enable/disable command? Or other flow?

I have tested the following sequence 500 times with FPGA image that doesn't contains fs2dram bridge, but didn't see the hang.
- program fpga image
- bridge enable
- write to h2f bridge
- read from h2f bridge
- bridge disable
- repeat step 1

Regards
Ley Foon

#33 lore raw

PATCH 1/1 ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()

Quoted 52 lines · Ley Foon Tan
Quoted 51 lines · Marek Vasut
Quoted 49 lines · Ley Foon Tan
Quoted 35 lines · Simon Goldschmidt
Quoted 20 lines · Marek Vasut
Quoted 20 lines
Quoted 3 lines

I can reproduce the issue if without setting applycfg bit. Access to F2sdram interface will cause system hang.

From the Cyclone 5 Soc datasheet:
applycfg - Write with this bit set to apply all the settings loaded in SDR registers to the memory interface. This bit is write-only and always returns 0 if read.

Software should set applycfg bit if change any register under SDR register range. SW is allowed to set this bit multiple times, the only condition is SDRAM need to be idle.
My suggestion is we add back socfpga_sdram_apply_static_cfg(), but change the sequence to below:
writel(iswgrp_handoff[3], &sdr_ctrl->fpgaport_rst); socfpga_sdram_apply_static_cfg();

Quoted 5 lines
Quoted 1 line

Marek and Simon, are you okay with this? If yes, I will submit patch for this.

The problem was that this was causing weird sporadic hangs on Gen5, which is why it was removed. So until there is an explanation for those hangs, I'm not really OK with this.

These sporadic hangs you saw were on devices without an FPGA image directly accessing the SDRAM ports, right?

Quoted 3 lines

Maybe the application of static config should happen in SPL, before the DRAM is running, or something like that ?

Quoted 7 lines

Thinking this further, limiting it to applying in SPL is not a good idea since that prevents us from implementing different FPGA images/configs by loading a config later in the boot (i.e. in U-Boot from a FIT-image).

Would it work to make setting this optional, i.e. only write the bit if an FPGA config actually uses these ports? Then it couldn't lead to problems on other hardware...

If the sporadic hangs issue happen on FPGA image that doesn't connect to f2sdram interface, we can add the checking to only apply static cfg when it has f2sdram port enabled.
It can send a patch with this checking for you to try if want.

Quoted 5 lines
Quoted 3 lines

Well, what could cause that sporadic hang ?
Yes, the hang happens on image which doesn't access the SDRAM IIRC.

Do you remember if the hang happen when run bridge enable/disable command? Or other flow?

FPGA bitstream was loaded via the fpga command , and then during the bridge enable it got stuck.

Quoted 8 lines

I have tested the following sequence 500 times with FPGA image that doesn't contains fs2dram bridge, but didn't see the hang.
- program fpga image
- bridge enable
- write to h2f bridge
- read from h2f bridge
- bridge disable
- repeat step 1

The test we did also contained booting Linux inbetween, and then reboot through U-Boot, which loaded the bitstream , enabled bridges , started Linux, reboot etc.

Signature · 2 lines
Best regards,
Marek Vasut