Skip to contentSkip to conversation

spi: ti-qspi: improve ->remove() callback

PATCH In review Felipe Balbi 2 participants 7 messages Oct 29, 2015 – Nov 2, 2015 6 messages not in the archive SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: ti-qspi: improve ->remove() callback

there's no need to call pm_runtime_get_sync() followed by pm_runtime_put(). We should, instead, just call pm_runtime_put_sync() and pm_runtime_disable().

---
 drivers/spi/spi-ti-qspi.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/spi/spi-ti-qspi.c +1 -10
index 69c1a95b0615..64318fcfacf2 100644
@@ -554,16 +554,7 @@ free_master:
 
 static int ti_qspi_remove(struct platform_device *pdev)
 {
-	struct ti_qspi *qspi = platform_get_drvdata(pdev);
-	int ret;
-
-	ret = pm_runtime_get_sync(qspi->dev);
-	if (ret < 0) {
-		dev_err(qspi->dev, "pm_runtime_get_sync() failed\n");
-		return ret;
-	}
-
-	pm_runtime_put(qspi->dev);
+	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
 	return 0;
Signature · 6 lines
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1446127050-5957-1-git-send-email-balbi-l0cyMroinI0@public.gmane.org

#2 lore raw
Quoted 3 lines · Felipe Balbi

there's no need to call pm_runtime_get_sync() followed by pm_runtime_put(). We should, instead, just call pm_runtime_put_sync() and pm_runtime_disable().

Sry, but why do we need to call pm_runtime_put[_sync]() here?

My be just pm_runtime_disable() will be ok?

Quoted 29 lines
---
  drivers/spi/spi-ti-qspi.c | 11 +----------
  1 file changed, 1 insertion(+), 10 deletions(-)
drivers/spi/spi-ti-qspi.c +1 -10
index 69c1a95b0615..64318fcfacf2 100644
@@ -554,16 +554,7 @@ free_master:
 
  static int ti_qspi_remove(struct platform_device *pdev)
  {
-	struct ti_qspi *qspi = platform_get_drvdata(pdev);
-	int ret;
-
-	ret = pm_runtime_get_sync(qspi->dev);
-	if (ret < 0) {
-		dev_err(qspi->dev, "pm_runtime_get_sync() failed\n");
-		return ret;
-	}
-
-	pm_runtime_put(qspi->dev);
+	pm_runtime_put_sync(&pdev->dev);
  	pm_runtime_disable(&pdev->dev);
 
  	return 0;
Signature · 6 lines
regards,
-grygorii
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 8 lines · Grygorii Strashko
Quoted 3 lines · Felipe Balbi

there's no need to call pm_runtime_get_sync() followed by pm_runtime_put(). We should, instead, just call pm_runtime_put_sync() and pm_runtime_disable().

Sry, but why do we need to call pm_runtime_put[_sync]() here?

My be just pm_runtime_disable() will be ok?

and disable with unbalanced pm_runtime_get() ?

Signature · 1 line
balbi

A message that is not in the archive (sent off-list or not yet received): 87bnbcctsk.fsf-HgARHv6XitJaoMGHk7MhZQC/[email protected]

#6 lore raw
Quoted 7 lines · Felipe Balbi
Quoted 5 lines · Grygorii Strashko
Quoted 3 lines · Felipe Balbi

there's no need to call pm_runtime_get_sync() followed by pm_runtime_put(). We should, instead, just call pm_runtime_put_sync() and pm_runtime_disable().

Quoted 6 lines
Quoted 3 lines

Sry, but why do we need to call pm_runtime_put[_sync]() here?

My be just pm_runtime_disable() will be ok?

and disable with unbalanced pm_runtime_get() ?

Which one is unbalanced pm_runtime_get()?
There are no pm_runtime_get() in probe, so there you are going to introduce unbalanced pm_runtime_put_sync() actually :(

Signature · 6 lines
regards,
-grygorii
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

hi,

Quoted 10 lines · Grygorii Strashko
Quoted 9 lines · Felipe Balbi
Quoted 7 lines · Grygorii Strashko
Quoted 3 lines · Felipe Balbi

there's no need to call pm_runtime_get_sync() followed by pm_runtime_put(). We should, instead, just call pm_runtime_put_sync() and pm_runtime_disable().

Sry, but why do we need to call pm_runtime_put[_sync]() here?

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

My be just pm_runtime_disable() will be ok?

and disable with unbalanced pm_runtime_get() ?

Which one is unbalanced pm_runtime_get()?
There are no pm_runtime_get() in probe, so there you are going to introduce unbalanced pm_runtime_put_sync() actually :(

look at ti_qspi_setup(). I _do_ see, however, that it calls pm_runtime_put_autosuspend() in the same function; what happens if driver is removed after ti_qspi_setup() runs but before put_autosuspend() has time to actually run ?

Signature · 1 line
balbi

A message that is not in the archive (sent off-list or not yet received): 87si4oo07n.fsf-HgARHv6XitJaoMGHk7MhZQC/[email protected]

#10 lore raw
Quoted 19 lines · Felipe Balbi

hi,

Quoted 15 lines · Grygorii Strashko
Quoted 13 lines · Felipe Balbi
Quoted 8 lines · Grygorii Strashko
Quoted 3 lines · Felipe Balbi

there's no need to call pm_runtime_get_sync() followed by pm_runtime_put(). We should, instead, just call pm_runtime_put_sync() and pm_runtime_disable().

Sry, but why do we need to call pm_runtime_put[_sync]() here?

My be just pm_runtime_disable() will be ok?

and disable with unbalanced pm_runtime_get() ?

Quoted 9 lines
Quoted 3 lines

Which one is unbalanced pm_runtime_get()?
There are no pm_runtime_get() in probe, so there you are going to introduce unbalanced pm_runtime_put_sync() actually :(

look at ti_qspi_setup(). I _do_ see, however, that it calls pm_runtime_put_autosuspend() in the same function; what happens if driver is removed after ti_qspi_setup() runs but before put_autosuspend() has time to actually run ?

Seems nothing :) If I understand code in __device_release_driver() right:
the .remove() callback will be called after pm_runtime_put_sync() and device should be disabled at this moment.

Also, note that ti_qspi_setup() will be called for each SPI device attached to SPI master and further PM management of SPI master is performed by SPI core from __spi_pump_messages().

Signature · 6 lines
regards,
-grygorii
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw

Hi,

Quoted 30 lines · Grygorii Strashko
Quoted 19 lines · Felipe Balbi

hi,

Quoted 15 lines · Grygorii Strashko
Quoted 13 lines · Felipe Balbi
Quoted 8 lines · Grygorii Strashko
Quoted 3 lines · Felipe Balbi

there's no need to call pm_runtime_get_sync() followed by pm_runtime_put(). We should, instead, just call pm_runtime_put_sync() and pm_runtime_disable().

Sry, but why do we need to call pm_runtime_put[_sync]() here?

My be just pm_runtime_disable() will be ok?

and disable with unbalanced pm_runtime_get() ?

Quoted 9 lines
Quoted 3 lines

Which one is unbalanced pm_runtime_get()?
There are no pm_runtime_get() in probe, so there you are going to introduce unbalanced pm_runtime_put_sync() actually :(

look at ti_qspi_setup(). I _do_ see, however, that it calls pm_runtime_put_autosuspend() in the same function; what happens if driver is removed after ti_qspi_setup() runs but before put_autosuspend() has time to actually run ?

Quoted 7 lines

Seems nothing :) If I understand code in __device_release_driver()
right: the .remove() callback will be called after pm_runtime_put_sync() and device should be disabled at this moment.

Also, note that ti_qspi_setup() will be called for each SPI device attached to SPI master and further PM management of SPI master is performed by SPI core from __spi_pump_messages().

all right, do you want to send a patch fixing it ?

Signature · 1 line
balbi