public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: u-boot@lists.denx.de, Peng Fan <peng.fan@nxp.com>,
	sbabic@denx.de, festevam@gmail.com,
	ariel.dalessandro@collabora.com, michael@amarulasolutions.com,
	tharvey@gateworks.com, sjg@chromium.org, marek.behun@nic.cz,
	pali@kernel.org, sr@denx.de, ricardo@foundries.io,
	patrick.delaunay@foss.st.com, trini@konsulko.com
Subject: Re: [PATCH V4 6/8] ddr: imx8m: helper: load ddr firmware according to binman symbols
Date: Sun, 22 May 2022 16:57:41 +0300	[thread overview]
Message-ID: <08a31c30-e119-86e4-7a8b-c8fd8a5dadd7@gmail.com> (raw)
In-Reply-To: <20220520141048.20034-7-peng.fan@oss.nxp.com>

On 20/05/2022 17:10, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> By reading binman symbols, we no need hard coded IMEM_LEN/DMEM_LEN after
> we update the binman dtsi to drop 0x8000/0x4000 length for the firmware.
> 
> And that could save binary size for many KBs.
> 
> Tested-by: Tim Harvey <tharvey@gateworks.com> #imx8m[m,n,p]-venice
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/ddr/imx/imx8m/helper.c | 51 ++++++++++++++++++++++++++++------
>  1 file changed, 43 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/ddr/imx/imx8m/helper.c b/drivers/ddr/imx/imx8m/helper.c
> index f23904bf712..b3bd57531b7 100644
> --- a/drivers/ddr/imx/imx8m/helper.c
> +++ b/drivers/ddr/imx/imx8m/helper.c
> @@ -4,6 +4,7 @@
>   */
>  
>  #include <common.h>
> +#include <binman_sym.h>
>  #include <log.h>
>  #include <spl.h>
>  #include <asm/global_data.h>
> @@ -25,15 +26,30 @@ DECLARE_GLOBAL_DATA_PTR;
>  #define DMEM_OFFSET_ADDR 0x00054000
>  #define DDR_TRAIN_CODE_BASE_ADDR IP2APB_DDRPHY_IPS_BASE_ADDR(0)
>  
> +binman_sym_declare(ulong, blob_ext_1, image_pos);
> +binman_sym_declare(ulong, blob_ext_1, size);
> +
> +binman_sym_declare(ulong, blob_ext_2, image_pos);
> +binman_sym_declare(ulong, blob_ext_2, size);
> +
> +#if !IS_ENABLED(CONFIG_IMX8M_DDR3L)
> +binman_sym_declare(ulong, blob_ext_3, image_pos);
> +binman_sym_declare(ulong, blob_ext_3, size);
> +
> +binman_sym_declare(ulong, blob_ext_4, image_pos);
> +binman_sym_declare(ulong, blob_ext_4, size);
> +#endif
> +

(Descriptive entry names would make these more meaningful.)

