Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp2163118pja; Thu, 26 Mar 2020 10:40:04 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsNcvwqqxWXd0z1srZ7wYt826/3O7n0drxzYwaajviORy3KCEUb+0g/ORtcEi1ixeLnQ5jS X-Received: by 2002:a9d:5a09:: with SMTP id v9mr6817580oth.214.1585244404084; Thu, 26 Mar 2020 10:40:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585244404; cv=none; d=google.com; s=arc-20160816; b=ufvte84xtLu97upKtqeRU4C1KmzrDAAiWqLyLKX5OM6YiOIwJ9bbCdBklZbu62BowG d3zFeS4eZ5I1JsoKHS/JEu+tGBiRPSi2sJZ50LC6GWAQCiYcUhytTvDMQdMPHgZzigwD pBiGb6e3XULudlCtbjYor8ZBKiLew1F9qMEgcj1n1U5l0ebkZ1INRbVBvb+rE0IGL6J9 OP7Q0r0IoLwydNSp8SERDw0Lnv9ExPvpzwKfflX/TNDZUzIgJZ8GlOszVoOLNJa8+NIc Zj5CSnY5fyHA2lxgy51hAQhZsizUqG6sgZEmbXi7ISruAjIaxcd7c8ojr+sV0v6Ks8MX lyHw== 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=/D/aa61SSrTgUugEvHhrOY8jgWtuncxu+n39vgr9cq8=; b=miMIEeYR7tfXHdW6gGtTSlNf2Su+h954xjGjxLlMDysChzr/FOTL5g3QchHe6+OZ/C PIYXrOhp2Iyi6/4v04O38geNlBkjVq8CAoauXTvBRqizPfNybNFpIlYMf4WZsSMtGESD O1E8E7kmjdn5iQ7V59iJsf7y7EpRlKJOH13oxEC7I6lhP/pId1xCajQ9QMF5TItQ2vxY JNxpfORyePESy6Rhxfmdq0m6amnTyFXIhLr1QZSpTV+YUBCc383GXg+8ZxqQJKUkXTBR HANZuNslbXBjGXvDxOjiO0Brr1b8jAfBALLmmZ2HhVMICS7AxtPBHLqAEl+c+Do88tpy Yw5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b="qIrA5j/0"; 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 i204si1251547oif.245.2020.03.26.10.39.50; Thu, 26 Mar 2020 10:40:04 -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="qIrA5j/0"; 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 S1728543AbgCZRi2 (ORCPT + 99 others); Thu, 26 Mar 2020 13:38:28 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:47699 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727889AbgCZRi2 (ORCPT ); Thu, 26 Mar 2020 13:38:28 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1585244307; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=/D/aa61SSrTgUugEvHhrOY8jgWtuncxu+n39vgr9cq8=; b=qIrA5j/03ipb1cMxIoozXXINUR8XTWJDKHyYjn7zuXo2oq3LKj7elKm0oc/34uFIQJB0QVqa eqDek9oRgQC62xnMTI99+COZnyS1FpiHGjnqXvtViimKCu/JK4qQwmZxsCtO0WKlJFsyXXIW a6zF5gaO8qFzcjR4WDq7kLn2Iu4= X-Mailgun-Sending-Ip: 104.130.122.26 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 5e7ce893.7f9b5006b068-smtp-out-n03; Thu, 26 Mar 2020 17:38:27 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 2CECEC44791; Thu, 26 Mar 2020 17:38:27 +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, URIBL_BLOCKED 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 7EADFC4478C; Thu, 26 Mar 2020 17:38:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7EADFC4478C 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 v14 3/6] soc: qcom: rpmh: Invalidate SLEEP and WAKE TCSes before flushing new data Date: Thu, 26 Mar 2020 23:07:47 +0530 Message-Id: <1585244270-637-4-git-send-email-mkshah@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1585244270-637-1-git-send-email-mkshah@codeaurora.org> References: <1585244270-637-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 --- 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..5147d82 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 active 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