Re: [U-Boot] [PATCH v3] MC : Report extra reserved memory to Linux

2019-03-22 Thread Prabhakar Kushwaha

> -Original Message-
> From: Meenakshi Aggarwal 
> Sent: Wednesday, March 13, 2019 10:41 PM
> To: u-boot@lists.denx.de; Prabhakar Kushwaha
> 
> Cc: Meenakshi Aggarwal 
> Subject: [PATCH v3] MC : Report extra reserved memory to Linux
> 

Update subject as

driver: net: mc: Report extra reserved memory to Linux


> For MC, 512 MB DDR is reserved because of MC's alignment requirement.
> But for MC binaries needing 128MB or 256MB DDR memory, rest of the
> memory is a waste. So reporting this extra memory to Linux through dtb
> memory fixup.
> 
> Signed-off-by: Meenakshi Aggarwal 
> Reviewed-by: Ashish Kumar 
> ---
>  board/freescale/lx2160a/lx2160a.c | 28 +++-
>  drivers/net/fsl-mc/mc.c   | 13 +
>  include/fsl-mc/fsl_mc.h   |  1 +
>  3 files changed, 41 insertions(+), 1 deletion(-)
> 
> diff --git a/board/freescale/lx2160a/lx2160a.c

This change should be done for other DPAA2 platform also. 

> b/board/freescale/lx2160a/lx2160a.c
> index ad72eed..b763f6d 100644
> --- a/board/freescale/lx2160a/lx2160a.c
> +++ b/board/freescale/lx2160a/lx2160a.c
> @@ -532,8 +532,15 @@ void board_quiesce_devices(void)  int
> ft_board_setup(void *blob, bd_t *bd)  {
>   int i;
> + bool mc_memory_bank = false;
> +
> +#ifdef CONFIG_FSL_MC_ENET
> + u64 base[CONFIG_NR_DRAM_BANKS + 1];
> + u64 size[CONFIG_NR_DRAM_BANKS + 1];

Please don't use magic number. Adding "1"is not providing any info


> +#else

>   u64 base[CONFIG_NR_DRAM_BANKS];
>   u64 size[CONFIG_NR_DRAM_BANKS];
> +#endif
> 
>   ft_cpu_setup(blob, bd);
> 
> @@ -556,7 +563,26 @@ int ft_board_setup(void *blob, bd_t *bd)
>   size[2] = gd->arch.resv_ram - base[2];  #endif
> 
> - fdt_fixup_memory_banks(blob, base, size,
> CONFIG_NR_DRAM_BANKS);
> +#ifdef CONFIG_FSL_MC_ENET
> + fdt_fixup_mc_ddr([3], [3]);
> +
> + if (base[3] != 0) {
> + for (i = 0; i <= CONFIG_NR_DRAM_BANKS; i++) {
> + if (base[i] == 0 && size[i] == 0) {
> + base[i] = base[3];
> + size[i] = size[3];
> + break;
> + }
> + }
> + if (i == CONFIG_NR_DRAM_BANKS)
> + mc_memory_bank = true;
> + }
> +#endif
> + if (mc_memory_bank)
> + fdt_fixup_memory_banks(
> +  blob, base, size, CONFIG_NR_DRAM_BANKS + 1);
> + else
> + fdt_fixup_memory_banks(blob, base, size,
> CONFIG_NR_DRAM_BANKS);
> 

Why are you doing fixup? Ideally you should mark it reserved. 

--pk

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3] MC : Report extra reserved memory to Linux

2019-03-13 Thread Meenakshi Aggarwal
For MC, 512 MB DDR is reserved because of MC's alignment
requirement.
But for MC binaries needing 128MB or 256MB DDR memory, rest
of the memory is a waste. So reporting this extra memory to
Linux through dtb memory fixup.

Signed-off-by: Meenakshi Aggarwal 
Reviewed-by: Ashish Kumar 
---
 board/freescale/lx2160a/lx2160a.c | 28 +++-
 drivers/net/fsl-mc/mc.c   | 13 +
 include/fsl-mc/fsl_mc.h   |  1 +
 3 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/board/freescale/lx2160a/lx2160a.c 
b/board/freescale/lx2160a/lx2160a.c
index ad72eed..b763f6d 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -532,8 +532,15 @@ void board_quiesce_devices(void)
 int ft_board_setup(void *blob, bd_t *bd)
 {
int i;
+   bool mc_memory_bank = false;
+
+#ifdef CONFIG_FSL_MC_ENET
+   u64 base[CONFIG_NR_DRAM_BANKS + 1];
+   u64 size[CONFIG_NR_DRAM_BANKS + 1];
+#else
u64 base[CONFIG_NR_DRAM_BANKS];
u64 size[CONFIG_NR_DRAM_BANKS];
+#endif
 
ft_cpu_setup(blob, bd);
 
@@ -556,7 +563,26 @@ int ft_board_setup(void *blob, bd_t *bd)
size[2] = gd->arch.resv_ram - base[2];
 #endif
 
-   fdt_fixup_memory_banks(blob, base, size, CONFIG_NR_DRAM_BANKS);
+#ifdef CONFIG_FSL_MC_ENET
+   fdt_fixup_mc_ddr([3], [3]);
+
+   if (base[3] != 0) {
+   for (i = 0; i <= CONFIG_NR_DRAM_BANKS; i++) {
+   if (base[i] == 0 && size[i] == 0) {
+   base[i] = base[3];
+   size[i] = size[3];
+   break;
+   }
+   }
+   if (i == CONFIG_NR_DRAM_BANKS)
+   mc_memory_bank = true;
+   }
+#endif
+   if (mc_memory_bank)
+   fdt_fixup_memory_banks(
+blob, base, size, CONFIG_NR_DRAM_BANKS + 1);
+   else
+   fdt_fixup_memory_banks(blob, base, size, CONFIG_NR_DRAM_BANKS);
 
 #ifdef CONFIG_USB
fsl_fdt_fixup_dr_usb(blob, bd);
diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index dddc9cc..d7a2e8f 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -285,6 +285,19 @@ static int mc_fixup_dpl_mac_addr(void *blob, int dpmac_id,
 MC_FIXUP_DPL);
 }
 
+void fdt_fixup_mc_ddr(u64 *base, u64 *size)
+{
+   u64 mc_size = mc_get_dram_block_size();
+
+   if (mc_size < MC_DRAM_BLOCK_DEFAULT_SIZE) {
+   *base = mc_get_dram_addr() + mc_size;
+   *size = MC_DRAM_BLOCK_DEFAULT_SIZE - mc_size;
+   } else {
+   *base = 0;
+   *size = 0;
+   }
+}
+
 void fdt_fsl_mc_fixup_iommu_map_entry(void *blob)
 {
u32 *prop;
diff --git a/include/fsl-mc/fsl_mc.h b/include/fsl-mc/fsl_mc.h
index aef40d3..492a714 100644
--- a/include/fsl-mc/fsl_mc.h
+++ b/include/fsl-mc/fsl_mc.h
@@ -54,6 +54,7 @@ struct mc_ccsr_registers {
 void fdt_fsl_mc_fixup_iommu_map_entry(void *blob);
 int get_mc_boot_status(void);
 int get_dpl_apply_status(void);
+void fdt_fixup_mc_ddr(u64 *base, u64 *size);
 #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET
 int get_aiop_apply_status(void);
 #endif
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot