Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3187094rdb; Thu, 16 Nov 2023 02:43:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIoCr6Y9uyfv4JwjC0aakh5Dto1Eswdr3kws3Ob9YgriUtAquwxdWeKqegp7G5edf1qi91 X-Received: by 2002:a17:903:1212:b0:1cc:688e:5b1e with SMTP id l18-20020a170903121200b001cc688e5b1emr8069819plh.67.1700131423534; Thu, 16 Nov 2023 02:43:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700131423; cv=none; d=google.com; s=arc-20160816; b=CWO0sDSNFWrXZCAIJ9g2/gkAYQJDq9rkPwHSCK4Iiu/1SITTknfbANQiBb8nOL0hxP K6DlQxxUWFwIJV7xuIfzOIUO/qM36QBi4MIRfRVgiAVNAclfFFYqvZINGz+uwoN8qy5Z 2gD7HJWhMO160GhPea08yWpIYqoDmsCWg5OOHBRv/XtrFosZQTvQntEsHR3ROz2z9YUP 6f45aj9I4EfScOKut1v+NF6b9OJe/VANg4e1p25zFHRHAhDWL51wkgai6vbgLTJ8x3Pl 66loVuCb4gmDv9mtq6vMZxWgXFHbRrPJ9vq02lMECuWkq9ZaYXJ8ivs38INaD6tJeSIZ fuBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=exfqg5Gy1TL1CFxTgMKzEKKiOxoyEHWs3MeOTbQpbPM=; fh=q3Bj0ayvFxizQFMlBMShVxb+LnNED/AS984AvaT7ZtU=; b=V/5gTHqi+Eh4UVDVLa5cqXOWYtEnp/jBx5vOgnrUM2WOHFg3hF/yu2WkaULszgLHlT Sx5c9CqHA/4jOWTqgRvMFHsUQshvqAhO1oeyP1oIAAri/oCGpldttuKws2ESq+maiPoD FTDhBOih+QDW4x/6LqavYbyb0iBYNXXrFeM0Hf8AVLIMsl+lfO1PYGUV/neWuRzKYt6T 58lTHc32C+dOjvjlE7WKG13ZgXFMHiXW44qgRRHTtIzBgPFKZCdpzA/iwvvFkQU1Uz8t pRgIA7tgz0EtX6U+7RNvye8Vrti+WELGn3e2gLVW8Wl8h+GuzW0Xhxs3KMUHAvTjsIJG s2Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oakk90eG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id i17-20020a170902c95100b001c3b4eb2135si12478319pla.463.2023.11.16.02.43.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 02:43:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oakk90eG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id DA31681A6E7D; Thu, 16 Nov 2023 02:43:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345030AbjKPKnh (ORCPT + 99 others); Thu, 16 Nov 2023 05:43:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345013AbjKPKna (ORCPT ); Thu, 16 Nov 2023 05:43:30 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AD70B8 for ; Thu, 16 Nov 2023 02:43:26 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1cc58219376so5875305ad.1 for ; Thu, 16 Nov 2023 02:43:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700131406; x=1700736206; darn=vger.kernel.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=exfqg5Gy1TL1CFxTgMKzEKKiOxoyEHWs3MeOTbQpbPM=; b=oakk90eGdb/FNiJPskBRpKIq57Win0VAbBKOf+E4B/7IdKDzVD7ITZkmh6KdJQ2u9z Y7j+PyUb0WZ9ErwLXaMGDo7yCQjOpbV/idfDkKfph7kzKNuxznhQNZMEB5zit6nODio7 sfJ6qLREHVGTPFix6winUMF0u4FeKb3JJ2bIK1UYN50q9ikI7Gpwg/+P2bYO8KZJIyM7 MDWDcCsagV0OSNUV5fGCNLsdidfdSqgUrBbIzs3mr+0HMaCi8xNrfNLOM794o65fsys3 w+WWA350h0bIHQjjpFNh+lcHeyJIZUBVqC5FVdNqV63aVMPzi7cuS7a9tzsbyq3SEyBv OR+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700131406; x=1700736206; 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=exfqg5Gy1TL1CFxTgMKzEKKiOxoyEHWs3MeOTbQpbPM=; b=wbH+mA9lrAzJwfm/4RtRUb1Eb8TvWa1Ufe78GcaPjAoGS/dOPcVGhy4BOg622i8VIF THoFSsTXJKyCNHjWDjcBaozQrD1CC5S+F74JBnTJQDxRieFNqOyRT6vxpvgFYNBnCJt2 Y5cszSNWr5LF9+vbncMwYsXyp3egfR8Uq3wBE42i+rcN0qvgJvaM14U95Ji8Tex8Y43i 8wt9dk0jg9LgDJcAHexPkInmTiJQo1hG6mxCZMyHukFtI/XaEO/HqqYfUcYUlu833qJV pv/iBVHuWOVMoV35Apy0RyE04afwViso2KP5Ptr+99+bJDHwFMNVkWo12+2+UqZsdejH MYxw== X-Gm-Message-State: AOJu0Yy7V+GR/6DBaZXOPUV1Tzdzx+MsIEcMbT0Z2XlOD9MeEg8mdUj9 pFRUa20RA3Aq6nViUG3zGv/FxQ== X-Received: by 2002:a17:90b:3e89:b0:281:40b:5a7a with SMTP id rj9-20020a17090b3e8900b00281040b5a7amr16857952pjb.8.1700131405640; Thu, 16 Nov 2023 02:43:25 -0800 (PST) Received: from localhost ([122.172.82.6]) by smtp.gmail.com with ESMTPSA id sr5-20020a17090b4e8500b00280c6f35546sm1307044pjb.49.2023.11.16.02.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 02:43:25 -0800 (PST) From: Viresh Kumar To: Ulf Hansson , Stephan Gerhold , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Konrad Dybcio , Manivannan Sadhasivam , linux-kernel@vger.kernel.org Subject: [PATCH V3 3/3] OPP: Don't set OPP recursively for a parent genpd Date: Thu, 16 Nov 2023 16:13:07 +0530 Message-Id: <084b6088106da837abc43526c11d7d8bec850c5c.1700131353.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 16 Nov 2023 02:43:41 -0800 (PST) Like other frameworks (clk, regulator, etc.) genpd core too takes care of propagation to performance state to parent genpds. The OPP core shouldn't attempt the same, or it may result in undefined behavior. Add checks at various places to take care of the same. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 16 +++++++++++++++- drivers/opp/of.c | 7 +++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index e08375ed50aa..4f1ca84d9ed0 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2392,6 +2392,12 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, 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; @@ -2453,8 +2459,16 @@ static int _opp_set_required_devs(struct opp_table *opp_table, if (opp_table->required_devs[0]) return 0; - for (i = 0; i < opp_table->required_opp_count; i++) + 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; + } + opp_table->required_devs[i] = required_devs[i]; + } return 0; } diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 5a7e294e56b7..f9f0b22bccbb 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -339,8 +339,11 @@ static int _link_required_opps(struct dev_pm_opp *opp, struct opp_table *opp_tab */ if (required_table->is_genpd && opp_table->required_opp_count == 1 && !opp_table->required_devs[0]) { - if (!WARN_ON(opp->level != OPP_LEVEL_UNSET)) - opp->level = opp->required_opps[0]->level; + /* 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; -- 2.31.1.272.g89b43f80a514