Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: qcom: Support attaching GDSCs to multiple parents

When a clock-controller lists multiple power-domains we need make each GDSC a
subdomain of each of the clock-controller's listed power-domains.

GDSCs without an explicitly defined parent should be a subdomain of each of
the clock-controller's listed power-domains.

GDSCs with an explicitly defined parent should attach only to the parent
GDSC and not the listed power-domains. Any votes will trickle through the
hierarchy up to the external power-domains.

========================================
:: arch/arm64/boot/dts/example.dtsi ::
========================================

clockcc: clock-controller@0 {
compat ="qcom,example-clockcc";
power-domains = <&pd_a, &pd_b>;
}

========================================
:: drivers/clk/qcom/example-clockcc.c ::
========================================

static struct gdsc parent_gdsc = {
.pd = {
.name = "parent_gdsc",
},
};

static struct gdsc child0_gdsc = {
.pd = {
.name = "child0_gdsc",
},
.parent = &parent_gdsc.pd,
};

static struct gdsc child1_gdsc = {
.pd = {
.name = "child1_gdsc",
},
.parent = &parent_gdsc.pd,
};

========================================
:: power-subdomains ::
========================================

pm-domain::pd_a
└── pm-subdomain::clockcc::parent_gdsc
├── pm-subdomain::clockcc::child0_gdsc
└── pm-subdomain::clockcc::child1_gdsc

pm-domain::pd_b
└── pm-subdomain::clockcc::parent_gdsc
├── pm-subdomain::clockcc::child1_gdsc
└── pm-subdomain::clockcc::child2_gdsc

The performance states will percolate through the pm-domain hierarchy to
the domains that handle the relevant states.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Link: https://lore.kernel.org/r/20250117-b4-linux-next-24-11-18-clock-multiple-power-domains-v10-4-13f2bb656dad@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Bryan O'Donoghue and committed by
Bjorn Andersson
b489235b ed5a0d06

+37
+1
drivers/clk/qcom/common.c
··· 323 323 scd->dev = dev; 324 324 scd->scs = desc->gdscs; 325 325 scd->num = desc->num_gdscs; 326 + scd->pd_list = cc->pd_list; 326 327 ret = gdsc_register(scd, &reset->rcdev, regmap); 327 328 if (ret) 328 329 return ret;
+35
drivers/clk/qcom/gdsc.c
··· 506 506 return ret; 507 507 } 508 508 509 + static int gdsc_add_subdomain_list(struct dev_pm_domain_list *pd_list, 510 + struct generic_pm_domain *subdomain) 511 + { 512 + int i, ret; 513 + 514 + for (i = 0; i < pd_list->num_pds; i++) { 515 + struct device *dev = pd_list->pd_devs[i]; 516 + struct generic_pm_domain *genpd = pd_to_genpd(dev->pm_domain); 517 + 518 + ret = pm_genpd_add_subdomain(genpd, subdomain); 519 + if (ret) 520 + return ret; 521 + } 522 + 523 + return 0; 524 + } 525 + 526 + static void gdsc_remove_subdomain_list(struct dev_pm_domain_list *pd_list, 527 + struct generic_pm_domain *subdomain) 528 + { 529 + int i; 530 + 531 + for (i = 0; i < pd_list->num_pds; i++) { 532 + struct device *dev = pd_list->pd_devs[i]; 533 + struct generic_pm_domain *genpd = pd_to_genpd(dev->pm_domain); 534 + 535 + pm_genpd_remove_subdomain(genpd, subdomain); 536 + } 537 + } 538 + 509 539 static void gdsc_pm_subdomain_remove(struct gdsc_desc *desc, size_t num) 510 540 { 511 541 struct device *dev = desc->dev; ··· 550 520 pm_genpd_remove_subdomain(scs[i]->parent, &scs[i]->pd); 551 521 else if (!IS_ERR_OR_NULL(dev->pm_domain)) 552 522 pm_genpd_remove_subdomain(pd_to_genpd(dev->pm_domain), &scs[i]->pd); 523 + else if (desc->pd_list) 524 + gdsc_remove_subdomain_list(desc->pd_list, &scs[i]->pd); 553 525 } 554 526 } 555 527 ··· 607 575 ret = pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd); 608 576 else if (!IS_ERR_OR_NULL(dev->pm_domain)) 609 577 ret = pm_genpd_add_subdomain(pd_to_genpd(dev->pm_domain), &scs[i]->pd); 578 + else if (desc->pd_list) 579 + ret = gdsc_add_subdomain_list(desc->pd_list, &scs[i]->pd); 580 + 610 581 if (ret) 611 582 goto err_pm_subdomain_remove; 612 583 }
+1
drivers/clk/qcom/gdsc.h
··· 80 80 struct device *dev; 81 81 struct gdsc **scs; 82 82 size_t num; 83 + struct dev_pm_domain_list *pd_list; 83 84 }; 84 85 85 86 #ifdef CONFIG_QCOM_GDSC