>  /* We need PHY iMEM PHY is 32KB padded */
>  void ddr_load_train_firmware(enum fw_type type)
>  {
>  	u32 tmp32, i;
>  	u32 error = 0;
>  	unsigned long pr_to32, pr_from32;
> -	unsigned long fw_offset = type ? IMEM_2D_OFFSET : 0;
> -	unsigned long imem_start = (unsigned long)&_end + fw_offset;
> -	unsigned long dmem_start;
> +	uint32_t fw_offset = type ? IMEM_2D_OFFSET : 0;
> +	uint32_t imem_start = (unsigned long)&_end + fw_offset;
> +	uint32_t dmem_start;
> +	uint32_t imem_len = IMEM_LEN, dmem_len = DMEM_LEN;
>  
>  #ifdef CONFIG_SPL_OF_CONTROL
>  	if (gd->fdt_blob && !fdt_check_header(gd->fdt_blob)) {
> @@ -43,11 +59,30 @@ void ddr_load_train_firmware(enum fw_type type)
>  	}
>  #endif
>  
> -	dmem_start = imem_start + IMEM_LEN;
> +	if (CONFIG_IS_ENABLED(BINMAN_SYMBOLS)) {
> +		switch (type) {
> +		case FW_1D_IMAGE:
> +			imem_start = binman_sym(ulong, blob_ext_1, image_pos);
> +			imem_len = binman_sym(ulong, blob_ext_1, size);
> +			dmem_start = binman_sym(ulong, blob_ext_2, image_pos);
> +			dmem_len = binman_sym(ulong, blob_ext_2, size);
> +			break;
> +		case FW_2D_IMAGE:
> +#if !IS_ENABLED(CONFIG_IMX8M_DDR3L)
> +			imem_start = binman_sym(ulong, blob_ext_3, image_pos);
> +			imem_len = binman_sym(ulong, blob_ext_3, size);
> +			dmem_start = binman_sym(ulong, blob_ext_4, image_pos);
> +			dmem_len = binman_sym(ulong, blob_ext_4, size);
> +#endif
> +			break;
> +		}
> +	}
> +
> +	dmem_start = imem_start + imem_len;

This overwrites the values from binman symbols, which looks wrong to me.
I think this line should appear before the if block.

>  
>  	pr_from32 = imem_start;
>  	pr_to32 = DDR_TRAIN_CODE_BASE_ADDR + 4 * IMEM_OFFSET_ADDR;
> -	for (i = 0x0; i < IMEM_LEN; ) {
> +	for (i = 0x0; i < imem_len; ) {
>  		tmp32 = readl(pr_from32);
>  		writew(tmp32 & 0x0000ffff, pr_to32);
>  		pr_to32 += 4;
> @@ -59,7 +94,7 @@ void ddr_load_train_firmware(enum fw_type type)
>  
>  	pr_from32 = dmem_start;
>  	pr_to32 = DDR_TRAIN_CODE_BASE_ADDR + 4 * DMEM_OFFSET_ADDR;
> -	for (i = 0x0; i < DMEM_LEN; ) {
> +	for (i = 0x0; i < dmem_len; ) {
>  		tmp32 = readl(pr_from32);
>  		writew(tmp32 & 0x0000ffff, pr_to32);
>  		pr_to32 += 4;
> @@ -72,7 +107,7 @@ void ddr_load_train_firmware(enum fw_type type)
>  	debug("check ddr_pmu_train_imem code\n");
>  	pr_from32 = imem_start;
>  	pr_to32 = DDR_TRAIN_CODE_BASE_ADDR + 4 * IMEM_OFFSET_ADDR;
> -	for (i = 0x0; i < IMEM_LEN; ) {
> +	for (i = 0x0; i < imem_len; ) {
>  		tmp32 = (readw(pr_to32) & 0x0000ffff);
>  		pr_to32 += 4;
>  		tmp32 += ((readw(pr_to32) & 0x0000ffff) << 16);
> @@ -93,7 +128,7 @@ void ddr_load_train_firmware(enum fw_type type)
>  	debug("check ddr4_pmu_train_dmem code\n");
>  	pr_from32 = dmem_start;
>  	pr_to32 = DDR_TRAIN_CODE_BASE_ADDR + 4 * DMEM_OFFSET_ADDR;
> -	for (i = 0x0; i < DMEM_LEN;) {
> +	for (i = 0x0; i < dmem_len;) {
>  		tmp32 = (readw(pr_to32) & 0x0000ffff);
>  		pr_to32 += 4;
>  		tmp32 += ((readw(pr_to32) & 0x0000ffff) << 16);

  reply	other threads:[~2022-05-22 13:59 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-20 14:10 [PATCH V4 0/8] arm64: binman: use binman symbols for imx Peng Fan (OSS)
2022-05-20 14:10 ` [PATCH V4 1/8] spl: guard u_boot_any with X86 Peng Fan (OSS)
2022-05-20 15:21   ` Tom Rini
2022-05-21  8:33     ` Peng Fan
2022-05-21 12:05       ` Tom Rini
2022-05-22 13:56         ` Alper Nebi Yasak
2022-05-22 14:50           ` Tom Rini
2022-05-23 21:10             ` Alper Nebi Yasak
2022-05-23  6:19           ` Peng Fan (OSS)
2022-05-23  6:28         ` Peng Fan (OSS)
2022-05-23 14:10           ` Tom Rini
2022-05-23 21:10             ` Alper Nebi Yasak
2022-05-22 13:55   ` Alper Nebi Yasak
2022-05-20 14:10 ` [PATCH V4 2/8] arm: dts: imx8m: update binman ddr firmware node name Peng Fan (OSS)
2022-05-22 13:56   ` Alper Nebi Yasak
2022-05-23  7:01     ` Peng Fan (OSS)
2022-05-23 21:11       ` Alper Nebi Yasak
2022-05-20 14:10 ` [PATCH V4 3/8] imx: imx8mm-icore: migrate to use BINMAN Peng Fan (OSS)
2022-05-22 13:56   ` Alper Nebi Yasak
2022-05-23  7:02     ` Peng Fan (OSS)
2022-05-20 14:10 ` [PATCH V4 4/8] armv8: u-boot-spl.lds: mark __image_copy_start as symbol Peng Fan (OSS)
2022-05-20 15:21   ` Tom Rini
2022-05-20 14:10 ` [PATCH V4 5/8] tools: binman: section: replace @ with - Peng Fan (OSS)
2022-05-22 13:57   ` Alper Nebi Yasak
2022-05-23  7:05     ` Peng Fan (OSS)
2022-05-20 14:10 ` [PATCH V4 6/8] ddr: imx8m: helper: load ddr firmware according to binman symbols Peng Fan (OSS)
2022-05-22 13:57   ` Alper Nebi Yasak [this message]
2022-05-23  7:08     ` Peng Fan (OSS)
2022-05-20 14:10 ` [PATCH V4 7/8] arm: dts: imx8m: shrink ddr firmware size to actual file size Peng Fan (OSS)
2022-05-23 21:12   ` Alper Nebi Yasak
2022-05-24  5:50     ` Michael Nazzareno Trimarchi
2022-05-20 14:10 ` [PATCH V4 8/8] binman_sym: guard with CONFIG_SPL_BINMAN_SYMBOLS Peng Fan (OSS)
2022-05-22 13:57   ` Alper Nebi Yasak
2022-05-23  7:10     ` Peng Fan (OSS)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=08a31c30-e119-86e4-7a8b-c8fd8a5dadd7@gmail.com \
    --to=alpernebiyasak@gmail.com \
    --cc=ariel.dalessandro@collabora.com \
    --cc=festevam@gmail.com \
    --cc=marek.behun@nic.cz \
    --cc=michael@amarulasolutions.com \
    --cc=pali@kernel.org \
    --cc=patrick.delaunay@foss.st.com \
    --cc=peng.fan@nxp.com \
    --cc=peng.fan@oss.nxp.com \
    --cc=ricardo@foundries.io \
    --cc=sbabic@denx.de \
    --cc=sjg@chromium.org \
    --cc=sr@denx.de \
    --cc=tharvey@gateworks.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox