Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8840043ybl; Fri, 17 Jan 2020 01:59:51 -0800 (PST) X-Google-Smtp-Source: APXvYqzte/a4+U0aJWLn1kahqPcGak1hZFqd5rxQasGIJ19bTC2khDEAW2OyxD1w1BdUza/H7PXY X-Received: by 2002:aca:ed81:: with SMTP id l123mr2822297oih.129.1579255191446; Fri, 17 Jan 2020 01:59:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579255191; cv=none; d=google.com; s=arc-20160816; b=FtMs5kbL4jvRzXCcRJ7NwJxfV4DL3/MjmUxbIJ+xzGAdKjZ800zCGyRNyTySswhFXt W+ODnVUWjjf9sC/Pay9+f76k0LZ74vSyru60jnH0qa3lLOdvtgmG8vCTL9szjac4XwQ7 lJsP6ZRApztK0qZ2CKqh8usS2FiTu5cYG3c19fdP3haouDY2Ch++sQUqxtk93LHnnPKo x7MNERQarqpbPATAaSP7iNFYxVs9hsHUQf2WxqprgXCETh3ZtOLWFVT2pwjR8WcWAxmt baF0YkoH2st2vCaSRniOpQMdbgRHKitMyqPCpxkx4vvoutkjc49xJvpScNoeoAvfRigf 0s0g== 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=96TwPn9tZGUSDTaF/Oy40asyB7vDV/iwGB6pLp4mfFQ=; b=BFyv+dCaQRWUZN6CeElBUXOaunvLyrrPNObcSSLTo3vlMwJnNNIpATaYzy3pJxNHnS F4JONezW5MCETsYoZsgWFQ2Un6aAbaB9oDJ1KxfzveD3wtxPJVzed+yh/aCJPGdJoE71 GC3erVRarsCs+YkkHo9V5NvjSbGoo1hd8cOUeZM1Y5ofAbUabWRM0AAaiQkfeSIB0/if 7KeBPeYhQw6T1a2rcG+TiFqyUd9VL4AUyVPIurKiijD/PbUbGyhnXGj+kIoR+OKqWR+5 v76jtvklVDurrof1vGOlZ98rrV6/TLnDx3XYn0tQrR05+IX5nM8BoPw7GDkoKN3Ry8GQ KAZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wu8zTcz9; 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; 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 d20si14569289otq.157.2020.01.17.01.59.38; Fri, 17 Jan 2020 01:59:51 -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=pass header.i=@linaro.org header.s=google header.b=Wu8zTcz9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729022AbgAQJ6d (ORCPT + 99 others); Fri, 17 Jan 2020 04:58:33 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:45803 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728827AbgAQJ63 (ORCPT ); Fri, 17 Jan 2020 04:58:29 -0500 Received: by mail-wr1-f68.google.com with SMTP id j42so22013851wrj.12 for ; Fri, 17 Jan 2020 01:58:27 -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=96TwPn9tZGUSDTaF/Oy40asyB7vDV/iwGB6pLp4mfFQ=; b=Wu8zTcz9k2Vpywvl31N0c25HBVn2qwXOqD+MWlsqko83KPs6S99De4fRi1hfH9F8TT Bg5GAmWjYud1pvlRTCQmmg2nHWybCYCtt0u8WW0WHk8rwJvl8LiDDa7JZ8IDcRORVEw3 2wtW9ktAzWPuLhTC9wg4wsxYNJZ4lJMqrpdVhlWS365QBIt5lSmxFzCPYY3ew2eFr4pF zUcuQdWuHEqjjl0oFrXtTNXF7ZGD6DbBmaOEfE8ryP1K2/cuK94vwoX8VlgL+5iye5IJ 3jgdn1lOCh62EdMU1CYcA5EuwBGMv9Fyhn7RbNbIIRnp3RRBvf5FpZKvi2Mx0KXUm1Pf asHw== 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=96TwPn9tZGUSDTaF/Oy40asyB7vDV/iwGB6pLp4mfFQ=; b=XPEgY3HN3iFM5/mxa7QgFS74TJy4rYyn6l/Ptmdn1Hd4G38nO2bqCUHwqNP//67XpN 2y2YIkhNnHdgik14RDzk0LK19RE5efuLN2J/gHgcesB2LRPkvve/G//NR5DUmKC5EO1p Abi/GuPuJmunNVUdb7e0VKeahFG3JYzRCzhj/nnf88mJXZ1frGaHQHVcLF9sZL3SE5ym FPVn0IhW6+y+K8z9MQoxqsFiTSUhwzo6Od/jg9K1Ed+PEDtA2Tvec06FHh31oY+pvqwP JCs1Nrt3SdsOZJwXcUTaWGQh70gloAhk57axj4UFHUxZVRjZb6+rrBo/L9nbJ7wm3lku 373A== X-Gm-Message-State: APjAAAUxmlI2X1ga2+o09h/Ect//TsMfmktGtI7gmFpHXnnSD9iv2N8f mUPOzyjuxxejfSqzxcb/k9Ij9w== X-Received: by 2002:adf:fe0e:: with SMTP id n14mr2278558wrr.116.1579255106666; Fri, 17 Jan 2020 01:58:26 -0800 (PST) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id r62sm9967007wma.32.2020.01.17.01.58.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Jan 2020 01:58:26 -0800 (PST) From: Georgi Djakov To: gregkh@linuxfoundation.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Georgi Djakov , Evan Green , Brian Masney , Bjorn Andersson Subject: [PATCH 06/12] interconnect: Add a common standard aggregate function Date: Fri, 17 Jan 2020 11:58:10 +0200 Message-Id: <20200117095816.23575-7-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200117095816.23575-1-georgi.djakov@linaro.org> References: <20200117095816.23575-1-georgi.djakov@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently there is one very standard aggregation method that is used by several drivers. Let's add this as a common function, so that drivers could just point to it, instead of copy/pasting code. Suggested-by: Evan Green Reviewed-by: Brian Masney Reviewed-by: Bjorn Andersson Reviewed-by: Evan Green Signed-off-by: Georgi Djakov --- drivers/interconnect/core.c | 10 ++++++++++ include/linux/interconnect-provider.h | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index fbec2e4fdfeb..03625406c69f 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -221,6 +221,16 @@ static int apply_constraints(struct icc_path *path) return ret; } +int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw, + u32 peak_bw, u32 *agg_avg, u32 *agg_peak) +{ + *agg_avg += avg_bw; + *agg_peak = max(*agg_peak, peak_bw); + + return 0; +} +EXPORT_SYMBOL_GPL(icc_std_aggregate); + /* of_icc_xlate_onecell() - Translate function using a single index. * @spec: OF phandle args to map into an interconnect node. * @data: private data (pointer to struct icc_onecell_data) diff --git a/include/linux/interconnect-provider.h b/include/linux/interconnect-provider.h index 31440c921216..0c494534b4d3 100644 --- a/include/linux/interconnect-provider.h +++ b/include/linux/interconnect-provider.h @@ -92,6 +92,8 @@ struct icc_node { #if IS_ENABLED(CONFIG_INTERCONNECT) +int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw, + u32 peak_bw, u32 *agg_avg, u32 *agg_peak); struct icc_node *icc_node_create(int id); void icc_node_destroy(int id); int icc_link_create(struct icc_node *node, const int dst_id); @@ -104,6 +106,12 @@ int icc_provider_del(struct icc_provider *provider); #else +static inline int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw, + u32 peak_bw, u32 *agg_avg, u32 *agg_peak) +{ + return -ENOTSUPP; +} + static inline struct icc_node *icc_node_create(int id) { return ERR_PTR(-ENOTSUPP);