diff mbox

[U-Boot,1/5] ls2080: Exit dpaa only right before exiting U-Boot

Message ID 1463142095-182586-2-git-send-email-agraf@suse.de
State Superseded
Delegated to: York Sun
Headers show

Commit Message

Alexander Graf May 13, 2016, 12:21 p.m. UTC
On ls2080 we have a separate network fabric component which we need to
shut down before we enter Linux (or any other OS). Along with that also
comes configuration of the fabric using a description file.

Today we always stop and configure the fabric in the boot script and
(again) exit it on device tree generation. This works ok for the normal
booti case, but with bootefi the payload we're running may still want to
access the network.

So let's add a new fsl_mc command that defers configuration and stopping
the hardware to when we actually exit U-Boot, so that we can still use
the fabric from an EFI payload.

For existing boot scripts, nothing should change with this patch.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/arm/lib/bootm.c                    | 11 +++++++++++
 board/freescale/ls2080a/ls2080a.c       |  1 -
 board/freescale/ls2080aqds/ls2080aqds.c |  4 ----
 board/freescale/ls2080ardb/ls2080ardb.c |  4 ----
 drivers/net/fsl-mc/mc.c                 | 22 ++++++++++++++++++++--
 lib/efi_loader/efi_boottime.c           | 10 ++++++++++
 6 files changed, 41 insertions(+), 11 deletions(-)

Comments

Prabhakar Kushwaha May 18, 2016, 12:29 p.m. UTC | #1
> -----Original Message-----
> From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of
> Alexander Graf
> Sent: Friday, May 13, 2016 5:52 PM
> To: u-boot@lists.denx.de
> Subject: [U-Boot] [PATCH 1/5] ls2080: Exit dpaa only right before exiting U-
> Boot
> 
> On ls2080 we have a separate network fabric component which we need to
> shut down before we enter Linux (or any other OS). Along with that also
> comes configuration of the fabric using a description file.
> 
> Today we always stop and configure the fabric in the boot script and
> (again) exit it on device tree generation. This works ok for the normal booti
> case, but with bootefi the payload we're running may still want to access the
> network.
> 
> So let's add a new fsl_mc command that defers configuration and stopping
> the hardware to when we actually exit U-Boot, so that we can still use the
> fabric from an EFI payload.
> 
> For existing boot scripts, nothing should change with this patch.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>

With this patch.

If I does not apply MC,  I am getting following crash:-

Starting kernel ...

"Synchronous Abort" handler, esr 0x96000044
ELR:     fff4666c
LR:      fff46cc4
x0 : d51ec00010004000 x1 : 00000000ffcf9fc0
x2 : 0000000000000001 x3 : d51ec00010004000
x4 : 00000000d51ec000 x5 : 0000000000000000
x6 : 0000000000000000 x7 : 000000009fffccc7
x8 : 000000009fffd080 x9 : 000000000000000c
x10: 0000000000000003 x11: 00000000ffcf9cd8
x12: 00000000fff6cc40 x13: 00000000ffcf90e0
x14: 0000000100000000 x15: 000000009ffff9a3
x16: 00000000ffd0ad40 x17: 00000000ffd0b630
x18: 00000000ffcfbd78 x19: 0000000000000000
x20: 00000000fffba000 x21: 00000000fffba520
x22: 00000000fffba528 x23: 0000000000000000
x24: 0000000000000000 x25: 00000000ffd03878
x26: 00000000fff8fb40 x27: 0000000000000000
x28: 00000000a00000e0 x29: 00000000ffcf9f70

Resetting CPU ...

### ERROR ### Please RESET the board ###



If I apply this patch.  MC timeout happens

Starting kernel ...

Error: Timeout waiting for MC response
dpbp_open() failed: -110
dpbp_exit() failed: -110
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Initializing cgroup subsys cpu


--prabhakar
Alexander Graf May 27, 2016, 2:27 p.m. UTC | #2
On 05/18/2016 02:29 PM, Prabhakar Kushwaha wrote:
>> -----Original Message-----
>> From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of
>> Alexander Graf
>> Sent: Friday, May 13, 2016 5:52 PM
>> To: u-boot@lists.denx.de
>> Subject: [U-Boot] [PATCH 1/5] ls2080: Exit dpaa only right before exiting U-
>> Boot
>>
>> On ls2080 we have a separate network fabric component which we need to
>> shut down before we enter Linux (or any other OS). Along with that also
>> comes configuration of the fabric using a description file.
>>
>> Today we always stop and configure the fabric in the boot script and
>> (again) exit it on device tree generation. This works ok for the normal booti
>> case, but with bootefi the payload we're running may still want to access the
>> network.
>>
>> So let's add a new fsl_mc command that defers configuration and stopping
>> the hardware to when we actually exit U-Boot, so that we can still use the
>> fabric from an EFI payload.
>>
>> For existing boot scripts, nothing should change with this patch.
>>
>> Signed-off-by: Alexander Graf <agraf@suse.de>
> With this patch.
>
> If I does not apply MC,  I am getting following crash:-
>
> Starting kernel ...
>
> "Synchronous Abort" handler, esr 0x96000044

