summaryrefslogtreecommitdiff
path: root/payloads/libpayload/drivers
diff options
context:
space:
mode:
authorHsin-Te Yuan <yuanhsinte@google.com>2022-08-09 15:00:55 +0800
committerMartin Roth <martin.roth@amd.corp-partner.google.com>2022-09-01 14:21:11 +0000
commitcb28d649eab01a43eb28b95ac69631c4261ccfae (patch)
tree47e50bc095223d64eadf852fe317c1312f4d9a17 /payloads/libpayload/drivers
parent412222ae75d1743a78d2b745754431a558f31be8 (diff)
x86/cache.c: Implement dcache_*
A new ChromeOS automated test will be introduced to check the cbmem log of diagnostic boot mode. Because the diagnostic boot does not allow booting into kernel, the test must perform AP reset and then check the cbmem log afterwards. However, the memory content might not be written back to memory (from CPU cache) during AP reset because of the cache snooping mechanism on x86. Hence, some API to flush cache is needed. Implement dcache_* to allow flushing cache proactively in x86. To avoid unnecessary flush, check dma_coherent before calling dcache_* functions, which will be always true in x86. Therefore, this change won't affect the original functionality. BUG=b:190026346 TEST=FW_NAME=primus emerge-brya libpayload Cq-Depend: chromium:3841252 Signed-off-by: Hsin-Te Yuan <yuanhsinte@google.com> Change-Id: I622d8b1cc652cbe477954a900885d12e6494d94d Reviewed-on: https://review.coreboot.org/c/coreboot/+/66578 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Diffstat (limited to 'payloads/libpayload/drivers')
-rw-r--r--payloads/libpayload/drivers/udc/chipidea.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/payloads/libpayload/drivers/udc/chipidea.c b/payloads/libpayload/drivers/udc/chipidea.c
index 3df7d2409c..54c0ca9f2e 100644
--- a/payloads/libpayload/drivers/udc/chipidea.c
+++ b/payloads/libpayload/drivers/udc/chipidea.c
@@ -221,10 +221,10 @@ static void advance_endpoint(struct chipidea_pdata *p, int endpoint, int in_dir)
job->tds = tds;
job->td_count = td_count;
-
dcache_clean_by_mva(tds, sizeof(struct td) * td_count);
- dcache_clean_by_mva(job->data, job->length);
dcache_clean_by_mva(qh, sizeof(*qh));
+ if (!dma_coherent(job->data))
+ dcache_clean_by_mva(job->data, job->length);
debug("priming EP %d-%d with %zx bytes starting at %x (%p)\n", endpoint,
in_dir, job->length, tds[0].page0, job->data);
@@ -240,7 +240,7 @@ static void handle_endpoint(struct usbdev_ctrl *this, int endpoint, int in_dir)
struct job *job = SIMPLEQ_FIRST(&p->job_queue[endpoint][in_dir]);
SIMPLEQ_REMOVE_HEAD(&p->job_queue[endpoint][in_dir], queue);
- if (in_dir)
+ if (in_dir && !dma_coherent(job->data))
dcache_invalidate_by_mva(job->data, job->length);
int length = job->length;