All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] MC : Report extra reserved memory to Linux
@ 2019-03-11 15:44 Meenakshi Aggarwal
  2019-03-12 11:24 ` [U-Boot] [PATCH v2] " Meenakshi Aggarwal
  0 siblings, 1 reply; 4+ messages in thread
From: Meenakshi Aggarwal @ 2019-03-11 15:44 UTC (permalink / raw)
  To: u-boot

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 <meenakshi.aggarwal@nxp.com>
---
 board/freescale/lx2160a/lx2160a.c | 27 ++++++++++++++++++++++++++-
 drivers/net/fsl-mc/mc.c           | 13 +++++++++++++
 include/fsl-mc/fsl_mc.h           |  1 +
 3 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c
index ad72eed..3cbb7d1 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,25 @@ 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(&base[3], &size[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..79a38d6 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..30f961b 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

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

* [U-Boot] [PATCH v2] MC : Report extra reserved memory to Linux
  2019-03-11 15:44 [U-Boot] [PATCH] MC : Report extra reserved memory to Linux Meenakshi Aggarwal
@ 2019-03-12 11:24 ` Meenakshi Aggarwal
  2019-03-13 17:10   ` [U-Boot] [PATCH v3] " Meenakshi Aggarwal
  0 siblings, 1 reply; 4+ messages in thread
From: Meenakshi Aggarwal @ 2019-03-12 11:24 UTC (permalink / raw)
  To: u-boot

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 <meenakshi.aggarwal@nxp.com>
---
 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(&base[3], &size[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

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

* [U-Boot] [PATCH v3] MC : Report extra reserved memory to Linux
  2019-03-12 11:24 ` [U-Boot] [PATCH v2] " Meenakshi Aggarwal
@ 2019-03-13 17:10   ` Meenakshi Aggarwal
  2019-03-23  0:28     ` Prabhakar Kushwaha
  0 siblings, 1 reply; 4+ messages in thread
From: Meenakshi Aggarwal @ 2019-03-13 17:10 UTC (permalink / raw)
  To: u-boot

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 <meenakshi.aggarwal@nxp.com>
Reviewed-by: Ashish Kumar <Ashish.Kumar@nxp.com>
---
 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(&base[3], &size[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

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

* [U-Boot] [PATCH v3] MC : Report extra reserved memory to Linux
  2019-03-13 17:10   ` [U-Boot] [PATCH v3] " Meenakshi Aggarwal
@ 2019-03-23  0:28     ` Prabhakar Kushwaha
  0 siblings, 0 replies; 4+ messages in thread
From: Prabhakar Kushwaha @ 2019-03-23  0:28 UTC (permalink / raw)
  To: u-boot


> -----Original Message-----
> From: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> Sent: Wednesday, March 13, 2019 10:41 PM
> To: u-boot at lists.denx.de; Prabhakar Kushwaha
> <prabhakar.kushwaha@nxp.com>
> Cc: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> 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 <meenakshi.aggarwal@nxp.com>
> Reviewed-by: Ashish Kumar <Ashish.Kumar@nxp.com>
> ---
>  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(&base[3], &size[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

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

end of thread, other threads:[~2019-03-23  0:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-11 15:44 [U-Boot] [PATCH] MC : Report extra reserved memory to Linux Meenakshi Aggarwal
2019-03-12 11:24 ` [U-Boot] [PATCH v2] " Meenakshi Aggarwal
2019-03-13 17:10   ` [U-Boot] [PATCH v3] " Meenakshi Aggarwal
2019-03-23  0:28     ` Prabhakar Kushwaha

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.