From nobody Thu Nov 28 08:40:05 2024 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (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 0D3F61CF7C7 for ; Wed, 2 Oct 2024 12:22:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871765; cv=none; b=YoYB6PXuYD8PDAxzSX9E2zpXItYsDBdaJhKiHzJ4gDueHNbiNTYUuRUCPhZYvExhG0DYFr8KxfWs8gdb/R4Prxo26GSZlcntamhc7wihV9soqzoXlcDGFbbmWwg9m1Gv9ZTVkEr1kf7ZYrzj/y+DqigTgCKyeXHe0/4nCiPHcjk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871765; c=relaxed/simple; bh=bHtjzPG/Hb+7ZqaAKxtS3yoYjps3dQcwfj0ujdDPyg4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DCYIu3uUJ4RW4zHSzSEQ1UzdMaqwZ0YnmTaqPVR0ln6n7bjV8bniysrXRnmafJusfEHaR5gLfGjqcFOeezleDfMgj04B6MxITsLvJrohtYD5IkEdY1/j4QbwDs1XCtHoFmE3yUebgjNcZ4C2eWhglSjRw6Ywxk+UtEsCeW9EIhA= 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=OXshoZqi; arc=none smtp.client-ip=209.85.167.45 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="OXshoZqi" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-5398a26b64fso5044940e87.3 for ; Wed, 02 Oct 2024 05:22:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727871762; x=1728476562; 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=eSX9EU17ASlDm3AgTKh4ubal0EGKVpY/9w9SUmxv4Ak=; b=OXshoZqiEfStsTOGcDG8w+vDkCQh0boU7rqDrgyxZIDcJ8S+pnfgSxSFWl5zDK38Ch 7Z3QkM3o2CAeZeXaX5OcjbeHlIhTccy9uM4fy2pDOhfeBeGqVw9i3UFjiJlYIkVUxJoc mgXbQbIb0csjJL1nFWkzYvP1aDVxCwsTJcWcrvTI7lDJJIOv2ZCZW07GvvBPoY/L49/O pQVIMpw65Sa6lUMOBEQYqDhwK8VzPyq/WgV9uhS1CwIvGRLVAiZ7E+uyvpUMdsF8i+Ao FcjrUu5jDX1BJAbkDI6EEnqpTKs9gOi2HuFmLaC2Q0WFOE+3Z1mC5sdqkSByZbhlUlRV Metw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727871762; x=1728476562; 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=eSX9EU17ASlDm3AgTKh4ubal0EGKVpY/9w9SUmxv4Ak=; b=FPwaG8TyKfXui0c/utZ78lvYpyHPCpPQ4SMqeuJJ67obEvE9Rqog2iuKwCjya534Sl 2p1Cb5oTFxJo9QN8igCYNcMkDcwwCVl7rrE3yficoxbQSZVOYZdgCeFTPJXN0RHpLelv TTBwRlDvEXAkx11OFq7X4UjjnLNk+P216eTDXdEf8XBC7ZMIL+P77ja+X0LvdH78PQk3 W2S2ZMkBxHiIXxd8wuK1B5kS8OnL1tb2rPSYCVZ8sKSb8LXTCIuCVXACpduuYuAlByDB 8uqq/s9BykxKDaMSTCyiFDVEgBq2euGzvspPeLTa5txljxpR+99yJxDVJ5NlLFbnM/98 6jyA== X-Forwarded-Encrypted: i=1; AJvYcCVEa/yzYKr2osovOtIU2sPqfPt7Tp7ec4938xt7vQr60MLjGrKNA85Kwi6xZGF/o2IAmhBu6GlenmPCCn4=@vger.kernel.org X-Gm-Message-State: AOJu0YyvkO3xtV7RS7F93P6g2wJxuj2nekZd3tf4M+ko0CMvakKj7lO2 zg4pnh7enb1B7ELGl0/WAqGUlNcskvJqP0aaxKKuL5W/8oOFBI86yHPFqcpIPaU= X-Google-Smtp-Source: AGHT+IHEvwRxBb9GrNyhgaRg0+vv+PetyLiU75/JMXFKI6h0PdYDgnClXnPqY2gTN5ud9jelhP1j5g== X-Received: by 2002:a05:6512:280a:b0:530:d088:233f with SMTP id 2adb3069b0e04-539a079f870mr1678944e87.40.1727871762024; Wed, 02 Oct 2024 05:22:42 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 05:22:41 -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 01/11] Revert "drm/tegra: gr3d: Convert into dev_pm_domain_attach|detach_list()" Date: Wed, 2 Oct 2024 14:22:22 +0200 Message-Id: <20241002122232.194245-2-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" This reverts commit f790b5c09665cab0d51dfcc84832d79d2b1e6c0e. The reverted commit was not ready to be applied due to dependency on other OPP/pmdomain changes that didn't make it for the last release cycle. Let's revert it to fix the behaviour. Signed-off-by: Ulf Hansson --- Changes in v4: - New patch. - Thierry, I intend to queue this via my pmdomain tree as a fix for v6.12. Please let me know, if you have any issues with that. --- drivers/gpu/drm/tegra/gr3d.c | 46 ++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/tegra/gr3d.c b/drivers/gpu/drm/tegra/gr3d.c index 4de1ea0fc7c0..00c8564520e7 100644 --- a/drivers/gpu/drm/tegra/gr3d.c +++ b/drivers/gpu/drm/tegra/gr3d.c @@ -46,7 +46,6 @@ struct gr3d { unsigned int nclocks; struct reset_control_bulk_data resets[RST_GR3D_MAX]; unsigned int nresets; - struct dev_pm_domain_list *pd_list; =20 DECLARE_BITMAP(addr_regs, GR3D_NUM_REGS); }; @@ -370,12 +369,18 @@ static int gr3d_power_up_legacy_domain(struct device = *dev, const char *name, return 0; } =20 +static void gr3d_del_link(void *link) +{ + device_link_del(link); +} + static int gr3d_init_power(struct device *dev, struct gr3d *gr3d) { - struct dev_pm_domain_attach_data pd_data =3D { - .pd_names =3D (const char *[]) { "3d0", "3d1" }, - .num_pd_names =3D 2, - }; + static const char * const opp_genpd_names[] =3D { "3d0", "3d1", NULL }; + const u32 link_flags =3D DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME; + struct device **opp_virt_devs, *pd_dev; + struct device_link *link; + unsigned int i; int err; =20 err =3D of_count_phandle_with_args(dev->of_node, "power-domains", @@ -409,10 +414,29 @@ static int gr3d_init_power(struct device *dev, struct= gr3d *gr3d) if (dev->pm_domain) return 0; =20 - err =3D dev_pm_domain_attach_list(dev, &pd_data, &gr3d->pd_list); - if (err < 0) + err =3D devm_pm_opp_attach_genpd(dev, opp_genpd_names, &opp_virt_devs); + if (err) return err; =20 + for (i =3D 0; opp_genpd_names[i]; i++) { + pd_dev =3D opp_virt_devs[i]; + if (!pd_dev) { + dev_err(dev, "failed to get %s power domain\n", + opp_genpd_names[i]); + return -EINVAL; + } + + link =3D 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 =3D devm_add_action_or_reset(dev, gr3d_del_link, link); + if (err) + return err; + } + return 0; } =20 @@ -503,13 +527,13 @@ static int gr3d_probe(struct platform_device *pdev) =20 err =3D devm_tegra_core_dev_init_opp_table_common(&pdev->dev); if (err) - goto err; + return err; =20 err =3D host1x_client_register(&gr3d->client.base); if (err < 0) { dev_err(&pdev->dev, "failed to register host1x client: %d\n", err); - goto err; + return err; } =20 /* initialize address register map */ @@ -517,9 +541,6 @@ static int gr3d_probe(struct platform_device *pdev) set_bit(gr3d_addr_regs[i], gr3d->addr_regs); =20 return 0; -err: - dev_pm_domain_detach_list(gr3d->pd_list); - return err; } =20 static void gr3d_remove(struct platform_device *pdev) @@ -528,7 +549,6 @@ static void gr3d_remove(struct platform_device *pdev) =20 pm_runtime_disable(&pdev->dev); host1x_client_unregister(&gr3d->client.base); - dev_pm_domain_detach_list(gr3d->pd_list); } =20 static int __maybe_unused gr3d_runtime_suspend(struct device *dev) --=20 2.34.1 From nobody Thu Nov 28 08:40:05 2024 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (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 7FDAC1CFECE for ; Wed, 2 Oct 2024 12:22:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871767; cv=none; b=Nf5BWtS3Il93p5gToyXVAcYZVxjT899Ak1bQAZbPc2QRVeO12n6Uz3QvZK2O/aFr1GOqdZ2/HkFTEsCo4WuE8iK1hBNtAPT5E8v3k31+b0lZLtsW3W/GB+fYQrIQfFI4kxfdTcEEVwtquoZrFvVtmzKpTd6AOh3ZitHGmtam/mw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871767; c=relaxed/simple; bh=bzcM5H+oeqTzoW0VCpVpOTPFzApwGE8O5mfZWirVFUw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WKE7kuR0tCMHI/QjYCwzA3h6DGovfNuMPm0WDT9gx8e6puujjk4+gMKnXyUgZ1B1+jotiTopEf3EBkO3TGZOEWHG09ReHkhPMI9H6ygoZ8SuNCrcDTfzivrQeKZ3wyI+hEBM+eoC18Io0ce2kNX5m0QFAPDmI2iT/nVM+6dmino= 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=LWhTO41b; arc=none smtp.client-ip=209.85.167.43 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="LWhTO41b" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5398c1bd0b8so805821e87.0 for ; Wed, 02 Oct 2024 05:22:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727871763; x=1728476563; 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=GnPQMJcE35HfZ9AP9Q+AP3/u7Io2rZuoy0lFJRDyvTQ=; b=LWhTO41b4U1ICWSdRiPrFu8M+xl84/DKXDyIA6TMxznAomMnIJ6XtZNdPdnuOzizYE evryVlU7TtwdEu9b0YqX8SB1kDEG2bfzg24uq81mttsjEGR/n8Ha0qkkYUFUihp8xg7E TNUNpnRmjU4OpP+jdSljrtNx8zbGrjIWDKbtQ1rXPB06u13CIT4yWIevM/SxksuaLgtl UIhfVv+FocpA9FWOI8jat5sXsJDUVkVBVg63OIv62ts9CKCAlFcpLJ3jwkcTZM39dsuv UdMIJG80eqWkKNFmyg3nwXrhrpFyBDal3Uf3X9KgcGzoqPigr1Wr2E2DhqilJ13yvXvH fxIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727871763; x=1728476563; 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=GnPQMJcE35HfZ9AP9Q+AP3/u7Io2rZuoy0lFJRDyvTQ=; b=i6PrDFw038yYMwPqUel0MkYy6D+HT1YjHASbnu9wYReABU/wUP+K1tvsa5So5lZX74 LV2/ir5JfGDTQ2zJa9kbgGXCj8VWwkwde93BUFg1XVSehLNIHgRI3OKzx2UIdCJTCTYs LLI30CC6SAfRgT8G+CkMvPejPYfEEwYKWcKUNKukdLzquTWnyPURdANxFd4uYl0zWlpz 5yxV/msW1pmj+o5nv7cULhQpuzAhYSmFPdtegkNlQJIcgLNuVz67O6tpjFUkH1Xqd2Yn 0b2bOvtX/dUt0XCnzNco+Fmxonl47WGecc5UzTO/oHJmi40NlzSOGZWlbVUrETkOquI6 o4mQ== X-Forwarded-Encrypted: i=1; AJvYcCVWuK4+Sj+TuUncug4UMqd3IWnyMPhkd7XK5iiqaLmJV33IMl7IqiurARaLEfPAUmg0i0PK3PFbW4OOOns=@vger.kernel.org X-Gm-Message-State: AOJu0YzRkDbziNOCmnT7+vDvGACc0C5EAmDRgkwoyv4IwLrdC/NSrA3+ bV5dobk1O9y3F2qhmMNirTvY+RliV+fxGYBypG01pthCmY/kWmLl7kmSGQMutDM= X-Google-Smtp-Source: AGHT+IH3lbHH/Ci/Lm2nPio+9vcLRk9yL/BoeI12+KlsgJmqos4Z7kBLLfAx4B214LknbA9lF9GWVw== X-Received: by 2002:a05:6512:239c:b0:538:9d49:f740 with SMTP id 2adb3069b0e04-539a014dd0dmr1050179e87.15.1727871763458; Wed, 02 Oct 2024 05:22:43 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 05:22:42 -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, stable@vger.kernel.org Subject: [PATCH v4 02/11] PM: domains: Fix alloc/free in dev_pm_domain_attach|detach_list() Date: Wed, 2 Oct 2024 14:22:23 +0200 Message-Id: <20241002122232.194245-3-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" The dev_pm_domain_attach|detach_list() functions are not resource managed, hence they should not use devm_* helpers to manage allocation/freeing of data. Let's fix this by converting to the traditional alloc/free functions. Fixes: 161e16a5e50a ("PM: domains: Add helper functions to attach/detach mu= ltiple PM domains") Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson --- Changes in v4: - New patch. =09 --- drivers/base/power/common.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c index 8c34ae1cd8d5..cca2fd0a1aed 100644 --- a/drivers/base/power/common.c +++ b/drivers/base/power/common.c @@ -195,6 +195,7 @@ int dev_pm_domain_attach_list(struct device *dev, struct device *pd_dev =3D NULL; int ret, i, num_pds =3D 0; bool by_id =3D true; + size_t size; u32 pd_flags =3D data ? data->pd_flags : 0; u32 link_flags =3D pd_flags & PD_FLAG_NO_DEV_LINK ? 0 : DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME; @@ -217,19 +218,17 @@ int dev_pm_domain_attach_list(struct device *dev, if (num_pds <=3D 0) return 0; =20 - pds =3D devm_kzalloc(dev, sizeof(*pds), GFP_KERNEL); + pds =3D kzalloc(sizeof(*pds), GFP_KERNEL); if (!pds) return -ENOMEM; =20 - pds->pd_devs =3D devm_kcalloc(dev, num_pds, sizeof(*pds->pd_devs), - GFP_KERNEL); - if (!pds->pd_devs) - return -ENOMEM; - - pds->pd_links =3D devm_kcalloc(dev, num_pds, sizeof(*pds->pd_links), - GFP_KERNEL); - if (!pds->pd_links) - return -ENOMEM; + size =3D sizeof(*pds->pd_devs) + sizeof(*pds->pd_links); + 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); =20 if (link_flags && pd_flags & PD_FLAG_DEV_LINK_ON) link_flags |=3D DL_FLAG_RPM_ACTIVE; @@ -272,6 +271,9 @@ int dev_pm_domain_attach_list(struct device *dev, device_link_del(pds->pd_links[i]); dev_pm_domain_detach(pds->pd_devs[i], true); } + kfree(pds->pd_devs); +free_pds: + kfree(pds); return ret; } EXPORT_SYMBOL_GPL(dev_pm_domain_attach_list); @@ -363,6 +365,9 @@ void dev_pm_domain_detach_list(struct dev_pm_domain_lis= t *list) device_link_del(list->pd_links[i]); dev_pm_domain_detach(list->pd_devs[i], true); } + + kfree(list->pd_devs); + kfree(list); } EXPORT_SYMBOL_GPL(dev_pm_domain_detach_list); =20 --=20 2.34.1 From nobody Thu Nov 28 08:40:05 2024 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 63BAE1D0156 for ; Wed, 2 Oct 2024 12:22:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871769; cv=none; b=upAj/OYLpvec8vLnifPugw9LYR6mV4szdZEfPpIayI9ULCWf8FxWcrK/o8qoyGAf32wqMccp7Pb9SABPQEYC0NimFjZi53kiUzvnBA7ROyFiojA3sP1ugZrke7bPp2sHbV/boNYJpQlaQuCPpwFxNMZFaDr6GtKnMvn1mT+AOwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871769; c=relaxed/simple; bh=X4NFsCvjfecv5yqdm2M15YFm3XbR+UbiVuUmlYW/wNE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iBPQDvXwDkAlteatQPZRbFLCk5R8eCCg/QPGJUGA91gTdrbUbAfH+PgYYoyEiR/bLB4RuC2lFbd+K0A4hmEOerVOQK+nmGkhIw3S9HuCqx4ZsK8s/kjuqmm+ECTwzdPvRpInnk8lLrqrbKhliThXl3i7fp5mJWMj4JT/i0YIjSg= 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=vCONkas1; arc=none smtp.client-ip=209.85.167.44 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="vCONkas1" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-5399675e14cso3961776e87.3 for ; Wed, 02 Oct 2024 05:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727871765; x=1728476565; 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=floLT8azXrau0uBiWc2H3i8kWyeGNrZXbzjRyDzZNWA=; b=vCONkas15M40x1l4xYWk4yDU5sEmXY7dsNv/vouEfBvEa8QvQMihSZWR2rj5g50M0E IiTqWTqETHykkym1/LMONQF86alAVdGjjeG6M6opx3nMAvdiZpoU/jHSSFYzKBzLpmop 9Hcfe5MMs5NnBv5gadg/w/xAS75oj6z2NXa55zEt7AyEusy9awbkzG9vKR+2JinX7MYr EooelARbb+OhsFc27kiZ8hRYAv92uSbsV1IPu1CTvNDP5SkxcWFyyNsMY2qqTEWKsxmq 7wo8RKNQQVqjlYuN0dSVy7+p4j8wFRDZMBJicxgB1VvHKWtj4q8GOU7lkhivJhoHYDAs OC/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727871765; x=1728476565; 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=floLT8azXrau0uBiWc2H3i8kWyeGNrZXbzjRyDzZNWA=; b=g3iccCZsHKwe/Tr/8O2AWccfXZlgmPFKqXhjzS9APU9RSUDdQRkE09z+CP09zgFSNf 7wrRnNSZAygJo2ZctUEbwro5T1QSmTBRsT5oA6lrYdF8yMgkOjVewM6af+XGL7phOapE gzm/YyX7OV0sDDbLQ7NKBxfcJ9K+/eFifwQdmmhukiwrevLyCKKw0MRDTJ7VF8mPGbrA btVrBwlq9rGPmZ2KLSNSM4DmWCrPG5mwMmZ/KZIw5zcyLQOQqMXMrvQpaXTkkiqiaYXO 1TrMEptbQKb+0YEi1JMhSVFRBMYnb/vnllbvNYrPJgWrzeUn6XHeyQ2wkE7XcfTAZiO0 /TBA== X-Forwarded-Encrypted: i=1; AJvYcCX7wBDPZdTdIZyWeY5smNnmjj7Z7oNYAv6eCF7S3Z9MxVUd8r1VAvpLPzuunO5wkzOXI7aXCA8XicQ2S/c=@vger.kernel.org X-Gm-Message-State: AOJu0YwYkqRh5RlUrE9jwYPPrKiDkfuZFv24HF74XUX4oQZK94woW88f W14ygIkvxW5gxZw3b9/Z7yzmkE8l3wKUsbHCVwNDmV0DeeEfuPUTV+GZ7nZ6QXc= X-Google-Smtp-Source: AGHT+IGipWOmvHlQrLglkd+yAung3UQEpC+X/wwP2Q+EER4yzHDfTodUudPaHdOa/Q/fomec/vgvsQ== X-Received: by 2002:a05:6512:2206:b0:530:aa82:a50a with SMTP id 2adb3069b0e04-539a0793c90mr1578500e87.45.1727871765278; Wed, 02 Oct 2024 05:22:45 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 05:22:44 -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 03/11] OPP: Rework _set_required_devs() to manage a single device per call Date: Wed, 2 Oct 2024 14:22:24 +0200 Message-Id: <20241002122232.194245-4-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" 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 PM domain 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. Subsequent changes starts making use of this. Signed-off-by: Ulf Hansson Acked-by: Viresh Kumar --- Changes in v4: - Lots of update. A re-review is needed. --- drivers/opp/core.c | 81 ++++++++++++++++++++++++++++-------------- drivers/opp/opp.h | 4 ++- include/linux/pm_opp.h | 10 +++--- 3 files changed, 63 insertions(+), 32 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 3aa18737470f..42b7c8f2e71e 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2473,47 +2473,72 @@ static int _opp_attach_genpd(struct opp_table *opp_= table, struct device *dev, =20 } =20 -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, + unsigned int index) { - int i; + struct opp_table *required_table, *pd_table; + struct device *gdev; =20 - if (!opp_table->required_devs) { + /* 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; + } + + if (index >=3D opp_table->required_opp_count) { dev_err(dev, "Required OPPs not available, can't set required devs\n"); return -EINVAL; } =20 - /* Another device that shares the OPP table has set the required devs ? */ - if (opp_table->required_devs[0]) - return 0; + required_table =3D opp_table->required_opp_tables[index]; + if (IS_ERR(required_table)) { + dev_err(dev, "Missing OPP table, unable to set the required devs\n"); + return -ENODEV; + } =20 - for (i =3D 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; + /* + * 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 =3D dev_to_genpd_dev(required_dev); + if (IS_ERR(gdev)) + return PTR_ERR(gdev); + + pd_table =3D _find_opp_table(gdev); + if (!IS_ERR(pd_table)) { + if (pd_table !=3D required_table) { + dev_pm_opp_put_opp_table(required_table); + opp_table->required_opp_tables[index] =3D pd_table; + } else { + dev_pm_opp_put_opp_table(pd_table); } - - opp_table->required_devs[i] =3D required_devs[i]; } =20 + opp_table->required_devs[index] =3D required_dev; return 0; } =20 -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 =3D 0; i < opp_table->required_opp_count; i++) - opp_table->required_devs[i] =3D NULL; + opp_table->required_devs[index] =3D NULL; } =20 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); =20 @@ -2641,13 +2666,15 @@ int dev_pm_opp_set_config(struct device *dev, struc= t dev_pm_opp_config *config) goto err; =20 data->flags |=3D OPP_CONFIG_GENPD; - } else if (config->required_devs) { - ret =3D _opp_set_required_devs(opp_table, dev, - config->required_devs); + } else if (config->required_dev) { + ret =3D _opp_set_required_dev(opp_table, dev, + config->required_dev, + config->required_dev_index); if (ret) goto err; =20 - data->flags |=3D OPP_CONFIG_REQUIRED_DEVS; + data->index =3D config->required_dev_index; + data->flags |=3D OPP_CONFIG_REQUIRED_DEV; } =20 ret =3D 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) =20 /** * 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; }; =20 /** diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 6424692c30b7..bc74bc69107a 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 gen= pd to - * attach. Mutually exclusive with required_devs. + * attach. Mutually exclusive with required_dev. * @virt_devs: Pointer to return the array of genpd virtual devices. Mutua= lly - * exclusive with required_devs. - * @required_devs: Required OPP devices. Mutually exclusive with genpd_nam= es/virt_devs. + * exclusive with required_dev. + * @required_dev: Required OPP device. Mutually exclusive with genpd_names= /virt_devs. + * @required_dev_index: The index of the required OPP for the @required_de= v. * * This structure contains platform specific OPP configurations for the de= vice. */ @@ -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; + unsigned int required_dev_index; }; =20 #define OPP_LEVEL_UNSET U32_MAX --=20 2.34.1 From nobody Thu Nov 28 08:40:05 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 From nobody Thu Nov 28 08:40:05 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 4D4A11D043E for ; Wed, 2 Oct 2024 12:22:53 +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=1727871775; cv=none; b=kL7NrCupJFjyG4TYDoV4RFVNQIT75Ie1h0J3Gd/Q0LzjkOQO/p6HgHQ3H1PI6UoYOC9/5j/SvRfo+m8b/WfvEuD06hIczrOzs+yb6mfmq4DDr68tHgaIBf24m8FQilGx/18UrceCTkd6HHXAhGO9AQlobBs7P3Zdwr6NsSDgGqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871775; c=relaxed/simple; bh=4oMD95LmzrY2BBiXM7ugPb7ru7xnwAUSFNySR58E1js=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KhzCLbER5TInbPoOMxbD7Dg3QLiMb3dlzC5DcBSJd2EN7dFZtlNs0nJn9TMdNjnCzLti5Sc6x0Zs8jrDuE6calnrSXWvYer/Ar8iWSRMBb1lnktxKPKQ4dzorRVBPrBjPrLmQjzmO+2vpmOwbuBz6a4+2voGykZrCWChPvJ8b3U= 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=iCop0QB/; 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="iCop0QB/" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-53993564cb1so4090628e87.2 for ; Wed, 02 Oct 2024 05:22:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727871771; x=1728476571; 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=/xhrWVuNulAVPF9JAXfDIgOPkMQL+mGco7UiYnj3y1Y=; b=iCop0QB/dqby4qdLQDmyVe81BE6NHl8/JDGAgB42J9Vs+CXbqua7HUm2yMGUFk6kec BiKLBk0IfQzSsDnSQvZNRUKXYxc4l2TXIymKsoMxUTEfzwPTE48i6iz350ronZLRN8eC bXejTzmLM12+vyW8dIbrO99CwjXYlqU4KI1CERGA299PtJ+a8omH0ZgkmWCoPclcYf6m fFYPifIQcg9EeaU/yAhDbPLuJ11L8nsgcm817YZy1i1dZeW8sbf0BVjG7toNaW8XCemv HveXypt2tCvRDJd6YjPliH4tO2M10kzbEY/DYbM/jvnca89x7S7SNXkchc7ANe6Z3NcX k8Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727871771; x=1728476571; 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=/xhrWVuNulAVPF9JAXfDIgOPkMQL+mGco7UiYnj3y1Y=; b=lNKLznwpPVf6B4gcmHbJOn1cG/Xh/pQxfpZWMlTZ8zalSiHhPkMC9bTP7WJgQiUNv3 gG8Ea2hh/NL7wjhP3Rr4f731AJFoFtNRM6L1JqcJETgxbI0r4e4J7+9WSjhGblqtYoiL BUOZmDlQOxGSUqU2S4CFyVIQYvfAZ/UDhZMbZwKeRwXop1baTWwfniSuIt7FaMYDbmFy pPTLlW7MgTWrhQz6kir9PYeAv5Eh6I4wZY+/voWmKgIqs3/FDvCjntitafaIeyaQjlRs hkFBiiCQs1gqssfnq8Q+ljlS1kt+ldyZGLsaWjYQd9N4q9a1yWprFl8olP+RS+wIBm/7 fVAQ== X-Forwarded-Encrypted: i=1; AJvYcCWlTBjvjOrS06mLp0SEAj5z79z3oWOp7DLklld4H4ZShPvgQO0q86dxz0r/v3acgoYHgCwWtEfLK05JifU=@vger.kernel.org X-Gm-Message-State: AOJu0YyDalgCfqPOzDfiNHr4hQ+NEzMBat9Mzhja3apWWuj3PndN1gme dzCL177Wy5G6ghNIE68lEN0goNExQQ4G/a5eokJ1okmZhOgUYdKbLdZSUY7Zd78= X-Google-Smtp-Source: AGHT+IFlrdWAbde1p7e4lL7d3a2kLfPGGaZt2qMjbzrVa76L6m2xNGY6jbMEy1GlEJDkWr0SrTwnww== X-Received: by 2002:a05:6512:b18:b0:539:91b8:edc0 with SMTP id 2adb3069b0e04-539a07a64e9mr1661121e87.50.1727871771211; Wed, 02 Oct 2024 05:22:51 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 05:22:49 -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, Viresh Kumar Subject: [PATCH v4 05/11] pmdomain: core: Manage the default required OPP from a separate function Date: Wed, 2 Oct 2024 14:22:26 +0200 Message-Id: <20241002122232.194245-6-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" To improve the readability of the code in __genpd_dev_pm_attach(), let's move out the required OPP handling into a separate function. Acked-by: Viresh Kumar Signed-off-by: Ulf Hansson --- Changes in v4: - 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 5ede0f7eda09..259abd338f4c 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); } =20 +static int genpd_set_required_opp(struct device *dev, unsigned int index) +{ + int ret, pstate; + + /* Set the default performance state */ + pstate =3D of_get_required_opp_performance_state(dev->of_node, index); + if (pstate < 0 && pstate !=3D -ENODEV && pstate !=3D -EOPNOTSUPP) { + ret =3D pstate; + goto err; + } else if (pstate > 0) { + ret =3D dev_pm_genpd_set_performance_state(dev, pstate); + if (ret) + goto err; + dev_gpd_data(dev)->default_pstate =3D 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_d= ev, unsigned int index, bool power_on) { struct of_phandle_args pd_args; struct generic_pm_domain *pd; - int pstate; int ret; =20 ret =3D 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 =3D genpd_dev_pm_detach; dev->pm_domain->sync =3D genpd_dev_pm_sync; =20 - /* Set the default performance state */ - pstate =3D of_get_required_opp_performance_state(dev->of_node, index); - if (pstate < 0 && pstate !=3D -ENODEV && pstate !=3D -EOPNOTSUPP) { - ret =3D pstate; + ret =3D genpd_set_required_opp(dev, index); + if (ret) goto err; - } else if (pstate > 0) { - ret =3D dev_pm_genpd_set_performance_state(dev, pstate); - if (ret) - goto err; - dev_gpd_data(dev)->default_pstate =3D pstate; - } =20 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; =20 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; } --=20 2.34.1 From nobody Thu Nov 28 08:40:05 2024 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 766471D04A3 for ; Wed, 2 Oct 2024 12:22:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871776; cv=none; b=HA4Dp9hjYWK5tAxkgQiIQ6572eZnGUU78cvE8VJjJL/bcOIBTcEzKc9cNSPknvJd3CTlVnBgr/hkLEXHwfXqBvjDneaIQReO2ASPDaIQyQov7Ws9Pzh411/sdOMULm7qbDRuMZVmwq1J2j9A+M44pGKusF/1YcOpAlPbLeq0mjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871776; c=relaxed/simple; bh=/vKrvSejn1Gdmisdzt5mbHhhl+vKu31y2VR+4L/5Z6A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LZyVAUJ7YcbPrR6/j9i03mhDHDS0AOgAIBeNdZk8MjTOMPzRyW97iM1LOAyfQaRYNA+z6VZngBG/ZKc2tigHyG/h8REEiWo9Iet/406hProheNi2qXkaz374APpLCL7GKE3JVwgO4hkI/49ee8RpZsmgW4s/6JiGEM9gYJjjIPk= 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=zsD4q0B/; arc=none smtp.client-ip=209.85.167.49 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="zsD4q0B/" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-5389e24a4d1so6681767e87.3 for ; Wed, 02 Oct 2024 05:22:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727871772; x=1728476572; 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=gFH9tv3EyMbkQCesSF+Pisa4vxI80qkPcngq9hSO9D0=; b=zsD4q0B/p1FTzq1+pRwTjlioGtqHgxLxOyhn/QN9ST5ZBI++sS+JxVCJ/194fKF25r 04FeXWBNQzY565cqOzg76sfSe4FKRjQVazq0F9n+42ZWMTPfI3XUmCLdzsGM6+OHziUp A8GzuxDl8S84+gxHapFhoavAi5h85prgDA2Ls19kNu5SAS/1TLnTRMew1f22TbGNoKBS qEpnpxsifETaWA0qLKAodJ1Myzh5n0SokqW/rZcwKxkDvzU3YrB7xSTSHsDl8WcXbZdG N53yYFDJStDkAjE4kdgR7XxhN84Z3M6yMwN1uIZ7jlAotmB/7LcimcNwCi2S8sVuWZy6 YgTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727871772; x=1728476572; 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=gFH9tv3EyMbkQCesSF+Pisa4vxI80qkPcngq9hSO9D0=; b=Z2RX0s06A9HdArhfpGulnj4tuJwR9DbIpCv1Ni5IpuE3Yw+hlrH7OIgQIcWwyQDeUe SoXxlgijbgFjkQyNTypv09I7WnmcCh+4iswKaSk5HYjbl0SINKBnbCyqv397b/rdiGCA ItR/FRW9GZlk11MSQTJg57lxdKgbsCDFVeUcRLuUirotwJnHTuK1LT1PvUzHHfG8N7M+ A/Y/P29uhncdL5m7Wt7Ik4m1Z3/q+ThCZ14QEJqjEgqiTMNbrioE6HjqLkyS5jNIgYtt AxHla3MQKZllpcyRjYaCTmK44UQhddxH/i8FXrfv+zvfCewUsANQ4yJg6AnIcnnw8Tey IlUg== X-Forwarded-Encrypted: i=1; AJvYcCWvMyjNIKNz6Vt3rmdvWGnCcHt3gcwPPsnT35nFb5Avl4cPsETsoi+yt8kdQln8w+0S1CdBAnGv/ff8uOI=@vger.kernel.org X-Gm-Message-State: AOJu0Yy1zG8fmg93M+rHZd6gi6qSP6LXt4gkHGwYRkNxvlxzZW+V555C SupqnpWeZ6Y4C/ndB3JdXIEnU7rIA8gIxuMhUbYJQ7T9rPLVkXdicSB3RmmSTdS65QhoZq8++0r m X-Google-Smtp-Source: AGHT+IHEjNv7ZCxNOSC2V6obj2+dWZVZVLatN/UEyPBuKnoG56fp85/7vBdsw6KDnsPAalW5KMVKog== X-Received: by 2002:a05:6512:124d:b0:539:8f4d:a7dd with SMTP id 2adb3069b0e04-539a0795b71mr1720419e87.42.1727871772538; Wed, 02 Oct 2024 05:22:52 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 05:22:52 -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 06/11] pmdomain: core: Set the required dev for a required OPP during genpd attach Date: Wed, 2 Oct 2024 14:22:27 +0200 Message-Id: <20241002122232.194245-7-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 single PM domain case there is no need for platform code to specify the index of the corresponding required OPP in DT, as the index must be zero. This allows us to assign a required dev for the required OPP from genpd, while attaching a device to its PM domain. In this way, we can remove some of the genpd specific code in the OPP core for the single PM domain case. Although, this cleanup is made from a subsequent change. Signed-off-by: Ulf Hansson --- Changes in v4: - Limit the assignment of the required_dev to the single PM domain case. - Use dev_pm_opp_set_config() rather than the resource managed version. --- drivers/pmdomain/core.c | 42 ++++++++++++++++++++++++++++++++++++--- include/linux/pm_domain.h | 1 + 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index 259abd338f4c..76490f0bf1e2 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -1722,6 +1722,7 @@ static void genpd_free_dev_data(struct device *dev, =20 spin_unlock_irq(&dev->power.lock); =20 + dev_pm_opp_clear_config(gpd_data->opp_token); kfree(gpd_data->td); kfree(gpd_data); dev_pm_put_subsys_data(dev); @@ -2884,6 +2885,29 @@ static void genpd_dev_pm_sync(struct device *dev) genpd_queue_power_off_work(pd); } =20 +static int genpd_set_required_opp_dev(struct device *dev, + struct device *base_dev) +{ + struct dev_pm_opp_config config =3D { + .required_dev =3D dev, + }; + int ret; + + /* 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; + + ret =3D dev_pm_opp_set_config(base_dev, &config); + if (ret < 0) + return ret; + + dev_gpd_data(dev)->opp_token =3D ret; + return 0; +} + static int genpd_set_required_opp(struct device *dev, unsigned int index) { int ret, pstate; @@ -2908,7 +2932,8 @@ static int genpd_set_required_opp(struct device *dev,= unsigned int index) } =20 static int __genpd_dev_pm_attach(struct device *dev, struct device *base_d= ev, - unsigned int index, bool power_on) + unsigned int index, unsigned int num_domains, + bool power_on) { struct of_phandle_args pd_args; struct generic_pm_domain *pd; @@ -2940,6 +2965,17 @@ static int __genpd_dev_pm_attach(struct device *dev,= struct device *base_dev, dev->pm_domain->detach =3D genpd_dev_pm_detach; dev->pm_domain->sync =3D genpd_dev_pm_sync; =20 + /* + * For a single PM domain the index of the required OPP must be zero, so + * let's try to assign a required dev in that case. In the multiple PM + * domains case, we need platform code to specify the index. + */ + if (num_domains =3D=3D 1) { + ret =3D genpd_set_required_opp_dev(dev, base_dev); + if (ret) + goto err; + } + ret =3D genpd_set_required_opp(dev, index); if (ret) goto err; @@ -2994,7 +3030,7 @@ int genpd_dev_pm_attach(struct device *dev) "#power-domain-cells") !=3D 1) return 0; =20 - return __genpd_dev_pm_attach(dev, dev, 0, true); + return __genpd_dev_pm_attach(dev, dev, 0, 1, true); } EXPORT_SYMBOL_GPL(genpd_dev_pm_attach); =20 @@ -3047,7 +3083,7 @@ struct device *genpd_dev_pm_attach_by_id(struct devic= e *dev, } =20 /* Try to attach the device to the PM domain at the specified index. */ - ret =3D __genpd_dev_pm_attach(virt_dev, dev, index, false); + ret =3D __genpd_dev_pm_attach(virt_dev, dev, index, num_domains, false); if (ret < 1) { device_unregister(virt_dev); return ret ? ERR_PTR(ret) : NULL; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 92f9d56f623d..76775ab38898 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -252,6 +252,7 @@ struct generic_pm_domain_data { unsigned int performance_state; unsigned int default_pstate; unsigned int rpm_pstate; + unsigned int opp_token; bool hw_mode; void *data; }; --=20 2.34.1 From nobody Thu Nov 28 08:40:05 2024 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 96E5C1D0791 for ; Wed, 2 Oct 2024 12:22:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871778; cv=none; b=LFR9PbyTZikkbIbtKZOqYmbFWxTSFHhWcZ3Su5agv2fSXvESBigaeXPbXfuFzqZseYucCqV727ZcAjr88GNCYme/KH43RSvj8GK2g6UuA245v4hfrKcvdQFROaH1VOZCXazamGwKmkbHzCpF8Q32CglJ3sh3IG2cnGK7e+zJxyc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871778; c=relaxed/simple; bh=ymLt5GJ4WzLGmHp/1aNDFGoqylRVrycvX/KQELNdW6w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ceR+R/Hn2UHen603tzLfKDw0Re0coDnxKUMP+ZSQVRetrGe0pROMKMQJYylLDolEJVJf3rlCPgZLZGYJ8uMEnCpIiEBDs0Vou0UaIM6Ru8t9K72Si1PPhdMn7zLhHwYJwFCEdUG5OKnv4DooHXYK5UwlnGJDgw1PfSj2OogWTds= 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=gMaT8AC5; arc=none smtp.client-ip=209.85.167.44 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="gMaT8AC5" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-5398d171fa2so4392501e87.0 for ; Wed, 02 Oct 2024 05:22:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727871775; x=1728476575; 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=mo7s8jETlda0+BRvPrZ2XPBCxDBpJQxwBMXkwhH6GW8=; b=gMaT8AC5iqB0I+NLajV3wkoPVkLytwhaRosYJ8dLNL+W9NI+15f2q4IYUkY4oWbyVh p9yHTaRB9wTKhxqKUCno1GSmm+sBulB3gK6vQvs98oxbD9WMuXZMQWPBcA3JAOYYiAfA Mu1HhQsZLeAONuGAHAfkXjiAizQgtEtoUDtN2IxdCXl3g4/tdAVTfK0co80J7a4yiaT6 8iDo5H5faKXYeKTbd7Bd31rSEbbq20Nw27DpjvT394KDc2yiOi6xfvk8qWy6kjXJVupv BjRbzJWMPm/Qu6+FtjE8sifqyQRFDUISQQhTmd7cJqZixb3XE/YAQTWQh6pNk4vpJO0x CLmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727871775; x=1728476575; 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=mo7s8jETlda0+BRvPrZ2XPBCxDBpJQxwBMXkwhH6GW8=; b=GsvKROE4DLKukPoAIJKU2gW81Vu2jCRmJiCEMiheTnhOppKjhfmcGDtDtll8OfDA5G 9VuQZRocDS11E8CpdTCpjZ/tU4JFdjVQ8fOt7KLPyiQ1bvZpCwl+L0UazuAoVMYC49xk ZAfaGl3hUcxbvGLnHD1kF32mklL2LQtUKEQ4dutdF0wGF8NjYaYlNvswvoLaMzzYLyus WaI1tu9BTjgKZofEL4vPrw/WQyLyZK9htemfMoqENqjJVD/y3+IcmExONTi7IGt5YKw1 R6rCSbv62SaVaDrguLmUUuzEfqPaFUMH6inMFxW+yWux6GpYAICs/nEJn0usnp+21fO3 TLTQ== X-Forwarded-Encrypted: i=1; AJvYcCX/iKX00amgpGB2wipVHZ/MsOOgzd+wZY//pxxIziRXiABUR47R/v7WmBZ2bV3KELZ5cr+nFdDs7bOGjNk=@vger.kernel.org X-Gm-Message-State: AOJu0YxGWmmb2fTf28od/Hd15682zY1nRiYRriv73bj150vf4ULibZhb ua2qiUkHaBi52LvOQkU94rET55/pF4vNRV+5RburiEPClSdKEuYos0zDRxuDnpk= X-Google-Smtp-Source: AGHT+IFh4SkJpxD6spSOu73m9HsEd5DxCdeculcsrmUe25jRNKIFNnrt0WhU+LWoCEgB2xvQ62eotg== X-Received: by 2002:a05:6512:3b9e:b0:52c:e086:7953 with SMTP id 2adb3069b0e04-539a065e945mr1702937e87.4.1727871774821; Wed, 02 Oct 2024 05:22:54 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 05:22:53 -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, Viresh Kumar Subject: [PATCH v4 07/11] OPP: Drop redundant code in _link_required_opps() Date: Wed, 2 Oct 2024 14:22:28 +0200 Message-Id: <20241002122232.194245-8-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" Due to that the required-devs for the required OPPs are now always being assigned, we no longer need the special treatment in _link_required_opps() for the single PM domain case. Let's therefore drop it. Acked-by: Viresh Kumar Signed-off-by: Ulf Hansson --- Changes in v4: - 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); } =20 -static int _link_required_opps(struct dev_pm_opp *opp, struct opp_table *o= pp_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; } =20 - /* - * 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 =3D=3D 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 !=3D OPP_LEVEL_UNSET)) - opp->level =3D opp->required_opps[0]->level; - } - } - return 0; } =20 @@ -370,7 +337,7 @@ static int _of_opp_alloc_required_opps(struct opp_table= *opp_table, if (IS_ERR_OR_NULL(required_table)) continue; =20 - ret =3D _link_required_opps(opp, opp_table, required_table, i); + ret =3D _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 *op= p_table, int ret; =20 list_for_each_entry(opp, &opp_table->opp_list, node) { - ret =3D _link_required_opps(opp, opp_table, new_table, index); + ret =3D _link_required_opps(opp, new_table, index); if (ret) return ret; } --=20 2.34.1 From nobody Thu Nov 28 08:40:05 2024 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (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 25CCD1D07BD for ; Wed, 2 Oct 2024 12:22:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871780; cv=none; b=KHf71Ze8zbrYXMXV201Zr+4EzcW7p4dAwHsC9Wq0EzaK6FnT8oSl6umtQKBeDanjXzQeSykaO05KulloQbuM3jUw24be+0G/DjjDoD2g1AaHul7BODFCqvhB5dZJ137IqEzIVnknfYYqOGgZxpv9lsQoreYbaY6CWidKaeQfhts= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871780; c=relaxed/simple; bh=KxhfgynaXl+ts0gFVfYweXnYNKp5iegvppU1weAPpVk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=S2y31ezRQ89R5dJZUhwW4ZVwj4JH+S3XjnZv8tcxdKU4Cru87/IZ6b+yLCC8RqEjKwDiUMpjGE0/RmceceFYZn7j/Du5ST4ACS+EkfmfcS8yiX5wKiSZaedIuFS+Fwr49TLX3I7xxw4tMz5isFfaBTxpndgixxvbvfJ43bUTG7w= 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=uz5UTbpL; arc=none smtp.client-ip=209.85.167.46 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="uz5UTbpL" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-5398e53ca28so4351509e87.3 for ; Wed, 02 Oct 2024 05:22:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727871777; x=1728476577; 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=EWiwvj5KSak5iw1HXEVPujm6Q2wWyAwA6z/lZYjaN0g=; b=uz5UTbpL6IF1Qs6U3c7ARIytAVMOGbEwfX+WXh1Ba64C+KZqZy6e592h9Vq5Ipcs3a S5V5zSzMg+ZOeChhJqiseohFIRvyKHObDlZl7HXVQNYgIB8Dve2IJYHbJ/XGGRCTPwzX TFDcHThn1TIOnVbEH3ff2C7NkeW3N/Sbva0YqKdk7x5CXFM2VQdzCHSIWHVpGuaYso82 BEeJ/InCcgTaXy9pI7Xee/jSApaBkh4++MOuA0xUCw70RLUYcv2pPjNjc+1rcQbG84PV AsZ7W2UNjAKvOx4WoPE57HojnkJRCEI/N4bdyloVoMF0/zdkkkHn8W2Byda+hmm2Jmeq qqRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727871777; x=1728476577; 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=EWiwvj5KSak5iw1HXEVPujm6Q2wWyAwA6z/lZYjaN0g=; b=gFWnoM0FVDpZXQ+PIwvdEgRi2xIeEBUkNikkd3JyL+zBjTqeD7cDzwvfaTZu9ZRnN1 s6rgcQoFD+LeeDoxvcDrhxq4Kd9/bA7Wm/oIe/oY9bPA6+vH/pFTTcTtx7jwcSr9gzO9 tPp3dllyXJ7rCcueUuR2vbNidLsNX9JmPdQ4YLQ6PoNA9oP0lXhY6kyhP9C2no/MmT4S RKcjr/F72v0ucOE1g3OHSMjXsjuoiY0SvqOtYpTX0ag2bXAIrPOpCOcf8WWECvukH0MS oGkLyliLAo1+G+nCd5xcM+vObjeSZvJjVJMwDI55ZcDvsjI4m3IkDK5g5V0y47HeZRHA aTlw== X-Forwarded-Encrypted: i=1; AJvYcCVeDCneiMRPV5aR5DwFlPbgS1UEW51h1d5s6+fUmnbfLXPthK1PXE74onR5QatixhUNPcNI+OnHZbwb8DU=@vger.kernel.org X-Gm-Message-State: AOJu0YzUKIziWsd5f2Ho7WbDZOMDKAj8qrm0SGVX5WqeBmeB7Oi5aIYH IYAgD72nn4BHmyxc2Y77S56p/FoMf7wu9CfCCPpV+RLFofuay4jlRXxMAdtjuR0= X-Google-Smtp-Source: AGHT+IG2YfIlzqOBf8Qe1+i7eKAaGcPaaQ69rOLevaHyKiEZfEu6G3jNyhzopd/Ym4Ztq1N1Cwr9lw== X-Received: by 2002:a05:6512:33d4:b0:52d:b226:9428 with SMTP id 2adb3069b0e04-539a065c7d5mr1786952e87.6.1727871777108; Wed, 02 Oct 2024 05:22:57 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 05:22:55 -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, Viresh Kumar , Thierry Reding Subject: [PATCH v4 08/11] drm/tegra: gr3d: Convert into devm_pm_domain_attach_list() Date: Wed, 2 Oct 2024 14:22:29 +0200 Message-Id: <20241002122232.194245-9-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" 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(). Acked-by: Viresh Kumar Acked-by: Thierry Reding Signed-off-by: Ulf Hansson --- Changes in v4: - Minor. Use PD_FLAG_REQUIRED_OPP. --- drivers/gpu/drm/tegra/gr3d.c | 39 ++++++++---------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/tegra/gr3d.c b/drivers/gpu/drm/tegra/gr3d.c index 00c8564520e7..caee824832b3 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; =20 DECLARE_BITMAP(addr_regs, GR3D_NUM_REGS); }; @@ -369,18 +370,13 @@ static int gr3d_power_up_legacy_domain(struct device = *dev, const char *name, return 0; } =20 -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[] =3D { "3d0", "3d1", NULL }; - const u32 link_flags =3D 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 =3D { + .pd_names =3D (const char *[]) { "3d0", "3d1" }, + .num_pd_names =3D 2, + .pd_flags =3D PD_FLAG_REQUIRED_OPP, + }; int err; =20 err =3D of_count_phandle_with_args(dev->of_node, "power-domains", @@ -414,29 +410,10 @@ static int gr3d_init_power(struct device *dev, struct= gr3d *gr3d) if (dev->pm_domain) return 0; =20 - err =3D devm_pm_opp_attach_genpd(dev, opp_genpd_names, &opp_virt_devs); - if (err) + err =3D devm_pm_domain_attach_list(dev, &pd_data, &gr3d->pd_list); + if (err < 0) return err; =20 - for (i =3D 0; opp_genpd_names[i]; i++) { - pd_dev =3D opp_virt_devs[i]; - if (!pd_dev) { - dev_err(dev, "failed to get %s power domain\n", - opp_genpd_names[i]); - return -EINVAL; - } - - link =3D 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 =3D devm_add_action_or_reset(dev, gr3d_del_link, link); - if (err) - return err; - } - return 0; } =20 --=20 2.34.1 From nobody Thu Nov 28 08:40:05 2024 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 84D901D0953 for ; Wed, 2 Oct 2024 12:23:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871782; cv=none; b=o5apub5cIOOflxNJ9cD1+DiZwoWncDDbrQ0U7kbnbVv80vwTai3NbMbWq0OZuT3rsTLyxCuaLarKBaaIW9K5w7kFu8sJwmQej4ArVHN4hiaHfH7JdDjejMHuxLaS3DNiXjaoJGEQhxZy//rRep8VLxy3Wc9KfrUQJauNqGLMGt0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871782; c=relaxed/simple; bh=sGY+H8789Q9JtgwErnOIGZdYqKc19DOjdR9zTGYRZHY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nTXk+sMFs2XDJjFAXUYn7CrPmeNBmQaMOkydEffaaIPOHytBHlSiEpI/S1k4NGV7+EE42XrI/1b1w4Zw4u8WWxKF3bqTWGglpFKlYSZYMLdAcf8iKGHz6qMEweeXbOcaa/UeLsSMbdaz/4EUoGvcY/9w+OPb+xtFnJ2az4NIr6U= 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=i8J8SpJw; arc=none smtp.client-ip=209.85.167.42 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="i8J8SpJw" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-5366fd6fdf1so8134869e87.0 for ; Wed, 02 Oct 2024 05:23:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727871779; x=1728476579; 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=Vaf6IlG9zhgPzI3KNwNmZFZZ51blXFrFiAKMgpkRJ3I=; b=i8J8SpJw8mciG5ab3QqfV+BOsaSZELHCG/wNd53iWsDaN38x0+zapdoJNOAzqV4O9o MCXAGrFgv8g7+Xf2B7mggvKG0tWd5qky+OUGo2bXjGqOIQOQGgE/AEb1J7G/2ffFjKG/ Q+WjD/Qj4Lz3uH13uhlGCDpmpn1ZkfRa/8z8xFyU/j2Fkyh1L1KXRD3xi1jMntcqULOo Jl8lJBpcPwmJPjImSJm7B+JKFJBvSuq6Wkk7pPtYPpxI34l1we0cIl2Fj898ADlrQgLt BTYYW+BLd4RTEdqiiKv78vnIItM1wlPAYY7ce12ia4fFoor5bsopBVkIu2TwGsOIB9fq Qr3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727871779; x=1728476579; 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=Vaf6IlG9zhgPzI3KNwNmZFZZ51blXFrFiAKMgpkRJ3I=; b=i2r5OURsGaQS+Bd6a14VaKXgNHKSMw07hEIkd0hu69aODV8WZBKyjtebJD4aZOawtj KkZadmwKu++mIs1CbfUWzl1dYDI2cueNKhp9YVhTKk1t3r8fSNZOLnsN3TN6rs0ep7KE Tn/UmxprB1o+yN1eXYRwPa2/uIizbSQb+cZAmapR2l0J/hts0dM2J4Zn+0CfxV/IzI7K y8zcXQNqAy6XMT0H/LDGvjebbrpcaZuBLic5xtMfW0UA1f3+lS5XgKtOOh31YCG3cMY3 v/xJAqSHVUH6BUcH/8xATUVUkrrJv9miREw1U7ZwzZoHj5/vbvNfQAqq3AtzmppoAfCD c5BA== X-Forwarded-Encrypted: i=1; AJvYcCXLZA4JuduOVchwZnVBmRhHx3ChXdAdk/8okd40hIhbonz1Noya8ODoNePhbWDp2a4BhD12G5of4MTM6ts=@vger.kernel.org X-Gm-Message-State: AOJu0YzsmKzDDC+ehC9mhQwQ/AqhD9Pij7CD9yX1FWovdEVvCikBfzux gQjriDtxHrG4ZcKcV6J4pTfNiMk2z0Ptl1jqt7CsQTKfq/GoEXnBjxSfbIheXbo= X-Google-Smtp-Source: AGHT+IF2C5fiXmGg2CrFCAR3PvK0jhrzjShfC2YJsprlsYnRU756vzhC6TCORSWVEQUMw5Zyl9Yn6w== X-Received: by 2002:a05:6512:334d:b0:539:a4ef:6752 with SMTP id 2adb3069b0e04-539a4ef6a4dmr525834e87.6.1727871778597; Wed, 02 Oct 2024 05:22:58 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 05:22:58 -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, Viresh Kumar Subject: [PATCH v4 09/11] media: venus: Convert into devm_pm_domain_attach_list() for OPP PM domain Date: Wed, 2 Oct 2024 14:22:30 +0200 Message-Id: <20241002122232.194245-10-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" 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 Acked-by: Viresh Kumar Signed-off-by: Ulf Hansson --- Changes in v4: - Minor. Use PD_FLAG_REQUIRED_OPP. --- 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/platf= orm/qcom/venus/core.c index 84e95a46dfc9..8ad36ed0ca8b 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -752,7 +752,7 @@ static const struct venus_resources sdm845_res_v2 =3D { .vcodec_clks_num =3D 2, .vcodec_pmdomains =3D (const char *[]) { "venus", "vcodec0", "vcodec1" }, .vcodec_pmdomains_num =3D 3, - .opp_pmdomain =3D (const char *[]) { "cx", NULL }, + .opp_pmdomain =3D (const char *[]) { "cx" }, .vcodec_num =3D 2, .max_load =3D 3110400, /* 4096x2160@90 */ .hfi_version =3D HFI_VERSION_4XX, @@ -801,7 +801,7 @@ static const struct venus_resources sc7180_res =3D { .vcodec_clks_num =3D 2, .vcodec_pmdomains =3D (const char *[]) { "venus", "vcodec0" }, .vcodec_pmdomains_num =3D 2, - .opp_pmdomain =3D (const char *[]) { "cx", NULL }, + .opp_pmdomain =3D (const char *[]) { "cx" }, .vcodec_num =3D 1, .hfi_version =3D HFI_VERSION_4XX, .vpu_version =3D VPU_VERSION_AR50, @@ -858,7 +858,7 @@ static const struct venus_resources sm8250_res =3D { .vcodec_clks_num =3D 1, .vcodec_pmdomains =3D (const char *[]) { "venus", "vcodec0" }, .vcodec_pmdomains_num =3D 2, - .opp_pmdomain =3D (const char *[]) { "mx", NULL }, + .opp_pmdomain =3D (const char *[]) { "mx" }, .vcodec_num =3D 1, .max_load =3D 7833600, .hfi_version =3D HFI_VERSION_6XX, @@ -917,7 +917,7 @@ static const struct venus_resources sc7280_res =3D { .vcodec_clks_num =3D 2, .vcodec_pmdomains =3D (const char *[]) { "venus", "vcodec0" }, .vcodec_pmdomains_num =3D 2, - .opp_pmdomain =3D (const char *[]) { "cx", NULL }, + .opp_pmdomain =3D (const char *[]) { "cx" }, .vcodec_num =3D 1, .hfi_version =3D HFI_VERSION_6XX, .vpu_version =3D VPU_VERSION_IRIS2_1, diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platf= orm/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..33a5a659c0ad 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 =3D core->dev; const struct venus_resources *res =3D core->res; struct dev_pm_domain_attach_data vcodec_data =3D { @@ -872,6 +871,11 @@ static int vcodec_domains_get(struct venus_core *core) .num_pd_names =3D res->vcodec_pmdomains_num, .pd_flags =3D PD_FLAG_NO_DEV_LINK, }; + struct dev_pm_domain_attach_data opp_pd_data =3D { + .pd_names =3D res->opp_pmdomain, + .num_pd_names =3D 1, + .pd_flags =3D PD_FLAG_DEV_LINK_ON | PD_FLAG_REQUIRED_OPP, + }; =20 if (!res->vcodec_pmdomains_num) goto skip_pmdomains; @@ -881,37 +885,15 @@ static int vcodec_domains_get(struct venus_core *core) return ret; =20 skip_pmdomains: - if (!core->res->opp_pmdomain) + if (!res->opp_pmdomain) return 0; =20 /* Attach the power domain for setting performance state */ - ret =3D devm_pm_opp_attach_genpd(dev, res->opp_pmdomain, &opp_virt_dev); - if (ret) - goto opp_attach_err; - - core->opp_pmdomain =3D *opp_virt_dev; - core->opp_dl_venus =3D device_link_add(dev, core->opp_pmdomain, - DL_FLAG_RPM_ACTIVE | - DL_FLAG_PM_RUNTIME | - DL_FLAG_STATELESS); - if (!core->opp_dl_venus) { - ret =3D -ENODEV; - goto opp_attach_err; - } + ret =3D devm_pm_domain_attach_list(dev, &opp_pd_data, &core->opp_pmdomain= ); + if (ret < 0) + return ret; =20 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); } =20 static int core_resets_reset(struct venus_core *core) @@ -1000,9 +982,7 @@ static int core_get_v4(struct venus_core *core) =20 if (core->res->opp_pmdomain) { ret =3D devm_pm_opp_of_add_table(dev); - if (!ret) { - core->has_opp_table =3D true; - } else if (ret !=3D -ENODEV) { + if (ret && ret !=3D -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) =20 static void core_put_v4(struct venus_core *core) { - if (legacy_binding) - return; - - vcodec_domains_put(core); } =20 static int core_power_v4(struct venus_core *core, int on) --=20 2.34.1 From nobody Thu Nov 28 08:40:05 2024 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (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 61D351D0977 for ; Wed, 2 Oct 2024 12:23:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871784; cv=none; b=MNOsdqW7TzpAL4Nt+vkLjEwMTV+k/mRv34X6JAyFowEmKWQ59SQrhMYmVTj6TgQ1GmyCwmVa8rWSLIaAypRt8BYtgdtiItRaynDYsjHQI+M8ZfbK+yxn3pI2/ulfGqkyiTVc2Mm3XULrIcRLdNeuoN8I4hgvB5R37coIpYX7H/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871784; c=relaxed/simple; bh=SmO3sdlVk0x8zX0KM6W3DZtxwnyTB8/LIKgDqf6GADQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hBKlba2UQMpiZ6n48ThDSBfReT/7FD2qvUPZL2A7CFEi0JtZZxiswtqZAj472O7X1FRZF1gHEWyvMyGgcLe5IQ8jrKQ/SSsjnN7eqdLmwhtp/llBUs/cqOKePlsi8D+TAq7HsG9IJhMawpRMIYNh3z6ycDYzYEmt9bm7MWO0nzY= 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=l0NoTj8e; arc=none smtp.client-ip=209.85.167.43 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="l0NoTj8e" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5398c1bd0b8so806059e87.0 for ; Wed, 02 Oct 2024 05:23:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727871780; x=1728476580; 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=ioJK8BOaSsn9HTDSl84hfYEjyAU3JP05p6zQ+wzakGg=; b=l0NoTj8eoRDMZWbsZFMRnWSOxBAm7PkGeK9x8dIeP+IXLFgA3iRCJLivpoLC4Nsku1 ZQUEA/lfoU9h2y1HrQg53d0PnFX+zkYqB4RtKlnIvneBTjwKqOXwqkUvFtNMAJGs7GE0 KgFVdztl2E6vTnEAV8gsp1DoVoHTiRrS+CB+hJekOVLZnVXxgSw86s7ou+xE5JUqySp1 UYYDp8toQN5lMkxtm1oI0zcLuD3cxhvB0StpQemehA4Q63nN66275zDcS66NtG0k4Q+x bNS+6BPPlbhASgv51apXTEH+UTWJnIXG8df6xmMjQiiGlk+bz8uhpgj3RhiA2Gafjrt+ 51jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727871780; x=1728476580; 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=ioJK8BOaSsn9HTDSl84hfYEjyAU3JP05p6zQ+wzakGg=; b=dLoO9surCWo3tJSRMLhTagVLPawsvuWeOBGaa1xFpuhgjDi+2zB1i5Rt5pMt7wkDrX X8SE0n6EJds8Kw7nsb/fhSTbta9XfbuQI41CD0/k9EsEAqFkIiMPSw0ey8dk9FOB52Kb 3hKaE1Otrw2eFx+NbWEoFdhT0vZskWgShjHIQW8Tghkv2dKgFA8nWysVvTSYXa0FEZNf bm7hk7kSz0p4NjbHRc+z6njGHg0eQQAlPY+ytk33DDZcYojKeptsp3kpb/H4iWE2H2E0 XTRTCAz3PZFOq26fmD+EdYBqrGs7y3JiT6U98L0jNXk72dxfRQYcBNIrTH/Tq1d83SXn a1QA== X-Forwarded-Encrypted: i=1; AJvYcCXtESVQnZ1mIutFKkVArOITUGR/IHwP/UlSOVYxhCWVm3sVQk5PlKTeAKn20AZJATR5Tr3ywFzavvpuRC8=@vger.kernel.org X-Gm-Message-State: AOJu0YxtFKR5+U+MtPS+3sO5w0b49lUWamHIcAQX4MZYFQAL1/47N+pm TdwXlOQPOIIDBmup3WeYwWdGFVb6cLmkJtiSqFoEt5EtojFnpr9wwV9wfK2DiZI= X-Google-Smtp-Source: AGHT+IHZvUpUQVKydq2pw6p7GG/MT83+FpL8b5ACaxZ94aFtOvkahJE/oZ+bt2LWwTM0yOZWU2UVgw== X-Received: by 2002:a05:6512:e9a:b0:539:922e:2374 with SMTP id 2adb3069b0e04-5399a23594bmr2277661e87.1.1727871780381; Wed, 02 Oct 2024 05:23:00 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 05:22:59 -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, Viresh Kumar Subject: [PATCH v4 10/11] cpufreq: qcom-nvmem: Convert to dev_pm_domain_attach|detach_list() Date: Wed, 2 Oct 2024 14:22:31 +0200 Message-Id: <20241002122232.194245-11-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" 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. Acked-by: Viresh Kumar Signed-off-by: Ulf Hansson --- Changes in v4: - Minor. Use PD_FLAG_REQUIRED_OPP. --- drivers/cpufreq/qcom-cpufreq-nvmem.c | 82 ++++++++++------------------ 1 file changed, 28 insertions(+), 54 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cp= ufreq-nvmem.c index 703308fb891a..ae556d5ba231 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; }; =20 struct qcom_cpufreq_drv_cpu { int opp_token; - struct device **virt_devs; + struct dev_pm_domain_list *pd_list; }; =20 struct qcom_cpufreq_drv { @@ -395,8 +396,6 @@ static int qcom_cpufreq_ipq8074_name_version(struct dev= ice *cpu_dev, return 0; } =20 -static const char *generic_genpd_names[] =3D { "perf", NULL }; - static const struct qcom_cpufreq_match_data match_data_kryo =3D { .get_version =3D qcom_cpufreq_kryo_name_version, }; @@ -407,13 +406,13 @@ static const struct qcom_cpufreq_match_data match_dat= a_krait =3D { =20 static const struct qcom_cpufreq_match_data match_data_msm8909 =3D { .get_version =3D qcom_cpufreq_simple_get_version, - .genpd_names =3D generic_genpd_names, + .pd_names =3D (const char *[]) { "perf" }, + .num_pd_names =3D 1, }; =20 -static const char *qcs404_genpd_names[] =3D { "cpr", NULL }; - static const struct qcom_cpufreq_match_data match_data_qcs404 =3D { - .genpd_names =3D qcs404_genpd_names, + .pd_names =3D (const char *[]) { "cpr" }, + .num_pd_names =3D 1, }; =20 static const struct qcom_cpufreq_match_data match_data_ipq6018 =3D { @@ -428,28 +427,16 @@ static const struct qcom_cpufreq_match_data match_dat= a_ipq8074 =3D { .get_version =3D qcom_cpufreq_ipq8074_name_version, }; =20 -static void qcom_cpufreq_suspend_virt_devs(struct qcom_cpufreq_drv *drv, u= nsigned int cpu) -{ - const char * const *name =3D drv->data->genpd_names; - int i; - - if (!drv->cpus[cpu].virt_devs) - return; - - for (i =3D 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, unsig= ned int cpu) +static void qcom_cpufreq_suspend_pd_devs(struct qcom_cpufreq_drv *drv, uns= igned int cpu) { - const char * const *name =3D drv->data->genpd_names; + struct dev_pm_domain_list *pd_list =3D drv->cpus[cpu].pd_list; int i; =20 - if (!drv->cpus[cpu].virt_devs) + if (!pd_list) return; =20 - for (i =3D 0; *name; i++, name++) - pm_runtime_put(drv->cpus[cpu].virt_devs[i]); + for (i =3D 0; i < pd_list->num_pds; i++) + device_set_awake_path(pd_list->pd_devs[i]); } =20 static int qcom_cpufreq_probe(struct platform_device *pdev) @@ -503,7 +490,6 @@ static int qcom_cpufreq_probe(struct platform_device *p= dev) } =20 for_each_possible_cpu(cpu) { - struct device **virt_devs =3D NULL; struct dev_pm_opp_config config =3D { .supported_hw =3D NULL, }; @@ -522,12 +508,7 @@ static int qcom_cpufreq_probe(struct platform_device *= pdev) config.prop_name =3D pvs_name; } =20 - if (drv->data->genpd_names) { - config.genpd_names =3D drv->data->genpd_names; - config.virt_devs =3D &virt_devs; - } - - if (config.supported_hw || config.genpd_names) { + if (config.supported_hw) { drv->cpus[cpu].opp_token =3D dev_pm_opp_set_config(cpu_dev, &config); if (drv->cpus[cpu].opp_token < 0) { ret =3D drv->cpus[cpu].opp_token; @@ -536,25 +517,18 @@ static int qcom_cpufreq_probe(struct platform_device = *pdev) } } =20 - if (virt_devs) { - const char * const *name =3D config.genpd_names; - int i, j; - - for (i =3D 0; *name; i++, name++) { - ret =3D pm_runtime_resume_and_get(virt_devs[i]); - if (ret) { - dev_err(cpu_dev, "failed to resume %s: %d\n", - *name, ret); - - /* Rollback previous PM runtime calls */ - name =3D config.genpd_names; - for (j =3D 0; *name && j < i; j++, name++) - pm_runtime_put(virt_devs[j]); - - goto free_opp; - } - } - drv->cpus[cpu].virt_devs =3D virt_devs; + if (drv->data->pd_names) { + struct dev_pm_domain_attach_data attach_data =3D { + .pd_names =3D drv->data->pd_names, + .num_pd_names =3D drv->data->num_pd_names, + .pd_flags =3D PD_FLAG_DEV_LINK_ON | + PD_FLAG_REQUIRED_OPP, + }; + + ret =3D dev_pm_domain_attach_list(cpu_dev, &attach_data, + &drv->cpus[cpu].pd_list); + if (ret < 0) + goto free_opp; } } =20 @@ -570,7 +544,7 @@ static int qcom_cpufreq_probe(struct platform_device *p= dev) =20 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 +558,7 @@ static void qcom_cpufreq_remove(struct platform_device = *pdev) platform_device_unregister(cpufreq_dt_pdev); =20 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 +569,7 @@ static int qcom_cpufreq_suspend(struct device *dev) unsigned int cpu; =20 for_each_possible_cpu(cpu) - qcom_cpufreq_suspend_virt_devs(drv, cpu); + qcom_cpufreq_suspend_pd_devs(drv, cpu); =20 return 0; } --=20 2.34.1 From nobody Thu Nov 28 08:40:05 2024 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 E127E1D0B98 for ; Wed, 2 Oct 2024 12:23:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871785; cv=none; b=VWlyYQYDO4tAlSVmC+PMVNisLT9YSVVMJw037CUfSp9Ne4KaAqXqsV1Su+fJ9ybDl6nOavG1pvMhQnuPOHtFiwyp85s6oFvjfk5+jB/iTmC1BzE3Xanyfiyoyyn9QDu088ETm8WX4bX7bTlGv/qtJr+t9UkMSV+D3ojD6wGZxSU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871785; c=relaxed/simple; bh=B+cxcgnBoCbaeNr/2/pJBjD+nouj1vfJ4FbwWfvcU8U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Tzc/HiTtuDYPSnBDQm1llj94PRzjgfRfggPD6z+sABqmJvx8/NVbl0rLgLGN7TRtweqglJkTByZNRK+HcKwN6UAvH8RxAjz/X1wNQs+6lf1HbDqhfUWK7lUSejQmbElsupn6zynnCp3Qe5lrmPj9O1aNAqya0P8eZ/H5/RvXfns= 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=ajrdUhGQ; arc=none smtp.client-ip=209.85.208.175 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="ajrdUhGQ" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2fabfc06de3so44752411fa.1 for ; Wed, 02 Oct 2024 05:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727871782; x=1728476582; 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=R/TIVUQtU3PI71l1Gg1zwcb6OPzLgVwsx6x/KydYFvA=; b=ajrdUhGQJ4X540cSO3QmFF6ArknkA+VgLOI6S61KDlDibFtYOAkqLgfI7SlpSx1yzS N9AFRod+hqZHvbqTyjKoU/Uox9ws0LCe3sCaswc6BcuiEI/14in+EY1lGi9zAVOa5k4u dqZEob9D66w4Xj9DrPQMLqnutbl6QH5TEVDoryjO2VbFhr7nD/mRBORxEe0jtSeIjgch LG0JcPNhNlECRlPZYADOI0UaCFH4Wx1RvtDx+ciZOl2u8hDvj+JBVZxBcrep/sTpe8Vj AOellouJV9FSEpe+Iil/2k88YsO+P6tmsV7U4pEQX/Svuh4IaFXXxisuGS4VAg825x1+ ROiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727871782; x=1728476582; 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=R/TIVUQtU3PI71l1Gg1zwcb6OPzLgVwsx6x/KydYFvA=; b=BlTNyulmYahxGTihkzbNqu8vnPIzPOHEP84/ohxQEwxcl4PyA8J/TW2s4Ted4EHygF cGOQPh6oMQfsFKrAANsphgZfodpjK+Fx491AzVMhtnGgbbF1d4bXxnRRHy3/1l5e1v1P nVbpnSfrcs8X3Ix/FMkSA6HIXDsjwMJvwZAno9cxbReaYQOLyL9PU0gQBysZ5gsC5bwt 0TLHk5+EsGMTH1Lw9uGUZoCvgY9tLNkytqiCfyWRSJMWLKCa9Y38vS71fFqKAY4IyInm 6Zg+yTz1+jDjSsHRAMz+f/CWDINTnLfLe0nbKgY4ghOTJeQmi3VugMgRRzw+HPlypvLV mndQ== X-Forwarded-Encrypted: i=1; AJvYcCVvjaEExgJv3O2ZhzUZTXv565oYGJT8JtWFE8vWuVxwPRPjz+tKnMXiWnjo619s619j1B8T9mtEN7pWy6Q=@vger.kernel.org X-Gm-Message-State: AOJu0YyxANUUtOZC33cYe8Osgi/mfJ/2KStkauMMHMSCAELi9rf2N10E 4H5en/wSm6MG/akC3Mso2jT/6MZx4m5V+21ab6f8U/n8hI3jm0kw/KpOw81pCM4= X-Google-Smtp-Source: AGHT+IFawbKX+I8rk+bpYYckI/zcGZtQxnHsS92WEjhwf3PwCQ2ejxH/QFVFPUhojNeLCdjjKr54Vg== X-Received: by 2002:a05:6512:1393:b0:536:53c2:8179 with SMTP id 2adb3069b0e04-539a079e87fmr1798776e87.37.1727871781914; Wed, 02 Oct 2024 05:23:01 -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.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 05:23:01 -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, Viresh Kumar Subject: [PATCH v4 11/11] OPP: Drop redundant *_opp_attach|detach_genpd() Date: Wed, 2 Oct 2024 14:22:32 +0200 Message-Id: <20241002122232.194245-12-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" 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. Acked-by: Viresh Kumar Signed-off-by: Ulf Hansson --- Changes in v4: - A plain rebase. --- drivers/opp/core.c | 131 +---------------------------------------- drivers/opp/opp.h | 3 +- include/linux/pm_opp.h | 38 +----------- 3 files changed, 3 insertions(+), 169 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 42b7c8f2e71e..55c4c2c39a93 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2360,119 +2360,6 @@ static void _opp_put_config_regulators_helper(struc= t opp_table *opp_table) opp_table->config_regulators =3D NULL; } =20 -static void _opp_detach_genpd(struct opp_table *opp_table) -{ - int index; - - for (index =3D 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); - opp_table->required_devs[index] =3D NULL; - } -} - -/* - * Multiple generic power domains for a device are supported with the help= of - * virtual genpd devices, which are created for each consumer device - gen= pd - * pair. These are the device structures which are attached to the power d= omain - * and are required by the OPP core to set the performance state of the ge= npd. - * The same API also works for the case where single genpd is available an= d 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 *d= ev, - const char * const *names, struct device ***virt_devs) -{ - struct device *virt_dev, *gdev; - struct opp_table *genpd_table; - int index =3D 0, ret =3D -EINVAL; - const char * const *name =3D 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 >=3D 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 =3D dev_pm_domain_attach_by_name(dev, *name); - if (IS_ERR_OR_NULL(virt_dev)) { - ret =3D virt_dev ? PTR_ERR(virt_dev) : -ENODEV; - dev_err(dev, "Couldn't attach to pm_domain: %d\n", ret); - 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 =3D dev_to_genpd_dev(virt_dev); - if (IS_ERR(gdev)) { - ret =3D PTR_ERR(gdev); - goto err; - } - - genpd_table =3D _find_opp_table(gdev); - if (!IS_ERR(genpd_table)) { - if (genpd_table !=3D opp_table->required_opp_tables[index]) { - dev_pm_opp_put_opp_table(opp_table->required_opp_tables[index]); - opp_table->required_opp_tables[index] =3D genpd_table; - } else { - dev_pm_opp_put_opp_table(genpd_table); - } - } - - opp_table->required_devs[index] =3D virt_dev; - index++; - name++; - } - - if (virt_devs) - *virt_devs =3D 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, @@ -2539,9 +2426,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) @@ -2653,20 +2537,7 @@ int dev_pm_opp_set_config(struct device *dev, struct= dev_pm_opp_config *config) data->flags |=3D OPP_CONFIG_REGULATOR; } =20 - /* Attach genpds */ - if (config->genpd_names) { - if (config->required_devs) { - ret =3D -EINVAL; - goto err; - } - - ret =3D _opp_attach_genpd(opp_table, dev, config->genpd_names, - config->virt_devs); - if (ret) - goto err; - - data->flags |=3D OPP_CONFIG_GENPD; - } else if (config->required_dev) { + if (config->required_dev) { ret =3D _opp_set_required_dev(opp_table, dev, config->required_dev, config->required_dev_index); 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) =20 /** * struct opp_config_data - data for set config operations diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index bc74bc69107a..568183e3e641 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 gen= pd to - * attach. Mutually exclusive with required_dev. - * @virt_devs: Pointer to return the array of genpd virtual devices. Mutua= lly - * exclusive with required_dev. - * @required_dev: Required OPP device. Mutually exclusive with genpd_names= /virt_devs. + * @required_dev: The required OPP device. * @required_dev_index: The index of the required OPP for the @required_de= v. * * This structure contains platform specific OPP configurations for the de= vice. @@ -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; unsigned int required_dev_index; }; @@ -677,36 +671,6 @@ static inline void dev_pm_opp_put_config_regulators(in= t token) dev_pm_opp_clear_config(token); } =20 -/* 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 =3D { - .genpd_names =3D names, - .virt_devs =3D 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 =3D { - .genpd_names =3D names, - .virt_devs =3D 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) { --=20 2.34.1