coreboot/src/include
Subrata Banik 36faccfec5 include/cpu/x86: Skip wbinvd on CPUs with cache self-snooping (SS)
This patch refers and backport some of previous work from Linux Kernel
(https://lore.kernel.org/all/1561689337-19390-3-git-send-email-ricardo.
neri-calderon@linux.intel.com/T/#u) that optimizes the MTRR register
programming in multi-processor systems by relying on the CPUID
(self-snoop feature supported).

Refer to the details below:

Programming MTRR registers in multi-processor systems is a rather
lengthy process as it involves flushing caches. As a result, the
process may take a considerable amount of time. Furthermore, all
processors must program these registers serially.

`wbinvd` instruction is used to invalidate the cache line to ensure
that all modified data is written back to memory. All logical processors
are stopped from executing until after the write-back and invalidate
operation is completed.

The amount of time or cycles for WBINVD to complete will vary due to the
size of different cache hierarchies and other factors. As a consequence,
the use of the WBINVD instruction can have an impact on response time.

As per measurements, around 98% of the time needed by the procedure to
program MTRRs in multi-processor systems is spent flushing caches with
wbinvd(). As per the Section 11.11.8 of the Intel 64 and IA 32
Architectures Software Developer's Manual, it is not necessary to flush
caches if the CPU supports cache self-snooping (ss).

"Flush all caches using the WBINVD instructions. Note on a processor
that supports self-snooping, CPUID feature flag bit 27, this step is
unnecessary."

Thus, skipping the cache flushes can reduce by several tens of
milliseconds the time needed to complete the programming of the MTRR
registers:

Platform                              Before	 After
  12-core (14 Threads) MeteorLake      35ms       1ms

BUG=b:260455826
TEST=Able to build and boot google/rex.

Change-Id: I83cac2b1e1707bbb1bc1bba82cf3073984e9768f
Signed-off-by: Subrata Banik <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/75511
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jérémy Compostella <jeremy.compostella@intel.com>
Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
Reviewed-by: Himanshu Sahdev <himanshu.sahdev@intel.com>
Reviewed-by: Tarun Tuli <taruntuli@google.com>
2023-06-01 07:52:12 +00:00
..
acpi acpi/acpigen: rename and clarify bus/IO/MMIO resource producer functions 2023-05-30 16:05:35 +00:00
boot lib/coreboot_table: Rename lb_fill_pcie 2022-11-04 19:17:49 +00:00
console console: Add format-checking __printf() to die() 2023-05-17 11:23:59 +00:00
cpu include/cpu/x86: Skip wbinvd on CPUs with cache self-snooping (SS) 2023-06-01 07:52:12 +00:00
device treewide: Remove 'extern' from functions declaration 2023-05-26 13:45:24 +00:00
efi include/efi: Add EFI Status code definitions 2022-03-25 19:26:28 +00:00
mipi drivers/soundwire/cs42l42: Support CS42L42 SoundWire device 2023-05-25 21:22:32 +00:00
pc80 drivers/pc80/rtc/mc146818rtc.c: Add Kconfig for RTC CMOS base addresses 2023-05-08 17:51:08 +00:00
smp include: Add SPDX-License-Identifiers to files missing them 2022-08-01 13:59:11 +00:00
superio src/include: Add PnP/HWM unset_and_set functions 2020-09-18 12:06:38 +00:00
sys include: Add SPDX-License-Identifiers to files missing them 2022-08-01 13:59:11 +00:00
adainit.h Add option to use Ada code in romstage 2022-12-17 20:48:06 +00:00
asan.h include: Add SPDX-License-Identifiers to files missing them 2022-08-01 13:59:11 +00:00
assert.h treewide: Remove 'extern' from functions declaration 2023-05-26 13:45:24 +00:00
b64_decode.h
base3.h treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
boardid.h treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
boot_device.h cbfs: Move more stuff into cbfs_boot_lookup() 2020-12-02 22:13:06 +00:00
bootblock_common.h decompressor: Add CBFS_VERIFICATION support 2021-04-06 07:49:15 +00:00
bootmem.h lib: set up specific purpose memory as LB_MEM_SOFT_RESERVED 2023-03-03 11:10:38 +00:00
bootmode.h mb/google,samsung: Drop init_bootmode_straps() 2022-04-09 02:50:01 +00:00
bootsplash.h drivers/intel/fsp1_1,fsp2_0: Refactor logo display 2021-02-09 07:52:31 +00:00
bootstate.h include/bootstate.h: Fail compilation on invalid bootstate hooks 2023-02-04 01:42:31 +00:00
cbfs.h commonlib/bsd: Remove cb_err_t 2022-03-09 02:18:21 +00:00
cbfs_glue.h vboot: Add VBOOT_CBFS_INTEGRATION support 2022-11-08 23:03:49 +00:00
cbmem.h cbmem_top_chipset: Change the return value to uintptr_t 2022-11-18 16:00:45 +00:00
cper.h include/cper.h: Add CPER Memory Error Section definitions 2022-12-09 03:46:33 +00:00
crc_byte.h src/include: Add missing includes 2020-07-26 21:37:35 +00:00
ctype.h include: Add SPDX-License-Identifiers to files missing them 2022-08-01 13:59:11 +00:00
delay.h include: Add SPDX-License-Identifiers to files missing them 2022-08-01 13:59:11 +00:00
device_tree.h tree: Drop repeated words 2023-02-07 04:37:31 +00:00
dimm_info_util.h arch/x86: Refactor the SMBIOS type 17 write function 2021-11-11 09:10:10 +00:00
dp_aux.h google/trogdor: Add backlight support for Parade ps8640 2021-11-02 08:17:21 +00:00
edid.h include/edid.h: Remove repeated word 2021-01-18 07:37:04 +00:00
elog.h treewide: Remove 'extern' from functions declaration 2023-05-26 13:45:24 +00:00
endian.h
espi.h include/espi.h: Switch to types.h 2022-03-27 15:13:31 +00:00
fallback.h include: Add SPDX-License-Identifiers to files missing them 2022-08-01 13:59:11 +00:00
fit.h
fmap.h src/include: Add missing includes 2020-07-26 21:37:35 +00:00
framebuffer_info.h src: Remove unused <stdbool> 2022-01-19 15:15:50 +00:00
fw_config.h lib: add stub for fw_config_get_field 2022-12-24 05:50:00 +00:00
gpio.h soc/intel/common/gpio: Add function to read GPIO TX value 2023-01-25 14:33:06 +00:00
halt.h treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
identity.h lib/version: Move board identification strings 2023-04-22 16:20:49 +00:00
imd.h include/imd: Improve API documentation 2020-08-26 07:32:37 +00:00
imd_private.h include: Add SPDX-License-Identifiers to files missing them 2022-08-01 13:59:11 +00:00
input-event-codes.h src/include: Drop unneeded empty lines 2020-09-14 07:09:41 +00:00
inttypes.h treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
ip_checksum.h include: Add SPDX-License-Identifiers to files missing them 2022-08-01 13:59:11 +00:00
kconfig.h
lib.h lib: Add __fls() (Find Last Set) 2021-12-13 02:57:07 +00:00
limits.h include: Add SPDX-License-Identifiers to files missing them 2022-08-01 13:59:11 +00:00
list.h lib/list: Add list_append 2021-11-03 08:29:16 +00:00
main_decl.h include: Add SPDX-License-Identifiers to files missing them 2022-08-01 13:59:11 +00:00
memlayout.h treewide: stop calling custom TPM log "TCPA" 2023-01-11 16:00:55 +00:00
memory_info.h include/memory_info.h: Add soc_num to dimm_info struct 2023-01-08 01:33:23 +00:00
memrange.h include/memrange.h: Remove trailing semicolon 2022-09-28 16:12:04 +00:00
metadata_hash.h src: Drop "This file is part of the coreboot project" lines 2021-05-10 15:07:33 +00:00
mrc_cache.h mrc_cache: Change mrc_cache_load_current to return size of entry 2020-10-09 05:38:04 +00:00
nhlt.h lib/nhlt, soc/intel/skl: Update NHLT to program feedback config 2022-12-21 13:57:48 +00:00
option.h option: Turn CMOS option backend into choice 2021-05-28 11:37:16 +00:00
post.h treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
program_loading.h lib/program_loaders.c: Mark run_ramstage with __noreturn 2022-07-14 23:10:17 +00:00
ramdetect.h src/include/ramdetect.h: Add missing includes 2020-07-25 01:25:57 +00:00
random.h arch/x86: Use 'enum cb_err' 2022-12-25 15:09:16 +00:00
reg_script.h include/reg_script.h: Remove trailing semicolon 2022-09-28 16:12:24 +00:00
region_file.h region_file_update_data_arr: Modify region_file with array of buffers 2020-09-16 16:02:54 +00:00
reset.h include: Add SPDX-License-Identifiers to files missing them 2022-08-01 13:59:11 +00:00
rmodule.h treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
romstage_common.h arch/x86: Add a common romstage entry 2022-06-07 12:54:39 +00:00
romstage_handoff.h treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
rtc.h lib/rtc: Add sanity check for time and date 2021-05-30 20:24:13 +00:00
rules.h console: Print architecture 2023-01-31 15:26:16 +00:00
sar.h vc/google/chromeos: use fw_config field to return sar filename 2022-12-24 05:50:13 +00:00
sdram_mode.h treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
smbios.h arch/x86/smbios: Replace SMBIOS type4 processor upgrade fields 2023-01-08 01:27:14 +00:00
smmstore.h drivers/smmstore: Expose region device 2023-02-12 08:20:08 +00:00
spd.h spd.h: Move enum ddr3_module_type to ddr3.h 2023-01-04 12:39:32 +00:00
spd_bin.h lib: Add LPDDR5x DRAM type 2022-11-07 02:29:23 +00:00
spd_cache.h src/lib: Add Kconfig option for SPD cache in FMAP 2020-12-14 08:23:41 +00:00
spi-generic.h drivers/spi/spi-generic: document SPI_CNTRLR_DEDUCT_CMD_LEN better 2021-12-15 22:39:21 +00:00
spi_bitbang.h treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
spi_flash.h drivers: spi_flash: Add Fast Read Dual I/O support 2021-07-15 14:05:34 +00:00
spi_sdcard.h src/include: Add missing includes 2020-07-26 21:37:35 +00:00
stage_cache.h stage_cache: Add resume_from_stage_cache() 2021-01-29 10:53:33 +00:00
stdarg.h
stdbool.h src/include: Remove unused 'include <stdint.h>' 2020-07-26 20:59:16 +00:00
stddef.h include: Add SPDX-License-Identifiers to files missing them 2022-08-01 13:59:11 +00:00
stdint.h treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
stdio.h
stdlib.h include: Add SPDX-License-Identifiers to files missing them 2022-08-01 13:59:11 +00:00
string.h treewide: Add 'IWYU pragma: export' comment 2022-11-03 13:05:17 +00:00
swab.h include: Add SPDX-License-Identifiers to files missing them 2022-08-01 13:59:11 +00:00
symbols.h treewide: stop calling custom TPM log "TCPA" 2023-01-11 16:00:55 +00:00
thread.h rules.h: Use more consistent naming 2022-05-16 21:52:22 +00:00
timer.h timer: Change timer util functions to 64-bit 2022-09-14 11:55:39 +00:00
timestamp.h timestamp: Allow timestamp_add to accept a negative number 2022-01-21 22:42:19 +00:00
types.h treewide: Add 'IWYU pragma: export' comment 2022-11-03 13:05:17 +00:00
uuid.h include/uuid.h: Add missing include 2020-05-28 16:20:40 +00:00
vbe.h include: Add SPDX-License-Identifiers to files missing them 2022-08-01 13:59:11 +00:00
version.h lib/version: Move board identification strings 2023-04-22 16:20:49 +00:00
watchdog.h include: Add SPDX-License-Identifiers to files missing them 2022-08-01 13:59:11 +00:00
wrdd.h treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
xxhash.h lib/xxhash.c: Add new hash functions 2022-09-07 22:24:51 +00:00