All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()
@ 2019-04-23 16:14 Marek Vasut
  2019-04-26  6:39 ` Simon Goldschmidt
  0 siblings, 1 reply; 39+ messages in thread
From: Marek Vasut @ 2019-04-23 16:14 UTC (permalink / raw)
  To: u-boot

The usage of socfpga_sdram_apply_static_cfg() seems rather dubious and
is confirmed to lead to a rare system hang when enabling bridges. This
patch removes the socfpga_sdram_apply_static_cfg() altogether, because
it's use seems unjustified and problematic.

The socfpga_sdram_apply_static_cfg() triggers write to SDRAM staticcfg
register to set the applycfg bit, which according to old vendor U-Boot
sources can only be written when there is no traffic between the SDRAM
controller and the rest of the system. Empirical measurements confirm
this, setting the applycfg bit when there is traffic between the SDRAM
controller and CPU leads to the SDRAM controller accesses being blocked
shortly after.

Altera originally solved this by moving the entire code which sets the
staticcfg register to OCRAM [1]. The commit message claims that the
applycfg bit needs to be set after write to fpgaportrst register. This
is however inverted by Altera shortly after in [2], where the order
becomes the exact opposite of what commit message [1] claims to be the
required order. The explanation points to a possible problem in AMP
use-case, where the FPGA might be sending transactions through the F2S
bridge.

However, the AMP is only the tip of the iceberg here. Any of the other
L2, L3 or L4 masters can trigger transactions to the SDRAM. It becomes
rather non-trivial to guarantee there are no transactions to the SDRAM
controller.

The SoCFPGA SDRAM driver always writes the applycfg bit in SPL. Thus,
writing the applycfg again in bridge enable code seems redundant and
can presumably be dropped.

[1] https://github.com/altera-opensource/u-boot-socfpga/commit/75905816ec95b0ccd515700b922628d7aa9036f8
[2] https://github.com/altera-opensource/u-boot-socfpga/commit/8ba6986b04a91d23c7adf529186b34c8d2967ad5

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Chin Liang See <chin.liang.see@intel.com>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Cc: Tien Fong Chee <tien.fong.chee@intel.com>
---
 arch/arm/mach-socfpga/misc_gen5.c | 31 -------------------------------
 1 file changed, 31 deletions(-)

diff --git a/arch/arm/mach-socfpga/misc_gen5.c b/arch/arm/mach-socfpga/misc_gen5.c
index 7876953595..eeba199edc 100644
--- a/arch/arm/mach-socfpga/misc_gen5.c
+++ b/arch/arm/mach-socfpga/misc_gen5.c
@@ -220,35 +220,6 @@ 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;
@@ -263,14 +234,12 @@ 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);
 	} else {
 		writel(0, &sysmgr_regs->fpgaintfgrp_module);
 		writel(0, &sdr_ctrl->fpgaport_rst);
-		socfpga_sdram_apply_static_cfg();
 		writel(0, &reset_manager_base->brg_mod_reset);
 		writel(1, &nic301_regs->remap);
 	}
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 39+ messages in thread
* [U-Boot] [PATCH] ARM: socfpga: Remove socfpga_sdram_apply_static_cfg()
@ 2020-02-06 10:50 Nico Becker
  2020-02-06 11:53 ` Marek Vasut
  0 siblings, 1 reply; 39+ messages in thread
From: Nico Becker @ 2020-02-06 10:50 UTC (permalink / raw)
  To: u-boot

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>



-- 
Best regards
Nico Becker

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2020-03-31 11:27 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-23 16:14 [U-Boot] [PATCH] ARM: socfpga: Remove socfpga_sdram_apply_static_cfg() Marek Vasut
2019-04-26  6:39 ` Simon Goldschmidt
2019-04-29  8:34   ` Marek Vasut
2019-04-29 13:02     ` See, Chin Liang
2019-04-29 21:29       ` Marek Vasut
2020-02-06 10:50 Nico Becker
2020-02-06 11:53 ` Marek Vasut
2020-02-06 12:57   ` Nico Becker
2020-02-06 13:00     ` Marek Vasut
2020-02-06 14:13       ` Nico Becker
2020-02-06 14:57         ` Simon Goldschmidt
2020-02-07  7:55           ` Marek Vasut
2020-02-07 12:09             ` Simon Goldschmidt
2020-02-07 12:27               ` Marek Vasut
2020-02-07 13:44                 ` Simon Goldschmidt
2020-02-07 13:49                   ` Marek Vasut
2020-02-12 18:52                     ` Dalon L Westergreen
2020-03-09  8:50                       ` Ley Foon Tan
2020-03-09 12:57                         ` Marek Vasut
2020-03-09 14:10                           ` Simon Goldschmidt
2020-03-09 14:15                             ` Marek Vasut
2020-03-09 14:24                               ` Simon Goldschmidt
2020-03-09 14:25                                 ` Marek Vasut
2020-03-12 15:54                                   ` Dalon L Westergreen
2020-03-12 15:57                                     ` Marek Vasut
2020-03-16 18:04                                       ` Dalon L Westergreen
2020-03-16 19:04                                         ` Simon Goldschmidt
2020-03-16 19:06                                           ` Marek Vasut
2020-03-16 19:09                                             ` Simon Goldschmidt
2020-03-16 19:19                                               ` Marek Vasut
2020-03-16 19:55                                             ` Dalon L Westergreen
2020-03-16 20:01                                               ` Simon Goldschmidt
2020-03-20  7:52                                                 ` Ley Foon Tan
2020-03-31  8:13                                                   ` Ley Foon Tan
2020-03-31 11:27                                                     ` Marek Vasut
2020-03-11  9:54                             ` Ley Foon Tan
2020-03-11  9:58                               ` Marek Vasut
2020-03-12  9:31                                 ` Ley Foon Tan
2020-03-12 11:34                                   ` Marek Vasut

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.