Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp496375ybi; Thu, 13 Jun 2019 21:18:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwY4OSB8k1H42D8ZCwg3lLIoUkeLJvXim46Efw6ej6i+5qcUWpN7/jPzB7ZllE572VSHvRF X-Received: by 2002:a62:1d8f:: with SMTP id d137mr13140370pfd.207.1560485903507; Thu, 13 Jun 2019 21:18:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560485903; cv=none; d=google.com; s=arc-20160816; b=h/cMjhfmYsxmtwE1SCi2tc/UG6gYzqiUhNdcEv9YH7UCwyDZM0I2NT4bb7kRd8Ptk4 eO9cJusnAzXKLqbskInhLyHVpaBUja12qCGMBGPmPQWy5j3dUFvW/3LrnGEuS3zmyAkD MdritzPs6RSqwu2jRQWe6bp9br5TPCoKYSi5+b6XNMbXyG1+tEIhniWcOFnGzQBBSGx8 6dtzhJM3n8tZsbhkOp/gdWqnAp00zb4VfmB7Fg5fIVUSsmTUuGh2l1wH5EMymmrH+CJ1 YEP0moW4zKBngkderXLujrszM04gstz0fQiYzVzR8A6cC8jJXXdTkgeNrsWtE0dYlZNx Yg2Q== 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=SJIMb+Ux62XaD1zvTN7sgB8J991Gr80Gygm6D6H4n5w=; b=Nljeh65CB28DMc3Twam5HKBMV/6LcfczBDJ10bPNJ0OZc73BI8liTa6Xpdrg5mJQpc STl6FwrgQWxTWy+V277Z4/nIr7/nH/CAD0rbGk1+QyVM5v/yfDz5G4SN5vkeWLP9QUmF AQticbNubs3BsMqPNDdeY+dNtBSWNa3PAhWZnYuQcbt+FP3vZxJKMPpKu9ZfGz1XRjdD Ly18UQV1vQlQyedlHZQ5iskvhjSW13G3YHY35cOcyw1RwR9+vVYQBQnlUonfl7HmLakQ VrKa6Vil2Gyli6uqOleN8+tjWGJ54VHtM8OrlkRGR7IHCDl8ZwfUXK63TnRDG+SfbNbL a9WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hghN2IFd; 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 l2si1467558pgs.315.2019.06.13.21.18.07; Thu, 13 Jun 2019 21:18:23 -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=hghN2IFd; 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 S1726144AbfFNERt (ORCPT + 99 others); Fri, 14 Jun 2019 00:17:49 -0400 Received: from mail-qk1-f201.google.com ([209.85.222.201]:51971 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726108AbfFNERs (ORCPT ); Fri, 14 Jun 2019 00:17:48 -0400 Received: by mail-qk1-f201.google.com with SMTP id n126so979895qkc.18 for ; Thu, 13 Jun 2019 21:17:47 -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=SJIMb+Ux62XaD1zvTN7sgB8J991Gr80Gygm6D6H4n5w=; b=hghN2IFdVV5jQWGPzPZfj8N0Ul84C8eBuXKbdeQmfXQzCGBY5ZqbUuqpImEdmhWmIo 9qOU//XwKxDBz8ELfcENjG8S6e3Ef6obgwIFjcQgIaBIbwIV0iUk4hQVUaxc1E0RPs6j 4B9xobeLA/t4xbUsX/xYRsjJB8sXtHhWHikl9LulTCv4m1ziaHGzx7wSNqwwdsMQVOsn j/b1oMDv0cECZqjkMZPJEigAkUMZOeXATrxQNeFFMVyFcRcHLLw8tE9H0sS3z62rtfxV uZcH/amHURKnUuYj0dXECYNQ4NhskYS+atKwxbBeRUvUo72AlN2cAxa/+7QeaY1t/7NI aiUA== 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=SJIMb+Ux62XaD1zvTN7sgB8J991Gr80Gygm6D6H4n5w=; b=D6+6tQrOJ8IgfUyP1XdAzJ7Ju2WQebiwfFiy/uUqPpd9wmCCtNs7BA6hB4G3uuzLjT Osh2XJZGtyRLtQaVQ94Gd8obPPLBjWo/uBcRWVwFKYPVn8dxO6F8yQ9nFmnZpU6w9vYi 16goZEXkKeDtPVZW2jA82DQMqu/UUhwKLNCp67sj6jkEpO3pQpspREYp63y3ZTlwhP7y VgwrDxNFOiQil4jz8TYcaLhclzrMrTR2Hs6ojf0SyKPpz9CBjFc7DOdZc7de071nVByy uDVOC3ELYjDn0ZA+dzbFA1UjTbBH1YGEebxmibeeWteG7xcoYSe87k0mfwZoESaQ6hyC JhIA== X-Gm-Message-State: APjAAAXcni4B1pT9lKsGjLqm7tKMy57g1AnD+vJqPC4hU2grJf3aFPIB 9YeKVjLL4RRprQqViw5JXjzWNeFtyxnXjZ4= X-Received: by 2002:ac8:685:: with SMTP id f5mr4388547qth.9.1560485867363; Thu, 13 Jun 2019 21:17:47 -0700 (PDT) Date: Thu, 13 Jun 2019 21:17:25 -0700 In-Reply-To: <20190614041733.120807-1-saravanak@google.com> Message-Id: <20190614041733.120807-4-saravanak@google.com> Mime-Version: 1.0 References: <20190614041733.120807-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v2 03/11] PM / devfreq: Add required OPPs support to passive governor From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@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 | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c index 3bc29acbd54e..bd4a98bb15b1 100644 --- a/drivers/devfreq/governor_passive.c +++ b/drivers/devfreq/governor_passive.c @@ -21,8 +21,9 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, struct devfreq_passive_data *p_data = (struct devfreq_passive_data *)devfreq->data; struct devfreq *parent_devfreq = (struct devfreq *)p_data->parent; + struct opp_table *opp_table = NULL, *c_opp_table = NULL; unsigned long child_freq = ULONG_MAX; - struct dev_pm_opp *opp; + struct dev_pm_opp *opp = NULL, *c_opp = NULL; int i, count, ret = 0; /* @@ -65,7 +66,20 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, goto out; } - dev_pm_opp_put(opp); + opp_table = dev_pm_opp_get_opp_table(parent_devfreq->dev.parent); + if (IS_ERR_OR_NULL(opp_table)) { + ret = PTR_ERR(opp_table); + goto out; + } + + c_opp_table = dev_pm_opp_get_opp_table(devfreq->dev.parent); + if (!IS_ERR_OR_NULL(c_opp_table)) + c_opp = dev_pm_opp_xlate_opp(opp_table, c_opp_table, opp); + if (c_opp) { + *freq = dev_pm_opp_get_freq(c_opp); + dev_pm_opp_put(c_opp); + goto out; + } /* * Get the OPP table's index of decided freqeuncy by governor @@ -92,6 +106,13 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, *freq = child_freq; out: + if (!IS_ERR_OR_NULL(opp_table)) + dev_pm_opp_put_opp_table(opp_table); + if (!IS_ERR_OR_NULL(c_opp_table)) + dev_pm_opp_put_opp_table(c_opp_table); + if (!IS_ERR_OR_NULL(opp)) + dev_pm_opp_put(opp); + return ret; } -- 2.22.0.rc2.383.gf4fbbf30c2-goog