Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp578247ybm; Wed, 27 May 2020 02:51:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZqgb6CkDCbzdAGKJG1glhT4Wm7Teg6RBh2nqC06j8dLzsUhMY0wIC5uAbh3WVxHWEboGZ X-Received: by 2002:a05:6402:70b:: with SMTP id w11mr676158edx.251.1590573060753; Wed, 27 May 2020 02:51:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590573060; cv=none; d=google.com; s=arc-20160816; b=eXX51TNYVcOs93SLW+GZxOrd793PguE1hkn0O36iW6NYCWAaGfHRDH8upAahkzhWOd UyVNmSyEJ/Q/gFeOmpp4CP3ptjlDEaHojS747skqoBgEX+S/Z9W02VHWO05UQ6ZfKyv+ xOsWGsRNoqrN0sdEKjVD4pkT7upYSLZVARHGs0RwyDTUE4oxufcundhAHEFZw/lJjv2V JXDCm6o39bBgtIrGo3zAYEfbyHzFYaaYkEgHo+qBc+i0uJYsTEg2/+dEhzX/go2UVhaS IsMrkLHg7uRBNYn4WHhuSKbNVhTQQ44dYDQddgT3GJzKpLcA+J0JDqVGR3U1ictXfRWs yOIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AfGrQhANyY91hXOGSpuo1mwaEcVmt3M+OaE9Tl+XS5Y=; b=adAG4y6aMCzLgLrSNRJTt3owrfwR+VEWdgXLmu2Yyx90VveECcS5nb4/65Se6L/91X yRROkYoZamNHoTIoyQwyNwPG3XNvxE20VGdV1Wie3KOR/BA6UtUMmlmJxjqYpwST5ctC 7miT0BR2cHt7AEyUux3eyv7dVW828r3zRCpFPDbVYWjkHG30tJWxjOkMkDTBuHLMwjqP y7/bMrQiUEPQTwYInwiMKY0LdbN3Dv55eES4FOfYujAq9RhO1J8HKZWQuknhyHRj9pXL +tPqHIttWh9VxLAs5tTQcKR+HIVRcMkO/XMcI7g24+AdoYwzQToku4NXS23phEDtHurV Y2oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yc9MHRKH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qu5si1464839ejb.365.2020.05.27.02.50.37; Wed, 27 May 2020 02:51:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yc9MHRKH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728632AbgE0ENd (ORCPT + 99 others); Wed, 27 May 2020 00:13:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728626AbgE0ENd (ORCPT ); Wed, 27 May 2020 00:13:33 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC66CC03E97B for ; Tue, 26 May 2020 21:13:32 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id 124so4984713pgi.9 for ; Tue, 26 May 2020 21:13:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AfGrQhANyY91hXOGSpuo1mwaEcVmt3M+OaE9Tl+XS5Y=; b=yc9MHRKHZBNnZOmxUrGmqU+Z+7ZywJkjcbhb96l70OeshyTattGt2KB+DO5GOfMS9q 0dUP/f4JiyU+qJq1zXgDQWJkJcqE0HCu3Rme/QapoxmAQf/6iJMbZgQ7Fxzwr6G1+Rft MW4+9dTfS6xhmJk349y9xRFKkfD2Q61CnFLkZAaeI2d02s5EqwSwylsetVlMhNhmbCz3 V1iD+MrvsmQxsCmhHwSAZwUiIa7HrMzVYaO0nJZvrxHlHhrISjTqSlguqfVgD18MEHnw jKkUJNkUs/UMWRCiR4dGUdK68aw6sQKfKeTZY1Bqs/LetHNcrlZIqLAXI1+Gsci6sh/N k5GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AfGrQhANyY91hXOGSpuo1mwaEcVmt3M+OaE9Tl+XS5Y=; b=O9NSP+cv7u1m/ned1TrvF5LCOUZlomwN6NPjNAtXuO6ND2Q9JExqBJLI5qoy+Q1Eqj oh5gJ9RQbzlDMlVmKeQImGqSNhFm/i5K1Kvv4xP31RFa0HIanX+j2nQcjafzR499uKR2 NQlpDBjHCtSOWe5PxL0PJQJz0JIxXMNvODY5kLYbjp4OT+F6LHaa1WS5YgBmpC5mE1ym enqnnbURTVTE4EymYPa4n7ifg9JPmWbtgBlL4ThiM8Cofr+UEmVYuO7hSe2adN3tvl/z 4BwM3zvISsGMTTS0hv04+uuXE5l0AEA5/noNynRf+xMbtG4lOmW3mzbOpZUp6NoooxYE qrCA== X-Gm-Message-State: AOAM53164+9AieXAlueJ7SBWZE8sw2jbvREZTf7OFFjcAcu2eyzbqysB AldLQYFRPYS1RpPfajSOLI+qsg== X-Received: by 2002:a63:f502:: with SMTP id w2mr2061317pgh.321.1590552812239; Tue, 26 May 2020 21:13:32 -0700 (PDT) Received: from localhost ([122.172.60.59]) by smtp.gmail.com with ESMTPSA id 192sm823471pfu.202.2020.05.26.21.13.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 May 2020 21:13:31 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , georgi.djakov@linaro.org, Sibi Sankar , linux-kernel@vger.kernel.org Subject: [PATCH V2] opp: Remove bandwidth votes when target_freq is zero Date: Wed, 27 May 2020 09:43:26 +0530 Message-Id: <3aa3870d71b536127bb6af88c1dbfb4672ba4173.1590552778.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: <20200512125327.1868-1-georgi.djakov@linaro.org> References: <20200512125327.1868-1-georgi.djakov@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We already drop several votes when target_freq is set to zero, drop bandwidth votes as well. Reported-by: Sibi Sankar Signed-off-by: Viresh Kumar --- V2: Some changes left uncommited in my tree by mistake. drivers/opp/core.c | 49 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 56d3022c1ca2..df12c3804533 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -725,6 +725,34 @@ static int _generic_set_opp_regulator(struct opp_table *opp_table, return ret; } +static int _set_opp_bw(const struct opp_table *opp_table, + struct dev_pm_opp *opp, struct device *dev, bool remove) +{ + u32 avg, peak; + int i, ret; + + if (!opp_table->paths) + return 0; + + for (i = 0; i < opp_table->path_count; i++) { + if (remove) { + avg = 0; + peak = 0; + } else { + avg = opp->bandwidth[i].avg; + peak = opp->bandwidth[i].peak; + } + ret = icc_set_bw(opp_table->paths[i], avg, peak); + if (ret) { + dev_err(dev, "Failed to %s bandwidth[%d]: %d\n", + remove ? "remove" : "set", i, ret); + return ret; + } + } + + return 0; +} + static int _set_opp_custom(const struct opp_table *opp_table, struct device *dev, unsigned long old_freq, unsigned long freq, @@ -820,7 +848,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) unsigned long freq, old_freq, temp_freq; struct dev_pm_opp *old_opp, *opp; struct clk *clk; - int ret, i; + int ret; opp_table = _find_opp_table(dev); if (IS_ERR(opp_table)) { @@ -837,12 +865,17 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) if (!_get_opp_count(opp_table)) return 0; - if (!opp_table->required_opp_tables && !opp_table->regulators) { + if (!opp_table->required_opp_tables && !opp_table->regulators && + !opp_table->paths) { dev_err(dev, "target frequency can't be 0\n"); ret = -EINVAL; goto put_opp_table; } + ret = _set_opp_bw(opp_table, opp, dev, true); + if (ret) + return ret; + if (opp_table->regulator_enabled) { regulator_disable(opp_table->regulators[0]); opp_table->regulator_enabled = false; @@ -932,16 +965,8 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) dev_err(dev, "Failed to set required opps: %d\n", ret); } - if (!ret && opp_table->paths) { - for (i = 0; i < opp_table->path_count; i++) { - ret = icc_set_bw(opp_table->paths[i], - opp->bandwidth[i].avg, - opp->bandwidth[i].peak); - if (ret) - dev_err(dev, "Failed to set bandwidth[%d]: %d\n", - i, ret); - } - } + if (!ret) + ret = _set_opp_bw(opp_table, opp, dev, false); put_opp: dev_pm_opp_put(opp); -- 2.25.0.rc1.19.g042ed3e048af