From patchwork Fri Oct 12 11:11:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 148752 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp599009lji; Fri, 12 Oct 2018 04:12:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV63nXqbEvHKhMEC/xDPQna2gPsP8+Y6uk4xsJbMmgPASWWWSN4a17DkguNhxLp6WSd0MwnSA X-Received: by 2002:a63:cc:: with SMTP id 195-v6mr5060877pga.44.1539342722598; Fri, 12 Oct 2018 04:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539342722; cv=none; d=google.com; s=arc-20160816; b=f/GE4oc3oDcbdsKXpAUbpSdiJ/pfsKweyQfo+DpA5ul0Gor96rmmESH3R9d0triHjr s/fbKyxdjlrPXP16WkytvSYZsPjaVnP0FMIEHZG+N85jiuo83jq/0q2/n6jCT1+gZeB3 GeCuLiGUBTfOHUMt5Oo4PSTJohzFPz8gx4UTz9awv810hG24UFzjovCOqizg5VQgz44E AWEJ+dSPHfG2D8XlXKUZWJ7xjtA6HlP3kaFJoTXx4rGFB6f77ztyouIJJFfcFm9pHcsn /SXgtj9R/UBDZ0IngLDfsVR9a1ZwMhm2RLp10eCiT2BChArQe0xhqttoxsZQvGygQfpG jkww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=blaWPqPFlJGJ+DD2m7muSQ78d8p4LHOlTL3txRfKTuM=; b=pmU1aGzCyPX568Xxykb64d2YdUmd/evGAOqiHEkXlyeIdKckPwxSAFII46UT2xcnKP TOGI7+i83HosyAADAfEE/iW1TTGrMdWYNzjkRi74k/gfuCPJ0rQ9hgeApKPcNdhgUPT7 ByRjfEeFuTCzlybSwyULZkDG6THSIKDh75C45j+Q7IByXQA63O6q3CYrlAwF1DZn8ak6 KpzpGTbKIBy3P6q02OjBq0j+cFs6ZVyt7yHL8MN+G2y3qNOo7fZaniUbkhkmm1vTDMom 2iGsfjs/KnRkMMvsVMnyyXKGN6serdWthbig2LwWQUSYGh3IbUCxzPtE1DvQX5vxTkO/ XNPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D5rUBQr1; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f11-v6si1072844pgr.65.2018.10.12.04.12.01; Fri, 12 Oct 2018 04:12:02 -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=@linaro.org header.s=google header.b=D5rUBQr1; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728464AbeJLSnz (ORCPT + 32 others); Fri, 12 Oct 2018 14:43:55 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:45047 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728368AbeJLSnx (ORCPT ); Fri, 12 Oct 2018 14:43:53 -0400 Received: by mail-pl1-f193.google.com with SMTP id p25-v6so5778651pli.11 for ; Fri, 12 Oct 2018 04:11:58 -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; bh=blaWPqPFlJGJ+DD2m7muSQ78d8p4LHOlTL3txRfKTuM=; b=D5rUBQr1vrcVc2BiXCmd7EiQMTO1uXdbtMYnWRamB5cquWHi9NzLxeEsCMD0M9wOgo PHNKNZrl2nVXuRuwsowZrfnIswszWdoTKiBxdadMSfSDWAEwRn7SPyGBVf8ezP66W1TL GtoFhOj9S7JgD8sZTolBIrQkHyr3Xfi0uqygY= 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; bh=blaWPqPFlJGJ+DD2m7muSQ78d8p4LHOlTL3txRfKTuM=; b=sWKHsjxkk74jNippRcwoHC/k09fmyUB3rIwSW1cXSZhAY3GK3qLaUo24GizmqLSH0p ZsYFbWJawI/XliPvbcB0DD3SC6Iffpnb7zaoSkxBUWbJAIwMzN+gAbXHCqqWgU0T+NPa L6LQm84/TO+PSzT9YijgV9pN86bCFMnaroVLmEkrw29cTF7Vnu6neNrClz0vD2tUZXJN DlUDHxJFOj1rBr3itq0tNO+3v3AcRniEFe7W0M2c4TdFs/XEzju/daw5lU60LVAaFRYP BIeuj2eSqDn96JrJzW0m7gQGIV0GKoT15LQmeSoyku9jX4FiCSQGO7nhezbk9V9Km0Vg +51w== X-Gm-Message-State: ABuFfogPFe04KhMd5u6UzgQP5dd30xznIelCmaMeIUFGXd1CvOayShe2 NEAhosiW35t+1pJcVgiqFbb0Rg== X-Received: by 2002:a17:902:1129:: with SMTP id d38-v6mr156721pla.270.1539342717651; Fri, 12 Oct 2018 04:11:57 -0700 (PDT) Received: from localhost ([122.171.67.41]) by smtp.gmail.com with ESMTPSA id l129-v6sm2092376pfc.155.2018.10.12.04.11.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 04:11:57 -0700 (PDT) From: Viresh Kumar To: ulf.hansson@linaro.org, "Rafael J. Wysocki" , Kevin Hilman , Pavel Machek , Len Brown Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Stephen Boyd , Nishanth Menon , niklas.cassel@linaro.org, rnayak@codeaurora.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 5/9] PM / Domains: Add genpd_opp_to_performance_state() Date: Fri, 12 Oct 2018 16:41:13 +0530 Message-Id: X-Mailer: git-send-email 2.18.0.rc1.242.g61856ae69a2c In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The OPP core currently stores the performance state in the consumer device's OPP table, but that is going to change going forward and performance state will rather be set directly in the genpd's OPP table. For that we need to get the performance state for genpd's device structure instead of the consumer device's structure. Add a new helper to do that. Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 39 +++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 8 ++++++++ 2 files changed, 47 insertions(+) -- 2.18.0.rc1.242.g61856ae69a2c diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 4b5714199490..2c82194d2a30 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2508,6 +2508,45 @@ int of_genpd_parse_idle_states(struct device_node *dn, } EXPORT_SYMBOL_GPL(of_genpd_parse_idle_states); +/** + * genpd_opp_to_performance_state- Gets performance state of the genpd from its OPP node. + * + * @genpd_dev: Genpd's device for which the performance-state needs to be found. + * @opp: struct dev_pm_opp of the OPP for which we need to find performance + * state. + * + * Returns performance state encoded in the OPP of the genpd. This calls + * platform specific genpd->opp_to_performance_state() callback to translate + * power domain OPP to performance state. + * + * Returns performance state on success and 0 on failure. + */ +unsigned int genpd_opp_to_performance_state(struct device *genpd_dev, + struct dev_pm_opp *opp) +{ + struct generic_pm_domain *genpd = NULL, *temp; + int state; + + lockdep_assert_held(&gpd_list_lock); + + list_for_each_entry(temp, &gpd_list, gpd_list_node) { + if (&temp->dev == genpd_dev) { + genpd = temp; + break; + } + } + + if (unlikely(!genpd || !genpd->opp_to_performance_state)) + return 0; + + genpd_lock(genpd); + state = genpd->opp_to_performance_state(genpd, opp); + genpd_unlock(genpd); + + return state; +} +EXPORT_SYMBOL_GPL(genpd_opp_to_performance_state); + /** * of_genpd_opp_to_performance_state- Gets performance state of device's * power domain corresponding to a DT node's "required-opps" property. diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 776c546d581a..e03f300f7468 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -233,6 +233,8 @@ int of_genpd_add_subdomain(struct of_phandle_args *parent, struct generic_pm_domain *of_genpd_remove_last(struct device_node *np); int of_genpd_parse_idle_states(struct device_node *dn, struct genpd_power_state **states, int *n); +unsigned int genpd_opp_to_performance_state(struct device *genpd_dev, + struct dev_pm_opp *opp); unsigned int of_genpd_opp_to_performance_state(struct device *dev, struct device_node *np); @@ -274,6 +276,12 @@ static inline int of_genpd_parse_idle_states(struct device_node *dn, return -ENODEV; } +static inline unsigned int +genpd_opp_to_performance_state(struct device *genpd_dev, struct dev_pm_opp *opp) +{ + return 0; +} + static inline unsigned int of_genpd_opp_to_performance_state(struct device *dev, struct device_node *np)