linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] bus: ti-sysc: fixes for reset handling
@ 2019-08-07 12:46 Tero Kristo
  2019-08-07 12:46 ` [PATCH 1/3] bus: ti-sysc: re-order the clkdm control around " Tero Kristo
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Tero Kristo @ 2019-08-07 12:46 UTC (permalink / raw)
  To: linux-omap, tony, s-anna; +Cc: linux-kernel

Hi,

Here are a few patches to fix reset handling for ti-sysc bus driver.
Without these, the iommu won't be working properly at least.

-Tero

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

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

* [PATCH 1/3] bus: ti-sysc: re-order the clkdm control around reset handling
  2019-08-07 12:46 [PATCH 0/3] bus: ti-sysc: fixes for reset handling Tero Kristo
@ 2019-08-07 12:46 ` Tero Kristo
  2019-08-07 12:46 ` [PATCH 2/3] bus: ti-sysc: rework the " Tero Kristo
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Tero Kristo @ 2019-08-07 12:46 UTC (permalink / raw)
  To: linux-omap, tony, s-anna; +Cc: linux-kernel

Parenting clockdomain for the IP should be enabled during the reset
handling logic, otherwise the reset may not finish properly. Re-order
the clockdomain control logic to avoid this.

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

diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
index e6deabd..ad9c6d3 100644
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -1091,11 +1091,11 @@ static int __maybe_unused sysc_runtime_suspend(struct device *dev)
 	ddata->enabled = false;
 
 err_allow_idle:
-	sysc_clkdm_allow_idle(ddata);
-
 	if (ddata->disable_on_idle)
 		reset_control_assert(ddata->rsts);
 
+	sysc_clkdm_allow_idle(ddata);
+
 	return error;
 }
 
@@ -1109,11 +1109,12 @@ static int __maybe_unused sysc_runtime_resume(struct device *dev)
 	if (ddata->enabled)
 		return 0;
 
-	if (ddata->disable_on_idle)
-		reset_control_deassert(ddata->rsts);
 
 	sysc_clkdm_deny_idle(ddata);
 
+	if (ddata->disable_on_idle)
+		reset_control_deassert(ddata->rsts);
+
 	if (sysc_opt_clks_needed(ddata)) {
 		error = sysc_enable_opt_clocks(ddata);
 		if (error)
-- 
1.9.1

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

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

* [PATCH 2/3] bus: ti-sysc: rework the reset handling
  2019-08-07 12:46 [PATCH 0/3] bus: ti-sysc: fixes for reset handling Tero Kristo
  2019-08-07 12:46 ` [PATCH 1/3] bus: ti-sysc: re-order the clkdm control around " Tero Kristo
@ 2019-08-07 12:46 ` Tero Kristo
  2019-08-07 12:46 ` [PATCH 3/3] bus: ti-sysc: allow reset sharing across devices Tero Kristo
  2019-08-13 11:33 ` [PATCH 0/3] bus: ti-sysc: fixes for reset handling Tony Lindgren
  3 siblings, 0 replies; 5+ messages in thread
From: Tero Kristo @ 2019-08-07 12:46 UTC (permalink / raw)
  To: linux-omap, tony, s-anna; +Cc: linux-kernel

If reset controllers are assigned to the ti-sysc target-module, only
ti-sysc is going to be able to control these. Thus, remove all the
disable_on_idle flag usage, and assert/de-assert the reset always
in the idle path. Otherwise the reset signal will always just be
de-asserted.

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

diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
index ad9c6d3..e08125a 100644
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -95,7 +95,6 @@ struct sysc {
 	unsigned int enabled:1;
 	unsigned int needs_resume:1;
 	unsigned int child_needs_resume:1;
-	unsigned int disable_on_idle:1;
 	struct delayed_work idle_work;
 	void (*clk_enable_quirk)(struct sysc *sysc);
 	void (*clk_disable_quirk)(struct sysc *sysc);
@@ -1031,8 +1030,7 @@ static int __maybe_unused sysc_runtime_suspend_legacy(struct device *dev,
 		dev_err(dev, "%s: could not idle: %i\n",
 			__func__, error);
 
-	if (ddata->disable_on_idle)
-		reset_control_assert(ddata->rsts);
+	reset_control_assert(ddata->rsts);
 
 	return 0;
 }
@@ -1043,8 +1041,7 @@ static int __maybe_unused sysc_runtime_resume_legacy(struct device *dev,
 	struct ti_sysc_platform_data *pdata;
 	int error;
 
-	if (ddata->disable_on_idle)
-		reset_control_deassert(ddata->rsts);
+	reset_control_deassert(ddata->rsts);
 
 	pdata = dev_get_platdata(ddata->dev);
 	if (!pdata)
@@ -1091,8 +1088,7 @@ static int __maybe_unused sysc_runtime_suspend(struct device *dev)
 	ddata->enabled = false;
 
 err_allow_idle:
-	if (ddata->disable_on_idle)
-		reset_control_assert(ddata->rsts);
+	reset_control_assert(ddata->rsts);
 
 	sysc_clkdm_allow_idle(ddata);
 
@@ -1112,8 +1108,7 @@ static int __maybe_unused sysc_runtime_resume(struct device *dev)
 
 	sysc_clkdm_deny_idle(ddata);
 
-	if (ddata->disable_on_idle)
-		reset_control_deassert(ddata->rsts);
+	reset_control_deassert(ddata->rsts);
 
 	if (sysc_opt_clks_needed(ddata)) {
 		error = sysc_enable_opt_clocks(ddata);
@@ -1543,14 +1538,7 @@ static int sysc_rstctrl_reset_deassert(struct sysc *ddata, bool reset)
 			return error;
 	}
 
-	error = reset_control_deassert(ddata->rsts);
-	if (error == -EEXIST)
-		return 0;
-
-	error = readx_poll_timeout(reset_control_status, ddata->rsts, val,
-				   val == 0, 100, MAX_MODULE_SOFTRESET_WAIT);
-
-	return error;
+	return reset_control_deassert(ddata->rsts);
 }
 
 /*
@@ -2449,9 +2437,6 @@ static int sysc_probe(struct platform_device *pdev)
 		pm_runtime_put(&pdev->dev);
 	}
 
-	if (!of_get_available_child_count(ddata->dev->of_node))
-		ddata->disable_on_idle = true;
-
 	return 0;
 
 err:
-- 
1.9.1

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

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

* [PATCH 3/3] bus: ti-sysc: allow reset sharing across devices
  2019-08-07 12:46 [PATCH 0/3] bus: ti-sysc: fixes for reset handling Tero Kristo
  2019-08-07 12:46 ` [PATCH 1/3] bus: ti-sysc: re-order the clkdm control around " Tero Kristo
  2019-08-07 12:46 ` [PATCH 2/3] bus: ti-sysc: rework the " Tero Kristo
@ 2019-08-07 12:46 ` Tero Kristo
  2019-08-13 11:33 ` [PATCH 0/3] bus: ti-sysc: fixes for reset handling Tony Lindgren
  3 siblings, 0 replies; 5+ messages in thread
From: Tero Kristo @ 2019-08-07 12:46 UTC (permalink / raw)
  To: linux-omap, tony, s-anna; +Cc: linux-kernel

Some devices need to share their reset signals, like DSP MMUs, thus drop
the exclusive notation from reset request. Also, balance the init time
reset count, otherwise the resets will never be applied post boot.

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

diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
index e08125a..b30eb05 100644
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -502,7 +502,7 @@ static void sysc_clkdm_allow_idle(struct sysc *ddata)
 static int sysc_init_resets(struct sysc *ddata)
 {
 	ddata->rsts =
-		devm_reset_control_get_optional(ddata->dev, "rstctrl");
+		devm_reset_control_get_optional_shared(ddata->dev, "rstctrl");
 	if (IS_ERR(ddata->rsts))
 		return PTR_ERR(ddata->rsts);
 
@@ -1527,7 +1527,7 @@ static int sysc_legacy_init(struct sysc *ddata)
  */
 static int sysc_rstctrl_reset_deassert(struct sysc *ddata, bool reset)
 {
-	int error, val;
+	int error;
 
 	if (!ddata->rsts)
 		return 0;
@@ -1538,7 +1538,9 @@ static int sysc_rstctrl_reset_deassert(struct sysc *ddata, bool reset)
 			return error;
 	}
 
-	return reset_control_deassert(ddata->rsts);
+	reset_control_deassert(ddata->rsts);
+
+	return 0;
 }
 
 /*
@@ -2418,6 +2420,10 @@ static int sysc_probe(struct platform_device *pdev)
 		goto unprepare;
 	}
 
+	/* Balance reset counts */
+	if (ddata->rsts)
+		reset_control_assert(ddata->rsts);
+
 	sysc_show_registers(ddata);
 
 	ddata->dev->type = &sysc_device_type;
-- 
1.9.1

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

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

* Re: [PATCH 0/3] bus: ti-sysc: fixes for reset handling
  2019-08-07 12:46 [PATCH 0/3] bus: ti-sysc: fixes for reset handling Tero Kristo
                   ` (2 preceding siblings ...)
  2019-08-07 12:46 ` [PATCH 3/3] bus: ti-sysc: allow reset sharing across devices Tero Kristo
@ 2019-08-13 11:33 ` Tony Lindgren
  3 siblings, 0 replies; 5+ messages in thread
From: Tony Lindgren @ 2019-08-13 11:33 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, s-anna, linux-kernel

* Tero Kristo <t-kristo@ti.com> [190807 05:47]:
> Hi,
> 
> Here are a few patches to fix reset handling for ti-sysc bus driver.
> Without these, the iommu won't be working properly at least.

Applying these into omap-for-v5.4/ti-sysc since the prm rstctrl
driver is not yet merged and these should not be needed as fixes
at this point.

Regards,

Tony

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

end of thread, other threads:[~2019-08-13 11:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-07 12:46 [PATCH 0/3] bus: ti-sysc: fixes for reset handling Tero Kristo
2019-08-07 12:46 ` [PATCH 1/3] bus: ti-sysc: re-order the clkdm control around " Tero Kristo
2019-08-07 12:46 ` [PATCH 2/3] bus: ti-sysc: rework the " Tero Kristo
2019-08-07 12:46 ` [PATCH 3/3] bus: ti-sysc: allow reset sharing across devices Tero Kristo
2019-08-13 11:33 ` [PATCH 0/3] bus: ti-sysc: fixes for reset handling 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).