Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2513549ybb; Sun, 12 Apr 2020 07:51:58 -0700 (PDT) X-Google-Smtp-Source: APiQypIHEDISo1Dc1VwiRmJhI4olH3djUHh5Nzr2oBagLX3JMWcp+tw6+NADH/I57xGvJPYNivzj X-Received: by 2002:aed:3445:: with SMTP id w63mr7405924qtd.183.1586703118506; Sun, 12 Apr 2020 07:51:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586703118; cv=none; d=google.com; s=arc-20160816; b=0+4WXrxsQOcoxZVTJGWo3hJvQfGJd5DdFKNCEHwtxCaPeO/Mt4KYMnEIVjuE0OSTl8 dGVs1gkJN9N4c4bvLIISn03Vm71n7J8R5OBUy2nix+FhU5m+0T2d2f2fR5M+fWA1SfYW kUJ+DeJkWIldhk9aIuHkTHZP+OHEt70x+IAve/bv3zKSeisQSlaW3177sMiwa1YZ+FuK BU1pswd4VLCcYBVE427xsRZNqexdifbA4V0fnd5eQZnIC4QF8pO6d2zS5MAGNXYFzlcm 8bhZNm7L8Yx+ZgHrBkX1g2CXukYV1N5qLQ/XCni4y5nxf2msBEOGZ9Ep3zo3TQfA3k3F ZAgw== 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=4ZgYKqHdQMfT+w3htPCV8Q0a/mPEaMPWrEE+lfEDMDY=; b=cdYtQj6ZPPG1G67GxiK5GQ/OddrzMjt77Y/Z16UhN4yb+3Hg2R+JnYOkh0xKZHfZ54 sjaR1iImFbtkSBkVdJLRa3oWLdgrrxvaeR9cZtlLUTwKydeyC6Ksm/1Uwl1Ev+9snXbx TcKfc4OWgqbQzfhvogzseQja+EPEWO4u69xzQqIzWCtTtMk5uq43NGBUUNOuw3E9padc 5WgqhB3w9Kn/svDI7h14BpOrbsm5NXb0l+HZG5gDWacuU3Uf/Fr77jJaPL4k1S1m7Yt9 JcdlICrAClUzdsl7yFMslGCKuijvWs4LkSjJC4Xa4isQpMWqxzz036Ume4PTGIJR5MVp VmEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b="mscA8PG/"; 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 i22si4154520qtp.390.2020.04.12.07.51.44; Sun, 12 Apr 2020 07:51:58 -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="mscA8PG/"; 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 S1727107AbgDLOun (ORCPT + 99 others); Sun, 12 Apr 2020 10:50:43 -0400 Received: from mail27.static.mailgun.info ([104.130.122.27]:13094 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbgDLOun (ORCPT ); Sun, 12 Apr 2020 10:50:43 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1586703043; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=4ZgYKqHdQMfT+w3htPCV8Q0a/mPEaMPWrEE+lfEDMDY=; b=mscA8PG/jOviYifIppky24y4/OSUjq990Dk8rh2GZ3n5jc39xTGOQsrqapQsRafgXKWdTaAw YKZ9Ci0F8bEpMq636idtsAXfiLRETqixEJvfrWcslmtTBQI/5XP3WR65lY81Lv2QO3n+IUQK 8zDSDj5K5E0ORythKNrHA1XV3RY= 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 5e932abd.7f540702d340-smtp-out-n04; Sun, 12 Apr 2020 14:50:37 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 08C73C433BA; Sun, 12 Apr 2020 14:50: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 E4AEDC43636; Sun, 12 Apr 2020 14:50:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E4AEDC43636 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 v17 3/6] soc: qcom: rpmh: Invalidate SLEEP and WAKE TCSes before flushing new data Date: Sun, 12 Apr 2020 20:20:01 +0530 Message-Id: <1586703004-13674-4-git-send-email-mkshah@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1586703004-13674-1-git-send-email-mkshah@codeaurora.org> References: <1586703004-13674-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