From patchwork Tue Jul 23 14:46:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13740145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E58B9C3DA49 for ; Tue, 23 Jul 2024 14:47:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SMvMejcYTJIM4KIVqv1c9N6HVUpji/79NTaho6YiZqU=; b=cLlJIZfKxO6/heC/v2q69YbT/H GnbO2QsZZKnaEckd85gzHHEDgAdBB2Amw+QNClVF+4kDLoFZ0e9UON7c8iT0r06LTaM6febgnHT0c aMtwGXevpo9SD2UddgEynLfQ40fMtGsqfuC/IqnMHUu3nPY6IIhtMUqfLDqmEUFk1iEbwpXn8nXrb su6WcZbbTeze0CYNgeRzsDrCLtngxmtUmjrf2O8XdlxLmprXL//ZD8La4FQQVplfLVRXp0OPh1xzn cgkC9mH0UyvXWZ79NJXN8VqHfzYkgwrzzZnHd58s6Onc7MmZfS39NH9ZzqD604oO+GEcPaMTl54QA SAxQ8xqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWGnR-0000000Cm3t-066M; Tue, 23 Jul 2024 14:47:21 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWGmi-0000000ClrE-1SDt for linux-arm-kernel@lists.infradead.org; Tue, 23 Jul 2024 14:46:38 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-52f04c1e58eso2954228e87.3 for ; Tue, 23 Jul 2024 07:46:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721745994; x=1722350794; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SMvMejcYTJIM4KIVqv1c9N6HVUpji/79NTaho6YiZqU=; b=x+GhyYnpWmfV8byc+MVOAVTmtmHXpHJMWWK/WKUxd+00w8NzibAuWpQZmh87OQjyas akw8RkufSU8qQGYOStLGJjZCJFF8PAOOVPi6Qqj5Auj302BHbhDYWZpuoG0GClIiOyce lU5BA8i/x9jPuvtPPGZYoBs6IMO2TcHGQDLwgetHiy+UPiv6aVbU7Yx6ADzIRcrZlN0S RIR9wHGDSm3UivMYl4x2fjEDBAg9Ey3fRl0CbF2eHzpcHP3WAUSb2hwC/tTyJCDhHmPG JRQqsEmm7PPWXlXEScaxP0EetW5hspKNnYNdk6v2J/1DPNpTA0UOOQ1Yy38M5Zl6PTyf 9w0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721745994; x=1722350794; 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=SMvMejcYTJIM4KIVqv1c9N6HVUpji/79NTaho6YiZqU=; b=YW415CBijp4zbBwwF+zvgb9FBHtFlbIKtvb0N4xsLCIOUe3So2LGcBdiW++GX7Z6rz NDK0jCDP1j/5dhIj65p5Z6LyqGpGJEjmmTSWr/5S4h5n4icQVxfqrjUQHc7Ld+/ybIzc moQ7GvuLWmY5iXmpa72m3HriSNQVB4qmgc4ndModuhlHT9HwbwVm5+9czW24Cq1ku6nN pSPxRn6qpRtcH5/BdFTYFvbvCy9XMNqYZpu/Wl1VtSfNFYm1BQUeMzGDPy7c/OIBKMiY X6nAubKso5zJ2+72MNnLgzbAxR2t6NxmqSwVswc5eZQVk31UbTTLpYp/wGDIc5hQ1Vyz TH4w== X-Forwarded-Encrypted: i=1; AJvYcCWP21UdOd4mTozLDGjwnv6D3KWOOJv8xTb9b0xJjT5BZXMyWDkgLKCBddx7VIOYgcRu1gYb0Bf9K9NkjobuQGyM/ozLHvJmJ6LIhOmqxw+GplWNQwA= X-Gm-Message-State: AOJu0YwvbPna0wveDKTXJJbzfpnQiweel/DFYOxVReXjRatcWa7EjNX4 PJ4joA0qAVDusE8NtLvDFDcW57rsM9yGz1yZ6jNU0YFfLTOaMGlYLplZxB0JV9U= X-Google-Smtp-Source: AGHT+IEZ1h6MbPLjULEjFJKo9gP06D2/tDoy9HevGDIpR9mHTnvQPTceARptLwA/k582cDSpVdzfpQ== X-Received: by 2002:a05:6512:4008:b0:52e:fada:f002 with SMTP id 2adb3069b0e04-52efb5223cemr8834295e87.10.1721745994036; Tue, 23 Jul 2024 07:46:34 -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-52f0415eb08sm774540e87.9.2024.07.23.07.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 07:46:33 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 1/4] drm/tegra: gr3d: Convert into dev_pm_domain_attach|detach_list() Date: Tue, 23 Jul 2024 16:46:07 +0200 Message-Id: <20240723144610.564273-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240723144610.564273-1-ulf.hansson@linaro.org> References: <20240723144610.564273-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240723_074636_408180_CA608D78 X-CRM114-Status: GOOD ( 16.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 dev_pm_domain_attach|detach_list. Signed-off-by: Ulf Hansson --- drivers/gpu/drm/tegra/gr3d.c | 46 ++++++++++-------------------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/tegra/gr3d.c b/drivers/gpu/drm/tegra/gr3d.c index 00c8564520e7..4de1ea0fc7c0 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,12 @@ 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, + }; int err; err = of_count_phandle_with_args(dev->of_node, "power-domains", @@ -414,29 +409,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 = dev_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; } @@ -527,13 +503,13 @@ static int gr3d_probe(struct platform_device *pdev) err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev); if (err) - return err; + goto err; err = host1x_client_register(&gr3d->client.base); if (err < 0) { dev_err(&pdev->dev, "failed to register host1x client: %d\n", err); - return err; + goto err; } /* initialize address register map */ @@ -541,6 +517,9 @@ 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) @@ -549,6 +528,7 @@ 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 Tue Jul 23 14:46:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13740158 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 36CD7C3DA63 for ; Tue, 23 Jul 2024 14:47:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XBP7dKcnoInh8D+ltmvy6AsIFtXdPmqqH+0/BiruIy4=; b=WN4+GZPs1R+hRzeZTKRw66fAlB AlZj1/h5d2iwF9fy4OxLRL8Upadluat/kn9CIe6NNbMST356enojSAvlE4xiC7Tc1Pwef5GZ6Jw0p JL/pIBdYOe4AyFs0E1lPNfLr7/w7sPJW1IUfRD1waCw7nn0rOM3yF+10ru/RhZ2YZTUUpaDmdDzTX Bpc+2x2NMUttKTHOPCHElsraFPqcxbiQzD5zB5IBowXe+mLPfBxA+r7Glz91nOXRKVwKX+KMCuqfY TewdkixwetSJ28EZ1ZSNT2vhi4zLvFz4b3bUn9CmXQDt3egLVgM+qFsSrwi1As89/SaZmY85gNc0Q l6En+R3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWGnm-0000000CmCB-27N0; Tue, 23 Jul 2024 14:47:42 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWGmj-0000000ClrR-3Oum for linux-arm-kernel@lists.infradead.org; Tue, 23 Jul 2024 14:46:39 +0000 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-52f04150796so3129389e87.3 for ; Tue, 23 Jul 2024 07:46:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721745995; x=1722350795; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XBP7dKcnoInh8D+ltmvy6AsIFtXdPmqqH+0/BiruIy4=; b=NnbxQ6Dn5IT0fsErfE5v+YVGtMS7DxnqVqUzv6XHAEQGLCjbkWoEm2bmVhjrenkJTx LV214q0gnJSWFdqwzBbpSS7zxINwP1JGLRkkzJPqcWz6ScLjDMjJzp1wJPsa+mY5Wvxu LqcONocET4xIA88uCAlFewtc+lztEf3raqlfyUhF0E1fECrvauSq/TnQhigcGTDbqlwZ aN9efHhWTbAriEPqGlWzDKG4vQmnVDOwoEn5cJctJwXJv8RJ3Tz/E7KsqU00hZ7mIgUG flLWIXWrZ0+4Cjzwub96twjQPf5W/FzV/bV2b/gfYVvFekpuL8PDG/t1KX8rLbqTVN0m /mwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721745995; x=1722350795; 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=XBP7dKcnoInh8D+ltmvy6AsIFtXdPmqqH+0/BiruIy4=; b=ISJusRPxLJW25w23izTO773ujZ1lWEpWXhnIJ4UZZHa4BdnKP/Vw+C0qD5omg9Z3fD IYfenwQNDYc+ur4sdwP6TL4S5ol6fot6Nf4xBKZseqelTLXHUNZOLkQowj1b/t6ikKeJ yg/Px9pkmpYx/T78Z2yJkmZjeEunjAWzXqD3EDsqmme90x4+oncnqm6vx1wdlRfv/gi+ DC74EXiOh66Y084XWQCqcq+mD8booVDjgBe7VL9N5Z2ynO7DEIVbcP2nlRiRklHpCcsY ScCbMsBn93iGR9VyIciFJ+wr4x/7ZqEuvi9qrdpxgOG2d6QIV2uQWxk2H18wBqCvJ7++ iRCA== X-Forwarded-Encrypted: i=1; AJvYcCVniaWclTSwp2p8F1DKsjd9lFi3OgljANcS3LoTAyRiT1O//YnABrldq//eyEW9AGnCTaGMjj8b+F8KE0KN3GPR7zImx9wmxCLvkJ4+3+pDRRCu6fs= X-Gm-Message-State: AOJu0YySY1avWBi2KA/oz6EXSJ2hBgjmEl715FD2syleWv5UqBaXkchf YZzc0b1xlmnctS4Uog72AGZh42ouwwUKHcWMgMW/QeDZOuW5q3eqDZo8w4thMJw= X-Google-Smtp-Source: AGHT+IFGj2dGhWRS15wyntOxuIbZDSW3f20N1Gxb1NU6kUm4Z5FMUXshX3IqJbFS6MM2MvmCAr6WLA== X-Received: by 2002:a05:6512:2204:b0:52c:cc38:592c with SMTP id 2adb3069b0e04-52fc3fef109mr2116350e87.0.1721745995211; Tue, 23 Jul 2024 07:46:35 -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-52f0415eb08sm774540e87.9.2024.07.23.07.46.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 07:46:34 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Stanimir Varbanov , Vikash Garodia , linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 2/4] media: venus: Use dev_pm_domain_attach|detach_list() for OPP PM domain Date: Tue, 23 Jul 2024 16:46:08 +0200 Message-Id: <20240723144610.564273-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240723144610.564273-1-ulf.hansson@linaro.org> References: <20240723144610.564273-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240723_074637_880035_478F6D4F X-CRM114-Status: GOOD ( 19.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 dev_pm_domain_attach|detach_list. Signed-off-by: Ulf Hansson Acked-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.c | 8 ++--- drivers/media/platform/qcom/venus/core.h | 6 +--- .../media/platform/qcom/venus/pm_helpers.c | 31 ++++++------------- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index ce206b709754..a422bbb3b610 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -709,7 +709,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, @@ -758,7 +758,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, @@ -815,7 +815,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, @@ -874,7 +874,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 6a77de374454..aec587e6294f 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 @@ -185,10 +183,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 502822059498..e133683871aa 100644 --- a/drivers/media/platform/qcom/venus/pm_helpers.c +++ b/drivers/media/platform/qcom/venus/pm_helpers.c @@ -857,7 +857,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 = { @@ -865,6 +864,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, + }; if (!res->vcodec_pmdomains_num) goto skip_pmdomains; @@ -874,24 +878,14 @@ 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); + ret = dev_pm_domain_attach_list(dev, &opp_pd_data, &core->opp_pmdomain); 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; - } - return 0; opp_attach_err: @@ -902,12 +896,7 @@ static int vcodec_domains_get(struct venus_core *core) static void vcodec_domains_put(struct venus_core *core) { dev_pm_domain_detach_list(core->pmdomains); - - if (!core->has_opp_table) - return; - - if (core->opp_dl_venus) - device_link_del(core->opp_dl_venus); + dev_pm_domain_detach_list(core->opp_pmdomain); } static int core_resets_reset(struct venus_core *core) @@ -996,9 +985,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; } From patchwork Tue Jul 23 14:46:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13740159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8E5B2C3DA63 for ; Tue, 23 Jul 2024 14:48:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FrrcMYfLG/IRNiRlIGOfcILMNeNyK16y6kYofjra+ME=; b=Bxcc7D1CQNEisNohLTNYwfPBsP VLXHdBYB9F8m8SQXJFgBLcW5YR4t7aa1jC/7izineNqd35Dj7HHHbbirUZ9V7K1ff1QqEml/hAvyJ edzB+GUxyGacVD1GhZNitfqXejfCDledxOfKFRMD16wQef+Gedvosp7Zx/I5DbWvlmuNyAvDN4EHd u403ZNepDlrGvPX4+29aG2ac5fLCZlkLlGCmmV2Hb+4j+luqwk7PW84TFpj/pVlT9R8nt5nAtdaKw e+IrNquBcX26UZ7gd9n0YoKzFP8G7XKrDsNKRwD9J5ONBem4bfpF/0gyTDU4qkPvujZ0t5LEFMa6E D4qWTtmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWGo7-0000000CmHu-3ITZ; Tue, 23 Jul 2024 14:48:03 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWGmk-0000000Clrn-3vjz for linux-arm-kernel@lists.infradead.org; Tue, 23 Jul 2024 14:46:40 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-52f00ad303aso3515121e87.2 for ; Tue, 23 Jul 2024 07:46:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721745996; x=1722350796; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FrrcMYfLG/IRNiRlIGOfcILMNeNyK16y6kYofjra+ME=; b=oJ3t5KhCA6RdEYl3Kc3ekjEoiqAPAsbdPkR6J7ZiPH3iuGrIvT4EvnzzloIx9fnfej 7MOe4H0culwjLMt9BwdVulOxt6WB7PUoQ974y4ZD96JffhTXdjDds+pnneSSNDtisYUR Go+BLyiJPoNzgr8UsU9B8Y/mQP19epcd7cDUgblfqksetVGj/pmpbpRdscz3OtOTzrFs SKvZZx6OouF9wZWlbXHoRuioF2z2SOIi5D4kIgE/DM4PKNjeLGAOFoMZ/rd+HX+cDpJW sHRy3ejUItFvtmhxnm76yt5yCZ+XyJXicfn49KOISkhKoZ+xo4SdGYpzFeSjTLGE2odG 2WjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721745996; x=1722350796; 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=FrrcMYfLG/IRNiRlIGOfcILMNeNyK16y6kYofjra+ME=; b=dzdmZJABRh7YsI4mYb2FJd3ydhBbZ+b5Edx8GGIXLRnzYFjrZVyc2rsP/NVDZEaSu7 YVCpbRFNS+ze52BY1cIQldFRTAFcqgn92nGX/da4cm6F6rBUmKN7lLQwluSwoLcRrFzK bECzJxlp+URtixORv6Pyd6KPjNwoG7GzZm44Nea6yHuiqmyccqNbd2LCFZ3Pd6VZZmym HcjY8+hsI1tP1GmmkelWhzsOWT1NciDxphqav3k47L4k0rcFbq1MpGqftw53rk1F2eIy VP8JEoSJybYeSV3AqByHox7sAYXLq18SdV56gnFmfJzAuiEnrlctBeYUQtIZKP/+aioo aV+A== X-Forwarded-Encrypted: i=1; AJvYcCWzZylJq8bdRINzsauLUHB9oel49XRWThcMlIl/fcQN3NqAZW6lMof59XC+O2jXixBvPULSsT6qlnafq48IOeW3cLOSzYi/8y6Ph+wLTOS7chid5BM= X-Gm-Message-State: AOJu0Yx0meiV+63ysi4uLoBQyjxhV9MO5JfNt87i2IYmDxXVDdguTf0F 1rwcI08Rpgnt7meCJri0eJDFDkYsf50wkUqLFp/Xaja/c67qdr2ce6Ac/hu/u3g= X-Google-Smtp-Source: AGHT+IHI7MKcmaUYwLbT8KpWV+gZCkHNesswZsoZOrPGXmC51ZgZNSlNboV0W17HiSXE+kZ3RDydkQ== X-Received: by 2002:a05:6512:31c7:b0:52e:be1f:bf8b with SMTP id 2adb3069b0e04-52fc406f0famr2550946e87.47.1721745996507; Tue, 23 Jul 2024 07:46:36 -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-52f0415eb08sm774540e87.9.2024.07.23.07.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 07:46:36 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Ilia Lin , Stephan Gerhold , linux-arm-msm@vger.kernel.org Subject: [PATCH 3/4] cpufreq: qcom-nvmem: Convert to dev_pm_domain_attach|detach_list() Date: Tue, 23 Jul 2024 16:46:09 +0200 Message-Id: <20240723144610.564273-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240723144610.564273-1-ulf.hansson@linaro.org> References: <20240723144610.564273-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240723_074639_006052_AA30AE7F X-CRM114-Status: GOOD ( 20.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. Signed-off-by: Ulf Hansson --- drivers/cpufreq/qcom-cpufreq-nvmem.c | 79 +++++++++------------------- 1 file changed, 26 insertions(+), 53 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c index ea05d9d67490..65739ce98658 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 { @@ -394,8 +395,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, }; @@ -406,13 +405,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 = { @@ -427,28 +426,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) +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++) - 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) -{ - const char * const *name = drv->data->genpd_names; - int i; - - if (!drv->cpus[cpu].virt_devs) - 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) @@ -505,7 +492,6 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) of_node_put(np); for_each_possible_cpu(cpu) { - struct device **virt_devs = NULL; struct dev_pm_opp_config config = { .supported_hw = NULL, }; @@ -524,12 +510,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; @@ -538,25 +519,17 @@ 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); + 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, + }; - /* 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; + ret = dev_pm_domain_attach_list(cpu_dev, &attach_data, + &drv->cpus[cpu].pd_list); + if (ret < 0) + goto free_opp; } } @@ -572,7 +545,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; @@ -586,7 +559,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); } } @@ -597,7 +570,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 Tue Jul 23 14:46:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13740160 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0CEF2C3DA63 for ; Tue, 23 Jul 2024 14:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1r6mQjxdA5Ycu1o4JlXvEuFhP6RdDyjqQdXSFbqbnuk=; b=Jt/6zzjPyJuySceF1Rusi1SKD0 nM7gAT1C7IR6029LGgPjiXrpInNief0DmlcBav4ygDHQL5Srpwt77eEJmEjXmHWJqg7QtaUF4d71N sVlbHoPm8tVZ+njzES6pUzEsvkqX1HV6DJgoA9cHK9poaJdaUobT3Ukh1dFQoNiYjYT1K88mNyzdk IyghrVCINheB41ODvxvU+oeJO3LzbVc2gVloBhKAWqsNtYDXO0fULNeFrCIToEmEYeqPoeAO3HFIU HszAM+mE342BERjk0YyD+x5sh8rjyIKNkT8ShcYL5nDMvzjIFqD16F3fY7n5ncf93csAOKtzatXn7 dxaKvyuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWGoT-0000000CmPh-0rMf; Tue, 23 Jul 2024 14:48:25 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWGml-0000000ClsB-0wEI for linux-arm-kernel@lists.infradead.org; Tue, 23 Jul 2024 14:46:40 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-52efc89dbedso3103670e87.3 for ; Tue, 23 Jul 2024 07:46:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721745998; x=1722350798; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1r6mQjxdA5Ycu1o4JlXvEuFhP6RdDyjqQdXSFbqbnuk=; b=Z/J30OW7yBlczvojFSfLOFUiXd/ZmTt01tYh7/2HYln8vqOuY2XQek13lepDYcON+a DfQk3mn2UJS2wk1fPjs/9Yml8Mmon+Li10q8mZuwXDyb8GL+XVAMXHMmk/yvNPUEJxlx Kg3QBtvA7HMj0ssClk4hcpdzeXK2Dp/QevUQC9DC1DErlY70QJdQdmKTSmtIqVU1ofYw 20nmAMemvPfK2rVcvXBJGauinDIyiBatzaXUdcqFOH/uchrqs3oE3eAsol3dDlPgMblx oLw2AgljqudM+IRQklCCIl1vBeyT6LMvzgVU5hgz1hSOg+Otm+GMlWGwTHJG4JwkC1eC k1DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721745998; x=1722350798; 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=1r6mQjxdA5Ycu1o4JlXvEuFhP6RdDyjqQdXSFbqbnuk=; b=V0sZlLJczYOOh2Um6d/0FuuaFTD6rotRpPsvDmWfhgG0ScC0XKtp70NMKq2UAr6SSo aRkZN5gz6ct4mI+2cF2ZFcgrg81ZhbnOdJ/iBPmINLXWbK2KxnByjOUVd3ZXcPPFtBRy VaQ2zN8/v+qwUNkxk6jQw9HPU6pKYXFfMJbs6Gi1r45jQjySyH7eZvFrL/T53YYv4G0t pBYgeRTuJ60C9+Jrt1hn9D/tYggUHb1Zisa9fXscAhRnfSJV9qicXts4LyPLCkxXIYAM uuX33ByGOySJ+kRshh9skbfllh5Ir8/vQNz1i7hmFq0fQsHIKjgR9MbnRrCTNXBQ5FvO 8pzg== X-Forwarded-Encrypted: i=1; AJvYcCW561mKHbrNeREtghxO5kXym44Hxe4FEgoScpJj5j0/ZlzaNjQmCmI+c/3XNoRWLphsgUg6moLKhcR0u3+F3r9xq098ioZA/hqnBGvqN2sci9E8R0A= X-Gm-Message-State: AOJu0YwVEP3m4MNGaNhfR9onyaMb18STpNBjjpllh0fp6B9v2rTwPkQ2 8HZA5DVS7FpdVoMc6awB+JD6eUJsrmssysC73SlRA1cnkPZ/EjI4SkJfMQdPWB0= X-Google-Smtp-Source: AGHT+IF4JXt63g3aJOtD34L0D3D22CnPoBsXJUr8hYUB/3dr0SeT1SQm94wxj0Gjpxn1WXB5Y5YwJw== X-Received: by 2002:a05:6512:1048:b0:52f:c3c9:1691 with SMTP id 2adb3069b0e04-52fc404d27bmr2282609e87.32.1721745997599; Tue, 23 Jul 2024 07:46:37 -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-52f0415eb08sm774540e87.9.2024.07.23.07.46.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 07:46:37 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] OPP: Drop redundant _opp_attach|detach_genpd() Date: Tue, 23 Jul 2024 16:46:10 +0200 Message-Id: <20240723144610.564273-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240723144610.564273-1-ulf.hansson@linaro.org> References: <20240723144610.564273-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240723_074639_473399_E555EF2C X-CRM114-Status: GOOD ( 25.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There no longer any users of _opp_attach|detach_genpd(), hence let's drop it along with the corresponding exported functions. Signed-off-by: Ulf Hansson --- drivers/opp/core.c | 96 +----------------------------------------- drivers/opp/opp.h | 3 +- include/linux/pm_opp.h | 38 +---------------- 3 files changed, 3 insertions(+), 134 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index cad7e84c9ad3..66cac7a1d9db 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2360,86 +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); - } -} - -/* - * 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; - 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; - } - - 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, @@ -2516,9 +2436,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) @@ -2630,18 +2547,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_dev) - 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 && config->required_opp_table) { + if (config->required_dev && config->required_opp_table) { ret = _opp_set_required_dev(opp_table, dev, config->required_dev, config->required_opp_table); 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 5fade5c4de40..451a7465a605 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: Required OPP device. * @required_opp_table: The corresponding required OPP table for @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; struct opp_table *required_opp_table; }; @@ -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) {