Skip to contentSkip to conversation

clk: qcom:

PATCH Superseded Jordan Crouse 2 participants 5 messages Nov 26, 2018 – Nov 29, 2018

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#1 lore raw

PATCH 1/2 clk: qcom: gdsc: Don't override existing gdsc pd functions

In reply to Jordan Crouse

In extreme cases an individual gdsc may wish to override the power domain enable or disable callback functions for their own purposes. Only set the generic gdsc callback if the function pointers are not already set.

---
 drivers/clk/qcom/gdsc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/clk/qcom/gdsc.c +4 -2
index a077133c7ce3..dd63aa36b092 100644
@@ -350,8 +350,10 @@ static int gdsc_init(struct gdsc *sc)
 	else
 		gdsc_clear_mem_on(sc);
 
-	sc->pd.power_off = gdsc_disable;
-	sc->pd.power_on = gdsc_enable;
+	if (!sc->pd.power_off)
+		sc->pd.power_off = gdsc_disable;
+	if (!sc->pd.power_on)
+		sc->pd.power_on = gdsc_enable;
 	pm_genpd_init(&sc->pd, NULL, !on);
 
 	return 0;
Signature · 1 line
2.18.0
#3 lore raw

PATCH 2/2 clk: qcom: Add a dummy enable function for GX gdsc

In reply to Jordan Crouse

Most of the time the CPU should not be touching the GX domain on the GPU except for a very special use case when the CPU needs to force the GX headswitch off. Add a dummy enable function for the GX gdsc to simulate success so that the pm_runtime reference counting is correct.

---
 drivers/clk/qcom/gpucc-sdm845.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/clk/qcom/gpucc-sdm845.c +26 -0
index 11222f487a65..7266e9a1d77e 100644
@@ -131,11 +131,37 @@ static struct gdsc gpu_cx_gdsc = {
 	.flags = VOTABLE,
 };
 
+/*
+ * On SDM845 the GPU GX domain is *almost* entirely controlled by the GMU
+ * running in the CX domain so the CPU doesn't need to know anything about the
+ * GX domain EXCEPT....
+ *
+ * Hardware constraints dictate that the GX be powered down before the CX. If
+ * the GMU crashes it could leave the GX on. In order to successfully bring back
+ * the device the CPU needs to disable the GX headswitch. There being no sane
+ * way to reach in and touch that register from deep inside the GPU driver we
+ * need to set up the infrastructure to be able to ensure that the GPU can
+ * ensure that the GX is off during this super special case. We do this by
+ * defining a GX gdsc with a dummy enable function and a "default" disable
+ * function.
+ *
+ * This allows us to attach with genpd_dev_pm_attach_by_name() in the GPU
+ * driver. During power up, nothing will happen from the CPU (and the GMU will
+ * power up normally but during power down this will ensure that the GX domain
+ * is *really* off - this gives us a semi standard way of doing what we need.
+ */
+static int gx_gdsc_enable(struct generic_pm_domain *domain)
+{
+	/* Do nothing but give genpd the impression that we were successful */
+	return 0;
+}
+
 static struct gdsc gpu_gx_gdsc = {
 	.gdscr = 0x100c,
 	.clamp_io_ctrl = 0x1508,
 	.pd = {
 		.name = "gpu_gx_gdsc",
+		.power_on = gx_gdsc_enable,
 	},
 	.pwrsts = PWRSTS_OFF_ON,
 	.flags = CLAMP_IO | AON_RESET | POLL_CFG_GDSCR,
Signature · 1 line
2.18.0
#0 lore raw

cover clk: qcom:

The GPU GX domain on SDM845 is nominally managed by the GMU microcontroller but there are certain circumstances when the CPU needs to be sure that the GX headswitch is off.

This series modifies the GPU GX domain on SDM845 to use a dummy enable function (leaving the GMU hardware to handle the power on) and the default disable function to allow the CPU to ensure that the power is off.

With these changes we can attach the domain to the GMU device and control it from the start up and shut down functions as implemented by [2].

This patchset is based on the core GPU clock support from [1].

[1] https://patchwork.kernel.org/patch/10696671/
[2] https://patchwork.freedesktop.org/patch/262765/

v2: Rebase on the latest from Taniya and remove the GPU functions to make it easier to apply to the clock tree.

Jordan Crouse (2):
clk: qcom: gdsc: Don't override existing gdsc pd functions
clk: qcom: Add a dummy enable function for GX gdsc

 drivers/clk/qcom/gdsc.c         |  6 ++++--
 drivers/clk/qcom/gpucc-sdm845.c | 26 ++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 2 deletions(-)
Signature · 1 line
2.18.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] clk: qcom: gdsc: Don't override existing gdsc pd functions

