linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH next 0/1] Add simple PM operations to sifive-spi
@ 2022-06-10  7:44 Andy Chiu
  2022-06-10  7:44 ` [PATCH next 1/1] spi: sifive: add PM callbacks to support suspend/resume Andy Chiu
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Andy Chiu @ 2022-06-10  7:44 UTC (permalink / raw)
  To: broonie, palmer, paul.walmsley, linux-spi, linux-riscv; +Cc: Andy Chiu

The patch has been tested on Unmatched using pm_test. The Unmatched board
uses SD over SPI and it was tested by initiating S2RAM cycles for all
devices while reading/writing files at the same time. We found no dropped
connection to the card or corrupted filesystem during test cycles.

Andy Chiu (1):
  spi: sifive: add PM callbacks to support suspend/resume

 drivers/spi/spi-sifive.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

-- 
2.36.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH next 1/1] spi: sifive: add PM callbacks to support suspend/resume
  2022-06-10  7:44 [PATCH next 0/1] Add simple PM operations to sifive-spi Andy Chiu
@ 2022-06-10  7:44 ` Andy Chiu
  2022-06-10 12:04   ` Mark Brown
  2022-06-22 10:24   ` Andy Shevchenko
  2022-06-10 12:05 ` [PATCH next 0/1] Add simple PM operations to sifive-spi Mark Brown
  2022-06-10 15:59 ` Mark Brown
  2 siblings, 2 replies; 7+ messages in thread
From: Andy Chiu @ 2022-06-10  7:44 UTC (permalink / raw)
  To: broonie, palmer, paul.walmsley, linux-spi, linux-riscv
  Cc: Andy Chiu, Greentime Hu

Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
---
 drivers/spi/spi-sifive.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/spi/spi-sifive.c b/drivers/spi/spi-sifive.c
