From ac290b4993104acee0955b69002e58aee8653aa5 Mon Sep 17 00:00:00 2001 From: Lina Iyer Date: Tue, 16 Jun 2020 17:39:48 -0600 Subject: [PATCH] drivers: qcom: rpmh: caching batch requests should flag the cache dirty The sleep/wake state batch requests are saved in a linked list and flushed along with other sleep/wake request when entering system low power modes. Caches are flushed only if the state flag is marked dirty. A race situation could cause the batch sleep/wake requests to not be flushed. Here is how this could happen - - Interconnect driver (ICC) invalidates the sleep/wake requests - RSC driver clears the TCSes (BCM, VRM, ARC sleep votes cleared) - ICC sends an active state response-required request - RSC driver sends the AMC request - RPMH waits on the response, calls wait_for_completion - Scheduler schedules idle thread - cpuidle enters cluster idle state - RPMH flushes cache and marks cache clean (no BCM votes in TCS) - RSC driver receives IRQ response - RPMH calls complete() - ICC worker thread resumes execution - ICC driver calls RPMH driver with updated sleep and wake votes - RPMH caches the request, *cache is NOT marked dirty* - Scheduler schedules idle thread - cpuidle enters cluster idle state - Cache is clean and nothing to flush - CPU enters idle =>ICC sleep/wake votes are not sent Fix this by dirtying the cache state even when caching batch requests. Change-Id: I7613e665d181f8abb27915d622442e7b981f9fcc Signed-off-by: Lina Iyer --- drivers/soc/qcom/rpmh.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index 671486d937aa..946145c3f292 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -350,6 +350,7 @@ static void cache_batch(struct rpmh_ctrlr *ctrlr, struct batch_cache_req *req) spin_lock_irqsave(&ctrlr->cache_lock, flags); list_add_tail(&req->list, &ctrlr->batch_cache); + ctrlr->dirty = true; spin_unlock_irqrestore(&ctrlr->cache_lock, flags); }