Skip to content

Commit 75f2b37

Browse files
committed
Merge tag 'pmdomain-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm
Pull pmdomain updates from Ulf Hansson: "pmdomain core: - Set the required dev for a required OPP during genpd attach - Add support for required OPPs to dev_pm_domain_attach_list() pmdomain providers: - ti: Enable GENPD_FLAG_ACTIVE_WAKEUP flag for ti_sci PM domains - mediatek: Add support for MT6735 PM domains - mediatek: Use OF-specific regulator API to get power domain supply - qcom: Add support for the SM8750/SAR2130P/qcs615/qcs8300 rpmhpds pmdomain consumers: - Convert a couple of consumer drivers to *_pm_domain_attach|detach_list() opp core: - Rework and cleanup some code that manages required OPPs - Remove *_opp_attach|detach_genpd()" * tag 'pmdomain-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm: (25 commits) pmdomain: qcom: rpmhpd: Add rpmhpd support for SM8750 dt-bindings: power: qcom,rpmpd: document the SM8750 RPMh Power Domains pmdomain: imx: Use of_property_present() for non-boolean properties pmdomain: imx: gpcv2: replace dev_err() with dev_err_probe() pmdomain: ti-sci: Use scope based of_node_put() to simplify code. pmdomain: ti-sci: Add missing of_node_put() for args.np pmdomain: ti-sci: set the GENPD_FLAG_ACTIVE_WAKEUP flag for all PM domains pmdomain: mediatek: Add support for MT6735 pmdomain: qcom: rpmhpd: add support for SAR2130P dt-bindings: power: Add binding for MediaTek MT6735 power controller dt-bindings: power: rpmpd: Add SAR2130P compatible OPP: Drop redundant *_opp_attach|detach_genpd() cpufreq: qcom-nvmem: Convert to dev_pm_domain_attach|detach_list() media: venus: Convert into devm_pm_domain_attach_list() for OPP PM domain drm/tegra: gr3d: Convert into devm_pm_domain_attach_list() OPP: Drop redundant code in _link_required_opps() pmdomain: core: Set the required dev for a required OPP during genpd attach pmdomain: core: Manage the default required OPP from a separate function PM: domains: Support required OPPs in dev_pm_domain_attach_list() OPP: Rework _set_required_devs() to manage a single device per call ...
2 parents 0cea110 + 5812b95 commit 75f2b37

25 files changed

Lines changed: 434 additions & 398 deletions

File tree

Documentation/devicetree/bindings/power/mediatek,power-controller.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ properties:
2323

2424
compatible:
2525
enum:
26+
- mediatek,mt6735-power-controller
2627
- mediatek,mt6795-power-controller
2728
- mediatek,mt8167-power-controller
2829
- mediatek,mt8173-power-controller

Documentation/devicetree/bindings/power/qcom,rpmpd.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ properties:
3232
- qcom,msm8998-rpmpd
3333
- qcom,qcm2290-rpmpd
3434
- qcom,qcs404-rpmpd
35+
- qcom,qcs615-rpmhpd
36+
- qcom,qcs8300-rpmhpd
3537
- qcom,qdu1000-rpmhpd
3638
- qcom,qm215-rpmpd
3739
- qcom,sa8155p-rpmhpd
3840
- qcom,sa8540p-rpmhpd
3941
- qcom,sa8775p-rpmhpd
42+
- qcom,sar2130p-rpmhpd
4043
- qcom,sc7180-rpmhpd
4144
- qcom,sc7280-rpmhpd
4245
- qcom,sc8180x-rpmhpd
@@ -58,6 +61,7 @@ properties:
5861
- qcom,sm8450-rpmhpd
5962
- qcom,sm8550-rpmhpd
6063
- qcom,sm8650-rpmhpd
64+
- qcom,sm8750-rpmhpd
6165
- qcom,x1e80100-rpmhpd
6266
- items:
6367
- enum:

