All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: Nick Hu <nick.hu@sifive.com>,
	zong.li@sifive.com, gregkh@linuxfoundation.org,
	jirislaby@kernel.org, palmer@dabbelt.com,
	paul.walmsley@sifive.com, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org
Subject: Re: [PATCH 1/2] serial: sifive: Add suspend and resume operations
Date: Tue, 8 Aug 2023 09:47:55 +0100	[thread overview]
Message-ID: <12c1e981-b664-b80c-d0df-7e7a098e32b1@codethink.co.uk> (raw)
In-Reply-To: <20230808072625.2109564-1-nick.hu@sifive.com>

On 08/08/2023 08:26, Nick Hu wrote:
> If the Sifive Uart is not used as the wake up source, suspend the uart
> before the system enter the suspend state to prevent it woken up by
> unexpected uart interrupt. Resume the uart once the system woken up.
> 
> Signed-off-by: Nick Hu <nick.hu@sifive.com>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>

^ This should be Reviewed-by, as I did review on this earlier.

> ---
>   drivers/tty/serial/sifive.c | 26 ++++++++++++++++++++++++++
>   1 file changed, 26 insertions(+)
> 
> diff --git a/drivers/tty/serial/sifive.c b/drivers/tty/serial/sifive.c
> index a19db49327e2..87994cb69007 100644
> --- a/drivers/tty/serial/sifive.c
> +++ b/drivers/tty/serial/sifive.c
> @@ -1022,6 +1022,31 @@ static int sifive_serial_remove(struct platform_device *dev)
>   	return 0;
>   }
>   
> +static int sifive_serial_suspend(struct device *dev)
> +{
> +	int ret = 0;
> +	struct sifive_serial_port *ssp = dev_get_drvdata(dev);

Minor annyonance is ordering of ssp and ret, I think the showrter one
last is the nicest looking.

> +	if (ssp && ssp->port.type != PORT_UNKNOWN)
> +		ret = uart_suspend_port(&sifive_serial_uart_driver, &ssp->port);

Do we really need a test for ssp being valid if the device is bound.
Not sure if the port.type is also useful?

> +	return ret;
> +}
> +
> +static int sifive_serial_resume(struct device *dev)
> +{
> +	int ret = 0;
> +	struct sifive_serial_port *ssp = dev_get_drvdata(dev);
> +
> +	if (ssp && ssp->port.type != PORT_UNKNOWN)
> +		ret = uart_resume_port(&sifive_serial_uart_driver, &ssp->port);
> +
> +	return ret;
> +}
> +
> +DEFINE_SIMPLE_DEV_PM_OPS(sifive_uart_pm_ops, sifive_serial_suspend,
> +			 sifive_serial_resume);
> +
>   static const struct of_device_id sifive_serial_of_match[] = {
>   	{ .compatible = "sifive,fu540-c000-uart0" },
>   	{ .compatible = "sifive,uart0" },
> @@ -1034,6 +1059,7 @@ static struct platform_driver sifive_serial_platform_driver = {
>   	.remove		= sifive_serial_remove,
>   	.driver		= {
>   		.name	= SIFIVE_SERIAL_NAME,
> +		.pm = pm_sleep_ptr(&sifive_uart_pm_ops),
>   		.of_match_table = of_match_ptr(sifive_serial_of_match),
>   	},
>   };

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

WARNING: multiple messages have this Message-ID (diff)
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: Nick Hu <nick.hu@sifive.com>,
	zong.li@sifive.com, gregkh@linuxfoundation.org,
	jirislaby@kernel.org, palmer@dabbelt.com,
	paul.walmsley@sifive.com, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org
Subject: Re: [PATCH 1/2] serial: sifive: Add suspend and resume operations
Date: Tue, 8 Aug 2023 09:47:55 +0100	[thread overview]
Message-ID: <12c1e981-b664-b80c-d0df-7e7a098e32b1@codethink.co.uk> (raw)
In-Reply-To: <20230808072625.2109564-1-nick.hu@sifive.com>

On 08/08/2023 08:26, Nick Hu wrote:
> If the Sifive Uart is not used as the wake up source, suspend the uart
> before the system enter the suspend state to prevent it woken up by
> unexpected uart interrupt. Resume the uart once the system woken up.
> 
> Signed-off-by: Nick Hu <nick.hu@sifive.com>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>

^ This should be Reviewed-by, as I did review on this earlier.

> ---
>   drivers/tty/serial/sifive.c | 26 ++++++++++++++++++++++++++
>   1 file changed, 26 insertions(+)
> 
> diff --git a/drivers/tty/serial/sifive.c b/drivers/tty/serial/sifive.c
> index a19db49327e2..87994cb69007 100644
> --- a/drivers/tty/serial/sifive.c
> +++ b/drivers/tty/serial/sifive.c
> @@ -1022,6 +1022,31 @@ static int sifive_serial_remove(struct platform_device *dev)
>   	return 0;
>   }
>   
> +static int sifive_serial_suspend(struct device *dev)
> +{
> +	int ret = 0;
> +	struct sifive_serial_port *ssp = dev_get_drvdata(dev);

Minor annyonance is ordering of ssp and ret, I think the showrter one
last is the nicest looking.

> +	if (ssp && ssp->port.type != PORT_UNKNOWN)
> +		ret = uart_suspend_port(&sifive_serial_uart_driver, &ssp->port);

Do we really need a test for ssp being valid if the device is bound.
Not sure if the port.type is also useful?

> +	return ret;
> +}
> +
> +static int sifive_serial_resume(struct device *dev)
> +{
> +	int ret = 0;
> +	struct sifive_serial_port *ssp = dev_get_drvdata(dev);
> +
> +	if (ssp && ssp->port.type != PORT_UNKNOWN)
> +		ret = uart_resume_port(&sifive_serial_uart_driver, &ssp->port);
> +
> +	return ret;
> +}
> +
> +DEFINE_SIMPLE_DEV_PM_OPS(sifive_uart_pm_ops, sifive_serial_suspend,
> +			 sifive_serial_resume);
> +
>   static const struct of_device_id sifive_serial_of_match[] = {
>   	{ .compatible = "sifive,fu540-c000-uart0" },
>   	{ .compatible = "sifive,uart0" },
> @@ -1034,6 +1059,7 @@ static struct platform_driver sifive_serial_platform_driver = {
>   	.remove		= sifive_serial_remove,
>   	.driver		= {
>   		.name	= SIFIVE_SERIAL_NAME,
> +		.pm = pm_sleep_ptr(&sifive_uart_pm_ops),
>   		.of_match_table = of_match_ptr(sifive_serial_of_match),
>   	},
>   };

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html


  parent reply	other threads:[~2023-08-08  8:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-08  7:26 [PATCH 1/2] serial: sifive: Add suspend and resume operations Nick Hu
2023-08-08  7:26 ` Nick Hu
2023-08-08  8:44 ` Conor Dooley
2023-08-08  8:44   ` Conor Dooley
2023-08-09  1:54   ` Nick Hu
2023-08-09  1:54     ` Nick Hu
2023-08-08  8:47 ` Ben Dooks [this message]
2023-08-08  8:47   ` Ben Dooks
2023-08-09  2:10   ` Nick Hu
2023-08-09  2:10     ` Nick Hu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12c1e981-b664-b80c-d0df-7e7a098e32b1@codethink.co.uk \
    --to=ben.dooks@codethink.co.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=nick.hu@sifive.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=zong.li@sifive.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.