Skip to contentSkip to conversation

x86: Change tesing logic of mtrr commit

PATCH In review Simon Glass 2 participants 5 messages Jul 31, 2023 – Aug 1, 2023 x86

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 x86: Change tesing logic of mtrr commit

From: Bin Meng <[email protected]>

On Coral U-Boot SPL programs some MTRRs and FSPv2 in U-Boot proper needs to program MTRRs too. With current testing logic of mtrr commit in init_cache_f_r(), the mtrr commit is skipped which won't work as the queued mtrr requests include setup for DRAM regions.

Change the logic to allow such configuration.

Tweak to put back CONFIG_FSP_VERSION2 at top:

---

Changes in v3:
- Allow committing MTRRs with FSP_VERSION2

Changes in v2:
- new patch: "x86: Change tesing logic of mtrr commit"

 arch/x86/lib/init_helpers.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/x86/lib/init_helpers.c +2 -4
index f33194045f9e..60a2707dcf1b 100644
@@ -21,8 +21,7 @@ int init_cache_f_r(void)
 	/*
 	 * Supported configurations:
 	 *
-	 * booting from slimbootloader - in that case the MTRRs are already set
-	 *	up
+	 * booting from slimbootloader - MTRRs are already set up
 	 * booting with FSPv1 - MTRRs are already set up
 	 * booting with FSPv2 - MTRRs must be set here
 	 * booting from coreboot - in this case there is no SPL, so we set up
@@ -30,8 +29,7 @@ int init_cache_f_r(void)
 	 * Note: if there is an SPL, then it has already set up MTRRs so we
 	 *	don't need to do that here
 	 */
