From patchwork Fri Feb 8 17:21:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 157864 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2204897jaa; Fri, 8 Feb 2019 09:22:15 -0800 (PST) X-Google-Smtp-Source: AHgI3IYq++Cvp95EmycOua3f+P4dl+EMxpxcExtyOoA6jg99NHTEXeaDwH7wR42PG9Nn/xo7zeC4 X-Received: by 2002:a17:902:2a0a:: with SMTP id i10mr23512388plb.323.1549646535339; Fri, 08 Feb 2019 09:22:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549646535; cv=none; d=google.com; s=arc-20160816; b=eWlpKhWuSF59NeJUjoADtiCWejQ0GE+C43ilN+O0uFDxHO/151kBECv6P0JRJSycxy Yj1qyDF+bOdy3DnbBVVQf0G+DKzk9GgQeIgBlTblshfK7SznEbFCYhPo72FjIk13EnQj TDRgSz3WEGtgMYUm3gry9zO2Tpz+weRZgfauyLZ/Jy3Q/kkRcK1So15a7USjOqPb68f+ PegurBf1ct7kmIIt1q5EEgDgMYB/KOPtusA0GjyCMci2DI2aodKrXfoYg7pHUZsKIdiC tFw32KtB5Vy6aEsY1QxqYKpdIjfCe7NlNgIDQz67axLY3N+jJsBYYMNqVv5VwpGR4MJ/ sovA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9ELIDzrFuDE4fv0H7ZmmXRZO/WnsGeJX4P6W+1XXVUI=; b=FrMI3LGjgZuIS26IImRTqBVbWQSPoZr9a/VJ1ySCF5sVAnIQSrbqpj+HwDKLNley9I vLvmMUvMWFqxdQpdGdQPBNfLpHvQpmtmx3b093NYdHUF6UotK45ofTlEB9s1rlBjfkvq PdsNu4CjrxZNQWHxgacHSh+8n4a1MXOXrR6IS/p0onspHI0eRoO+cWWEi0/bkSd9hXPm FK34T9LfWmWjW9ye9TA/nAOtkMRaNmJsetYwEtBva1H3UtY0gz05tkAix+nFBQ+PMVr6 qBfV2/XnZV+56roaETYu+J3BtSoQVCgFiFwVOs2nPEtDRcOrEbk3xN/44v/VoHDyk2jb o0Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NRfnV9a5; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l1si2449415pgq.157.2019.02.08.09.22.13; Fri, 08 Feb 2019 09:22:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NRfnV9a5; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727843AbfBHRWB (ORCPT + 15 others); Fri, 8 Feb 2019 12:22:01 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:50320 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726522AbfBHRWA (ORCPT ); Fri, 8 Feb 2019 12:22:00 -0500 Received: by mail-wm1-f65.google.com with SMTP id z5so4273451wmf.0 for ; Fri, 08 Feb 2019 09:21:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9ELIDzrFuDE4fv0H7ZmmXRZO/WnsGeJX4P6W+1XXVUI=; b=NRfnV9a540UmNDKscNJAOYXOcEyFaaX8bPbnN++HLDJnypKbdEz6liciFdRn1wcNfi PGUHa4X+nTbJuFKsM6OXlu8ssaLc0mgIh+bdoxtjsAweLEQZmfJ+mkyGlAU38d0brE55 xjAV8U3Ej3uPiRhFaYsZ6svKUA0jzzdTONgMwWk0Y20lmjmjr75HWi+bt/7bLodDvwBg qmNVkPO6qD9OgGDp+OgtiBt5kd7pGcFF53ph03VnYe2baWXVbofhnvYHQjghX387wCxT vCzSZXZy9p3kYhvb0Gf03Ev65jet852z+os9RYnpCJnF2JIWCxZqAmLb0Gh4utqi+Vjk skxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9ELIDzrFuDE4fv0H7ZmmXRZO/WnsGeJX4P6W+1XXVUI=; b=lGuXX8svRp232WHreZm1F+Rqz+DYSDCU4gI12MHCJpMTYHrXFfdK/W+5DBnQBjDa/F CnN5W529PmvC9DfDYgV5fZ7pBMq97+BC/6GGURHJy/OMRjhKlq9ZEscyHEi2UCK4z7lf if2AXpty5hC344A6bEsgBvewbqayzLqMVH5qfoqvuw9dK5FonwIG2Uo7W4tfkIRVfO/8 s7Be6YjJHEV4mL5fCvNlRKTJS3ly+R7YQT5JBi0tdDq1vu9ReRvfLhDCMg9XoslQ9hXs Iw4QeKIjNcWsJ0avDn7RAAx3tdRpXv9amkEv0DJOVL2Xk7G/qCdQSFaDWnB3NvUj326L e07w== X-Gm-Message-State: AHQUAuZNVm0QC5oULofMlu926zTjgNvXUKA1zbytfduqzt0wlCy7TZ8H 3/B4saMCY9hzBrG41Dylj1uZGA== X-Received: by 2002:a05:6000:120a:: with SMTP id e10mr17621512wrx.85.1549646518598; Fri, 08 Feb 2019 09:21:58 -0800 (PST) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id k23sm4097150wmj.32.2019.02.08.09.21.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Feb 2019 09:21:57 -0800 (PST) From: Georgi Djakov To: linux-pm@vger.kernel.org Cc: daidavid1@codeaurora.org, vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, evgreen@chromium.org, dianders@chromium.org, seansw@qti.qualcomm.com, mturquette@baylibre.com, abailon@baylibre.com, thierry.reding@gmail.com, ksitaraman@nvidia.com, sanjayc@nvidia.com, henryc.chen@mediatek.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v1 2/2] interconnect: qcom: Add tagging and wake/sleep support for sdm845 Date: Fri, 8 Feb 2019 19:21:52 +0200 Message-Id: <20190208172152.1807-3-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190208172152.1807-1-georgi.djakov@linaro.org> References: <20190208172152.1807-1-georgi.djakov@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: David Dai Add support for wake and sleep commands by using a tag to indicate whether or not the aggregate and set requests are active only or dual context for a particular path. Signed-off-by: David Dai Signed-off-by: Georgi Djakov --- drivers/interconnect/qcom/sdm845.c | 101 +++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 26 deletions(-) diff --git a/drivers/interconnect/qcom/sdm845.c b/drivers/interconnect/qcom/sdm845.c index fb526004c82e..13499f681160 100644 --- a/drivers/interconnect/qcom/sdm845.c +++ b/drivers/interconnect/qcom/sdm845.c @@ -65,6 +65,12 @@ struct bcm_db { #define SDM845_MAX_BCMS 30 #define SDM845_MAX_BCM_PER_NODE 2 #define SDM845_MAX_VCD 10 +#define SDM845_MAX_CTX 2 +#define SDM845_EE_STATE 2 +#define EE_STATE_WAKE 0 +#define EE_STATE_SLEEP 1 +#define AO_CTX 0 +#define DUAL_CTX 1 /** * struct qcom_icc_node - Qualcomm specific interconnect nodes @@ -86,8 +92,8 @@ struct qcom_icc_node { u16 num_links; u16 channels; u16 buswidth; - u64 sum_avg; - u64 max_peak; + u64 sum_avg[SDM845_MAX_CTX]; + u64 max_peak[SDM845_MAX_CTX]; struct qcom_icc_bcm *bcms[SDM845_MAX_BCM_PER_NODE]; size_t num_bcms; }; @@ -112,8 +118,8 @@ struct qcom_icc_bcm { const char *name; u32 type; u32 addr; - u64 vote_x; - u64 vote_y; + u64 vote_x[SDM845_EE_STATE]; + u64 vote_y[SDM845_EE_STATE]; bool dirty; bool keepalive; struct bcm_db aux_data; @@ -555,7 +561,7 @@ inline void tcs_cmd_gen(struct tcs_cmd *cmd, u64 vote_x, u64 vote_y, cmd->wait = true; } -static void tcs_list_gen(struct list_head *bcm_list, +static void tcs_list_gen(struct list_head *bcm_list, int ee_state, struct tcs_cmd tcs_list[SDM845_MAX_VCD], int n[SDM845_MAX_VCD]) { @@ -573,8 +579,8 @@ static void tcs_list_gen(struct list_head *bcm_list, commit = true; cur_vcd_size = 0; } - tcs_cmd_gen(&tcs_list[idx], bcm->vote_x, bcm->vote_y, - bcm->addr, commit); + tcs_cmd_gen(&tcs_list[idx], bcm->vote_x[ee_state], + bcm->vote_y[ee_state], bcm->addr, commit); idx++; n[batch]++; /* @@ -595,32 +601,42 @@ static void tcs_list_gen(struct list_head *bcm_list, static void bcm_aggregate(struct qcom_icc_bcm *bcm) { - size_t i; - u64 agg_avg = 0; - u64 agg_peak = 0; + size_t i, ctx; + u64 agg_avg[SDM845_MAX_CTX] = {0}; + u64 agg_peak[SDM845_MAX_CTX] = {0}; u64 temp; - for (i = 0; i < bcm->num_nodes; i++) { - temp = bcm->nodes[i]->sum_avg * bcm->aux_data.width; - do_div(temp, bcm->nodes[i]->buswidth * bcm->nodes[i]->channels); - agg_avg = max(agg_avg, temp); + for (ctx = 0; ctx < SDM845_MAX_CTX; ctx++) { + for (i = 0; i < bcm->num_nodes; i++) { + temp = bcm->nodes[i]->sum_avg[ctx] * bcm->aux_data.width; + do_div(temp, bcm->nodes[i]->buswidth * bcm->nodes[i]->channels); + agg_avg[ctx] = max(agg_avg[ctx], temp); - temp = bcm->nodes[i]->max_peak * bcm->aux_data.width; - do_div(temp, bcm->nodes[i]->buswidth); - agg_peak = max(agg_peak, temp); + temp = bcm->nodes[i]->max_peak[ctx] * bcm->aux_data.width; + do_div(temp, bcm->nodes[i]->buswidth); + agg_peak[ctx] = max(agg_peak[ctx], temp); + } } - temp = agg_avg * 1000ULL; + temp = agg_avg[AO_CTX] + agg_avg[DUAL_CTX] * 1000ULL; + do_div(temp, bcm->aux_data.unit); + bcm->vote_x[EE_STATE_WAKE] = temp; + + temp = max(agg_peak[AO_CTX], agg_peak[DUAL_CTX]) * 1000ULL; + do_div(temp, bcm->aux_data.unit); + bcm->vote_y[EE_STATE_WAKE] = temp; + + temp = agg_avg[DUAL_CTX] * 1000ULL; do_div(temp, bcm->aux_data.unit); - bcm->vote_x = temp; + bcm->vote_x[EE_STATE_SLEEP] = temp; - temp = agg_peak * 1000ULL; + temp = agg_peak[DUAL_CTX] * 1000ULL; do_div(temp, bcm->aux_data.unit); - bcm->vote_y = temp; + bcm->vote_y[EE_STATE_SLEEP] = temp; if (bcm->keepalive && bcm->vote_x == 0 && bcm->vote_y == 0) { - bcm->vote_x = 1; - bcm->vote_y = 1; + bcm->vote_x[EE_STATE_WAKE] = 1; + bcm->vote_y[EE_STATE_WAKE] = 1; } bcm->dirty = false; @@ -631,14 +647,16 @@ static int qcom_icc_aggregate(struct icc_node *node, u32 tag, u32 avg_bw, { size_t i; struct qcom_icc_node *qn; + u32 ctx = 0; qn = node->data; + ctx = (!!tag) ? AO_CTX : DUAL_CTX; *agg_avg += avg_bw; *agg_peak = max_t(u32, *agg_peak, peak_bw); - qn->sum_avg = *agg_avg; - qn->max_peak = *agg_peak; + qn->sum_avg[ctx] = *agg_avg; + qn->max_peak[ctx] = *agg_peak; for (i = 0; i < qn->num_bcms; i++) qn->bcms[i]->dirty = true; @@ -675,7 +693,7 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst) * Construct the command list based on a pre ordered list of BCMs * based on VCD. */ - tcs_list_gen(&commit_list, cmds, commit_idx); + tcs_list_gen(&commit_list, EE_STATE_WAKE, cmds, commit_idx); if (!commit_idx[0]) return ret; @@ -693,6 +711,37 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst) return ret; } + INIT_LIST_HEAD(&commit_list); + + for (i = 0; i < qp->num_bcms; i++) { + /* Only generate WAKE and SLEEP commands if a resource's + * requirements change as the execution environment transitions + * between different power states. + */ + if (qp->bcms[i]->vote_x[EE_STATE_WAKE] != + qp->bcms[i]->vote_x[EE_STATE_SLEEP] || + qp->bcms[i]->vote_y[EE_STATE_WAKE] != + qp->bcms[i]->vote_y[EE_STATE_SLEEP]) { + list_add_tail(&qp->bcms[i]->list, &commit_list); + } + } + + tcs_list_gen(&commit_list, EE_STATE_WAKE, cmds, commit_idx); + + ret = rpmh_write_batch(qp->dev, RPMH_WAKE_ONLY_STATE, cmds, commit_idx); + if (ret) { + dev_err(qp->dev, "Error sending WAKE RPMH requests: %d\n", ret); + return ret; + } + + tcs_list_gen(&commit_list, EE_STATE_SLEEP, cmds, commit_idx); + + ret = rpmh_write_batch(qp->dev, RPMH_SLEEP_STATE, cmds, commit_idx); + if (ret) { + dev_err(qp->dev, "Error sending SLEEP RPMH requests: %d\n", ret); + return ret; + } + return ret; }