index f7c1e20432e0..e29e85cee88a 100644
--- a/drivers/spi/spi-sifive.c
+++ b/drivers/spi/spi-sifive.c
@@ -427,6 +427,44 @@ static int sifive_spi_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static int sifive_spi_suspend(struct device *dev)
+{
+	struct spi_master *master = dev_get_drvdata(dev);
+	struct sifive_spi *spi = spi_master_get_devdata(master);
+	int ret;
+
+	ret = spi_master_suspend(master);
+	if (ret)
+		return ret;
+
+	/* Disable all the interrupts just in case */
+	sifive_spi_write(spi, SIFIVE_SPI_REG_IE, 0);
+
+	clk_disable_unprepare(spi->clk);
+
+	return ret;
+}
+
+static int sifive_spi_resume(struct device *dev)
+{
+	struct spi_master *master = dev_get_drvdata(dev);
+	struct sifive_spi *spi = spi_master_get_devdata(master);
+	int ret;
+
+	ret = clk_prepare_enable(spi->clk);
+	if (ret)
+		return ret;
+	ret = spi_master_resume(master);
+	if (ret)
+		clk_disable_unprepare(spi->clk);
+
+	return ret;
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(sifive_spi_pm_ops,
+				sifive_spi_suspend, sifive_spi_resume);
+
+
 static const struct of_device_id sifive_spi_of_match[] = {
 	{ .compatible = "sifive,spi0", },
 	{}
@@ -438,6 +476,7 @@ static struct platform_driver sifive_spi_driver = {
 	.remove = sifive_spi_remove,
 	.driver = {
 		.name = SIFIVE_SPI_DRIVER_NAME,
+		.pm = &sifive_spi_pm_ops,
 		.of_match_table = sifive_spi_of_match,
 	},
 };
-- 
2.36.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH next 1/1] spi: sifive: add PM callbacks to support suspend/resume
  2022-06-10  7:44 ` [PATCH next 1/1] spi: sifive: add PM callbacks to support suspend/resume Andy Chiu
@ 2022-06-10 12:04   ` Mark Brown
  2022-06-22  3:06     ` Andy Chiu
  2022-06-22 10:24   ` Andy Shevchenko
  1 sibling, 1 reply; 7+ messages in thread
From: Mark Brown @ 2022-06-10 12:04 UTC (permalink / raw)
  To: Andy Chiu; +Cc: palmer, paul.walmsley, linux-spi, linux-riscv, Greentime Hu

[-- Attachment #1: Type: text/plain, Size: 594 bytes --]

On Fri, Jun 10, 2022 at 03:44:59PM +0800, Andy Chiu wrote:

> +static int sifive_spi_suspend(struct device *dev)
> +{
> +	struct spi_master *master = dev_get_drvdata(dev);
> +	struct sifive_spi *spi = spi_master_get_devdata(master);
> +	int ret;
> +
> +	ret = spi_master_suspend(master);
> +	if (ret)
> +		return ret;
> +
> +	/* Disable all the interrupts just in case */
> +	sifive_spi_write(spi, SIFIVE_SPI_REG_IE, 0);
> +
> +	clk_disable_unprepare(spi->clk);

Seems like the clock managemnet could usefully be done as runtime PM
too?  In any case, that can be done as an incremental change.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH next 0/1] Add simple PM operations to sifive-spi
  2022-06-10  7:44 [PATCH next 0/1] Add simple PM operations to sifive-spi Andy Chiu
  2022-06-10  7:44 ` [PATCH next 1/1] spi: sifive: add PM callbacks to support suspend/resume Andy Chiu
@ 2022-06-10 12:05 ` Mark Brown
  2022-06-10 15:59 ` Mark Brown
  2 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2022-06-10 12:05 UTC (permalink / raw)
  To: Andy Chiu; +Cc: palmer, paul.walmsley, linux-spi, linux-riscv

[-- Attachment #1: Type: text/plain, Size: 663 bytes --]

On Fri, Jun 10, 2022 at 03:44:58PM +0800, Andy Chiu wrote:
> The patch has been tested on Unmatched using pm_test. The Unmatched board
> uses SD over SPI and it was tested by initiating S2RAM cycles for all
> devices while reading/writing files at the same time. We found no dropped
> connection to the card or corrupted filesystem during test cycles.

Please don't send cover letters for single patches, if there is anything
that needs saying put it in the changelog of the patch or after the ---
if it's administrative stuff.  This reduces mail volume and ensures that 
any important information is recorded in the changelog rather than being
lost. 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH next 0/1] Add simple PM operations to sifive-spi
  2022-06-10  7:44 [PATCH next 0/1] Add simple PM operations to sifive-spi Andy Chiu
  2022-06-10  7:44 ` [PATCH next 1/1] spi: sifive: add PM callbacks to support suspend/resume Andy Chiu
  2022-06-10 12:05 ` [PATCH next 0/1] Add simple PM operations to sifive-spi Mark Brown
@ 2022-06-10 15:59 ` Mark Brown
  2 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2022-06-10 15:59 UTC (permalink / raw)
  To: linux-spi, andy.chiu, paul.walmsley, linux-riscv, palmer

On Fri, 10 Jun 2022 15:44:58 +0800, Andy Chiu wrote:
> The patch has been tested on Unmatched using pm_test. The Unmatched board
> uses SD over SPI and it was tested by initiating S2RAM cycles for all
> devices while reading/writing files at the same time. We found no dropped
> connection to the card or corrupted filesystem during test cycles.
> 
> Andy Chiu (1):
>   spi: sifive: add PM callbacks to support suspend/resume
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: sifive: add PM callbacks to support suspend/resume
      commit: a1f0161eadbd7941c09b5f4c6a210c390d2b86d6

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH next 1/1] spi: sifive: add PM callbacks to support suspend/resume
  2022-06-10 12:04   ` Mark Brown
@ 2022-06-22  3:06     ` Andy Chiu
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Chiu @ 2022-06-22  3:06 UTC (permalink / raw)
  To: Mark Brown
  Cc: Palmer Dabbelt, Paul Walmsley, linux-spi, linux-riscv, Greentime Hu

> Seems like the clock managemnet could usefully be done as runtime PM
> too?  In any case, that can be done as an incremental change.

Thanks for the suggestion. We will work on it soon in the future.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH next 1/1] spi: sifive: add PM callbacks to support suspend/resume
  2022-06-10  7:44 ` [PATCH next 1/1] spi: sifive: add PM callbacks to support suspend/resume Andy Chiu
  2022-06-10 12:04   ` Mark Brown
@ 2022-06-22 10:24   ` Andy Shevchenko
  1 sibling, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2022-06-22 10:24 UTC (permalink / raw)
  To: Andy Chiu
  Cc: Mark Brown, Palmer Dabbelt, Paul Walmsley, linux-spi,
	linux-riscv, Greentime Hu

On Fri, Jun 10, 2022 at 10:05 AM Andy Chiu <andy.chiu@sifive.com> wrote:
>

Missed changelog.

> Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
> Reviewed-by: Greentime Hu <greentime.hu@sifive.com>

>         .driver = {
>                 .name = SIFIVE_SPI_DRIVER_NAME,
> +               .pm = &sifive_spi_pm_ops,

Missed pm_sleep_ptr(). Have you compiled it with CONFIG_PM_SLEEP=n?
Have you got warnings of unused functions?

>                 .of_match_table = sifive_spi_of_match,
>         },

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-06-22 10:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-10  7:44 [PATCH next 0/1] Add simple PM operations to sifive-spi Andy Chiu
2022-06-10  7:44 ` [PATCH next 1/1] spi: sifive: add PM callbacks to support suspend/resume Andy Chiu
2022-06-10 12:04   ` Mark Brown
2022-06-22  3:06     ` Andy Chiu
2022-06-22 10:24   ` Andy Shevchenko
2022-06-10 12:05 ` [PATCH next 0/1] Add simple PM operations to sifive-spi Mark Brown
2022-06-10 15:59 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).