-	do_mtrr &= !IS_ENABLED(CONFIG_SPL) &&
-		!IS_ENABLED(CONFIG_FSP_VERSION1) &&
+	do_mtrr &= !IS_ENABLED(CONFIG_FSP_VERSION1) &&
 		!IS_ENABLED(CONFIG_SYS_SLIMBOOTLOADER);
 
 	if (do_mtrr) {
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#1 lore raw

Hi Simon,

Quoted 40 lines · Simon Glass

From: Bin Meng <[email protected]>

On Coral U-Boot SPL programs some MTRRs and FSPv2 in U-Boot proper needs to program MTRRs too. With current testing logic of mtrr commit in init_cache_f_r(), the mtrr commit is skipped which won't work as the queued mtrr requests include setup for DRAM regions.

Change the logic to allow such configuration.

Tweak to put back CONFIG_FSP_VERSION2 at top:

---

Changes in v3:
- Allow committing MTRRs with FSP_VERSION2

Changes in v2:
- new patch: "x86: Change tesing logic of mtrr commit"

 arch/x86/lib/init_helpers.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/x86/lib/init_helpers.c +1 -2
index f33194045f9e..60a2707dcf1b 100644
@@ -21,8 +21,7 @@ int init_cache_f_r(void)
        /*
         * Supported configurations:
         *
-        * booting from slimbootloader - in that case the MTRRs are already set
-        *      up
+        * booting from slimbootloader - MTRRs are already set up
         * booting with FSPv1 - MTRRs are already set up
         * booting with FSPv2 - MTRRs must be set here
         * booting from coreboot - in this case there is no SPL, so we set up

arch/x86/lib/init_helpers.c int init_cache_f_r(void) · line 32

Quoted 6 lines
arch/x86/lib/init_helpers.c +1 -2
@@ -30,8 +29,7 @@ int init_cache_f_r(void)
         * Note: if there is an SPL, then it has already set up MTRRs so we
         *      don't need to do that here
         */
-       do_mtrr &= !IS_ENABLED(CONFIG_SPL) &&
-               !IS_ENABLED(CONFIG_FSP_VERSION1) &&
+       do_mtrr &= !IS_ENABLED(CONFIG_FSP_VERSION1) &&

The drop of IS_ENABLED(CONFIG_SPL) here will cause:

1. SPL programs the MTRR
2. U-Boot proper programs the MTRR again, which is not we want

My patch covers such scenario, no?

arch/x86/lib/init_helpers.c int init_cache_f_r(void) · line 35

Quoted 3 lines
arch/x86/lib/init_helpers.c +0 -0
                !IS_ENABLED(CONFIG_SYS_SLIMBOOTLOADER);
 
        if (do_mtrr) {

Regards,
Bin

#2 lore raw

Hi Bin,

Quoted 53 lines · Bin Meng

Hi Simon,

Quoted 40 lines · Simon Glass

From: Bin Meng <[email protected]>

On Coral U-Boot SPL programs some MTRRs and FSPv2 in U-Boot proper needs to program MTRRs too. With current testing logic of mtrr commit in init_cache_f_r(), the mtrr commit is skipped which won't work as the queued mtrr requests include setup for DRAM regions.

Change the logic to allow such configuration.

Tweak to put back CONFIG_FSP_VERSION2 at top:

---

Changes in v3:
- Allow committing MTRRs with FSP_VERSION2

Changes in v2:
- new patch: "x86: Change tesing logic of mtrr commit"

 arch/x86/lib/init_helpers.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/x86/lib/init_helpers.c +1 -2
index f33194045f9e..60a2707dcf1b 100644
@@ -21,8 +21,7 @@ int init_cache_f_r(void)
        /*
         * Supported configurations:
         *
-        * booting from slimbootloader - in that case the MTRRs are already set
-        *      up
+        * booting from slimbootloader - MTRRs are already set up
         * booting with FSPv1 - MTRRs are already set up
         * booting with FSPv2 - MTRRs must be set here
         * booting from coreboot - in this case there is no SPL, so we set up

arch/x86/lib/init_helpers.c int init_cache_f_r(void) · line 32

Quoted 6 lines
arch/x86/lib/init_helpers.c +1 -2
@@ -30,8 +29,7 @@ int init_cache_f_r(void)
         * Note: if there is an SPL, then it has already set up MTRRs so we
         *      don't need to do that here
         */
-       do_mtrr &= !IS_ENABLED(CONFIG_SPL) &&
-               !IS_ENABLED(CONFIG_FSP_VERSION1) &&
+       do_mtrr &= !IS_ENABLED(CONFIG_FSP_VERSION1) &&

The drop of IS_ENABLED(CONFIG_SPL) here will cause:

Quoted 2 lines

1. SPL programs the MTRR
2. U-Boot proper programs the MTRR again, which is not we want

I believe it is what we want since we want to drop the SPI things and add the SDRAM ones which U-Boot proper has added.

Quoted 6 lines

My patch covers such scenario, no?

Quoted 3 lines
arch/x86/lib/init_helpers.c +0 -0
                !IS_ENABLED(CONFIG_SYS_SLIMBOOTLOADER);
 
        if (do_mtrr) {

No, with your patch do_mtrr is set to false at the top, so the &= does nothing. I promise you, if it worked I would say so, but it doesn't :-)

Regards,
Simon

#3 lore raw

Hi Simon,

Quoted 66 lines · Simon Glass

Hi Bin,

Quoted 53 lines · Bin Meng

Hi Simon,

Quoted 40 lines · Simon Glass

From: Bin Meng <[email protected]>

On Coral U-Boot SPL programs some MTRRs and FSPv2 in U-Boot proper needs to program MTRRs too. With current testing logic of mtrr commit in init_cache_f_r(), the mtrr commit is skipped which won't work as the queued mtrr requests include setup for DRAM regions.

Change the logic to allow such configuration.

Tweak to put back CONFIG_FSP_VERSION2 at top:

---

Changes in v3:
- Allow committing MTRRs with FSP_VERSION2

Changes in v2:
- new patch: "x86: Change tesing logic of mtrr commit"

 arch/x86/lib/init_helpers.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/x86/lib/init_helpers.c +1 -2
index f33194045f9e..60a2707dcf1b 100644
@@ -21,8 +21,7 @@ int init_cache_f_r(void)
        /*
         * Supported configurations:
         *
-        * booting from slimbootloader - in that case the MTRRs are already set
-        *      up
+        * booting from slimbootloader - MTRRs are already set up
         * booting with FSPv1 - MTRRs are already set up
         * booting with FSPv2 - MTRRs must be set here
         * booting from coreboot - in this case there is no SPL, so we set up

arch/x86/lib/init_helpers.c int init_cache_f_r(void) · line 32

Quoted 6 lines
arch/x86/lib/init_helpers.c +1 -2
@@ -30,8 +29,7 @@ int init_cache_f_r(void)
         * Note: if there is an SPL, then it has already set up MTRRs so we
         *      don't need to do that here
         */
-       do_mtrr &= !IS_ENABLED(CONFIG_SPL) &&
-               !IS_ENABLED(CONFIG_FSP_VERSION1) &&
+       do_mtrr &= !IS_ENABLED(CONFIG_FSP_VERSION1) &&

The drop of IS_ENABLED(CONFIG_SPL) here will cause:

Quoted 2 lines

1. SPL programs the MTRR
2. U-Boot proper programs the MTRR again, which is not we want

I believe it is what we want since we want to drop the SPI things and add the SDRAM ones which U-Boot proper has added.

Quoted 3 lines

My patch covers such scenario, no?

Quoted 8 lines
Quoted 3 lines

arch/x86/lib/init_helpers.c int init_cache_f_r(void) · line 35

Quoted 3 lines
arch/x86/lib/init_helpers.c +0 -0
                !IS_ENABLED(CONFIG_SYS_SLIMBOOTLOADER);
 
        if (do_mtrr) {

No, with your patch do_mtrr is set to false at the top, so the &= does nothing. I promise you, if it worked I would say so, but it doesn't :-)

Great!

Regards,
Bin

#4 lore raw
In reply to Simon Glass
Quoted 16 lines · Simon Glass

From: Bin Meng <[email protected]>

On Coral U-Boot SPL programs some MTRRs and FSPv2 in U-Boot proper needs to program MTRRs too. With current testing logic of mtrr commit in init_cache_f_r(), the mtrr commit is skipped which won't work as the queued mtrr requests include setup for DRAM regions.

Change the logic to allow such configuration.

Tweak to put back CONFIG_FSP_VERSION2 at top:

---

Quoted 9 lines

Changes in v3:
- Allow committing MTRRs with FSP_VERSION2

Changes in v2:
- new patch: "x86: Change tesing logic of mtrr commit"

 arch/x86/lib/init_helpers.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

applied to u-boot-x86, thanks!