From 1d8568c91413c76ee147bf6c09ae87197f7e75d7 Mon Sep 17 00:00:00 2001 From: Bernardo Perez Priego Date: Tue, 14 Jan 2020 15:59:19 -0800 Subject: [PATCH] ec/google/wilco: Set minimum UCSI_ACPI region length IMD provides support for small and large allocations. Region IMD Small memory is 1 KB with 32 Bytes alignment, this region holds smaller entries without having to reserve a whole 4 KB page. Remaining space is assigned to IMD Large to hold various regions with 4 KB alignment. The UCSI kernel (kernel version 4.19) driver maps the UCSI_ACPI memory as not cached. Cache mapping is set on page boundaries and all IMD Small is within the same page. If another driver maps the memory as write-back before the UCSI driver is loaded then the UCSI driver will fail to map the memory as not cached. Placing UCSI_ACPI in IMD Large region will prevent this mapping issue since it will now be located within its own page. This patch will force UCSI_ACPI region to be located in IMD Large region. BUG=b:144826008 Signed-off-by: Bernardo Perez Priego Change-Id: Id00e76dca240279773a95c8054831e05df390664 Reviewed-on: https://review.coreboot.org/c/coreboot/+/38414 Reviewed-by: Duncan Laurie Reviewed-by: Mathew King Tested-by: build bot (Jenkins) --- src/ec/google/wilco/chip.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ec/google/wilco/chip.c b/src/ec/google/wilco/chip.c index 70e612442c..b44cbd6c64 100644 --- a/src/ec/google/wilco/chip.c +++ b/src/ec/google/wilco/chip.c @@ -27,6 +27,11 @@ #include "ec.h" #include "chip.h" +/* + * Setting minimum length of UCSI_ACPI will ensure this region is placed out of IMD Small. + * Having this region out of IMD Small will prevent any memory mapping conflicts. + */ +#define UCSI_MIN_ALLOC_REGION_LEN CBMEM_SM_ROOT_SIZE /* * The UCSI fields are defined in the UCSI specification at * https://www.intel.com/content/www/us/en/io/universal-serial-bus/usb-type-c-ucsi-spec.html @@ -175,19 +180,22 @@ static void wilco_ec_fill_ssdt_generator(struct device *dev) { struct opregion opreg; void *region_ptr; + size_t ucsi_alloc_region_len; if (!dev->enabled) return; - region_ptr = cbmem_add(CBMEM_ID_ACPI_UCSI, ucsi_region_len); + ucsi_alloc_region_len = ucsi_region_len < UCSI_MIN_ALLOC_REGION_LEN ? + UCSI_MIN_ALLOC_REGION_LEN : ucsi_region_len; + region_ptr = cbmem_add(CBMEM_ID_ACPI_UCSI, ucsi_alloc_region_len); if (!region_ptr) return; - memset(region_ptr, 0, ucsi_region_len); + memset(region_ptr, 0, ucsi_alloc_region_len); opreg.name = "UCSM"; opreg.regionspace = SYSTEMMEMORY; opreg.regionoffset = (uintptr_t)region_ptr; - opreg.regionlen = ucsi_region_len; + opreg.regionlen = ucsi_alloc_region_len; acpigen_write_scope(acpi_device_path_join(dev, "UCSI")); acpigen_write_name("_CRS");