2023-08-09 14:55:01

by Nick Hu

[permalink] [raw]
Subject: [PATCH v2 0/1] Add Sifive uart suspend and resume

Add Sifive uart suspend and resume functions for system suspend.

Changes in v2:
- Change Signed-off-by: Ben Dooks to Reviewed-by: Ben Dooks
- Remove the unnecessary check

Nick Hu (1):
serial: sifive: Add suspend and resume operations

drivers/tty/serial/sifive.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

--
2.34.1



2023-08-09 15:29:37

by Nick Hu

[permalink] [raw]
Subject: [PATCH v2 1/1] serial: sifive: Add suspend and resume operations

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 <[email protected]>
Reviewed-by: Ben Dooks <[email protected]>
---
drivers/tty/serial/sifive.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

diff --git a/drivers/tty/serial/sifive.c b/drivers/tty/serial/sifive.c
index a19db49327e2..939dd351a058 100644
--- a/drivers/tty/serial/sifive.c
+++ b/drivers/tty/serial/sifive.c
@@ -1022,6 +1022,23 @@ static int sifive_serial_remove(struct platform_device *dev)
return 0;
}

+static int sifive_serial_suspend(struct device *dev)
+{
+ struct sifive_serial_port *ssp = dev_get_drvdata(dev);
+
+ return uart_suspend_port(&sifive_serial_uart_driver, &ssp->port);
+}
+
+static int sifive_serial_resume(struct device *dev)
+{
+ struct sifive_serial_port *ssp = dev_get_drvdata(dev);
+
+ return uart_resume_port(&sifive_serial_uart_driver, &ssp->port);
+}
+
+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 +1051,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),
},
};
--
2.34.1


2023-08-11 20:13:40

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v2 0/1] Add Sifive uart suspend and resume

On Wed, Aug 09, 2023 at 09:50:41PM +0800, Nick Hu wrote:
> Add Sifive uart suspend and resume functions for system suspend.
>
> Changes in v2:
> - Change Signed-off-by: Ben Dooks to Reviewed-by: Ben Dooks
> - Remove the unnecessary check
>
> Nick Hu (1):
> serial: sifive: Add suspend and resume operations
>
> drivers/tty/serial/sifive.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> --
> 2.34.1
>

Does not apply to my tree :(

2023-08-14 07:33:25

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v2 0/1] Add Sifive uart suspend and resume

On Mon, Aug 14, 2023 at 01:55:58PM +0800, Nick Hu wrote:
> Hi Greg
>
> On Sat, Aug 12, 2023 at 3:11 AM Greg KH <[email protected]> wrote:
> >
> > On Wed, Aug 09, 2023 at 09:50:41PM +0800, Nick Hu wrote:
> > > Add Sifive uart suspend and resume functions for system suspend.
> > >
> > > Changes in v2:
> > > - Change Signed-off-by: Ben Dooks to Reviewed-by: Ben Dooks
> > > - Remove the unnecessary check
> > >
> > > Nick Hu (1):
> > > serial: sifive: Add suspend and resume operations
> > >
> > > drivers/tty/serial/sifive.c | 18 ++++++++++++++++++
> > > 1 file changed, 18 insertions(+)
> > >
> > > --
> > > 2.34.1
> > >
> >
> > Does not apply to my tree :(
> Is there any reason that it doesn't apply to your tree?
> Which tree should I go?

Which tree did you make it against? It doesn't apply due to conflicts.
Perhaps either regenerate it against the tty-next branch of the tty.git
tree, or linux-next?

thanks,

greg k-h

2023-08-14 07:34:52

by Nick Hu

[permalink] [raw]
Subject: Re: [PATCH v2 0/1] Add Sifive uart suspend and resume

Hi Greg

On Sat, Aug 12, 2023 at 3:11 AM Greg KH <[email protected]> wrote:
>
> On Wed, Aug 09, 2023 at 09:50:41PM +0800, Nick Hu wrote:
> > Add Sifive uart suspend and resume functions for system suspend.
> >
> > Changes in v2:
> > - Change Signed-off-by: Ben Dooks to Reviewed-by: Ben Dooks
> > - Remove the unnecessary check
> >
> > Nick Hu (1):
> > serial: sifive: Add suspend and resume operations
> >
> > drivers/tty/serial/sifive.c | 18 ++++++++++++++++++
> > 1 file changed, 18 insertions(+)
> >
> > --
> > 2.34.1
> >
>
> Does not apply to my tree :(
Is there any reason that it doesn't apply to your tree?
Which tree should I go?

2023-08-14 09:42:13

by Nick Hu

[permalink] [raw]
Subject: Re: [PATCH v2 0/1] Add Sifive uart suspend and resume

Hi Greg

On Mon, Aug 14, 2023 at 2:02 PM Greg KH <[email protected]> wrote:
>
> On Mon, Aug 14, 2023 at 01:55:58PM +0800, Nick Hu wrote:
> > Hi Greg
> >
> > On Sat, Aug 12, 2023 at 3:11 AM Greg KH <[email protected]> wrote:
> > >
> > > On Wed, Aug 09, 2023 at 09:50:41PM +0800, Nick Hu wrote:
> > > > Add Sifive uart suspend and resume functions for system suspend.
> > > >
> > > > Changes in v2:
> > > > - Change Signed-off-by: Ben Dooks to Reviewed-by: Ben Dooks
> > > > - Remove the unnecessary check
> > > >
> > > > Nick Hu (1):
> > > > serial: sifive: Add suspend and resume operations
> > > >
> > > > drivers/tty/serial/sifive.c | 18 ++++++++++++++++++
> > > > 1 file changed, 18 insertions(+)
> > > >
> > > > --
> > > > 2.34.1
> > > >
> > >
> > > Does not apply to my tree :(
> > Is there any reason that it doesn't apply to your tree?
> > Which tree should I go?
>
> Which tree did you make it against? It doesn't apply due to conflicts.
> Perhaps either regenerate it against the tty-next branch of the tty.git
> tree, or linux-next?
>
> thanks,
>
> greg k-h
I'm using the mainline linux kernel.
Thanks for the information.
I can reproduce it in tty-next branch of the tty.git!
I'll fix it in v3.

Regards,
Nick