Documentation/devicetree/bindings/soc/mediatek/scpsys.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Required properties:
2020
- compatible: Should be one of:
2121
- "mediatek,mt2701-scpsys"
2222
- "mediatek,mt2712-scpsys"
23+
- "mediatek,mt6735-scpsys"
2324
- "mediatek,mt6765-scpsys"
2425
- "mediatek,mt6797-scpsys"
2526
- "mediatek,mt7622-scpsys"

drivers/base/power/common.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/pm_clock.h>
1212
#include <linux/acpi.h>
1313
#include <linux/pm_domain.h>
14+
#include <linux/pm_opp.h>
1415

1516
#include "power.h"
1617

@@ -222,13 +223,15 @@ int dev_pm_domain_attach_list(struct device *dev,
222223
if (!pds)
223224
return -ENOMEM;
224225

225-
size = sizeof(*pds->pd_devs) + sizeof(*pds->pd_links);
226+
size = sizeof(*pds->pd_devs) + sizeof(*pds->pd_links) +
227+
sizeof(*pds->opp_tokens);
226228
pds->pd_devs = kcalloc(num_pds, size, GFP_KERNEL);
227229
if (!pds->pd_devs) {
228230
ret = -ENOMEM;
229231
goto free_pds;
230232
}
231233
pds->pd_links = (void *)(pds->pd_devs + num_pds);
234+
pds->opp_tokens = (void *)(pds->pd_links + num_pds);
232235

233236
if (link_flags && pd_flags & PD_FLAG_DEV_LINK_ON)
234237
link_flags |= DL_FLAG_RPM_ACTIVE;
@@ -244,6 +247,19 @@ int dev_pm_domain_attach_list(struct device *dev,
244247
goto err_attach;
245248
}
246249

250+
if (pd_flags & PD_FLAG_REQUIRED_OPP) {
251+
struct dev_pm_opp_config config = {
252+
.required_dev = pd_dev,
253+
.required_dev_index = i,
254+
};
255+
256+
ret = dev_pm_opp_set_config(dev, &config);
257+
if (ret < 0)
258+
goto err_link;
259+
260+
pds->opp_tokens[i] = ret;
261+
}
262+
247263
if (link_flags) {
248264
struct device_link *link;
249265

@@ -264,9 +280,11 @@ int dev_pm_domain_attach_list(struct device *dev,
264280
return num_pds;
265281

266282
err_link:
283+
dev_pm_opp_clear_config(pds->opp_tokens[i]);
267284
dev_pm_domain_detach(pd_dev, true);
268285
err_attach:
269286
while (--i >= 0) {
287+
dev_pm_opp_clear_config(pds->opp_tokens[i]);
270288
if (pds->pd_links[i])
271289
device_link_del(pds->pd_links[i]);
272290
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)
361379
return;
362380

363381
for (i = 0; i < list->num_pds; i++) {
382+
dev_pm_opp_clear_config(list->opp_tokens[i]);
364383
if (list->pd_links[i])
365384
device_link_del(list->pd_links[i]);
366385
dev_pm_domain_detach(list->pd_devs[i], true);

drivers/cpufreq/qcom-cpufreq-nvmem.c

Lines changed: 28 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,13 @@ struct qcom_cpufreq_match_data {
5252
struct nvmem_cell *speedbin_nvmem,
5353
char **pvs_name,
5454
struct qcom_cpufreq_drv *drv);
55-
const char **genpd_names;
55+
const char **pd_names;
56+
unsigned int num_pd_names;
5657
};
5758

5859
struct qcom_cpufreq_drv_cpu {
5960
int opp_token;
60-
struct device **virt_devs;
61+
struct dev_pm_domain_list *pd_list;
6162
};
6263

6364
struct qcom_cpufreq_drv {
@@ -395,8 +396,6 @@ static int qcom_cpufreq_ipq8074_name_version(struct device *cpu_dev,
395396
return 0;
396397
}
397398

398-
static const char *generic_genpd_names[] = { "perf", NULL };
399-
400399
static const struct qcom_cpufreq_match_data match_data_kryo = {
401400
.get_version = qcom_cpufreq_kryo_name_version,
402401
};
@@ -407,13 +406,13 @@ static const struct qcom_cpufreq_match_data match_data_krait = {
407406

408407
static const struct qcom_cpufreq_match_data match_data_msm8909 = {
409408
.get_version = qcom_cpufreq_simple_get_version,
410-
.genpd_names = generic_genpd_names,
409+
.pd_names = (const char *[]) { "perf" },
410+
.num_pd_names = 1,
411411
};
412412

413-
static const char *qcs404_genpd_names[] = { "cpr", NULL };
414-
415413
static const struct qcom_cpufreq_match_data match_data_qcs404 = {
416-
.genpd_names = qcs404_genpd_names,
414+
.pd_names = (const char *[]) { "cpr" },
415+
.num_pd_names = 1,
417416
};
418417

419418
static const struct qcom_cpufreq_match_data match_data_ipq6018 = {
@@ -428,28 +427,16 @@ static const struct qcom_cpufreq_match_data match_data_ipq8074 = {
428427
.get_version = qcom_cpufreq_ipq8074_name_version,
429428
};
430429

431-
static void qcom_cpufreq_suspend_virt_devs(struct qcom_cpufreq_drv *drv, unsigned int cpu)
432-
{
433-
const char * const *name = drv->data->genpd_names;
434-
int i;
435-
436-
if (!drv->cpus[cpu].virt_devs)
437-
return;
438-
439-
for (i = 0; *name; i++, name++)
440-
device_set_awake_path(drv->cpus[cpu].virt_devs[i]);
441-
}
442-
443-
static void qcom_cpufreq_put_virt_devs(struct qcom_cpufreq_drv *drv, unsigned int cpu)
430+
static void qcom_cpufreq_suspend_pd_devs(struct qcom_cpufreq_drv *drv, unsigned int cpu)
444431
{
445-
const char * const *name = drv->data->genpd_names;
432+
struct dev_pm_domain_list *pd_list = drv->cpus[cpu].pd_list;
446433
int i;
447434

448-
if (!drv->cpus[cpu].virt_devs)
435+
if (!pd_list)
449436
return;
450437

451-
for (i = 0; *name; i++, name++)
452-
pm_runtime_put(drv->cpus[cpu].virt_devs[i]);
438+
for (i = 0; i < pd_list->num_pds; i++)
439+
device_set_awake_path(pd_list->pd_devs[i]);
453440
}
454441

455442
static int qcom_cpufreq_probe(struct platform_device *pdev)
@@ -503,7 +490,6 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
503490
}
504491

505492
for_each_possible_cpu(cpu) {
506-
struct device **virt_devs = NULL;
507493
struct dev_pm_opp_config config = {
508494
.supported_hw = NULL,
509495
};
@@ -522,12 +508,7 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
522508
config.prop_name = pvs_name;
523509
}
524510

525-
if (drv->data->genpd_names) {
526-
config.genpd_names = drv->data->genpd_names;
527-
config.virt_devs = &virt_devs;
528-
}
529-
530-
if (config.supported_hw || config.genpd_names) {
511+
if (config.supported_hw) {
531512
drv->cpus[cpu].opp_token = dev_pm_opp_set_config(cpu_dev, &config);
532513
if (drv->cpus[cpu].opp_token < 0) {
533514
ret = drv->cpus[cpu].opp_token;
@@ -536,25 +517,18 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
536517
}
537518
}
538519

539-
if (virt_devs) {
540-
const char * const *name = config.genpd_names;
541-
int i, j;
542-
543-
for (i = 0; *name; i++, name++) {
544-
ret = pm_runtime_resume_and_get(virt_devs[i]);
545-
if (ret) {
546-
dev_err(cpu_dev, "failed to resume %s: %d\n",
547-
*name, ret);
548-
549-
/* Rollback previous PM runtime calls */
550-
name = config.genpd_names;
551-
for (j = 0; *name && j < i; j++, name++)
552-
pm_runtime_put(virt_devs[j]);
553-
554-
goto free_opp;
555-
}
556-
}
557-
drv->cpus[cpu].virt_devs = virt_devs;
520+
if (drv->data->pd_names) {
521+
struct dev_pm_domain_attach_data attach_data = {
522+
.pd_names = drv->data->pd_names,
523+
.num_pd_names = drv->data->num_pd_names,
524+
.pd_flags = PD_FLAG_DEV_LINK_ON |
525+
PD_FLAG_REQUIRED_OPP,
526+
};
527+
528+
ret = dev_pm_domain_attach_list(cpu_dev, &attach_data,
529+
&drv->cpus[cpu].pd_list);
530+
if (ret < 0)
531+
goto free_opp;
558532
}
559533
}
560534

@@ -570,7 +544,7 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
570544

571545
free_opp:
572546
for_each_possible_cpu(cpu) {
573-
qcom_cpufreq_put_virt_devs(drv, cpu);
547+
dev_pm_domain_detach_list(drv->cpus[cpu].pd_list);
574548
dev_pm_opp_clear_config(drv->cpus[cpu].opp_token);
575549
}
576550
return ret;
@@ -584,7 +558,7 @@ static void qcom_cpufreq_remove(struct platform_device *pdev)
584558
platform_device_unregister(cpufreq_dt_pdev);
585559

586560
for_each_possible_cpu(cpu) {
587-
qcom_cpufreq_put_virt_devs(drv, cpu);
561+
dev_pm_domain_detach_list(drv->cpus[cpu].pd_list);
588562
dev_pm_opp_clear_config(drv->cpus[cpu].opp_token);
589563
}
590564
}
@@ -595,7 +569,7 @@ static int qcom_cpufreq_suspend(struct device *dev)
595569
unsigned int cpu;
596570

597571
for_each_possible_cpu(cpu)
598-
qcom_cpufreq_suspend_virt_devs(drv, cpu);
572+
qcom_cpufreq_suspend_pd_devs(drv, cpu);
599573

600574
return 0;
601575
}

drivers/gpu/drm/tegra/gr3d.c

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct gr3d {
4646
unsigned int nclocks;
4747
struct reset_control_bulk_data resets[RST_GR3D_MAX];
4848
unsigned int nresets;
49+
struct dev_pm_domain_list *pd_list;
4950

5051
DECLARE_BITMAP(addr_regs, GR3D_NUM_REGS);
5152
};
@@ -369,18 +370,13 @@ static int gr3d_power_up_legacy_domain(struct device *dev, const char *name,
369370
return 0;
370371
}
371372

372-
static void gr3d_del_link(void *link)
373-
{
374-
device_link_del(link);
375-
}
376-
377373
static int gr3d_init_power(struct device *dev, struct gr3d *gr3d)
378374
{
379-
static const char * const opp_genpd_names[] = { "3d0", "3d1", NULL };
380-
const u32 link_flags = DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME;
381-
struct device **opp_virt_devs, *pd_dev;
382-
struct device_link *link;
383-
unsigned int i;
375+
struct dev_pm_domain_attach_data pd_data = {
376+
.pd_names = (const char *[]) { "3d0", "3d1" },
377+
.num_pd_names = 2,
378+
.pd_flags = PD_FLAG_REQUIRED_OPP,
379+
};
384380
int err;
385381

386382
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)
414410
if (dev->pm_domain)
415411
return 0;
416412

417-
err = devm_pm_opp_attach_genpd(dev, opp_genpd_names, &opp_virt_devs);
418-
if (err)
413+
err = devm_pm_domain_attach_list(dev, &pd_data, &gr3d->pd_list);
414+
if (err < 0)
419415
return err;
420416

421-
for (i = 0; opp_genpd_names[i]; i++) {
422-
pd_dev = opp_virt_devs[i];
423-
if (!pd_dev) {
424-
dev_err(dev, "failed to get %s power domain\n",
425-
opp_genpd_names[i]);
426-
return -EINVAL;
427-
}
428-
429-
link = device_link_add(dev, pd_dev, link_flags);
430-
if (!link) {
431-
dev_err(dev, "failed to link to %s\n", dev_name(pd_dev));
432-
return -EINVAL;
433-
}
434-
435-
err = devm_add_action_or_reset(dev, gr3d_del_link, link);
436-
if (err)
437-
return err;
438-
}
439-
440417
return 0;
441418
}
442419

drivers/media/platform/qcom/venus/core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ static const struct venus_resources sdm845_res_v2 = {
752752
.vcodec_clks_num = 2,
753753
.vcodec_pmdomains = (const char *[]) { "venus", "vcodec0", "vcodec1" },
754754
.vcodec_pmdomains_num = 3,
755-
.opp_pmdomain = (const char *[]) { "cx", NULL },
755+
.opp_pmdomain = (const char *[]) { "cx" },
756756
.vcodec_num = 2,
757757
.max_load = 3110400, /* 4096x2160@90 */
758758
.hfi_version = HFI_VERSION_4XX,
@@ -801,7 +801,7 @@ static const struct venus_resources sc7180_res = {
801801
.vcodec_clks_num = 2,
802802
.vcodec_pmdomains = (const char *[]) { "venus", "vcodec0" },
803803
.vcodec_pmdomains_num = 2,
804-
.opp_pmdomain = (const char *[]) { "cx", NULL },
804+
.opp_pmdomain = (const char *[]) { "cx" },
805805
.vcodec_num = 1,
806806
.hfi_version = HFI_VERSION_4XX,
807807
.vpu_version = VPU_VERSION_AR50,
@@ -858,7 +858,7 @@ static const struct venus_resources sm8250_res = {
858858
.vcodec_clks_num = 1,
859859
.vcodec_pmdomains = (const char *[]) { "venus", "vcodec0" },
860860
.vcodec_pmdomains_num = 2,
861-
.opp_pmdomain = (const char *[]) { "mx", NULL },
861+
.opp_pmdomain = (const char *[]) { "mx" },
862862
.vcodec_num = 1,
863863
.max_load = 7833600,
864864
.hfi_version = HFI_VERSION_6XX,
@@ -917,7 +917,7 @@ static const struct venus_resources sc7280_res = {
917917
.vcodec_clks_num = 2,
918918
.vcodec_pmdomains = (const char *[]) { "venus", "vcodec0" },
919919
.vcodec_pmdomains_num = 2,
920-
.opp_pmdomain = (const char *[]) { "cx", NULL },
920+
.opp_pmdomain = (const char *[]) { "cx" },
921921
.vcodec_num = 1,
922922
.hfi_version = HFI_VERSION_6XX,
923923
.vpu_version = VPU_VERSION_IRIS2_1,

drivers/media/platform/qcom/venus/core.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ struct venus_format {
132132
* @vcodec1_clks: an array of vcodec1 struct clk pointers
133133
* @video_path: an interconnect handle to video to/from memory path
134134
* @cpucfg_path: an interconnect handle to cpu configuration path
135-
* @has_opp_table: does OPP table exist
136135
* @pmdomains: a pointer to a list of pmdomains
137-
* @opp_dl_venus: an device-link for device OPP
138136
* @opp_pmdomain: an OPP power-domain
139137
* @resets: an array of reset signals
140138
* @vdev_dec: a reference to video device structure for decoder instances
@@ -186,10 +184,8 @@ struct venus_core {
186184
struct clk *vcodec1_clks[VIDC_VCODEC_CLKS_NUM_MAX];
187185
struct icc_path *video_path;
188186
struct icc_path *cpucfg_path;
189-
bool has_opp_table;
190187
struct dev_pm_domain_list *pmdomains;
191-
struct device_link *opp_dl_venus;
192-
struct device *opp_pmdomain;
188+
struct dev_pm_domain_list *opp_pmdomain;
193189
struct reset_control *resets[VIDC_RESETS_NUM_MAX];
194190
struct video_device *vdev_dec;
195191
struct video_device *vdev_enc;

0 commit comments

Comments
 (0)