From patchwork Mon Sep 25 13:17:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13397790 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 B9B5CCE7A94 for ; Mon, 25 Sep 2023 13:18:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2bYZ3Yl8ToFy5NFCS4OBfICc6qHhYtNXacaxDYtOACo=; b=bwagOiZ38VP/fz QtiA++o61hujCvl1P1auAutHAWI/zuA85TvZKDk6kkbUp1RcEguekiJ5HNEB4Hq6hIi+fqwnrxQoD xUgZ/b+u08iKoByuzIvIKgWHZmyl16bgvGSZwYOqd1sx1dKdL2z/6bJNJYfSgtNrF+DkT0NfeoRcf Ck5kTvuoVkIAKwrcmRaAnirNWK0LxbopFQz8nm6cE1U3I9ByfZf3waG/eP0KHt9CWNRZIPxSTMmoE 3h3tPJuAoVwU6XcE3rYNvMtDGgy3BrQ2bIuUyL4ktBZjH0z+Oo5ItOKCDBwCiozYsrDkR8hCpuMh5 ZcEj5GcvkoILqx+udJaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qklTd-00EJW9-0S; Mon, 25 Sep 2023 13:18:17 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qklTP-00EJPp-1k for linux-arm-kernel@lists.infradead.org; Mon, 25 Sep 2023 13:18:05 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-5043120ffbcso9372454e87.2 for ; Mon, 25 Sep 2023 06:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695647882; x=1696252682; 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=2bFHpy7o1LqMw4W/VuJiDN5LSPCulCxHGcm0dhiriMk=; b=I9TGzz2+s4CKn/KBSRoRbN7KO5H9tgIJGdvCCT4Hw48ERAxw963qPYmHtdY1xx5sF9 nOcRsr7mneexvQmS1kN8cE+/Ro1BO3VQJruOsMu6MCspzVQijSpDUdi1Zd2663OWJtlv OMo178SnvoTFTLZviFnXx0bVreiJAKL76aJclDrUuSNO3fjAGRl6sBvDUVOGIFtt8iOA SfxgFgnASBZyjy6yFyL0EbqHlTRTbLm0bsgx1qqnmbercFFvG4TaaEQmMtGhp4IMRyib XzvmemJPYWXjWpg+Xx5kVBPDx0bc6pCclxCB/bOIb1dtIIUHONdS1u2U2GPkqTHPzynD qbig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695647882; x=1696252682; 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=2bFHpy7o1LqMw4W/VuJiDN5LSPCulCxHGcm0dhiriMk=; b=eNZOVoWuZnXyerj2ZcbFYCxceqqzbOow9gXRUPVvPENJurUOjscqZFfaEYJ0cbpVV4 t91bBnk7AVCKVxHspZ4H0Lazj7PEwUxgPTJP9NdYpxhIodXhfvMYDtuh0SaRKR8M2RFN EhAdsX8MSMbbeNSrsjkIb7X4s2sfMNFslPPnhGFBy+XrlaFGe/LgzJarbb0vx+YSmO4j V24syZf0HtggAYHtIexlj/OMRYvkiHW/PCiDd7E4x3lYOwXBg4AIcDJ34RxI0PSCU5hy ekNPsbfPanRGh/PET0xFfAVCboBEazq+lcvy25I2YOvBEvQyvIXocNEGDCZlxhzKCB5u L/FQ== X-Gm-Message-State: AOJu0Yw62erRC+im9KkqARaqF6jin53qY0uzD1xT0DEjLHGWeARsCUJS ZU0EJIe2G4wYoc8+f59VFncp6g== X-Google-Smtp-Source: AGHT+IGmFBgkJKVaTj0hT0ug8ZmhpL42wRm/KPZyj7Yq0oqitc6hAqHCl9UOX5muul8rmBpDMAJOnQ== X-Received: by 2002:a05:6512:39c5:b0:4fd:faa5:64ed with SMTP id k5-20020a05651239c500b004fdfaa564edmr7421632lfu.11.1695647882083; Mon, 25 Sep 2023 06:18:02 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id m29-20020a056512015d00b004fe10276bbfsm1823583lfo.296.2023.09.25.06.18.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 06:18:01 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , "Rafael J . Wysocki" Cc: Nishanth Menon , Stephen Boyd , Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/9] OPP: Extend support for the opp-level beyond required-opps Date: Mon, 25 Sep 2023 15:17:12 +0200 Message-Id: <20230925131715.138411-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230925131715.138411-1-ulf.hansson@linaro.org> References: <20230925131715.138411-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-20230925_061803_580459_769EC948 X-CRM114-Status: GOOD ( 17.61 ) 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 the level (performance state) for an OPP is currently limited to be requested for a device that is attached to a PM domain. Moreover, the device needs to have the so called required-opps assigned to it, which are based upon OPP tables being described in DT. To extend the support beyond required-opps and DT, let's enable the level to be set for all OPPs. More precisely, if the requested OPP has a valid level let's try to request it through the device's optional PM domain, via calling dev_pm_domain_set_performance_state(). Signed-off-by: Ulf Hansson --- drivers/opp/core.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 60dca60ac4af..afb73978cdcb 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1107,6 +1107,22 @@ void _update_set_required_opps(struct opp_table *opp_table) opp_table->set_required_opps = _opp_set_required_opps_generic; } +static int _set_opp_level(struct device *dev, struct opp_table *opp_table, + struct dev_pm_opp *opp) +{ + int ret = 0; + + /* Request a new performance state through the device's PM domain. */ + if (opp && opp->level) { + ret = dev_pm_domain_set_performance_state(dev, opp->level); + if (ret) + dev_err(dev, "Failed to set performance state %u (%d)\n", + opp->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); @@ -1154,8 +1170,13 @@ static int _disable_opp_table(struct device *dev, struct opp_table *opp_table) if (opp_table->regulators) regulator_disable(opp_table->regulators[0]); + ret = _set_opp_level(dev, opp_table, NULL); + if (ret) + goto out; + ret = _set_required_opps(dev, opp_table, NULL, false); +out: opp_table->enabled = false; return ret; } @@ -1198,6 +1219,10 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table, return ret; } + ret = _set_opp_level(dev, opp_table, opp); + if (ret) + return ret; + ret = _set_opp_bw(opp_table, opp, dev); if (ret) { dev_err(dev, "Failed to set bw: %d\n", ret); @@ -1241,6 +1266,10 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table, return ret; } + ret = _set_opp_level(dev, opp_table, opp); + if (ret) + return ret; + ret = _set_required_opps(dev, opp_table, opp, false); if (ret) { dev_err(dev, "Failed to set required opps: %d\n", ret);