Re: [PATCH] soc: qcom: rpmh-rsc: Write the sleep and wake sets again after hibernation

From: Maulik Shah

Date: Mon Nov 30 2026 - 00:19:30 EST




On 20-11-2026 20:38, Abel Vesa wrote:
> +/*
> + * A hibernation image is restored by another kernel, which filled the sleep
> + * and wake TCSes with its own votes. Our cache still says they hold ours, so
> + * rpmh_flush() would never write them again and the next power collapse would
> + * use what the other kernel left behind. Write them again before that.
> + */
> +static int rpmh_rsc_restore_early(struct device *dev)
> +{
> + struct rsc_drv *drv = dev_get_drvdata(dev);
> + unsigned long flags;
> +
> + spin_lock_irqsave(&drv->client.cache_lock, flags);
> + drv->client.dirty = true;
> + spin_unlock_irqrestore(&drv->client.cache_lock, flags);
> +
> + return 0;
> +}
> +
> +static const struct dev_pm_ops rpmh_rsc_pm_ops = {
> + .restore_early = pm_sleep_ptr(rpmh_rsc_restore_early),
> +};

Its very likely that client would have already send a new/updated vote before the restore_early phase,
for example, PCIe maps its .restore_noirq same as .resume_noirq,

qcom_pcie_resume_noirq()   → icc_enable()    → qcom_icc_set()    → qcom_icc_bcm_voter_commit()    → rpmh_invalidate()
would have updated dirty cache flag. So this callback be needed to be moved to .restore_noirq stage or even before actual voting re-starts
or the idle low power mode happens.

For the RSCs using the CPU PM notifier fallback (not using power-domains property), When the saved image resumes
cpuidle gets enabled in syscore stage.

syscore_resume() => pm_sleep_enable_secondary_cpus() => cpuidle_resume(),

If all CPUs enter idle while device restoration is pending, the last CPU can therefore reach rpmh_rsc_cpu_pm_callback()
and rpmh_flush() while the restored dirty flag is still false.

so need to re-set this dirty flag in the syscore ops, resume callback.

Thanks,
Maulik