Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1880081ybc; Wed, 20 Nov 2019 05:38:31 -0800 (PST) X-Google-Smtp-Source: APXvYqx3Q+uHk+9lv5GJv+FiNMKco/tZuAl60AwwFjEfz6CNUza/4Auab7py142jwpWeQ98oLx59 X-Received: by 2002:a17:906:709:: with SMTP id y9mr5277348ejb.321.1574257111426; Wed, 20 Nov 2019 05:38:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574257111; cv=none; d=google.com; s=arc-20160816; b=bC3ZxSyJ/OpxkPqb3X/MLCuIatbn3Oc8EP8RgU8ZcHtZEIDAIFYDqImrwGTauT+9Ch wyVgTn0Jxesl+sDWqVqS4MxPZOm7RfxInW6cmdYslINFH26iuFw1AMDnZhB7arE/k7pd CFiMkmpsME4VEPbSrDx2ZpHI0k4jnvdgdxtoPfeOn/Oa8pGdSZoMSQ8GQvf9sJpMAQkG X9hzuNnN7f/8vPcNUMUjFoOQ56pVNJjPvEq3FIn3uf7V3StMT/UsJWb1wJejr7l8G8aq S301Z0Oxjx2lvuQJMegy/Hwf7Z7zv1I8Qs0maB5KSej6WB/4lnl8oVCFUFj8y+kZ165l HCOg== 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=e3cBvCJGRcxYKob0R3G9a3fkI3S2TOmBRjT4BE52Zwg=; b=nK/eHOGQ2NQtQVI1126IyCujouxgGRz5pOTj81FkVEo30QgsxQn9UsXpnrEQIVnTD/ iZG0kcBxIqzQ/PbwRHpOREMqDYye3y/iPSERt/AkiZTrc5vcCBePcu9f3SlQvxbvVHPN bbPVjvHo8OzmJxlBd9nwUeKJgI3DKdnvOSDkVHC6KOdDxAFIVxfFw8j8LdYI/uC0DtXt AvRzf5Ig+/a+Lz04EnyrFZ6jc8DfCPURQ6k/VnejDIvSx9FhxdzbD3tNeGakt0KHwDcU ouaYTzz3hxkYi1rqsTqPwvI+E25HRUCavKm6L72H5r1VO6UbxcAAkBqNyoAvWx1aIb7x Lz8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ArXeuvGp; 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 b5si18202410edj.310.2019.11.20.05.38.07; Wed, 20 Nov 2019 05:38:31 -0800 (PST) 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=ArXeuvGp; 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 S1729950AbfKTM4p (ORCPT + 99 others); Wed, 20 Nov 2019 07:56:45 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:35807 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728247AbfKTM4o (ORCPT ); Wed, 20 Nov 2019 07:56:44 -0500 Received: by mail-qt1-f195.google.com with SMTP id n4so28850884qte.2 for ; Wed, 20 Nov 2019 04:56:44 -0800 (PST) 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=e3cBvCJGRcxYKob0R3G9a3fkI3S2TOmBRjT4BE52Zwg=; b=ArXeuvGpoBlrfpILMx/M83+Zn/RbRWXihN50pPnTAw2ZLLkb/hp/kzXGE4e3pJcJ3R gsYaNqlAFKy0EJHJMMUsBRCdN68xbd0/u9HLA/lwkwTiRIie2u8OQ4ubtENtMbs+NnKA Cmru7KlvSqU/6oQTWAAxXSVXZ6dwfTVAU3AzwldjvPeVnpnzaSmGsFp5a7oWXickOmYY lTxHgbpbFs/+r9OWV46swlR8FLMWOQm2U4HrrqbOFOYw4nt/ffV6HidWqcKbMNWUSzi9 AvukxXBhZ5W7XQoSKlFGkGDOkaR04e6y3vxHPJgKzQqCIvZauZdPMGjAh/jNQPeUlWKf 7XSQ== 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=e3cBvCJGRcxYKob0R3G9a3fkI3S2TOmBRjT4BE52Zwg=; b=sSqyzi7W3PtLnKrt6T801qBm94BAW2u4Oxpzgwece34M0SuUJgG/FfYZ5dgr2TRPNe Au4YhucuJdQdZuNmRk0zxNIIgnrGM6sQ/clhmQSWh+D4qteydvjsvR/5umOQSqDgo2/n 3WmCLmigmHOhPFTPI30QTYc2HSvIeXUPIQYW4gS0G3kOP6BmSnmV10r1hccqNozNrOVB CKn9F0cHDzrAID8+dSd/90XKJ+7RF3wSaZL1/ZoO0Sz/nsuI6mNlI/munjdzeaWsfD0D JwAKEVWY1XCBS0nL2PcleT+7DhmMTdj5WqoUkSB/HIzxXFODY6mzOgRkN6tDdkXq9ZZ1 Y8zQ== X-Gm-Message-State: APjAAAVo0lLT52NxPAAMIGR4nuJiVB+HiAAprjR5c5z2pbUwc/EQ0BwD yyWnIUnTsEKYYDJUvvDr0tT4ug== X-Received: by 2002:aed:3c0a:: with SMTP id t10mr2434630qte.173.1574254603451; Wed, 20 Nov 2019 04:56:43 -0800 (PST) Received: from Thara-Work-Ubuntu.fios-router.home (pool-71-255-246-27.washdc.fios.verizon.net. [71.255.246.27]) by smtp.googlemail.com with ESMTPSA id r2sm14109637qtc.28.2019.11.20.04.56.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Nov 2019 04:56:41 -0800 (PST) From: Thara Gopinath To: edubezval@gmail.com, rui.zhang@intel.com, ulf.hansson@linaro.org, daniel.lezcano@linaro.org, bjorn.andersson@linaro.org, agross@kernel.org Cc: amit.kucheria@verdurent.com, mark.rutland@arm.com, rjw@rjwysocki.net, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [Patch v4 1/7] PM/Domains: Add support for retrieving genpd performance states information Date: Wed, 20 Nov 2019 07:56:27 -0500 Message-Id: <1574254593-16078-2-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1574254593-16078-1-git-send-email-thara.gopinath@linaro.org> References: <1574254593-16078-1-git-send-email-thara.gopinath@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add two new APIs in the genpd framework, dev_pm_genpd_get_performance_state to return the current performance state of a power domain and dev_pm_genpd_performance_state_count to return the total number of performance states supported by a power domain. Since the genpd framework does not maintain a count of number of performance states supported by a power domain, introduce a new callback(.get_performance_state_count) that can be used to retrieve this information from power domain drivers. These APIs are added to aid the implementation of a power domain as a warming device. Linux kernel cooling device framework(into which warming device can be plugged in) requires during initialization to be provided with the maximum number of states that can be supported. When a power domain acts as a warming device, the max state is the max number of perfomrance states supported by the power domain. The cooling device framework implements API to retrieve the current state of the cooling device. This in turn translates to the current performance state of the power domain. Signed-off-by: Thara Gopinath Reviewed-by: Ulf Hansson --- drivers/base/power/domain.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 13 +++++++++++++ 2 files changed, 50 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index cc85e87..507e530 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -408,6 +408,43 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) } EXPORT_SYMBOL_GPL(dev_pm_genpd_set_performance_state); +int dev_pm_genpd_get_performance_state(struct device *dev) +{ + struct generic_pm_domain *genpd; + unsigned int state; + + genpd = dev_to_genpd_safe(dev); + if (IS_ERR(genpd)) + return -ENODEV; + + genpd_lock(genpd); + state = genpd->performance_state; + genpd_unlock(genpd); + + return state; +} +EXPORT_SYMBOL_GPL(dev_pm_genpd_get_performance_state); + +int dev_pm_genpd_performance_state_count(struct device *dev) +{ + struct generic_pm_domain *genpd; + int count; + + genpd = dev_to_genpd_safe(dev); + if (IS_ERR(genpd)) + return -ENODEV; + + if (unlikely(!genpd->get_performance_state_count)) + return -EINVAL; + + genpd_lock(genpd); + count = genpd->get_performance_state_count(genpd); + genpd_unlock(genpd); + + return count; +} +EXPORT_SYMBOL_GPL(dev_pm_genpd_performance_state_count); + static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed) { unsigned int state_idx = genpd->state_idx; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index baf02ff..e88e57f 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -117,6 +117,7 @@ struct generic_pm_domain { struct dev_pm_opp *opp); int (*set_performance_state)(struct generic_pm_domain *genpd, unsigned int state); + int (*get_performance_state_count)(struct generic_pm_domain *genpd); struct gpd_dev_ops dev_ops; s64 max_off_time_ns; /* Maximum allowed "suspended" time. */ bool max_off_time_changed; @@ -204,6 +205,8 @@ int pm_genpd_init(struct generic_pm_domain *genpd, struct dev_power_governor *gov, bool is_off); int pm_genpd_remove(struct generic_pm_domain *genpd); int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state); +int dev_pm_genpd_get_performance_state(struct device *dev); +int dev_pm_genpd_performance_state_count(struct device *dev); extern struct dev_power_governor simple_qos_governor; extern struct dev_power_governor pm_domain_always_on_gov; @@ -251,6 +254,16 @@ static inline int dev_pm_genpd_set_performance_state(struct device *dev, return -ENOTSUPP; } +static inline int dev_pm_genpd_get_performance_state(struct device *dev) +{ + return -ENOTSUPP; +} + +static inline int dev_pm_genpd_performance_state_count(struct device *dev) +{ + return -ENOTSUPP; +} + #define simple_qos_governor (*(struct dev_power_governor *)(NULL)) #define pm_domain_always_on_gov (*(struct dev_power_governor *)(NULL)) #endif -- 2.1.4