Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3374958ybf; Tue, 3 Mar 2020 04:58:09 -0800 (PST) X-Google-Smtp-Source: ADFU+vsyXy/01NpAF5UVQHAWBS7a8Ltls70YuOgiiISiDuxHwA5CgeLULZtAbll/ovD2yRSIXusa X-Received: by 2002:a54:478a:: with SMTP id o10mr2327385oic.45.1583240289630; Tue, 03 Mar 2020 04:58:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583240289; cv=none; d=google.com; s=arc-20160816; b=Nrwj9xv1lOsuOyYV20Jtvb35uQAIdVQnE+YDh7nNMPTzDplwKf/XeBdEgpa/2iKYCN DOa8S5ZQHSuritvDeUZgG08vDe5kJ1eME0pACN3vcAaPnIXdCbEhqvYq9NZWq/MbR4E5 Tj/a29suekHpgh8t0D14l9UzE9OMEgxclK0rRhddCfn7mE7WXdtUuabQxMPpqF746QRa FGnJoTZTmwRol0CsohvSgsZ1Au8X9QNingQgXmn5ILu5CufHbnjTqCKI1g5DSg+aOa6v SIMHPMqFIRs+kXwjPxwJjKWMHfjf0F4zKC0sNuEt1w/sEpfEzqQxHletC5MPLP1COihB ccDg== 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=cA2LLkxEX4uYV2XzgslkgOWAvlesm1tq5fiZiVIroSc=; b=0rnQcwGRockgliu7RPxYVrLCojsuy929RmWz3FZ5Kq4aJjuVXLLRNdKM1RhpAYOQs/ rRELB/3eS7j4mVVgUL9Nt7ThR7cjH6jnI1ZHzjepPrItZzJQzfZPHsr6ZgwZT6HIWynr bpTV2LSX39mcM828ecisjNom90HMPU9kYWhaNjt3LkDPTqTXvbUUQwK7FSElRvE5LP3N UZlHoV1lqakq+q/hsgQs1qL61e5CBjDegx5+6Cy4gJLgG5CqkJ2P90Dd5TSFpG0sLV+Q O2nh7Abf8g2nYHXTfrNlXOImDQcH5CjXv6+hWsUKi6xKSCGSeZ9MWaAt2AjgD8TlfPyf R+VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=klYGwIfB; 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 c140si2057748oib.195.2020.03.03.04.57.57; Tue, 03 Mar 2020 04:58:09 -0800 (PST) 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=klYGwIfB; 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 S1729277AbgCCM1g (ORCPT + 99 others); Tue, 3 Mar 2020 07:27:36 -0500 Received: from mail26.static.mailgun.info ([104.130.122.26]:51056 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729263AbgCCM1g (ORCPT ); Tue, 3 Mar 2020 07:27:36 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1583238454; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=cA2LLkxEX4uYV2XzgslkgOWAvlesm1tq5fiZiVIroSc=; b=klYGwIfBAdwfip95SNHU/W7T2MyMM9Yxpa9hbBpd0bbPQzv+jwLrMDTnzu3ssBb67F0KyXB5 0p65D+tFh0kkQ0X2+cOonnXVTJEmxYiXqdD3wPAQGjs0XbU82DiNIVRa8mQL/DYjZ6vS2Z4z nNX1Voywnr9uy7fu4GVBo4aMBO0= 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 5e5e4d24.7f54d1701d88-smtp-out-n01; Tue, 03 Mar 2020 12:27:16 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 2C005C4479F; Tue, 3 Mar 2020 12:27:16 +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 C937DC4479C; Tue, 3 Mar 2020 12:27:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C937DC4479C 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, mka@chromium.org, evgreen@chromium.org, bjorn.andersson@linaro.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, agross@kernel.org, dianders@chromium.org, rnayak@codeaurora.org, ilina@codeaurora.org, lsrao@codeaurora.org, Maulik Shah Subject: [PATCH v10 3/3] soc: qcom: rpmh: Invoke rpmh_flush() for dirty caches Date: Tue, 3 Mar 2020 17:56:55 +0530 Message-Id: <1583238415-18686-4-git-send-email-mkshah@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1583238415-18686-1-git-send-email-mkshah@codeaurora.org> References: <1583238415-18686-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 Add changes to invoke rpmh flush() from within cache_lock when the data in cache is dirty. This is done only if OSI is not supported in PSCI. If OSI is supported rpmh_flush can get invoked when the last cpu going to power collapse deepest low power mode. Also remove "depends on COMPILE_TEST" for Kconfig option QCOM_RPMH so the driver is only compiled for arm64 which supports psci_has_osi_support() API. Signed-off-by: Maulik Shah Reviewed-by: Srinivas Rao L --- drivers/soc/qcom/Kconfig | 2 +- drivers/soc/qcom/rpmh.c | 37 ++++++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index d0a73e7..2e581bc 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -105,7 +105,7 @@ config QCOM_RMTFS_MEM config QCOM_RPMH bool "Qualcomm RPM-Hardened (RPMH) Communication" - depends on ARCH_QCOM && ARM64 || COMPILE_TEST + depends on ARCH_QCOM && ARM64 help Support for communication with the hardened-RPM blocks in Qualcomm Technologies Inc (QTI) SoCs. RPMH communication uses an diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index f28afe4..dafb0da 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -158,6 +159,13 @@ static struct cache_req *cache_rpm_request(struct rpmh_ctrlr *ctrlr, } unlock: + if (ctrlr->dirty && !psci_has_osi_support()) { + if (rpmh_flush(ctrlr)) { + spin_unlock_irqrestore(&ctrlr->cache_lock, flags); + return ERR_PTR(-EINVAL); + } + } + spin_unlock_irqrestore(&ctrlr->cache_lock, flags); return req; @@ -285,26 +293,35 @@ int rpmh_write(const struct device *dev, enum rpmh_state state, } EXPORT_SYMBOL(rpmh_write); -static void cache_batch(struct rpmh_ctrlr *ctrlr, struct batch_cache_req *req) +static int cache_batch(struct rpmh_ctrlr *ctrlr, struct batch_cache_req *req) { unsigned long flags; spin_lock_irqsave(&ctrlr->cache_lock, flags); + list_add_tail(&req->list, &ctrlr->batch_cache); ctrlr->dirty = true; + + if (!psci_has_osi_support()) { + if (rpmh_flush(ctrlr)) { + spin_unlock_irqrestore(&ctrlr->cache_lock, flags); + return -EINVAL; + } + } + spin_unlock_irqrestore(&ctrlr->cache_lock, flags); + + return 0; } static int flush_batch(struct rpmh_ctrlr *ctrlr) { struct batch_cache_req *req; const struct rpmh_request *rpm_msg; - unsigned long flags; int ret = 0; int i; /* Send Sleep/Wake requests to the controller, expect no response */ - spin_lock_irqsave(&ctrlr->cache_lock, flags); list_for_each_entry(req, &ctrlr->batch_cache, list) { for (i = 0; i < req->count; i++) { rpm_msg = req->rpm_msgs + i; @@ -314,7 +331,6 @@ static int flush_batch(struct rpmh_ctrlr *ctrlr) break; } } - spin_unlock_irqrestore(&ctrlr->cache_lock, flags); return ret; } @@ -386,10 +402,8 @@ int rpmh_write_batch(const struct device *dev, enum rpmh_state state, cmd += n[i]; } - if (state != RPMH_ACTIVE_ONLY_STATE) { - cache_batch(ctrlr, req); - return 0; - } + if (state != RPMH_ACTIVE_ONLY_STATE) + return cache_batch(ctrlr, req); for (i = 0; i < count; i++) { struct completion *compl = &compls[i]; @@ -455,9 +469,6 @@ static int send_single(struct rpmh_ctrlr *ctrlr, enum rpmh_state state, * Return: -EBUSY if the controller is busy, probably waiting on a response * to a RPMH request sent earlier. * - * This function is always called from the sleep code from the last CPU - * that is powering down the entire system. Since no other RPMH API would be - * executing at this time, it is safe to run lockless. */ int rpmh_flush(struct rpmh_ctrlr *ctrlr) { @@ -474,10 +485,6 @@ int rpmh_flush(struct rpmh_ctrlr *ctrlr) if (ret) return ret; - /* - * Nobody else should be calling this function other than system PM, - * hence we can run without locks. - */ list_for_each_entry(p, &ctrlr->cache, list) { if (!is_req_valid(p)) { pr_debug("%s: skipping RPMH req: a:%#x s:%#x w:%#x", -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation