linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] bus: ti-sysc: fix reset sequencing
@ 2019-10-07 12:29 Tero Kristo
  2019-10-07 12:29 ` [PATCH 1/3] bus: ti-sysc: re-order reset and main clock controls Tero Kristo
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Tero Kristo @ 2019-10-07 12:29 UTC (permalink / raw)
  To: linux-omap, tony; +Cc: linux-arm-kernel

Hi,

These three patches make sure that IOMMU/remoteprocs work across
all devices with the latest OMAP PRM series for reset support [1].
The last dangling issues were caused by the removal of the hardlink
between the reset + clock drivers.

-Tero

[1] https://patchwork.kernel.org/cover/11142871/


--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 1/3] bus: ti-sysc: re-order reset and main clock controls
  2019-10-07 12:29 [PATCH 0/3] bus: ti-sysc: fix reset sequencing Tero Kristo
@ 2019-10-07 12:29 ` Tero Kristo
  2019-10-07 12:29 ` [PATCH 2/3] bus: ti-sysc: drop the extra hardreset during init Tero Kristo
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Tero Kristo @ 2019-10-07 12:29 UTC (permalink / raw)
  To: linux-omap, tony; +Cc: linux-arm-kernel

The main clocks and reset controls have a hardware level dependency,
where one can't transition state without the other one transitioning.
Because we don't have the dependency implemented in software, we must
ensure the ordering of these two is done properly; they way this is
handled is that clocks transition on software level without delay,
and the status is only polled on reset side. Because of this, we must
re-order the main clock and reset handling on the ti-sysc driver.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 drivers/bus/ti-sysc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
index 193d8b23d54d..c9d01e2d3a64 100644
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -1032,8 +1032,6 @@ static int __maybe_unused sysc_runtime_resume_legacy(struct device *dev,
 	struct ti_sysc_platform_data *pdata;
 	int error;
 
-	reset_control_deassert(ddata->rsts);
-
 	pdata = dev_get_platdata(ddata->dev);
 	if (!pdata)
 		return 0;
@@ -1046,6 +1044,8 @@ static int __maybe_unused sysc_runtime_resume_legacy(struct device *dev,
 		dev_err(dev, "%s: could not enable: %i\n",
 			__func__, error);
 
+	reset_control_deassert(ddata->rsts);
+
 	return 0;
 }
 
@@ -1099,8 +1099,6 @@ static int __maybe_unused sysc_runtime_resume(struct device *dev)
 
 	sysc_clkdm_deny_idle(ddata);
 
-	reset_control_deassert(ddata->rsts);
-
 	if (sysc_opt_clks_needed(ddata)) {
 		error = sysc_enable_opt_clocks(ddata);
 		if (error)
@@ -1111,6 +1109,8 @@ static int __maybe_unused sysc_runtime_resume(struct device *dev)
 	if (error)
 		goto err_opt_clocks;
 
+	reset_control_deassert(ddata->rsts);
+
 	if (ddata->legacy_mode) {
 		error = sysc_runtime_resume_legacy(dev, ddata);
 		if (error)
-- 
2.17.1

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/3] bus: ti-sysc: drop the extra hardreset during init
  2019-10-07 12:29 [PATCH 0/3] bus: ti-sysc: fix reset sequencing Tero Kristo
  2019-10-07 12:29 ` [PATCH 1/3] bus: ti-sysc: re-order reset and main clock controls Tero Kristo
@ 2019-10-07 12:29 ` Tero Kristo
  2019-10-07 12:29 ` [PATCH 3/3] bus: ti-sysc: avoid toggling power state of module during probe Tero Kristo
  2019-10-07 16:38 ` [PATCH 0/3] bus: ti-sysc: fix reset sequencing Tony Lindgren
  3 siblings, 0 replies; 7+ messages in thread
From: Tero Kristo @ 2019-10-07 12:29 UTC (permalink / raw)
  To: linux-omap, tony; +Cc: linux-arm-kernel

There seems to be unnecessary extra hardreset line toggling applied
during module init. This is unnecessary, as the reset lines are already
asserted during boot, and it can cause certain modules to hang (iommus,
remoteprocs.) Remove the extra hardreset toggle, and remove the now
redundant function to handle this also.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 drivers/bus/ti-sysc.c | 37 +------------------------------------
 1 file changed, 1 insertion(+), 36 deletions(-)

diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
index c9d01e2d3a64..6f392469d5b0 100644
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -1518,37 +1518,6 @@ static int sysc_legacy_init(struct sysc *ddata)
 	return error;
 }
 
-/**
- * sysc_rstctrl_reset_deassert - deassert rstctrl reset
- * @ddata: device driver data
- * @reset: reset before deassert
- *
- * A module can have both OCP softreset control and external rstctrl.
- * If more complicated rstctrl resets are needed, please handle these
- * directly from the child device driver and map only the module reset
- * for the parent interconnect target module device.
- *
- * Automatic reset of the module on init can be skipped with the
- * "ti,no-reset-on-init" device tree property.
- */
-static int sysc_rstctrl_reset_deassert(struct sysc *ddata, bool reset)
-{
-	int error;
-
-	if (!ddata->rsts)
-		return 0;
-
-	if (reset) {
-		error = reset_control_assert(ddata->rsts);
-		if (error)
-			return error;
-	}
-
-	reset_control_deassert(ddata->rsts);
-
-	return 0;
-}
-
 /*
  * Note that the caller must ensure the interconnect target module is enabled
  * before calling reset. Otherwise reset will not complete.
@@ -1613,10 +1582,6 @@ static int sysc_init_module(struct sysc *ddata)
 	int error = 0;
 	bool manage_clocks = true;
 
-	error = sysc_rstctrl_reset_deassert(ddata, false);
-	if (error)
-		return error;
-
 	if (ddata->cfg.quirks &
 	    (SYSC_QUIRK_NO_IDLE | SYSC_QUIRK_NO_IDLE_ON_INIT))
 		manage_clocks = false;
@@ -1640,7 +1605,7 @@ static int sysc_init_module(struct sysc *ddata)
 		goto err_opt_clocks;
 
 	if (!(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)) {
-		error = sysc_rstctrl_reset_deassert(ddata, true);
+		error = reset_control_deassert(ddata->rsts);
 		if (error)
 			goto err_main_clocks;
 	}
-- 
2.17.1

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 3/3] bus: ti-sysc: avoid toggling power state of module during probe
  2019-10-07 12:29 [PATCH 0/3] bus: ti-sysc: fix reset sequencing Tero Kristo
  2019-10-07 12:29 ` [PATCH 1/3] bus: ti-sysc: re-order reset and main clock controls Tero Kristo
  2019-10-07 12:29 ` [PATCH 2/3] bus: ti-sysc: drop the extra hardreset during init Tero Kristo
@ 2019-10-07 12:29 ` Tero Kristo
  2019-10-07 16:38 ` [PATCH 0/3] bus: ti-sysc: fix reset sequencing Tony Lindgren
  3 siblings, 0 replies; 7+ messages in thread
From: Tero Kristo @ 2019-10-07 12:29 UTC (permalink / raw)
  To: linux-omap, tony; +Cc: linux-arm-kernel

Current implementation for ti-sysc powers down the module once module
init is complete. However, right after power is disabled, it is enabled
via runtime PM. This is unnecessary so avoid it by re-ordering the
events a bit; move powering down of the module post runtime PM enable
which makes sure the use counts are maintained properly and there is
no extra power down/up sequence for the module.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 drivers/bus/ti-sysc.c | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
index 6f392469d5b0..5b69457fa857 100644
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -1580,11 +1580,6 @@ static int sysc_reset(struct sysc *ddata)
 static int sysc_init_module(struct sysc *ddata)
 {
 	int error = 0;
-	bool manage_clocks = true;
-
-	if (ddata->cfg.quirks &
-	    (SYSC_QUIRK_NO_IDLE | SYSC_QUIRK_NO_IDLE_ON_INIT))
-		manage_clocks = false;
 
 	error = sysc_clockdomain_init(ddata);
 	if (error)
@@ -1617,28 +1612,32 @@ static int sysc_init_module(struct sysc *ddata)
 	if (ddata->legacy_mode) {
 		error = sysc_legacy_init(ddata);
 		if (error)
-			goto err_main_clocks;
+			goto err_reset;
 	}
 
 	if (!ddata->legacy_mode) {
 		error = sysc_enable_module(ddata->dev);
 		if (error)
-			goto err_main_clocks;
+			goto err_reset;
 	}
 
 	error = sysc_reset(ddata);
 	if (error)
 		dev_err(ddata->dev, "Reset failed with %d\n", error);
 
-	if (!ddata->legacy_mode && manage_clocks)
+	if (error && !ddata->legacy_mode)
 		sysc_disable_module(ddata->dev);
 
+err_reset:
+	if (error && !(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT))
+		reset_control_assert(ddata->rsts);
+
 err_main_clocks:
-	if (manage_clocks)
+	if (error)
 		sysc_disable_main_clocks(ddata);
 err_opt_clocks:
 	/* No re-enable of clockdomain autoidle to prevent module autoidle */
-	if (manage_clocks) {
+	if (error) {
 		sysc_disable_opt_clocks(ddata);
 		sysc_clkdm_allow_idle(ddata);
 	}
@@ -2411,9 +2410,16 @@ static int sysc_probe(struct platform_device *pdev)
 		goto unprepare;
 	}
 
-	/* Balance reset counts */
-	if (ddata->rsts)
-		reset_control_assert(ddata->rsts);
+	/* Balance use counts as PM runtime should have enabled these all */
+	if (!(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT))
+		reset_control_assert(ddata->rsts);
+
+	if (!(ddata->cfg.quirks &
+	      (SYSC_QUIRK_NO_IDLE | SYSC_QUIRK_NO_IDLE_ON_INIT))) {
+		sysc_disable_main_clocks(ddata);
+		sysc_disable_opt_clocks(ddata);
+		sysc_clkdm_allow_idle(ddata);
+	}
 
 	sysc_show_registers(ddata);
 
-- 
2.17.1

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 0/3] bus: ti-sysc: fix reset sequencing
  2019-10-07 12:29 [PATCH 0/3] bus: ti-sysc: fix reset sequencing Tero Kristo
                   ` (2 preceding siblings ...)
  2019-10-07 12:29 ` [PATCH 3/3] bus: ti-sysc: avoid toggling power state of module during probe Tero Kristo
@ 2019-10-07 16:38 ` Tony Lindgren
  2019-10-07 19:00   ` Tero Kristo
  3 siblings, 1 reply; 7+ messages in thread
From: Tony Lindgren @ 2019-10-07 16:38 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, linux-arm-kernel

* Tero Kristo <t-kristo@ti.com> [191007 12:30]:
> Hi,
> 
> These three patches make sure that IOMMU/remoteprocs work across
> all devices with the latest OMAP PRM series for reset support [1].
> The last dangling issues were caused by the removal of the hardlink
> between the reset + clock drivers.

OK. I presume these are safe to wait for v5.5 since we don't
have the rstctrl driver yet?

Regards,

Tony


> [1] https://patchwork.kernel.org/cover/11142871/
> 
> 
> --
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 0/3] bus: ti-sysc: fix reset sequencing
  2019-10-07 16:38 ` [PATCH 0/3] bus: ti-sysc: fix reset sequencing Tony Lindgren
@ 2019-10-07 19:00   ` Tero Kristo
  2019-10-08 14:09     ` Tony Lindgren
  0 siblings, 1 reply; 7+ messages in thread
From: Tero Kristo @ 2019-10-07 19:00 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, linux-arm-kernel

On 07/10/2019 19:38, Tony Lindgren wrote:
> * Tero Kristo <t-kristo@ti.com> [191007 12:30]:
>> Hi,
>>
>> These three patches make sure that IOMMU/remoteprocs work across
>> all devices with the latest OMAP PRM series for reset support [1].
>> The last dangling issues were caused by the removal of the hardlink
>> between the reset + clock drivers.
> 
> OK. I presume these are safe to wait for v5.5 since we don't
> have the rstctrl driver yet?

Yeah, they are safe to wait.

-Tero
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 0/3] bus: ti-sysc: fix reset sequencing
  2019-10-07 19:00   ` Tero Kristo
@ 2019-10-08 14:09     ` Tony Lindgren
  0 siblings, 0 replies; 7+ messages in thread
From: Tony Lindgren @ 2019-10-08 14:09 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, linux-arm-kernel

* Tero Kristo <t-kristo@ti.com> [191007 19:00]:
> On 07/10/2019 19:38, Tony Lindgren wrote:
> > * Tero Kristo <t-kristo@ti.com> [191007 12:30]:
> > > Hi,
> > > 
> > > These three patches make sure that IOMMU/remoteprocs work across
> > > all devices with the latest OMAP PRM series for reset support [1].
> > > The last dangling issues were caused by the removal of the hardlink
> > > between the reset + clock drivers.
> > 
> > OK. I presume these are safe to wait for v5.5 since we don't
> > have the rstctrl driver yet?
> 
> Yeah, they are safe to wait.

OK applying into omap-for-v5.5/ti-sysc thanks.

Tony

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-10-08 14:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-07 12:29 [PATCH 0/3] bus: ti-sysc: fix reset sequencing Tero Kristo
2019-10-07 12:29 ` [PATCH 1/3] bus: ti-sysc: re-order reset and main clock controls Tero Kristo
2019-10-07 12:29 ` [PATCH 2/3] bus: ti-sysc: drop the extra hardreset during init Tero Kristo
2019-10-07 12:29 ` [PATCH 3/3] bus: ti-sysc: avoid toggling power state of module during probe Tero Kristo
2019-10-07 16:38 ` [PATCH 0/3] bus: ti-sysc: fix reset sequencing Tony Lindgren
2019-10-07 19:00   ` Tero Kristo
2019-10-08 14:09     ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).