From patchwork Fri Feb 4 19:50:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12735503 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55363C433F5 for ; Fri, 4 Feb 2022 19:51:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235203AbiBDTvG (ORCPT ); Fri, 4 Feb 2022 14:51:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234865AbiBDTu6 (ORCPT ); Fri, 4 Feb 2022 14:50:58 -0500 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AC68C061401 for ; Fri, 4 Feb 2022 11:50:51 -0800 (PST) Received: by mail-io1-xd34.google.com with SMTP id r144so8675997iod.9 for ; Fri, 04 Feb 2022 11:50:51 -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=NJSgbV82nLgKXKYaIVZ+XNSiEnkL4FwHctPzlM9hZrc=; b=TBH0vug6qzMDfkTjUwcRV6xDfQ0Mqum9N0MGVz/HzcJVHbrTjpQB8+okfUwRP8tf2B Yam7tHCuthYq3FceCn2e68E4b10FScquG59FmK+tqTmndIihxhzLypYKk63v6IlstG0p L8PtWtqI76mAS8srcF28bsa4wfSzf7Cu7Y/Epqt/9RZ/KXXLu3LbF3+eHThJDvAMJAKx FwNVv7vg28Gl9LVA+gfJNUx0yj/baf7Obi28RdEDW9kFakpTnhAXdiv0oYQfx1z9XXvS qD/IUGjQ7gBoJpkgJV5M0GMPp5vYsczEzUhTWn6aUWh5SO/6w/SkLzxgnBycBs6UsbA9 TCeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NJSgbV82nLgKXKYaIVZ+XNSiEnkL4FwHctPzlM9hZrc=; b=lClVf4MYvB8PnymMGWh56je7UJmLKTVMsj5QWrFrnk6O3MDNGVSrCthCGh99prre9l 0pU6ysTpsl2MWJhpbFav4c/NsxH1mR89Uv6fFhqkVaVlGNYekM8M6aNhUON068Gys+DB pqBubSOPL8dAcbV25k0stuCmUEmsuwJE9UlIgCJ8xNYK9hHeQ51dRu0T7qmYAEIvPp1x 6QXvz8m+KS43UTPO/U8lT5MSVZ3eLLlxE4wtwN2M9as7zk40UN8qCn4tiUwJNIxA1dqB 59NJJP+F0z9Gln7VX5ju7eCmIGX+Zd+auTS47ZMOw8fAAFsDeblSsewgseozZJTFZFax BD7g== X-Gm-Message-State: AOAM530aEDuoihxC/TuOqCD3FyU00X54a4QWQNA+nHvWQsUKoRKpGYqn LtzBE4UJngmmfymtDfIDJ4PkbA== X-Google-Smtp-Source: ABdhPJwpBNCFvez/OLynGuHBQ2f9mdL2Z1qTx8ZzJBTX4+77xoY9IEAMS2FBbT407BP/f+st7brCwA== X-Received: by 2002:a05:6638:10c5:: with SMTP id q5mr335290jad.113.1644004250388; Fri, 04 Feb 2022 11:50:50 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id k13sm1417564ili.22.2022.02.04.11.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 11:50:49 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: djakov@kernel.org, bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/7] net: ipa: kill struct ipa_interconnect Date: Fri, 4 Feb 2022 13:50:38 -0600 Message-Id: <20220204195044.1082026-2-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220204195044.1082026-1-elder@linaro.org> References: <20220204195044.1082026-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The ipa_interconnect structure contains an icc_path pointer, plus an average and peak bandwidth value. Other than the interconnect name, this matches the icc_bulk_data structure exactly. Use the icc_bulk_data structure in place of the ipa_interconnect structure, and add an initialization of its name field. Then get rid of the now unnecessary ipa_interconnect structure definition. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_power.c | 39 +++++++++++++------------------------ 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c index f2989aac47a62..28be0e45cccfd 100644 --- a/drivers/net/ipa/ipa_power.c +++ b/drivers/net/ipa/ipa_power.c @@ -34,18 +34,6 @@ #define IPA_AUTOSUSPEND_DELAY 500 /* milliseconds */ -/** - * struct ipa_interconnect - IPA interconnect information - * @path: Interconnect path - * @average_bandwidth: Average interconnect bandwidth (KB/second) - * @peak_bandwidth: Peak interconnect bandwidth (KB/second) - */ -struct ipa_interconnect { - struct icc_path *path; - u32 average_bandwidth; - u32 peak_bandwidth; -}; - /** * enum ipa_power_flag - IPA power flags * @IPA_POWER_FLAG_RESUMED: Whether resume from suspend has been signaled @@ -79,11 +67,11 @@ struct ipa_power { spinlock_t spinlock; /* used with STOPPED/STARTED power flags */ DECLARE_BITMAP(flags, IPA_POWER_FLAG_COUNT); u32 interconnect_count; - struct ipa_interconnect *interconnect; + struct icc_bulk_data *interconnect; }; static int ipa_interconnect_init_one(struct device *dev, - struct ipa_interconnect *interconnect, + struct icc_bulk_data *interconnect, const struct ipa_interconnect_data *data) { struct icc_path *path; @@ -99,13 +87,14 @@ static int ipa_interconnect_init_one(struct device *dev, } interconnect->path = path; - interconnect->average_bandwidth = data->average_bandwidth; - interconnect->peak_bandwidth = data->peak_bandwidth; + interconnect->name = data->name; + interconnect->avg_bw = data->average_bandwidth; + interconnect->peak_bw = data->peak_bandwidth; return 0; } -static void ipa_interconnect_exit_one(struct ipa_interconnect *interconnect) +static void ipa_interconnect_exit_one(struct icc_bulk_data *interconnect) { icc_put(interconnect->path); memset(interconnect, 0, sizeof(*interconnect)); @@ -115,7 +104,7 @@ static void ipa_interconnect_exit_one(struct ipa_interconnect *interconnect) static int ipa_interconnect_init(struct ipa_power *power, struct device *dev, const struct ipa_interconnect_data *data) { - struct ipa_interconnect *interconnect; + struct icc_bulk_data *interconnect; u32 count; int ret; @@ -146,7 +135,7 @@ static int ipa_interconnect_init(struct ipa_power *power, struct device *dev, /* Inverse of ipa_interconnect_init() */ static void ipa_interconnect_exit(struct ipa_power *power) { - struct ipa_interconnect *interconnect; + struct icc_bulk_data *interconnect; interconnect = power->interconnect + power->interconnect_count; while (interconnect-- > power->interconnect) @@ -158,7 +147,7 @@ static void ipa_interconnect_exit(struct ipa_power *power) /* Currently we only use one bandwidth level, so just "enable" interconnects */ static int ipa_interconnect_enable(struct ipa *ipa) { - struct ipa_interconnect *interconnect; + struct icc_bulk_data *interconnect; struct ipa_power *power = ipa->power; int ret; u32 i; @@ -166,12 +155,12 @@ static int ipa_interconnect_enable(struct ipa *ipa) interconnect = power->interconnect; for (i = 0; i < power->interconnect_count; i++) { ret = icc_set_bw(interconnect->path, - interconnect->average_bandwidth, - interconnect->peak_bandwidth); + interconnect->avg_bw, + interconnect->peak_bw); if (ret) { dev_err(&ipa->pdev->dev, "error %d enabling %s interconnect\n", - ret, icc_get_name(interconnect->path)); + ret, interconnect->name); goto out_unwind; } interconnect++; @@ -189,9 +178,9 @@ static int ipa_interconnect_enable(struct ipa *ipa) /* To disable an interconnect, we just its bandwidth to 0 */ static int ipa_interconnect_disable(struct ipa *ipa) { - struct ipa_interconnect *interconnect; struct ipa_power *power = ipa->power; struct device *dev = &ipa->pdev->dev; + struct icc_bulk_data *interconnect; int result = 0; u32 count; int ret; @@ -203,7 +192,7 @@ static int ipa_interconnect_disable(struct ipa *ipa) ret = icc_set_bw(interconnect->path, 0, 0); if (ret) { dev_err(dev, "error %d disabling %s interconnect\n", - ret, icc_get_name(interconnect->path)); + ret, interconnect->name); /* Try to disable all; record only the first error */ if (!result) result = ret; From patchwork Fri Feb 4 19:50:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12735501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37A5CC433F5 for ; Fri, 4 Feb 2022 19:51:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234888AbiBDTvB (ORCPT ); Fri, 4 Feb 2022 14:51:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234871AbiBDTu6 (ORCPT ); Fri, 4 Feb 2022 14:50:58 -0500 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81DAEC06174A for ; Fri, 4 Feb 2022 11:50:52 -0800 (PST) Received: by mail-il1-x136.google.com with SMTP id w5so5771902ilo.2 for ; Fri, 04 Feb 2022 11:50:52 -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=2OpxrECw+JfiUzuzU5c0ZHXTX3WGTRoSTdmnh1YRIC8=; b=HppWBMMgS9Yme1jfcB/7ZwVahRJawVt1l8kj+tAf6MHiFKWQLzPebfNIpBW1eLCh/I shmD14+oZJYKJDKicVkCJCOW+R6SF0xPMVjTOIBt50C80pG4Y8Lqfc3duSKDBGuM5SWq JuC0MchZwF+7UpnJ+NYgptOXolGO8zQHw1Y+g+q0VSQUVB8jCPbolUMs1CnlfH+fBhXx Gzel8bnxvP2WEpKa43bgrha85b7g6Y6wTgkSZawdudjgESRArf6wTLQSls/mxe/gx879 ggL4AEF0TkMBWgYlIA4x8YdSFP8bQMnC9jq8u3bK8h8BC+FEqMka9cPIN60o1pQp7fqL Z+PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2OpxrECw+JfiUzuzU5c0ZHXTX3WGTRoSTdmnh1YRIC8=; b=Nx6m2FBQUfGMohLlAbi53nJU+bF/8FikSnrK0w+iJXK5lBWr077ObPzWxt4REZxqas PCqotmcSSP3fVHal76b8BQSyQW7OqNVA8CeBSu75sq2+yiMswI3MTJsjcVdLCgfPf4+c M8k2UPvgS4ifr21ro/M1dEGa0ONV9OHqfZi2ezb4hoX1oRyPmVZ8jrwXzb+jysqGV1ij IhrjFIkqPaDnsyt0qsFpdsx1nbVDAsDg+SuUw9fxv0JlVi6pdXpO0IL7//DUQUeX2QF3 bE62eG8arEAB7B8PbQzcKOefCEAqm3UcgeFQmczCnP2IIkcuHcjON1jOVom5HCHNHlGV ziog== X-Gm-Message-State: AOAM531wXUk8ReIwmGp/NEcYc8m5uf7a1t8gKEWGr1p2KpLvdeAhaYGW DKyKqx2tXm3+V1ATw4L4xmpI8g== X-Google-Smtp-Source: ABdhPJy0fJauEzAvOAJjzaHIbr3Jkbg0HH/4xt5CZ+WZplszz/0rFrRA056xs6blwDbe9VWyIQ/uHw== X-Received: by 2002:a05:6e02:b41:: with SMTP id f1mr376396ilu.193.1644004251799; Fri, 04 Feb 2022 11:50:51 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id k13sm1417564ili.22.2022.02.04.11.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 11:50:51 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: djakov@kernel.org, bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/7] net: ipa: use icc_enable() and icc_disable() Date: Fri, 4 Feb 2022 13:50:39 -0600 Message-Id: <20220204195044.1082026-3-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220204195044.1082026-1-elder@linaro.org> References: <20220204195044.1082026-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The interconnect framework now provides the ability to enable and disable interconnects without having to change their recorded "enabled" bandwidth value. Use this mechanism, rather than setting the bandwidth values to zero and non-zero respectively to disable and enable the IPA interconnects. Disable each interconnect before setting its "enabled" average and peak bandwidth values. Thereafter, enable and disable interconnects when required rather than setting their bandwidths. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_power.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c index 28be0e45cccfd..ec2ebc74edb8b 100644 --- a/drivers/net/ipa/ipa_power.c +++ b/drivers/net/ipa/ipa_power.c @@ -75,17 +75,29 @@ static int ipa_interconnect_init_one(struct device *dev, const struct ipa_interconnect_data *data) { struct icc_path *path; + int ret; path = of_icc_get(dev, data->name); if (IS_ERR(path)) { - int ret = PTR_ERR(path); - + ret = PTR_ERR(path); dev_err_probe(dev, ret, "error getting %s interconnect\n", data->name); return ret; } + /* All interconnects are initially disabled */ + (void)icc_disable(path); + + /* Set the bandwidth values to be used when enabled */ + ret = icc_set_bw(path, data->average_bandwidth, data->peak_bandwidth); + if (ret) { + dev_err(dev, "error %d setting %s interconnect bandwidths\n", + ret, data->name); + + return ret; + } + interconnect->path = path; interconnect->name = data->name; interconnect->avg_bw = data->average_bandwidth; @@ -154,9 +166,7 @@ static int ipa_interconnect_enable(struct ipa *ipa) interconnect = power->interconnect; for (i = 0; i < power->interconnect_count; i++) { - ret = icc_set_bw(interconnect->path, - interconnect->avg_bw, - interconnect->peak_bw); + ret = icc_enable(interconnect->path); if (ret) { dev_err(&ipa->pdev->dev, "error %d enabling %s interconnect\n", @@ -170,7 +180,7 @@ static int ipa_interconnect_enable(struct ipa *ipa) out_unwind: while (interconnect-- > power->interconnect) - (void)icc_set_bw(interconnect->path, 0, 0); + (void)icc_disable(interconnect->path); return ret; } @@ -189,7 +199,7 @@ static int ipa_interconnect_disable(struct ipa *ipa) interconnect = power->interconnect + count; while (count--) { interconnect--; - ret = icc_set_bw(interconnect->path, 0, 0); + ret = icc_disable(interconnect->path); if (ret) { dev_err(dev, "error %d disabling %s interconnect\n", ret, interconnect->name); From patchwork Fri Feb 4 19:50:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12735500 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 697E0C43219 for ; Fri, 4 Feb 2022 19:51:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235055AbiBDTvC (ORCPT ); Fri, 4 Feb 2022 14:51:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231869AbiBDTvA (ORCPT ); Fri, 4 Feb 2022 14:51:00 -0500 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0B70C06174E for ; Fri, 4 Feb 2022 11:50:53 -0800 (PST) Received: by mail-io1-xd2b.google.com with SMTP id q204so8702738iod.8 for ; Fri, 04 Feb 2022 11:50:53 -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=5LJv5iPo5cfeDn7N9X9RNaWuiPsLPljE4VKtBlutQww=; b=EIiV10YUOa0iymNyqqOQm9wimg/uokoVQ8nT6jny2j+KxImXvD8GNpCFnT0VGUGHcM 5yQ0bBj8XCV8YXz4HMf42uUrL+k3FOFll1rXFZ4YdGikX2Y8W1g4tlocwjWu6jicXu3z TuXgW0AhLwRYV3XVJxjunk18tywwyRvw0BcRN6KGnXqbIssyOLU2BGp1iGM2SOz1OTQP zRTSEKsNcFBpwTwEQ6h1dTjfmAHPe3BjZhW5RQWDDDMjYekVq1fE/0CR8oxDIUbNh0ZN vi+VA9nptc5uk5hxU3c+4Hwyy3C/o1eDE0Hkoe3GoVf2Up/tqHjx75KV+GubAAcOcxYT fn8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5LJv5iPo5cfeDn7N9X9RNaWuiPsLPljE4VKtBlutQww=; b=b6GoNuGCOM2E+zswz5VSa2M5DExQHoK3wnVU83mM1KKTgXnX3pt7JDrtsc00t0lvdl gj1SzSf/sxBehaWufzdyFbaewRn1dAnbb7xGGhNBDUhLozxqkNd7pTstmXs/ep0Oqw29 YUTuYlUGdWqu7JeW5wMw/RV++db67KtUQuuBt1s66tJCHsgKyWXP+QvCsLZIearAJRAT I0KNKOQA6lNz8U1TzQZ9nkREh/4d3jwB02D3EhpKQ4oyrn6dI7twHnzootEFhz8On91r VWOMhBinWC/zZXVxKz0ZEYCuTlSa2XjSiX2Pg8JZEbCrACA9C1Kz6fdt/M+G20+FjUMU AAeg== X-Gm-Message-State: AOAM531T/y9Ee6kAGYVLimzpZ1NYLZnrvSy5BgGPK1Q3uckMXa7sjwjd bodCqtRcjHXdESfn1u5/28oFOA== X-Google-Smtp-Source: ABdhPJxrBfbDH5oX3YphnJkdAxIm9RlX5nAnVNUMssOtRR5pjt51YC9wTVHO3xlCUZuEfVfyxbt+pw== X-Received: by 2002:a6b:ef06:: with SMTP id k6mr332289ioh.70.1644004253239; Fri, 04 Feb 2022 11:50:53 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id k13sm1417564ili.22.2022.02.04.11.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 11:50:52 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: djakov@kernel.org, bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/7] net: ipa: use interconnect bulk enable/disable operations Date: Fri, 4 Feb 2022 13:50:40 -0600 Message-Id: <20220204195044.1082026-4-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220204195044.1082026-1-elder@linaro.org> References: <20220204195044.1082026-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The power interconnect array is now an array of icc_bulk_data structures, which is what the interconnect bulk enable and disable functions require. Get rid of ipa_interconnect_enable() and ipa_interconnect_disable(), and just call icc_bulk_enable() and icc_bulk_disable() instead. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_power.c | 76 +++++++------------------------------ 1 file changed, 13 insertions(+), 63 deletions(-) diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c index ec2ebc74edb8b..67f76e6a6ae59 100644 --- a/drivers/net/ipa/ipa_power.c +++ b/drivers/net/ipa/ipa_power.c @@ -156,86 +156,34 @@ static void ipa_interconnect_exit(struct ipa_power *power) power->interconnect = NULL; } -/* Currently we only use one bandwidth level, so just "enable" interconnects */ -static int ipa_interconnect_enable(struct ipa *ipa) -{ - struct icc_bulk_data *interconnect; - struct ipa_power *power = ipa->power; - int ret; - u32 i; - - interconnect = power->interconnect; - for (i = 0; i < power->interconnect_count; i++) { - ret = icc_enable(interconnect->path); - if (ret) { - dev_err(&ipa->pdev->dev, - "error %d enabling %s interconnect\n", - ret, interconnect->name); - goto out_unwind; - } - interconnect++; - } - - return 0; - -out_unwind: - while (interconnect-- > power->interconnect) - (void)icc_disable(interconnect->path); - - return ret; -} - -/* To disable an interconnect, we just its bandwidth to 0 */ -static int ipa_interconnect_disable(struct ipa *ipa) -{ - struct ipa_power *power = ipa->power; - struct device *dev = &ipa->pdev->dev; - struct icc_bulk_data *interconnect; - int result = 0; - u32 count; - int ret; - - count = power->interconnect_count; - interconnect = power->interconnect + count; - while (count--) { - interconnect--; - ret = icc_disable(interconnect->path); - if (ret) { - dev_err(dev, "error %d disabling %s interconnect\n", - ret, interconnect->name); - /* Try to disable all; record only the first error */ - if (!result) - result = ret; - } - } - - return result; -} - /* Enable IPA power, enabling interconnects and the core clock */ static int ipa_power_enable(struct ipa *ipa) { + struct ipa_power *power = ipa->power; int ret; - ret = ipa_interconnect_enable(ipa); + ret = icc_bulk_enable(power->interconnect_count, power->interconnect); if (ret) return ret; - ret = clk_prepare_enable(ipa->power->core); + ret = clk_prepare_enable(power->core); if (ret) { dev_err(&ipa->pdev->dev, "error %d enabling core clock\n", ret); - (void)ipa_interconnect_disable(ipa); + icc_bulk_disable(power->interconnect_count, + power->interconnect); } return ret; } /* Inverse of ipa_power_enable() */ -static int ipa_power_disable(struct ipa *ipa) +static void ipa_power_disable(struct ipa *ipa) { - clk_disable_unprepare(ipa->power->core); + struct ipa_power *power = ipa->power; - return ipa_interconnect_disable(ipa); + clk_disable_unprepare(power->core); + + icc_bulk_disable(power->interconnect_count, power->interconnect); } static int ipa_runtime_suspend(struct device *dev) @@ -249,7 +197,9 @@ static int ipa_runtime_suspend(struct device *dev) gsi_suspend(&ipa->gsi); } - return ipa_power_disable(ipa); + ipa_power_disable(ipa); + + return 0; } static int ipa_runtime_resume(struct device *dev) From patchwork Fri Feb 4 19:50:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12735498 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B884CC433F5 for ; Fri, 4 Feb 2022 19:51:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234990AbiBDTvB (ORCPT ); Fri, 4 Feb 2022 14:51:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234931AbiBDTvA (ORCPT ); Fri, 4 Feb 2022 14:51:00 -0500 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39A8CC06173E for ; Fri, 4 Feb 2022 11:50:55 -0800 (PST) Received: by mail-il1-x12e.google.com with SMTP id x6so5730062ilg.9 for ; Fri, 04 Feb 2022 11:50:55 -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=pUf+PCh+TXxcthO6K+0yXDdvKrWCHt/PS/ocodABFUM=; b=XYtFs0GAaPChPsV6fugdX3/KwPRFUc7fOhot7UWWhNBTABRBq//tRQEJ5PJqKM+dXd ZOKUNXyqq2NoXhf8k63H+ChbhiHrBo3gScX2+edBqDtlsbFnxoXmTbZkGG6tH2TG59hg 1gKBvw3ylB9gmGBrL+viDL/xP7Wg2RHAP/IsXqy8CQkEEIY+DF5+Ne0UKmO43Pq6kzeT Dl3cKBeM+XRtkNWBqtqYV/hBKv4ybraJRIoaL+HDVQGxBnJhWxYV63jMrYlgp6N1TQ7D BoRBFZuuMHrSmDSzIJZKFDXUgkGA6uk/2PIcr6seUJYSE/9Eyl8r8NBrGsUV+fFRGVDJ VsCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pUf+PCh+TXxcthO6K+0yXDdvKrWCHt/PS/ocodABFUM=; b=mkDRk+I8of3GZIRILJXLFdzC619wwhcq2a35dWB79o4SJ8AcqWGRZ+XqxL67Jp4snt dE6OjTfUSpax4yuqXAEfQGolAQop3sMuqOTY3X/lPgnPooTm3baTczTKrQ6j2XF+pjRV xG4WjnOD1fkKngFRnGhwFLrMibwKNRSkyiIX48qFke2VTJOKqLR3f5q+pOa9dHqrGwAv tVe3evmgS7cYYapneuh7mdSWKWmO2CUda0V5y0tJr4xSheMTWr8w0t6JtH6KyxrdA3rK 1MJEUoRj/PiUSqpntpjfpH29TQnZxQ2ZLIF6oJuTpZZLALO9iAEi23hcZxWfebZjcZdQ lo+Q== X-Gm-Message-State: AOAM531BQ/v8HPvpCivPMG2o2gHjSarwAuuP44n0f1F7n5YUU+tz+AM7 rxag05R5T1cbsm4ke6QqZZuGlw== X-Google-Smtp-Source: ABdhPJzPP2eOSeqCq6tU4c6HCqyIwDVGReJxWNvlCRO8Aksx0W0xi+fITf+26isG5S/B1za8BKGktg== X-Received: by 2002:a05:6e02:1c8f:: with SMTP id w15mr359448ill.103.1644004254584; Fri, 04 Feb 2022 11:50:54 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id k13sm1417564ili.22.2022.02.04.11.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 11:50:54 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: djakov@kernel.org, bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/7] net: ipa: use bulk operations to set up interconnects Date: Fri, 4 Feb 2022 13:50:41 -0600 Message-Id: <20220204195044.1082026-5-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220204195044.1082026-1-elder@linaro.org> References: <20220204195044.1082026-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Use of_icc_bulk_get() and icc_bulk_put(), icc_bulk_set_bw(), and icc_bulk_enable() and icc_bulk_disable() to initialize individual IPA interconnects. Those functions already log messages in the event of error so we don't need to. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_power.c | 40 ++++++++++++++----------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c index 67f76e6a6ae59..c0da1274f5d67 100644 --- a/drivers/net/ipa/ipa_power.c +++ b/drivers/net/ipa/ipa_power.c @@ -74,41 +74,31 @@ static int ipa_interconnect_init_one(struct device *dev, struct icc_bulk_data *interconnect, const struct ipa_interconnect_data *data) { - struct icc_path *path; int ret; - path = of_icc_get(dev, data->name); - if (IS_ERR(path)) { - ret = PTR_ERR(path); - dev_err_probe(dev, ret, "error getting %s interconnect\n", - data->name); - - return ret; - } - - /* All interconnects are initially disabled */ - (void)icc_disable(path); - - /* Set the bandwidth values to be used when enabled */ - ret = icc_set_bw(path, data->average_bandwidth, data->peak_bandwidth); - if (ret) { - dev_err(dev, "error %d setting %s interconnect bandwidths\n", - ret, data->name); - - return ret; - } - - interconnect->path = path; + /* interconnect->path is filled in by of_icc_bulk_get() */ interconnect->name = data->name; interconnect->avg_bw = data->average_bandwidth; interconnect->peak_bw = data->peak_bandwidth; - return 0; + ret = of_icc_bulk_get(dev, 1, interconnect); + if (ret) + return ret; + + /* All interconnects are initially disabled */ + icc_bulk_disable(1, interconnect); + + /* Set the bandwidth values to be used when enabled */ + ret = icc_bulk_set_bw(1, interconnect); + if (ret) + icc_bulk_put(1, interconnect); + + return ret; } static void ipa_interconnect_exit_one(struct icc_bulk_data *interconnect) { - icc_put(interconnect->path); + icc_bulk_put(1, interconnect); memset(interconnect, 0, sizeof(*interconnect)); } From patchwork Fri Feb 4 19:50:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12735499 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB5E0C43217 for ; Fri, 4 Feb 2022 19:51:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234884AbiBDTvC (ORCPT ); Fri, 4 Feb 2022 14:51:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234945AbiBDTvA (ORCPT ); Fri, 4 Feb 2022 14:51:00 -0500 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AAD3C061755 for ; Fri, 4 Feb 2022 11:50:56 -0800 (PST) Received: by mail-io1-xd34.google.com with SMTP id e79so8642293iof.13 for ; Fri, 04 Feb 2022 11:50:56 -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=kmF/moFaP2vIu3wyyPlPwTNgQVyw6cgxTUQxtgkWdeo=; b=t5BfgawT/Wi7BmrdzbQR8QJ+QBreob1GlKCLwZgqgf1bRGhvxIC96l1yYniIAJJOvr RojhGZHINyxfRZUofCo5qxAutycDc6s0FTMi2j8aZQpGWIJY77vzqX5GGb0LYnjCRCp+ G4C2CfCwJ49OfMY8jBde4zjpjcgzUQ862CJfRyXrofRs5uXXbs9ka0A2jNh1bsKnw/wI VIxwlcO5njztQsVeiI/UF2llVsZ4C3qelhUT0ZsHnPp7JIFKHcNZBZGeDX8/Hd1olUKb MhBd4joG/lOC0yHP0uPVlqFkaN4EXj4wNuTwJG90Nz41DSEnZMUZOAspV5MQUygbOoQ5 46gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kmF/moFaP2vIu3wyyPlPwTNgQVyw6cgxTUQxtgkWdeo=; b=0ZEjQ1ODP76R/WqvnkYZqZ6jhs2lJDq7saHISKVz4L643SHZ4r/PceVv/+VUHSEYPP sLzTwRxPY1Sf7AksVfV+k1UC8G6+x0PH/zVGVw4JAt6tB7p8OM93ePk1uYw4bhkINZfq x9FXDeEoTGXBzaRJoSCGDvLuyP572lemTyYRc6zMBJHLwqVhEHl16Zon/dz38t62eT1x ISjGjv2TgEHcrk+2SBYC0PPy/21JYSKNqKk4usvVY928nQDGAmUVfqX8WkT9ipnvenod PTJ/XAYoV1clJ1d7eQXnvGBXamyfugJKko/MkV+5QugcWI5b1hvghlYiDWjkPo0EEyiy Q9Cw== X-Gm-Message-State: AOAM531V6u7aGE8ms0I+ljL3x6i86dIpYAll/ifaKpCcBd6QAC3BGTvz UdYpMFRP4L0N8LhCjVRUssXVfg== X-Google-Smtp-Source: ABdhPJxZOI7fkns7Bw4xQje93fgOz8XkJ6mRP3Npz85CJMRQOrUd35T3uQximAJItlvsrQkXLclU+Q== X-Received: by 2002:a05:6638:379c:: with SMTP id w28mr326787jal.275.1644004255938; Fri, 04 Feb 2022 11:50:55 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id k13sm1417564ili.22.2022.02.04.11.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 11:50:55 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: djakov@kernel.org, bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 5/7] net: ipa: use bulk interconnect initialization Date: Fri, 4 Feb 2022 13:50:42 -0600 Message-Id: <20220204195044.1082026-6-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220204195044.1082026-1-elder@linaro.org> References: <20220204195044.1082026-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The previous patch used bulk interconnect operations to initialize IPA interconnects one at a time. This rearranges things to use the bulk interfaces as intended--on all interconnects together. As a result ipa_interconnect_init_one() and ipa_interconnect_exit_one() are no longer needed. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_power.c | 66 +++++++++++++------------------------ 1 file changed, 23 insertions(+), 43 deletions(-) diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c index c0da1274f5d67..b1f6978dddadb 100644 --- a/drivers/net/ipa/ipa_power.c +++ b/drivers/net/ipa/ipa_power.c @@ -70,38 +70,6 @@ struct ipa_power { struct icc_bulk_data *interconnect; }; -static int ipa_interconnect_init_one(struct device *dev, - struct icc_bulk_data *interconnect, - const struct ipa_interconnect_data *data) -{ - int ret; - - /* interconnect->path is filled in by of_icc_bulk_get() */ - interconnect->name = data->name; - interconnect->avg_bw = data->average_bandwidth; - interconnect->peak_bw = data->peak_bandwidth; - - ret = of_icc_bulk_get(dev, 1, interconnect); - if (ret) - return ret; - - /* All interconnects are initially disabled */ - icc_bulk_disable(1, interconnect); - - /* Set the bandwidth values to be used when enabled */ - ret = icc_bulk_set_bw(1, interconnect); - if (ret) - icc_bulk_put(1, interconnect); - - return ret; -} - -static void ipa_interconnect_exit_one(struct icc_bulk_data *interconnect) -{ - icc_bulk_put(1, interconnect); - memset(interconnect, 0, sizeof(*interconnect)); -} - /* Initialize interconnects required for IPA operation */ static int ipa_interconnect_init(struct ipa_power *power, struct device *dev, const struct ipa_interconnect_data *data) @@ -116,18 +84,34 @@ static int ipa_interconnect_init(struct ipa_power *power, struct device *dev, return -ENOMEM; power->interconnect = interconnect; + /* Initialize our interconnect data array for bulk operations */ while (count--) { - ret = ipa_interconnect_init_one(dev, interconnect, data++); - if (ret) - goto out_unwind; + /* interconnect->path is filled in by of_icc_bulk_get() */ + interconnect->name = data->name; + interconnect->avg_bw = data->average_bandwidth; + interconnect->peak_bw = data->peak_bandwidth; + data++; interconnect++; } + ret = of_icc_bulk_get(dev, power->interconnect_count, + power->interconnect); + if (ret) + goto err_free; + + /* All interconnects are initially disabled */ + icc_bulk_disable(power->interconnect_count, power->interconnect); + + /* Set the bandwidth values to be used when enabled */ + ret = icc_bulk_set_bw(power->interconnect_count, power->interconnect); + if (ret) + goto err_bulk_put; + return 0; -out_unwind: - while (interconnect-- > power->interconnect) - ipa_interconnect_exit_one(interconnect); +err_bulk_put: + icc_bulk_put(power->interconnect_count, power->interconnect); +err_free: kfree(power->interconnect); power->interconnect = NULL; @@ -137,11 +121,7 @@ static int ipa_interconnect_init(struct ipa_power *power, struct device *dev, /* Inverse of ipa_interconnect_init() */ static void ipa_interconnect_exit(struct ipa_power *power) { - struct icc_bulk_data *interconnect; - - interconnect = power->interconnect + power->interconnect_count; - while (interconnect-- > power->interconnect) - ipa_interconnect_exit_one(interconnect); + icc_bulk_put(power->interconnect_count, power->interconnect); kfree(power->interconnect); power->interconnect = NULL; } From patchwork Fri Feb 4 19:50:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12735502 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1120C433EF for ; Fri, 4 Feb 2022 19:51:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234926AbiBDTvG (ORCPT ); Fri, 4 Feb 2022 14:51:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234852AbiBDTvB (ORCPT ); Fri, 4 Feb 2022 14:51:01 -0500 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 005A4C06175A for ; Fri, 4 Feb 2022 11:50:57 -0800 (PST) Received: by mail-il1-x134.google.com with SMTP id z18so5771971ilp.3 for ; Fri, 04 Feb 2022 11:50:57 -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=d9+lLIbQQk6sLGoYu7PiXuh09aVQl9bHmfYbzTffMYE=; b=UW9iwpf9Z8Um162Z1+cdMye4SLMCbwHQaxbF5+QZIxIz9PQm1RsHVJ2uDepNrIzCXU 6gXHVa+T6+fcWL4Vq+fx5SXkAftmSR8hVcAMxYZtKaNcDbGQRtcYX1ASqP69mk7geYev dPtoqgJYvXaqePLJoCPPAvpI1vh3tsucDSdqpNAaCkCiqfOvzd9BwysNt/LTofz+QU0e tFTRiaeMnd/SLYcGmRa36BMTAEMVnLwcM/HlfNKK6RkW5RIo8ytuXIVS0fhDO5ZjRHNo FjjRk7jxYVIL0+Q3XXooX327uIo4Jpy/3Jva6lXm7YfSqKnGqDfdVaW6TqIlZ+jVFCnZ URlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d9+lLIbQQk6sLGoYu7PiXuh09aVQl9bHmfYbzTffMYE=; b=Op8W91bv7c1/3r2HdEC21mbX8v74MsTdfcZ2n0Jq2LJ58rU9O+t++7YdYl+7rSSl0i nrayDBwZ2sQCbCmFWel8DwV8ShUfQnEzCYlnpOsLWodCVz0yxMrYGgH9I2JTO8+/7dji XL6/OYNyHjsk2Mk6s/tHOahHX3glaNaUE5Dq/vt6egjvbyJsBO0gaeC8U/E3L+nBLKH0 ikC7y0TMRPySP0eO+c8dtf8AqP8e9MdD6IxXmXtccLFmCTm1du2ioUAdbZ7pYO4OCIAg v6HWU6Xs+NaiITD3aHF3kTLg9mheQ58qtZsZExZ0sqILBQhB53OOaEk2DM7tJZrsOawf nvMQ== X-Gm-Message-State: AOAM533A7yaz3rit0LKte3qa86aYcT1YqUbXG8P1+LSYDmVlJ0usiHhq xbrvq1K6JxX/uJ445JD4OrhR4Q== X-Google-Smtp-Source: ABdhPJxTqGwwgi18qKr7zXKCfAt8SrlpDioemQ93R/nHSxgtRR7KCCYjsG0cqq80VcTS8ddJe+SLuQ== X-Received: by 2002:a05:6e02:170c:: with SMTP id u12mr360045ill.135.1644004257334; Fri, 04 Feb 2022 11:50:57 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id k13sm1417564ili.22.2022.02.04.11.50.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 11:50:56 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: djakov@kernel.org, bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 6/7] net: ipa: embed interconnect array in the power structure Date: Fri, 4 Feb 2022 13:50:43 -0600 Message-Id: <20220204195044.1082026-7-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220204195044.1082026-1-elder@linaro.org> References: <20220204195044.1082026-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Rather than allocating the interconnect array dynamically, represent the interconnects with a variable-length array at the end of the ipa_power structure. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_power.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c index b1f6978dddadb..8a564d72799da 100644 --- a/drivers/net/ipa/ipa_power.c +++ b/drivers/net/ipa/ipa_power.c @@ -67,7 +67,7 @@ struct ipa_power { spinlock_t spinlock; /* used with STOPPED/STARTED power flags */ DECLARE_BITMAP(flags, IPA_POWER_FLAG_COUNT); u32 interconnect_count; - struct icc_bulk_data *interconnect; + struct icc_bulk_data interconnect[]; }; /* Initialize interconnects required for IPA operation */ @@ -75,17 +75,12 @@ static int ipa_interconnect_init(struct ipa_power *power, struct device *dev, const struct ipa_interconnect_data *data) { struct icc_bulk_data *interconnect; - u32 count; int ret; - - count = power->interconnect_count; - interconnect = kcalloc(count, sizeof(*interconnect), GFP_KERNEL); - if (!interconnect) - return -ENOMEM; - power->interconnect = interconnect; + u32 i; /* Initialize our interconnect data array for bulk operations */ - while (count--) { + interconnect = &power->interconnect[0]; + for (i = 0; i < power->interconnect_count; i++) { /* interconnect->path is filled in by of_icc_bulk_get() */ interconnect->name = data->name; interconnect->avg_bw = data->average_bandwidth; @@ -97,7 +92,7 @@ static int ipa_interconnect_init(struct ipa_power *power, struct device *dev, ret = of_icc_bulk_get(dev, power->interconnect_count, power->interconnect); if (ret) - goto err_free; + return ret; /* All interconnects are initially disabled */ icc_bulk_disable(power->interconnect_count, power->interconnect); @@ -105,15 +100,7 @@ static int ipa_interconnect_init(struct ipa_power *power, struct device *dev, /* Set the bandwidth values to be used when enabled */ ret = icc_bulk_set_bw(power->interconnect_count, power->interconnect); if (ret) - goto err_bulk_put; - - return 0; - -err_bulk_put: - icc_bulk_put(power->interconnect_count, power->interconnect); -err_free: - kfree(power->interconnect); - power->interconnect = NULL; + icc_bulk_put(power->interconnect_count, power->interconnect); return ret; } @@ -122,8 +109,6 @@ static int ipa_interconnect_init(struct ipa_power *power, struct device *dev, static void ipa_interconnect_exit(struct ipa_power *power) { icc_bulk_put(power->interconnect_count, power->interconnect); - kfree(power->interconnect); - power->interconnect = NULL; } /* Enable IPA power, enabling interconnects and the core clock */ @@ -372,6 +357,7 @@ ipa_power_init(struct device *dev, const struct ipa_power_data *data) { struct ipa_power *power; struct clk *clk; + size_t size; int ret; clk = clk_get(dev, "core"); @@ -388,7 +374,8 @@ ipa_power_init(struct device *dev, const struct ipa_power_data *data) goto err_clk_put; } - power = kzalloc(sizeof(*power), GFP_KERNEL); + size = data->interconnect_count * sizeof(power->interconnect[0]); + power = kzalloc(sizeof(*power) + size, GFP_KERNEL); if (!power) { ret = -ENOMEM; goto err_clk_put; From patchwork Fri Feb 4 19:50:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12735504 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DBCFC433FE for ; Fri, 4 Feb 2022 19:51:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235383AbiBDTvJ (ORCPT ); Fri, 4 Feb 2022 14:51:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235033AbiBDTvC (ORCPT ); Fri, 4 Feb 2022 14:51:02 -0500 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55512C06175F for ; Fri, 4 Feb 2022 11:50:59 -0800 (PST) Received: by mail-il1-x12a.google.com with SMTP id z7so5744958ilb.6 for ; Fri, 04 Feb 2022 11:50: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=Q42zjW8xahSVhGaNilfnj63EHK+Wikk3dCoDovWBQQY=; b=Fqu8+ypIkgxeVioleBdx7cz2kzcNe89AS6NsggXAOlU1Ts4IPADKZ7XQeqdEbNyf89 SAwWXPLyU9ULlM70bsTCwyoO4AYCOLi9/eUmNITJ8VrsmKVKrxSjiJqvPtseykw4EZcI 7i8RqubLHz8YGtUo1UHLJKtlFDeKXKdw9yb2FasbkTYh78guITuK5WoEem40G8WTdxNI N2ZTPzSdf0zgrNKA7v4PckXQhcoazag/+YBMSZrJJ51D1Yj4DXi3d3/mwjcQ34YFtLul GJRRg3fl06CGSyOoSnuyNX5UWetE1yfvt15CEfeAHhUtgBC2UVyjdv2AnnMPDzCd61Vc tpSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q42zjW8xahSVhGaNilfnj63EHK+Wikk3dCoDovWBQQY=; b=wSIe/YQAOJGZwlSgUBsFRcpEdUhDCWkgOr7e72HsHfDoJYLsO9hFfggtqh4/0hqDK7 4JS/S6EAQUn8C4okP9m6qQR1GyjBi0LI3dX8eiephHm5BNaDolqej7isbHKqSHdfP499 tbZPxqgRZ0hqWu2Tl6Dr6XI7qLm7uzU4009XT8y8tKo9P9+7XOnhq8v0eMy/iBFU3YRr TD3XbqTP/PtxluSzMYpccYUq1tXF0jGyxLSz/1e7yW2vTmcCFVr4ZwJhHRJhkHJ0r7om SyR5NTUyLsDjYG35jDHoJHJpGJgM0yWSqNQE3SNOG/0WxeQSjUOgiEwkzhhqkNY9q1fX +eKA== X-Gm-Message-State: AOAM530pmgDndych63WHdfgLNPtzsi7fjQZy6VIkQ0ptC5X6vmy33WJp a/GkG3V+hl9wet9Lu+xkRlGVgg== X-Google-Smtp-Source: ABdhPJwifcbLNOdRURW/rAIAn/Qb8lZQb1jM5cBMyOnP8fsp1/pvuwPkQuyCiwRCNj/Yx2I45RV8vQ== X-Received: by 2002:a92:c569:: with SMTP id b9mr374353ilj.140.1644004258743; Fri, 04 Feb 2022 11:50:58 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id k13sm1417564ili.22.2022.02.04.11.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 11:50:58 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: djakov@kernel.org, bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 7/7] net: ipa: use IPA power device pointer Date: Fri, 4 Feb 2022 13:50:44 -0600 Message-Id: <20220204195044.1082026-8-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220204195044.1082026-1-elder@linaro.org> References: <20220204195044.1082026-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The ipa_power structure contains a copy of the IPA device pointer, so there's no need to pass it to ipa_interconnect_init(). We can also use that pointer for an error message in ipa_power_enable(). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_power.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c index 8a564d72799da..16ece27d14d7e 100644 --- a/drivers/net/ipa/ipa_power.c +++ b/drivers/net/ipa/ipa_power.c @@ -71,7 +71,7 @@ struct ipa_power { }; /* Initialize interconnects required for IPA operation */ -static int ipa_interconnect_init(struct ipa_power *power, struct device *dev, +static int ipa_interconnect_init(struct ipa_power *power, const struct ipa_interconnect_data *data) { struct icc_bulk_data *interconnect; @@ -89,7 +89,7 @@ static int ipa_interconnect_init(struct ipa_power *power, struct device *dev, interconnect++; } - ret = of_icc_bulk_get(dev, power->interconnect_count, + ret = of_icc_bulk_get(power->dev, power->interconnect_count, power->interconnect); if (ret) return ret; @@ -123,7 +123,7 @@ static int ipa_power_enable(struct ipa *ipa) ret = clk_prepare_enable(power->core); if (ret) { - dev_err(&ipa->pdev->dev, "error %d enabling core clock\n", ret); + dev_err(power->dev, "error %d enabling core clock\n", ret); icc_bulk_disable(power->interconnect_count, power->interconnect); } @@ -385,7 +385,7 @@ ipa_power_init(struct device *dev, const struct ipa_power_data *data) spin_lock_init(&power->spinlock); power->interconnect_count = data->interconnect_count; - ret = ipa_interconnect_init(power, dev, data->interconnect_data); + ret = ipa_interconnect_init(power, data->interconnect_data); if (ret) goto err_kfree;