2020-08-05 07:07:28

by Alain Volmat

[permalink] [raw]
Subject: [PATCH 02/18] spi: stm32-spi: defer probe for reset

Defer the probe operation when a reset controller device is expected
but have not yet been probed.

This change replaces use of devm_reset_control_get_exclusive() with
devm_reset_control_get_optional_exclusive() as reset controller is
optional which is now explicitly stated.

Signed-off-by: Alain Volmat <[email protected]>
---
drivers/spi/spi-stm32.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 838d3ce3ebae..eaa416c551c9 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -1886,8 +1886,16 @@ static int stm32_spi_probe(struct platform_device *pdev)
goto err_clk_disable;
}

- rst = devm_reset_control_get_exclusive(&pdev->dev, NULL);
- if (!IS_ERR(rst)) {
+ rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
+ if (rst) {
+ if (IS_ERR(rst)) {
+ ret = PTR_ERR(rst);
+ if (ret != -EPROBE_DEFER)
+ dev_err(&pdev->dev, "reset get failed: %d\n",
+ ret);
+ goto err_clk_disable;
+ }
+
reset_control_assert(rst);
udelay(2);
reset_control_deassert(rst);
--
2.7.4


2020-08-05 11:59:52

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 02/18] spi: stm32-spi: defer probe for reset

On Wed, Aug 05, 2020 at 09:01:57AM +0200, Alain Volmat wrote:

> - rst = devm_reset_control_get_exclusive(&pdev->dev, NULL);
> - if (!IS_ERR(rst)) {
> + rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
> + if (rst) {
> + if (IS_ERR(rst)) {
> + ret = PTR_ERR(rst);
> + if (ret != -EPROBE_DEFER)
> + dev_err(&pdev->dev, "reset get failed: %d\n",
> + ret);
> + goto err_clk_disable;
> + }

This will not provide any diagnostics when deferring which isn't very
helpful if there's issues.


Attachments:
(No filename) (533.00 B)
signature.asc (499.00 B)
Download all attachments

2020-08-07 13:45:00

by Alain Volmat

[permalink] [raw]
Subject: Re: [PATCH 02/18] spi: stm32-spi: defer probe for reset

On Wed, Aug 05, 2020 at 11:49:06AM +0100, Mark Brown wrote:
> On Wed, Aug 05, 2020 at 09:01:57AM +0200, Alain Volmat wrote:
>
> > - rst = devm_reset_control_get_exclusive(&pdev->dev, NULL);
> > - if (!IS_ERR(rst)) {
> > + rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
> > + if (rst) {
> > + if (IS_ERR(rst)) {
> > + ret = PTR_ERR(rst);
> > + if (ret != -EPROBE_DEFER)
> > + dev_err(&pdev->dev, "reset get failed: %d\n",
> > + ret);
> > + goto err_clk_disable;
> > + }
>
> This will not provide any diagnostics when deferring which isn't very
> helpful if there's issues.

Do you mean that a message when deferring would be needed ?

I am worrying that this would lead to having too much noise during boot
since probe deferring is kinda common. Of course it can also be due to a bad
configuration of the kernel as well but having looked around I think that
usually driver are rather silent in case of deferring.

2020-08-07 14:09:35

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 02/18] spi: stm32-spi: defer probe for reset

On Fri, Aug 07, 2020 at 03:42:54PM +0200, Alain Volmat wrote:
> On Wed, Aug 05, 2020 at 11:49:06AM +0100, Mark Brown wrote:
> > On Wed, Aug 05, 2020 at 09:01:57AM +0200, Alain Volmat wrote:

> > > - rst = devm_reset_control_get_exclusive(&pdev->dev, NULL);
> > > - if (!IS_ERR(rst)) {
> > > + rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
> > > + if (rst) {
> > > + if (IS_ERR(rst)) {
> > > + ret = PTR_ERR(rst);
> > > + if (ret != -EPROBE_DEFER)
> > > + dev_err(&pdev->dev, "reset get failed: %d\n",
> > > + ret);
> > > + goto err_clk_disable;
> > > + }

> > This will not provide any diagnostics when deferring which isn't very
> > helpful if there's issues.

> Do you mean that a message when deferring would be needed ?

Yes, if for examaple the reset driver isn't being built then the driver
will defer for ever waiting for it to instantiate and the user will have
to have some method for figuring out what it's waiting for.

> I am worrying that this would lead to having too much noise during boot
> since probe deferring is kinda common. Of course it can also be due to a bad
> configuration of the kernel as well but having looked around I think that
> usually driver are rather silent in case of deferring.

This is not something that should be open coded in your driver.


Attachments:
(No filename) (1.32 kB)
signature.asc (499.00 B)
Download all attachments