Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3489621ybb; Tue, 31 Mar 2020 06:22:25 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuHl8g739J21L2O/Sfqs30Bffdhf+fNXqHBjSSNBh8JkEicGD5sNRgoyVLerefHcommwRNi X-Received: by 2002:aca:d64f:: with SMTP id n76mr1962514oig.48.1585660945311; Tue, 31 Mar 2020 06:22:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585660945; cv=none; d=google.com; s=arc-20160816; b=nj+0awBo91IqKYEd8OfOqHwW1G4zqrYieTPxS8g3BI04o0bJg0kI8B3yKH9ekCvlpG TmhMJtcCVPmoLtlbwWjBsxBWM1aECSIEQ73moT/S44FzZx9bFk3+7YB/hP0uxFfDj90j H+pwL7vzjo4J/9D3eRzRcApJmOZ7O4/2Pa96e2W8lEKyYsPR3gHh46P4yY1fKTcLO71b YiiBC0pDMjtGA2Nz1h4ypxJ+/fz8G2DUttPAFzARnzNnGib8g75bLkGDFW5QOFIjW7YF vLTps8nnwROWrtHxXpH1R6L0WXYhfcLfR+Nx8WW3ceK0e+3BW3ls6twgKPB6y+WvadOS uiIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature; bh=Z43BwKJL/HZB89s/V9T4Drpkuv9POZH784QrMkde+gg=; b=aZ4xMlPtMeIxqddnm1EqouP1QS2GrwD5fz6ga/N6fOgDe+N4HnSWhLDT6bqoZbgsaD 7Bv1Tb0BFAg6D9Pcz9Mahl4GracbyEwecuLjYWf1uejXI4O91c6vz/w03ajxfxVKo1oJ 49GGygVDf5Qsuw/NE5ebaXcDHJVA4rFBzeFF+A9MaIgGOfY6tJ8MyY9z3NKHc2iBEYQN gDxwpInsXjM4csqC5hWmE5ixu1OEnHlZPgG6d2r9eTvXhVpndWWE3pndpM+tT3sI7wB7 +61BJp9UgtPRUF3Kei89eJ6wLyzFlHUHQc0NYzPkRYUeHQrdpfjMlMv4iz3JgTLCTJpL AycA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=vGofDl1T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b22si8006034ooe.7.2020.03.31.06.22.12; Tue, 31 Mar 2020 06:22:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=vGofDl1T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730860AbgCaNUn (ORCPT + 99 others); Tue, 31 Mar 2020 09:20:43 -0400 Received: from mail27.static.mailgun.info ([104.130.122.27]:30788 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730464AbgCaNUn (ORCPT ); Tue, 31 Mar 2020 09:20:43 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1585660842; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=Z43BwKJL/HZB89s/V9T4Drpkuv9POZH784QrMkde+gg=; b=vGofDl1TAUOCQOfiaPu0HtALvkbGGO9l1/yiUeJhzHScHa+Ctdq4nAbKqEAID7Y5Z2qGadDi VFQku4pC9l9eFtue/DYca1iCF+67yDzOTpfXlEISjRq0ZMn/osHaPjV+d45t6WXyzGpaVMFu dcRey/E7R3A5aOVEh6HBIaE29yo= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e8343a4.7f335100e570-smtp-out-n04; Tue, 31 Mar 2020 13:20:36 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 82A76C43636; Tue, 31 Mar 2020 13:20:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mkshah-linux.qualcomm.com (blr-c-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mkshah) by smtp.codeaurora.org (Postfix) with ESMTPSA id 74476C43637; Tue, 31 Mar 2020 13:20:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 74476C43637 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=mkshah@codeaurora.org From: Maulik Shah To: swboyd@chromium.org, evgreen@chromium.org, dianders@chromium.org, bjorn.andersson@linaro.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, agross@kernel.org, mka@chromium.org, rnayak@codeaurora.org, ilina@codeaurora.org, lsrao@codeaurora.org, Maulik Shah Subject: [PATCH v15 3/7] soc: qcom: rpmh: Invalidate SLEEP and WAKE TCSes before flushing new data Date: Tue, 31 Mar 2020 18:49:38 +0530 Message-Id: <1585660782-23416-4-git-send-email-mkshah@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1585660782-23416-1-git-send-email-mkshah@codeaurora.org> References: <1585660782-23416-1-git-send-email-mkshah@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org TCSes have previously programmed data when rpmh_flush is called. This can cause old data to trigger along with newly flushed. Fix this by cleaning SLEEP and WAKE TCSes before new data is flushed. With this there is no need to invoke rpmh_rsc_invalidate() call from rpmh_invalidate(). Simplify rpmh_invalidate() by moving invalidate_batch() inside. Fixes: 600513dfeef3 ("drivers: qcom: rpmh: cache sleep/wake state requests") Signed-off-by: Maulik Shah Reviewed-by: Douglas Anderson --- drivers/soc/qcom/rpmh.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index 03630ae..a75f3df 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -317,19 +317,6 @@ static int flush_batch(struct rpmh_ctrlr *ctrlr) return ret; } -static void invalidate_batch(struct rpmh_ctrlr *ctrlr) -{ - struct batch_cache_req *req, *tmp; - unsigned long flags; - - spin_lock_irqsave(&ctrlr->cache_lock, flags); - list_for_each_entry_safe(req, tmp, &ctrlr->batch_cache, list) - kfree(req); - INIT_LIST_HEAD(&ctrlr->batch_cache); - ctrlr->dirty = true; - spin_unlock_irqrestore(&ctrlr->cache_lock, flags); -} - /** * rpmh_write_batch: Write multiple sets of RPMH commands and wait for the * batch to finish. @@ -467,6 +454,13 @@ int rpmh_flush(struct rpmh_ctrlr *ctrlr) return 0; } + /* Invalidate the TCSes first to avoid stale data */ + do { + ret = rpmh_rsc_invalidate(ctrlr_to_drv(ctrlr)); + } while (ret == -EAGAIN); + if (ret) + return ret; + /* First flush the cached batch requests */ ret = flush_batch(ctrlr); if (ret) @@ -498,24 +492,25 @@ int rpmh_flush(struct rpmh_ctrlr *ctrlr) } /** - * rpmh_invalidate: Invalidate all sleep and active sets - * sets. + * rpmh_invalidate: Invalidate sleep and wake sets in batch_cache * * @dev: The device making the request * - * Invalidate the sleep and active values in the TCS blocks. + * Invalidate the sleep and wake values in batch_cache. */ int rpmh_invalidate(const struct device *dev) { struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev); - int ret; - - invalidate_batch(ctrlr); + struct batch_cache_req *req, *tmp; + unsigned long flags; - do { - ret = rpmh_rsc_invalidate(ctrlr_to_drv(ctrlr)); - } while (ret == -EAGAIN); + spin_lock_irqsave(&ctrlr->cache_lock, flags); + list_for_each_entry_safe(req, tmp, &ctrlr->batch_cache, list) + kfree(req); + INIT_LIST_HEAD(&ctrlr->batch_cache); + ctrlr->dirty = true; + spin_unlock_irqrestore(&ctrlr->cache_lock, flags); - return ret; + return 0; } EXPORT_SYMBOL(rpmh_invalidate); -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation