Fix PM Hooks in the Cadence Quad SPI Driver
cover Fix PM Hooks in the Cadence Quad SPI Driver
This series adds fixes to the Suspend and Resume Hooks of the CQSPI Driver. Earlier, the ltp-ddt test "OSPI_S_FUNC_DD_RW_ERASESIZE_UBIFS" failed post system suspend resume. It is now passing as shown in [0].
Tested on top of linux-next (next-20230414) on an AM625-SK-EVM. For logs, please refer [0].
[0] https://gist.github.com/DhruvaG2000/29b15f9c8a1e632c6819a986e5f28ab2
Dhruva Gole (2):
spi: cadence-quadspi: use macro SIMPLE_DEV_PM_OPS
spi: cadence-quadspi: fix suspend-resume implementations
drivers/spi/spi-cadence-quadspi.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 spi: cadence-quadspi: use macro SIMPLE_DEV_PM_OPS
Using this macro makes the code more readable.
It also inits the members of dev_pm_ops in the following manner without us explicitly needing to:
.suspend = cqspi_suspend, \
.resume = cqspi_resume, \
.freeze = suspend_fn, \
.thaw = resume_fn, \
.poweroff = suspend_fn, \
.restore = resume_fn,
--- drivers/spi/spi-cadence-quadspi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/spi/spi-cadence-quadspi.c +1 -4
@@ -1829,10 +1829,7 @@ static int cqspi_resume(struct device *dev)return 0 ; } -static const struct dev_pm_ops cqspi__dev_pm_ops = { - .suspend = cqspi_suspend, - .resume = cqspi_resume, -}; +static SIMPLE_DEV_PM_OPS(cqspi__dev_pm_ops, cqspi_suspend, cqspi_resume);#define CQSPI_DEV_PM_OPS (&cqspi__dev_pm_ops)#else
Signature · 1 line
2.25.1
Mark Brown
maintainerRe: [PATCH 1/2] spi: cadence-quadspi: use macro SIMPLE_DEV_PM_OPS
drivers/spi/spi-cadence-quadspi.c static int cqspi_resume(struct device *dev) · line 1835
Quoted 8 lines · Dhruva Gole
drivers/spi/spi-cadence-quadspi.c +1
-4-static const struct dev_pm_ops cqspi__dev_pm_ops = { - .suspend = cqspi_suspend, - .resume = cqspi_resume, -}; +static SIMPLE_DEV_PM_OPS(cqspi__dev_pm_ops, cqspi_suspend, cqspi_resume);#define CQSPI_DEV_PM_OPS (&cqspi__dev_pm_ops)#else
These days you should use DEFINE_SIMPLE_DEV_PM_OPS() instead.
Re: [PATCH 1/2] spi: cadence-quadspi: use macro SIMPLE_DEV_PM_OPS
Hi Mark, Thanks for going through my patch.
Quoted 11 lines · Mark Brown
drivers/spi/spi-cadence-quadspi.c static int cqspi_resume(struct device *dev) · line 1835
Quoted 8 lines · Dhruva Gole
drivers/spi/spi-cadence-quadspi.c +1
-4-static const struct dev_pm_ops cqspi__dev_pm_ops = { - .suspend = cqspi_suspend, - .resume = cqspi_resume, -}; +static SIMPLE_DEV_PM_OPS(cqspi__dev_pm_ops, cqspi_suspend, cqspi_resume);#define CQSPI_DEV_PM_OPS (&cqspi__dev_pm_ops)#else These days you should use
DEFINE_SIMPLE_DEV_PM_OPS()instead.
Sure, I can respin this series with this macro instead,
https://elixir.bootlin.com/linux/v6.1/source/include/linux/pm.h#L399
So essentially it will look like,
static DEFINE_SIMPLE_DEV_PM_OPS(cqspi__dev_pm_ops, cqspi_suspend, cqspi_resume);
Are there any other improvements you'd like me to make in my next revision of this series?
Signature · 2 lines
Regards, Dhruva Gole <[email protected]>
Mark Brown
maintainerRe: [PATCH 1/2] spi: cadence-quadspi: use macro SIMPLE_DEV_PM_OPS
Quoted 1 line · Dhruva
Are there any other improvements you'd like me to make in my next revision of this series?
That was it. I think I queued patch 2 already.
PATCH 2/2 spi: cadence-quadspi: fix suspend-resume implementations
In reply to Dhruva GoleThe cadence QSPI driver misbehaves after performing a full system suspend resume:
...
spi-nor spi0.0: resume() failed
...
This results in a flash connected via OSPI interface after system suspend- resume to be unusable.
fix these suspend and resume functions.
--- drivers/spi/spi-cadence-quadspi.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/spi/spi-cadence-quadspi.c +16 -3
@@ -1816,17 +1816,30 @@ static void cqspi_remove(struct platform_device *pdev)static int cqspi_suspend (struct device *dev) {struct cqspi_st *cqspi =dev_get_drvdata (dev); +struct spi_master *master =dev_get_drvdata (dev); +int ret; + ret =spi_master_suspend (master);cqspi_controller_enable (cqspi,0 ); -return 0 ; + +clk_disable_unprepare (cqspi->clk); + +return ret; }static int cqspi_resume (struct device *dev) {struct cqspi_st *cqspi =dev_get_drvdata (dev); +struct spi_master *master =dev_get_drvdata (dev); -cqspi_controller_enable (cqspi,1 ); -return 0 ; +clk_prepare_enable (cqspi->clk); +cqspi_wait_idle (cqspi); +cqspi_controller_init (cqspi); + + cqspi->current_cs =-1 ; + cqspi->sclk =0 ; + +return spi_master_resume (master); } static SIMPLE_DEV_PM_OPS(cqspi__dev_pm_ops, cqspi_suspend, cqspi_resume);
Signature · 1 line
2.25.1
Mark Brown
maintainerRe: (subset) [PATCH 0/2] Fix PM Hooks in the Cadence Quad SPI Driver
In reply to Dhruva GoleQuoted 8 lines · Dhruva Gole
This series adds fixes to the Suspend and Resume Hooks of the CQSPI Driver. Earlier, the ltp-ddt test "
OSPI_S_FUNC_DD_RW_ERASESIZE_UBIFS" failed post system suspend resume. It is now passing as shown in [0].Tested on top of linux-next (next-20230414) on an AM625-SK-EVM. For logs, please refer [0].
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[2/2] spi: cadence-quadspi: fix suspend-resume implementations
commit: 2087e85bb66ee3652dafe732bb9b9b896229eafc
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark