mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pmdomain: rockchip: do not restore QoS that was never saved
@ 2026-11-01  5:56 Jiaxing Hu
  2026-11-01 11:09 ` Shawn Lin
  0 siblings, 1 reply; 2+ messages in thread
From: Jiaxing Hu @ 2026-11-01  5:56 UTC (permalink / raw)
  To: ulfh, heiko
  Cc: sebastian.reichel, shawn.lin, finley.xiao, zhangqing, linux-pm,
	linux-rockchip, linux-arm-kernel, linux-kernel, Jiaxing Hu

rockchip_pmu_restore_qos() writes back what rockchip_pmu_save_qos() read
on the last power-off. A domain that was off when it was registered has
not been powered off by the driver yet, so on its first power-on the
restore writes the zeroed save array over the QoS reset values.

On RK3576 this is the GPU on every boot. Read back after the restore, its
QoS is all zeros; with this patch it keeps the values it powers up with,
priority 0x101, mode 3, bandwidth 0x80 and saturation 8.

Only restore after a save. Rockchip's own driver does the same with an
is_qos_saved flag.

Fixes: 074c6a422d86 ("soc: rockchip: power-domain: support qos save and restore")
Signed-off-by: Jiaxing Hu <gahing@gahingwoo.com>
---
 drivers/pmdomain/rockchip/pm-domains.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
index db3879846db6..d1c025bdaa08 100644
--- a/drivers/pmdomain/rockchip/pm-domains.c
+++ b/drivers/pmdomain/rockchip/pm-domains.c
@@ -97,6 +97,7 @@ struct rockchip_pm_domain {
 	int num_qos;
 	struct regmap **qos_regmap;
 	u32 *qos_save_regs[MAX_QOS_REGS_NUM];
+	bool qos_saved;
 	int num_clks;
 	struct clk_bulk_data *clks;
 	struct device_node *node;
@@ -474,6 +475,7 @@ static int rockchip_pmu_save_qos(struct rockchip_pm_domain *pd)
 			    QOS_EXTCONTROL,
 			    &pd->qos_save_regs[4][i]);
 	}
+	pd->qos_saved = true;
 	return 0;
 }
 
@@ -481,6 +483,14 @@ static int rockchip_pmu_restore_qos(struct rockchip_pm_domain *pd)
 {
 	int i;
 
+	/*
+	 * A domain that was off when it was registered has nothing saved yet,
+	 * and writing the zeroed array would replace the reset values the QoS
+	 * registers came up with.
+	 */
+	if (!pd->qos_saved)
+		return 0;
+
 	for (i = 0; i < pd->num_qos; i++) {
 		regmap_write(pd->qos_regmap[i],
 			     QOS_PRIORITY,

base-commit: 7649ba73f9e7e1e04d0b46213e39c79ae09dd55c
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] pmdomain: rockchip: do not restore QoS that was never saved
  2026-11-01  5:56 [PATCH] pmdomain: rockchip: do not restore QoS that was never saved Jiaxing Hu
@ 2026-11-01 11:09 ` Shawn Lin
  0 siblings, 0 replies; 2+ messages in thread
From: Shawn Lin @ 2026-11-01 11:09 UTC (permalink / raw)
  To: Jiaxing Hu, ulfh, heiko
  Cc: shawn.lin, sebastian.reichel, finley.xiao, zhangqing, linux-pm,
	linux-rockchip, linux-arm-kernel, linux-kernel

在 2026/11/01 星期日 13:56, Jiaxing Hu 写道:
> rockchip_pmu_restore_qos() writes back what rockchip_pmu_save_qos() read
> on the last power-off. A domain that was off when it was registered has
> not been powered off by the driver yet, so on its first power-on the
> restore writes the zeroed save array over the QoS reset values.
> 
> On RK3576 this is the GPU on every boot. Read back after the restore, its
> QoS is all zeros; with this patch it keeps the values it powers up with,
> priority 0x101, mode 3, bandwidth 0x80 and saturation 8.
> 

Thanks for the patch. LGTM,

Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>

> Only restore after a save. Rockchip's own driver does the same with an
> is_qos_saved flag.
> 
> Fixes: 074c6a422d86 ("soc: rockchip: power-domain: support qos save and restore")
> Signed-off-by: Jiaxing Hu <gahing@gahingwoo.com>
> ---
>   drivers/pmdomain/rockchip/pm-domains.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
> index db3879846db6..d1c025bdaa08 100644
> --- a/drivers/pmdomain/rockchip/pm-domains.c
> +++ b/drivers/pmdomain/rockchip/pm-domains.c
> @@ -97,6 +97,7 @@ struct rockchip_pm_domain {
>   	int num_qos;
>   	struct regmap **qos_regmap;
>   	u32 *qos_save_regs[MAX_QOS_REGS_NUM];
> +	bool qos_saved;
>   	int num_clks;
>   	struct clk_bulk_data *clks;
>   	struct device_node *node;
> @@ -474,6 +475,7 @@ static int rockchip_pmu_save_qos(struct rockchip_pm_domain *pd)
>   			    QOS_EXTCONTROL,
>   			    &pd->qos_save_regs[4][i]);
>   	}
> +	pd->qos_saved = true;
>   	return 0;
>   }
>   
> @@ -481,6 +483,14 @@ static int rockchip_pmu_restore_qos(struct rockchip_pm_domain *pd)
>   {
>   	int i;
>   
> +	/*
> +	 * A domain that was off when it was registered has nothing saved yet,
> +	 * and writing the zeroed array would replace the reset values the QoS
> +	 * registers came up with.
> +	 */
> +	if (!pd->qos_saved)
> +		return 0;
> +
>   	for (i = 0; i < pd->num_qos; i++) {
>   		regmap_write(pd->qos_regmap[i],
>   			     QOS_PRIORITY,
> 
> base-commit: 7649ba73f9e7e1e04d0b46213e39c79ae09dd55c


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-01 11:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-01  5:56 [PATCH] pmdomain: rockchip: do not restore QoS that was never saved Jiaxing Hu
2026-11-01 11:09 ` Shawn Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®