So should we consider it a bug fix or regression then? :)


Alex
Prabhakar Kushwaha June 7, 2016, 1:28 a.m. UTC | #3
Hi Alex,

> -----Original Message-----
> From: Alexander Graf [mailto:agraf@suse.de]
> Sent: Friday, May 27, 2016 7:58 PM
> To: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>; u-
> boot@lists.denx.de
> Cc: york sun <york.sun@nxp.com>
> Subject: Re: [U-Boot] [PATCH 1/5] ls2080: Exit dpaa only right before exiting
> U-Boot
> 
> On 05/18/2016 02:29 PM, Prabhakar Kushwaha wrote:
> >> -----Original Message-----
> >> From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of
> >> Alexander Graf
> >> Sent: Friday, May 13, 2016 5:52 PM
> >> To: u-boot@lists.denx.de
> >> Subject: [U-Boot] [PATCH 1/5] ls2080: Exit dpaa only right before
> >> exiting U- Boot
> >>
> >> On ls2080 we have a separate network fabric component which we need
> >> to shut down before we enter Linux (or any other OS). Along with that
> >> also comes configuration of the fabric using a description file.
> >>
> >> Today we always stop and configure the fabric in the boot script and
> >> (again) exit it on device tree generation. This works ok for the
> >> normal booti case, but with bootefi the payload we're running may
> >> still want to access the network.
> >>
> >> So let's add a new fsl_mc command that defers configuration and
> >> stopping the hardware to when we actually exit U-Boot, so that we can
> >> still use the fabric from an EFI payload.
> >>
> >> For existing boot scripts, nothing should change with this patch.
> >>
> >> Signed-off-by: Alexander Graf <agraf@suse.de>
> > With this patch.
> >
> > If I does not apply MC,  I am getting following crash:-
> >
> > Starting kernel ...
> >
> > "Synchronous Abort" handler, esr 0x96000044
> 
> So should we consider it a bug fix or regression then? :)
> 
> 

Are you planning to fix it?

If not let me know I will try to  work on it. 

--prabhakar
diff mbox

Patch

diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 0838d89..95037c1 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -30,6 +30,11 @@ 
 #include <asm/armv7.h>
 #endif
 
+#ifdef CONFIG_FSL_MC_ENET
+#include <fsl-mc/fsl_mc.h>
+#include <fsl-mc/fsl_mc_private.h>
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 static struct tag *params;
@@ -84,6 +89,12 @@  static void announce_and_cleanup(int fake)
 #ifdef CONFIG_USB_DEVICE
 	udc_disconnect();
 #endif
+
+#ifdef CONFIG_FSL_MC_ENET
+	if (!fsl_mc_ldpaa_exit(NULL))
+		mc_apply_dpl(0);
+#endif
+
 	cleanup_before_linux();
 }
 
diff --git a/board/freescale/ls2080a/ls2080a.c b/board/freescale/ls2080a/ls2080a.c
index 00337d7..ca2bcfc 100644
--- a/board/freescale/ls2080a/ls2080a.c
+++ b/board/freescale/ls2080a/ls2080a.c
@@ -127,7 +127,6 @@  int ft_board_setup(void *blob, bd_t *bd)
 
 #ifdef CONFIG_FSL_MC_ENET
 	fdt_fixup_board_enet(blob);
-	fsl_mc_ldpaa_exit(bd);
 #endif
 
 	return 0;
