Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3010061ybb; Sun, 5 Apr 2020 23:34:01 -0700 (PDT) X-Google-Smtp-Source: APiQypITlZcYPL6jePErt4h9eWWSt3li5+e/FOJ2bzc/Ps+AMh5NVVBo+/DLDmyqyQmcFF03h+aG X-Received: by 2002:a05:6808:288:: with SMTP id z8mr7269121oic.149.1586154841844; Sun, 05 Apr 2020 23:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586154841; cv=none; d=google.com; s=arc-20160816; b=rPT3NRaAjozhuLdDrXDQdGkxWjw2drRDxEEwtxXeP9Tt3ZzMHomJrIFt7LVOH67Vre +jJb88MGgOZ0Znm/yIxkM5dJ45cbPZqJQ8rtbOSXliRbOlU6v1vJzYA+qhY++ONgiZq1 zPcW+Ja7pK0gwAKzwLaODvtvGScpP4c6ZO0z83ET+9MXsGwz26SoDNjTuIAdtawLrrrE k2pmEGP2bgBWi1ZmHZrINcyCSExv+ZYzO10RyuI2WjwHztHgp6MVDU/muIBAkhtxWieV Sa42XzaAUIFZ8BuIOQbAuFKpOwU9CAWDvPm/z7fM6PJfqZvQkDSjikSvnFXce+gm+84t n6DA== 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=bi0hsjDx/X3bkHNzFG00xZZqnwIoir8HqMp/EzJq6MWQ73IoUJJ/vUt15QzQoiC3r+ wdx0lXrJSwNACNlo9XBqNV8iwd7jjnfx8Qrr5N5LpBYro3gH6V7qrwHDiExsiz8WZrU+ Hcuzb5KhIDhurajSdPeU5cmF00dDeIuFmgbkcjBBIXJqlTB8whROP7u2rEe3d91mCtKC 7040qNE4uQYjrxjcYx4Nb45js/WaZzTOpE7I1lWRxt+lz8V0xWa5xdGOF+O55dzH9cp2 iOFrdEW/QGlneE1XYlGFUoHpsj66ptlxmqIdMdJS2SBy3hg42WCITDN50gOeuAbbqFpp gtow== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=UCxacerh; 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 15si7128081oix.96.2020.04.05.23.33.49; Sun, 05 Apr 2020 23:34:01 -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=UCxacerh; 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 S1726632AbgDFGdG (ORCPT + 99 others); Mon, 6 Apr 2020 02:33:06 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:39882 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726621AbgDFGdF (ORCPT ); Mon, 6 Apr 2020 02:33:05 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1586154785; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=Z43BwKJL/HZB89s/V9T4Drpkuv9POZH784QrMkde+gg=; b=UCxacerh5+hGcXtPjEQlQwuXEQS7VpAlGMXBnNTw5G3ceBrYXY+5Sa5aVN7oLcqq9UUnYFKc qsGY7N16ioQvQxOoqPHiNpkp60O49twqGTT9gCOKsPd2sfWyAu/4lJpgKQwu+aRqiHobqDy1 2It1uOZsCxsz7AXeodrGzRezyr4= 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 5e8acd19.7feff22efc70-smtp-out-n02; Mon, 06 Apr 2020 06:32:57 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id AA75CC43637; Mon, 6 Apr 2020 06:32:57 +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 CEEEFC433D2; Mon, 6 Apr 2020 06:32:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org CEEEFC433D2 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 v16 3/6] soc: qcom: rpmh: Invalidate SLEEP and WAKE TCSes before flushing new data Date: Mon, 6 Apr 2020 12:02:18 +0530 Message-Id: <1586154741-8293-4-git-send-email-mkshah@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1586154741-8293-1-git-send-email-mkshah@codeaurora.org> References: <1586154741-8293-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