Skip to contentSkip to conversation

Unbalanced calls to spi_master_get in coldfire-qspi and s3c64xx SPI master drivers

DISCUSSION Guenter Roeck 2 participants 3 messages Aug 13, 2012 – Aug 16, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,

looking through SPI master drivers, I noticed that the following drivers call spi_master_get() in their suspend and resume functions. Yet, there is no matching call to spi_master_put(), meaning the reference count will increase with each suspend/resume cycle.

	spi-coldfire-qspi.c
	spi-s3c64xx.c

Other SPI master drivers also support suspend and resume, but do not call spi_master_get() in the suspend/resume functions. The spi-pl022 driver calls spi_master_suspend() and spi_master_resume() like the above, but does not call spi_master_get() either.

This leads me to believe that the above drivers will hang on unload after a suspend/resume cycle due to the extra references.

Can someone please have a look and confirm if my understanding is correct ? If so I'll send a set of patches to fix the problems.

Thanks,
Guenter

#1 lore raw
Quoted 13 lines · Guenter Roeck

Hi all,

looking through SPI master drivers, I noticed that the following drivers call spi_master_get() in their suspend and resume functions. Yet, there is no matching call to spi_master_put(), meaning the reference count will increase with each suspend/resume cycle.

        spi-coldfire-qspi.c
        spi-s3c64xx.c

Other SPI master drivers also support suspend and resume, but do not call spi_master_get() in the suspend/resume functions. The spi-pl022 driver calls spi_master_suspend() and spi_master_resume() like the above, but does not call spi_master_get() either.

Quoted 5 lines

This leads me to believe that the above drivers will hang on unload after a suspend/resume cycle due to the extra references.

Can someone please have a look and confirm if my understanding is correct ? If so I'll send a set of patches to fix the problems.

For spi-s3c64xx.c, yes it does seem that the spi_master_get() and spi_master_put() calls are not balanced. The probable change could be

- struct spi_master *master = spi_master_get(dev_get_drvdata(dev));
+ struct spi_master *master = dev_get_drvdata(dev);

Thanks,
Thomas.

#2 lore raw
Quoted 17 lines · Thomas Abraham
Quoted 16 lines · Guenter Roeck

Hi all,

looking through SPI master drivers, I noticed that the following drivers call spi_master_get() in their suspend and resume functions. Yet, there is no matching call to spi_master_put(), meaning the reference count will increase with each suspend/resume cycle.

        spi-coldfire-qspi.c
        spi-s3c64xx.c

Other SPI master drivers also support suspend and resume, but do not call spi_master_get() in the suspend/resume functions. The spi-pl022 driver calls spi_master_suspend() and spi_master_resume() like the above, but does not call spi_master_get() either.

This leads me to believe that the above drivers will hang on unload after a suspend/resume cycle due to the extra references.

Quoted 9 lines
Quoted 2 lines

Can someone please have a look and confirm if my understanding is correct ? If so I'll send a set of patches to fix the problems.

For spi-s3c64xx.c, yes it does seem that the spi_master_get() and spi_master_put() calls are not balanced. The probable change could be

- struct spi_master *master = spi_master_get(dev_get_drvdata(dev));
+ struct spi_master *master = dev_get_drvdata(dev);

Yes, that is what I thought.

Thanks,
Guenter