diff --git a/board/freescale/ls2080aqds/ls2080aqds.c b/board/freescale/ls2080aqds/ls2080aqds.c
index b3bd40a..a8620f7 100644
--- a/board/freescale/ls2080aqds/ls2080aqds.c
+++ b/board/freescale/ls2080aqds/ls2080aqds.c
@@ -282,7 +282,6 @@  void fdt_fixup_board_enet(void *fdt)
 #ifdef CONFIG_OF_BOARD_SETUP
 int ft_board_setup(void *blob, bd_t *bd)
 {
-	int err;
 	u64 base[CONFIG_NR_DRAM_BANKS];
 	u64 size[CONFIG_NR_DRAM_BANKS];
 
@@ -298,9 +297,6 @@  int ft_board_setup(void *blob, bd_t *bd)
 
 #ifdef CONFIG_FSL_MC_ENET
 	fdt_fixup_board_enet(blob);
-	err = fsl_mc_ldpaa_exit(bd);
-	if (err)
-		return err;
 #endif
 
 	return 0;
diff --git a/board/freescale/ls2080ardb/ls2080ardb.c b/board/freescale/ls2080ardb/ls2080ardb.c
index fb39af6..0cc67c1 100644
--- a/board/freescale/ls2080ardb/ls2080ardb.c
+++ b/board/freescale/ls2080ardb/ls2080ardb.c
@@ -261,7 +261,6 @@  void fdt_fixup_board_enet(void *fdt)
 #ifdef CONFIG_OF_BOARD_SETUP
 int ft_board_setup(void *blob, bd_t *bd)
 {
-	int err;
 	u64 base[CONFIG_NR_DRAM_BANKS];
 	u64 size[CONFIG_NR_DRAM_BANKS];
 
@@ -277,9 +276,6 @@  int ft_board_setup(void *blob, bd_t *bd)
 
 #ifdef CONFIG_FSL_MC_ENET
 	fdt_fixup_board_enet(blob);
-	err = fsl_mc_ldpaa_exit(bd);
-	if (err)
-		return err;
 #endif
 
 	return 0;
diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index 1811b0f..d0f5e02 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -40,6 +40,7 @@  int child_dprc_id;
 struct fsl_dpbp_obj *dflt_dpbp = NULL;
 struct fsl_dpio_obj *dflt_dpio = NULL;
 struct fsl_dpni_obj *dflt_dpni = NULL;
+static u64 mc_lazy_dpl_addr;
 
 #ifdef DEBUG
 void dump_ram_words(const char *title, void *addr)
@@ -572,6 +573,12 @@  int mc_apply_dpl(u64 mc_dpl_addr)
 	u64 mc_ram_addr = mc_get_dram_addr();
 	size_t mc_ram_size = mc_get_dram_block_size();
 
+	if (!mc_dpl_addr)
+		mc_dpl_addr = mc_lazy_dpl_addr;
+
+	if (!mc_dpl_addr)
+		return -1;
+
 	error = load_mc_dpl(mc_ram_addr, mc_ram_size, mc_dpl_addr);
 	if (error != 0)
 		return error;
@@ -1259,6 +1266,7 @@  static int do_fsl_mc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		}
 		break;
 
+	case 'l':
 	case 'a': {
 			u64 mc_dpl_addr;
 
@@ -1279,8 +1287,17 @@  static int do_fsl_mc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 				return -ENODEV;
 			}
 
-			if (!fsl_mc_ldpaa_exit(NULL))
-				err = mc_apply_dpl(mc_dpl_addr);
+			if (argv[1][0] == 'l') {
+				/*
+				 * We will do the actual dpaa exit and dpl apply
+				 * later from announce_and_cleanup().
+				 */
+				mc_lazy_dpl_addr = mc_dpl_addr;
+			} else {
+				/* The user wants it applied now */
+				if (!fsl_mc_ldpaa_exit(NULL))
+					err = mc_apply_dpl(mc_dpl_addr);
+			}
 			break;
 		}
 	default:
@@ -1298,5 +1315,6 @@  U_BOOT_CMD(
 	"DPAA2 command to manage Management Complex (MC)",
 	"start mc [FW_addr] [DPC_addr] - Start Management Complex\n"
 	"fsl_mc apply DPL [DPL_addr] - Apply DPL file\n"
+	"fsl_mc lazyapply DPL [DPL_addr] - Apply DPL file on exit\n"
 	"fsl_mc start aiop [FW_addr] - Start AIOP\n"
 );
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 9daca50..0aff793 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -18,6 +18,11 @@ 
 #include <inttypes.h>
 #include <watchdog.h>
 
+#ifdef CONFIG_FSL_MC_ENET
+#include <fsl-mc/fsl_mc.h>
+#include <fsl-mc/fsl_mc_private.h>
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 /* This list contains all the EFI objects our payload has access to */
@@ -516,6 +521,11 @@  static efi_status_t EFIAPI efi_exit_boot_services(void *image_handle,
 {
 	EFI_ENTRY("%p, %ld", image_handle, map_key);
 
+#ifdef CONFIG_FSL_MC_ENET
+	if (!fsl_mc_ldpaa_exit(NULL))
+		mc_apply_dpl(0);
+#endif
+
 	/* Fix up caches for EFI payloads if necessary */
 	efi_exit_caches();