From patchwork Thu Sep 2 10:16:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 12471197 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54C7AC4320E for ; Thu, 2 Sep 2021 10:19:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1FEB66109E for ; Thu, 2 Sep 2021 10:19:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1FEB66109E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WNRM9duZFaBhc62McYPErF0ONs92wut//aCNfvC+bvs=; b=y40OJcxzadQu9k SDupP5qmNhEu64H1woCgnEP7OzRow1t3T47Tkj4Q9RhcSJgtow/LBNlfeFat2UMCl8lHSQiLFbdZg kjo1nRTHFp6k23kXP1l0Qvck8N7nQPIn9vZCrDeE8+Y8kA03eMBnDANManzhnWNOUeroXufRqWMVN 24t0PwecTzzHTn02jq7sCeaJhMsN849sZJrauVBgRCdQs8HJ41e9PAOtlWEzsh4Yh4nHcKJTxRc9H pzSH8v3uJV2xrtCibugv80hB79+OQrcfdm4ZqF4tIMHV7DD7NBiyi+WJIuqjObyJ2xrI2etKg0lhK 9tjPPKVeNlB1neJQN5rQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLjmZ-009HzN-JR; Thu, 02 Sep 2021 10:17:19 +0000 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLjm0-009Hty-5F for linux-arm-kernel@lists.infradead.org; Thu, 02 Sep 2021 10:16:48 +0000 Received: by mail-lj1-x230.google.com with SMTP id h1so2543851ljl.9 for ; Thu, 02 Sep 2021 03:16:43 -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 :mime-version:content-transfer-encoding; bh=Q8gHKZlIfNMsE2pwpZyxC6yykTeyy3ncWsPcdI97ZBw=; b=Oz8M17UZ6Gx8M9KbOtjRmP3bgfiYuuxEHm6LOcO2pUnB9laFx5UVB5VKthK6ntGR0x cgOiXgmpxCBMTPt/U5URfmDm6XbHPMzJPBpI8F9nPcS+UPXKuUjf9oO6SsetA3IbfmGh zjk9F3KXuQ/XWjnP2i6TL9e7xb5KIWe2AoGuVI3F013ag+8+I8dOKA2qxSRwxORsd7WE pju3HKN/TnJi0qfjLLYp9ZNuqr0/mWb+6mbuC8HIyNI4UYHCT0kiYobL4YoyUXJpPTnW 8nFlCLi9dH+VxjezfhukcYdstS5keqcN+GyypIPpk2DtDWWXlg9sYWKqg7huXgJyvhP7 w0Cw== 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=Q8gHKZlIfNMsE2pwpZyxC6yykTeyy3ncWsPcdI97ZBw=; b=D1rc1iJcCqJyLTOqFlgfhF6T5uTDE4Wsiy9DFk2NQW27TzV54cW7OwEt8O+qBixnVT 0RFrVhD/Gc7Y0HnDGDBPRCXGsYh+505LcxreCDWZXb2DbwdryF7R2zl4Uw2biF0MC9Ix Ag5/ya1UBoKF4BpNiYKMRlqmzAFIT1l7GCz6O1/oilcn6dVTcKNvuARU/EwGOOrWbRug yV4tz/UEQfLZ3ZjA4k1b6PXEQdAiKud59zGqZtDwG/hzTivQNDU7ldn6cPFFqCtbtf1V 395q0fH8hbajHA/MyABSV0A582XaiVcOzT3ic994dHllATFXNWWlAyx8bVW/IEPSLL0f HsHw== X-Gm-Message-State: AOAM5327NB9W2oa8WP7Y5a0DLhW1+iVBef5ytCmbioDxG9C3i6gw5LFm t8iA5hPHdlf/zbvE25JhaSYZhzrXFp8q6T50 X-Google-Smtp-Source: ABdhPJzB9h6Twzy69IlKpaCmsSc174yIyH9MuvDLdUFpiBXC0tvx5XVeFz7kIcQaHw3PYf6tMNnYrA== X-Received: by 2002:a2e:5758:: with SMTP id r24mr1849768ljd.432.1630577802207; Thu, 02 Sep 2021 03:16:42 -0700 (PDT) Received: from localhost.localdomain (h-155-4-129-146.NA.cust.bahnhof.se. [155.4.129.146]) by smtp.gmail.com with ESMTPSA id s4sm155897lfd.53.2021.09.02.03.16.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 03:16:41 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Viresh Kumar , Dmitry Osipenko , linux-pm@vger.kernel.org Cc: Dmitry Baryshkov , Jonathan Hunter , Thierry Reding , Rajendra Nayak , Stephan Gerhold , Bjorn Andersson , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH 3/3] PM: domains: Add a ->dev_get_performance_state() callback to genpd Date: Thu, 2 Sep 2021 12:16:34 +0200 Message-Id: <20210902101634.827187-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210902101634.827187-1-ulf.hansson@linaro.org> References: <20210902101634.827187-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210902_031644_267556_643A18A2 X-CRM114-Status: GOOD ( 22.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hardware may be preprogrammed to a specific performance state, which may not be zero initially during boot. This may lead to that genpd's current performance state becomes inconsistent with the state of the hardware. To deal with this, the driver for a device that is being attached to its genpd, need to request an initial performance state vote, which is typically done by calling some of the OPP APIs while probing. In some cases this would lead to boilerplate code in the drivers. Let's make it possible to avoid this, by adding a new optional callback to genpd and invoke it per device during the attach process. In this way, the genpd provider driver can inform genpd about the initial performance state that is needed for the device. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 8 +++++--- include/linux/pm_domain.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 800adf831cae..1a6f3538af8d 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2640,13 +2640,15 @@ static void genpd_dev_pm_sync(struct device *dev) genpd_queue_power_off_work(pd); } -static int genpd_get_default_performance_state(struct device *dev, +static int genpd_get_default_performance_state(struct generic_pm_domain *genpd, + struct device *dev, unsigned int index) { int pstate = of_get_required_opp_performance_state(dev->of_node, index); if (pstate == -ENODEV || pstate == -EOPNOTSUPP) - return 0; + pstate = genpd->dev_get_performance_state ? + genpd->dev_get_performance_state(genpd, dev) : 0; return pstate; } @@ -2701,7 +2703,7 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, } /* Set the default performance state */ - pstate = genpd_get_default_performance_state(dev, index); + pstate = genpd_get_default_performance_state(pd, dev, index); if (pstate < 0) { ret = pstate; goto err; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 21a0577305ef..da694489a05a 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -131,6 +131,8 @@ struct generic_pm_domain { struct opp_table *opp_table; /* OPP table of the genpd */ unsigned int (*opp_to_performance_state)(struct generic_pm_domain *genpd, struct dev_pm_opp *opp); + int (*dev_get_performance_state)(struct generic_pm_domain *genpd, + struct device *dev); int (*set_performance_state)(struct generic_pm_domain *genpd, unsigned int state); struct gpd_dev_ops dev_ops;