From patchwork Wed Jul 22 11:01:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 246991 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp425048ilg; Wed, 22 Jul 2020 04:01:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxl2FwgaAEUthz18w8gE48giQjn9lUq54UeJeDykDiXItChflKJhBVoIfq/5mskpJCVwCNW X-Received: by 2002:a17:906:70cf:: with SMTP id g15mr27941281ejk.531.1595415706063; Wed, 22 Jul 2020 04:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595415706; cv=none; d=google.com; s=arc-20160816; b=JHgokH1Z4sZN4Any0WU06657md7wm3jj1TAZ5WdRcAE0vbe7sSz+CF3/vs0cek2H8t h5UcprxgipfaSr1h9w7c+ErxhADBrngjxqpVr+yFnAQkWCOfAfcZQJJ71qKhgPBak1Qs O21/3+coQ7+bKdQ0FlSl7NPDvjPop9AorZucktL6vffKGy0wCEfxNLC/CwlxMTXglqeI fCixaLOc1WPWPPAt1a3F49dwlnl4EX0h7uFLzNX80N4NTm5nBjTwF1q6yzBp96nCavZL YlS6C8qvG4UyNSyI63bf6io9qdN0/JyXfUCqwMJu/HYv5BSGhjA6Ledqu+zYI5OpmwcL qqYQ== 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=Mb4TDwngKstdYsXu7RUzjZ9eyxkXyxQaDZSnxs4t1+Y=; b=E/lZmqw/gecdhsS7rzy9i4KBL4yv9l4tLock/MR646F79x4U2sFNhsptGmaBcbizn+ AB823Rw/Osr8TlRp/EUuUhKyH2HWzZIprO2rHZAqUbl8Wn6nel2YbEDA9ZNELHG16Yw5 xx3HOzMsp+Can1oYYvjj4CO+YoHehXZBdP3KSCfAuFGnom6sZDAvFICh34VzDfB/Sv1Y 9CTwVO1zJ1R3JmnUePc+cy1BI0qgIyone3+9quvEnQ1gRZVBYh0/zkZ5TwDQRmL/GhK2 VJdbaL5O9E2slG0r/TCgu8UT545T+OV0h+AUqlEr6P7cref8pqTiM4efO2bPBChNfTOu 2rcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N60bJeq9; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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. [23.128.96.18]) by mx.google.com with ESMTP id bs23si13812727edb.562.2020.07.22.04.01.45; Wed, 22 Jul 2020 04:01:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N60bJeq9; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 S1730061AbgGVLBo (ORCPT + 10 others); Wed, 22 Jul 2020 07:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729037AbgGVLBn (ORCPT ); Wed, 22 Jul 2020 07:01:43 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEAFDC0619DF for ; Wed, 22 Jul 2020 04:01:42 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id s10so1445903wrw.12 for ; Wed, 22 Jul 2020 04:01:42 -0700 (PDT) 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=Mb4TDwngKstdYsXu7RUzjZ9eyxkXyxQaDZSnxs4t1+Y=; b=N60bJeq90gF41M58w7DHRMQvF6qMoRnkCpkk5WCEHbDJW0aHQ6I4402GfkkTroitnv DxGEB6UcyEovmUTMewJhlshvkGdmcaqwzbcqdfA9nxgw8Spu298DxnjSikpWRXypTvC8 dQSOOG0oVp3kRk+4vQZBFRagUdUm0V8zL5nCuMACDngI5NldIASAtY9m3s+pDNjYVNEZ Ga8vzcgGqEaScwPGpp2H60wF2eh+4Q9q9UsO3QEH84g81YpAwV7+Ti9bty7qsYWIdfSA uYRKddOBJ/AArr/opFW0AMFu8JnJf8jQZLjQoYGrQLEdLYE7a2pVrXYOpPbKi3sQdRLd RSNA== 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=Mb4TDwngKstdYsXu7RUzjZ9eyxkXyxQaDZSnxs4t1+Y=; b=rmgaS3Pt8Wx1rtQNpkVmXxjAeyHlOxE68ijPPdWaiuIDR2bMY8ewz4O3da/zDJY3vu cfwJnXO97kn+hMdCpHsN6D++ujRDVYXdWCIgaFL6xUHtDurEesl8LurBWp0EgUNvinzM kql8188abYbQ8X+K6RkshtsY5yp9CZf69xJgqHe08VHMl29RY62I0D1uRCqHNy7EamXb b7CAZwaaDoibj3VVmL+QaybKhuk/layhtelLnMIMpO3daDFjp98w61UM0eNr5S0TBsGY pB9EzoRBC6yN8u8ShtGK+nQAlSMxEAsVGaFeYfKdaxm4hHLHFEtOzyFFGylWsOZNzzcX H5Jg== X-Gm-Message-State: AOAM531NdetsTyO3TfYXeGlr0x6mcFQWNfng1eYa0avZN5Zanbo1XzR2 j6Lq4tlptpm7KAv7PMGYGv5/+JXEBso= X-Received: by 2002:adf:cd8b:: with SMTP id q11mr22330993wrj.98.1595415701114; Wed, 22 Jul 2020 04:01:41 -0700 (PDT) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id y6sm41256164wrr.74.2020.07.22.04.01.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jul 2020 04:01:40 -0700 (PDT) From: Georgi Djakov To: linux-pm@vger.kernel.org Cc: saravanak@google.com, mdtipton@codeaurora.org, okukatla@codeaurora.org, bjorn.andersson@linaro.org, vincent.guittot@linaro.org, georgi.djakov@linaro.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] interconnect: Add sync state support Date: Wed, 22 Jul 2020 14:01:38 +0300 Message-Id: <20200722110139.24778-2-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200722110139.24778-1-georgi.djakov@linaro.org> References: <20200722110139.24778-1-georgi.djakov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The bootloaders often do some initial configuration of the interconnects in the system and we want to keep this configuration until all consumers have probed and expressed their bandwidth needs. This is because we don't want to change the configuration by starting to disable unused paths until every user had a chance to request the amount of bandwidth it needs. To accomplish this we will implement an interconnect specific sync_state callback which will synchronize (aggregate and set) the current bandwidth settings when all consumers have been probed. Signed-off-by: Georgi Djakov --- drivers/interconnect/core.c | 61 +++++++++++++++++++++++++++ include/linux/interconnect-provider.h | 5 +++ 2 files changed, 66 insertions(+) diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index e5f998744501..0c4e38d9f1fa 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -26,6 +26,8 @@ static DEFINE_IDR(icc_idr); static LIST_HEAD(icc_providers); +static int providers_count; +static bool synced_state; static DEFINE_MUTEX(icc_lock); static struct dentry *icc_debugfs_dir; @@ -255,6 +257,12 @@ static int aggregate_requests(struct icc_node *node) continue; p->aggregate(node, r->tag, r->avg_bw, r->peak_bw, &node->avg_bw, &node->peak_bw); + + /* during boot use the initial bandwidth as a floor value */ + if (!synced_state) { + node->avg_bw = max(node->avg_bw, node->init_avg); + node->peak_bw = max(node->peak_bw, node->init_peak); + } } return 0; @@ -919,6 +927,13 @@ void icc_node_add(struct icc_node *node, struct icc_provider *provider) node->provider = provider; list_add_tail(&node->node_list, &provider->nodes); + /* get the initial bandwidth values and sync them with hardware */ + if ((node->init_avg || node->init_peak) && provider->set) { + node->avg_bw = node->init_avg; + node->peak_bw = node->init_peak; + provider->set(node, node); + } + mutex_unlock(&icc_lock); } EXPORT_SYMBOL_GPL(icc_node_add); @@ -1014,8 +1029,54 @@ int icc_provider_del(struct icc_provider *provider) } EXPORT_SYMBOL_GPL(icc_provider_del); +static int of_count_icc_providers(struct device_node *np) +{ + struct device_node *child; + int count = 0; + + for_each_available_child_of_node(np, child) { + if (of_property_read_bool(child, "#interconnect-cells")) + count++; + count += of_count_icc_providers(child); + } + of_node_put(np); + + return count; +} + +void icc_sync_state(struct device *dev) +{ + struct icc_provider *p; + struct icc_node *n; + static int count; + + count++; + + if (count < providers_count) + return; + + mutex_lock(&icc_lock); + synced_state = true; + list_for_each_entry(p, &icc_providers, provider_list) { + dev_dbg(p->dev, "interconnect provider is in synced state\n"); + list_for_each_entry(n, &p->nodes, node_list) { + if (n->init_avg || n->init_peak) { + aggregate_requests(n); + p->set(n, n); + } + } + } + mutex_unlock(&icc_lock); +} +EXPORT_SYMBOL_GPL(icc_sync_state); + static int __init icc_init(void) { + struct device_node *root = of_find_node_by_path("/"); + + providers_count = of_count_icc_providers(root); + of_node_put(root); + icc_debugfs_dir = debugfs_create_dir("interconnect", NULL); debugfs_create_file("interconnect_summary", 0444, icc_debugfs_dir, NULL, &icc_summary_fops); diff --git a/include/linux/interconnect-provider.h b/include/linux/interconnect-provider.h index 0c494534b4d3..aa85b96296c4 100644 --- a/include/linux/interconnect-provider.h +++ b/include/linux/interconnect-provider.h @@ -71,6 +71,8 @@ struct icc_provider { * @req_list: a list of QoS constraint requests associated with this node * @avg_bw: aggregated value of average bandwidth requests from all consumers * @peak_bw: aggregated value of peak bandwidth requests from all consumers + * @init_avg: average bandwidth value that is read from the hardware during init + * @init_peak: peak bandwidth value that is read from the hardware during init * @data: pointer to private data */ struct icc_node { @@ -87,6 +89,8 @@ struct icc_node { struct hlist_head req_list; u32 avg_bw; u32 peak_bw; + u32 init_avg; + u32 init_peak; void *data; }; @@ -103,6 +107,7 @@ void icc_node_del(struct icc_node *node); int icc_nodes_remove(struct icc_provider *provider); int icc_provider_add(struct icc_provider *provider); int icc_provider_del(struct icc_provider *provider); +void icc_sync_state(struct device *dev); #else From patchwork Wed Jul 22 11:01:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 246992 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp425153ilg; Wed, 22 Jul 2020 04:01:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfwiRtxfjMmvpsHvkbiiiLabmGQ4+4TtZy0cyYDwGq++2yrK7QuIGjMkaRxpL1R3LKtAXt X-Received: by 2002:a05:6402:49:: with SMTP id f9mr23864153edu.112.1595415712747; Wed, 22 Jul 2020 04:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595415712; cv=none; d=google.com; s=arc-20160816; b=0WWg6jChKizuP9ewecXFjCnfo7PNDwlU2y27d8/UD/HBKwTj5trseqwiUAQNmWYWwy dV6t2213g7oIwFZ3FJPQX12nSQawVKVfj5a+TgcDuz7yz8XzyXBcpjopF26M+T1Y07Bv LkqCOdlQh/7kg+CQxGk6HRhT5VyAyBnHXB5qBqxhVPfx1rkmKmYjPs8awPahzHWyndrv MVcHS4MElguPVmkXjKhNHjG1AX3LCeTmu51C/YKP1kODTjcWKk/B5aaGk9MRLTVGx7B9 WW26+rzBJQayZ5VL81hVNAXT0lBgIbY9QAlcM1LD2O+f6sVwvWTPTSHCGoJch76TmAgf pIhg== 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=niAmRUGsg4kxR596xiqQAVaMYD9d+SGcGWnDYDntXxM=; b=Wi09zO+a2AnxsnO/0JnlZFVQyJcD9Fsr97OvqWCptqianGyJ2guErCzhyJsmWO2hAM epXlotmwVey5sV0JLo7MwwS8s8r37lE4+L1laG6vdnWqkostXBO9SJvC1CaVzl9IXVWU DOk01PXRVFJfGSYoc/ySMDbisnyNoVgTxbUWU+MBXTS0fAfmm7Cq7r7IDYnkuNDZPi1F 3s2/+mIxJL9TPvdXMqlBfqv32PHdM/7RpHY19xd1a1ElzgEvqsTScR3SwpgcnZL601fe veKxJQ7Q1M2hXeDdmiXUPYYtnpEgZc6QOsLG2iZ1KaHEQ3xwsSwwy6bEeKk2X1EuEOO5 mlww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r94Bx+p3; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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. [23.128.96.18]) by mx.google.com with ESMTP id pw26si14383667ejb.240.2020.07.22.04.01.51; Wed, 22 Jul 2020 04:01:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r94Bx+p3; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 S1730142AbgGVLBo (ORCPT + 10 others); Wed, 22 Jul 2020 07:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726462AbgGVLBo (ORCPT ); Wed, 22 Jul 2020 07:01:44 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07C23C0619DC for ; Wed, 22 Jul 2020 04:01:44 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id a15so1452737wrh.10 for ; Wed, 22 Jul 2020 04:01:43 -0700 (PDT) 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=niAmRUGsg4kxR596xiqQAVaMYD9d+SGcGWnDYDntXxM=; b=r94Bx+p3fcIDdAUsi8ATLuebYYefpEfjtAfalUhzc8pUWLe7DYZlGToUERmUT6175v ridcQ7TDaWP5Jou4y5JCHVow5LoJaJmJTCGsqXpB1OrI5UBftKfAYaVYfwzURR66u/H9 iHci+7rpt+mdko5bdHcESZMNj4ARx6gtgIhfZZ/o0auMSlQPxuV4B2FlB+9MMh7yl9Iv nBI5Anaw9Q7+OmR8XNlS06NTmtjbZTzwh5i4lOJra4g19ge0YzKw0ZZOzzm/YUG6QVwU 8Am9GunVPEw14N3o7HFV6CuCO0QWUc6s/ie+Uy5RY9m5EjGvqPB07L4KQv75NEShn5qI N7IA== 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=niAmRUGsg4kxR596xiqQAVaMYD9d+SGcGWnDYDntXxM=; b=ZdU5E0CkYbPqEgiJ9uE8AzoydV8DFHBTcOKkY6/Os0Xmx1aUWHhg4Y7jihu9zGX8VU M90EUVGjJG6Up3IjFN8LJx0Pki4Vh8XYIDy7nXWcPZSXmVPm+T1v6xFYFUVcsQSyBPz6 ZflM4YyV6r/7GHyKl2PHg3eFntR0jSlX6E+kBpoGH1BypSRxQ6j/7MK7KoSd206Zag4H c6HxHvJP4+hbMDFzcCIkBXZqRyxTdDnuOU9NNn2nmeKAmoN1tOGQ4TajeQSlPaTps76k bq6cWG5053tWnOV/foiFsVIQYddQO/O3wc6zjv+GfBYcqnahOL+Dz4hwIx7YUItjIzQE zSJg== X-Gm-Message-State: AOAM533icBv0FLY9V6XTqDlkBK4JcEXnnYr6AA1O53vsuooezhaOGovJ Di53dMX428XbOL7+xRZW/je9Ngr7gng= X-Received: by 2002:a5d:4a0d:: with SMTP id m13mr13001479wrq.12.1595415702339; Wed, 22 Jul 2020 04:01:42 -0700 (PDT) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id y6sm41256164wrr.74.2020.07.22.04.01.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jul 2020 04:01:41 -0700 (PDT) From: Georgi Djakov To: linux-pm@vger.kernel.org Cc: saravanak@google.com, mdtipton@codeaurora.org, okukatla@codeaurora.org, bjorn.andersson@linaro.org, vincent.guittot@linaro.org, georgi.djakov@linaro.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] interconnect: qcom: Use icc_sync_state in sdm845 and osm-3l drivers Date: Wed, 22 Jul 2020 14:01:39 +0300 Message-Id: <20200722110139.24778-3-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200722110139.24778-1-georgi.djakov@linaro.org> References: <20200722110139.24778-1-georgi.djakov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Lowering the bandwidth on the bus might have negative consequences if it's done before all consumers had a chance to cast their vote. Let's return the maximum amount of bandwidth as initial value. This bandwidth level would be maintained until all consumers have probed. Signed-off-by: Georgi Djakov --- drivers/interconnect/qcom/osm-l3.c | 3 +++ drivers/interconnect/qcom/sdm845.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/interconnect/qcom/osm-l3.c b/drivers/interconnect/qcom/osm-l3.c index 96fb9ff5ff2e..54aff6273af1 100644 --- a/drivers/interconnect/qcom/osm-l3.c +++ b/drivers/interconnect/qcom/osm-l3.c @@ -236,6 +236,8 @@ static int qcom_osm_l3_probe(struct platform_device *pdev) node->name = qnodes[i]->name; node->data = qnodes[i]; + node->init_avg = INT_MAX; + node->init_peak = INT_MAX; icc_node_add(node, provider); for (j = 0; j < qnodes[i]->num_links; j++) @@ -268,6 +270,7 @@ static struct platform_driver osm_l3_driver = { .driver = { .name = "osm-l3", .of_match_table = osm_l3_of_match, + .sync_state = icc_sync_state, }, }; module_platform_driver(osm_l3_driver); diff --git a/drivers/interconnect/qcom/sdm845.c b/drivers/interconnect/qcom/sdm845.c index f6c7b969520d..c04775820f15 100644 --- a/drivers/interconnect/qcom/sdm845.c +++ b/drivers/interconnect/qcom/sdm845.c @@ -503,6 +503,8 @@ static int qnoc_probe(struct platform_device *pdev) node->name = qnodes[i]->name; node->data = qnodes[i]; + node->init_avg = INT_MAX; + node->init_peak = INT_MAX; icc_node_add(node, provider); for (j = 0; j < qnodes[i]->num_links; j++) @@ -559,6 +561,7 @@ static struct platform_driver qnoc_driver = { .driver = { .name = "qnoc-sdm845", .of_match_table = qnoc_of_match, + .sync_state = icc_sync_state, }, }; module_platform_driver(qnoc_driver);