ARC: HSDK: improve reset driver
diff mbox series

Message ID 20180827143803.28178-1-Eugeniy.Paltsev@synopsys.com
State New
Headers show
Series
  • ARC: HSDK: improve reset driver
Related show

Commit Message

Eugeniy Paltsev Aug. 27, 2018, 2:38 p.m. UTC
As for today HSDK reset driver implements only
.reset() callback.

In case of driver which implements one of standard
reset controller usage pattern
(call *_deassert() in probe(), call *_assert() in remove())
that leads to inoperability of this reset driver.

Improve HSDK reset driver by calling .reset() callback inside of
.assert()/.deassert() callbacks to avoid each reset controller
user adaptation for work with both reset methods
(reset() and .assert()/.deassert() pair)

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
---
 drivers/reset/reset-hsdk.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Eugeniy Paltsev Sept. 11, 2018, 3:25 p.m. UTC | #1
Hi Philipp,

Maybe you have any comments or remarks about this patch? And if you don't could you please apply it.
Thanks!

On Mon, 2018-08-27 at 17:38 +0300, Eugeniy Paltsev wrote:
> As for today HSDK reset driver implements only
> .reset() callback.
> 
> In case of driver which implements one of standard
> reset controller usage pattern
> (call *_deassert() in probe(), call *_assert() in remove())
> that leads to inoperability of this reset driver.
> 
> Improve HSDK reset driver by calling .reset() callback inside of
> .assert()/.deassert() callbacks to avoid each reset controller
> user adaptation for work with both reset methods
> (reset() and .assert()/.deassert() pair)
> 
> Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
> ---
>  drivers/reset/reset-hsdk.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/reset/reset-hsdk.c b/drivers/reset/reset-hsdk.c
> index 8bce391c6943..1fd91df91343 100644
> --- a/drivers/reset/reset-hsdk.c
> +++ b/drivers/reset/reset-hsdk.c
> @@ -86,6 +86,8 @@ static int hsdk_reset_reset(struct reset_controller_dev *rcdev,
>  
>  static const struct reset_control_ops hsdk_reset_ops = {
>  	.reset	= hsdk_reset_reset,
> +	.assert = hsdk_reset_reset,
> +	.deassert = hsdk_reset_reset,
>  };
>  
>  static int hsdk_reset_probe(struct platform_device *pdev)
Philipp Zabel Sept. 14, 2018, 10:38 a.m. UTC | #2
Hi Eugeniy,

On Mon, 2018-08-27 at 17:38 +0300, Eugeniy Paltsev wrote:
> As for today HSDK reset driver implements only
> .reset() callback.
> 
> In case of driver which implements one of standard
> reset controller usage pattern
> (call *_deassert() in probe(), call *_assert() in remove())
> that leads to inoperability of this reset driver.
> 
> Improve HSDK reset driver by calling .reset() callback inside of
> .assert()/.deassert() callbacks to avoid each reset controller
> user adaptation for work with both reset methods
> (reset() and .assert()/.deassert() pair)
> 
> Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
> ---
>  drivers/reset/reset-hsdk.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/reset/reset-hsdk.c b/drivers/reset/reset-hsdk.c
> index 8bce391c6943..1fd91df91343 100644
> --- a/drivers/reset/reset-hsdk.c
> +++ b/drivers/reset/reset-hsdk.c
> @@ -86,6 +86,8 @@ static int hsdk_reset_reset(struct reset_controller_dev *rcdev,
>  
>  static const struct reset_control_ops hsdk_reset_ops = {
>  	.reset	= hsdk_reset_reset,
> +	.assert = hsdk_reset_reset,

This is incorrect for exclusive reset controls.
It will cause reset_control_assert() to return success for exclusive
reset controls, even though the .assert op failed to leave the reset
line asserted after the function returns.

While calling hsdk_reset_reset from .assert for shared reset controls
would be fine, I don't see how this is necessary of useful.
If a consumer driver requires the reset to be asserted upon remove(), it
must not request a shared reset control anyway, because with shared
reset controls other drivers may keep the reset line deasserted
indefinitely.

> +	.deassert = hsdk_reset_reset,

This should be fine. I wonder from time to time whether this should be
implemented in the core, in reset_control_deassert().

regards
Philipp
Eugeniy Paltsev Sept. 24, 2018, 11:08 a.m. UTC | #3
Hi Philip,

On Fri, 2018-09-14 at 12:38 +0200, Philipp Zabel wrote:
> Hi Eugeniy,
> 
> On Mon, 2018-08-27 at 17:38 +0300, Eugeniy Paltsev wrote:
> > As for today HSDK reset driver implements only
> > .reset() callback.
> > 
> > In case of driver which implements one of standard
> > reset controller usage pattern
> > (call *_deassert() in probe(), call *_assert() in remove())
> > that leads to inoperability of this reset driver.
> > 
> > Improve HSDK reset driver by calling .reset() callback inside of
> > .assert()/.deassert() callbacks to avoid each reset controller
> > user adaptation for work with both reset methods
> > (reset() and .assert()/.deassert() pair)
> > 
> > Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
> > ---
> >  drivers/reset/reset-hsdk.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/reset/reset-hsdk.c b/drivers/reset/reset-hsdk.c
> > index 8bce391c6943..1fd91df91343 100644
> > --- a/drivers/reset/reset-hsdk.c
> > +++ b/drivers/reset/reset-hsdk.c
> > @@ -86,6 +86,8 @@ static int hsdk_reset_reset(struct reset_controller_dev *rcdev,
> >  
> >  static const struct reset_control_ops hsdk_reset_ops = {
> >  	.reset	= hsdk_reset_reset,
> > +	 = hsdk_reset_reset,
> 
> This is incorrect for exclusive reset controls.
> It will cause reset_control_assert() to return success for exclusive
> reset controls, even though the .assert op failed to leave the reset
> line asserted after the function returns.
> 
> While calling hsdk_reset_reset from .assert for shared reset controls
> would be fine, I don't see how this is necessary of useful.
> If a consumer driver requires the reset to be asserted upon remove(), it
> must not request a shared reset control anyway, because with shared
> reset controls other drivers may keep the reset line deasserted
> indefinitely.

Ok, I agree that doing reset from .assert isn't necessary/useful here.
The reason I added hsdk_reset_reset into .assert is to prevent -ENOTSUPP
returning by reset_control_assert().

Lots of drivers implement following pattern to reset HW:
------------------------->8------------------------------
reset_control_assert(resets);
usleep_range(10, 1000);
reset_control_deassert(resets);
------------------------->8------------------------------

And some of them check reset_control_assert() and reset_control_deassert()
return status.

So these driver will fail if I implement only .reset and .deassert callback in my
reset driver.

I can implement something like that:
------------------------->8------------------------------
static int hsdk_dummy_assert(struct reset_controller_dev *rd, unsigned long id)
{
	return 0;
}

static const struct reset_control_ops hsdk_reset_ops = {
	.reset    = hsdk_reset_reset,
	.assert   = hsdk_dummy_assert,
	.deassert = hsdk_reset_reset,
};
------------------------->8------------------------------



> > +	.deassert = hsdk_reset_reset,
> 
> This should be fine. 

> I wonder from time to time whether this should be
> implemented in the core, in reset_control_deassert().

Sounds OK for me. At least I don't see any issues it may cause.

> regards
> Philipp

Patch
diff mbox series

diff --git a/drivers/reset/reset-hsdk.c b/drivers/reset/reset-hsdk.c
index 8bce391c6943..1fd91df91343 100644
--- a/drivers/reset/reset-hsdk.c
+++ b/drivers/reset/reset-hsdk.c
@@ -86,6 +86,8 @@  static int hsdk_reset_reset(struct reset_controller_dev *rcdev,
 
 static const struct reset_control_ops hsdk_reset_ops = {
 	.reset	= hsdk_reset_reset,
+	.assert = hsdk_reset_reset,
+	.deassert = hsdk_reset_reset,
 };
 
 static int hsdk_reset_probe(struct platform_device *pdev)