From patchwork Tue Jan 29 01:55:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 10785333 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2B1C91E for ; Tue, 29 Jan 2019 01:56:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93F202AC4E for ; Tue, 29 Jan 2019 01:56:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8755D2AD6D; Tue, 29 Jan 2019 01:56:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CB162AC4E for ; Tue, 29 Jan 2019 01:56:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727283AbfA2B4T (ORCPT ); Mon, 28 Jan 2019 20:56:19 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:46830 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727212AbfA2Bzw (ORCPT ); Mon, 28 Jan 2019 20:55:52 -0500 Received: by mail-pf1-f194.google.com with SMTP id c73so8876075pfe.13 for ; Mon, 28 Jan 2019 17:55:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i6Ukre4J8kw+qIeAmw1qZ7CnmonboLU8CoIx+jx7WtU=; b=SJQaG4pLHgn/wwoU7A6H/p5DK4ALlI1mOrTuXBTXYPaWCosnys8PLB8WzhJXMMDlAM hB4EknTLzPBeuUM+kLdUdMkZzUXnYSkHYRy2K9anlFHV8atrAowTiAOZI7dhK1xc+gGA vOOzRXlLhKe+ECdR2k7WiPh6BXSqVSnTzZXsE= 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=i6Ukre4J8kw+qIeAmw1qZ7CnmonboLU8CoIx+jx7WtU=; b=TPzpxbs3wryXU8SajX5CzWn4ZF1qYQ790nMa80i+kTR+Ny7jHsczIWU6awZ38ehdnH cyyuuXMIepqbrTvCQ85yasNMmYMFtF85nFSigIwYGsydyonSjhIy1nKEuxl0slNAAWQ2 OerxRlOxr7XpWKyxueK67/S39OQ0DrJ3RqK0Yc5P7DwmqU1PUMuTxJC4hg1LnjflPaC6 MWTa3kWnYhCuuVNTYxWi2BEFfHDZNXLRg7yJvU0eqBQOSXeBNCg6kwwOGcpaGZOdF11o 5LZJiYt+dyWBCI9BA/zqZSjjGL3RmEaJ/QvC6BtrAP6qcSzdZjSbwc7HMPPl7WcEU3vL rDiw== X-Gm-Message-State: AJcUukeUhr0iMaEoOzdUlgiPeB1Mh45/tjWA3wJnARmIuKBB2q47NHMh qnQx2r+deLxMpAS/udxNVxvvrA== X-Google-Smtp-Source: ALg8bN6jbvvJhCUvVVA0umN3QOZTVDuA0rd7YCFeOVu4SxWDXbYWzHQfQv86Zfyn7D4eJ6ecouYc2w== X-Received: by 2002:a63:165e:: with SMTP id 30mr21997482pgw.103.1548726951973; Mon, 28 Jan 2019 17:55:51 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id g15sm142911530pfj.131.2019.01.28.17.55.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 17:55:51 -0800 (PST) From: Stephen Boyd To: linux-kernel@vger.kernel.org Cc: Rajendra Nayak , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-serial@vger.kernel.org, linux-spi@vger.kernel.org, Ulf Hansson , Viresh Kumar , Doug Anderson Subject: [RFC/PATCH 2/5] OPP: Make dev_pm_opp_set_rate() with freq=0 as valid Date: Mon, 28 Jan 2019 17:55:44 -0800 Message-Id: <20190129015547.213276-3-swboyd@chromium.org> X-Mailer: git-send-email 2.20.1.495.gaa96b0ce6b-goog In-Reply-To: <20190129015547.213276-1-swboyd@chromium.org> References: <20190129015547.213276-1-swboyd@chromium.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rajendra Nayak For devices with performance state, we use dev_pm_opp_set_rate() to set the appropriate clk rate and the performance state. We do need a way to *remove* the performance state vote when we idle the device and turn the clocks off. Use dev_pm_opp_set_rate() with freq=0 to achieve this. Signed-off-by: Rajendra Nayak Signed-off-by: Stephen Boyd --- drivers/opp/core.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index b6516d623c5a..ac5099c237de 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -709,18 +709,24 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) struct clk *clk; int ret; - if (unlikely(!target_freq)) { - dev_err(dev, "%s: Invalid target frequency %lu\n", __func__, - target_freq); - return -EINVAL; - } - opp_table = _find_opp_table(dev); if (IS_ERR(opp_table)) { dev_err(dev, "%s: device opp doesn't exist\n", __func__); return PTR_ERR(opp_table); } + if (unlikely(!target_freq)) { + if (opp_table->required_opp_tables) { + /* drop the performance state vote */ + dev_pm_genpd_set_performance_state(dev, 0); + return 0; + } else { + dev_err(dev, "%s: Invalid target frequency %lu\n", __func__, + target_freq); + return -EINVAL; + } + } + clk = opp_table->clk; if (IS_ERR(clk)) { dev_err(dev, "%s: No clock available for the device\n",