x86: Fix up the MRC cache on ivybridge
Subsystems (2)
cover x86: Fix up the MRC cache on ivybridge
At present the MRC cache on ivybridge is disabled due to a bug which was unknown. This has now been located and a fix is included in this series. In addition, the RTC functions have a few problems which prevent the checksum from being read correctly. This series fixes these and adds a few other minor improvements.
Also included is a modified version of Bin's patch to enable the MRC cache on ivybridge.
Bin Meng (1):
x86: ivybridge: Enable the MRC cache
Simon Glass (8):
rtc: mc146818: Add a comment to the #endif
rtc: mc146818: Use probe() to set up the device
dm: rtc: Correct rtc_read32() return value
x86: ivybridge: Use 'ret' instead of 'rcode'
x86: ivybridge: Check the RTC return value
x86: ivybridge: Use CONFIG_ENABLE_MRC_CACHE option
x86: ivybridge: Fix car_uninit() to correctly set run state
x86: ivybridge: Measure the MRC code execution time
arch/x86/cpu/ivybridge/Kconfig | 6 ------ arch/x86/cpu/ivybridge/car.S | 6 +++--- arch/x86/cpu/ivybridge/sdram.c | 42 +++++++++++++++++++++++------------------- drivers/rtc/mc146818.c | 6 +++--- drivers/rtc/rtc-uclass.c | 2 +- 5 files changed, 30 insertions(+), 32 deletions(-)
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH 1/9 rtc: mc146818: Add a comment to the #endif
Add a comment to make it clear to which block the #endif relates.
---
drivers/rtc/mc146818.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/mc146818.c +1 -1
@@ -192,7 +192,7 @@ static void mc146818_init(void)/* Clear any pending interrupts */ mc146818_read8(RTC_CONFIG_C); } -#endif +#endif /* CONFIG_CMD_DATE */ #ifdef CONFIG_DM_RTC
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH 1/9 rtc: mc146818: Add a comment to the #endif
Quoted 13 lines · Simon Glass
Add a comment to make it clear to which block the #endif relates.
Signed-off-by Simon Glass <[email protected]>---
drivers/rtc/mc146818.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/mc146818.c +0
-0
drivers/rtc/mc146818.c static void mc146818_init(void)
Quoted 9 lines
drivers/rtc/mc146818.c +1
-2@@ -192,7 +192,7 @@ static void mc146818_init(void)/* Clear any pending interrupts */ mc146818_read8(RTC_CONFIG_C); } -#endif +#endif /* CONFIG_CMD_DATE */ #ifdef CONFIG_DM_RTC --
PATCH 1/9 rtc: mc146818: Add a comment to the #endif
Quoted 20 lines · Bin Meng
Quoted 19 lines · Simon Glass
Add a comment to make it clear to which block the #endif relates.
Signed-off-by Simon Glass <[email protected]>---
drivers/rtc/mc146818.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/mc146818.c +1
-1@@ -192,7 +192,7 @@ static void mc146818_init(void)/* Clear any pending interrupts */ mc146818_read8(RTC_CONFIG_C); } -#endif +#endif /* CONFIG_CMD_DATE */
Quoted 5 lines
drivers/rtc/mc146818.c static void mc146818_init(void)
Quoted 3 lines
drivers/rtc/mc146818.c +0
-1#ifdef CONFIG_DM_RTC --Reviewed-by Bin Meng <[email protected]>
Applied to u-boot-x86.
PATCH 2/9 rtc: mc146818: Use probe() to set up the device
In reply to Simon GlassAt present this driver uses bind() to set up the device. The bind() method should not touch the hardware, so move the init code to probe().
---
drivers/rtc/mc146818.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/mc146818.c +2 -2
@@ -225,7 +225,7 @@ static int rtc_mc146818_write8(struct udevice *dev, unsigned int reg, int val)return 0 ; } -static int rtc_mc146818_bind (struct udevice *dev) +static int rtc_mc146818_probe (struct udevice *dev) {mc146818_init ();
@@ -249,7 +249,7 @@ U_BOOT_DRIVER(rtc_mc146818) = { .name = "rtc_mc146818", .id = UCLASS_RTC, .of_match = rtc_mc146818_ids, - .bind = rtc_mc146818_bind, + .probe = rtc_mc146818_probe, .ops = &rtc_mc146818_ops, };
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH 2/9 rtc: mc146818: Use probe() to set up the device
Hi Simon,
Quoted 3 lines · Simon Glass
At present this driver uses
bind()to set up the device. Thebind()method should not touch the hardware, so move the init code toprobe().
I think RTC should be initialized anyway. If moving it to probe, it may not be initialized by U-Boot before jumping to kernel.
Quoted 20 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/rtc/mc146818.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/rtc/mc146818.c +1
-1@@ -225,7 +225,7 @@ static int rtc_mc146818_write8(struct udevice *dev, unsigned int reg, int val)return 0 ; } -static int rtc_mc146818_bind (struct udevice *dev) +static int rtc_mc146818_probe (struct udevice *dev) {mc146818_init ();
drivers/rtc/mc146818.c U_BOOT_DRIVER(rtc_mc146818) = {
Quoted 9 lines
drivers/rtc/mc146818.c +1
-2@@ -249,7 +249,7 @@ U_BOOT_DRIVER(rtc_mc146818) = { .name = "rtc_mc146818", .id = UCLASS_RTC, .of_match = rtc_mc146818_ids, - .bind = rtc_mc146818_bind, + .probe = rtc_mc146818_probe, .ops = &rtc_mc146818_ops, }; --
Regards,
Bin
PATCH 2/9 rtc: mc146818: Use probe() to set up the device
Hi Bin,
Quoted 9 lines · Bin Meng
Hi Simon,
Quoted 3 lines · Simon Glass
At present this driver uses
bind()to set up the device. Thebind()method should not touch the hardware, so move the init code toprobe().I think RTC should be initialized anyway. If moving it to probe, it may not be initialized by U-Boot before jumping to kernel.
That's fine, but the correct way to do this is to probe the device, not put the init code into the bind() method.
Quoted 29 lines
Quoted 29 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/rtc/mc146818.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/rtc/mc146818.c +2
-2@@ -225,7 +225,7 @@ static int rtc_mc146818_write8(struct udevice *dev, unsigned int reg, int val)return 0 ; } -static int rtc_mc146818_bind (struct udevice *dev) +static int rtc_mc146818_probe (struct udevice *dev) {mc146818_init ();@@ -249,7 +249,7 @@ U_BOOT_DRIVER(rtc_mc146818) = { .name = "rtc_mc146818", .id = UCLASS_RTC, .of_match = rtc_mc146818_ids, - .bind = rtc_mc146818_bind, + .probe = rtc_mc146818_probe, .ops = &rtc_mc146818_ops, };
Quoted 4 lines
Quoted 1 line
--
Regards,
Bin
Regards,
Simon
PATCH 2/9 rtc: mc146818: Use probe() to set up the device
Hi Simon,
Quoted 10 lines · Simon Glass
Hi Bin,
Quoted 7 lines · Bin Meng
Hi Simon,
Quoted 3 lines · Simon Glass
At present this driver uses
bind()to set up the device. Thebind()method should not touch the hardware, so move the init code toprobe().
Quoted 5 lines
Quoted 2 lines
I think RTC should be initialized anyway. If moving it to probe, it may not be initialized by U-Boot before jumping to kernel.
That's fine, but the correct way to do this is to probe the device, not put the init code into the
bind()method.
Yes, I agree. So maybe we explicitly trigger the probe somewhere in the initialization path?
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/rtc/mc146818.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/rtc/mc146818.c +2
-2@@ -225,7 +225,7 @@ static int rtc_mc146818_write8(struct udevice *dev, unsigned int reg, int val)return 0 ; } -static int rtc_mc146818_bind (struct udevice *dev) +static int rtc_mc146818_probe (struct udevice *dev) {mc146818_init ();@@ -249,7 +249,7 @@ U_BOOT_DRIVER(rtc_mc146818) = { .name = "rtc_mc146818", .id = UCLASS_RTC, .of_match = rtc_mc146818_ids, - .bind = rtc_mc146818_bind, + .probe = rtc_mc146818_probe, .ops = &rtc_mc146818_ops, };
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
--
Regards,
Bin
PATCH 2/9 rtc: mc146818: Use probe() to set up the device
Hi Bin,
Quoted 13 lines · Bin Meng
Hi Simon,
Quoted 10 lines · Simon Glass
Hi Bin,
Quoted 7 lines · Bin Meng
Hi Simon,
Quoted 3 lines · Simon Glass
At present this driver uses
bind()to set up the device. Thebind()method should not touch the hardware, so move the init code toprobe().
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
I think RTC should be initialized anyway. If moving it to probe, it may not be initialized by U-Boot before jumping to kernel.
That's fine, but the correct way to do this is to probe the device, not put the init code into the
bind()method.Yes, I agree. So maybe we explicitly trigger the probe somewhere in the initialization path?
Or maybe just before jumping to the OS - e.g. in boot_prep_linux()?
[snip]
Regards,
Simon
PATCH 2/9 rtc: mc146818: Use probe() to set up the device
Hi Simon,
Quoted 19 lines · Simon Glass
Hi Bin,
Quoted 16 lines · Bin Meng
Hi Simon,
Quoted 13 lines · Simon Glass
Hi Bin,
Quoted 9 lines · Bin Meng
Hi Simon,
Quoted 3 lines · Simon Glass
At present this driver uses
bind()to set up the device. Thebind()method should not touch the hardware, so move the init code toprobe().I think RTC should be initialized anyway. If moving it to probe, it may not be initialized by U-Boot before jumping to kernel.
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
That's fine, but the correct way to do this is to probe the device, not put the init code into the
bind()method.Yes, I agree. So maybe we explicitly trigger the probe somewhere in the initialization path?
Or maybe just before jumping to the OS - e.g. in
boot_prep_linux()?
Yes, that sounds good. And we may need consider other OSes as well. Maybe we need some consolidation.
Quoted 2 lines
[snip]
Regards,
Bin
PATCH 2/9 rtc: mc146818: Use probe() to set up the device
Quoted 32 lines · Bin Meng
Hi Simon,
Quoted 19 lines · Simon Glass
Hi Bin,
Quoted 16 lines · Bin Meng
Hi Simon,
Quoted 13 lines · Simon Glass
Hi Bin,
Quoted 9 lines · Bin Meng
Hi Simon,
Quoted 3 lines · Simon Glass
At present this driver uses
bind()to set up the device. Thebind()method should not touch the hardware, so move the init code toprobe().I think RTC should be initialized anyway. If moving it to probe, it may not be initialized by U-Boot before jumping to kernel.
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
That's fine, but the correct way to do this is to probe the device, not put the init code into the
bind()method.Yes, I agree. So maybe we explicitly trigger the probe somewhere in the initialization path?
Or maybe just before jumping to the OS - e.g. in
boot_prep_linux()?
Quoted 8 lines
Yes, that sounds good. And we may need consider other OSes as well. Maybe we need some consolidation.
Quoted 2 lines
[snip]
Regards,
Bin
Applied to u-boot-x86.
PATCH 3/9 dm: rtc: Correct rtc_read32() return value
In reply to Simon GlassThe current check is incorrect and will fail when any non-zero byte is read. Fix it.
---
drivers/rtc/rtc-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-uclass.c +1 -1
@@ -68,7 +68,7 @@ int rtc_read32(struct udevice *dev, unsigned int reg, u32 *valuep)for (i =0 ; i <sizeof (value); i++) { ret =rtc_read8 (dev, reg + i); -if (ret) +if (ret <0 )return ret; value |= ret << (i <<3 ); }
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH 3/9 dm: rtc: Correct rtc_read32() return value
Quoted 14 lines · Simon Glass
The current check is incorrect and will fail when any non-zero byte is read. Fix it.
Signed-off-by Simon Glass <[email protected]>---
drivers/rtc/rtc-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/rtc-uclass.c +0
-0
drivers/rtc/rtc-uclass.c int rtc_read32(struct udevice *dev, unsigned int reg, u32 *valuep)
Quoted 9 lines
drivers/rtc/rtc-uclass.c +1
-2@@ -68,7 +68,7 @@ int rtc_read32(struct udevice *dev, unsigned int reg, u32 *valuep)for (i =0 ; i <sizeof (value); i++) { ret =rtc_read8 (dev, reg + i); -if (ret) +if (ret <0 )return ret; value |= ret << (i <<3 ); } --
PATCH 3/9 dm: rtc: Correct rtc_read32() return value
Quoted 16 lines · Bin Meng
Quoted 15 lines · Simon Glass
The current check is incorrect and will fail when any non-zero byte is read. Fix it.
Signed-off-by Simon Glass <[email protected]>---
drivers/rtc/rtc-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/rtc-uclass.c +0
-0@@ -68,7 +68,7 @@ int rtc_read32(struct udevice *dev, unsigned int reg, u32 *valuep)
Quoted 10 lines
drivers/rtc/rtc-uclass.c int rtc_read32(struct udevice *dev, unsigned int reg, u32 *valuep)
Quoted 8 lines
drivers/rtc/rtc-uclass.c +1
-2for (i =0 ; i <sizeof (value); i++) { ret =rtc_read8 (dev, reg + i); -if (ret) +if (ret <0 )return ret; value |= ret << (i <<3 ); } --Reviewed-by Bin Meng <[email protected]>
Applied to u-boot-x86.
PATCH 4/9 x86: ivybridge: Use 'ret' instead of 'rcode'
In reply to Simon GlassFor consistency, use 'ret' to handle a return value.
---
arch/x86/cpu/ivybridge/sdram.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/x86/cpu/ivybridge/sdram.c +8 -8
@@ -93,11 +93,11 @@ static int read_seed_from_cmos(struct pei_data *pei_data) {u16 c1, c2, checksum, seed_checksum;struct udevice *dev; -int rcode =0 ; +int ret =0 ; - rcode =uclass_get_device (UCLASS_RTC ,0 , &dev); -if (rcode) { -debug ("Cannot find RTC: err=%d\n" , rcode); + ret =uclass_get_device (UCLASS_RTC ,0 , &dev); +if (ret) { +debug ("Cannot find RTC: err=%d\n" , ret);return -ENODEV ; }
@@ -170,11 +170,11 @@ static int write_seeds_to_cmos(struct pei_data *pei_data) {u16 c1, c2, checksum;struct udevice *dev; -int rcode =0 ; +int ret =0 ; - rcode =uclass_get_device (UCLASS_RTC ,0 , &dev); -if (rcode) { -debug ("Cannot find RTC: err=%d\n" , rcode); + ret =uclass_get_device (UCLASS_RTC ,0 , &dev); +if (ret) { +debug ("Cannot find RTC: err=%d\n" , ret);return -ENODEV ; }
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH 4/9 x86: ivybridge: Use 'ret' instead of 'rcode'
Quoted 35 lines · Simon Glass
For consistency, use 'ret' to handle a return value.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/ivybridge/sdram.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)arch/x86/cpu/ivybridge/sdram.c +5
-5@@ -93,11 +93,11 @@ static int read_seed_from_cmos(struct pei_data *pei_data) {u16 c1, c2, checksum, seed_checksum;struct udevice *dev; -int rcode =0 ; +int ret =0 ; - rcode =uclass_get_device (UCLASS_RTC ,0 , &dev); -if (rcode) { -debug ("Cannot find RTC: err=%d\n" , rcode); + ret =uclass_get_device (UCLASS_RTC ,0 , &dev); +if (ret) { +debug ("Cannot find RTC: err=%d\n" , ret);return -ENODEV ; }@@ -170,11 +170,11 @@ static int write_seeds_to_cmos(struct pei_data *pei_data) {u16 c1, c2, checksum;struct udevice *dev; -int rcode =0 ; +int ret =0 ;
arch/x86/cpu/ivybridge/sdram.c static int write_seeds_to_cmos(struct pei_data *pei_data)
Quoted 10 lines
arch/x86/cpu/ivybridge/sdram.c +3
-4- rcode =uclass_get_device (UCLASS_RTC ,0 , &dev); -if (rcode) { -debug ("Cannot find RTC: err=%d\n" , rcode); + ret =uclass_get_device (UCLASS_RTC ,0 , &dev); +if (ret) { +debug ("Cannot find RTC: err=%d\n" , ret);return -ENODEV ; } --
PATCH 4/9 x86: ivybridge: Use 'ret' instead of 'rcode'
Quoted 6 lines · Bin Meng
Quoted 5 lines · Simon Glass
For consistency, use 'ret' to handle a return value.
Signed-off-by Simon Glass <[email protected]>---
Quoted 6 lines
Quoted 3 lines
arch/x86/cpu/ivybridge/sdram.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)Reviewed-by Bin Meng <[email protected]>
Applied to u-boot-x86.
PATCH 5/9 x86: ivybridge: Check the RTC return value
In reply to Simon GlassThe RTC can fail, so check the return value for reads.
---
arch/x86/cpu/ivybridge/sdram.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
arch/x86/cpu/ivybridge/sdram.c +10 -3
@@ -107,11 +107,18 @@ static int read_seed_from_cmos(struct pei_data *pei_data)* the flash too much. So we store these in CMOS and the large MRC * data in SPI flash. */ -rtc_read32 (dev,CMOS_OFFSET_MRC_SEED , &pei_data->scrambler_seed); + ret =rtc_read32 (dev,CMOS_OFFSET_MRC_SEED , &pei_data->scrambler_seed); +if (!ret) { + ret =rtc_read32 (dev,CMOS_OFFSET_MRC_SEED_S3 , + &pei_data->scrambler_seed_s3); + } +if (ret) { +debug ("Failed to read from RTC %s\n" , dev->name); +return ret; + } +debug ("Read scrambler seed 0x%08x from CMOS 0x%02x\n" , pei_data->scrambler_seed,CMOS_OFFSET_MRC_SEED ); - -rtc_read32 (dev,CMOS_OFFSET_MRC_SEED_S3 , &pei_data->scrambler_seed_s3);debug ("Read S3 scrambler seed 0x%08x from CMOS 0x%02x\n" , pei_data->scrambler_seed_s3,CMOS_OFFSET_MRC_SEED_S3 );
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH 5/9 x86: ivybridge: Check the RTC return value
Quoted 25 lines · Simon Glass
The RTC can fail, so check the return value for reads.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/ivybridge/sdram.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)arch/x86/cpu/ivybridge/sdram.c +8
-1@@ -107,11 +107,18 @@ static int read_seed_from_cmos(struct pei_data *pei_data)* the flash too much. So we store these in CMOS and the large MRC * data in SPI flash. */ -rtc_read32 (dev,CMOS_OFFSET_MRC_SEED , &pei_data->scrambler_seed); + ret =rtc_read32 (dev,CMOS_OFFSET_MRC_SEED , &pei_data->scrambler_seed); +if (!ret) { + ret =rtc_read32 (dev,CMOS_OFFSET_MRC_SEED_S3 , + &pei_data->scrambler_seed_s3); + } +if (ret) { +debug ("Failed to read from RTC %s\n" , dev->name); +return ret;
arch/x86/cpu/ivybridge/sdram.c static int read_seed_from_cmos(struct pei_data *pei_data)
Quoted 10 lines
arch/x86/cpu/ivybridge/sdram.c +2
-3+ } +debug ("Read scrambler seed 0x%08x from CMOS 0x%02x\n" , pei_data->scrambler_seed,CMOS_OFFSET_MRC_SEED ); - -rtc_read32 (dev,CMOS_OFFSET_MRC_SEED_S3 , &pei_data->scrambler_seed_s3);debug ("Read S3 scrambler seed 0x%08x from CMOS 0x%02x\n" , pei_data->scrambler_seed_s3,CMOS_OFFSET_MRC_SEED_S3 ); --
PATCH 5/9 x86: ivybridge: Check the RTC return value
Quoted 9 lines · Bin Meng
Quoted 8 lines · Simon Glass
The RTC can fail, so check the return value for reads.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/ivybridge/sdram.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
[snip]
Quoted 2 lines
Reviewed-by Bin Meng <[email protected]>
Applied to u-boot-x86.
PATCH 6/9 x86: ivybridge: Use CONFIG_ENABLE_MRC_CACHE option
In reply to Simon GlassUse this option instead of a private CONFIG_CACHE_MRC_BIN option.
---
arch/x86/cpu/ivybridge/Kconfig | 6 ------ arch/x86/cpu/ivybridge/car.S | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-)
arch/x86/cpu/ivybridge/Kconfig +0 -6
@@ -8,12 +8,10 @@ config NORTHBRIDGE_INTEL_SANDYBRIDGE bool - select CACHE_MRC_BIN select CPU_INTEL_MODEL_206AX config NORTHBRIDGE_INTEL_IVYBRIDGE bool - select CACHE_MRC_BIN select CPU_INTEL_MODEL_306AX if NORTHBRIDGE_INTEL_SANDYBRIDGE
@@ -136,8 +134,4 @@ config SOCKET_SPECIFIC_OPTIONS # dummy select SSE select CACHE_AS_RAM -config CACHE_MRC_BIN - bool - default n - endif
arch/x86/cpu/ivybridge/car.S +2 -2
@@ -145,7 +145,7 @@ clear_mtrrs: wrmsr post_code(POST_CAR_ROM_CACHE) -#ifdef CONFIG_CACHE_MRC_BIN +#ifdef CONFIG_ENABLE_MRC_CACHE /* Enable caching for ram init code to run faster */ movl $MTRR_PHYS_BASE_MSR(2), %ecx movl $(CACHE_MRC_BASE | MTRR_TYPE_WRPROT), %eax
@@ -200,7 +200,7 @@ car_uninit: andl $~1, %eax wrmsr -#ifdef CONFIG_CACHE_MRC_BIN +#ifdef CONFIG_ENABLE_MRC_CACHE /* Clear the MTRR that was used to cache MRC */ xorl %eax, %eax xorl %edx, %edx
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH 6/9 x86: ivybridge: Use CONFIG_ENABLE_MRC_CACHE option
Hi Simon,
Quoted 2 lines · Simon Glass
Use this option instead of a private
CONFIG_CACHE_MRC_BINoption.
The CONFIG_CACHE_MRC_BIN option seems to be used to program the MTRR for the mrc.bin text range to make it run faster. It is nothing related to the MRC cache data that the CONFIG_ENABLE_MRC_CACHE option is about.
Quoted 47 lines
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/ivybridge/Kconfig | 6 ------ arch/x86/cpu/ivybridge/car.S | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-)arch/x86/cpu/ivybridge/Kconfig +0
-6@@ -8,12 +8,10 @@ config NORTHBRIDGE_INTEL_SANDYBRIDGE bool - select CACHE_MRC_BIN select CPU_INTEL_MODEL_206AX config NORTHBRIDGE_INTEL_IVYBRIDGE bool - select CACHE_MRC_BIN select CPU_INTEL_MODEL_306AX if NORTHBRIDGE_INTEL_SANDYBRIDGE@@ -136,8 +134,4 @@ config SOCKET_SPECIFIC_OPTIONS # dummy select SSE select CACHE_AS_RAM -config CACHE_MRC_BIN - bool - default n - endifarch/x86/cpu/ivybridge/car.S +1
-1@@ -145,7 +145,7 @@ clear_mtrrs: wrmsr post_code(POST_CAR_ROM_CACHE) -#ifdef CONFIG_CACHE_MRC_BIN +#ifdef CONFIG_ENABLE_MRC_CACHE /* Enable caching for ram init code to run faster */ movl $MTRR_PHYS_BASE_MSR(2), %ecx movl $(CACHE_MRC_BASE | MTRR_TYPE_WRPROT), %eax
arch/x86/cpu/ivybridge/car.S car_uninit:
Quoted 9 lines
arch/x86/cpu/ivybridge/car.S +1
-2@@ -200,7 +200,7 @@ car_uninit: andl $~1, %eax wrmsr -#ifdef CONFIG_CACHE_MRC_BIN +#ifdef CONFIG_ENABLE_MRC_CACHE /* Clear the MTRR that was used to cache MRC */ xorl %eax, %eax xorl %edx, %edx --
Regards,
Bin
PATCH 6/9 x86: ivybridge: Use CONFIG_ENABLE_MRC_CACHE option
Quoted 10 lines · Bin Meng
Hi Simon,
Quoted 2 lines · Simon Glass
Use this option instead of a private
CONFIG_CACHE_MRC_BINoption.The
CONFIG_CACHE_MRC_BINoption seems to be used to program the MTRR for the mrc.bin text range to make it run faster. It is nothing related to the MRC cache data that theCONFIG_ENABLE_MRC_CACHEoption is about.
OK, I'll just drop this patch.
Quoted 8 lines
Quoted 8 lines
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/ivybridge/Kconfig | 6 ------ arch/x86/cpu/ivybridge/car.S | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-)
[snip]
PATCH 7/9 x86: ivybridge: Fix car_uninit() to correctly set run state
In reply to Simon GlassAt present a missing $ causes this code to hang when using the MRC cache/ Fix it.
---
arch/x86/cpu/ivybridge/car.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/cpu/ivybridge/car.S +1 -1
@@ -188,7 +188,7 @@ car_uninit: wrmsr /* Disable the no-eviction run state */ - movl NOEVICTMOD_MSR, %ecx + movl $NOEVICTMOD_MSR, %ecx rdmsr andl $~2, %eax wrmsr
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH 7/9 x86: ivybridge: Fix car_uninit() to correctly set run state
Hi Simon,
Quoted 4 lines · Simon Glass
At present a missing $ causes this code to hang when using the MRC cache/ Fix it.
Signed-off-by Simon Glass <[email protected]>
Quoted 10 lines
---
arch/x86/cpu/ivybridge/car.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/cpu/ivybridge/car.S +0
-0
arch/x86/cpu/ivybridge/car.S car_uninit: · line 191
Quoted 5 lines
arch/x86/cpu/ivybridge/car.S +1
-1@@ -188,7 +188,7 @@ car_uninit: wrmsr /* Disable the no-eviction run state */ - movl NOEVICTMOD_MSR, %ecx + movl $NOEVICTMOD_MSR, %ecx
I am wondering why compiler does not complain this.
arch/x86/cpu/ivybridge/car.S car_uninit:
Quoted 4 lines
arch/x86/cpu/ivybridge/car.S +0
-1rdmsr andl $~2, %eax wrmsr --
Regards,
Bin
PATCH 7/9 x86: ivybridge: Fix car_uninit() to correctly set run state
Hi Bin,
Quoted 22 lines · Bin Meng
Hi Simon,
Quoted 4 lines · Simon Glass
At present a missing $ causes this code to hang when using the MRC cache/ Fix it.
Signed-off-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>Quoted 12 lines
---
arch/x86/cpu/ivybridge/car.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/cpu/ivybridge/car.S +0
-0@@ -188,7 +188,7 @@ car_uninit: wrmsr
Quoted 6 lines
arch/x86/cpu/ivybridge/car.S car_uninit: · line 191
Quoted 3 lines
arch/x86/cpu/ivybridge/car.S +1
-1/* Disable the no-eviction run state */ - movl NOEVICTMOD_MSR, %ecx + movl $NOEVICTMOD_MSR, %ecxI am wondering why compiler does not complain this.
I suppose it just uses the value at that address.
Quoted 4 lines
arch/x86/cpu/ivybridge/car.S car_uninit:
Quoted 4 lines
arch/x86/cpu/ivybridge/car.S +0
-1rdmsr andl $~2, %eax wrmsr --
Regards,
Simon
PATCH 7/9 x86: ivybridge: Fix car_uninit() to correctly set run state
Quoted 34 lines · Simon Glass
Hi Bin,
Quoted 22 lines · Bin Meng
Hi Simon,
Quoted 4 lines · Simon Glass
At present a missing $ causes this code to hang when using the MRC cache/ Fix it.
Signed-off-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>Quoted 12 lines
---
arch/x86/cpu/ivybridge/car.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/cpu/ivybridge/car.S +0
-0@@ -188,7 +188,7 @@ car_uninit: wrmsrQuoted 6 lines
arch/x86/cpu/ivybridge/car.S car_uninit: · line 191
Quoted 3 lines
arch/x86/cpu/ivybridge/car.S +1
-1/* Disable the no-eviction run state */ - movl NOEVICTMOD_MSR, %ecx + movl $NOEVICTMOD_MSR, %ecxI am wondering why compiler does not complain this.
I suppose it just uses the value at that address.
Quoted 7 lines
Quoted 4 lines
arch/x86/cpu/ivybridge/car.S car_uninit:
Quoted 4 lines
arch/x86/cpu/ivybridge/car.S +0
-1rdmsr andl $~2, %eax wrmsr --Regards,
Simon
Applied to u-boot-x86.
PATCH 8/9 x86: ivybridge: Measure the MRC code execution time
In reply to Simon GlassThis code takes about 450ms without the MRC cache and about 27ms with the cache. Add a debug timer so that this time can be displayed.
---
arch/x86/cpu/ivybridge/sdram.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/cpu/ivybridge/sdram.c +3 -0
@@ -336,9 +336,11 @@ int sdram_initialise(struct pei_data *pei_data)if (data) {int rv;int (*func)(struct pei_data *); +ulong start;debug ("Calling MRC at %p\n" , data);post_code (POST_PRE_MRC ); + start =get_timer (0 ); func = (int (*)(struct pei_data *))data; rv =func (pei_data);post_code (POST_MRC );
@@ -356,6 +358,7 @@ int sdram_initialise(struct pei_data *pei_data)printf ("Nonzero MRC return value.\n" );return -EFAULT ; } +debug ("MRC execution time %lu ms\n" ,get_timer (start)); }else {printf ("UEFI PEI System Agent not found.\n" );return -ENOSYS ;
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH 8/9 x86: ivybridge: Measure the MRC code execution time
Quoted 26 lines · Simon Glass
This code takes about 450ms without the MRC cache and about 27ms with the cache. Add a debug timer so that this time can be displayed.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/ivybridge/sdram.c | 3 +++ 1 file changed, 3 insertions(+)arch/x86/cpu/ivybridge/sdram.c +2
-0@@ -336,9 +336,11 @@ int sdram_initialise(struct pei_data *pei_data)if (data) {int rv;int (*func)(struct pei_data *); +ulong start;debug ("Calling MRC at %p\n" , data);post_code (POST_PRE_MRC ); + start =get_timer (0 ); func = (int (*)(struct pei_data *))data; rv =func (pei_data);post_code (POST_MRC );
arch/x86/cpu/ivybridge/sdram.c int sdram_initialise(struct pei_data *pei_data)
Quoted 8 lines
arch/x86/cpu/ivybridge/sdram.c +1
-1@@ -356,6 +358,7 @@ int sdram_initialise(struct pei_data *pei_data)printf ("Nonzero MRC return value.\n" );return -EFAULT ; } +debug ("MRC execution time %lu ms\n" ,get_timer (start)); }else {printf ("UEFI PEI System Agent not found.\n" );return -ENOSYS ; --
PATCH 8/9 x86: ivybridge: Measure the MRC code execution time
Quoted 10 lines · Bin Meng
Quoted 9 lines · Simon Glass
This code takes about 450ms without the MRC cache and about 27ms with the cache. Add a debug timer so that this time can be displayed.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/ivybridge/sdram.c | 3 +++ 1 file changed, 3 insertions(+)
[snip]
Quoted 2 lines
Reviewed-by Bin Meng <[email protected]>
Applied to u-boot-x86.
PATCH 9/9 x86: ivybridge: Enable the MRC cache
In reply to Simon GlassFrom: Bin Meng <[email protected]>
This works correctly now, so enable it.
Dropped malloc() and adjusted commit message:
---
arch/x86/cpu/ivybridge/sdram.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
arch/x86/cpu/ivybridge/sdram.c +2 -8
@@ -158,14 +158,8 @@ static int prepare_mrc_cache(struct pei_data *pei_data)if (!mrc_cache)return -ENOENT ; -/* -* TODO(sjg at chromium.org): Skip this for now as it causes boot -* problems -*/ -if (0 ) { - pei_data->mrc_input = mrc_cache->data; - pei_data->mrc_input_len = mrc_cache->data_size; - } + pei_data->mrc_input = mrc_cache->data; + pei_data->mrc_input_len = mrc_cache->data_size;debug ("%s: at %p, size %x checksum %04x\n" , __func__, pei_data->mrc_input, pei_data->mrc_input_len, mrc_cache->checksum);
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH 9/9 x86: ivybridge: Enable the MRC cache
Quoted 25 lines · Simon Glass
From: Bin Meng <[email protected]>
This works correctly now, so enable it.
Signed-off-by Bin Meng <[email protected]>Dropped
malloc()and adjusted commit message:Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/ivybridge/sdram.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)arch/x86/cpu/ivybridge/sdram.c +0
-4@@ -158,14 +158,8 @@ static int prepare_mrc_cache(struct pei_data *pei_data)if (!mrc_cache)return -ENOENT ; -/* -* TODO(sjg at chromium.org): Skip this for now as it causes boot -* problems -*/
arch/x86/cpu/ivybridge/sdram.c static int prepare_mrc_cache(struct pei_data *pei_data)
Quoted 10 lines
arch/x86/cpu/ivybridge/sdram.c +2
-5-if (0 ) { - pei_data->mrc_input = mrc_cache->data; - pei_data->mrc_input_len = mrc_cache->data_size; - } + pei_data->mrc_input = mrc_cache->data; + pei_data->mrc_input_len = mrc_cache->data_size;debug ("%s: at %p, size %x checksum %04x\n" , __func__, pei_data->mrc_input, pei_data->mrc_input_len, mrc_cache->checksum); --
PATCH 9/9 x86: ivybridge: Enable the MRC cache
Quoted 14 lines · Bin Meng
Quoted 13 lines · Simon Glass
From: Bin Meng <[email protected]>
This works correctly now, so enable it.
Signed-off-by Bin Meng <[email protected]>Dropped
malloc()and adjusted commit message:Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/ivybridge/sdram.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
[snip]
Quoted 2 lines
Reviewed-by Bin Meng <[email protected]>
Applied to u-boot-x86.