From patchwork Wed Oct 2 12:22:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13819737 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 062571CF7C6 for ; Wed, 2 Oct 2024 12:22:43 +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=1727871765; cv=none; b=Bkm+6Cl6r8JuTXZxoTg6fQCnVDM0H+rJN3qJfPwDq/ZlyDeWR4mIUVfV9+C3lh4XlsfAtJmUlIu5eVFGrmLtTjdDYDo57otr2i0Ic7i3H+HzaggwRIKhrSHHwsXPnX0mPbceHB8LW1zkJ7teE1/HEONDyojBZj0KdvtMLy2mM74= 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.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="OXshoZqi" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5398ec2f3c3so993928e87.1 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=RuasjwNXx9kfoVbC/2G86uIj9hbGMJDxabditv0GLLcj9rghbuauDxyx8DQe1qFIE/ F6phga0uuPtCMdD8FsOUiFxeCdAm6768pZPcYX66atl5Sv1skKEe31yxwjsi5zPZqqCz 4XN3finh8VvvPdmTf3u7SVe3g4ufLeCeLVIcfBU2PossZUEcN5drniqTGsB5qKDBIWtt RX5ct7seHyJJlNh6bnS4oumH6jAuEhs8CFvfoo7ZmbGRuSSI/vSa37isVa7uoeyyeGoR XjnA02mH/H3Y/RoKdZLMeq1zVL8dMYclri9AJiNOzqx30ClvdA2wYLhcc8IJMDYllUP2 /BJQ== X-Forwarded-Encrypted: i=1; AJvYcCWlJbjSMa8Fl0hCA7JL+A6hwwmjuBWWU4jV597VrBiUH/pr792uxmkfeLm2Ivx1gVvuTBE2vnyCZw==@vger.kernel.org X-Gm-Message-State: AOJu0Yzca4gUvDZAYtdAfIIXj/FnPiGNqN/Ju0Elyt3DMsTzIRWr/iMW QFPw7ggrBEpBhGSFzVo+3Dhn4vYV574eCLw/M+KfkDhpGuhp7/0dIUQpa+OIV3A18u5onnh+Cbj F 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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; 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; } +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 = { - .pd_names = (const char *[]) { "3d0", "3d1" }, - .num_pd_names = 2, - }; + static const char * const opp_genpd_names[] = { "3d0", "3d1", NULL }; + const u32 link_flags = DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME; + struct device **opp_virt_devs, *pd_dev; + struct device_link *link; + unsigned int i; int err; err = 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; - err = dev_pm_domain_attach_list(dev, &pd_data, &gr3d->pd_list); - if (err < 0) + err = devm_pm_opp_attach_genpd(dev, opp_genpd_names, &opp_virt_devs); + if (err) return err; + for (i = 0; opp_genpd_names[i]; i++) { + pd_dev = opp_virt_devs[i]; + if (!pd_dev) { + dev_err(dev, "failed to get %s power domain\n", + opp_genpd_names[i]); + return -EINVAL; + } + + link = device_link_add(dev, pd_dev, link_flags); + if (!link) { + dev_err(dev, "failed to link to %s\n", dev_name(pd_dev)); + return -EINVAL; + } + + err = devm_add_action_or_reset(dev, gr3d_del_link, link); + if (err) + return err; + } + return 0; } @@ -503,13 +527,13 @@ static int gr3d_probe(struct platform_device *pdev) err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev); if (err) - goto err; + return err; err = 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; } /* 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); return 0; -err: - dev_pm_domain_detach_list(gr3d->pd_list); - return err; } static void gr3d_remove(struct platform_device *pdev) @@ -528,7 +549,6 @@ static void gr3d_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); host1x_client_unregister(&gr3d->client.base); - dev_pm_domain_detach_list(gr3d->pd_list); } static int __maybe_unused gr3d_runtime_suspend(struct device *dev) From patchwork Wed Oct 2 12:22:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13819738 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 85CAE1CFED2 for ; Wed, 2 Oct 2024 12:22:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871767; cv=none; b=pZJ7xRzqbdJQTl1ic9b/IVXEkOgeu4QzRJZgiuVt4qRuCoU/o4z6iQErCI/Xjpx85+4uUX2RSLQQGtBwEJURlcLB86/PhVYu43TG+FJkQrIM2Us6wzskYN4fere3EXx3vIVTMIjetD5BWaPRgSLgSXKSGZ4GOB+gECj1ECO5X8s= 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=bNqwpn5U; arc=none smtp.client-ip=209.85.167.52 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="bNqwpn5U" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-5398b2f43b9so707862e87.1 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=1727871764; x=1728476564; 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=bNqwpn5UC3ukEVpwcZ2gZGXBEg4mE9A3Izra5X0tMznDOu23o0D+bjMflFV+rSiRGZ 2fT8jbvbswLr9mtxWRS9hfBZR+SGezcNfe/myc8IMm2vY9mOeBnM8OF5P4N+aCaKgZWP aUyU+FFQC0DHM41FfZjtCiw/ko8jYYesNDUbi8O0y1QXOIcpJe9tQef1mvRozgQpc96Z e7OYSkZTOc0eb2FfDa7+4/LTjBgKzWwlP6UT6LtBYnJbE2RPnKJw0Drxd90O6GvSv51A zalFiQpcJPBCzZH4jG99J7UkWSrLmC4utxAoNFpMtI3f0k5ZmvC45sknzcbVt2U8cbl7 l4cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727871764; x=1728476564; 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=ZL4jZU8+ShXcidyI+bxxWHeGcdueVjG9i1Gg/NAWcPcJLvm3mTKNjS5hHaUBhPQN7M X9cSLnIEpPfuR9R4c20f+aiVbj8sGLBjbf1cPmXeJ2MesG/0N8r/eMeNndmyhUfvMmX5 cZK9kCnYBRyS5vyn/sfJ8ezmbpolT9oKijiRS/V+moAZ3ze9wKLdvxnt7HBNlEwCAmVs iIBwBy+IieVQE6uHqKcQZiUdhqsc7DPLzi4jQn4v9nGk0UJNx2S83ij7H2BxRp7m+9gC S4Yczr0jFXea3m2GYQnhvRNDzS3y8fvFRxJ3yRgU16/hrJTEUxj/4w5EJ1dOxtZiQl8f 23mg== X-Forwarded-Encrypted: i=1; AJvYcCWhPrjTgu0iCgtJYMCymRNothjXpV+IcVI6L52NK3TvCIGiexGiZTZd7pHgZWs9ko6KurAK6JPvuw==@vger.kernel.org X-Gm-Message-State: AOJu0YxkgmWyt6bURv1PmPTBrI3BmH29vNnjCn1z0VP2EqE5UgcrqS/L S9d4pMBh8IYoo7Sm6d2SlhUszi899SB+Vg4Y06zdEvF2wBBkCoVqzALI5dJjAxo= 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 multiple PM domains") Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson --- Changes in v4: - New patch. --- 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 = NULL; int ret, i, num_pds = 0; bool by_id = true; + size_t size; u32 pd_flags = data ? data->pd_flags : 0; u32 link_flags = 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 <= 0) return 0; - pds = devm_kzalloc(dev, sizeof(*pds), GFP_KERNEL); + pds = kzalloc(sizeof(*pds), GFP_KERNEL); if (!pds) return -ENOMEM; - pds->pd_devs = devm_kcalloc(dev, num_pds, sizeof(*pds->pd_devs), - GFP_KERNEL); - if (!pds->pd_devs) - return -ENOMEM; - - pds->pd_links = devm_kcalloc(dev, num_pds, sizeof(*pds->pd_links), - GFP_KERNEL); - if (!pds->pd_links) - return -ENOMEM; + size = sizeof(*pds->pd_devs) + sizeof(*pds->pd_links); + pds->pd_devs = kcalloc(num_pds, size, GFP_KERNEL); + if (!pds->pd_devs) { + ret = -ENOMEM; + goto free_pds; + } + pds->pd_links = (void *)(pds->pd_devs + num_pds); if (link_flags && pd_flags & PD_FLAG_DEV_LINK_ON) link_flags |= 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_list *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); From patchwork Wed Oct 2 12:22:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13819739 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 43B5B1D0151 for ; Wed, 2 Oct 2024 12:22:47 +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=1727871769; cv=none; b=X6rHIWDttmOlsTP/LE3NXCx8gVHcNTfHdR+H8F81fOIuwYrqa4Wf1lA0CQXVILEU6mqQe+k+tEjG24ly1AMcqOk2RWKS7fODNUWjAzWuVvJwcnmgRSczVcIaOpqWC0F6dOl3wFqeBQTwl03Aidv+FIH/BXxB5WYnj6zWrxlDRYI= 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.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="vCONkas1" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-5389917ef34so7730715e87.2 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=VrfbeD5szIBaa2jKHyslqkZz+nkdEpMgvkuezac79wVsHjj8mMMc5kCmtQPie+s4R/ lXa0sdzTIefgo7YYqaEKz1G4CRTv+3RisZetJXrjTEJpAscZURcsHaYNw2jkFdlHjtpT I5yZz0XBZhmHYVh/jvsanrrrLH0w5/24m7WcI8H5SehcKhef4pQSngE02HkRGPdVIBVd OnUQJxhECHVT9lPq7LtNBAtdUutIxXtWl8yhgMXilI4DhvQwLQ8FZjfdIxrCaCZxkSSN H2Tx9CDRpD79Ohr78UCq/2FdAaUdkKNwyvf5LDEXfbJjNmh+n0EktjFiOCi47mcidm27 +iig== X-Forwarded-Encrypted: i=1; AJvYcCUyqlYaROZklJaQOI9Cwgwqj9SEuo0FRoTtSLC3HDI2B9Uvl48HsslnQWs6KHjYORXoUZRbG8FrpQ==@vger.kernel.org X-Gm-Message-State: AOJu0YyXCLNViN0bBhuvhGt9P6ub/POPxohPnDDP65Tycv/ynq/OU9gg H4RAtWz1Md88Kx69acjysLa3xCDOiQ1k90FteVhzk0wAhAtMACEEasLko3M3dHc= 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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, } -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; - 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 >= opp_table->required_opp_count) { dev_err(dev, "Required OPPs not available, can't set required devs\n"); return -EINVAL; } - /* Another device that shares the OPP table has set the required devs ? */ - if (opp_table->required_devs[0]) - return 0; + required_table = 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; + } - for (i = 0; i < opp_table->required_opp_count; i++) { - /* Genpd core takes care of propagation to parent genpd */ - if (required_devs[i] && opp_table->is_genpd && - opp_table->required_opp_tables[i]->is_genpd) { - dev_err(dev, "%s: Operation not supported for genpds\n", __func__); - return -EOPNOTSUPP; + /* + * The required_opp_tables parsing is not perfect, as the OPP core does + * the parsing solely based on the DT node pointers. The core sets the + * required_opp_tables entry to the first OPP table in the "opp_tables" + * list, that matches with the node pointer. + * + * If the target DT OPP table is used by multiple devices and they all + * create separate instances of 'struct opp_table' from it, then it is + * possible that the required_opp_tables entry may be set to the + * incorrect sibling device. + * + * Cross check it again and fix if required. + */ + gdev = dev_to_genpd_dev(required_dev); + if (IS_ERR(gdev)) + return PTR_ERR(gdev); + + pd_table = _find_opp_table(gdev); + if (!IS_ERR(pd_table)) { + if (pd_table != required_table) { + dev_pm_opp_put_opp_table(required_table); + opp_table->required_opp_tables[index] = pd_table; + } else { + dev_pm_opp_put_opp_table(pd_table); } - - opp_table->required_devs[i] = required_devs[i]; } + opp_table->required_devs[index] = required_dev; return 0; } -static void _opp_put_required_devs(struct opp_table *opp_table) +static void _opp_put_required_dev(struct opp_table *opp_table, + unsigned int index) { - int i; - - for (i = 0; i < opp_table->required_opp_count; i++) - opp_table->required_devs[i] = NULL; + opp_table->required_devs[index] = NULL; } static void _opp_clear_config(struct opp_config_data *data) { - if (data->flags & OPP_CONFIG_REQUIRED_DEVS) - _opp_put_required_devs(data->opp_table); + if (data->flags & OPP_CONFIG_REQUIRED_DEV) + _opp_put_required_dev(data->opp_table, data->index); else if (data->flags & OPP_CONFIG_GENPD) _opp_detach_genpd(data->opp_table); @@ -2641,13 +2666,15 @@ int dev_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config) goto err; data->flags |= OPP_CONFIG_GENPD; - } else if (config->required_devs) { - ret = _opp_set_required_devs(opp_table, dev, - config->required_devs); + } else if (config->required_dev) { + ret = _opp_set_required_dev(opp_table, dev, + config->required_dev, + config->required_dev_index); if (ret) goto err; - data->flags |= OPP_CONFIG_REQUIRED_DEVS; + data->index = config->required_dev_index; + data->flags |= OPP_CONFIG_REQUIRED_DEV; } ret = xa_alloc(&opp_configs, &id, data, XA_LIMIT(1, INT_MAX), diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index cff1fabd1ae3..5b5a4bd89c9e 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -35,12 +35,13 @@ extern struct list_head opp_tables; #define OPP_CONFIG_PROP_NAME BIT(3) #define OPP_CONFIG_SUPPORTED_HW BIT(4) #define OPP_CONFIG_GENPD BIT(5) -#define OPP_CONFIG_REQUIRED_DEVS BIT(6) +#define OPP_CONFIG_REQUIRED_DEV BIT(6) /** * struct opp_config_data - data for set config operations * @opp_table: OPP table * @flags: OPP config flags + * @index: The position in the array of required_devs * * This structure stores the OPP config information for each OPP table * configuration by the callers. @@ -48,6 +49,7 @@ extern struct list_head opp_tables; struct opp_config_data { struct opp_table *opp_table; unsigned int flags; + unsigned int index; }; /** diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 6424692c30b7..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 genpd to - * attach. Mutually exclusive with required_devs. + * attach. Mutually exclusive with required_dev. * @virt_devs: Pointer to return the array of genpd virtual devices. Mutually - * exclusive with required_devs. - * @required_devs: Required OPP devices. Mutually exclusive with genpd_names/virt_devs. + * exclusive with required_dev. + * @required_dev: Required OPP device. Mutually exclusive with genpd_names/virt_devs. + * @required_dev_index: The index of the required OPP for the @required_dev. * * This structure contains platform specific OPP configurations for the device. */ @@ -81,7 +82,8 @@ struct dev_pm_opp_config { const char * const *regulator_names; const char * const *genpd_names; struct device ***virt_devs; - struct device **required_devs; + struct device *required_dev; + unsigned int required_dev_index; }; #define OPP_LEVEL_UNSET U32_MAX From patchwork Wed Oct 2 12:22:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13819740 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 553FB1D0407 for ; Wed, 2 Oct 2024 12:22:49 +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=1727871771; cv=none; b=nXHcutXj0CpqJvoQqsRx6ytR88sm8dz9aEqECNoHZx4mEGm+nJvgaDromk0qtN2l0RGVlhO0Nh2vV9d9+pD3P47TicMfXc7Xe0OE1stI3u+r/f3Xw5chs6uCiO4MpOiKZcOOieQHTtD1AwKtCIR0x7UUU59P4dMIrHtTo80jztM= 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.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="Qo1oX2nh" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-5366fd6fdf1so8134534e87.0 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=NhqqE9qZ6m05yMhG0l5UKUQylfq+LoRXAkruUKJY2vmDi76tpUFoUe2ws7Av7v+bmt 9lTLBSHX35o5ZqvsNCHsndWkxGJJ7I8x6JuIsEmWaOOoe5CGt5t4FH/2/fW5VjALT2eI BFB+FsoBpi4iG3qyfBkd7yoMYhW2HI8FVzEFHru0eq8fJ3TqxXkcU0Cq+ht//tFJlgRD 6G7WVgeGoUds50FYReQkrExRJsDCFxHWvapjNLvi80h7ncF1+ahOeXDGKMjPGE7wyBKU KSsRiCN6z8ZLc/Lx/ijVjwHzFkJoFXiGReyjfm+RSdiK7AeQr6RVC//CQsDultnyV+NW pO8g== X-Forwarded-Encrypted: i=1; AJvYcCWX79XpxG+sY8u2gwIr9f1bCJodiLzJT/xkH+Dq46qQg9zD9PL9+D76X7sVxanfayNewwq2PlCTUA==@vger.kernel.org X-Gm-Message-State: AOJu0Yz9Yd1Snp641orlwihMDp2NBGHtOeUVxlhOWfO8po7NqYoj08i5 NcnsF89SiEBb7NADgQUwi5kztjGbpLnsP2Hf0MbP7BGO2a5mMDz9saHRBhZAiTcIr35ANdGfGnO p 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 #include "power.h" @@ -222,13 +223,15 @@ int dev_pm_domain_attach_list(struct device *dev, if (!pds) return -ENOMEM; - size = sizeof(*pds->pd_devs) + sizeof(*pds->pd_links); + size = sizeof(*pds->pd_devs) + sizeof(*pds->pd_links) + + sizeof(*pds->opp_tokens); pds->pd_devs = kcalloc(num_pds, size, GFP_KERNEL); if (!pds->pd_devs) { ret = -ENOMEM; goto free_pds; } pds->pd_links = (void *)(pds->pd_devs + num_pds); + pds->opp_tokens = (void *)(pds->pd_links + num_pds); if (link_flags && pd_flags & PD_FLAG_DEV_LINK_ON) link_flags |= DL_FLAG_RPM_ACTIVE; @@ -244,6 +247,19 @@ int dev_pm_domain_attach_list(struct device *dev, goto err_attach; } + if (pd_flags & PD_FLAG_REQUIRED_OPP) { + struct dev_pm_opp_config config = { + .required_dev = pd_dev, + .required_dev_index = i, + }; + + ret = dev_pm_opp_set_config(dev, &config); + if (ret < 0) + goto err_link; + + pds->opp_tokens[i] = ret; + } + if (link_flags) { struct device_link *link; @@ -264,9 +280,11 @@ int dev_pm_domain_attach_list(struct device *dev, return num_pds; err_link: + dev_pm_opp_clear_config(pds->opp_tokens[i]); dev_pm_domain_detach(pd_dev, true); err_attach: while (--i >= 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_list *list) return; for (i = 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) 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; }; From patchwork Wed Oct 2 12:22:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13819741 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 2F21D1D0428 for ; Wed, 2 Oct 2024 12:22:52 +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=1727871775; cv=none; b=S8wRukSHp9ZW5y5iVkMMSZf53KKF4h66YU8rGstxpin0gyGhpCFDkwhniOgUWpRyCiDFhPK/jxS/uMhWKgnQXBNHeYgN/Lq0d6Tk3NEjpHtw7vicbN7REAjcFBs7ZUBx4a8Qc+vmE97kK1ofVWMxmpf3kh5N+gZx6xZtWThCCDQ= 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.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="iCop0QB/" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-5366fd6fdf1so8134644e87.0 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=D2A3S9oUsu+wRgh3CHk7OKshtiWdRXGE588Al22WbRZEfwrJKs3gTJo9SDf/Bz7GCb 6XWXT7hBKeRrc5Iv9sofH5cyf3aIsV4X6C/kUc786QOa3YG8/psPv5RMAlgTb7nOcw2R NIqeVGDtCj7edCkIZPMpQ8V03Mu/shN2Im2R94Z4tI5SJ9ygDaDqhgQUX+Tty2nLFCyV N6rPiIvlYEJsEY/cD9+bUfXy+0JT1t0QlaerzJEwzStAw4MidFHR3E+H80Y8i4Ko6dSo UO5tZQ2D/z68MlAbgWLBhY9XAfw00VBPFq4d5u3glX4eU6tEIR1ZH0INIFfTvVtaHm/U ipmg== X-Forwarded-Encrypted: i=1; AJvYcCWMeMVLf0UOqr8hi2rL4gML7l/9jO6JHvo1lzeMl6AQp9tDSxHOYx6VkWOPytsDWsKnVH5PiDrBjA==@vger.kernel.org X-Gm-Message-State: AOJu0Yyo/EPOE55p5e+umNgHKHRExO5vn3Bq0OZLpnlf96av1336mlvq hnLGAuZB1CdEti+3fP07SYg+5O1cz7lPomXDoUS4Vdi0wOcdvZw2DccReDkUHzI= 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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); } +static int genpd_set_required_opp(struct device *dev, unsigned int index) +{ + int ret, pstate; + + /* Set the default performance state */ + pstate = of_get_required_opp_performance_state(dev->of_node, index); + if (pstate < 0 && pstate != -ENODEV && pstate != -EOPNOTSUPP) { + ret = pstate; + goto err; + } else if (pstate > 0) { + ret = dev_pm_genpd_set_performance_state(dev, pstate); + if (ret) + goto err; + dev_gpd_data(dev)->default_pstate = pstate; + } + + return 0; +err: + dev_err(dev, "failed to set required performance state for power-domain %s: %d\n", + dev_to_genpd(dev)->name, ret); + return ret; +} + static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, unsigned int index, bool power_on) { struct of_phandle_args pd_args; struct generic_pm_domain *pd; - int pstate; int ret; ret = of_parse_phandle_with_args(dev->of_node, "power-domains", @@ -2918,17 +2940,9 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, dev->pm_domain->detach = genpd_dev_pm_detach; dev->pm_domain->sync = genpd_dev_pm_sync; - /* Set the default performance state */ - pstate = of_get_required_opp_performance_state(dev->of_node, index); - if (pstate < 0 && pstate != -ENODEV && pstate != -EOPNOTSUPP) { - ret = pstate; + ret = genpd_set_required_opp(dev, index); + if (ret) goto err; - } else if (pstate > 0) { - ret = dev_pm_genpd_set_performance_state(dev, pstate); - if (ret) - goto err; - dev_gpd_data(dev)->default_pstate = pstate; - } if (power_on) { genpd_lock(pd); @@ -2950,8 +2964,6 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, return 1; err: - dev_err(dev, "failed to set required performance state for power-domain %s: %d\n", - pd->name, ret); genpd_remove_device(pd, dev); return ret; } From patchwork Wed Oct 2 12:22:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13819742 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (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 786D71D04A4 for ; Wed, 2 Oct 2024 12:22:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871776; cv=none; b=qqwS86YktgCqwG7vYfLVnEcNEAu0DKrQA9wybj3VwM1w0pvOt6iG6IfQGpjjaReF/KX2i9dozoRR+w/AkGDi76yDwLDtq4Ngi50Zoql3c8egslKLz/oI+PlEFG4CEkrQ3KSMbccPadNDWMEZSxs6bjXhRmju2pZpRdjOmdU2zpc= 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=Z/I9Gyhg; arc=none smtp.client-ip=209.85.167.54 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="Z/I9Gyhg" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-53994aadb66so3567297e87.2 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=1727871773; x=1728476573; 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=Z/I9GyhgH57hvQGIgdnppdXlky7T648DcU+Oo/f8jp5Rgk+NYhgtN8Aa/DwtjvhqZN SqerbU2yrl0lCym4NaIDXnNgOHRMyMu7lmIj80gAKMkjwIiIvI35NyCwxdZedRP4+rHi bzmoVUwFHK+FKR1XtTB3Z+PedQQB3sD10T/H6Z0UqcBtnhNpKp/et8Rcbtc+FIrhL2Ub No5PH9s3brRtzFxCcTn0DLVXn05uJu349B0z1PocxIRS4BuzkFMYRmx9+4xtZQ94lpX8 oJzRehEM33c7YEDix898RrXfwL3agPpvGvnaQ5wF/djwhAouev5roomPN1UAOJzAOJPx d/bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727871773; x=1728476573; 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=cqwAh6xMrSqQeYknoEJjC430yYTjvaHwEYJtpQevPt0f4MUsirJriZd2VJ5wFjETOk dMr/oXU1EhUiUDvWWL05XvcoPqOLYnOPGlcvSQEIjZc8b2bjUWKtfPGIHeYecATtq8gi sfoOvZKX4RtouTCvrUlvWmF+UPmDzoDEYqSJAdEMUu3q0zo23gEQQpGKJjiemwTVbSvy iWQpkPXNXvy4XaNe6h7vGwLkGa1rGdJUKnD9NFKKDq29JzbgQguUBZsRaxI+8vyRwVRD pB+yDfHPSaQiCqt8qtgqnZdyrpPGqsW/VV0S0aczlCfzBsn7xMf0DJPnOLRsNDc8916a E2Yw== X-Forwarded-Encrypted: i=1; AJvYcCVFfvJ4fF94gdDS5/XCfJKCzu2H4DsHxH+nSR34Fun7+HCFpbdzmq1spS3Yb7O953h9pWk4xPp8Qw==@vger.kernel.org X-Gm-Message-State: AOJu0Yyv1+ZLRZi1SrGvA2bInYUg971/xwNTKB6B/h7qAUGWig3GanEh wKFsdPCuDCrsfJz+BbIkjNrSsU0IL7m35OEe3YjZzWyKb1wAuL5BddUFCViTEWc= 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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, spin_unlock_irq(&dev->power.lock); + 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); } +static int genpd_set_required_opp_dev(struct device *dev, + struct device *base_dev) +{ + struct dev_pm_opp_config config = { + .required_dev = 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 = dev_pm_opp_set_config(base_dev, &config); + if (ret < 0) + return ret; + + dev_gpd_data(dev)->opp_token = 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) } static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, - 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 = genpd_dev_pm_detach; dev->pm_domain->sync = genpd_dev_pm_sync; + /* + * 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 == 1) { + ret = genpd_set_required_opp_dev(dev, base_dev); + if (ret) + goto err; + } + ret = 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") != 1) return 0; - 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); @@ -3047,7 +3083,7 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, } /* Try to attach the device to the PM domain at the specified index. */ - ret = __genpd_dev_pm_attach(virt_dev, dev, index, false); + ret = __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; }; From patchwork Wed Oct 2 12:22:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13819743 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (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 BA5641D0797 for ; Wed, 2 Oct 2024 12:22:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871778; cv=none; b=I8CVPR9wj3I6ujAs/y24PWJu/rJiZRw7h5w913paFdC9tp6UBV/rbxCed8VUZktpYexIhEqx2ihoSHopZ0wIO15Pf/tbWvaAfDKWneKKeDdj62jLLvU+f5x3zeXqru89gS/cA8AdnB7SdxZMBhoRyCdGjoqCR10H+4nH2lMRbas= 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.50 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-f50.google.com with SMTP id 2adb3069b0e04-5398e53ca28so4351422e87.3 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=o0AY6bAohb0D3I90TlvKe7jEjJPAFSPcMjO3o4gWDfWkS+zh5m+cdUnhh0rWG+zqIe bLkALgudow2Wkx0/dUxpFTgBEm1agZY5lF0cBo8ZdwGcLwbC5poFHs3xEHPuWzz3uR5C OYNgdd4ABMGHIH+m7jcjw6pkOk2BBUJm+adnVN5mfe2PKDXK+2exJuSE59u4tzxMA6j4 5ab6AXv47H2/Syr2eSzUTMMQUVSCvkrtPToIkE+mj1erYLBSSFPp7Rttm5LqTglvvVIC prQsFw17+7R8wSYAyf3nkVG933GH8OSQPeBDrKbYPpF2QVAG6mrTHNAcr0e72RmwVXQb +wqw== X-Forwarded-Encrypted: i=1; AJvYcCXN3xJ5/meh8vPM459p6ip/iqamkBz62PHHoKrqRORih0+EIc7qcjVx9IiGaEPfsajJ4X24N0nvyw==@vger.kernel.org X-Gm-Message-State: AOJu0Yxakw1GcehFtHGLEPxOqL310g98I46NR57vPDz1BVeCxcs9ipYZ H0+YYEzdD7BBRnCAirZiL6mib5gkmV1kmtn8OKmRIZC+UxE8/dgLP8rEyp3RSPg= 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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); } -static int _link_required_opps(struct dev_pm_opp *opp, struct opp_table *opp_table, +static int _link_required_opps(struct dev_pm_opp *opp, struct opp_table *required_table, int index) { struct device_node *np; @@ -313,39 +313,6 @@ static int _link_required_opps(struct dev_pm_opp *opp, struct opp_table *opp_tab return -ENODEV; } - /* - * There are two genpd (as required-opp) cases that we need to handle, - * devices with a single genpd and ones with multiple genpds. - * - * The single genpd case requires special handling as we need to use the - * same `dev` structure (instead of a virtual one provided by genpd - * core) for setting the performance state. - * - * It doesn't make sense for a device's DT entry to have both - * "opp-level" and single "required-opps" entry pointing to a genpd's - * OPP, as that would make the OPP core call - * dev_pm_domain_set_performance_state() for two different values for - * the same device structure. Lets treat single genpd configuration as a - * case where the OPP's level is directly available without required-opp - * link in the DT. - * - * Just update the `level` with the right value, which - * dev_pm_opp_set_opp() will take care of in the normal path itself. - * - * There is another case though, where a genpd's OPP table has - * required-opps set to a parent genpd. The OPP core expects the user to - * set the respective required `struct device` pointer via - * dev_pm_opp_set_config(). - */ - if (required_table->is_genpd && opp_table->required_opp_count == 1 && - !opp_table->required_devs[0]) { - /* Genpd core takes care of propagation to parent genpd */ - if (!opp_table->is_genpd) { - if (!WARN_ON(opp->level != OPP_LEVEL_UNSET)) - opp->level = opp->required_opps[0]->level; - } - } - return 0; } @@ -370,7 +337,7 @@ static int _of_opp_alloc_required_opps(struct opp_table *opp_table, if (IS_ERR_OR_NULL(required_table)) continue; - ret = _link_required_opps(opp, opp_table, required_table, i); + ret = _link_required_opps(opp, required_table, i); if (ret) goto free_required_opps; } @@ -391,7 +358,7 @@ static int lazy_link_required_opps(struct opp_table *opp_table, int ret; list_for_each_entry(opp, &opp_table->opp_list, node) { - ret = _link_required_opps(opp, opp_table, new_table, index); + ret = _link_required_opps(opp, new_table, index); if (ret) return ret; } From patchwork Wed Oct 2 12:22:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13819744 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 EA9361D0797 for ; Wed, 2 Oct 2024 12:22:58 +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=1727871780; cv=none; b=udvpK7BsRTHfg2+2ThnYBS6zpCpJI/qPVDdoNy0QtCB1cx+QzFD4UNWuKVPZ6mvpPBT4D50RiZCR5ugjs6gNjhk4Mc4zZarppm0ZAdF0vAD2Hk0GEJJDFUgyUwfziueEMNvZefYYJ6T+rESjmyxm10QZacohFrhppg9BSmfEI1I= 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.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="uz5UTbpL" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-5398d171fa2so4392591e87.0 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=gaiXAfQUtbC2arjOitTa5cM0KPTebcQlwyKdrJK0olwFiyUhsmD6VBBOFtxGA5zor5 b7K78EIQCywdjKK08/4etSIusZD0Yk+UiyJS8nUNEwOTOvp9q6nLaD4W96hVUysuWUfH W2QgSHzDEZOiR9OvivTm4/TShL5XNKGxWLWrP1V+wI2w9o8viCH3POfXJ71oMmmfCCQs ZbQYdMz3ixZfntiJ6V1noXF+ImlEzbca/b/JxAccQyg/0HK4cN8F3SGLFVmbsBK6ZU6n Jbr3xHlf3nAIb+9WTv9iV/wZWKgz4iA403qiZfJbotaG7ZlJILEcNGdeGkqIuihKpZj7 qwCA== X-Forwarded-Encrypted: i=1; AJvYcCW0Kt87h7f9TcPSAhcMHE8usluT3kMJYrhRo0/EkFxkJyq5/cYC7dgiSvj8bBB42ZAMK+h4s2zsow==@vger.kernel.org X-Gm-Message-State: AOJu0YzdDIOLp/NYEb8VeWda9vpDL5vwnrTeEHuuMjQkmRimLScQXMja bKLsQUcNr9ihgJgl8+ZPeXAatn9kGfAVVY4hh7k3ktoQ7RuJUzXbPWmHfvoBGhg= 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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; 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; } -static void gr3d_del_link(void *link) -{ - device_link_del(link); -} - static int gr3d_init_power(struct device *dev, struct gr3d *gr3d) { - static const char * const opp_genpd_names[] = { "3d0", "3d1", NULL }; - const u32 link_flags = DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME; - struct device **opp_virt_devs, *pd_dev; - struct device_link *link; - unsigned int i; + struct dev_pm_domain_attach_data pd_data = { + .pd_names = (const char *[]) { "3d0", "3d1" }, + .num_pd_names = 2, + .pd_flags = PD_FLAG_REQUIRED_OPP, + }; int err; err = 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; - err = devm_pm_opp_attach_genpd(dev, opp_genpd_names, &opp_virt_devs); - if (err) + err = devm_pm_domain_attach_list(dev, &pd_data, &gr3d->pd_list); + if (err < 0) return err; - for (i = 0; opp_genpd_names[i]; i++) { - pd_dev = opp_virt_devs[i]; - if (!pd_dev) { - dev_err(dev, "failed to get %s power domain\n", - opp_genpd_names[i]); - return -EINVAL; - } - - link = device_link_add(dev, pd_dev, link_flags); - if (!link) { - dev_err(dev, "failed to link to %s\n", dev_name(pd_dev)); - return -EINVAL; - } - - err = devm_add_action_or_reset(dev, gr3d_del_link, link); - if (err) - return err; - } - return 0; } From patchwork Wed Oct 2 12:22:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13819745 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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 9ACD61D0955 for ; Wed, 2 Oct 2024 12:23:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871782; cv=none; b=Z1MmnSNxkFZCMRhNHQzLWBlpbY8BCpEkm6nJYRS/msRQQfDGeS2xXhZGsKu33dZ4gHk5BYpgYZeifSjFtbsA89HsBxgpbxUM/7LpuWKGYFqJtNiq5OrfNSfILMkQVhwBlEb20cGzwnO5R3yiiG7pbREUt4aImcTiOR3SyLr3Bik= 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.51 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-f51.google.com with SMTP id 2adb3069b0e04-53993564cb1so4090858e87.2 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=ujwHWhHsGm6Ld2LcMQN7YCrY0mv2GdjKUo0Ko5znkZKCW05U8SZi0SU++LLzpR4Cfd /aqAuv4wVBK5nBoLFQ4/PQOw3BEZoM0y8Eo/MLvSZnWne9VqfC7NrNCgAkyAXbEB/A22 96BL25IwqDB9tOlCPgMoUhz3y35CRTpT6YohyqJt5rcTTlvTDS7ahcIHfijHLguZo+Bt /NhjSreAHjzNzO+ZrNgFJYrSgpHzh1XKSBAXCWYmVXg4aaJikkBZTVT4+GmBWumKI7om 9ec8/hWhyrO6Huz6gBEJor+hxMHx6DLD6Bcx2mzaUE8CHrXGXDso+GCXk8KISwP8gYDq 7phA== X-Forwarded-Encrypted: i=1; AJvYcCUSXmv0hNGFSL83L4XAd2m8QFddxLshCA0y4tlHozrNRjkx8kMGG8ebtKQI0+pYEPptKC2QDsiB2Q==@vger.kernel.org X-Gm-Message-State: AOJu0Yw6YwgjUtKWG/VFG4NOYmcRA2KOZq9IaYIlImGmLRqHhtnYPjeG HluZlI7IelhdiVRKT+rXwBuxWcIH0gXMnRUK1RvkPtkh4YqDy06M+haMx3m3IQQ= 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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/platform/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 = { .vcodec_clks_num = 2, .vcodec_pmdomains = (const char *[]) { "venus", "vcodec0", "vcodec1" }, .vcodec_pmdomains_num = 3, - .opp_pmdomain = (const char *[]) { "cx", NULL }, + .opp_pmdomain = (const char *[]) { "cx" }, .vcodec_num = 2, .max_load = 3110400, /* 4096x2160@90 */ .hfi_version = HFI_VERSION_4XX, @@ -801,7 +801,7 @@ static const struct venus_resources sc7180_res = { .vcodec_clks_num = 2, .vcodec_pmdomains = (const char *[]) { "venus", "vcodec0" }, .vcodec_pmdomains_num = 2, - .opp_pmdomain = (const char *[]) { "cx", NULL }, + .opp_pmdomain = (const char *[]) { "cx" }, .vcodec_num = 1, .hfi_version = HFI_VERSION_4XX, .vpu_version = VPU_VERSION_AR50, @@ -858,7 +858,7 @@ static const struct venus_resources sm8250_res = { .vcodec_clks_num = 1, .vcodec_pmdomains = (const char *[]) { "venus", "vcodec0" }, .vcodec_pmdomains_num = 2, - .opp_pmdomain = (const char *[]) { "mx", NULL }, + .opp_pmdomain = (const char *[]) { "mx" }, .vcodec_num = 1, .max_load = 7833600, .hfi_version = HFI_VERSION_6XX, @@ -917,7 +917,7 @@ static const struct venus_resources sc7280_res = { .vcodec_clks_num = 2, .vcodec_pmdomains = (const char *[]) { "venus", "vcodec0" }, .vcodec_pmdomains_num = 2, - .opp_pmdomain = (const char *[]) { "cx", NULL }, + .opp_pmdomain = (const char *[]) { "cx" }, .vcodec_num = 1, .hfi_version = HFI_VERSION_6XX, .vpu_version = VPU_VERSION_IRIS2_1, diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 55202b89e1b9..435325432922 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -132,9 +132,7 @@ struct venus_format { * @vcodec1_clks: an array of vcodec1 struct clk pointers * @video_path: an interconnect handle to video to/from memory path * @cpucfg_path: an interconnect handle to cpu configuration path - * @has_opp_table: does OPP table exist * @pmdomains: a pointer to a list of pmdomains - * @opp_dl_venus: an device-link for device OPP * @opp_pmdomain: an OPP power-domain * @resets: an array of reset signals * @vdev_dec: a reference to video device structure for decoder instances @@ -186,10 +184,8 @@ struct venus_core { struct clk *vcodec1_clks[VIDC_VCODEC_CLKS_NUM_MAX]; struct icc_path *video_path; struct icc_path *cpucfg_path; - bool has_opp_table; struct dev_pm_domain_list *pmdomains; - struct device_link *opp_dl_venus; - struct device *opp_pmdomain; + struct dev_pm_domain_list *opp_pmdomain; struct reset_control *resets[VIDC_RESETS_NUM_MAX]; struct video_device *vdev_dec; struct video_device *vdev_enc; diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c index ea8a2bd9419e..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 = core->dev; const struct venus_resources *res = core->res; struct dev_pm_domain_attach_data vcodec_data = { @@ -872,6 +871,11 @@ static int vcodec_domains_get(struct venus_core *core) .num_pd_names = res->vcodec_pmdomains_num, .pd_flags = PD_FLAG_NO_DEV_LINK, }; + struct dev_pm_domain_attach_data opp_pd_data = { + .pd_names = res->opp_pmdomain, + .num_pd_names = 1, + .pd_flags = PD_FLAG_DEV_LINK_ON | PD_FLAG_REQUIRED_OPP, + }; if (!res->vcodec_pmdomains_num) goto skip_pmdomains; @@ -881,37 +885,15 @@ static int vcodec_domains_get(struct venus_core *core) return ret; skip_pmdomains: - if (!core->res->opp_pmdomain) + if (!res->opp_pmdomain) return 0; /* Attach the power domain for setting performance state */ - ret = devm_pm_opp_attach_genpd(dev, res->opp_pmdomain, &opp_virt_dev); - if (ret) - goto opp_attach_err; - - core->opp_pmdomain = *opp_virt_dev; - core->opp_dl_venus = device_link_add(dev, core->opp_pmdomain, - DL_FLAG_RPM_ACTIVE | - DL_FLAG_PM_RUNTIME | - DL_FLAG_STATELESS); - if (!core->opp_dl_venus) { - ret = -ENODEV; - goto opp_attach_err; - } + ret = devm_pm_domain_attach_list(dev, &opp_pd_data, &core->opp_pmdomain); + if (ret < 0) + return ret; return 0; - -opp_attach_err: - return ret; -} - -static void vcodec_domains_put(struct venus_core *core) -{ - if (!core->has_opp_table) - return; - - if (core->opp_dl_venus) - device_link_del(core->opp_dl_venus); } static int core_resets_reset(struct venus_core *core) @@ -1000,9 +982,7 @@ static int core_get_v4(struct venus_core *core) if (core->res->opp_pmdomain) { ret = devm_pm_opp_of_add_table(dev); - if (!ret) { - core->has_opp_table = true; - } else if (ret != -ENODEV) { + if (ret && ret != -ENODEV) { dev_err(dev, "invalid OPP table in device tree\n"); return ret; } @@ -1013,10 +993,6 @@ static int core_get_v4(struct venus_core *core) static void core_put_v4(struct venus_core *core) { - if (legacy_binding) - return; - - vcodec_domains_put(core); } static int core_power_v4(struct venus_core *core, int on) From patchwork Wed Oct 2 12:22:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13819746 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 5689C1D0975 for ; Wed, 2 Oct 2024 12:23:02 +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=1727871784; cv=none; b=CT10TcC6yeM+rEJqNh8dXTGeenyDe7VRCoVCn73D3We12oyGraQh2Muld6dA9MHPiR8AeoLvLq2tKE5vYdSc/dbtGWGhihsT2EzxbemllyMqiOEKikNTQvCBiCJl9eOAwqb2h/S5nIT8vfOwZAz55MwFyGLH/SDv3GdQ2DaHnhw= 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.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="l0NoTj8e" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-5398b2f43b9so708103e87.1 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=Xd3P+LFdyS5lHZmNvCcuqd05oJv9K2FD3C/yWFD6DUZvNCE0s8FBhhmNN6hSH3A06p ZeBdhflqcYKXHDv9ryw/1YgSHVbqObx+QmrhwwjfOnTupnGI3eZ9F2ZusSNHs3m3nNFy 2fhK35sXItTl/TXOYb4qZKD4mvEe28CEs3Vm7zKzZlE/i5s8p/4EnVWRTjEarbWMrjC0 1aXokhapmuaGzGXDyes0mBj3qWac9qPTe7L18Y+w1PvLgQPOqyAxg7iSQg7qGbs0TIbd HLzY3z+6JjBT7pniK1CnFnj4OTNcsnJaEms1qw3bk0TbHHZjD9Ry4U2SkBihGj2gPu0L fOMA== X-Forwarded-Encrypted: i=1; AJvYcCUbY4FSCJJxIjVHGyROjToL10YBqXkNERVWgANie/q5cym2p2i+UBpPPyQFH+7Bb3vL/5hB2D9fPw==@vger.kernel.org X-Gm-Message-State: AOJu0Yw6hpidVlSzmq4w6D6FC8bPXaYfqzqn6gmm60wM7T7bJQPN5Xk5 WfkbUfFdfDY+cp24E0+TL1IMfsZ0RLrRccKPW6D83GA+AzDPt1SDbfZKvv/vDLI= 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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-cpufreq-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; }; struct qcom_cpufreq_drv_cpu { int opp_token; - struct device **virt_devs; + struct dev_pm_domain_list *pd_list; }; struct qcom_cpufreq_drv { @@ -395,8 +396,6 @@ static int qcom_cpufreq_ipq8074_name_version(struct device *cpu_dev, return 0; } -static const char *generic_genpd_names[] = { "perf", NULL }; - static const struct qcom_cpufreq_match_data match_data_kryo = { .get_version = qcom_cpufreq_kryo_name_version, }; @@ -407,13 +406,13 @@ static const struct qcom_cpufreq_match_data match_data_krait = { static const struct qcom_cpufreq_match_data match_data_msm8909 = { .get_version = qcom_cpufreq_simple_get_version, - .genpd_names = generic_genpd_names, + .pd_names = (const char *[]) { "perf" }, + .num_pd_names = 1, }; -static const char *qcs404_genpd_names[] = { "cpr", NULL }; - static const struct qcom_cpufreq_match_data match_data_qcs404 = { - .genpd_names = qcs404_genpd_names, + .pd_names = (const char *[]) { "cpr" }, + .num_pd_names = 1, }; static const struct qcom_cpufreq_match_data match_data_ipq6018 = { @@ -428,28 +427,16 @@ static const struct qcom_cpufreq_match_data match_data_ipq8074 = { .get_version = qcom_cpufreq_ipq8074_name_version, }; -static void qcom_cpufreq_suspend_virt_devs(struct qcom_cpufreq_drv *drv, unsigned int cpu) -{ - const char * const *name = drv->data->genpd_names; - int i; - - if (!drv->cpus[cpu].virt_devs) - return; - - for (i = 0; *name; i++, name++) - device_set_awake_path(drv->cpus[cpu].virt_devs[i]); -} - -static void qcom_cpufreq_put_virt_devs(struct qcom_cpufreq_drv *drv, unsigned int cpu) +static void qcom_cpufreq_suspend_pd_devs(struct qcom_cpufreq_drv *drv, unsigned int cpu) { - const char * const *name = drv->data->genpd_names; + struct dev_pm_domain_list *pd_list = drv->cpus[cpu].pd_list; int i; - if (!drv->cpus[cpu].virt_devs) + if (!pd_list) return; - for (i = 0; *name; i++, name++) - pm_runtime_put(drv->cpus[cpu].virt_devs[i]); + for (i = 0; i < pd_list->num_pds; i++) + device_set_awake_path(pd_list->pd_devs[i]); } static int qcom_cpufreq_probe(struct platform_device *pdev) @@ -503,7 +490,6 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) } for_each_possible_cpu(cpu) { - struct device **virt_devs = NULL; struct dev_pm_opp_config config = { .supported_hw = NULL, }; @@ -522,12 +508,7 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) config.prop_name = pvs_name; } - if (drv->data->genpd_names) { - config.genpd_names = drv->data->genpd_names; - config.virt_devs = &virt_devs; - } - - if (config.supported_hw || config.genpd_names) { + if (config.supported_hw) { drv->cpus[cpu].opp_token = dev_pm_opp_set_config(cpu_dev, &config); if (drv->cpus[cpu].opp_token < 0) { ret = drv->cpus[cpu].opp_token; @@ -536,25 +517,18 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) } } - if (virt_devs) { - const char * const *name = config.genpd_names; - int i, j; - - for (i = 0; *name; i++, name++) { - ret = pm_runtime_resume_and_get(virt_devs[i]); - if (ret) { - dev_err(cpu_dev, "failed to resume %s: %d\n", - *name, ret); - - /* Rollback previous PM runtime calls */ - name = config.genpd_names; - for (j = 0; *name && j < i; j++, name++) - pm_runtime_put(virt_devs[j]); - - goto free_opp; - } - } - drv->cpus[cpu].virt_devs = virt_devs; + if (drv->data->pd_names) { + struct dev_pm_domain_attach_data attach_data = { + .pd_names = drv->data->pd_names, + .num_pd_names = drv->data->num_pd_names, + .pd_flags = PD_FLAG_DEV_LINK_ON | + PD_FLAG_REQUIRED_OPP, + }; + + ret = dev_pm_domain_attach_list(cpu_dev, &attach_data, + &drv->cpus[cpu].pd_list); + if (ret < 0) + goto free_opp; } } @@ -570,7 +544,7 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) free_opp: for_each_possible_cpu(cpu) { - qcom_cpufreq_put_virt_devs(drv, cpu); + dev_pm_domain_detach_list(drv->cpus[cpu].pd_list); dev_pm_opp_clear_config(drv->cpus[cpu].opp_token); } return ret; @@ -584,7 +558,7 @@ static void qcom_cpufreq_remove(struct platform_device *pdev) platform_device_unregister(cpufreq_dt_pdev); for_each_possible_cpu(cpu) { - qcom_cpufreq_put_virt_devs(drv, cpu); + dev_pm_domain_detach_list(drv->cpus[cpu].pd_list); dev_pm_opp_clear_config(drv->cpus[cpu].opp_token); } } @@ -595,7 +569,7 @@ static int qcom_cpufreq_suspend(struct device *dev) unsigned int cpu; for_each_possible_cpu(cpu) - qcom_cpufreq_suspend_virt_devs(drv, cpu); + qcom_cpufreq_suspend_pd_devs(drv, cpu); return 0; } From patchwork Wed Oct 2 12:22:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13819747 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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 1D8D61D0B9B for ; Wed, 2 Oct 2024 12:23:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871786; cv=none; b=dCF4P57MGB5sSi3iSokd/E/i0PwMkPmwcBxMa8WdFDr//hYDylmpn1PJo73GioVDhutNPiELYwpYTi4T9ppi/Gm11Ffp0j5WwJUiZUOIaHqhNW2T75P83Mpbo5RWLbCz36b5wokljuQ7Z87PfXfzEJHOrYT9J9M9QXufME3XYIQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727871786; c=relaxed/simple; bh=B+cxcgnBoCbaeNr/2/pJBjD+nouj1vfJ4FbwWfvcU8U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f9+R/vhAjGnxqQ8JE/RvtESq5uGxHDRRiZaW9+EXTuLV7Vl6mZl57CtuDEyGAEsd1h/fJP8mm02PlxK139FyxQ4p04GNSw6tFhVYIjGBPFzzAMNv2Fs5DBPGv8pQT8cKei89Pfl8lsVoGnh7sHapFb96DkEPrL6l6afpX1Zlr0s= 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.167.51 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-lf1-f51.google.com with SMTP id 2adb3069b0e04-53993c115cfso4202406e87.2 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=FGo3MEnbuP6o9qHnTLWZi6D1Bs1jES/X4BiyWrmO57qyTVyc11Au+hJB9PUpBLKlCP 7scqVs7jGtys8/ZNR7Bb4izDGhVGTFItTTOrX1xW2kWRKh8argWkzuJgSkyRc5Q+1oE3 NgoLNHiaZ6fwpIGkm9um3zG1BOLSPQ+Z4MtYJEaehHYQLxfl9YCcznC0VUi51TxS4QRC i6jcuqj0/CZ67Xy3efiy6l6INXCc7jnKMXApy+XTip91mCGSg9gbOH8tM++A14dfv/lE mR6+BTuy8sDUPgykt8XJANGZp0X7vcm4m3eVfRJK5vbe/f0XHGUYHbBVp3MbOepgzk/I yx5Q== X-Forwarded-Encrypted: i=1; AJvYcCWDLOlcbn18/U7SxlUz6GXW08g/NmejMPkRnxZFV+6pEXa78u+rH1uiNbX5Ue6XIwDVyfyEB8xGDw==@vger.kernel.org X-Gm-Message-State: AOJu0YyLtNeEss/CIdATu2U3pFzCFrSLqM0GpgAOFugb3DkGzoKjz0nH FZvJr1arbKHu6Ii4qWuQdBhonEGCRZIy5ttbHBWBhePXVNm0wvmhajR4S8mUEVE= 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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(struct opp_table *opp_table) opp_table->config_regulators = NULL; } -static void _opp_detach_genpd(struct opp_table *opp_table) -{ - int index; - - for (index = 0; index < opp_table->required_opp_count; index++) { - if (!opp_table->required_devs[index]) - continue; - - dev_pm_domain_detach(opp_table->required_devs[index], false); - opp_table->required_devs[index] = NULL; - } -} - -/* - * Multiple generic power domains for a device are supported with the help of - * virtual genpd devices, which are created for each consumer device - genpd - * pair. These are the device structures which are attached to the power domain - * and are required by the OPP core to set the performance state of the genpd. - * The same API also works for the case where single genpd is available and so - * we don't need to support that separately. - * - * This helper will normally be called by the consumer driver of the device - * "dev", as only that has details of the genpd names. - * - * This helper needs to be called once with a list of all genpd to attach. - * Otherwise the original device structure will be used instead by the OPP core. - * - * The order of entries in the names array must match the order in which - * "required-opps" are added in DT. - */ -static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, - const char * const *names, struct device ***virt_devs) -{ - struct device *virt_dev, *gdev; - struct opp_table *genpd_table; - int index = 0, ret = -EINVAL; - const char * const *name = names; - - if (!opp_table->required_devs) { - dev_err(dev, "Required OPPs not available, can't attach genpd\n"); - return -EINVAL; - } - - /* Genpd core takes care of propagation to parent genpd */ - if (opp_table->is_genpd) { - dev_err(dev, "%s: Operation not supported for genpds\n", __func__); - return -EOPNOTSUPP; - } - - /* Checking only the first one is enough ? */ - if (opp_table->required_devs[0]) - return 0; - - while (*name) { - if (index >= opp_table->required_opp_count) { - dev_err(dev, "Index can't be greater than required-opp-count - 1, %s (%d : %d)\n", - *name, opp_table->required_opp_count, index); - goto err; - } - - virt_dev = dev_pm_domain_attach_by_name(dev, *name); - if (IS_ERR_OR_NULL(virt_dev)) { - ret = virt_dev ? PTR_ERR(virt_dev) : -ENODEV; - dev_err(dev, "Couldn't attach to pm_domain: %d\n", ret); - goto err; - } - - /* - * The required_opp_tables parsing is not perfect, as the OPP - * core does the parsing solely based on the DT node pointers. - * The core sets the required_opp_tables entry to the first OPP - * table in the "opp_tables" list, that matches with the node - * pointer. - * - * If the target DT OPP table is used by multiple devices and - * they all create separate instances of 'struct opp_table' from - * it, then it is possible that the required_opp_tables entry - * may be set to the incorrect sibling device. - * - * Cross check it again and fix if required. - */ - gdev = dev_to_genpd_dev(virt_dev); - if (IS_ERR(gdev)) { - ret = PTR_ERR(gdev); - goto err; - } - - genpd_table = _find_opp_table(gdev); - if (!IS_ERR(genpd_table)) { - if (genpd_table != opp_table->required_opp_tables[index]) { - dev_pm_opp_put_opp_table(opp_table->required_opp_tables[index]); - opp_table->required_opp_tables[index] = genpd_table; - } else { - dev_pm_opp_put_opp_table(genpd_table); - } - } - - opp_table->required_devs[index] = virt_dev; - index++; - name++; - } - - if (virt_devs) - *virt_devs = opp_table->required_devs; - - return 0; - -err: - _opp_detach_genpd(opp_table); - return ret; - -} - static int _opp_set_required_dev(struct opp_table *opp_table, struct device *dev, struct device *required_dev, @@ -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 |= OPP_CONFIG_REGULATOR; } - /* Attach genpds */ - if (config->genpd_names) { - if (config->required_devs) { - ret = -EINVAL; - goto err; - } - - ret = _opp_attach_genpd(opp_table, dev, config->genpd_names, - config->virt_devs); - if (ret) - goto err; - - data->flags |= OPP_CONFIG_GENPD; - } else if (config->required_dev) { + if (config->required_dev) { ret = _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) /** * 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 genpd to - * attach. Mutually exclusive with required_dev. - * @virt_devs: Pointer to return the array of genpd virtual devices. Mutually - * exclusive with required_dev. - * @required_dev: Required OPP device. Mutually exclusive with genpd_names/virt_devs. + * @required_dev: The required OPP device. * @required_dev_index: The index of the required OPP for the @required_dev. * * This structure contains platform specific OPP configurations for the device. @@ -80,8 +76,6 @@ struct dev_pm_opp_config { const unsigned int *supported_hw; unsigned int supported_hw_count; const char * const *regulator_names; - const char * const *genpd_names; - struct device ***virt_devs; struct device *required_dev; unsigned int required_dev_index; }; @@ -677,36 +671,6 @@ static inline void dev_pm_opp_put_config_regulators(int token) dev_pm_opp_clear_config(token); } -/* genpd helpers */ -static inline int dev_pm_opp_attach_genpd(struct device *dev, - const char * const *names, - struct device ***virt_devs) -{ - struct dev_pm_opp_config config = { - .genpd_names = names, - .virt_devs = virt_devs, - }; - - return dev_pm_opp_set_config(dev, &config); -} - -static inline void dev_pm_opp_detach_genpd(int token) -{ - dev_pm_opp_clear_config(token); -} - -static inline int devm_pm_opp_attach_genpd(struct device *dev, - const char * const *names, - struct device ***virt_devs) -{ - struct dev_pm_opp_config config = { - .genpd_names = names, - .virt_devs = virt_devs, - }; - - return devm_pm_opp_set_config(dev, &config); -} - /* prop-name helpers */ static inline int dev_pm_opp_set_prop_name(struct device *dev, const char *name) {