Message ID | 20201217170933.10717-2-kostap@marvell.com |
---|---|
State | Superseded |
Headers | show |
Series | spi: new feature and fix for Marvell Orion driver | expand |
On Thu, Dec 17, 2020 at 07:09:31PM +0200, kostap@marvell.com wrote: > + /* > + * Make sure the clocks are enabled before > + * configuring the SPI controller. > + */ > + clk_prepare_enable(orion_spi->clk); > + if (!IS_ERR(orion_spi->axi_clk)) > + clk_prepare_enable(orion_spi->axi_clk); > + > return orion_spi_setup_transfer(spi, NULL); > } There's no matching disable here so we'll leak the enables every time setup() is called - we should unwind the enables after calling _setup_transfer(). It may be more sensible to just take a runtime PM reference rather than do the raw clock API stuff, one less call and means if anything else gets added to runtime PM it'll be handled.
Hi, Mark, > -----Original Message----- > From: Mark Brown <broonie@kernel.org> > > + /* > > + * Make sure the clocks are enabled before > > + * configuring the SPI controller. > > + */ > > + clk_prepare_enable(orion_spi->clk); > > + if (!IS_ERR(orion_spi->axi_clk)) > > + clk_prepare_enable(orion_spi->axi_clk); > > + > > return orion_spi_setup_transfer(spi, NULL); } > > There's no matching disable here so we'll leak the enables every time > setup() is called - we should unwind the enables after calling > _setup_transfer(). It may be more sensible to just take a runtime PM > reference rather than do the raw clock API stuff, one less call and means if > anything else gets added to runtime PM it'll be handled. [KP] You mean we should call here to orion_spi_runtime_resume() instead of clk_prepare_enable() and make this PM function available regardless the CONFIG_PM option? Thanks Kosta
On Tue, Dec 22, 2020 at 12:46:01PM +0000, Kostya Porotchkin wrote: Please fix your mail client to word wrap within paragraphs at something substantially less than 80 columns. Doing this makes your messages much easier to read and reply to. > > There's no matching disable here so we'll leak the enables every time > > setup() is called - we should unwind the enables after calling > > _setup_transfer(). It may be more sensible to just take a runtime PM > > reference rather than do the raw clock API stuff, one less call and means if > > anything else gets added to runtime PM it'll be handled. > [KP] You mean we should call here to orion_spi_runtime_resume() > instead of clk_prepare_enable() and make this PM function available > regardless the CONFIG_PM option? That's one part of the suggestion, yes - the other part is that you need to have a disable matching the enable here.
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index b57b8b3cc26e..3bfda4225d45 100644 --- a/drivers/spi/spi-orion.c +++ b/drivers/spi/spi-orion.c @@ -507,6 +507,16 @@ static int orion_spi_transfer_one(struct spi_master *master, static int orion_spi_setup(struct spi_device *spi) { + struct orion_spi *orion_spi = spi_master_get_devdata(spi->master); + + /* + * Make sure the clocks are enabled before + * configuring the SPI controller. + */ + clk_prepare_enable(orion_spi->clk); + if (!IS_ERR(orion_spi->axi_clk)) + clk_prepare_enable(orion_spi->axi_clk); + return orion_spi_setup_transfer(spi, NULL); }