From nobody Tue Dec 16 20:44:18 2025 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 DE3561D3643 for ; Thu, 22 Aug 2024 22:46:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724366780; cv=none; b=IAlcXvq5NN6qr9QxBXYMxMCFwX46Z+ODWk9jHIi1bjD4g2tNx4eguJ27YWdFnD1G1U1AJ3rHw6sdzVQPbGdh94mOrc2bgppdHj5jMLFJr61mVZs08DRRERW1iAqcBmz0gxgrcm1EKecmm7mMJAd8BSr18NbCfWSrXgAOYQPLA3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724366780; c=relaxed/simple; bh=fzv2Qhm8qkbuiNawozPPsMhWU0ubmi4ni4I/TKeUmdc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YBK+osurjkqnAU/IFLRAczaVl2bb26L12M5q+wZ/r0Lua0K34vRDRCLx2FF0YPPonUG5w/dPCtZRHzlhHk7gzjGwURtbQw9ROr8+C+xIgZOfL4/fLhWcNKdfCjVKvsn3yKL9RYctKssA7SpjMbYZ0HeDWyntKiaC524Wx5clg90= 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=h4tVCANt; arc=none smtp.client-ip=209.85.167.53 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="h4tVCANt" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-53349ee42a9so1662881e87.3 for ; Thu, 22 Aug 2024 15:46:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366777; x=1724971577; 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=iksFSJ//26ReVaxAnVHvTDyArAC4NnchBY2BZAJDBow=; b=h4tVCANtLg/Hai7zD3IRKcelktZ8/qw4aWtj6JFt6o0Uu+wuK/g4mO9M82r8KzfeSN Tsnnf6sNMlrRVGvWbrXsHceLbucnQmJAyckQSoWYDAoipRSWqyMsLtU1GOyIzz2LX7pe PM1qe3oL1nuGzckGy2HLizataa7AHiZ4qTjGP6sxEJ4N58xuqkWFo/OPmfM7GTkvF56d oM7EGprVswx/WIZJvHzJo3sgCpbRh+5cgyoaQOmFn/ejN4MvjKGhsT0KY5irnO2IpxHw uxZJf+DztaHY3BKECZ75Bxa7jk9F3sp2wfA2i3INKMvjxC2EpsMlqXl5YkJmemCDGjKk PVRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366777; x=1724971577; 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=iksFSJ//26ReVaxAnVHvTDyArAC4NnchBY2BZAJDBow=; b=M/fLsNKo7JSfj3qZwfFJUmPKigwYR/WBO21dRtJ51CCIyq73LZrOTpLol0oBh6I64B ECHuZr5WXUCiWvylbF89pfKBStm36+F7T1VJaFJWTMMucz/XhVm6MgSss9lcYR7ASnY0 irjEN+t4z+hb6n31lssufBwMXRifb4km5pro8V0mkp+3+b27oRbzedVFcibcOZxd3QQ0 lUmAIXm4Zqhp6kX+zdJHTtpA/6E6LgT4vTR+06r+EwYFjXX148DwOeH+hspRgkO6iFC6 7SQ867M+7SOt2yRAw1nqlGjn3YiZSg+JFFs55TONj8tJHn8QAeBYNOsY16gzzf7o95N2 jbWQ== X-Forwarded-Encrypted: i=1; AJvYcCU+WSzBww0ieOPWrkHgZCOGbtyS8fJ0OeK7lNZAxKcSzSjfEOe58p4gtIpYq5gDWMDr5ray1LmOJcB45qE=@vger.kernel.org X-Gm-Message-State: AOJu0YyEoavJycvfYLNlO4nvdiZengv4wiZyOhKzGi9g9UTIQC7Le9ZK Gr/6R1W/phDisHRTpe/uzJleBMGT6m2wMaf1civcfCTPID/e8a4Hf96ehkKsp3U= X-Google-Smtp-Source: AGHT+IFqYnnUrUddlV2VzJzkFcuvSxGz0XMOiVMuzx0Kw0HD/D4q6JeKW5PZ8PIU3LGdvGhnAFZwtQ== X-Received: by 2002:a05:6512:15a2:b0:530:ba4b:f65d with SMTP id 2adb3069b0e04-534387852e1mr179442e87.28.1724366776756; Thu, 22 Aug 2024 15:46:16 -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-5334ea362a4sm379443e87.66.2024.08.22.15.46.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:16 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: 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 v3 09/10] cpufreq: qcom-nvmem: Convert to dev_pm_domain_attach|detach_list() Date: Fri, 23 Aug 2024 00:45:46 +0200 Message-Id: <20240822224547.385095-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rather than hooking up the PM domains through _opp_attach_genpd() and manually manage runtime PM for the corresponding virtual devices created by genpd during attach, let's avoid the boilerplate-code by converting into dev_pm_domain_attach|detach_list. Signed-off-by: Ulf Hansson --- Changes in v3: - None. --- 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-cp= ufreq-nvmem.c index 939702dfa73f..6ba8c8378384 100644 --- a/drivers/cpufreq/qcom-cpufreq-nvmem.c +++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c @@ -52,12 +52,13 @@ struct qcom_cpufreq_match_data { struct nvmem_cell *speedbin_nvmem, char **pvs_name, struct qcom_cpufreq_drv *drv); - const char **genpd_names; + const char **pd_names; + unsigned int num_pd_names; }; =20 struct qcom_cpufreq_drv_cpu { int opp_token; - struct device **virt_devs; + struct dev_pm_domain_list *pd_list; }; =20 struct qcom_cpufreq_drv { @@ -395,8 +396,6 @@ static int qcom_cpufreq_ipq8074_name_version(struct dev= ice *cpu_dev, return 0; } =20 -static const char *generic_genpd_names[] =3D { "perf", NULL }; - static const struct qcom_cpufreq_match_data match_data_kryo =3D { .get_version =3D qcom_cpufreq_kryo_name_version, }; @@ -407,13 +406,13 @@ static const struct qcom_cpufreq_match_data match_dat= a_krait =3D { =20 static const struct qcom_cpufreq_match_data match_data_msm8909 =3D { .get_version =3D qcom_cpufreq_simple_get_version, - .genpd_names =3D generic_genpd_names, + .pd_names =3D (const char *[]) { "perf" }, + .num_pd_names =3D 1, }; =20 -static const char *qcs404_genpd_names[] =3D { "cpr", NULL }; - static const struct qcom_cpufreq_match_data match_data_qcs404 =3D { - .genpd_names =3D qcs404_genpd_names, + .pd_names =3D (const char *[]) { "cpr" }, + .num_pd_names =3D 1, }; =20 static const struct qcom_cpufreq_match_data match_data_ipq6018 =3D { @@ -428,28 +427,16 @@ static const struct qcom_cpufreq_match_data match_dat= a_ipq8074 =3D { .get_version =3D qcom_cpufreq_ipq8074_name_version, }; =20 -static void qcom_cpufreq_suspend_virt_devs(struct qcom_cpufreq_drv *drv, u= nsigned int cpu) +static void qcom_cpufreq_suspend_pd_devs(struct qcom_cpufreq_drv *drv, uns= igned int cpu) { - const char * const *name =3D drv->data->genpd_names; + struct dev_pm_domain_list *pd_list =3D drv->cpus[cpu].pd_list; int i; =20 - if (!drv->cpus[cpu].virt_devs) + if (!pd_list) return; =20 - for (i =3D 0; *name; i++, name++) - device_set_awake_path(drv->cpus[cpu].virt_devs[i]); -} - -static void qcom_cpufreq_put_virt_devs(struct qcom_cpufreq_drv *drv, unsig= ned int cpu) -{ - const char * const *name =3D drv->data->genpd_names; - int i; - - if (!drv->cpus[cpu].virt_devs) - return; - - for (i =3D 0; *name; i++, name++) - pm_runtime_put(drv->cpus[cpu].virt_devs[i]); + for (i =3D 0; i < pd_list->num_pds; i++) + device_set_awake_path(pd_list->pd_devs[i]); } =20 static int qcom_cpufreq_probe(struct platform_device *pdev) @@ -503,7 +490,6 @@ static int qcom_cpufreq_probe(struct platform_device *p= dev) } =20 for_each_possible_cpu(cpu) { - struct device **virt_devs =3D NULL; struct dev_pm_opp_config config =3D { .supported_hw =3D NULL, }; @@ -522,12 +508,7 @@ static int qcom_cpufreq_probe(struct platform_device *= pdev) config.prop_name =3D pvs_name; } =20 - if (drv->data->genpd_names) { - config.genpd_names =3D drv->data->genpd_names; - config.virt_devs =3D &virt_devs; - } - - if (config.supported_hw || config.genpd_names) { + if (config.supported_hw) { drv->cpus[cpu].opp_token =3D dev_pm_opp_set_config(cpu_dev, &config); if (drv->cpus[cpu].opp_token < 0) { ret =3D drv->cpus[cpu].opp_token; @@ -536,25 +517,17 @@ static int qcom_cpufreq_probe(struct platform_device = *pdev) } } =20 - if (virt_devs) { - const char * const *name =3D config.genpd_names; - int i, j; - - for (i =3D 0; *name; i++, name++) { - ret =3D pm_runtime_resume_and_get(virt_devs[i]); - if (ret) { - dev_err(cpu_dev, "failed to resume %s: %d\n", - *name, ret); + if (drv->data->pd_names) { + struct dev_pm_domain_attach_data attach_data =3D { + .pd_names =3D drv->data->pd_names, + .num_pd_names =3D drv->data->num_pd_names, + .pd_flags =3D PD_FLAG_DEV_LINK_ON, + }; =20 - /* Rollback previous PM runtime calls */ - name =3D config.genpd_names; - for (j =3D 0; *name && j < i; j++, name++) - pm_runtime_put(virt_devs[j]); - - goto free_opp; - } - } - drv->cpus[cpu].virt_devs =3D virt_devs; + ret =3D dev_pm_domain_attach_list(cpu_dev, &attach_data, + &drv->cpus[cpu].pd_list); + if (ret < 0) + goto free_opp; } } =20 @@ -570,7 +543,7 @@ static int qcom_cpufreq_probe(struct platform_device *p= dev) =20 free_opp: for_each_possible_cpu(cpu) { - qcom_cpufreq_put_virt_devs(drv, cpu); + dev_pm_domain_detach_list(drv->cpus[cpu].pd_list); dev_pm_opp_clear_config(drv->cpus[cpu].opp_token); } return ret; @@ -584,7 +557,7 @@ static void qcom_cpufreq_remove(struct platform_device = *pdev) platform_device_unregister(cpufreq_dt_pdev); =20 for_each_possible_cpu(cpu) { - qcom_cpufreq_put_virt_devs(drv, cpu); + dev_pm_domain_detach_list(drv->cpus[cpu].pd_list); dev_pm_opp_clear_config(drv->cpus[cpu].opp_token); } } @@ -595,7 +568,7 @@ static int qcom_cpufreq_suspend(struct device *dev) unsigned int cpu; =20 for_each_possible_cpu(cpu) - qcom_cpufreq_suspend_virt_devs(drv, cpu); + qcom_cpufreq_suspend_pd_devs(drv, cpu); =20 return 0; } --=20 2.34.1