Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp4120365ybd; Tue, 25 Jun 2019 14:35:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0jYRLtEcl2j0FYXGH07iLZaRUiEvnmehOp2MCg3QZzBUSXGCoBj3c56eqn6twG71IH2o0 X-Received: by 2002:a65:480b:: with SMTP id h11mr8214039pgs.222.1561498500455; Tue, 25 Jun 2019 14:35:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561498500; cv=none; d=google.com; s=arc-20160816; b=rPxcufhCRhy8lcAR/Z84LIYy4WFKKgM4kDHC2aCrUI4BOe+zrBSdKjhq59GEeJ4x/w HEMK7qRvlJnUG+dSb7Y1KQaDC4/hJoE/++QFEL976mlGCiIErqZXTbIYyTBbJ4xwrkoR uWsCTA6cmW4cH4D9EtGovq958kGMAyGZ71EWjzfisIIxd+0NlD+rguyLuO+PlIntyNv6 jcKYItlO8WsFVFrIBWbjjoYwIcKoj6Ztjfm8nE0AXbXCPHW7Vyua1XvQuLkYq/v2AYop TTTphLG5zob5EPZBO0/Cf5IX11f6K16oJ1ZE1BjhCY16cuCMWSx2s0IGXcq9P/nmDfOm souQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=pSd2SEQBNKQJHNErQavWSNgkmJEBQdH7SImGVZiADmI=; b=JLCQzkyxuqCs2OFFFKwyDKJrja21OfP+IC8UcAiFCj4ykS76TZvBhhCiMAfm7MvRkU LQpc7na92UddB36k0LuSOYJsqh64zojegBrKGrlvDY/t9UmXKMBTVp0tL5BQNhiJ9g8S v2WF1X29JxM95byeNG1jAxowK1UkbM1aev/b10Db9kzjjEIZ/Kmhjo5oAR55sIutwQjd mKvjk2Y6Vrbw5suiiMoI/Zy8iLlQDg9NtcZFs6X0eirMCZO1KlQFUfbEoiuPUaEVzirX RULca1MahHPllakoQke8ttPJgh6Rd+oW6VwdgARKglHuNI+UBdwu63KGAVoQNmlIVVnc J8CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Nac5aiSP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x16si14121827pgk.484.2019.06.25.14.34.43; Tue, 25 Jun 2019 14:35:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Nac5aiSP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726484AbfFYVeA (ORCPT + 99 others); Tue, 25 Jun 2019 17:34:00 -0400 Received: from mail-pg1-f201.google.com ([209.85.215.201]:52682 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726387AbfFYVdz (ORCPT ); Tue, 25 Jun 2019 17:33:55 -0400 Received: by mail-pg1-f201.google.com with SMTP id a13so140724pgw.19 for ; Tue, 25 Jun 2019 14:33:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=pSd2SEQBNKQJHNErQavWSNgkmJEBQdH7SImGVZiADmI=; b=Nac5aiSPpKXkEoBjULWPNAHKlYVVswo8Sv+aG4Nke8sMPOVW/szdI6v3v2LjD3wyEj dSxGFXMq4R6/VUvASlerc0YHjxEciGlmfpvUQaqcj9qMSwHIIRpqZIrWJldrniWDW9Hg CyVQmYNhxjtZcDOdChKUCwLkP9gicQce4SEip766nU7aK7h7m17qe6A1M/GXpqAaVYZu xCtO7hBsnvfCOL+wvWBKWthJhv9Yi76HPcJxAiR7XIIb7WmR4GVwX5BVQP558AWcJlB6 LcSUR0W4OQfEKF47DlvQQlgePqeSjxEA9B7/QWoIUYLIMXjc+UQDI6N9vFjDEnXMypku M9zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=pSd2SEQBNKQJHNErQavWSNgkmJEBQdH7SImGVZiADmI=; b=dC4poGuxaoQEGdzKrZ3jCJkq3unYo0N8VzUroMw7qixE9wfJX3NGouZQm8DEy1OSbi gwKhUcD35dn9ZT0aHTox/eoAOKRUW/V3Hs1sFijf897dsiFGMXtLiOe61k8C40YtJ0h6 5MM6BUXlQwhy4GbmVWS01AoXrW3jKb9cLqX2QjP9CHzYrdOTse4bXvlQptfu7OFfYp4x zqzDir036s+L05EaN9Ap7YP9WfiQHQ6Ul49SHTJ8Sk8MyCIvf1bBLHfKIe0T5XcZK81i pMcEqWea1Hv/3TbabnyQB8amhaoYXjfXy0nD/4k4Lllq/NfD52Z7xyowIXBU/ArhP9Uj gdVw== X-Gm-Message-State: APjAAAX6x+YOKv4NvDEhToUeBBujweCo+4uaeyNeBAN+vGRa5ocWePRe n5AohCMQGzM6/ek1Hq9j21C4HG7nYx3q27g= X-Received: by 2002:a63:34c3:: with SMTP id b186mr507704pga.294.1561498434498; Tue, 25 Jun 2019 14:33:54 -0700 (PDT) Date: Tue, 25 Jun 2019 14:33:37 -0700 In-Reply-To: <20190625213337.157525-1-saravanak@google.com> Message-Id: <20190625213337.157525-5-saravanak@google.com> Mime-Version: 1.0 References: <20190625213337.157525-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH v2 4/4] PM / devfreq: Add required OPPs support to passive governor From: Saravana Kannan To: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , kernel-team@android.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Look at the required OPPs of the "parent" device to determine the OPP that is required from the slave device managed by the passive governor. This allows having mappings between a parent device and a slave device even when they don't have the same number of OPPs. Signed-off-by: Saravana Kannan --- drivers/devfreq/governor_passive.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c index 3bc29acbd54e..f6de03de7a64 100644 --- a/drivers/devfreq/governor_passive.c +++ b/drivers/devfreq/governor_passive.c @@ -22,7 +22,7 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, = (struct devfreq_passive_data *)devfreq->data; struct devfreq *parent_devfreq = (struct devfreq *)p_data->parent; unsigned long child_freq = ULONG_MAX; - struct dev_pm_opp *opp; + struct dev_pm_opp *opp = NULL, *p_opp = NULL; int i, count, ret = 0; /* @@ -59,13 +59,20 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, * list of parent device. Because in this case, *freq is temporary * value which is decided by ondemand governor. */ - opp = devfreq_recommended_opp(parent_devfreq->dev.parent, freq, 0); - if (IS_ERR(opp)) { - ret = PTR_ERR(opp); + p_opp = devfreq_recommended_opp(parent_devfreq->dev.parent, freq, 0); + if (IS_ERR(p_opp)) { + ret = PTR_ERR(p_opp); goto out; } - dev_pm_opp_put(opp); + if (devfreq->opp_table && parent_devfreq->opp_table) + opp = dev_pm_opp_xlate_opp(parent_devfreq->opp_table, + devfreq->opp_table, p_opp); + if (opp) { + *freq = dev_pm_opp_get_freq(opp); + dev_pm_opp_put(opp); + goto out; + } /* * Get the OPP table's index of decided freqeuncy by governor @@ -92,6 +99,9 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, *freq = child_freq; out: + if (!IS_ERR_OR_NULL(opp)) + dev_pm_opp_put(p_opp); + return ret; } -- 2.22.0.410.gd8fdbe21b5-goog