From patchwork Wed Mar 9 19:20:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 550812 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 EB85BC4332F for ; Wed, 9 Mar 2022 19:20:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237586AbiCITVo (ORCPT ); Wed, 9 Mar 2022 14:21:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235339AbiCITVn (ORCPT ); Wed, 9 Mar 2022 14:21:43 -0500 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8265D12AF6 for ; Wed, 9 Mar 2022 11:20:44 -0800 (PST) Received: by mail-io1-xd30.google.com with SMTP id q11so3930850iod.6 for ; Wed, 09 Mar 2022 11:20:44 -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=E+A3m3Df2XZeF4WfA5W7GVhkpFgmg9kxaclocllYJcx2vNHTjcPe6dECAze201rv3s YKsGo/s2UfGIUfjwSrZWVks0rBMVTwR8hwy3jOWFhPEBDHLqDS1TmB5YK9C/MRXDKnBP AsyuckYzkQfZUJLCYzTuJiuUO/KSc57TButhaa+4XDLz0OwXKdKZCgmfFzNZ6mBFz9Fn 6GEJHrm+dUebenr/vmRH3kbAhnVKLHKX+9P9rKi4R5Vg+5fhW8/ze0hmTpO0Vzmvw81t RlxUDm/vik2EVXVJ5BSCcJ0hd4PGgAP2fU6IiClUept58mY0xC80hfYC7QzLmOc+7e67 wYXA== 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=g+w70F3t51cow/SCddYjEuLm8Xbp87OJ4LnQ/pVDPp3tuCBoNDaCdf5dyZilKxWrpD To9QlnQ4pxssfxnPp8vST/dDseli+cgT9KCRpShVFrIojqJ/ADoF1P/V7Ucq5P0I3aYd /poqCDeLezr6LzNyY4B3X1U6/azcXlwxfWsn1u8jGnYFdnU+fxk4y3u3NIoC9Hf43Xam jRE4fpdK7DuCSTJSbei8fP9ZR92fkBtFaTnm6FE2u3PJMtiSqs0QP0URz9aTvxg2VYsS XM00gXwRDtIPh7TDzJtx6jj855OzAaaZFNV50dXCLbiciljXNCmpTnm6q6i93JpJCNvV JD8A== X-Gm-Message-State: AOAM533PcMILfl8gtW2jt/M222Sbmw5fg97ylk/6tNxztD7NTHITXm+A zeIG5bs/mi6jTgTNzcmtUk66QpfRhBnrI/Nz X-Google-Smtp-Source: ABdhPJyzWkE0R4hdkxEKhIFmAMfHP6yTrmf7JfNf0/fXQz62F1a9csVpdC6JulbEzbMuZOvpfNJsVQ== X-Received: by 2002:a02:a690:0:b0:319:aed8:5d3 with SMTP id j16-20020a02a690000000b00319aed805d3mr418916jam.102.1646853643958; Wed, 09 Mar 2022 11:20:43 -0800 (PST) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id g8-20020a056602248800b006409fb2cbccsm1389182ioe.32.2022.03.09.11.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 11:20:43 -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 v2 1/7] net: ipa: kill struct ipa_interconnect Date: Wed, 9 Mar 2022 13:20:31 -0600 Message-Id: <20220309192037.667879-2-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220309192037.667879-1-elder@linaro.org> References: <20220309192037.667879-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 Wed Mar 9 19:20:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 549801 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 C0C80C433FE for ; Wed, 9 Mar 2022 19:20:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237632AbiCITVq (ORCPT ); Wed, 9 Mar 2022 14:21:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237602AbiCITVq (ORCPT ); Wed, 9 Mar 2022 14:21:46 -0500 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17CB212AF6 for ; Wed, 9 Mar 2022 11:20:46 -0800 (PST) Received: by mail-io1-xd2d.google.com with SMTP id w7so3940582ioj.5 for ; Wed, 09 Mar 2022 11:20:46 -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=lr5I8zByPz9LAOpeoXVbxybe1QruJW8EpJropdUrJuu0WldcfKYP8iVlQf/kVpn3qM JLMCZhM5YWGHs9JhkfaNDPB0Wh/InyGDfY5gvkJVTl89Cl9pez+/WP13crgcmHQABaFE mKc7VsQdY2Y9K6i31Sn2L08dXT3afAfKSNvmX5v8p8ihVaUxxojl+3+n2J/rO+L/q0P4 8o8tquGxi4+SpWjTZev66LdssgH6Qytsjizbk0Yp4ekw5OSq1WPf2m+KiTJREHVxVB8m 8Bj3tJ5gAz4/1pNM+Zq4o3FZDz+VSWIuryMHtKM3/+Mln9vbhR9PmFkzYZ7xB9Ytd+by EkQg== 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=56ayE8AnbganLoKfE8s3fT5Asa0fTAWSwQWCjfgxteRr63H0hxFHFA/wBIm1C/keP1 Pzjm3chD05AOErIxXIubvc9ldxBo+Yd/OMFp5fnHXPtfyTLXVWa13MSEHr6b5DqKt+o5 jIv0qO1i0ZSazHHPObhymQC0MJAKQq+jGZSDaQaN2niw2LV8zUB4slYkdaPJbw9NpTFj Kw6nkOoU9A/NpUmJgubO+qjD6nv5g+3ni1okq7x1K/sjeO7gk/ypQw2h/S/1ArE0R2VA PaK2y5qJ1icGOFAJF51tkg7E5sapECPTXTU6pv1hCPQ1n2XCsi6zSmEIJ9bs+15evnnD 0RcA== X-Gm-Message-State: AOAM530+M3dmpyY12Ixx8cwWhm8by5XRbQwTet5GzZZJCTv7F2L9l8WN 2vj69mwMSDIaHP5Es+wYPm+lpQ== X-Google-Smtp-Source: ABdhPJxSclbwA49r0YgPolsFP2X0A5/blFUbhDuhfW68UIesorjTvLCLm2kBfhX50RFHem9OcUHkXg== X-Received: by 2002:a05:6638:737:b0:317:d5e0:2b3a with SMTP id j23-20020a056638073700b00317d5e02b3amr837873jad.52.1646853645502; Wed, 09 Mar 2022 11:20:45 -0800 (PST) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id g8-20020a056602248800b006409fb2cbccsm1389182ioe.32.2022.03.09.11.20.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 11:20:44 -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 v2 2/7] net: ipa: use icc_enable() and icc_disable() Date: Wed, 9 Mar 2022 13:20:32 -0600 Message-Id: <20220309192037.667879-3-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220309192037.667879-1-elder@linaro.org> References: <20220309192037.667879-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 Wed Mar 9 19:20:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 550811 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 CCAAAC433F5 for ; Wed, 9 Mar 2022 19:20:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236497AbiCITVx (ORCPT ); Wed, 9 Mar 2022 14:21:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237621AbiCITVq (ORCPT ); Wed, 9 Mar 2022 14:21:46 -0500 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BF2B4BFCD for ; Wed, 9 Mar 2022 11:20:47 -0800 (PST) Received: by mail-io1-xd2c.google.com with SMTP id s20so3935502iol.2 for ; Wed, 09 Mar 2022 11:20:47 -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=qUG4z67OgiA7yzlxO55VgCWHFSXjrPoIKNgGXxYJ/EVfCiZ/4lWOp2CUjfNf4WQp5S fXJM3hjdPwRo7p0Q0ZONBqdzmRzwOGSab1iSgR9OjqvGURMOX5x3uvC/UBGt+LknkkIN uTJ+63ldQRGqztu2jEaw6/mbfSy/bpnuKLulPjrjUCso/TveswO5jzLsyEh4iEHS+cbl DK36rdqE8XBQUUiiNROVraobvyxQ54lCaXvcFjW+1jYufM/atPgI3sU88ruYK1bYyDKe CbL+g0mWfiRk9I75XK0dOnOGbDLGsyQM9M9eOpSptMnoW1viVj+tTgcqdPppjpsWKbGC qjpw== 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=cZSJF6Z6rkhgYB/WvgHjpvuv1adk2SIKrNZ8HoVd1j4yZ39LTMsF6IDrdqmSd64z+E +xvPRjDgIsuarV/NJU82cCL8WtVz4vN+Gq6ZoGeCwoTCUhWlboGAv2EjUJf9iMaqJk8M yR3ODARRuKZ+4NQoBu7kETBjSnHl+ucZWaDBvmD2V75afIkiqOx3kgMZ19Xr9Z2f5OcB QEjdoJdnDETxGbZTHi+cJwO2tNDzo4UnRAtRD3oNMPOfomnNKmkLtBojMcWrZxmED2oO 3k6jNro1hvZjqmUiBnog7SbneNDqYmi6oGH3YweuDAKWK+8xWRggjZszpcO0XHqMRAtG Y1Zg== X-Gm-Message-State: AOAM530zLFz4KdlFiesKA+XOWZ2hcwj0+ezh+jts7z7JP0RahwyPFTtx v9MZy58S5Qe/TBxRZe+k6Al/fLHEG3kninag X-Google-Smtp-Source: ABdhPJypAzVHZp5TOnYfcOxSKC9WT14z03V42SUGheb2MUrkUPWSJ6B6vfme8jgq3tNBlWgFpg62pQ== X-Received: by 2002:a02:cadb:0:b0:317:b785:8ab2 with SMTP id f27-20020a02cadb000000b00317b7858ab2mr894264jap.108.1646853646899; Wed, 09 Mar 2022 11:20:46 -0800 (PST) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id g8-20020a056602248800b006409fb2cbccsm1389182ioe.32.2022.03.09.11.20.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 11:20:46 -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 v2 3/7] net: ipa: use interconnect bulk enable/disable operations Date: Wed, 9 Mar 2022 13:20:33 -0600 Message-Id: <20220309192037.667879-4-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220309192037.667879-1-elder@linaro.org> References: <20220309192037.667879-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 Wed Mar 9 19:20:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 550810 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 59967C4332F for ; Wed, 9 Mar 2022 19:21:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237666AbiCITWF (ORCPT ); Wed, 9 Mar 2022 14:22:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237637AbiCITVv (ORCPT ); Wed, 9 Mar 2022 14:21:51 -0500 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05702E3899 for ; Wed, 9 Mar 2022 11:20:49 -0800 (PST) Received: by mail-il1-x131.google.com with SMTP id p2so2226961ile.2 for ; Wed, 09 Mar 2022 11:20:48 -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=GA3KQO1Nq0kyV/Mi7GuCK7h8MmlammulbUBRp4xzRhvCpi71Bfai4rpPpMAu8jvUD8 07xyICOHtOfF7axjufEUa9zLkcGWNkYvmWtlpCcJ5zmQQO8ayejYNhmi87TZhKVrK6IQ YB2jEUTSStLZTQzArOeCST2NhG1X85q+cIrPrJsdUlhsjABnrt/bU5UBVEeVXaHMb7Lg 9AxjJx49MZRJqkK1XMWFEDTUnyhPS7CEB1a6P/1MNOxl8sB7Y2NYADIU+3KmeYLrw3U2 1Ycd71yJWnBa3mp/kFx6iWTuTKnp+lNi58ByupiFMFlrvkdKWh3nt0ucKR3NTD9MVR2U eK6A== 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=ZRf0QuRMlH6h2pxXhTP+VPoPa1swaGd6g63Be0Qm+A2nn4PjrcKKL7gh7ScObMwK+O Mh0SBDmwDwCvp3wlD1uACD1MmITylNGDT2tISQE5sDcRJc5oomu2nfro3fnIQDOU4Wm2 pfa5YiIXlvgEi32E7R/awhl88sh7UJr1vcoqprESIo7kkkUvG8bvdp+UQCVlUTr6jL99 nhU9EqYNQXErzJHoivGyCus1aag+iqX+UAdZna51LGvMDjxzBJGVjzsKugMkbV1F8Tpn AIBG6i5sSYuPvadddcz9/iH4/RJfCyalxYWRVXPmiJK1YlLmMZJ5MAeOfjsa593hqkQ9 KjBg== X-Gm-Message-State: AOAM530nkBCl6JzRLbFeY0SgPCWhkRIh9OlICZ56tTKDQfhbsDr6tM30 JjEFke7DzQCqrDcFXbQb+SYF7w== X-Google-Smtp-Source: ABdhPJx1tlCe2qOGZf2mcNfYUL1GNSootybI9yjcmDZ0v4iOgD8NqiU2YY2mHB5pfHwAovrHB0Z6ow== X-Received: by 2002:a05:6e02:1beb:b0:2bf:eed2:cd93 with SMTP id y11-20020a056e021beb00b002bfeed2cd93mr735844ilv.99.1646853648308; Wed, 09 Mar 2022 11:20:48 -0800 (PST) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id g8-20020a056602248800b006409fb2cbccsm1389182ioe.32.2022.03.09.11.20.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 11:20:47 -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 v2 4/7] net: ipa: use bulk operations to set up interconnects Date: Wed, 9 Mar 2022 13:20:34 -0600 Message-Id: <20220309192037.667879-5-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220309192037.667879-1-elder@linaro.org> References: <20220309192037.667879-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 Wed Mar 9 19:20:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 549800 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 435A1C433EF for ; Wed, 9 Mar 2022 19:21:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237661AbiCITWF (ORCPT ); Wed, 9 Mar 2022 14:22:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236688AbiCITVw (ORCPT ); Wed, 9 Mar 2022 14:21:52 -0500 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84B4EF68F9 for ; Wed, 9 Mar 2022 11:20:50 -0800 (PST) Received: by mail-il1-x129.google.com with SMTP id b7so1198050ilm.12 for ; Wed, 09 Mar 2022 11:20:50 -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=tZQL42LMw7w8qEoQcgr/zFzmySjiweyFNh4ph819TAVXx1+OsZuq2+ZApoTwXoYSnj oHyAumuKdNS1V9uoLZ0FMpitmvSHy5bUpKwUIpCeLWDNwTkrdcBgiD5UXIxo3gS460V5 0Cdwbg4W6y53NYQdwmVJOCxhlLATTFfEnlgmiGfXLMm6u5pbrzYEZKdArA52pjZBqheU huFXMXcW0e0JlNrjsI455N5hNFzHSMlFmEaEdSsE753r2MIIyoDsAT4nWuMNOgD0p8HU +0aDommrpl9rOZc+uJCqvMEmTn0zu3GoR8WxmyJtIGOxbLc9qfRXkALfU8Ko3oSBXWfM gTLA== 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=Q12MUnluoTz3WS6UtTYFvibBeZtK5zpux8URWiGhnx828YEjfhfC1wB3NJZZAHatZW QPNZgbzN0rZ4dhhoLEt0KLdu8T/KMOVFQ80yTVfiF1IcVSJPMGY6HSADMH1iVXICoHAS 2ky7MBipaTWY0Xt3iWlXVhF6hncDudVxUbZjFLcYDQAxGZKMlPQKncMSsGDkKotYttFz JG8TEaHQE7ryQAlnMxDgbaZIOC1ZNM8/m5PtZhsWhz/7H3XMgv7wSpzngzKokMsdl/bK QJB9GA9PoZYLwrHN+uAnA35bgt0mzXaXyIUpxjIlPI138dKZzV1QA1iMwZqiCsIKI8MX vGWQ== X-Gm-Message-State: AOAM531fI7Lveuc1xgOyZJDmChWgSH4yfVBOcdnhsB2jS2pOk34KiWf/ rhllUYnNRuC5aSk25yGrPdBJOg== X-Google-Smtp-Source: ABdhPJzPrDgilD+IdsuARRSJnLjVmuLnZzSIbM26fRO56upgn5UdKvFS9Q7eftjgYS1yG3MpiGDHJw== X-Received: by 2002:a05:6e02:20e8:b0:2c1:e164:76e6 with SMTP id q8-20020a056e0220e800b002c1e16476e6mr726884ilv.135.1646853649808; Wed, 09 Mar 2022 11:20:49 -0800 (PST) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id g8-20020a056602248800b006409fb2cbccsm1389182ioe.32.2022.03.09.11.20.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 11:20: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 v2 5/7] net: ipa: use bulk interconnect initialization Date: Wed, 9 Mar 2022 13:20:35 -0600 Message-Id: <20220309192037.667879-6-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220309192037.667879-1-elder@linaro.org> References: <20220309192037.667879-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 Wed Mar 9 19:20:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 549799 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 2CAC9C433FE for ; Wed, 9 Mar 2022 19:21:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237792AbiCITWI (ORCPT ); Wed, 9 Mar 2022 14:22:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237675AbiCITVy (ORCPT ); Wed, 9 Mar 2022 14:21:54 -0500 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50E88111DD9 for ; Wed, 9 Mar 2022 11:20:52 -0800 (PST) Received: by mail-il1-x12b.google.com with SMTP id b9so823213ila.8 for ; Wed, 09 Mar 2022 11:20: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=d9+lLIbQQk6sLGoYu7PiXuh09aVQl9bHmfYbzTffMYE=; b=PvH1Bm5Xg0H+iKcrMwGJUZMAkJfxRho0JZTML7WN3T+a2B+o/72NlVLBihDe9xI5lM PEym/ogiP8/EtoEZ+vGL1hpu7TSeuosAVt//S3IuVqzRmKaZH7GVYZTGaaLBFhUVp35E umymw4vjP6x/jytdKBRqo7WPwzOPWElbVE8zAfmSel6g9CnnlRwjhkPDbhYfUNlsGwtA JRRPGWGUqUXIwr3xclWoTFLqbPt5sZG6D9HAkRSD0oZgacgI3f6Q6uygiH+wbKeRocxk TPEI2TMyjW6Ki/VVN3YJ+evLbrlVPFyx/5UXKN2RNCkvilILxXRLG3+S+OtNOvDK9mIC mEuA== 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=B47CXguo1fQyT1wMptrp+zMfaWJKFuiHcM/j9VDS8JbvuTVk9MI0k/hgnDgjHr/uD0 RkCEHbXeJ2XLrbwmiG4eMgfE46jDBIGqTG/X3nfPJRSqpIn5Qfr06bG6xBj5f49fnVIJ sSIPrztRoCa24wbotGdmIbOT1+1SpJq7zQ3GUkEwXatkJm8ppwxkmf/JoI/G7iTHvqBr CpbruG6P4oB5r8Cut/rpVFRHP+8EJtUvoCdv7tqxCll48OG3lQTWznvXJ0Pscy455jni kfv7pHZmgS1uA+yPtbksbNPn4pdXXyd6EEuzF3V/jRzs44xVPVlUbabOQ2yQjrAabuAx KG8w== X-Gm-Message-State: AOAM531wOA1X8xFEK9oDw1cgBx7CEq8P38r/QFrIyx47CUCIPiJmidIs mUfe7F0S6czB1wh9QDpVJd+Swg== X-Google-Smtp-Source: ABdhPJzdL7SZPWLaq005IBf9yCl5EX1HmSFnptZNEyVENvy0K2jaawXqNCrSqY/vTdKBBZ7aJCAcxw== X-Received: by 2002:a92:2907:0:b0:2c6:16f:79da with SMTP id l7-20020a922907000000b002c6016f79damr754853ilg.160.1646853651644; Wed, 09 Mar 2022 11:20:51 -0800 (PST) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id g8-20020a056602248800b006409fb2cbccsm1389182ioe.32.2022.03.09.11.20.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 11:20: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 v2 6/7] net: ipa: embed interconnect array in the power structure Date: Wed, 9 Mar 2022 13:20:36 -0600 Message-Id: <20220309192037.667879-7-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220309192037.667879-1-elder@linaro.org> References: <20220309192037.667879-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 Wed Mar 9 19:20:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 550809 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 1373CC433F5 for ; Wed, 9 Mar 2022 19:21:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230400AbiCITWL (ORCPT ); Wed, 9 Mar 2022 14:22:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237696AbiCITWE (ORCPT ); Wed, 9 Mar 2022 14:22:04 -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 D414F113DA3 for ; Wed, 9 Mar 2022 11:20:53 -0800 (PST) Received: by mail-io1-xd2b.google.com with SMTP id x4so3926390iop.7 for ; Wed, 09 Mar 2022 11:20: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=Q42zjW8xahSVhGaNilfnj63EHK+Wikk3dCoDovWBQQY=; b=xvVcZ8t2hTLcYyaR8IdpNwhqebsi1HHxLkwIaDM05AD3lNV0N4AV12KaR0NWsN5GuQ pdX87gjBv0H+CKrPZ+nNI3Y1CdEM7ga8ZJKA6pfpf7tU5IuKIkiLC+VBTLutyyiWlE+7 F7tJChmMw4gdInhfNtkjI0XJfVG2xMK14LP/L6QAkEBUaKr898KU7E0rxPJnYVRZXImV QtseXyJto1X7M7YjX3jJ8R2PjtZcDYj53/RHDbrRbEPlQaKvWj16VP35butKsdr6RMuy Untl7fwO6iB27zvzBwP+7A1quiRcAwNFJNjvPJ2Px8ntgSq96yBwRwuBqNv8dujSyoeK ddbQ== 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=Uw6eoyxRhhmYeAUFtRHSCQvU3cY3mEHkPlsn59A8KKAHJ32B97UxZHUmo61ICl7JV9 7Oad6+YxWLc4Ea0Jsw5p3XFwmCqXvrViY5xGlLjqcwseLde6C6SpQC3LO8eCTrDD3Noy ZtarZNCijpzaDqymtCK0o080YUpUDtehwSirVSSjgUSrbWSQcBexnNUYTjQxWN/ygcKc etm7+PhxWuVXvdCXC3NAPKS2ksMxnkARAmy5zqmEyRHwk+WtIIPdJku6wJXvkfyRoDa7 sWvixTQeE77QbG3/NOL0VgAmivYfdpHMsQdb80Ms6emv8nj6ySRsKtzU5LqaX8JjM5sV 2HKQ== X-Gm-Message-State: AOAM531jN2+Z74GL/elj5x2mhctiryVgBH+CHQhDxTBBmm9bzkrA7eiS I3NM8W4OYnp7yQMq76JZ53E3PA== X-Google-Smtp-Source: ABdhPJz9ICUaILN5z+iwfsY+OlIxZUZ6Tfiu+CkzHuqA9gUA/L8JZVq+gN3I234hfs6lurXOCK71Ug== X-Received: by 2002:a05:6602:2d51:b0:645:a9f2:82f3 with SMTP id d17-20020a0566022d5100b00645a9f282f3mr885134iow.9.1646853653196; Wed, 09 Mar 2022 11:20:53 -0800 (PST) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id g8-20020a056602248800b006409fb2cbccsm1389182ioe.32.2022.03.09.11.20.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 11:20: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 v2 7/7] net: ipa: use IPA power device pointer Date: Wed, 9 Mar 2022 13:20:37 -0600 Message-Id: <20220309192037.667879-8-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220309192037.667879-1-elder@linaro.org> References: <20220309192037.667879-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;