From patchwork Thu Sep 2 10:16:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 505732 Delivered-To: patches@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp1078644jai; Thu, 2 Sep 2021 03:16:39 -0700 (PDT) X-Received: by 2002:a2e:808a:: with SMTP id i10mr1778533ljg.396.1630577799453; Thu, 02 Sep 2021 03:16:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630577799; cv=none; d=google.com; s=arc-20160816; b=uDW+u4LQYBanRJIFkJ+E2F6ED5SDp1BrF4yCXRolBhFjx5YgQloDG5w78TTn3eMIZy Q93OvzIjS6IssLBkt00yab0pO1zNnEKzeQ6F+7DTsdVL5gz68JEH/yzJrpVvJghpsd+i CQeLsLatKZ41oSmrT7swdS/Ixj9xeJa7v1JIUNW3MPLXQwzw4oBSg/L7vFGi26Kslg6T 76cAPsS3PFIvpSl6lLRB2D2OIjh6zqoNj4HPGMImDsl431Kos8eXU0AyxzZs03H+UpKg gsNdSd/l63qVKGm+P7keUWn17mhNij/5PrRiKlMosJbS+X9ScoUw8VAVw1eEHdOUwt0+ B3+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=TywneFOHqk/q2lDRXrfDY/E+kQPlWfGyGjEe/NIEHS0=; b=YzkgDED+cvDihe9nHaBo0ADjkjjJpmIn63H2kLBLOdW6N2j3m0uKlLUQnLPXRYhmni QwIfcZBI+niBuyqz9wS5YiK0FE3eOcDCzLbKq/ytd+56fw/AxjaoZL0EJGLkcq04gPCs /6O4oQGjkLUw2J4aUbYI6HVvqXqxsS8iI9gQL93IwVrGZr/DtrKcGKcPT+hfWQgAzsXW E0XYEhHmOyFTcQL5CYSH0ZvbLr3V3lqS6zXUV9BNeP7E+ltBTP9WWYTUxpDoABJNHG0w 9Yjq76eZfat6a3i+kW246+OejY4kSv8sa0VZwlXd5hWdF4Li5MfyJorHP70VtBP2vq4h i4Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M8h86JEI; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id p9sor348127lfa.103.2021.09.02.03.16.39 for (Google Transport Security); Thu, 02 Sep 2021 03:16:39 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M8h86JEI; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=TywneFOHqk/q2lDRXrfDY/E+kQPlWfGyGjEe/NIEHS0=; b=M8h86JEIQRSZsTCGeR6pJ1N/QzA6dqeytHrr1+dBQeZWjNPOTfftT1ZYil39lLRzuI /+Mky0RdvsbyLL56yPCl536D0WeL6Ge+/lZDCk/exQAWqKxd9H+o0c01eHWWwglrUpRP T6rYxeocRQZ2uxuTa8X72ndaRdn68a92qloDdxFsAlvY20Bty0tO/O4xi8qRis2n3Uyj xn7vV44D7K9e9DDVNFJGpwAFpNChcqJ05ELDkXzVr7LS4MsxrnJlysoa9m4Jne+TX+2S n+rhCEQYf762oGA3FnjWzLpElbBMOKWMDCywomJ+uxGYYqNIm+KR9x2U1gRDD2z1NdW6 QERA== 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=TywneFOHqk/q2lDRXrfDY/E+kQPlWfGyGjEe/NIEHS0=; b=AFByTvOIrfYWMtAi7HggxDCISKcoBrPFyU/2kecKxplbhSpZamAYvkIvkFoTrIjj+6 04BmX0YEIrsMn8bl0OKPCGn9WZr96p4t5ivwNg0RWPzsZf3b6iX7LB066ZP7z6jv2yI1 PpVWN8qN0nlEfHCbuVaQkIrCzrhlOd+/7M8T6i9HfbOQxzRwSFgTSeUz635zDTsDSn/M 7VVeeiMm/sNr/eX4daT6/lYdM9uJXb5be+KixSskKB05die8/8HkttdC1siYCGnZ4aio xFqpmFg2KCmfIWp7kmAGu9T9ZKERb8uiIg8KXRPnmlLT3GgDQHrankDD5Lb3tIPqStt4 wE4g== X-Gm-Message-State: AOAM531LZOzxgjAedguW7nA5v7ffuQXrm4hV1w+MR0COoOX34tgQDf3V V9OO9B1ggimDrBoCwoZKzsOE4WaC X-Google-Smtp-Source: ABdhPJz03CxOy2DhzYQaRQsDsXZhX9SfdHEpc+fmAhDjGziDxiaA2v5/+BLy2btECx3VnNmdVU+HUQ== X-Received: by 2002:a05:6512:3091:: with SMTP id z17mr1987212lfd.418.1630577799097; Thu, 02 Sep 2021 03:16:39 -0700 (PDT) Return-Path: 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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 03:16:38 -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 1/3] PM: domains: Drop the performance state vote for a device at detach Date: Thu, 2 Sep 2021 12:16:32 +0200 Message-Id: <20210902101634.827187-2-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 When a device is detached from its genpd, genpd loses track of the device, including its performance state vote that may have been requested for it. Rather than relying on the consumer driver to drop the performance state vote for its device, let's do it internally in genpd when the device is getting detached. In this way, we makes sure that the aggregation of the votes in genpd becomes correct. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 9 ++------- include/linux/pm_domain.h | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) -- 2.25.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 5db704f02e71..278e040f607f 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1665,6 +1665,8 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, goto out; } + genpd_set_performance_state(dev, 0); + genpd->device_count--; genpd->max_off_time_changed = true; @@ -2604,12 +2606,6 @@ static void genpd_dev_pm_detach(struct device *dev, bool power_off) dev_dbg(dev, "removing from PM domain %s\n", pd->name); - /* Drop the default performance state */ - if (dev_gpd_data(dev)->default_pstate) { - dev_pm_genpd_set_performance_state(dev, 0); - dev_gpd_data(dev)->default_pstate = 0; - } - for (i = 1; i < GENPD_RETRY_MAX_MS; i <<= 1) { ret = genpd_remove_device(pd, dev); if (ret != -EAGAIN) @@ -2702,7 +2698,6 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, ret = dev_pm_genpd_set_performance_state(dev, pstate); if (ret) goto err; - dev_gpd_data(dev)->default_pstate = pstate; } return 1; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 67017c9390c8..21a0577305ef 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -198,7 +198,6 @@ struct generic_pm_domain_data { struct notifier_block *power_nb; int cpu; unsigned int performance_state; - unsigned int default_pstate; unsigned int rpm_pstate; ktime_t next_wakeup; void *data; From patchwork Thu Sep 2 10:16:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 505733 Delivered-To: patches@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp1078660jai; Thu, 2 Sep 2021 03:16:41 -0700 (PDT) X-Received: by 2002:a05:651c:4c7:: with SMTP id e7mr1880390lji.438.1630577801112; Thu, 02 Sep 2021 03:16:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630577801; cv=none; d=google.com; s=arc-20160816; b=RhO14mTI7CC0FrXb+oOiZaqsywQzsAqrYgEoFVma8EAiLOd81piT4mHarFcpmWy0wa STrprRwGP/CF6MMVtK5O9ArdT5I0xwh+IkDjQ1QsnfxHYloj7IEX8Iox4LYPlIDgNGM5 W2sh/HNaIN+nTSkTcG7aceCCJtrpq40T93Rs7iMlq5tBMnvQnyDxdbIGgNfLZEsKhqA4 MuqX5hakeOqc3zYw35YcfOfWhWFK1TdIcLTwbcGIfftT8eZHoWalMzCPmnLqQP41obFg oKI21i7Qxhu8fGflFxD0zsnW/U7eEaoj09WG7EEPXUtHsVah6g45ekhM2bt+9/lLyWpe AuTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=XZIDc5dNGmZMEuNI+q0RXZg7TDaDyQay2EJwpX2HagA=; b=y7xqWqiz4FSGy3TSoOX3zM8brirIx6GJt9aMJXdhfQ8TTfajK9j5A5YsHVlWqn/JSv m9/EGt2DHWFI8qL+DF1oAhVvkJAp1ruBKT5onxsl6wQtLU6dnJEHZ/Ij2d1FSxolPXDN 0+nyI0Wa138IPH4DAa+Bj1hOlj+ihfQimRs7kqe8OTFiOqACAHhkrh7Umj0IrMgs4IE2 MK6vg0c6wt9sod3fyhiFT7iveAVbARnF7ixxQPB0qBg8aUD0Ffkau/5Z9j5gG5Gqy0+h xzQO44zXo/pIPn5coT11QFmZQ4Zmi+opt+Gva9Q3Vav3Q5Pan6JAwfCaT3aFxnGx7ste zA7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tJEyqv27; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id v19sor745089ljg.25.2021.09.02.03.16.40 for (Google Transport Security); Thu, 02 Sep 2021 03:16:41 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tJEyqv27; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=XZIDc5dNGmZMEuNI+q0RXZg7TDaDyQay2EJwpX2HagA=; b=tJEyqv27c0M36cBiuxle+CZcejlnP42BqHYMsy3HH6riiEJsG+YpXDhRCks2ozu/0a YuXG3Fxzldz55lhNT71K7+qRshz8IyqqVyz2HmYf9jTDKw0jCy3PgRM96IBxbT8uJCDb FQVEoXVjv2YkFdPzs8JyfoTvs9cqJ3lQ7T21yNoEulElXLMqg5O1cNT1JvuikDEN+XGW hmX8t8qOEAbSrLsXUqtGNgo0+zISQLbbiCO2S5f/X3qavwykZZwIrxOhKUcfqe0n/Ljl YUMPiD+oIuf656o4snFxWRQSvao9oyutvr3Jb/HwWKASY4i/vU8L9O3bhDBhVe6+oxeF IdBg== 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=XZIDc5dNGmZMEuNI+q0RXZg7TDaDyQay2EJwpX2HagA=; b=ufn9yKnmPpCliZXKBhcVYKKJ58UD5/MYRjb1QtkYH6A4uXWeyIKQ8xQz7Gyc0/ewCA R7qo4tk97kpPd4XMJs3fFrEPyQrWrxBFXUJ6Qxk3vpw08aEKOrmj8iFkhfsnYUyM9dJM xv1oRhM4xwh8GAr109JZT52XCUmqW9ZVXoUY7nYq7TIBeG/7pCERatr4hwbwv0PIjNLf LtpgtKIbap+mCvSLwlcgDRd+vSI8M08I3M2FrWAlGUYUE4VyKz3T206rj/rzO6i9LGqI P10cvDFIUS49d6gDV4aZpsHLDO68M3U7npDcYbJlGatdP7AI02NVwDXsgBtRByMD0sAh smEg== X-Gm-Message-State: AOAM5313E/W2bDgBgxqVRiIe5bw9rhwFSTi3ViI/PwNmnXi5gI33x47M LFPDRRgeVAUf1sRAOYMziz8BbtVU X-Google-Smtp-Source: ABdhPJzNXuvX9XDTeaJ02yQt2BdTC2X0ZlUZgbJYnh+m6n9auTpgMAN6FyCEd7d8q4RZ8DQBiAQ5Aw== X-Received: by 2002:a2e:b53a:: with SMTP id z26mr1803113ljm.95.1630577800779; Thu, 02 Sep 2021 03:16:40 -0700 (PDT) Return-Path: 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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 03:16:39 -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 2/3] PM: domains: Restructure some code in __genpd_dev_pm_attach() Date: Thu, 2 Sep 2021 12:16:33 +0200 Message-Id: <20210902101634.827187-3-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 To slightly improve readability of the code, but also to prepare for a subsequent change on top, let's move the code that calls of_get_required_opp_performance_state() into a new separate function. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 278e040f607f..800adf831cae 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2640,6 +2640,17 @@ 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, + unsigned int index) +{ + int pstate = of_get_required_opp_performance_state(dev->of_node, index); + + if (pstate == -ENODEV || pstate == -EOPNOTSUPP) + return 0; + + return pstate; +} + static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, unsigned int index, bool power_on) { @@ -2690,8 +2701,8 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, } /* Set the default performance state */ - pstate = of_get_required_opp_performance_state(dev->of_node, index); - if (pstate < 0 && pstate != -ENODEV && pstate != -EOPNOTSUPP) { + pstate = genpd_get_default_performance_state(dev, index); + if (pstate < 0) { ret = pstate; goto err; } else if (pstate > 0) { 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: 505734 Delivered-To: patches@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp1078675jai; Thu, 2 Sep 2021 03:16:42 -0700 (PDT) X-Received: by 2002:a2e:1556:: with SMTP id 22mr1827746ljv.253.1630577802559; Thu, 02 Sep 2021 03:16:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630577802; cv=none; d=google.com; s=arc-20160816; b=OViHwSl1f/AJP1jhXB5rGH37JBpxZte9sXYM9C7r1aAUFhH/YzVU80nkJmnuv4Wzi9 X15Xy8HF7iW8qDGxQOOuvhyOR+clMcLNiRkff+yxgm35D1Y2nupRhCU5WZL+Qd0c/8Yu ZNwk6FPfjMZG0a/ohgrn9sTThLXlPBM30RY+olxk3PsejlPIRmOYrzfchiAc3NJtrS0F GYAhjG35+OdsK5kVWhQ12VHpGGcsnTH1eyL54Ps6TfDmhLoJk8nif89NHo+Arx9tjC8v XyBV6r9aBgOmbFQdp54PHj1nWGyhuL6ZqY3E8Gd7oxfqo2klt5H7AB5QGVv/2I0D+3Jj arEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Q8gHKZlIfNMsE2pwpZyxC6yykTeyy3ncWsPcdI97ZBw=; b=IrPzP+IwRZHi0p4d1HOXL+OZ6qXm1putrlr2MH6OvpO+FYHh3kfbCDdrbVN5rdBLty 5oy7lsPWyMWZ3hMAEccUhMUIDkcFOX/H/LfR6mIza07ufpmLT1ryv8zwFCs/HVijz120 tUtssSVZG5XCveN8qb8WtreFZTnwk2gtwZGcK7gWcu4PNc1jvYAXo9Fur7ewHecES+cQ XKGi8P/zDnKuA+YYKjKoRfwp/aUBY49Sg4vk5Bf3iRWB8PJMuRUvwAU1x8F8Ru63rsbR nTICkOXkfEao3z62aWSl8aYzaymW9kewMQqEEwPb4MTJDe62X4ctCwdblptFKlyL+kt9 gAeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Oz8M17UZ; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id e14sor739999lji.12.2021.09.02.03.16.42 for (Google Transport Security); Thu, 02 Sep 2021 03:16:42 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Oz8M17UZ; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=oKmmTqSfCSfdZy1yC5/Z9KcfcNYwHoG+Umnd9FmD7ZD5439lIAjA8eKRPN9iOjrE7a 1d2V019smaMjfsyu+hpAC/iE6VR8XdTqnPgMWJdLpBIs58ajerjfseq04D71RFNiZwe8 GcL8Th/4NHa+21RLb5Qvf8P8bhulk7EvPAkc2uzWIREiKvNv+CkX7eo9WkTHc1H4abJ2 52KqzwSKQA5UkewKIShIVJ8qM4SWq/autbaDQisy1oHd3jT9iqOP3HBRQmbXwbYkAHAX ESfjmL0f1LRIQZCgXKbR89Q7Wkh5CfgsOj6vRsrxyu+MmKGJijibi99HEtyoI0VtFI6I myKw== X-Gm-Message-State: AOAM532asFzyEXtG8SZGfRTZeKoD8qKhncGFNaP+4FmFiMzMs0qgu1yu w4PzBxgXbDPJ08iZ8oaD6ACPcqV3 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) Return-Path: 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 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(-) -- 2.25.1 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;