Re: [PATCH v2 1/2] PM / Domains: Add GENPD_FLAG_NO_SUSPEND/RESUME flags

From: Ulf Hansson
Date: Mon Aug 24 2020 - 07:12:27 EST


On Fri, 21 Aug 2020 at 22:49, Sibi Sankar <sibis@xxxxxxxxxxxxxx> wrote:
>
> Add GENPD_FLAG_NO_SUSPEND/RESUME flags to instruct genpd to keep the
> status of the PM domain unaltered during suspend/resume respectively.
> The flags are aimed at power domains coupled to co-processors which
> enter low-power modes independent to that of the application processor.
>
> Specifically the flags are to be used by the power domains exposed
> by the AOSS QMP driver linked to modem, adsp, cdsp remoteprocs. These
> power domains are used to notify the Always on Subsystem (AOSS) that
> a particular co-processor is up. AOSS uses this information to wait
> for the co-processors to suspend before starting its sleep sequence.
> The application processor powers off these power domains only if the
> co-processor has crashed or powered off and remains unaltered during
> system suspend/resume.
>
> Signed-off-by: Sibi Sankar <sibis@xxxxxxxxxxxxxx>

Reviewed-by: Ulf Hansson <ulf.hansson@xxxxxxxxxx>

Although, I would like Stephen's question to get an answer in the
other thread, before this gets applied.

Kind regards
Uffe

> ---
>
> V2:
> * Add more info in commit msg and description [Uffe/Kevin/Stephen]
> * Rename and split functionality into two flags [Uffe]
> * Drop R-b/T-b
>
> drivers/base/power/domain.c | 6 ++++--
> include/linux/pm_domain.h | 10 ++++++++++
> 2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 2cb5e04cf86cd..a5df5916f30f8 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -129,6 +129,8 @@ static const struct genpd_lock_ops genpd_spin_ops = {
> #define genpd_is_active_wakeup(genpd) (genpd->flags & GENPD_FLAG_ACTIVE_WAKEUP)
> #define genpd_is_cpu_domain(genpd) (genpd->flags & GENPD_FLAG_CPU_DOMAIN)
> #define genpd_is_rpm_always_on(genpd) (genpd->flags & GENPD_FLAG_RPM_ALWAYS_ON)
> +#define genpd_is_no_suspend(genpd) (genpd->flags & GENPD_FLAG_NO_SUSPEND)
> +#define genpd_is_no_resume(genpd) (genpd->flags & GENPD_FLAG_NO_RESUME)
>
> static inline bool irq_safe_dev_in_no_sleep_domain(struct device *dev,
> const struct generic_pm_domain *genpd)
> @@ -949,7 +951,7 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock,
> {
> struct gpd_link *link;
>
> - if (!genpd_status_on(genpd) || genpd_is_always_on(genpd))
> + if (!genpd_status_on(genpd) || genpd_is_always_on(genpd) || genpd_is_no_suspend(genpd))
> return;
>
> if (genpd->suspended_count != genpd->device_count
> @@ -991,7 +993,7 @@ static void genpd_sync_power_on(struct generic_pm_domain *genpd, bool use_lock,
> {
> struct gpd_link *link;
>
> - if (genpd_status_on(genpd))
> + if (genpd_status_on(genpd) || genpd_is_no_resume(genpd))
> return;
>
> list_for_each_entry(link, &genpd->child_links, child_node) {
> diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
> index ee11502a575b0..568abdf2e89cf 100644
> --- a/include/linux/pm_domain.h
> +++ b/include/linux/pm_domain.h
> @@ -55,6 +55,14 @@
> *
> * GENPD_FLAG_RPM_ALWAYS_ON: Instructs genpd to always keep the PM domain
> * powered on except for system suspend.
> + *
> + * GENPD_FLAG_NO_SUSPEND: Instructs genpd to keep the PM domain powered
> + * on during suspend (if it's already powered on)
> + * and runtime PM controlled otherwise.
> + *
> + * GENPD_FLAG_NO_RESUME: Instructs genpd to keep the PM domain powered
> + * off during resume (if it's already powered off)
> + * and runtime PM controlled otherwise.
> */
> #define GENPD_FLAG_PM_CLK (1U << 0)
> #define GENPD_FLAG_IRQ_SAFE (1U << 1)
> @@ -62,6 +70,8 @@
> #define GENPD_FLAG_ACTIVE_WAKEUP (1U << 3)
> #define GENPD_FLAG_CPU_DOMAIN (1U << 4)
> #define GENPD_FLAG_RPM_ALWAYS_ON (1U << 5)
> +#define GENPD_FLAG_NO_SUSPEND (1U << 6)
> +#define GENPD_FLAG_NO_RESUME (1U << 7)
>
> enum gpd_status {
> GPD_STATE_ACTIVE = 0, /* PM domain is active */
> --
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
>