From nobody Thu Nov 28 10:54:09 2024 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57D631D0408 for ; Wed, 2 Oct 2024 12:22:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871771; cv=none; b=G4/ZjmX7WyPzZr02x32cqryLARYyeRSsffvkg+yjApO+ZxMk53VwXP3uDbxjECbT00dI2urkBF8Ff+A+fGRrSsdn3F86mEA1eQMMfMIXjXTixQGMI+GaHA4+XUfx5h4WcdG5PlBM3cPudnDmSiHZC5CuwFtHmRIUYGEhd2iRxAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871771; c=relaxed/simple; bh=TZkiMrnNMk4mmip8oR67yJAGJpfZyAECM/+jjd0fBWU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RRyxEZhwoE4Qxg8n0Y891aVtJ9MQuh5Jg8K2fhCv9Dm+pujf8fc8XTb2fy8A91L9Clg9AsSQquIBSU02I7ZvX0CHB5FyaK+lE3Z3soawo0gs++Py71+PIOm7BYopTDamNfmQ2FDK8186mWJk0I8EK+jlQOmfldB/o55yRiot1jM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Qo1oX2nh; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Qo1oX2nh" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5398fb1a871so4055920e87.3 for ; Wed, 02 Oct 2024 05:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727871767; x=1728476567; 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=xcqYYVpLlj10i0qHI4tc+kYUPF8iaIvwsza/wsplKHw=; b=Qo1oX2nhMe23S6V31IGIj1KZsuWR70RqPEiIvVXqcmUkpcXx6YAuRLNXC0AcdyxdQn 9hgMf+FrXQlh1DPgwV7rWZ3X1RBvsrVodtQ6usPJRhrVJybFfmk9f8ViDDN1xTeAVV1l Zt9u/QmrHamxr4B9I8UmWO7RJVJoNNRcxtoelSigCX0B6N+Gy94T3HOsYa12qucrIjny fiarliC33WQOZWwk5e3yYXRWLvXcMGNaCXRKEtrIFV90of030MgQ13AgDS3g5B7FqSN+ sx2iNftydZcAEeNKxAp52+qCpTMpyNfrMP7vDT2Yxc/Ts23L1qG5H6TqrQYReeKvaS/C Vv9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727871767; x=1728476567; 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=xcqYYVpLlj10i0qHI4tc+kYUPF8iaIvwsza/wsplKHw=; b=pj+OU5pIQvgJojFkKjPe4pnXAx/jnng1/GiQ4K1bvsJF6g0QMaUDfzdE9ktW3FhXWe 3Dv5rBrf0qMR918pX6M6tFJK9utYNPtAuM8IIcGF6J+Sd3t0U9FlREr6fQ7sITLWWh9Y fEVjnPxiN147BEnwPI4pyIcDtpnt6QklaUhyQh6g5YMDAbadOsLV2fxovcBVhjxc+iiF mK7He9C9Wf4ylCExD/2Bza73o7AIPhyIzl/oY1NRR+KucngLC3ZYqz9I1GcDlBJdf39f NqLZaHWda2vCJgqvc+qJZyAPwsFo2VEFTRwejFYiR6l6w0odcET2hfQ3nTosUs5XGA/9 81Bg== X-Forwarded-Encrypted: i=1; AJvYcCUU/OBzP+EwYdKCAmomrnJ+nyBAotXxt/CEJAJEUFzyikSO6QC1wa2e6yfRQkNv5uZYk9HvlSCSh66qVQI=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1g05UI10XGq6FGxG0auVynhPhH1YQbYWKeJaHWGQEZlRbvnln UEmZitB7+ZuZRrGUfstG1QLV3WAs4NZBtY+EzdgARxu3Lq+89vT91vNuy3i6d5c= X-Google-Smtp-Source: AGHT+IHBll4ncIEBYGqKdaxs69HtCnmoAhR+84ep9dXSOAPhQjdXaNEiv/qua/AGSiyj5o8AWkwt0A== X-Received: by 2002:a05:6512:12d3:b0:530:aea3:4659 with SMTP id 2adb3069b0e04-539a0658b50mr1838434e87.9.1727871767496; Wed, 02 Oct 2024 05:22:47 -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-538a043204fsm1912659e87.165.2024.10.02.05.22.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 05:22:46 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: "Rafael J . Wysocki" , Dikshita Agarwal , Vedang Nagar , 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 v4 04/11] PM: domains: Support required OPPs in dev_pm_domain_attach_list() Date: Wed, 2 Oct 2024 14:22:25 +0200 Message-Id: <20241002122232.194245-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241002122232.194245-1-ulf.hansson@linaro.org> References: <20241002122232.194245-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In the multiple PM domain case we need platform code to specify the index of the corresponding required OPP in DT for a device, which is what *_opp_attach_genpd() is there to help us with. However, attaching a device to its PM domains is in general better done with dev_pm_domain_attach_list(). To avoid having two different ways to manage this and to prepare for the removal of *_opp_attach_genpd(), let's extend dev_pm_domain_attach|detach_list() to manage the required OPPs too. Signed-off-by: Ulf Hansson --- Changes in v4: - New patch. --- drivers/base/power/common.c | 21 ++++++++++++++++++++- include/linux/pm_domain.h | 8 ++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c index cca2fd0a1aed..781968a128ff 100644 --- a/drivers/base/power/common.c +++ b/drivers/base/power/common.c @@ -11,6 +11,7 @@ #include #include #include +#include =20 #include "power.h" =20 @@ -222,13 +223,15 @@ int dev_pm_domain_attach_list(struct device *dev, if (!pds) return -ENOMEM; =20 - size =3D sizeof(*pds->pd_devs) + sizeof(*pds->pd_links); + size =3D sizeof(*pds->pd_devs) + sizeof(*pds->pd_links) + + sizeof(*pds->opp_tokens); pds->pd_devs =3D kcalloc(num_pds, size, GFP_KERNEL); if (!pds->pd_devs) { ret =3D -ENOMEM; goto free_pds; } pds->pd_links =3D (void *)(pds->pd_devs + num_pds); + pds->opp_tokens =3D (void *)(pds->pd_links + num_pds); =20 if (link_flags && pd_flags & PD_FLAG_DEV_LINK_ON) link_flags |=3D DL_FLAG_RPM_ACTIVE; @@ -244,6 +247,19 @@ int dev_pm_domain_attach_list(struct device *dev, goto err_attach; } =20 + if (pd_flags & PD_FLAG_REQUIRED_OPP) { + struct dev_pm_opp_config config =3D { + .required_dev =3D pd_dev, + .required_dev_index =3D i, + }; + + ret =3D dev_pm_opp_set_config(dev, &config); + if (ret < 0) + goto err_link; + + pds->opp_tokens[i] =3D ret; + } + if (link_flags) { struct device_link *link; =20 @@ -264,9 +280,11 @@ int dev_pm_domain_attach_list(struct device *dev, return num_pds; =20 err_link: + dev_pm_opp_clear_config(pds->opp_tokens[i]); dev_pm_domain_detach(pd_dev, true); err_attach: while (--i >=3D 0) { + dev_pm_opp_clear_config(pds->opp_tokens[i]); if (pds->pd_links[i]) device_link_del(pds->pd_links[i]); dev_pm_domain_detach(pds->pd_devs[i], true); @@ -361,6 +379,7 @@ void dev_pm_domain_detach_list(struct dev_pm_domain_lis= t *list) return; =20 for (i =3D 0; i < list->num_pds; i++) { + dev_pm_opp_clear_config(list->opp_tokens[i]); if (list->pd_links[i]) device_link_del(list->pd_links[i]); dev_pm_domain_detach(list->pd_devs[i], true); diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index b637ec14025f..92f9d56f623d 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -30,9 +30,16 @@ * supplier and its PM domain when creating the * device-links. * + * PD_FLAG_REQUIRED_OPP: Assign required_devs for the required OPPs. The + * index of the required OPP must correspond to the + * index in the array of the pd_names. If pd_names + * isn't specified, the index just follows the + * index for the attached PM domain. + * */ #define PD_FLAG_NO_DEV_LINK BIT(0) #define PD_FLAG_DEV_LINK_ON BIT(1) +#define PD_FLAG_REQUIRED_OPP BIT(2) =20 struct dev_pm_domain_attach_data { const char * const *pd_names; @@ -43,6 +50,7 @@ struct dev_pm_domain_attach_data { struct dev_pm_domain_list { struct device **pd_devs; struct device_link **pd_links; + u32 *opp_tokens; u32 num_pds; }; =20 --=20 2.34.1