Skip to contentSkip to conversation

pmdomain: rockchip: do not restore QoS that was never saved

PATCH In review Jiaxing Hu 3 participants 3 messages Nov 1 – Nov 2

Subsystems (2)
lore
Share & tools
lore

Jiaxing Hu

author
#0 lore raw

PATCH 1/1 pmdomain: rockchip: do not restore QoS that was never saved

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")
---
 drivers/pmdomain/rockchip/pm-domains.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/pmdomain/rockchip/pm-domains.c +10 -0
index db3879846db6..d1c025bdaa08 100644
@@ -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

Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · 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,

Quoted 46 lines

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")
---
  drivers/pmdomain/rockchip/pm-domains.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
drivers/pmdomain/rockchip/pm-domains.c +10 -0
index db3879846db6..d1c025bdaa08 100644
@@ -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

Reviewed-by on v1 1/1
#2 lore raw
In reply to Jiaxing Hu
Quoted 23 lines · 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")
---
  drivers/pmdomain/rockchip/pm-domains.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
drivers/pmdomain/rockchip/pm-domains.c +0 -0
index db3879846db6..d1c025bdaa08 100644

drivers/pmdomain/rockchip/pm-domains.c struct rockchip_pm_domain { · line 100

Quoted 4 lines
drivers/pmdomain/rockchip/pm-domains.c +1 -0
@@ -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;

The fix itself looks correct. One minor nit: the downstream Rockchip kernel implements the same guard with a flag named is_qos_saved (you already reference it in the commit log). Reusing that exact name would make it easier to correlate with the vendor tree when debugging or backporting QoS issues like the RK3576 GPU case.

Quoted 28 lines
drivers/pmdomain/rockchip/pm-domains.c +9 -0
  	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

Signature · 10 lines
Best regards,

底层平台中心 肖锋(Finley Xiao)
************************************************************************************
瑞芯微电子股份有限公司
Rockchip Electronics Co., Ltd.
福建省福州市铜盘路软件大道89号软件园A区21号楼 350003
No.21 Building, A District, Fuzhou Software Park, Fuzhou, Fujian 350003, P.R. China
Tel: 0591-83991906-8602 Mobile: 18506057603
************************************************************************************