Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1203679 > unrolled thread

[PATCH 5/8] serial: imx: save and restore context in the suspend path

Started byEduardo Valentin <edubezval@gmail.com>
First post2015-08-09 20:30 +0200
Last post2015-08-11 02:00 +0200
Articles 5 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 5/8] serial: imx: save and restore context in the suspend path Eduardo Valentin <edubezval@gmail.com> - 2015-08-09 20:30 +0200
    Re: [PATCH 5/8] serial: imx: save and restore context in the suspend path Fabio Estevam <festevam@gmail.com> - 2015-08-10 05:40 +0200
      Re: [PATCH 5/8] serial: imx: save and restore context in the suspend  path Eduardo Valentin <edubezval@gmail.com> - 2015-08-10 06:10 +0200
        Re: [PATCH 5/8] serial: imx: save and restore context in the suspend path Fabio Estevam <festevam@gmail.com> - 2015-08-10 14:20 +0200
          Re: [PATCH 5/8] serial: imx: save and restore context in the suspend  path Eduardo Valentin <edubezval@gmail.com> - 2015-08-11 02:00 +0200

#1203679 — [PATCH 5/8] serial: imx: save and restore context in the suspend path

FromEduardo Valentin <edubezval@gmail.com>
Date2015-08-09 20:30 +0200
Subject[PATCH 5/8] serial: imx: save and restore context in the suspend path
Message-ID<pVDw5-5Jn-13@gated-at.bofh.it>
This change teaches the imx serial driver to save its
context and restore it across suspend and resume path.
To do so, it introduces serial_imx_restore_context()
and serial_imx_save_context() functions. They use
a shadow set of registers to save key registers
and restore them accordingly. These functions can
be reused on other situations, when the device
context is lost.

Cc: Fabio Stevam <festevam@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/tty/serial/imx.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index a03855d..494b182 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -217,6 +217,8 @@ struct imx_port {
 	unsigned int		tx_bytes;
 	unsigned int		dma_tx_nents;
 	wait_queue_head_t	dma_wait;
+	unsigned int		saved_reg[8];
+	bool			context_saved;
 };
 
 struct imx_port_ucrs {
@@ -1803,6 +1805,36 @@ static struct uart_driver imx_reg = {
 	.cons           = IMX_CONSOLE,
 };
 
+static void serial_imx_restore_context(struct imx_port *sport)
+{
+	if (!sport->context_saved)
+		return;
+
+	writel(sport->saved_reg[4], sport->port.membase + UFCR);
+	writel(sport->saved_reg[5], sport->port.membase + UBIR);
+	writel(sport->saved_reg[6], sport->port.membase + UBMR);
+	writel(sport->saved_reg[7], sport->port.membase + IMX21_UTS);
+	writel(sport->saved_reg[0], sport->port.membase + UCR1);
+	writel(sport->saved_reg[1] | 0x1, sport->port.membase + UCR2);
+	writel(sport->saved_reg[2], sport->port.membase + UCR3);
+	writel(sport->saved_reg[3], sport->port.membase + UCR4);
+	sport->context_saved = false;
+}
+
+static void serial_imx_save_context(struct imx_port *sport)
+{
+	/* Save necessary regs */
+	sport->saved_reg[0] = readl(sport->port.membase + UCR1);
+	sport->saved_reg[1] = readl(sport->port.membase + UCR2);
+	sport->saved_reg[2] = readl(sport->port.membase + UCR3);
+	sport->saved_reg[3] = readl(sport->port.membase + UCR4);
+	sport->saved_reg[4] = readl(sport->port.membase + UFCR);
+	sport->saved_reg[5] = readl(sport->port.membase + UBIR);
+	sport->saved_reg[6] = readl(sport->port.membase + UBMR);
+	sport->saved_reg[7] = readl(sport->port.membase + IMX21_UTS);
+	sport->context_saved = true;
+}
+
 static void serial_imx_enable_wakeup(struct imx_port *sport, bool on)
 {
 	unsigned int val;
@@ -1826,6 +1858,7 @@ static int serial_imx_suspend(struct device *dev)
 {
 	struct imx_port *sport = dev_get_drvdata(dev);
 
+	serial_imx_save_context(sport);
 	/* enable wakeup from i.MX UART */
 	serial_imx_enable_wakeup(sport, true);
 
@@ -1841,6 +1874,7 @@ static int serial_imx_resume(struct device *dev)
 	/* disable wakeup from i.MX UART */
 	serial_imx_enable_wakeup(sport, false);
 
+	serial_imx_restore_context(sport);
 	uart_resume_port(&imx_reg, &sport->port);
 
 	return 0;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1203760

FromFabio Estevam <festevam@gmail.com>
Date2015-08-10 05:40 +0200
Message-ID<pVM6m-1Gs-1@gated-at.bofh.it>
In reply to#1203679
Hi Eduardo,

On Sun, Aug 9, 2015 at 3:19 PM, Eduardo Valentin <edubezval@gmail.com> wrote:
> This change teaches the imx serial driver to save its
> context and restore it across suspend and resume path.
> To do so, it introduces serial_imx_restore_context()
> and serial_imx_save_context() functions. They use
> a shadow set of registers to save key registers
> and restore them accordingly. These functions can
> be reused on other situations, when the device
> context is lost.
>
> Cc: Fabio Stevam <festevam@gmail.com>

s/Stevam/Estevam (applies to all the patches)

> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Jiri Slaby <jslaby@suse.com>
> Cc: linux-serial@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
> ---
>  drivers/tty/serial/imx.c | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
>
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index a03855d..494b182 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -217,6 +217,8 @@ struct imx_port {
>         unsigned int            tx_bytes;
>         unsigned int            dma_tx_nents;
>         wait_queue_head_t       dma_wait;
> +       unsigned int            saved_reg[8];
> +       bool                    context_saved;
>  };
>
>  struct imx_port_ucrs {
> @@ -1803,6 +1805,36 @@ static struct uart_driver imx_reg = {
>         .cons           = IMX_CONSOLE,
>  };
>
> +static void serial_imx_restore_context(struct imx_port *sport)
> +{
> +       if (!sport->context_saved)
> +               return;
> +
> +       writel(sport->saved_reg[4], sport->port.membase + UFCR);
> +       writel(sport->saved_reg[5], sport->port.membase + UBIR);
> +       writel(sport->saved_reg[6], sport->port.membase + UBMR);
> +       writel(sport->saved_reg[7], sport->port.membase + IMX21_UTS);
> +       writel(sport->saved_reg[0], sport->port.membase + UCR1);
> +       writel(sport->saved_reg[1] | 0x1, sport->port.membase + UCR2);
> +       writel(sport->saved_reg[2], sport->port.membase + UCR3);
> +       writel(sport->saved_reg[3], sport->port.membase + UCR4);
> +       sport->context_saved = false;
> +}
> +
> +static void serial_imx_save_context(struct imx_port *sport)
> +{
> +       /* Save necessary regs */
> +       sport->saved_reg[0] = readl(sport->port.membase + UCR1);
> +       sport->saved_reg[1] = readl(sport->port.membase + UCR2);
> +       sport->saved_reg[2] = readl(sport->port.membase + UCR3);
> +       sport->saved_reg[3] = readl(sport->port.membase + UCR4);
> +       sport->saved_reg[4] = readl(sport->port.membase + UFCR);
> +       sport->saved_reg[5] = readl(sport->port.membase + UBIR);
> +       sport->saved_reg[6] = readl(sport->port.membase + UBMR);
> +       sport->saved_reg[7] = readl(sport->port.membase + IMX21_UTS);
> +       sport->context_saved = true;
> +}

This seems to be similar to what Shenwei posted earlier:
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-July/360841.html

Regards,

Fabio Estevam
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1203762 — Re: [PATCH 5/8] serial: imx: save and restore context in the suspend path

FromEduardo Valentin <edubezval@gmail.com>
Date2015-08-10 06:10 +0200
SubjectRe: [PATCH 5/8] serial: imx: save and restore context in the suspend path
Message-ID<pVMzn-2zZ-3@gated-at.bofh.it>
In reply to#1203760
On Mon, Aug 10, 2015 at 12:30:18AM -0300, Fabio Estevam wrote:
> Hi Eduardo,
> 
> On Sun, Aug 9, 2015 at 3:19 PM, Eduardo Valentin <edubezval@gmail.com> wrote:
> > This change teaches the imx serial driver to save its
> > context and restore it across suspend and resume path.
> > To do so, it introduces serial_imx_restore_context()
> > and serial_imx_save_context() functions. They use
> > a shadow set of registers to save key registers
> > and restore them accordingly. These functions can
> > be reused on other situations, when the device
> > context is lost.
> >
> > Cc: Fabio Stevam <festevam@gmail.com>
> 
> s/Stevam/Estevam (applies to all the patches)

Sorry, my bad here.

> 
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Cc: Jiri Slaby <jslaby@suse.com>
> > Cc: linux-serial@vger.kernel.org
> > Cc: linux-kernel@vger.kernel.org
> > Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
> > ---
> >  drivers/tty/serial/imx.c | 34 ++++++++++++++++++++++++++++++++++
> >  1 file changed, 34 insertions(+)
> >
> > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> > index a03855d..494b182 100644
> > --- a/drivers/tty/serial/imx.c
> > +++ b/drivers/tty/serial/imx.c
> > @@ -217,6 +217,8 @@ struct imx_port {
> >         unsigned int            tx_bytes;
> >         unsigned int            dma_tx_nents;
> >         wait_queue_head_t       dma_wait;
> > +       unsigned int            saved_reg[8];
> > +       bool                    context_saved;
> >  };
> >
> >  struct imx_port_ucrs {
> > @@ -1803,6 +1805,36 @@ static struct uart_driver imx_reg = {
> >         .cons           = IMX_CONSOLE,
> >  };
> >
> > +static void serial_imx_restore_context(struct imx_port *sport)
> > +{
> > +       if (!sport->context_saved)
> > +               return;
> > +
> > +       writel(sport->saved_reg[4], sport->port.membase + UFCR);
> > +       writel(sport->saved_reg[5], sport->port.membase + UBIR);
> > +       writel(sport->saved_reg[6], sport->port.membase + UBMR);
> > +       writel(sport->saved_reg[7], sport->port.membase + IMX21_UTS);
> > +       writel(sport->saved_reg[0], sport->port.membase + UCR1);
> > +       writel(sport->saved_reg[1] | 0x1, sport->port.membase + UCR2);
> > +       writel(sport->saved_reg[2], sport->port.membase + UCR3);
> > +       writel(sport->saved_reg[3], sport->port.membase + UCR4);
> > +       sport->context_saved = false;
> > +}
> > +
> > +static void serial_imx_save_context(struct imx_port *sport)
> > +{
> > +       /* Save necessary regs */
> > +       sport->saved_reg[0] = readl(sport->port.membase + UCR1);
> > +       sport->saved_reg[1] = readl(sport->port.membase + UCR2);
> > +       sport->saved_reg[2] = readl(sport->port.membase + UCR3);
> > +       sport->saved_reg[3] = readl(sport->port.membase + UCR4);
> > +       sport->saved_reg[4] = readl(sport->port.membase + UFCR);
> > +       sport->saved_reg[5] = readl(sport->port.membase + UBIR);
> > +       sport->saved_reg[6] = readl(sport->port.membase + UBMR);
> > +       sport->saved_reg[7] = readl(sport->port.membase + IMX21_UTS);
> > +       sport->context_saved = true;
> > +}
> 
> This seems to be similar to what Shenwei posted earlier:
> http://lists.infradead.org/pipermail/linux-arm-kernel/2015-July/360841.html

OK. Do you know what is the status of that patch set?

did it get accepted by any tree so far?

> 
> Regards,
> 
> Fabio Estevam
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1204210

FromFabio Estevam <festevam@gmail.com>
Date2015-08-10 14:20 +0200
Message-ID<pVUdA-62u-19@gated-at.bofh.it>
In reply to#1203762
On Mon, Aug 10, 2015 at 1:04 AM, Eduardo Valentin <edubezval@gmail.com> wrote:

> OK. Do you know what is the status of that patch set?
>
> did it get accepted by any tree so far?

It is in linux-next.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1204641 — Re: [PATCH 5/8] serial: imx: save and restore context in the suspend path

FromEduardo Valentin <edubezval@gmail.com>
Date2015-08-11 02:00 +0200
SubjectRe: [PATCH 5/8] serial: imx: save and restore context in the suspend path
Message-ID<pW590-4LG-3@gated-at.bofh.it>
In reply to#1204210

[Multipart message — attachments visible in raw view] — view raw

On Mon, Aug 10, 2015 at 09:17:55AM -0300, Fabio Estevam wrote:
> On Mon, Aug 10, 2015 at 1:04 AM, Eduardo Valentin <edubezval@gmail.com> wrote:
> 
> > OK. Do you know what is the status of that patch set?
> >
> > did it get accepted by any tree so far?
> 
> It is in linux-next.

Ok. I am rebasing my changes then. I will fix the naming issue too.

BR,

Eduardo Valentin

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web