lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1607049263.14806.69.camel@mhfsdcap03>
Date:   Fri, 4 Dec 2020 10:34:23 +0800
From:   Crystal Guo <crystal.guo@...iatek.com>
To:     Ikjoon Jang <ikjn@...omium.org>
CC:     "p.zabel@...gutronix.de" <p.zabel@...gutronix.de>,
        "robh+dt@...nel.org" <robh+dt@...nel.org>,
        "matthias.bgg@...il.com" <matthias.bgg@...il.com>,
        "devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
        Yong Liang (梁勇) 
        <Yong.Liang@...iatek.com>,
        Stanley Chu (朱原陞) 
        <stanley.chu@...iatek.com>,
        srv_heupstream <srv_heupstream@...iatek.com>,
        Seiya Wang (王迺君) 
        <seiya.wang@...iatek.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Fan Chen (陳凡) 
        <fan.chen@...iatek.com>,
        "linux-mediatek@...ts.infradead.org" 
        <linux-mediatek@...ts.infradead.org>,
        Yingjoe Chen (陳英洲) 
        <Yingjoe.Chen@...iatek.com>, "s-anna@...com" <s-anna@...com>,
        "linux-arm-kernel@...ts.infradead.org" 
        <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [v6,2/3] reset-controller: ti: introduce a new reset handler

On Mon, 2020-11-30 at 18:35 +0800, Ikjoon Jang wrote:
> On Wed, Sep 30, 2020 at 10:21:58AM +0800, Crystal Guo wrote:
> > Introduce ti_syscon_reset() to integrate assert and deassert together.
> > If some modules need do serialized assert and deassert operations
> > to reset itself, reset_control_reset can be called for convenience.
> > 
> > Such as reset-qcom-aoss.c, it integrates assert and deassert together
> > by 'reset' method. MTK Socs also need this method to perform reset.
> > 
> > Signed-off-by: Crystal Guo <crystal.guo@...iatek.com>
> 
> Reviewed-by: Ikjoon Jang <ikjn@...omium.org>
> 
> > ---
> >  drivers/reset/reset-ti-syscon.c | 40 ++++++++++++++++++++++++++++++++-
> >  1 file changed, 39 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/reset/reset-ti-syscon.c b/drivers/reset/reset-ti-syscon.c
> > index a2635c21db7f..5d1f8306cd4f 100644
> > --- a/drivers/reset/reset-ti-syscon.c
> > +++ b/drivers/reset/reset-ti-syscon.c
> > @@ -15,15 +15,22 @@
> >   * GNU General Public License for more details.
> >   */
> >  
> > +#include <linux/delay.h>
> >  #include <linux/mfd/syscon.h>
> >  #include <linux/module.h>
> >  #include <linux/of.h>
> > +#include <linux/of_device.h>
> >  #include <linux/platform_device.h>
> >  #include <linux/regmap.h>
> >  #include <linux/reset-controller.h>
> >  
> >  #include <dt-bindings/reset/ti-syscon.h>
> >  
> > +struct mediatek_reset_data {
> > +	unsigned char *reset_bits;
> > +	unsigned int reset_duration_us;
> > +};
> > +
> >  /**
> >   * struct ti_syscon_reset_control - reset control structure
> >   * @assert_offset: reset assert control register offset from syscon base
> > @@ -56,6 +63,7 @@ struct ti_syscon_reset_data {
> >  	struct regmap *regmap;
> >  	struct ti_syscon_reset_control *controls;
> >  	unsigned int nr_controls;
> > +	const struct mediatek_reset_data *reset_data;
> >  };
> >  
> >  #define to_ti_syscon_reset_data(rcdev)	\
> > @@ -158,9 +166,29 @@ static int ti_syscon_reset_status(struct reset_controller_dev *rcdev,
> >  		!(control->flags & STATUS_SET);
> >  }
> >  
> > +static int ti_syscon_reset(struct reset_controller_dev *rcdev,
> > +				  unsigned long id)
> > +{
> > +	struct ti_syscon_reset_data *data = to_ti_syscon_reset_data(rcdev);
> > +	int ret;
> > +
> > +	if (data->reset_data) {
> > +		ret = ti_syscon_reset_assert(rcdev, id);
> > +		if (ret)
> > +			return ret;
> > +		usleep_range(data->reset_data->reset_duration_us,
> > +			data->reset_data->reset_duration_us * 2);
> > +
> 
> There are many users using assert() and deassert() seperately
> without any delay between them.
> 
> If there's a timing requirement between assertion and deassertion,
> shouldn't there be a same amount of delay in assert?

The "reset_duration_us" is an optional configuration to make the reset
operation more generic, which was added based on Philipp's comment in
[v2,4/6].

Thanks,
Crystal
> 
> > +		return ti_syscon_reset_deassert(rcdev, id);
> > +	} else {
> > +		return -ENOTSUPP;
> > +	}
> > +}
> > +
> >  static const struct reset_control_ops ti_syscon_reset_ops = {
> >  	.assert		= ti_syscon_reset_assert,
> >  	.deassert	= ti_syscon_reset_deassert,
> > +	.reset		= ti_syscon_reset,
> >  	.status		= ti_syscon_reset_status,
> >  };
> >  
> > @@ -182,7 +210,11 @@ static int ti_syscon_reset_probe(struct platform_device *pdev)
> >  	if (IS_ERR(regmap))
> >  		return PTR_ERR(regmap);
> >  
> > -	list = of_get_property(np, "ti,reset-bits", &size);
> > +	data->reset_data = of_device_get_match_data(&pdev->dev);
> > +	if (data->reset_data)
> > +		list = of_get_property(np, data->reset_data->reset_bits, &size);
> > +	else
> > +		list = of_get_property(np, "ti,reset-bits", &size);
> >  	if (!list || (size / sizeof(*list)) % 7 != 0) {
> >  		dev_err(dev, "invalid DT reset description\n");
> >  		return -EINVAL;
> > @@ -217,8 +249,14 @@ static int ti_syscon_reset_probe(struct platform_device *pdev)
> >  	return devm_reset_controller_register(dev, &data->rcdev);
> >  }
> >  
> > +static const struct mediatek_reset_data mtk_reset_data = {
> > +	.reset_bits = "mediatek,reset-bits",
> > +	.reset_duration_us = 10,
> > +};
> > +
> >  static const struct of_device_id ti_syscon_reset_of_match[] = {
> >  	{ .compatible = "ti,syscon-reset", },
> > +	{ .compatible = "mediatek,syscon-reset", .data = &mtk_reset_data},
> >  	{ /* sentinel */ },
> >  };
> >  MODULE_DEVICE_TABLE(of, ti_syscon_reset_of_match);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