Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp291206ybk; Tue, 12 May 2020 23:43:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdSIppXj9hC6bmapM9jO5p2gOUc7vdwe108eM9/eY57Avk76Wcbc/PYo5CSV29FXDAMUiE X-Received: by 2002:a05:6402:c0e:: with SMTP id co14mr9684034edb.177.1589352225064; Tue, 12 May 2020 23:43:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589352225; cv=none; d=google.com; s=arc-20160816; b=kAw4XdsgbSwdpEc6K9+P53wAJ4Tl2XGKWMdgJY0WrHlYNyHQC/L7mTE7lTcukK6t9e 3iedB93pHfDNXZ/+OiISGbQSY6fI5MGhng8QSydGXeaITLkySzKaGB5SZJ+OZx21I5wh udlecwaMjP0Ou/Y0OwoAokbF1DcasNOjjpnZxATkvAURhXIzd6YheZwHfQ6b/zdF/BOM +QsEm5M7YpKgeoBF8j3NEaP8/5IfebfZ8Wf8QXH7CL7Sgm2BJW4WKtUWbCG0qOGHKL5B u2NjZ3PQuE0rS9BKRq4NxfPOBg8EWDF3FOyA3Mf4B4Yn11g82U4XX+hPG108a1bWDp7o r1ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=TEOOM5pOLFuCD0JNuG+xQHOyUpCjh1jvRN2yDj9HYr0=; b=aCeZfvdIbvt0PETAjgi9p5OkPAKEogm6rxlVFwNKlWHL3g3n48M30ooh9WzmKseuJy XZcGpQyXCMDp3zc0OBLy+A5o0+qPfb1JwEGX0iJ9Gpu2vegEbTpYfU4IhisZSnsOuHXz TnjXCNCIjXpEY8GwkUDOsa1pdAZzos0qXHMixEK5WTLNc5s/jQ0HZtKdV4LLSr6Kd+9t cmqbqmJ1ZqhqMApWr1i3K2xKM/C9slv7r2jzu/W44PgxG2Bof27rlgsHtWUQlHqzvSA/ 7qWBJ9EEVOb79ZgdO6eyfe/Pm5Mc5wTtkTJhRduDtJZ9bOZoAg+rMnyGx0CE6lkf4jfl GKYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="EH/x+7C1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id r13si3596789edq.64.2020.05.12.23.43.21; Tue, 12 May 2020 23:43:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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="EH/x+7C1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1729504AbgEMGlo (ORCPT + 99 others); Wed, 13 May 2020 02:41:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728712AbgEMGln (ORCPT ); Wed, 13 May 2020 02:41:43 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F045C061A0E for ; Tue, 12 May 2020 23:41:43 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id g11so3207552plp.1 for ; Tue, 12 May 2020 23:41:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=TEOOM5pOLFuCD0JNuG+xQHOyUpCjh1jvRN2yDj9HYr0=; b=EH/x+7C1HU7YxLs7m98yahVwIJPnz8bxLR2i6LAqgFXxc8rwzlEAY/xf9Dh8/p/7iI sqAjzbuzA9ZELOOxe8qQ1Qg4KaXF/LAv8Ozldpi25gg5qZ6uJMPk5eyBWlQt9cQd8r8j 3OrASK4tYsAmkX+tNPDKYPJBfjHBVsHNdp7SjvXsfp2xDihh4VlI104Umg7ogMA21eLI wthunohJNL1Y+VkmEjNE8CZr/L4Ou+7pT0bVHqgM3iYLjk6t8T9V0MCEVK1jF3Sz0Mfu WzYtuKxG+NQQeeNgJHwQ5QYFpUlY6J7PjIsLeLclo7vtV6CYgzZl3ataQINy/zEQC57s Ddqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=TEOOM5pOLFuCD0JNuG+xQHOyUpCjh1jvRN2yDj9HYr0=; b=Dl0ZzusCDWf6025BXIw0dd1GbE3HWD6ryptsYyukmDeZwwMfL3ANlN2amCnBwgsXMp Q+wFtYb3tU8vqAv7A9Wp1xs1aNTNAtRL/v29Y7JOEbQdBQ1UkrxltOCPjgbjfdEiAVnv R6AhRC9gOKnEQAU7eVCS/okD4Gd+GlGOjh82sTxIYkFtl9pIvyM4tUXfTryuaLOR8AeZ ASW30d5zxTqT4qxBN2YKC4OWugCOon4G/pLwcn2k2KpmbZbjGI4QR8CUhtUcz78PE+dy xAOB79TTx5r6uaQGKSa+DXkLoeImjeUu/N0hrjQhCMrUVt2Xy9BFEmEOOPmYySCU/mIt p5Rg== X-Gm-Message-State: AOAM533Q6XaDyO0F3hp9I1DdQVZm4CDGCS4lKj124AOVHmJyD2u5ZCEr TwT/JzvJ2la7ZgI1GA8+yfcnbA== X-Received: by 2002:a17:902:a714:: with SMTP id w20mr13716550plq.336.1589352102800; Tue, 12 May 2020 23:41:42 -0700 (PDT) Received: from localhost ([122.167.130.103]) by smtp.gmail.com with ESMTPSA id 9sm12174992pgr.17.2020.05.12.23.41.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2020 23:41:41 -0700 (PDT) Date: Wed, 13 May 2020 12:11:39 +0530 From: Viresh Kumar To: Georgi Djakov Cc: vireshk@kernel.org, nm@ti.com, sboyd@kernel.org, rjw@rjwysocki.net, saravanak@google.com, sibis@codeaurora.org, mka@chromium.org, robh+dt@kernel.org, rnayak@codeaurora.org, bjorn.andersson@linaro.org, vincent.guittot@linaro.org, jcrouse@codeaurora.org, evgreen@chromium.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 04/10] OPP: Add support for parsing interconnect bandwidth Message-ID: <20200513064139.5kxjjddcooqcvny3@vireshk-i7> References: <20200512125327.1868-1-georgi.djakov@linaro.org> <20200512125327.1868-5-georgi.djakov@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200512125327.1868-5-georgi.djakov@linaro.org> User-Agent: NeoMutt/20180716-391-311a52 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12-05-20, 15:53, Georgi Djakov wrote: > The OPP bindings now support bandwidth values, so add support to parse it > from device tree and store it into the new dev_pm_opp_icc_bw struct, which > is part of the dev_pm_opp. > > Signed-off-by: Georgi Djakov > --- > v8: > * Drop bandwidth requests and free memory in _opp_table_kref_release. > * Take into account the supply_count in struct size calculations. > * Free the temporary arrays for peak and average bandwidth. > * Fix the check for opp-level. > * Use dev_warn insted of dev_dbg. > * Rename _of_find_icc_paths to _of_find_icc_paths. > * Rename the variable count to supply_count. Added this delta to this patch: diff --git a/drivers/opp/core.c b/drivers/opp/core.c index a3dd0bc9b9f6..8b640eac86d5 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1000,7 +1000,7 @@ static struct opp_table *_allocate_opp_table(struct device *dev, int index) } /* Find interconnect path(s) for the device */ - ret = _of_find_icc_paths(opp_table, dev); + ret = dev_pm_opp_of_find_icc_paths(dev, opp_table); if (ret) dev_warn(dev, "%s: Error finding interconnect paths: %d\n", __func__, ret); diff --git a/drivers/opp/of.c b/drivers/opp/of.c index a41c0dc2ac04..15f30ed70bbc 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -332,10 +332,12 @@ static int _of_opp_alloc_required_opps(struct opp_table *opp_table, return ret; } -int _of_find_icc_paths(struct opp_table *opp_table, struct device *dev) +int dev_pm_opp_of_find_icc_paths(struct device *dev, + struct opp_table *opp_table) { struct device_node *np; int ret, i, count, num_paths; + struct icc_path **paths; np = of_node_get(dev->of_node); if (!np) @@ -354,15 +356,14 @@ int _of_find_icc_paths(struct opp_table *opp_table, struct device *dev) } num_paths = count / 2; - opp_table->paths = kcalloc(num_paths, sizeof(*opp_table->paths), - GFP_KERNEL); - if (!opp_table->paths) + paths = kcalloc(num_paths, sizeof(*paths), GFP_KERNEL); + if (!paths) return -ENOMEM; for (i = 0; i < num_paths; i++) { - opp_table->paths[i] = of_icc_get_by_index(dev, i); - if (IS_ERR(opp_table->paths[i])) { - ret = PTR_ERR(opp_table->paths[i]); + paths[i] = of_icc_get_by_index(dev, i); + if (IS_ERR(paths[i])) { + ret = PTR_ERR(paths[i]); if (ret != -EPROBE_DEFER) { dev_err(dev, "%s: Unable to get path%d: %d\n", __func__, i, ret); @@ -370,19 +371,23 @@ int _of_find_icc_paths(struct opp_table *opp_table, struct device *dev) goto err; } } - opp_table->path_count = num_paths; + + if (opp_table) { + opp_table->paths = paths; + opp_table->path_count = num_paths; + } return 0; err: while (i--) - icc_put(opp_table->paths[i]); + icc_put(paths[i]); - kfree(opp_table->paths); - opp_table->paths = NULL; + kfree(paths); return ret; } +EXPORT_SYMBOL_GPL(dev_pm_opp_of_find_icc_paths); static bool _opp_is_supported(struct device *dev, struct opp_table *opp_table, struct device_node *np) diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 17d45119d9bc..2b81ffef1ba4 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -231,14 +231,12 @@ void _of_clear_opp_table(struct opp_table *opp_table); struct opp_table *_managed_opp(struct device *dev, int index); void _of_opp_free_required_opps(struct opp_table *opp_table, struct dev_pm_opp *opp); -int _of_find_icc_paths(struct opp_table *opp_table, struct device *dev); #else static inline void _of_init_opp_table(struct opp_table *opp_table, struct device *dev, int index) {} static inline void _of_clear_opp_table(struct opp_table *opp_table) {} static inline struct opp_table *_managed_opp(struct device *dev, int index) { return NULL; } static inline void _of_opp_free_required_opps(struct opp_table *opp_table, struct dev_pm_opp *opp) {} -static inline int _of_find_icc_paths(struct opp_table *opp_table, struct device *dev) { return 0; } #endif #ifdef CONFIG_DEBUG_FS diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index cfceb0290401..d5c4a329321d 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -372,6 +372,7 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpuma struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev); struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp); int of_get_required_opp_performance_state(struct device_node *np, int index); +int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table); void dev_pm_opp_of_register_em(struct cpumask *cpus); #else static inline int dev_pm_opp_of_add_table(struct device *dev) @@ -420,6 +421,11 @@ static inline int of_get_required_opp_performance_state(struct device_node *np, { return -ENOTSUPP; } + +static inline int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table) +{ + return -ENOTSUPP; +} #endif #endif /* __LINUX_OPP_H__ */ -- viresh