In reply to Jordan Crouse
Quoted 6 lines · Jordan Crouse

In extreme cases an individual gdsc may wish to override the power domain enable or disable callback functions for their own purposes. Only set the generic gdsc callback if the function pointers are not already set.

Regards,
Bjorn

Quoted 25 lines
---
 drivers/clk/qcom/gdsc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/clk/qcom/gdsc.c +4 -2
index a077133c7ce3..dd63aa36b092 100644
@@ -350,8 +350,10 @@ static int gdsc_init(struct gdsc *sc)
 	else
 		gdsc_clear_mem_on(sc);
 
-	sc->pd.power_off = gdsc_disable;
-	sc->pd.power_on = gdsc_enable;
+	if (!sc->pd.power_off)
+		sc->pd.power_off = gdsc_disable;
+	if (!sc->pd.power_on)
+		sc->pd.power_on = gdsc_enable;
 	pm_genpd_init(&sc->pd, NULL, !on);
 
 	return 0;
Signature · 1 line
2.18.0
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] clk: qcom: Add a dummy enable function for GX gdsc

In reply to Jordan Crouse
Quoted 7 lines · Jordan Crouse

Most of the time the CPU should not be touching the GX domain on the GPU except for a very special use case when the CPU needs to force the GX headswitch off. Add a dummy enable function for the GX gdsc to simulate success so that the pm_runtime reference counting is correct.

Regards,
Bjorn

Quoted 49 lines
---
 drivers/clk/qcom/gpucc-sdm845.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/clk/qcom/gpucc-sdm845.c +26 -0
index 11222f487a65..7266e9a1d77e 100644
@@ -131,11 +131,37 @@ static struct gdsc gpu_cx_gdsc = {
 	.flags = VOTABLE,
 };
 
+/*
+ * On SDM845 the GPU GX domain is *almost* entirely controlled by the GMU
+ * running in the CX domain so the CPU doesn't need to know anything about the
+ * GX domain EXCEPT....
+ *
+ * Hardware constraints dictate that the GX be powered down before the CX. If
+ * the GMU crashes it could leave the GX on. In order to successfully bring back
+ * the device the CPU needs to disable the GX headswitch. There being no sane
+ * way to reach in and touch that register from deep inside the GPU driver we
+ * need to set up the infrastructure to be able to ensure that the GPU can
+ * ensure that the GX is off during this super special case. We do this by
+ * defining a GX gdsc with a dummy enable function and a "default" disable
+ * function.
+ *
+ * This allows us to attach with genpd_dev_pm_attach_by_name() in the GPU
+ * driver. During power up, nothing will happen from the CPU (and the GMU will
+ * power up normally but during power down this will ensure that the GX domain
+ * is *really* off - this gives us a semi standard way of doing what we need.
+ */
+static int gx_gdsc_enable(struct generic_pm_domain *domain)
+{
+	/* Do nothing but give genpd the impression that we were successful */
+	return 0;
+}
+
 static struct gdsc gpu_gx_gdsc = {
 	.gdscr = 0x100c,
 	.clamp_io_ctrl = 0x1508,
 	.pd = {
 		.name = "gpu_gx_gdsc",
+		.power_on = gx_gdsc_enable,
 	},
 	.pwrsts = PWRSTS_OFF_ON,
 	.flags = CLAMP_IO | AON_RESET | POLL_CFG_GDSCR,
Signature · 1 line
2.18.0