From nobody Thu Sep 19 00:52:46 2024 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41076156C78 for ; Tue, 23 Jul 2024 14:46:38 +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=1721746000; cv=none; b=p3cx7azp6Pvx/0sxDEjeCj/g0w5U+dvZaVZGDcwgfGSnsvUzoZnRsMSv1rqNZzSO1ylYqCeYmL/R+pMT3FI9soU/O37xOh9noeL7zlXzlRZEmMx999raa4j4vK0biogDk0RG4quV/+ikacDqK5vTIZl7f8t4+KNr0yiJEsA/9Qw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721746000; c=relaxed/simple; bh=/Cz64eiORglL+JzsTj4J/qRQ+zkIqCGxhfUI/VtVVk8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nxB8XxoHBpwMi8dpNKjo5m7XCUQslxYBIEP1rpZK+zCJ/wvNEO0awPXQFqeb29RsQpAwgdLxJbSQXH/AH+7dIPtWUWK1Q97PALILC37LX5wLVGg8uSeaiIztAF2MGuQ5xxBWqQPK6N+VVnEtl8T0vOirRbjAx/HfWrvXHwcV3JE= 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=Fs5k9JJw; 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="Fs5k9JJw" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-52efd08e6d9so4178464e87.1 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=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=FrrcMYfLG/IRNiRlIGOfcILMNeNyK16y6kYofjra+ME=; b=Fs5k9JJwNkn38jF5j/3cTOW6MPopJSbKnXcOYPNzoZ50zhX4iUrWqyu240TFa2g3IA zVT2RL9IhoYDT7vFkliRGTzQr5b3zEQsTcPY/sS6C7TDsDaFmMCkPGiYVf9hUQOJkioL DTpccfRNR1ptBiu/0vHr3nmJB7QP+3HDqMMnJ+zrJgLUEX0Jqjz4jNLTk38pPoiZ+CTF 8mCT8+hzsynEXpfKscPA31g1PFhIgk7bR3LXGbJw7AilQtbBPXkUkgJjaNoDMU6Hfzu1 KG8y2Eq2R5eqGiuVdghPK15FCT6ZNazqsb5FS82Sb7BTbt/VTM2U6UOIHQPYRtLf9K/i gumg== 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=kZnbq1omsgsJn2WLwPkp6XEU676jfHlW+Aid8a0SisR3iNJ4ial3ZwSPfjbEoFs5oC 2rPWr66DFREW43X+ivguBSMazg8phGivCaooqm1DTfDLpIkicBVIvf9TpMe31LhTslDn gAaw2aticRATqMiO2PD9FLYX2SQ5ESU7kv+YNN1aZkYInvps9VGbAvXqmwJo1ssFloeM jqYc5OWR/DbsJsqPee2rso8knudBBg7KSB13v4yLhQaBuvY3tLa3RUCD68K7ngkZPRx2 z+zms4/U385XXMeNOLe7nTsVg1V/56su2NT/t2rbMGqhoqpVMvSLGkBcU1glthU4tXWg lRbA== X-Forwarded-Encrypted: i=1; AJvYcCUnHOi2e7J7ZsRldNv56/SYKpcPDC+9VZCvz9t8VvjS4tiXrb2Ao6arwWQxVCWulVZ/xHXZAUEqWsW7Gox9s5PEj5Ba7HPOeZrbdVIj X-Gm-Message-State: AOJu0Yz18i8+3oRcBnCSdf9ZSinxmnRfz/fqANwRGY80CitDm6KpsZu7 dSRVEtFTDOoKicSjZfQ9xbuxhSxynB9aumzeT+bpBLiC0XKerP50GPWsMAnEv6I= 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> 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 --- 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 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; }; =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 { @@ -394,8 +395,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, }; @@ -406,13 +405,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 { @@ -427,28 +426,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) @@ -505,7 +492,6 @@ static int qcom_cpufreq_probe(struct platform_device *p= dev) of_node_put(np); =20 for_each_possible_cpu(cpu) { - struct device **virt_devs =3D NULL; struct dev_pm_opp_config config =3D { .supported_hw =3D NULL, }; @@ -524,12 +510,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; @@ -538,25 +519,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 @@ -572,7 +545,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; @@ -586,7 +559,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); } } @@ -597,7 +570,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