From patchwork Thu Aug 22 22:45:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13774316 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A4018C5320E for ; Thu, 22 Aug 2024 22:47:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rd4L2pq+cNv6ptoDFsJhK7t/4J9oetWQgiC2gczlRyk=; b=q5f/hq0HTb7+McfEhAg7Xu7+N7 UfkIjWjYreXT4En/ovwDwZiQre61PRahammjn6sH8T5C/KRWTmSQ1w+lwx0rKdL7WRyYj0JD2JOdY OaIsmKiy8PtMme/nx4V7T8nsKeriirWbopx1yq+S5fZw3iRRuC2Mr3FxkdL29dxQ8V0qiTufQmm/4 PWUkWsGZ5v6MyORT06X9i35t7sWojD9Y+Bu7CPf5iL4FeR90PCRY2L2RmRtH4HDVO1e6QG0UZXG3f pxdQQufY1ec9URlH00cMrXxXeaQzkeJ9/knsvGcyaBEaXFxhSnY8KD0hJab3so10ntjMgHrRIPE6N A0PKkQAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGZz-0000000EVob-3mYQ; Thu, 22 Aug 2024 22:46:56 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGZD-0000000EVcZ-3Wol for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2024 22:46:10 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-53349d3071eso1671080e87.2 for ; Thu, 22 Aug 2024 15:46:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366766; x=1724971566; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rd4L2pq+cNv6ptoDFsJhK7t/4J9oetWQgiC2gczlRyk=; b=tTaUbvwqJ+YlumUWztuVpK743lx/DDFB1ITYDL2y6WpF58b0u7lZBCUhfpna/f6wxU /jz0JxShCKC9khqGZvsmugbNJOsJvy4mDkvnQ7D9Lpxrn77XdXAQtGmBSf1D7z/6YVL4 /vsnPaIvPNRZv3xX6JBohRm0TD89ye5Y6RleAhbQBRDEtTCm5aH2yxU9wQ1yVuDBZq5H PS41D/7TegzkEYGwsY5MHyLfshBGr8lciF63jjPIQZzcmm7k9L7qYbveZ25rvJsTb13I MiY0eG1oCIJ7tDN0S1YPE320mJf11FAy8FyFbFYaRvRpfTHLvMdiM8ja47J9X6gMaiwo d9vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366766; x=1724971566; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rd4L2pq+cNv6ptoDFsJhK7t/4J9oetWQgiC2gczlRyk=; b=Rz88lM0LvDCy89p3F0ubxO02879+Yk1p4Ac+pOm9iimZobNDTCyp47Ee0UJU7wiZIY gAHbiSMVED/AmN9aGpMBz033mQm3uxoIgOgGZAGWRXn7n1DzxcFEy3pV09tmzqdJ0GN9 rmw6jfcRERrq7lnahf8ouK9sirZA3Lb0Y98/LjFv3Fy8gCK0VZF4eiO9lfrFb1ZV3eQ5 P96Y/W081vnPboAF6CcczlFJZYiZ65Y/2N+t/7SJ4ztGQ62Ii07LdVnjF5mUwOCVukZP Z1Tlt7ATnbwTWql8NUcC5ntFeQy3ZEBTx2B1cgM4lV1AowbzB63pdH7OzIUYyMvR93mb 76eQ== X-Forwarded-Encrypted: i=1; AJvYcCUp0XVBV1wUEpwbToe/NQkQKTtlfRkz5RgOpCEJlmjePfDTRywrr87yuGavm8NT/Qhsmqd4kZQi1sjX6hNBYZpf@lists.infradead.org X-Gm-Message-State: AOJu0Yxmc/hxsH80eCJ/eqOEwlRnRsyRkiTpZTcUR7693g2ghxKgc91y kt2KLAZnctHkurqyo0iexKkSvAsHiSs2GYx7eI3cUPBc2s8OkalIMqmK8mDhpA8= X-Google-Smtp-Source: AGHT+IElCYJAQaHkgKGtxiZoFimfR6Ft/lHijVpFpocO2DjQz0yBFh0jjHM8cqfvGlobtCvc9hXNsw== X-Received: by 2002:a05:6512:33c8:b0:533:4638:d490 with SMTP id 2adb3069b0e04-534387bbf16mr242936e87.38.1724366765813; Thu, 22 Aug 2024 15:46:05 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5334ea362a4sm379443e87.66.2024.08.22.15.46.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:05 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v3 01/10] OPP: Fix support for required OPPs for multiple PM domains Date: Fri, 23 Aug 2024 00:45:38 +0200 Message-Id: <20240822224547.385095-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-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-20240822_154607_905059_691F8264 X-CRM114-Status: GOOD ( 23.84 ) 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 It has turned out that having _set_required_opps() to recursively call dev_pm_opp_set_opp() to set the required OPPs, doesn't really work as well as we expected. More precisely, at each recursive call to dev_pm_opp_set_opp() we are changing an OPP for a required_dev that belongs to a required-OPP table. The problem with this, is that we may have several devices sharing the same required-OPP table, which leads to an incorrect behaviour in regards to aggregating the per device votes. To fix the problem for a required-OPP table belonging to a PM domain, which is the only existing usecase for now, let's simply replace the call to dev_pm_opp_set_opp() in _set_required_opps() by a call to _set_opp_level(). Moving forward we may potentially need to add support for other types of required-OPP tables. In this case, the aggregation needs to be thought of. Fixes: e37440e7e2c2 ("OPP: Call dev_pm_opp_set_opp() for required OPPs") Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson --- Changes in v3: - Clarified the commitmsg. Changes in v2: - Clarified the commitmsg. - Addressed some comments from Viresh. - Drop calls to _add_opp_dev() for required_devs. --- drivers/opp/core.c | 56 ++++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 5f4598246a87..494f8860220d 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1061,6 +1061,27 @@ static int _set_opp_bw(const struct opp_table *opp_table, return 0; } +static int _set_opp_level(struct device *dev, struct dev_pm_opp *opp) +{ + unsigned int level = 0; + int ret = 0; + + if (opp) { + if (opp->level == OPP_LEVEL_UNSET) + return 0; + + level = opp->level; + } + + /* Request a new performance state through the device's PM domain. */ + ret = dev_pm_domain_set_performance_state(dev, level); + if (ret) + dev_err(dev, "Failed to set performance state %u (%d)\n", level, + ret); + + return ret; +} + /* This is only called for PM domain for now */ static int _set_required_opps(struct device *dev, struct opp_table *opp_table, struct dev_pm_opp *opp, bool up) @@ -1091,7 +1112,7 @@ static int _set_required_opps(struct device *dev, struct opp_table *opp_table, if (devs[index]) { required_opp = opp ? opp->required_opps[index] : NULL; - ret = dev_pm_opp_set_opp(devs[index], required_opp); + ret = _set_opp_level(devs[index], required_opp); if (ret) return ret; } @@ -1102,27 +1123,6 @@ static int _set_required_opps(struct device *dev, struct opp_table *opp_table, return 0; } -static int _set_opp_level(struct device *dev, struct dev_pm_opp *opp) -{ - unsigned int level = 0; - int ret = 0; - - if (opp) { - if (opp->level == OPP_LEVEL_UNSET) - return 0; - - level = opp->level; - } - - /* Request a new performance state through the device's PM domain. */ - ret = dev_pm_domain_set_performance_state(dev, level); - if (ret) - dev_err(dev, "Failed to set performance state %u (%d)\n", level, - ret); - - return ret; -} - static void _find_current_opp(struct device *dev, struct opp_table *opp_table) { struct dev_pm_opp *opp = ERR_PTR(-ENODEV); @@ -2457,18 +2457,6 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, } } - /* - * Add the virtual genpd device as a user of the OPP table, so - * we can call dev_pm_opp_set_opp() on it directly. - * - * This will be automatically removed when the OPP table is - * removed, don't need to handle that here. - */ - if (!_add_opp_dev(virt_dev, opp_table->required_opp_tables[index])) { - ret = -ENOMEM; - goto err; - } - opp_table->required_devs[index] = virt_dev; index++; name++; From patchwork Thu Aug 22 22:45:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13774318 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9E63AC3DA4A for ; Thu, 22 Aug 2024 22:48:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=lvx3dtDyuaLtWvQBN1ccLzAdA+uGExJd6lwl1p/+zuE=; b=V5z+7LVxnyAxtHyfcHCRI5z4vr LGScajL64bZtRhL4FeyzvdLHUTrnftMrwvk0c8Ro8vg35w4uAgJe37k7Rt2SIARjlxXdv8anRbAci edyXUY6sDKTUzKJ2UguWdVB4dsvROMr/OM93F8g+KfYi+xh8CVAxLEQW+Qza2O8wp7PE+lHfnV2QK c4lQZT/EpwrrHNP0J9QY4TRTNfpDQvnr6/YucsQx0e6/dsKmDGg5W5HA2lR7m916ZiL5h7oz1J3Sh Mv5tqPhJbqUOqh4Tw94bVTUR784WYvAWry1rADCVV0n22NmwaRsNkz1DyP/gcezdZ4oTcTturNn9c yWXGDchA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGbS-0000000EWDt-2lLq; Thu, 22 Aug 2024 22:48:26 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGZF-0000000EVdA-29G7 for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2024 22:46:12 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-5334c018913so1279963e87.0 for ; Thu, 22 Aug 2024 15:46:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366767; x=1724971567; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lvx3dtDyuaLtWvQBN1ccLzAdA+uGExJd6lwl1p/+zuE=; b=A8NUF5BNr0a4aF/9raNypw6pPaZ1qjLgTq2VpErcNyOYMl5SBebU7JFPcgZJ9/AQF0 m+mK+gfKAu/e6C6MhKL8EZ8O5mmWJoOeL4WFvKwBVyfgFu582R1qJnRTit5oyqX8goGD DRpsryXjIN+XKthzHGJ3NcAbO7Qgbo1y2FEsiGoSosiKFCUiGjlDzEzh8Hga28fAb0ZG 2qPM8ETY+giigzk1xdvhtxPuVLDxjeIUkqfJf84wjCkT3n4fUVq5uqlfb0F7KskDNomz SCgVJd4Xhnb6QO5uCI3be6T9TA+k7xCKtzLjjUwW9WvBXiqtVAbrvsOM8Q9KWDhmXvOq +P6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366767; x=1724971567; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lvx3dtDyuaLtWvQBN1ccLzAdA+uGExJd6lwl1p/+zuE=; b=ttYllWU1qyvTXecj4gljy7e7xSiA8GDZ4ZYH6VKD3iZsMeyhnJVRAzfvujEsJDXG8i MgEA9STXn+ljb/bfXfSvembmHBJb7Aj3qFWGxfLuRpooBe5xtdQGWY4WX5CHcHtXY/IS nI7t+6bMMK/dAvdNkfN8F/5q4nyHkouIZBupbf/KRp2aDYUTEKR3+3pIwJUZ+DQYOO1i w0cF6lRSN0mnFL0r6HcRkYBprbL40q4YuudCrVvooyJulIO/8ACmCQPGVVnvnMjKKMp/ /4/2aIosgmmYq/Ua3+GVE6TREFuNmh8gb4/VtnQ7yQP1mFM0BXB6wtT0uRrnyRCKnb68 RwrA== X-Forwarded-Encrypted: i=1; AJvYcCVwge6r4bV7ucUEuZHoZtuBTWLVRHPZzH5x5Y2JOuF9/32rSkGH1k4r6FhyQ02hU2oFuHP8NSVrNHHScEIUOx2d@lists.infradead.org X-Gm-Message-State: AOJu0YwlakL5Kfc7Q9e+jDTABZi4iVaGnPuwt/0LbuGjki2d9TOCKLZK UNG3Dv9/JSqZN8cGe8Czku+CM2VgIvGZSgLm6TXXn+kDNLt9IUloXNul0ZjK7no= X-Google-Smtp-Source: AGHT+IGxvA4Uq9Y8lvyO5rIqpEo5VlzIQ99oKaiGIrLuFmsy7/2BQLTwlcgbwEWVVwymuZXSfzR59g== X-Received: by 2002:ac2:4e09:0:b0:52e:941d:7039 with SMTP id 2adb3069b0e04-5343886c9bdmr183956e87.59.1724366767061; Thu, 22 Aug 2024 15:46:07 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5334ea362a4sm379443e87.66.2024.08.22.15.46.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:06 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 02/10] OPP: Rework _set_required_devs() to manage a single device per call Date: Fri, 23 Aug 2024 00:45:39 +0200 Message-Id: <20240822224547.385095-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-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-20240822_154609_577735_2B8CA2A7 X-CRM114-Status: GOOD ( 32.11 ) 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 At this point there are no consumer drivers that makes use of _set_required_devs(), hence it should be straightforward to rework the code to enable it to better integrate with the genpd attach procedure. During attach, one device at the time is being hooked up to its corresponding PM domain. Therefore, let's update the _set_required_devs() to align to this behaviour, allowing callers to fill out one required_dev per call. As shown from a subsequent change, genpd becomes the first user of the reworked _set_required_dev(). Signed-off-by: Ulf Hansson --- Changes in v3: - Clarified the commitmsg. Changes in v2: - Addressed some comments from Viresh. - Drop calls to _add_opp_dev() for required_devs. --- drivers/opp/core.c | 91 +++++++++++++++++++++++++++++------------- drivers/opp/opp.h | 4 +- include/linux/pm_opp.h | 10 +++-- 3 files changed, 73 insertions(+), 32 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 494f8860220d..b6a699286aaa 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2473,9 +2473,10 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, } -static int _opp_set_required_devs(struct opp_table *opp_table, - struct device *dev, - struct device **required_devs) +static int _opp_set_required_dev(struct opp_table *opp_table, + struct device *dev, + struct device *required_dev, + struct opp_table *required_opp_table) { int i; @@ -2484,36 +2485,70 @@ static int _opp_set_required_devs(struct opp_table *opp_table, return -EINVAL; } - /* Another device that shares the OPP table has set the required devs ? */ - if (opp_table->required_devs[0]) - return 0; + /* Genpd core takes care of propagation to parent genpd */ + if (opp_table->is_genpd) { + dev_err(dev, "%s: Operation not supported for genpds\n", __func__); + return -EOPNOTSUPP; + } for (i = 0; i < opp_table->required_opp_count; i++) { - /* Genpd core takes care of propagation to parent genpd */ - if (required_devs[i] && opp_table->is_genpd && - opp_table->required_opp_tables[i]->is_genpd) { - dev_err(dev, "%s: Operation not supported for genpds\n", __func__); - return -EOPNOTSUPP; - } + struct opp_table *table = opp_table->required_opp_tables[i]; + + /* + * The OPP table should be available at this point. If not, it's + * not the one we are looking for. + */ + if (IS_ERR(table)) + continue; - opp_table->required_devs[i] = required_devs[i]; + /* Move to the next available index. */ + if (opp_table->required_devs[i]) + continue; + + /* + * We need to compare the nodes for the OPP tables, rather than + * the OPP tables themselves, as we may have separate instances. + */ + if (required_opp_table->np == table->np) { + /* + * The required_opp_tables parsing is not perfect, as + * the OPP core does the parsing solely based on the DT + * node pointers. The core sets the required_opp_tables + * entry to the first OPP table in the "opp_tables" + * list, that matches with the node pointer. + * + * If the target DT OPP table is used by multiple + * devices and they all create separate instances of + * 'struct opp_table' from it, then it is possible that + * the required_opp_tables entry may be set to the + * incorrect sibling device. Cross check it again and + * fix if required. + */ + if (required_opp_table != table) { + dev_pm_opp_put_opp_table(table); + _get_opp_table_kref(required_opp_table); + opp_table->required_opp_tables[i] = required_opp_table; + } + + opp_table->required_devs[i] = required_dev; + return i; + } } - return 0; + dev_err(dev, "Missing OPP table, unable to set the required dev\n"); + return -ENODEV; } -static void _opp_put_required_devs(struct opp_table *opp_table) +static void _opp_put_required_dev(struct opp_table *opp_table, + unsigned int index) { - int i; - - for (i = 0; i < opp_table->required_opp_count; i++) - opp_table->required_devs[i] = NULL; + opp_table->required_devs[index] = NULL; } static void _opp_clear_config(struct opp_config_data *data) { - if (data->flags & OPP_CONFIG_REQUIRED_DEVS) - _opp_put_required_devs(data->opp_table); + if (data->flags & OPP_CONFIG_REQUIRED_DEV) + _opp_put_required_dev(data->opp_table, data->index); else if (data->flags & OPP_CONFIG_GENPD) _opp_detach_genpd(data->opp_table); @@ -2630,7 +2665,7 @@ int dev_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config) /* Attach genpds */ if (config->genpd_names) { - if (config->required_devs) + if (config->required_dev) goto err; ret = _opp_attach_genpd(opp_table, dev, config->genpd_names, @@ -2639,13 +2674,15 @@ int dev_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config) goto err; data->flags |= OPP_CONFIG_GENPD; - } else if (config->required_devs) { - ret = _opp_set_required_devs(opp_table, dev, - config->required_devs); - if (ret) + } else if (config->required_dev && config->required_opp_table) { + ret = _opp_set_required_dev(opp_table, dev, + config->required_dev, + config->required_opp_table); + if (ret < 0) goto err; - data->flags |= OPP_CONFIG_REQUIRED_DEVS; + data->index = ret; + data->flags |= OPP_CONFIG_REQUIRED_DEV; } ret = xa_alloc(&opp_configs, &id, data, XA_LIMIT(1, INT_MAX), diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index cff1fabd1ae3..5b5a4bd89c9e 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -35,12 +35,13 @@ extern struct list_head opp_tables; #define OPP_CONFIG_PROP_NAME BIT(3) #define OPP_CONFIG_SUPPORTED_HW BIT(4) #define OPP_CONFIG_GENPD BIT(5) -#define OPP_CONFIG_REQUIRED_DEVS BIT(6) +#define OPP_CONFIG_REQUIRED_DEV BIT(6) /** * struct opp_config_data - data for set config operations * @opp_table: OPP table * @flags: OPP config flags + * @index: The position in the array of required_devs * * This structure stores the OPP config information for each OPP table * configuration by the callers. @@ -48,6 +49,7 @@ extern struct list_head opp_tables; struct opp_config_data { struct opp_table *opp_table; unsigned int flags; + unsigned int index; }; /** diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 6424692c30b7..5fade5c4de40 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -63,10 +63,11 @@ typedef int (*config_clks_t)(struct device *dev, struct opp_table *opp_table, * @supported_hw_count: Number of elements in the array. * @regulator_names: Array of pointers to the names of the regulator, NULL terminated. * @genpd_names: Null terminated array of pointers containing names of genpd to - * attach. Mutually exclusive with required_devs. + * attach. Mutually exclusive with required_dev. * @virt_devs: Pointer to return the array of genpd virtual devices. Mutually - * exclusive with required_devs. - * @required_devs: Required OPP devices. Mutually exclusive with genpd_names/virt_devs. + * exclusive with required_dev. + * @required_dev: Required OPP device. Mutually exclusive with genpd_names/virt_devs. + * @required_opp_table: The corresponding required OPP table for @required_dev. * * This structure contains platform specific OPP configurations for the device. */ @@ -81,7 +82,8 @@ struct dev_pm_opp_config { const char * const *regulator_names; const char * const *genpd_names; struct device ***virt_devs; - struct device **required_devs; + struct device *required_dev; + struct opp_table *required_opp_table; }; #define OPP_LEVEL_UNSET U32_MAX From patchwork Thu Aug 22 22:45:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13774319 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 50D30C5320E for ; Thu, 22 Aug 2024 22:49:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=24E2ZJlxZRFr5xBB3D3mkMAuhlD0R/qQC+7zUcBQFEc=; b=laDbhihitkqs3SaUpX9s5i1CRV ngonpcbxFUX8rIUOgORhCP5JYA8be5KE/bgI5UPq9IRCqpiNNOHi2ihRhq6gxuo8mxDvQEzworg+o TTxNj7PehljCh43LI4d7ddOe/lD7ZU43AV1ycCU6CsUUxssPmbudNzBVAb78ShKqX/YTWqV76n8wE DoWn7TXZfCVQYByIOHaEu7hEuOe3eh2mOIikiHkq4IULtMJEb1LeTjiq4ziJ6MQExm3uHdrpfbC45 4edM4xzLX2cc/AZUy68j0tJAHLd5dDMemZbY5ReJ3X4dDJuARHQ+GPeVG4zEyuYDWsyW/lyWCd8HX /fBl6Tqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGcA-0000000EWRf-2cOE; Thu, 22 Aug 2024 22:49:10 +0000 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGZG-0000000EVdI-3ipG for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2024 22:46:12 +0000 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2ef2c56d9dcso12281091fa.2 for ; Thu, 22 Aug 2024 15:46:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366769; x=1724971569; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=24E2ZJlxZRFr5xBB3D3mkMAuhlD0R/qQC+7zUcBQFEc=; b=t8OO22SAYJy2XQ03lRwp0u+Ug98gJH9OiIx0+vumjdozRAnXCw5qvCFfXwCb72J+jU 7V8b3oHWJZIXGPVExPntPKaofezfasnpd6dP2A43O4kZ7Ir79kj5Brehl+Cy29iQdVnR dPz+weGbnFnIgYq8agUtU8Ehz2sWu4m+OqtueFAay91/NuD64vHYZSamd+D532Tw0ARr m1FBbu2zvsaHvnLbA6b5DGBT3GuGZ+EXrUIa/1t42qlp1EoNJ40cGSYEdA+qLKluiAty xs/2tm0K49q/6Go8hpfbyKW0tNv5MuCWbbvh1uujWOaUhaBonc5GO8PVjUyK9t9i4L36 qrrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366769; x=1724971569; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=24E2ZJlxZRFr5xBB3D3mkMAuhlD0R/qQC+7zUcBQFEc=; b=AjzZ7pbb/OtuXgnDh7kF+j8fcQIYH+EyDfnQWUEQPowY2X6aFGpce7fUS2YNySIdkT GHVeONCDwlZdc5gB2wkNB9CvWs+m69QmXEcVOK4LmBUX0emg/FTfoCfwVWjtX3Gc7w8T 9evZz6r5Q5bSGmsvdVmA+jVNVrr4fxyf/I+QeQTu1RZSlzOORjXLiAh56pQA/qqkCgca hVzmfNolTmMb8pShttw708Xangbh/V12F7rhNxZBdPZhmaIC2tre77vXimpvmTmdsww+ dZ55xoZBz42JCKk/bmjyayu+zkcHXh8v0LtUxr/M4oJk90xAyKOmedgEKsYJvsdBDZyM nQMw== X-Forwarded-Encrypted: i=1; AJvYcCXyRO7+iBPb9gJvwyfu2tIPWMftWEqrCsc+Oy/ljU+nOXyg0t6bWAe3U2N6aLqI2HiDh2mPtiugDGFvXNNhtJd1@lists.infradead.org X-Gm-Message-State: AOJu0YxwYodI0oWs6g3N/MoQe2lwe1+HE3SvPlrrYOTjZq334VZ75lBo r9mqUW8QLK9MvE6z2IouW+xDfLssU1EkAEyQ8/YHxrOU4RXekztL4CVjgxwM2Xs= X-Google-Smtp-Source: AGHT+IELTL8/y0e0fGbr2lzzbBRJ4DDHIa+OZXd4j/RR2q0PvMAUXPDsy1xGSGg5oKqO9JdJ+zyCrg== X-Received: by 2002:a05:6512:23a9:b0:52c:d27b:ddcb with SMTP id 2adb3069b0e04-534387554cemr259563e87.3.1724366768686; Thu, 22 Aug 2024 15:46:08 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5334ea362a4sm379443e87.66.2024.08.22.15.46.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:08 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 03/10] pmdomain: core: Manage the default required OPP from a separate function Date: Fri, 23 Aug 2024 00:45:40 +0200 Message-Id: <20240822224547.385095-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-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-20240822_154610_961309_289E9A71 X-CRM114-Status: GOOD ( 17.91 ) 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 To improve the readability of the code in __genpd_dev_pm_attach(), let's move out the required OPP handling into a separate function. Signed-off-by: Ulf Hansson --- Changes in v3: - None. Changes in v2: - None. --- drivers/pmdomain/core.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index 2731b285e017..08c2192c02b4 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -2884,12 +2884,34 @@ static void genpd_dev_pm_sync(struct device *dev) genpd_queue_power_off_work(pd); } +static int genpd_set_required_opp(struct device *dev, unsigned int index) +{ + int ret, pstate; + + /* Set the default performance state */ + pstate = of_get_required_opp_performance_state(dev->of_node, index); + if (pstate < 0 && pstate != -ENODEV && pstate != -EOPNOTSUPP) { + ret = pstate; + goto err; + } else if (pstate > 0) { + ret = dev_pm_genpd_set_performance_state(dev, pstate); + if (ret) + goto err; + dev_gpd_data(dev)->default_pstate = pstate; + } + + return 0; +err: + dev_err(dev, "failed to set required performance state for power-domain %s: %d\n", + dev_to_genpd(dev)->name, ret); + return ret; +} + static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, unsigned int index, bool power_on) { struct of_phandle_args pd_args; struct generic_pm_domain *pd; - int pstate; int ret; ret = of_parse_phandle_with_args(dev->of_node, "power-domains", @@ -2918,17 +2940,9 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, dev->pm_domain->detach = genpd_dev_pm_detach; dev->pm_domain->sync = genpd_dev_pm_sync; - /* Set the default performance state */ - pstate = of_get_required_opp_performance_state(dev->of_node, index); - if (pstate < 0 && pstate != -ENODEV && pstate != -EOPNOTSUPP) { - ret = pstate; + ret = genpd_set_required_opp(dev, index); + if (ret) goto err; - } else if (pstate > 0) { - ret = dev_pm_genpd_set_performance_state(dev, pstate); - if (ret) - goto err; - dev_gpd_data(dev)->default_pstate = pstate; - } if (power_on) { genpd_lock(pd); @@ -2950,8 +2964,6 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, return 1; err: - dev_err(dev, "failed to set required performance state for power-domain %s: %d\n", - pd->name, ret); genpd_remove_device(pd, dev); return ret; } From patchwork Thu Aug 22 22:45:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13774320 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 65327C3DA4A for ; Thu, 22 Aug 2024 22:50:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=StJQRqCUVSSiSwu+3Mjs57fSdgGfFXaPCc1PsB3TzNQ=; b=jMc20oYhqdErt1AX2c5LcaS7wb M/vO99ldkqXXYDvMgSphRKlzQZ4hkEVB6lF1iJLd99FoBg8AGtxv66rgojzO0l22dFTysvAOw/F4j qjDjOmI0qU9LJXQx/y53UzE4DKXASsKyv7wdaGmDpkHvwL1JzXzH6B/NMkphfX/BANj9SAyDuDGOh 0kMeufhb4H0/Dj8hoanoqqf5HyOl3X7+VT4dxp1uoLNOAMIOeN1OuhBia9BT2uoSlOH+gGwsOnuan NToM5msZCSPyvTjWy52OCJ4zmdiSSSJDpMipw2SmcuNJgZ0Y3uhyGy/JCbIXabgAoYyHdLB72BBF7 y12ZQl2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGcs-0000000EWae-3Chg; Thu, 22 Aug 2024 22:49:54 +0000 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGZI-0000000EVdr-1a5m for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2024 22:46:13 +0000 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2f3b8eb3df5so12951881fa.1 for ; Thu, 22 Aug 2024 15:46:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366770; x=1724971570; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=StJQRqCUVSSiSwu+3Mjs57fSdgGfFXaPCc1PsB3TzNQ=; b=XJeToGFpD4mEW+y4L7Z6RnOPfyZyV09DwFUZ4eogImsdUA4ZmFAtS8oI1xb9sONg+l c+3V0gluMYpnNuk2WDZOfRnoxxx1b0jjhGQIo6eD8UhpZcD1imP36Q5rRh+9Goir6E42 Egm07LRDq7VJ1FBjCZjcvkvH6XBG0HImLdSvU7KQljvaR/eV3SmB7Pbo9F9OJXOwLMpu vLUl+uTeSRDD4KJBCxi71bCMTXD49KEpL732eghRl6uymgF16udOgVjE/oS9PBeu/8dP vtbh0d3RZVCD3IU2Z5Lca9Nzui1mATCSJyWsbyQeWSK3JJsWxyr5sGiAcvS/Gmfaa3Wo 5jZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366770; x=1724971570; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=StJQRqCUVSSiSwu+3Mjs57fSdgGfFXaPCc1PsB3TzNQ=; b=TnY0y60cOfz2/M9QQoBfuacGZt1YcIjOj/PSOMLuIJ3qQYg+lu3ShGixKN8OL6r4Cm lAF2MgdaSRBl9BdNJ/hCWudQfoJFSSRBES5wcEgtr0Ehr75aMyRROO4azySBv+SWhlPo g+YTDRvpVCOBzl8pT2XSkR3w/yYYiX4ELRe5bJsK6fP8a/Rd8+MpmtLXmfBeCnk7d9/X iP0KvJLxSdciAZwo2zsnOMCOnghmK6Ust2ROKhT3Zo8pvKtHlInaklSmugaz7OfsSGU9 Nd2aki9GhtdF6n+Ky/poJrK8oWw6cO9IptiAf3Beae7ypLozPnvuTPLWAdmwR/dX+TuD 7S1Q== X-Forwarded-Encrypted: i=1; AJvYcCXgPfQrobLmOcj3/S6MQe2/IK0GDWxJIYdAdj9L5Y3WTRRO0q61Fze08Cj0llqbda4jh6l6GGk02Nj3vsbTiZ8v@lists.infradead.org X-Gm-Message-State: AOJu0Yz09kj3xSC4SoiCr+fVW8ky7UIl7Ztrvk0W+E4XDDY1opVTIJAF l/sJnmZNTZtj5C9e3+CMeCk6c3VSAm6kTxOqs9IB4gHfSqNn1RQR0qr0zK0XCtQ= X-Google-Smtp-Source: AGHT+IGZamYSbygv3IkTZMVDGmekn9pjg+mdj2f5WolkNXH5KSnZ+vzYw3XXkDNayrwgkV2Bn3eurg== X-Received: by 2002:a05:6512:3b88:b0:532:c197:393e with SMTP id 2adb3069b0e04-5343882d172mr169993e87.11.1724366770078; Thu, 22 Aug 2024 15:46:10 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5334ea362a4sm379443e87.66.2024.08.22.15.46.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:09 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 04/10] OPP/pmdomain: Set the required_dev for a required OPP during genpd attach Date: Fri, 23 Aug 2024 00:45:41 +0200 Message-Id: <20240822224547.385095-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-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-20240822_154612_449469_895D0D30 X-CRM114-Status: GOOD ( 26.29 ) 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 Through dev_pm_opp_set_config() the _opp_attach_genpd() allows consumer drivers to attach a device to its PM domains. Their corresponding virtual devices that are created by genpd during attach, are later being assigned as the required_devs for the corresponding required OPPs. In principle, using dev_pm_opp_set_config() for this works fine. However, attaching a device to its PM domains is in general better done with dev_pm_domain_attach|detach_list(). To avoid having two different ways to manage this, let's prepare for the removal of _opp_attach_genpd(). More precisely, let's assign the required_devs during device attach in genpd, by using _opp_set_required_dev(). In this way, the consumer driver can rely solely on dev_pm_domain_attach|detach_list() to attach its device to its PM domains. Note that, we still need to allow existing users of _opp_attach_genpd(), which makes this change slightly more complicated. On the other hand, once we have migrated those users to dev_pm_domain_attach|detach_list(), the entire _opp_attach_genpd() can be removed. Signed-off-by: Ulf Hansson --- Changes in v3: - Clarified the commitmsg. Changes in v2: - Clarified the commitmsg. - Add a check for #power-domain-cells in genpd to avoid assigning the required-devs for non-genpd-providers. --- drivers/opp/core.c | 35 +----------------------- drivers/pmdomain/core.c | 59 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 34 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index b6a699286aaa..cad7e84c9ad3 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2369,7 +2369,6 @@ static void _opp_detach_genpd(struct opp_table *opp_table) continue; dev_pm_domain_detach(opp_table->required_devs[index], false); - opp_table->required_devs[index] = NULL; } } @@ -2393,8 +2392,7 @@ static void _opp_detach_genpd(struct opp_table *opp_table) static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, const char * const *names, struct device ***virt_devs) { - struct device *virt_dev, *gdev; - struct opp_table *genpd_table; + struct device *virt_dev; int index = 0, ret = -EINVAL; const char * const *name = names; @@ -2427,37 +2425,6 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, goto err; } - /* - * The required_opp_tables parsing is not perfect, as the OPP - * core does the parsing solely based on the DT node pointers. - * The core sets the required_opp_tables entry to the first OPP - * table in the "opp_tables" list, that matches with the node - * pointer. - * - * If the target DT OPP table is used by multiple devices and - * they all create separate instances of 'struct opp_table' from - * it, then it is possible that the required_opp_tables entry - * may be set to the incorrect sibling device. - * - * Cross check it again and fix if required. - */ - gdev = dev_to_genpd_dev(virt_dev); - if (IS_ERR(gdev)) { - ret = PTR_ERR(gdev); - goto err; - } - - genpd_table = _find_opp_table(gdev); - if (!IS_ERR(genpd_table)) { - if (genpd_table != opp_table->required_opp_tables[index]) { - dev_pm_opp_put_opp_table(opp_table->required_opp_tables[index]); - opp_table->required_opp_tables[index] = genpd_table; - } else { - dev_pm_opp_put_opp_table(genpd_table); - } - } - - opp_table->required_devs[index] = virt_dev; index++; name++; } diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index 08c2192c02b4..0749da94624f 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -2884,6 +2884,61 @@ static void genpd_dev_pm_sync(struct device *dev) genpd_queue_power_off_work(pd); } +static struct opp_table *genpd_find_opp_table(struct generic_pm_domain *genpd, + unsigned int depth) +{ + struct opp_table *opp_table; + struct gpd_link *link; + + if (genpd->opp_table) + return genpd->opp_table; + + list_for_each_entry(link, &genpd->child_links, child_node) { + struct generic_pm_domain *parent = link->parent; + + genpd_lock_nested(parent, depth + 1); + opp_table = genpd_find_opp_table(parent, depth + 1); + genpd_unlock(parent); + + if (opp_table) + return opp_table; + } + + return NULL; +} + +static int genpd_set_required_opp_dev(struct device *dev, + struct device *base_dev) +{ + struct generic_pm_domain *genpd = dev_to_genpd(dev); + struct opp_table *opp_table; + int ret = 0; + + /* Limit support to non-providers for now. */ + if (of_property_present(base_dev->of_node, "#power-domain-cells")) + return 0; + + if (!dev_pm_opp_of_has_required_opp(base_dev)) + return 0; + + genpd_lock(genpd); + opp_table = genpd_find_opp_table(genpd, 0); + genpd_unlock(genpd); + + if (opp_table) { + struct dev_pm_opp_config config = { + .required_dev = dev, + .required_opp_table = opp_table, + }; + + ret = devm_pm_opp_set_config(base_dev, &config); + if (ret < 0) + dev_err(dev, "failed to set opp config %d\n", ret); + } + + return ret; +} + static int genpd_set_required_opp(struct device *dev, unsigned int index) { int ret, pstate; @@ -2940,6 +2995,10 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, dev->pm_domain->detach = genpd_dev_pm_detach; dev->pm_domain->sync = genpd_dev_pm_sync; + ret = genpd_set_required_opp_dev(dev, base_dev); + if (ret) + goto err; + ret = genpd_set_required_opp(dev, index); if (ret) goto err; From patchwork Thu Aug 22 22:45:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13774321 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B92EBC5321D for ; Thu, 22 Aug 2024 22:50:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9IgtH0skR0e3C63jmvkIAtxr085sHyospA98t+tzDJI=; b=rngxYJDgJpB941GdpL+u/5NXO8 gBo3PB0V45HoB9WvhoNla0NNJhY8dK2VrOt/vCyW6qjPtRpgiXIoMR0WmfC+b+UsU2NcdiNGJ09pZ y0/BB1VstoQ6Sr2dlCoX+GuEfX8Qd0fLbIokXFqVrbKMbVb4c0hwesMCAvhO5pHi5Qw87TKQyobxA cCUsmAyJiL758WFO8D3D81FWg7O70sbJkZFBfOK1C2g9xi1MZyMQekHqkuq0EjdcainAYIcLJKIKe VZKm8vzs7KxnXZCoPrYfsrKZwzKnnuCy4+3syFfVAYbsb2KOGK2Y677WOAglI06Wm3+DoVNBtvqCe v+aYLqtA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGdZ-0000000EWjE-2Zw1; Thu, 22 Aug 2024 22:50:37 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGZJ-0000000EVe7-2NYV for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2024 22:46:14 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-534366c194fso639182e87.0 for ; Thu, 22 Aug 2024 15:46:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366771; x=1724971571; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9IgtH0skR0e3C63jmvkIAtxr085sHyospA98t+tzDJI=; b=N6ACWyxNTenwRKseBWPBLrf7jTnOTcHl6753m6JcLe9KH1oiAb37uLXWafE1dNVpHU /47KJunXNWeYuGXx9rHVI+GCLl8Hl00QFMfp0EpkA7H89DgMqaNvD8tpm3BNycEcUSzU fsgBgyammLkc3yOhLQ0wn6SnraySuLLAuRYge4YMz2676wjWjId1rcWeIMqQXeS5OWsM Q+pUysvYnF+ybuhAdvDu1lyybr0rnFTqLcUL5RnKYLzkzPeWTWxLCVWkmonoElwQMYdz ho4jpE2VdGl02/oYpHa7oIFjKzJcboi44ywn+E56yI6AczsLYdK8xn9EcUVs+IOJMBhW gZlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366771; x=1724971571; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9IgtH0skR0e3C63jmvkIAtxr085sHyospA98t+tzDJI=; b=u3Y3nkJCs4vZZ82NwlNKhfsTXcynG4IEg1WOwj35IQXF5H3yNXr88bba4xOJV1qO34 eWo4/2wSISTp6yehg3Kj1yOqdzTll5Ov7UEkm80d2VqbD5d8SOtnECWcnFc1M57nscI2 LJ6y3w3axm37NvSaZrko+pKCbPd0DdggaJgrrgbN46iHaYdngKfzGXoXAv2bZb4red/1 kFmv7Y5g7c8ohXIbjLyHjVaJ7qAHOJYRdgR5kztA6qMahOBman2gdA0kH8+pNfqNaAYR BApoWMsfLjOUsvQubJ1HuaeUCkcZKAmAPsSg9KXfroEM/0Yqq8bKnlPHj9GJS2Ck6dJ1 Ik5g== X-Forwarded-Encrypted: i=1; AJvYcCXaYdG4HdHZptn6vJVEhHeiw5wJ5dDgMSBkkohhQI2en/kUwhRCQRhY7shMu5B7cf3hwIyvCrOv0YXL2pq1BZZU@lists.infradead.org X-Gm-Message-State: AOJu0YzwNIFiUusXAJwJ53I7NTAiEVxKVjz8XPuLxO4cvdNqI9ng/b5/ 4UauIfa5PGqYcD3gaoZLQyp7VqTjEOfwyKovAsj84Po53QZVFNROEXs5Pn8NR9Q= X-Google-Smtp-Source: AGHT+IFNgxeohcK9pIDV2zZdHATDKL7WYCEymR2r9L2dWkQ/5MOeAMKb0NrqhPaC3r++lSrG4socBw== X-Received: by 2002:a05:6512:3c87:b0:52c:d905:9645 with SMTP id 2adb3069b0e04-534387786ebmr208252e87.13.1724366771338; Thu, 22 Aug 2024 15:46:11 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5334ea362a4sm379443e87.66.2024.08.22.15.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:10 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 05/10] pmdomain: core: Drop the redundant dev_to_genpd_dev() Date: Fri, 23 Aug 2024 00:45:42 +0200 Message-Id: <20240822224547.385095-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-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-20240822_154613_626019_D7313774 X-CRM114-Status: GOOD ( 11.04 ) 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 There's no longer any users of dev_to_genpd_dev(), hence let's drop it. Signed-off-by: Ulf Hansson --- Changes in v3: - None. Changes in v2: - None. --- drivers/pmdomain/core.c | 10 ---------- include/linux/pm_domain.h | 6 ------ 2 files changed, 16 deletions(-) diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index 0749da94624f..edef1a520110 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -226,16 +226,6 @@ static struct generic_pm_domain *dev_to_genpd(struct device *dev) return pd_to_genpd(dev->pm_domain); } -struct device *dev_to_genpd_dev(struct device *dev) -{ - struct generic_pm_domain *genpd = dev_to_genpd(dev); - - if (IS_ERR(genpd)) - return ERR_CAST(genpd); - - return &genpd->dev; -} - static int genpd_stop_dev(const struct generic_pm_domain *genpd, struct device *dev) { diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index b637ec14025f..f6d26cd81096 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -268,7 +268,6 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, 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); -struct device *dev_to_genpd_dev(struct device *dev); int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state); int dev_pm_genpd_add_notifier(struct device *dev, struct notifier_block *nb); int dev_pm_genpd_remove_notifier(struct device *dev); @@ -318,11 +317,6 @@ static inline int pm_genpd_remove(struct generic_pm_domain *genpd) return -EOPNOTSUPP; } -static inline struct device *dev_to_genpd_dev(struct device *dev) -{ - return ERR_PTR(-EOPNOTSUPP); -} - static inline int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) { From patchwork Thu Aug 22 22:45:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13774322 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B6FFCC3DA4A for ; Thu, 22 Aug 2024 22:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/D/aVXPRU7SQfotSax/kaOpx6m/gKAibnYASkuMoMcQ=; b=iSmWNeYerz54lSKV0AX2RjXwmn ZNELXTcbfZQvtSQg8DuRdXOkKJ6qVVTdhKzA5uKUY6K6LHZ3ULptDLmj6nJufuZX0LTOYARoC4Au2 TW9rik8W5enKJkQB3V2J7OZToYvBL6QBdwqYLIs+LJ7qjvKpZLryyDij2VLoKvAIHRPwqX7gWrrBa B0qlnqTr6aFpzffNfbLUnr1z6egKGo+ydVgKROPtylQeuxS93V1UZX1XztkjcGlZRZEY7ifFbIK5z 7g7bgJNKDqvlXNTnxAUl80iSNXJ1yxqqQB+NGw8m091JICEUJ3Qd3w/OC0cG9JV0LPlTfNsqrHmN3 5v14oikg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGeI-0000000EWsI-00ZT; Thu, 22 Aug 2024 22:51:22 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGZL-0000000EVfF-0FXo for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2024 22:46:16 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-53438aa64a4so60781e87.3 for ; Thu, 22 Aug 2024 15:46:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366773; x=1724971573; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/D/aVXPRU7SQfotSax/kaOpx6m/gKAibnYASkuMoMcQ=; b=h4B3fLRkZ+UZO4bTYYhJeNycPpq1v/aILp6WO1v4Ot0HNQ63xsztN20bgrmWY0/P/1 H93pE0QQidC5HwT64GHIrxlrHkFbsuebDWOENOWxV4PY4xShezcBdCuahuXTxvCWIGtb ivC76ed2pPwSB6H2DXdVUhgmgJOQbpZoM7Dr57jxSV6O4a+DPmAP7CjH/USq6EKx9Zvf jx/go6K2aj8lk1YD0h8EO53wUdlH5iDvNnf5woNBaamHKWeix9uHD6hRmBB7wqRPF90J IKIeQZj1dnuWb8Q7Y/m9x+cfMD8BNbtvjdSlsSlSEWX0FOolxerNbSPykv6YCL1mgblZ n6ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366773; x=1724971573; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/D/aVXPRU7SQfotSax/kaOpx6m/gKAibnYASkuMoMcQ=; b=NnK+4MBN4E53kFxsT6q79bQPRtBSd0qHZk5zXM+pNP8Qosfx57K9NvYPiuYY5rAXXH ZBj0bLFfPCfxoNouU75z5VY0VWH5q7uozF84NrZIFLLvH6gt9zL4baljWFQRQs6zfcYd mD4mQJ3ShwoY+oxc3LlX50/uGzd8GN6UYs0RH3yuUYerie4LAQ6dWVUq9vjJY8ziIsaH xGWt51JIxaeuVQh1Ybk3TR3NEPjQS1gUSzFOod5anFqDTM2BmPwS2Mmg+M1w0hawrEK6 ZVLtLyHZu9Wxah0kZkFElltUSVxFmjV/Itx6W5YCbBvQMCpRgoNJ9AGN7M+1ZtAW8RfV uIFg== X-Forwarded-Encrypted: i=1; AJvYcCWt3QfN7k5U0engcW6xXtWNTLKwaJPMmeMOYe93rtDZjVWPFlYPdypRwBLRSBLNTePDMh7NIKZUUm0rwTPL04vW@lists.infradead.org X-Gm-Message-State: AOJu0YzKgR6666Ap01eukmssT2bejYBE5rlHNGig91RxHFMMyIE27Ab6 4SqU78/nZGDrmNy43jXDZOprF1cALVK0rJS7nVkszwYqWQTZGBMPvqFdssAU30E= X-Google-Smtp-Source: AGHT+IHhhSvatCGlzIYJAKPJG00P39imQvuyh3f4XRIvd0rEr5zWn9noMQWqj/FUZVYPNGBt3R/oLQ== X-Received: by 2002:a05:6512:e89:b0:52e:767a:ada7 with SMTP id 2adb3069b0e04-53438868d57mr128566e87.50.1724366772836; Thu, 22 Aug 2024 15:46:12 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5334ea362a4sm379443e87.66.2024.08.22.15.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:12 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 06/10] OPP: Drop redundant code in _link_required_opps() Date: Fri, 23 Aug 2024 00:45:43 +0200 Message-Id: <20240822224547.385095-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-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-20240822_154615_125470_E43CA259 X-CRM114-Status: GOOD ( 20.46 ) 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 Due to that the required-devs for the required OPPs are now always being assigned during the attach process in genpd, we no longer need the special treatment in _link_required_opps() for the single PM domain case. Let's therefore drop it. Signed-off-by: Ulf Hansson --- Changes in v3: - None. --- drivers/opp/of.c | 39 +++------------------------------------ 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 55c8cfef97d4..fd5ed2858258 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -295,7 +295,7 @@ void _of_clear_opp(struct opp_table *opp_table, struct dev_pm_opp *opp) of_node_put(opp->np); } -static int _link_required_opps(struct dev_pm_opp *opp, struct opp_table *opp_table, +static int _link_required_opps(struct dev_pm_opp *opp, struct opp_table *required_table, int index) { struct device_node *np; @@ -313,39 +313,6 @@ static int _link_required_opps(struct dev_pm_opp *opp, struct opp_table *opp_tab return -ENODEV; } - /* - * There are two genpd (as required-opp) cases that we need to handle, - * devices with a single genpd and ones with multiple genpds. - * - * The single genpd case requires special handling as we need to use the - * same `dev` structure (instead of a virtual one provided by genpd - * core) for setting the performance state. - * - * It doesn't make sense for a device's DT entry to have both - * "opp-level" and single "required-opps" entry pointing to a genpd's - * OPP, as that would make the OPP core call - * dev_pm_domain_set_performance_state() for two different values for - * the same device structure. Lets treat single genpd configuration as a - * case where the OPP's level is directly available without required-opp - * link in the DT. - * - * Just update the `level` with the right value, which - * dev_pm_opp_set_opp() will take care of in the normal path itself. - * - * There is another case though, where a genpd's OPP table has - * required-opps set to a parent genpd. The OPP core expects the user to - * set the respective required `struct device` pointer via - * dev_pm_opp_set_config(). - */ - if (required_table->is_genpd && opp_table->required_opp_count == 1 && - !opp_table->required_devs[0]) { - /* Genpd core takes care of propagation to parent genpd */ - if (!opp_table->is_genpd) { - if (!WARN_ON(opp->level != OPP_LEVEL_UNSET)) - opp->level = opp->required_opps[0]->level; - } - } - return 0; } @@ -370,7 +337,7 @@ static int _of_opp_alloc_required_opps(struct opp_table *opp_table, if (IS_ERR_OR_NULL(required_table)) continue; - ret = _link_required_opps(opp, opp_table, required_table, i); + ret = _link_required_opps(opp, required_table, i); if (ret) goto free_required_opps; } @@ -391,7 +358,7 @@ static int lazy_link_required_opps(struct opp_table *opp_table, int ret; list_for_each_entry(opp, &opp_table->opp_list, node) { - ret = _link_required_opps(opp, opp_table, new_table, index); + ret = _link_required_opps(opp, new_table, index); if (ret) return ret; } From patchwork Thu Aug 22 22:45:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13774324 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 33198C5320E for ; Thu, 22 Aug 2024 22:52:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/SUsoi4RcXT0izJStB+EvDnWgGn5xCm1gI9JONZb3y0=; b=ywLHRRGRKQTb1V7HKH8bOq5Vj/ PWsNyC08wR5nMsKLJRGKPV5CeTYC7aHQnCOmRSTRk/9zU/lHZ72rQHgYcsjS7A6bDl0pg6uXt0z1e cDXYoueuXvcbCjZn46S+ym0uYILakHhgpJWH9cjItjFQvm8VjSHt/ZWpopZLNOv3FZq+fKt/IdXIc B+Ldfsv/kTdTXhTb6nnDWRGaoNY6iAHAdrjrB8ZLkFofuqt+p+i/yWf8ZWmURxci62Mvm6uFIcBLe g+AthVmCPHOmuchYF3UR8JXqw8mApG3WmNXqgh1ZeMXC1bnSmWSdf5JdaiXciMdICY+zDgVmMGsmE v7C8ftjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGey-0000000EWxP-3aEA; Thu, 22 Aug 2024 22:52:04 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGZM-0000000EVfT-0wm1 for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2024 22:46:17 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-5343617fdddso1316682e87.0 for ; Thu, 22 Aug 2024 15:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366774; x=1724971574; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/SUsoi4RcXT0izJStB+EvDnWgGn5xCm1gI9JONZb3y0=; b=kQggEHlCeqgtbNvnJoaENusPllAjUid5To8Jo70svxggKZr/TyniUEJ61dqKyr+TY8 27MJRNQwz0QrE1ADEJV4pV7nO4KkWQOYNQsm6H4KEvV1wiQGg4QjLFCdicRg8wd+m7oW 31xQxmqMIqjXSDUHpk42zOLv6IKLSP7Asj3K+BnPDkHdAFf83ZVFu4lQYPMbGjsdpnjR bTJgzi6GzZxy6xW/UAtFUSrRN6L+2zIiENMHENRReII2eySbT4io8K8m6iGwHAs20eLA TQj3wylnWhvzV4nnYyrlGMwJuQQSGFcJIBtVVt4/BTvSq9fKQw/YttWblJtd+JDospt4 TzsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366774; x=1724971574; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/SUsoi4RcXT0izJStB+EvDnWgGn5xCm1gI9JONZb3y0=; b=QRd9fmiDrqWfEt4ooxijkGzzkJQn3gEnp2FLZpyALhdurXPJnEJd6xx2Jz0gXm6IUX kliVS4FJ/1knIeWsc8CHsVJTCYLonxyQ7Jr4qDu9+I/3NeirfyLLjT6HfSVVRdf6I6Ha Pxl0aukHV0qH1hf6Q5x44tQUYpBQ0W4RcCMyXdyfOfVJGVZUTd732JBtuBZ8WhCk7TOC 3EZmYl61OrFW1THiTGWTo3q9F3a1N0LKdu/eCXtPHQLFF1wd0CoguouNllCs7tgE6lYU 5Epqc/pIJDHBPRUzgs1JVZr5iDNCwkgosfBSPhSoV+y7U07a7K78VDYZC+6U+j9QJ9kC yuvQ== X-Forwarded-Encrypted: i=1; AJvYcCWqN6Hxd7T31A0vkcmusVDVEENzbnR3gmmfI+GkzY2xA0NZKn1Ozm5elAiDai1bpgUzpqqy0RoqntR6Oo59E9JY@lists.infradead.org X-Gm-Message-State: AOJu0YysBTFrjP0siGdAvMavD6glskxjmmPO3nqOSQNjDCCfA419xV4R UPiJLD6/8zme5bZp2QoCVXQrcCP7U2Z7uu8LJd+byhpAjRAqFbL5X/k9xPsc2/U= X-Google-Smtp-Source: AGHT+IFCCObzEZAVeGe1xfyTqYfuTrbw8eyiD2QimVszxWbvB5nuySwzUySXFi47i38a78U9YOXQGg== X-Received: by 2002:a05:6512:3e19:b0:532:fb9e:a175 with SMTP id 2adb3069b0e04-5343883d5e7mr474551e87.6.1724366774161; Thu, 22 Aug 2024 15:46:14 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5334ea362a4sm379443e87.66.2024.08.22.15.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:13 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 07/10] drm/tegra: gr3d: Convert into devm_pm_domain_attach_list() Date: Fri, 23 Aug 2024 00:45:44 +0200 Message-Id: <20240822224547.385095-8-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-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-20240822_154616_287777_43F14864 X-CRM114-Status: GOOD ( 15.47 ) 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 Rather than hooking up the PM domains through devm_pm_opp_attach_genpd() and manage the device-link, let's avoid the boilerplate-code by converting into devm_pm_domain_attach_list(). Signed-off-by: Ulf Hansson Acked-by: Thierry Reding --- Changes in v3: - Updated commitmsg. - Converted to devm mangaged version of dev_pm_domain_attach_list() --- drivers/gpu/drm/tegra/gr3d.c | 38 +++++++----------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/tegra/gr3d.c b/drivers/gpu/drm/tegra/gr3d.c index 00c8564520e7..d52433cf939a 100644 --- a/drivers/gpu/drm/tegra/gr3d.c +++ b/drivers/gpu/drm/tegra/gr3d.c @@ -46,6 +46,7 @@ struct gr3d { unsigned int nclocks; struct reset_control_bulk_data resets[RST_GR3D_MAX]; unsigned int nresets; + struct dev_pm_domain_list *pd_list; DECLARE_BITMAP(addr_regs, GR3D_NUM_REGS); }; @@ -369,18 +370,12 @@ static int gr3d_power_up_legacy_domain(struct device *dev, const char *name, return 0; } -static void gr3d_del_link(void *link) -{ - device_link_del(link); -} - static int gr3d_init_power(struct device *dev, struct gr3d *gr3d) { - static const char * const opp_genpd_names[] = { "3d0", "3d1", NULL }; - const u32 link_flags = DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME; - struct device **opp_virt_devs, *pd_dev; - struct device_link *link; - unsigned int i; + struct dev_pm_domain_attach_data pd_data = { + .pd_names = (const char *[]) { "3d0", "3d1" }, + .num_pd_names = 2, + }; int err; err = of_count_phandle_with_args(dev->of_node, "power-domains", @@ -414,29 +409,10 @@ static int gr3d_init_power(struct device *dev, struct gr3d *gr3d) if (dev->pm_domain) return 0; - err = devm_pm_opp_attach_genpd(dev, opp_genpd_names, &opp_virt_devs); - if (err) + err = devm_pm_domain_attach_list(dev, &pd_data, &gr3d->pd_list); + if (err < 0) return err; - for (i = 0; opp_genpd_names[i]; i++) { - pd_dev = opp_virt_devs[i]; - if (!pd_dev) { - dev_err(dev, "failed to get %s power domain\n", - opp_genpd_names[i]); - return -EINVAL; - } - - link = device_link_add(dev, pd_dev, link_flags); - if (!link) { - dev_err(dev, "failed to link to %s\n", dev_name(pd_dev)); - return -EINVAL; - } - - err = devm_add_action_or_reset(dev, gr3d_del_link, link); - if (err) - return err; - } - return 0; } From patchwork Thu Aug 22 22:45:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13774325 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CBF2DC3DA4A for ; Thu, 22 Aug 2024 22:53:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=X1A26YlhfePaP3jDbaTwUiFXKbFKwoAq1rqRtisM7j8=; b=CkPfSdkDGBa8ljYKUzZx7l6FDf fQNW7jeKSZdpgNNrKFb5EMLGTXUxMYMTNfpCxSbOOjFT4J4k92Chw6rtHS0TEmWYLi95rxQYmby7K T9t2O++mdtkGjSu5Fm1RcRfNvUNUaLZVyR0/zvyKTSTF5CdA0gn/GqmeMPs5NEeJGqL48C6f2kL8I UdIfZC09vCl5XCHMksq/niAygw4aoFveRujKR9IPJ1xdYQJ0mL3lT6AplD9J3Of03VCZBBK+uxGw/ zNZ75/XlRaoOfLFRhAcswQscMH1y0GE1ir7XfQkdLqKiipoGIjxhZeG0Bs4uTa9VbtpLMap7hTF6r zZ7D1WUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGfh-0000000EX4N-0jSm; Thu, 22 Aug 2024 22:52:49 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGZN-0000000EVfr-2cTr for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2024 22:46:19 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-534366c1aa2so569797e87.1 for ; Thu, 22 Aug 2024 15:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366775; x=1724971575; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=X1A26YlhfePaP3jDbaTwUiFXKbFKwoAq1rqRtisM7j8=; b=XT2f4PZ5jJ5K3p5U9GU+W0MXbKF/nNg2UdHGocqRXeOjRMUeCgGmIUGWdQTr2kmjY2 YspPL861HTe0M3c32Cyt7h8SjExiOkdS7woVZ8o9exzb69+/jtvOV0AzgAg0axPDsYdP EAez1AiFHvIdrgznKu3+XoU1Cd8boO4xsPaukqftHddgQgI03lu8+R7ebCfdhEjJQHpk 6AS9htRS72TjKBcuvTbe6sVQ0O7mXIb8PtA06K2qVdQBeLvCNPw/kTS6zMVRgihvODgL n/7Yjg5rDnniyN9gGuGGVuv7qn/K/hqRYMXQz1AOFquDNtTpB6yXPImUf8486w/kW720 oHug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366775; x=1724971575; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X1A26YlhfePaP3jDbaTwUiFXKbFKwoAq1rqRtisM7j8=; b=AY5DvOSzzOB/G25m1ZHFjGyjwiSCL74pfH+zMrFfL6dlR0KUoKgayU+Ppks578/MMD s7oV2hnn7UPlJFRsTnf96yuDc/6lpToIx3CGpP/YBE9JsRSLtfnLgGcmGNghLK8+jo82 FobhJq5QFyCIOY8rKSAYINd9br7TXNd3+xVNKT/oFpHbA5kD7LDbzVKCI12iU/0LgVX3 /tVzOqDnpitEJZJqY9RSXPSQpIbP+pzJo4ghDTsC9j61Me/nqZdoBnKcqDW7X/mL3xa+ gfa402oBaYpn5glv04AjFqoW9W6l87pNE+b2m+0O6CvPjP3uYkPjodnB1jyrmzRAWVcW sd3Q== X-Forwarded-Encrypted: i=1; AJvYcCVXtHAPLtaAm3lKqqnRkUiTNUJS5Y1YXM1p/qoBpKRQhItddyQv6hV2UwPHLG2kbYFNQL6/091jEGo7T8N6FEsu@lists.infradead.org X-Gm-Message-State: AOJu0YxMgflIUHlzB1sf6r46qtxQBk/EaIMsqeWffrDQ5ff9KBELcjKR SBWYFkhOXmrk/dsotLcXJhC0pN3qjKwkzxw+wChWVWgdoITTv1KnhX9krV+479Q= X-Google-Smtp-Source: AGHT+IEYCvO6PxDZuiKr7Z/6TAjnmPIaE1HH1Y16/UregoH9/xLXNer5kgVUUiDFaWpCN/2/MSiCtA== X-Received: by 2002:a05:6512:1282:b0:533:4785:82a2 with SMTP id 2adb3069b0e04-53438869dccmr141908e87.59.1724366775519; Thu, 22 Aug 2024 15:46:15 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5334ea362a4sm379443e87.66.2024.08.22.15.46.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:15 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 08/10] media: venus: Convert into devm_pm_domain_attach_list() for OPP PM domain Date: Fri, 23 Aug 2024 00:45:45 +0200 Message-Id: <20240822224547.385095-9-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-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-20240822_154617_801504_FD8AA183 X-CRM114-Status: GOOD ( 21.31 ) 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 Rather than hooking up the PM domain through devm_pm_opp_attach_genpd() and manage the device-link, let's avoid the boilerplate-code by converting into devm_pm_domain_attach_list(). Acked-by: Stanimir Varbanov Signed-off-by: Ulf Hansson --- Changes in v3: - Updated commitmsg and added Stanimir's ack. - Converted to devm mangaged version of dev_pm_domain_attach_list() --- drivers/media/platform/qcom/venus/core.c | 8 ++-- drivers/media/platform/qcom/venus/core.h | 6 +-- .../media/platform/qcom/venus/pm_helpers.c | 44 +++++-------------- 3 files changed, 15 insertions(+), 43 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index 165c947a6703..4666278671e2 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -751,7 +751,7 @@ static const struct venus_resources sdm845_res_v2 = { .vcodec_clks_num = 2, .vcodec_pmdomains = (const char *[]) { "venus", "vcodec0", "vcodec1" }, .vcodec_pmdomains_num = 3, - .opp_pmdomain = (const char *[]) { "cx", NULL }, + .opp_pmdomain = (const char *[]) { "cx" }, .vcodec_num = 2, .max_load = 3110400, /* 4096x2160@90 */ .hfi_version = HFI_VERSION_4XX, @@ -800,7 +800,7 @@ static const struct venus_resources sc7180_res = { .vcodec_clks_num = 2, .vcodec_pmdomains = (const char *[]) { "venus", "vcodec0" }, .vcodec_pmdomains_num = 2, - .opp_pmdomain = (const char *[]) { "cx", NULL }, + .opp_pmdomain = (const char *[]) { "cx" }, .vcodec_num = 1, .hfi_version = HFI_VERSION_4XX, .vpu_version = VPU_VERSION_AR50, @@ -857,7 +857,7 @@ static const struct venus_resources sm8250_res = { .vcodec_clks_num = 1, .vcodec_pmdomains = (const char *[]) { "venus", "vcodec0" }, .vcodec_pmdomains_num = 2, - .opp_pmdomain = (const char *[]) { "mx", NULL }, + .opp_pmdomain = (const char *[]) { "mx" }, .vcodec_num = 1, .max_load = 7833600, .hfi_version = HFI_VERSION_6XX, @@ -916,7 +916,7 @@ static const struct venus_resources sc7280_res = { .vcodec_clks_num = 2, .vcodec_pmdomains = (const char *[]) { "venus", "vcodec0" }, .vcodec_pmdomains_num = 2, - .opp_pmdomain = (const char *[]) { "cx", NULL }, + .opp_pmdomain = (const char *[]) { "cx" }, .vcodec_num = 1, .hfi_version = HFI_VERSION_6XX, .vpu_version = VPU_VERSION_IRIS2_1, diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 55202b89e1b9..435325432922 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -132,9 +132,7 @@ struct venus_format { * @vcodec1_clks: an array of vcodec1 struct clk pointers * @video_path: an interconnect handle to video to/from memory path * @cpucfg_path: an interconnect handle to cpu configuration path - * @has_opp_table: does OPP table exist * @pmdomains: a pointer to a list of pmdomains - * @opp_dl_venus: an device-link for device OPP * @opp_pmdomain: an OPP power-domain * @resets: an array of reset signals * @vdev_dec: a reference to video device structure for decoder instances @@ -186,10 +184,8 @@ struct venus_core { struct clk *vcodec1_clks[VIDC_VCODEC_CLKS_NUM_MAX]; struct icc_path *video_path; struct icc_path *cpucfg_path; - bool has_opp_table; struct dev_pm_domain_list *pmdomains; - struct device_link *opp_dl_venus; - struct device *opp_pmdomain; + struct dev_pm_domain_list *opp_pmdomain; struct reset_control *resets[VIDC_RESETS_NUM_MAX]; struct video_device *vdev_dec; struct video_device *vdev_enc; diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c index ea8a2bd9419e..355dfa586f8e 100644 --- a/drivers/media/platform/qcom/venus/pm_helpers.c +++ b/drivers/media/platform/qcom/venus/pm_helpers.c @@ -864,7 +864,6 @@ static int venc_power_v4(struct device *dev, int on) static int vcodec_domains_get(struct venus_core *core) { int ret; - struct device **opp_virt_dev; struct device *dev = core->dev; const struct venus_resources *res = core->res; struct dev_pm_domain_attach_data vcodec_data = { @@ -872,6 +871,11 @@ static int vcodec_domains_get(struct venus_core *core) .num_pd_names = res->vcodec_pmdomains_num, .pd_flags = PD_FLAG_NO_DEV_LINK, }; + struct dev_pm_domain_attach_data opp_pd_data = { + .pd_names = res->opp_pmdomain, + .num_pd_names = 1, + .pd_flags = PD_FLAG_DEV_LINK_ON, + }; if (!res->vcodec_pmdomains_num) goto skip_pmdomains; @@ -881,37 +885,15 @@ static int vcodec_domains_get(struct venus_core *core) return ret; skip_pmdomains: - if (!core->res->opp_pmdomain) + if (!res->opp_pmdomain) return 0; /* Attach the power domain for setting performance state */ - ret = devm_pm_opp_attach_genpd(dev, res->opp_pmdomain, &opp_virt_dev); - if (ret) - goto opp_attach_err; - - core->opp_pmdomain = *opp_virt_dev; - core->opp_dl_venus = device_link_add(dev, core->opp_pmdomain, - DL_FLAG_RPM_ACTIVE | - DL_FLAG_PM_RUNTIME | - DL_FLAG_STATELESS); - if (!core->opp_dl_venus) { - ret = -ENODEV; - goto opp_attach_err; - } + ret = devm_pm_domain_attach_list(dev, &opp_pd_data, &core->opp_pmdomain); + if (ret < 0) + return ret; return 0; - -opp_attach_err: - return ret; -} - -static void vcodec_domains_put(struct venus_core *core) -{ - if (!core->has_opp_table) - return; - - if (core->opp_dl_venus) - device_link_del(core->opp_dl_venus); } static int core_resets_reset(struct venus_core *core) @@ -1000,9 +982,7 @@ static int core_get_v4(struct venus_core *core) if (core->res->opp_pmdomain) { ret = devm_pm_opp_of_add_table(dev); - if (!ret) { - core->has_opp_table = true; - } else if (ret != -ENODEV) { + if (ret && ret != -ENODEV) { dev_err(dev, "invalid OPP table in device tree\n"); return ret; } @@ -1013,10 +993,6 @@ static int core_get_v4(struct venus_core *core) static void core_put_v4(struct venus_core *core) { - if (legacy_binding) - return; - - vcodec_domains_put(core); } static int core_power_v4(struct venus_core *core, int on) From patchwork Thu Aug 22 22:45:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13774326 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B4B56C3DA4A for ; Thu, 22 Aug 2024 22:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=iksFSJ//26ReVaxAnVHvTDyArAC4NnchBY2BZAJDBow=; b=IF3HdXM6s+4Go2tn8b5fI3ld+N sIzb78dpx6lV7RVB4uAFG4kM33dH7kHffNvf58aM1Qt/vpHgXlk1D7+k1J3fvy1r2Kb4xcN9rUIol bE4up8nfGRZlVXeeC9Lj7HFBEECL9142Jin8lbo8bOdcxL4bq4EBrJH0A/uAaa3i05wxU1oXkJ6DI NHvERZFxqg3r39x/mDUoAcWWvqT+0Iu0rKf2Yw9q5GUaWDYSprshkxez82tGagzUrmFgKpU7LZLeV XkXOB3iLYyq/6gAFPGMRXzWpTs26Kurt/PilytFnoW6+RtR30xdonVc7NM4No+kWZSeYG9IGGruTc q2x6Hl3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGgO-0000000EXDc-1iy0; Thu, 22 Aug 2024 22:53:32 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGZO-0000000EVgN-28Ch for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2024 22:46:19 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-53349ee42a9so1662879e87.3 for ; Thu, 22 Aug 2024 15:46:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366777; x=1724971577; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iksFSJ//26ReVaxAnVHvTDyArAC4NnchBY2BZAJDBow=; b=SWi/twzg+jta+UVmdTG4pZf6zBnsmGWD18ArOZzRLycNoKoyon2R72ttogea+z7vyh PfW8UCoJ9jkqaWW1gIWR/XxMff7OrLnFJfztthvS62uY3DMyaM4WsCde7iWGVZQgwUWt MID1A2vJUofuY5PKZV5L0Tpyv3X3QcMF4ZASfviV2TZglrqhcjFKBMKWIVPVSy4aTvxz JwTfz8H7o+VOA+jTZbMqTNjKXmSzifUF6DfRKWv0Z9+7jtau6oPg1CVEfUs1YdJf+6XA ntxOGuTS2Ja6Wz0tgi7T6CTYVoPDz9WWN6EV1xUcDnrOrNWikrqi2r8qhP1tfTg36Pz3 PQNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366777; x=1724971577; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iksFSJ//26ReVaxAnVHvTDyArAC4NnchBY2BZAJDBow=; b=PGoK9iuYm5C1Px9rszFy81W2xmUgv8kSTc2zDVwhaOgwQtwYN4AgOIdBJtdOfae/G1 Fnii/u03FqtmK/M9aDl/rYFO+Yb0u8CT7HslGRcgfe0GKfx9Zg99Po0rUGQHW734N0aQ UuZPK/igOb93XsfFzPHu+iBb8V6TpplKd6KxQH3bVFF01BV+RNdOUcg+uCkd71JCc94C dvzIv7LjY+/YzC4KMY2qMF5gBW4nnsGirUn3YypRBwUDNY1nc51euo1sJMYp2PZjqhpt n7IVodh2LqnzCwb8rrTFllSPbOi8gvZXeOhK2tKpI93CK3XYT9m1zGuk4RVpH1dF9ekq OZVA== X-Forwarded-Encrypted: i=1; AJvYcCVS3I7Xh0Tu4jlP9kF+OCkgx2NdwaF1HqXn3bOtDBKBZVpJDH/FpySUH55sDKhlp6BfkXz/ZFT9IbVmpx9jBwTJ@lists.infradead.org X-Gm-Message-State: AOJu0YwZTddiRMcfa7iQRnB+zFahj1aPUpB84aitrlgd4tnYfxEes4zP 68OOy5OrIbG/8zvj8Dzil6NMuOx58yDYuQx2QWmYhVRfKawX0/CXaMCYGNU9W84= X-Google-Smtp-Source: AGHT+IFqYnnUrUddlV2VzJzkFcuvSxGz0XMOiVMuzx0Kw0HD/D4q6JeKW5PZ8PIU3LGdvGhnAFZwtQ== X-Received: by 2002:a05:6512:15a2:b0:530:ba4b:f65d with SMTP id 2adb3069b0e04-534387852e1mr179442e87.28.1724366776756; Thu, 22 Aug 2024 15:46:16 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5334ea362a4sm379443e87.66.2024.08.22.15.46.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:16 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 09/10] cpufreq: qcom-nvmem: Convert to dev_pm_domain_attach|detach_list() Date: Fri, 23 Aug 2024 00:45:46 +0200 Message-Id: <20240822224547.385095-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-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-20240822_154618_584253_2C3B6C53 X-CRM114-Status: GOOD ( 21.35 ) 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 Rather than hooking up the PM domains through _opp_attach_genpd() and manually manage runtime PM for the corresponding virtual devices created by genpd during attach, let's avoid the boilerplate-code by converting into dev_pm_domain_attach|detach_list. Signed-off-by: Ulf Hansson --- Changes in v3: - None. --- drivers/cpufreq/qcom-cpufreq-nvmem.c | 79 +++++++++------------------- 1 file changed, 26 insertions(+), 53 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c index 939702dfa73f..6ba8c8378384 100644 --- a/drivers/cpufreq/qcom-cpufreq-nvmem.c +++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c @@ -52,12 +52,13 @@ struct qcom_cpufreq_match_data { struct nvmem_cell *speedbin_nvmem, char **pvs_name, struct qcom_cpufreq_drv *drv); - const char **genpd_names; + const char **pd_names; + unsigned int num_pd_names; }; struct qcom_cpufreq_drv_cpu { int opp_token; - struct device **virt_devs; + struct dev_pm_domain_list *pd_list; }; struct qcom_cpufreq_drv { @@ -395,8 +396,6 @@ static int qcom_cpufreq_ipq8074_name_version(struct device *cpu_dev, return 0; } -static const char *generic_genpd_names[] = { "perf", NULL }; - static const struct qcom_cpufreq_match_data match_data_kryo = { .get_version = qcom_cpufreq_kryo_name_version, }; @@ -407,13 +406,13 @@ static const struct qcom_cpufreq_match_data match_data_krait = { static const struct qcom_cpufreq_match_data match_data_msm8909 = { .get_version = qcom_cpufreq_simple_get_version, - .genpd_names = generic_genpd_names, + .pd_names = (const char *[]) { "perf" }, + .num_pd_names = 1, }; -static const char *qcs404_genpd_names[] = { "cpr", NULL }; - static const struct qcom_cpufreq_match_data match_data_qcs404 = { - .genpd_names = qcs404_genpd_names, + .pd_names = (const char *[]) { "cpr" }, + .num_pd_names = 1, }; static const struct qcom_cpufreq_match_data match_data_ipq6018 = { @@ -428,28 +427,16 @@ static const struct qcom_cpufreq_match_data match_data_ipq8074 = { .get_version = qcom_cpufreq_ipq8074_name_version, }; -static void qcom_cpufreq_suspend_virt_devs(struct qcom_cpufreq_drv *drv, unsigned int cpu) +static void qcom_cpufreq_suspend_pd_devs(struct qcom_cpufreq_drv *drv, unsigned int cpu) { - const char * const *name = drv->data->genpd_names; + struct dev_pm_domain_list *pd_list = drv->cpus[cpu].pd_list; int i; - if (!drv->cpus[cpu].virt_devs) + if (!pd_list) return; - for (i = 0; *name; i++, name++) - device_set_awake_path(drv->cpus[cpu].virt_devs[i]); -} - -static void qcom_cpufreq_put_virt_devs(struct qcom_cpufreq_drv *drv, unsigned int cpu) -{ - const char * const *name = drv->data->genpd_names; - int i; - - if (!drv->cpus[cpu].virt_devs) - return; - - for (i = 0; *name; i++, name++) - pm_runtime_put(drv->cpus[cpu].virt_devs[i]); + for (i = 0; i < pd_list->num_pds; i++) + device_set_awake_path(pd_list->pd_devs[i]); } static int qcom_cpufreq_probe(struct platform_device *pdev) @@ -503,7 +490,6 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) } for_each_possible_cpu(cpu) { - struct device **virt_devs = NULL; struct dev_pm_opp_config config = { .supported_hw = NULL, }; @@ -522,12 +508,7 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) config.prop_name = pvs_name; } - if (drv->data->genpd_names) { - config.genpd_names = drv->data->genpd_names; - config.virt_devs = &virt_devs; - } - - if (config.supported_hw || config.genpd_names) { + if (config.supported_hw) { drv->cpus[cpu].opp_token = dev_pm_opp_set_config(cpu_dev, &config); if (drv->cpus[cpu].opp_token < 0) { ret = drv->cpus[cpu].opp_token; @@ -536,25 +517,17 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) } } - if (virt_devs) { - const char * const *name = config.genpd_names; - int i, j; - - for (i = 0; *name; i++, name++) { - ret = pm_runtime_resume_and_get(virt_devs[i]); - if (ret) { - dev_err(cpu_dev, "failed to resume %s: %d\n", - *name, ret); + if (drv->data->pd_names) { + struct dev_pm_domain_attach_data attach_data = { + .pd_names = drv->data->pd_names, + .num_pd_names = drv->data->num_pd_names, + .pd_flags = PD_FLAG_DEV_LINK_ON, + }; - /* Rollback previous PM runtime calls */ - name = config.genpd_names; - for (j = 0; *name && j < i; j++, name++) - pm_runtime_put(virt_devs[j]); - - goto free_opp; - } - } - drv->cpus[cpu].virt_devs = virt_devs; + ret = dev_pm_domain_attach_list(cpu_dev, &attach_data, + &drv->cpus[cpu].pd_list); + if (ret < 0) + goto free_opp; } } @@ -570,7 +543,7 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) free_opp: for_each_possible_cpu(cpu) { - qcom_cpufreq_put_virt_devs(drv, cpu); + dev_pm_domain_detach_list(drv->cpus[cpu].pd_list); dev_pm_opp_clear_config(drv->cpus[cpu].opp_token); } return ret; @@ -584,7 +557,7 @@ static void qcom_cpufreq_remove(struct platform_device *pdev) platform_device_unregister(cpufreq_dt_pdev); for_each_possible_cpu(cpu) { - qcom_cpufreq_put_virt_devs(drv, cpu); + dev_pm_domain_detach_list(drv->cpus[cpu].pd_list); dev_pm_opp_clear_config(drv->cpus[cpu].opp_token); } } @@ -595,7 +568,7 @@ static int qcom_cpufreq_suspend(struct device *dev) unsigned int cpu; for_each_possible_cpu(cpu) - qcom_cpufreq_suspend_virt_devs(drv, cpu); + qcom_cpufreq_suspend_pd_devs(drv, cpu); return 0; } From patchwork Thu Aug 22 22:45:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13774327 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CFA05C3DA4A for ; Thu, 22 Aug 2024 22:54:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VphURB1Gan/55uptQu3RfCpWor8wG0jCnNbpjQVr+aE=; b=PGqmCbHVv//WYQfMTHhjapDfu4 QV3vrAjS8Q4qlzOAL7HbVSz6jKCZ5yv1HbthBLXgcaNi9JWoQX/9Hyj5TLWcQ02iESCUCFq/boE/s L0zvlkQREbjuzr/umOt1s7jrfAlc77hTNjDdb8CUNH5QbU5H/Qn0WU7t7ggHLNrAJ/AbFlQFvAj2f qH2H1K8NXiyPOsa/4fkKUwfefdZgUowlELHirLNSGvkyaMQpHjMCpliB2JROk01Z3S4cl2y++Eqgk BNOi2vzMy80M5JL1TCl+TUttBO0o4V9CsrG3d63Q9PXI3/54w/aOeWUEOA5VyzSYCWFeYGy4Oz+/D 2q/9D0xQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGh6-0000000EXKv-3TIL; Thu, 22 Aug 2024 22:54:16 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shGZP-0000000EVh2-3Ray for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2024 22:46:21 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-5334879ba28so1672088e87.3 for ; Thu, 22 Aug 2024 15:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366778; x=1724971578; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VphURB1Gan/55uptQu3RfCpWor8wG0jCnNbpjQVr+aE=; b=SJJt3ZK/1BLSKA2oWNxqZQchdl8A2m1wrjAlseRLZef7X+7u3PF0wgEPXtJW1GiqHM XhAw4EnQFMywdncSKpI3wtoyZk6goyT+7gjE6UR3eSP8nPePj3ZOtSyORdydHzbsMxeo IfmE07B3RGz7YMVGnoBoWnJRPet5/9ICBUrvdZHDIUned9xtbWzBePfO0GQowPFS4yh6 PNklPuBFys5OI+YyNKHtvB3ScjdK1Vnln4Tl8HfGKmgle72ZKMqYhjUq/IDL/8XjEGQj 1Lekvi7/eV8e2XHxCBnb9G9UygFNk4dwJAhJc2bTmkou6MsLug9n81ulzOoY2Q7cYnGI 7vcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366778; x=1724971578; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VphURB1Gan/55uptQu3RfCpWor8wG0jCnNbpjQVr+aE=; b=OfjZ79JYx9yBBgoIPQb4NMAEi3vvWbhAlh/cM06m67rVEy5PIa94ZXonW7wVgtUsXr /Rynh6FjWB56VYWxlNm51uPGv97LhjVw04t3ShMylaQiK22OO3wiRRBXJbKPEWk84UPJ 2yOw0MYIaEHkX31Ajrz/0bvgFqlXaAcgT2unWViw52FxsXuE/DjzCgdh8j8GZ8pxzd1T qw4+Ts/3lN4VQCXPMsviFrcWFl5zihuSyWurIh4r/nzcyPjijuCecVrmtA28K1MkyaBx CWopDGuhOxuHiSn/EDBwYMsxb1EeuTKVADQhgwxmCuIAEjcSZdtMkHgZcsvkDqtf6AnR Lrew== X-Forwarded-Encrypted: i=1; AJvYcCWjkBMuOhewQZ81PVZFm/wpFxdb2fEPcedFoHdiRpXVrBhJUbzaEcQ1jaLigj9PInFSHnxAhu7b8pZGNKhU2vwp@lists.infradead.org X-Gm-Message-State: AOJu0Yw2mPrbpWT8hxiUyfxNXbQ4KpOJTwgUzgTE23IVubpmUmjr7/mb 7DOgU1s55OuYn4TzS9KEPuxexSpk/U/S04ii6MBIv/qAhwllrEMuwXG+ViFGADk= X-Google-Smtp-Source: AGHT+IFXpNYl8qtj2IvlPSDp3CA4+6RBm9vf/UbMJ3jZi+owQVOFOxqR3Yik2fhh9EMH6VdRLWKJ4g== X-Received: by 2002:a05:6512:31c4:b0:52e:f950:31f3 with SMTP id 2adb3069b0e04-53438785441mr234491e87.35.1724366778108; Thu, 22 Aug 2024 15:46:18 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5334ea362a4sm379443e87.66.2024.08.22.15.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:17 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 10/10] OPP: Drop redundant _opp_attach|detach_genpd() Date: Fri, 23 Aug 2024 00:45:47 +0200 Message-Id: <20240822224547.385095-11-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-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-20240822_154619_897733_B9668C89 X-CRM114-Status: GOOD ( 25.44 ) 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 All users of _opp_attach|detach_genpd(), have been converted to use dev|devm_pm_domain_attach|detach_list(), hence let's drop it along with its corresponding exported functions. Signed-off-by: Ulf Hansson --- Changes in v3: - None. --- drivers/opp/core.c | 96 +----------------------------------------- drivers/opp/opp.h | 3 +- include/linux/pm_opp.h | 38 +---------------- 3 files changed, 3 insertions(+), 134 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index cad7e84c9ad3..66cac7a1d9db 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2360,86 +2360,6 @@ static void _opp_put_config_regulators_helper(struct opp_table *opp_table) opp_table->config_regulators = NULL; } -static void _opp_detach_genpd(struct opp_table *opp_table) -{ - int index; - - for (index = 0; index < opp_table->required_opp_count; index++) { - if (!opp_table->required_devs[index]) - continue; - - dev_pm_domain_detach(opp_table->required_devs[index], false); - } -} - -/* - * Multiple generic power domains for a device are supported with the help of - * virtual genpd devices, which are created for each consumer device - genpd - * pair. These are the device structures which are attached to the power domain - * and are required by the OPP core to set the performance state of the genpd. - * The same API also works for the case where single genpd is available and so - * we don't need to support that separately. - * - * This helper will normally be called by the consumer driver of the device - * "dev", as only that has details of the genpd names. - * - * This helper needs to be called once with a list of all genpd to attach. - * Otherwise the original device structure will be used instead by the OPP core. - * - * The order of entries in the names array must match the order in which - * "required-opps" are added in DT. - */ -static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, - const char * const *names, struct device ***virt_devs) -{ - struct device *virt_dev; - int index = 0, ret = -EINVAL; - const char * const *name = names; - - if (!opp_table->required_devs) { - dev_err(dev, "Required OPPs not available, can't attach genpd\n"); - return -EINVAL; - } - - /* Genpd core takes care of propagation to parent genpd */ - if (opp_table->is_genpd) { - dev_err(dev, "%s: Operation not supported for genpds\n", __func__); - return -EOPNOTSUPP; - } - - /* Checking only the first one is enough ? */ - if (opp_table->required_devs[0]) - return 0; - - while (*name) { - if (index >= opp_table->required_opp_count) { - dev_err(dev, "Index can't be greater than required-opp-count - 1, %s (%d : %d)\n", - *name, opp_table->required_opp_count, index); - goto err; - } - - virt_dev = dev_pm_domain_attach_by_name(dev, *name); - if (IS_ERR_OR_NULL(virt_dev)) { - ret = virt_dev ? PTR_ERR(virt_dev) : -ENODEV; - dev_err(dev, "Couldn't attach to pm_domain: %d\n", ret); - goto err; - } - - index++; - name++; - } - - if (virt_devs) - *virt_devs = opp_table->required_devs; - - return 0; - -err: - _opp_detach_genpd(opp_table); - return ret; - -} - static int _opp_set_required_dev(struct opp_table *opp_table, struct device *dev, struct device *required_dev, @@ -2516,9 +2436,6 @@ static void _opp_clear_config(struct opp_config_data *data) { if (data->flags & OPP_CONFIG_REQUIRED_DEV) _opp_put_required_dev(data->opp_table, data->index); - else if (data->flags & OPP_CONFIG_GENPD) - _opp_detach_genpd(data->opp_table); - if (data->flags & OPP_CONFIG_REGULATOR) _opp_put_regulators(data->opp_table); if (data->flags & OPP_CONFIG_SUPPORTED_HW) @@ -2630,18 +2547,7 @@ int dev_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config) data->flags |= OPP_CONFIG_REGULATOR; } - /* Attach genpds */ - if (config->genpd_names) { - if (config->required_dev) - goto err; - - ret = _opp_attach_genpd(opp_table, dev, config->genpd_names, - config->virt_devs); - if (ret) - goto err; - - data->flags |= OPP_CONFIG_GENPD; - } else if (config->required_dev && config->required_opp_table) { + if (config->required_dev && config->required_opp_table) { ret = _opp_set_required_dev(opp_table, dev, config->required_dev, config->required_opp_table); diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 5b5a4bd89c9e..318a4ecbabf1 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -34,8 +34,7 @@ extern struct list_head opp_tables; #define OPP_CONFIG_REGULATOR_HELPER BIT(2) #define OPP_CONFIG_PROP_NAME BIT(3) #define OPP_CONFIG_SUPPORTED_HW BIT(4) -#define OPP_CONFIG_GENPD BIT(5) -#define OPP_CONFIG_REQUIRED_DEV BIT(6) +#define OPP_CONFIG_REQUIRED_DEV BIT(5) /** * struct opp_config_data - data for set config operations diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 5fade5c4de40..451a7465a605 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -62,11 +62,7 @@ typedef int (*config_clks_t)(struct device *dev, struct opp_table *opp_table, * @supported_hw: Array of hierarchy of versions to match. * @supported_hw_count: Number of elements in the array. * @regulator_names: Array of pointers to the names of the regulator, NULL terminated. - * @genpd_names: Null terminated array of pointers containing names of genpd to - * attach. Mutually exclusive with required_dev. - * @virt_devs: Pointer to return the array of genpd virtual devices. Mutually - * exclusive with required_dev. - * @required_dev: Required OPP device. Mutually exclusive with genpd_names/virt_devs. + * @required_dev: Required OPP device. * @required_opp_table: The corresponding required OPP table for @required_dev. * * This structure contains platform specific OPP configurations for the device. @@ -80,8 +76,6 @@ struct dev_pm_opp_config { const unsigned int *supported_hw; unsigned int supported_hw_count; const char * const *regulator_names; - const char * const *genpd_names; - struct device ***virt_devs; struct device *required_dev; struct opp_table *required_opp_table; }; @@ -677,36 +671,6 @@ static inline void dev_pm_opp_put_config_regulators(int token) dev_pm_opp_clear_config(token); } -/* genpd helpers */ -static inline int dev_pm_opp_attach_genpd(struct device *dev, - const char * const *names, - struct device ***virt_devs) -{ - struct dev_pm_opp_config config = { - .genpd_names = names, - .virt_devs = virt_devs, - }; - - return dev_pm_opp_set_config(dev, &config); -} - -static inline void dev_pm_opp_detach_genpd(int token) -{ - dev_pm_opp_clear_config(token); -} - -static inline int devm_pm_opp_attach_genpd(struct device *dev, - const char * const *names, - struct device ***virt_devs) -{ - struct dev_pm_opp_config config = { - .genpd_names = names, - .virt_devs = virt_devs, - }; - - return devm_pm_opp_set_config(dev, &config); -} - /* prop-name helpers */ static inline int dev_pm_opp_set_prop_name(struct device *dev, const char *name) {