All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 04/10] serial: sh-sci: console runtime PM support (revisit)
Date: Wed, 07 Nov 2012 06:59:06 +0000	[thread overview]
Message-ID: <509A06BA.30101@renesas.com> (raw)
In-Reply-To: <509A0658.1010503@renesas.com>

The commit 1ba7622094 (serial: sh-sci: console Runtime PM support,
from Magnus Damm <damm@opensource.se>, 2011-08-03), tried to support
console runtime PM, but unfortunately it didn't work for us for some
reason.  We did not investigated further at that time, instead would
like to propose a different approach.

In Linux tty/serial world, to get console PM work properly, a serial
client driver does not have to maintain .runtime_suspend()/..resume()
calls itself, but can leave console power power management handling to
the serial core driver.

This patch moves the sh-sci driver in that direction.

Notes:

* There is room to optimize console runtime PM more aggressively by
  maintaining additional local runtime PM calls, but as a first step
  having .pm() operation would suffice.

* We still have a couple of direct calls to sci_port_enable/..disable
  left in the driver.  We have to live with them, because they're out
  of serial core's help.

Signed-off-by: Teppei Kamijou <teppei.kamijou.yb@renesas.com>
Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
---
 drivers/tty/serial/sh-sci.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index e9e8883..e65e546 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1746,8 +1746,6 @@ static int sci_startup(struct uart_port *port)
 
 	dev_dbg(port->dev, "%s(%d)\n", __func__, port->line);
 
-	sci_port_enable(s);
-
 	ret = sci_request_irq(s);
 	if (unlikely(ret < 0))
 		return ret;
@@ -1771,8 +1769,6 @@ static void sci_shutdown(struct uart_port *port)
 
 	sci_free_dma(port);
 	sci_free_irq(s);
-
-	sci_port_disable(s);
 }
 
 static unsigned int sci_scbrr_calc(unsigned int algo_id, unsigned int bps,
@@ -1921,6 +1917,21 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
 	sci_port_disable(s);
 }
 
+static void sci_pm(struct uart_port *port, unsigned int state,
+		   unsigned int oldstate)
+{
+	struct sci_port *sci_port = to_sci_port(port);
+
+	switch (state) {
+	case 3:
+		sci_port_disable(sci_port);
+		break;
+	default:
+		sci_port_enable(sci_port);
+		break;
+	}
+}
+
 static const char *sci_type(struct uart_port *port)
 {
 	switch (port->type) {
@@ -2042,6 +2053,7 @@ static struct uart_ops sci_uart_ops = {
 	.startup	= sci_startup,
 	.shutdown	= sci_shutdown,
 	.set_termios	= sci_set_termios,
+	.pm		= sci_pm,
 	.type		= sci_type,
 	.release_port	= sci_release_port,
 	.request_port	= sci_request_port,
@@ -2195,16 +2207,12 @@ static void serial_console_write(struct console *co, const char *s,
 	struct uart_port *port = &sci_port->port;
 	unsigned short bits;
 
-	sci_port_enable(sci_port);
-
 	uart_console_write(port, s, count, serial_console_putchar);
 
 	/* wait until fifo is empty and last bit has been transmitted */
 	bits = SCxSR_TDxE(port) | SCxSR_TEND(port);
 	while ((serial_port_in(port, SCxSR) & bits) != bits)
 		cpu_relax();
-
-	sci_port_disable(sci_port);
 }
 
 static int __devinit serial_console_setup(struct console *co, char *options)
@@ -2236,12 +2244,9 @@ static int __devinit serial_console_setup(struct console *co, char *options)
 	if (unlikely(ret != 0))
 		return ret;
 
-	sci_port_enable(sci_port);
-
 	if (options)
 		uart_parse_options(options, &baud, &parity, &bits, &flow);
 
-	/* TODO: disable clock */
 	return uart_set_options(port, co, baud, parity, bits, flow);
 }
 
-- 
1.7.12.4


WARNING: multiple messages have this Message-ID (diff)
From: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
To: lethal@linux-sh.org, magnus.damm@gmail.com, rjw@sisk.pl,
	alan@linux.intel.com, gregkh@linuxfoundation.org
Cc: takashi.yoshii.zj@renesas.com, linux-serial@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-sh@vger.kernel.org
Subject: [PATCH 04/10] serial: sh-sci: console runtime PM support (revisit)
Date: Wed, 07 Nov 2012 15:59:06 +0900	[thread overview]
Message-ID: <509A06BA.30101@renesas.com> (raw)
In-Reply-To: <509A0658.1010503@renesas.com>

The commit 1ba7622094 (serial: sh-sci: console Runtime PM support,
from Magnus Damm <damm@opensource.se>, 2011-08-03), tried to support
console runtime PM, but unfortunately it didn't work for us for some
reason.  We did not investigated further at that time, instead would
like to propose a different approach.

In Linux tty/serial world, to get console PM work properly, a serial
client driver does not have to maintain .runtime_suspend()/..resume()
calls itself, but can leave console power power management handling to
the serial core driver.

This patch moves the sh-sci driver in that direction.

Notes:

* There is room to optimize console runtime PM more aggressively by
  maintaining additional local runtime PM calls, but as a first step
  having .pm() operation would suffice.

* We still have a couple of direct calls to sci_port_enable/..disable
  left in the driver.  We have to live with them, because they're out
  of serial core's help.

Signed-off-by: Teppei Kamijou <teppei.kamijou.yb@renesas.com>
Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
---
 drivers/tty/serial/sh-sci.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index e9e8883..e65e546 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1746,8 +1746,6 @@ static int sci_startup(struct uart_port *port)
 
 	dev_dbg(port->dev, "%s(%d)\n", __func__, port->line);
 
-	sci_port_enable(s);
-
 	ret = sci_request_irq(s);
 	if (unlikely(ret < 0))
 		return ret;
@@ -1771,8 +1769,6 @@ static void sci_shutdown(struct uart_port *port)
 
 	sci_free_dma(port);
 	sci_free_irq(s);
-
-	sci_port_disable(s);
 }
 
 static unsigned int sci_scbrr_calc(unsigned int algo_id, unsigned int bps,
@@ -1921,6 +1917,21 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
 	sci_port_disable(s);
 }
 
+static void sci_pm(struct uart_port *port, unsigned int state,
+		   unsigned int oldstate)
+{
+	struct sci_port *sci_port = to_sci_port(port);
+
+	switch (state) {
+	case 3:
+		sci_port_disable(sci_port);
+		break;
+	default:
+		sci_port_enable(sci_port);
+		break;
+	}
+}
+
 static const char *sci_type(struct uart_port *port)
 {
 	switch (port->type) {
@@ -2042,6 +2053,7 @@ static struct uart_ops sci_uart_ops = {
 	.startup	= sci_startup,
 	.shutdown	= sci_shutdown,
 	.set_termios	= sci_set_termios,
+	.pm		= sci_pm,
 	.type		= sci_type,
 	.release_port	= sci_release_port,
 	.request_port	= sci_request_port,
@@ -2195,16 +2207,12 @@ static void serial_console_write(struct console *co, const char *s,
 	struct uart_port *port = &sci_port->port;
 	unsigned short bits;
 
-	sci_port_enable(sci_port);
-
 	uart_console_write(port, s, count, serial_console_putchar);
 
 	/* wait until fifo is empty and last bit has been transmitted */
 	bits = SCxSR_TDxE(port) | SCxSR_TEND(port);
 	while ((serial_port_in(port, SCxSR) & bits) != bits)
 		cpu_relax();
-
-	sci_port_disable(sci_port);
 }
 
 static int __devinit serial_console_setup(struct console *co, char *options)
@@ -2236,12 +2244,9 @@ static int __devinit serial_console_setup(struct console *co, char *options)
 	if (unlikely(ret != 0))
 		return ret;
 
-	sci_port_enable(sci_port);
-
 	if (options)
 		uart_parse_options(options, &baud, &parity, &bits, &flow);
 
-	/* TODO: disable clock */
 	return uart_set_options(port, co, baud, parity, bits, flow);
 }
 
-- 
1.7.12.4


WARNING: multiple messages have this Message-ID (diff)
From: shinya.kuribayashi.px@renesas.com (Shinya Kuribayashi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 04/10] serial: sh-sci: console runtime PM support (revisit)
Date: Wed, 07 Nov 2012 15:59:06 +0900	[thread overview]
Message-ID: <509A06BA.30101@renesas.com> (raw)
In-Reply-To: <509A0658.1010503@renesas.com>

The commit 1ba7622094 (serial: sh-sci: console Runtime PM support,
from Magnus Damm <damm@opensource.se>, 2011-08-03), tried to support
console runtime PM, but unfortunately it didn't work for us for some
reason.  We did not investigated further at that time, instead would
like to propose a different approach.

In Linux tty/serial world, to get console PM work properly, a serial
client driver does not have to maintain .runtime_suspend()/..resume()
calls itself, but can leave console power power management handling to
the serial core driver.

This patch moves the sh-sci driver in that direction.

Notes:

* There is room to optimize console runtime PM more aggressively by
  maintaining additional local runtime PM calls, but as a first step
  having .pm() operation would suffice.

* We still have a couple of direct calls to sci_port_enable/..disable
  left in the driver.  We have to live with them, because they're out
  of serial core's help.

Signed-off-by: Teppei Kamijou <teppei.kamijou.yb@renesas.com>
Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
---
 drivers/tty/serial/sh-sci.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index e9e8883..e65e546 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1746,8 +1746,6 @@ static int sci_startup(struct uart_port *port)
 
 	dev_dbg(port->dev, "%s(%d)\n", __func__, port->line);
 
-	sci_port_enable(s);
-
 	ret = sci_request_irq(s);
 	if (unlikely(ret < 0))
 		return ret;
@@ -1771,8 +1769,6 @@ static void sci_shutdown(struct uart_port *port)
 
 	sci_free_dma(port);
 	sci_free_irq(s);
-
-	sci_port_disable(s);
 }
 
 static unsigned int sci_scbrr_calc(unsigned int algo_id, unsigned int bps,
@@ -1921,6 +1917,21 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
 	sci_port_disable(s);
 }
 
+static void sci_pm(struct uart_port *port, unsigned int state,
+		   unsigned int oldstate)
+{
+	struct sci_port *sci_port = to_sci_port(port);
+
+	switch (state) {
+	case 3:
+		sci_port_disable(sci_port);
+		break;
+	default:
+		sci_port_enable(sci_port);
+		break;
+	}
+}
+
 static const char *sci_type(struct uart_port *port)
 {
 	switch (port->type) {
@@ -2042,6 +2053,7 @@ static struct uart_ops sci_uart_ops = {
 	.startup	= sci_startup,
 	.shutdown	= sci_shutdown,
 	.set_termios	= sci_set_termios,
+	.pm		= sci_pm,
 	.type		= sci_type,
 	.release_port	= sci_release_port,
 	.request_port	= sci_request_port,
@@ -2195,16 +2207,12 @@ static void serial_console_write(struct console *co, const char *s,
 	struct uart_port *port = &sci_port->port;
 	unsigned short bits;
 
-	sci_port_enable(sci_port);
-
 	uart_console_write(port, s, count, serial_console_putchar);
 
 	/* wait until fifo is empty and last bit has been transmitted */
 	bits = SCxSR_TDxE(port) | SCxSR_TEND(port);
 	while ((serial_port_in(port, SCxSR) & bits) != bits)
 		cpu_relax();
-
-	sci_port_disable(sci_port);
 }
 
 static int __devinit serial_console_setup(struct console *co, char *options)
@@ -2236,12 +2244,9 @@ static int __devinit serial_console_setup(struct console *co, char *options)
 	if (unlikely(ret != 0))
 		return ret;
 
-	sci_port_enable(sci_port);
-
 	if (options)
 		uart_parse_options(options, &baud, &parity, &bits, &flow);
 
-	/* TODO: disable clock */
 	return uart_set_options(port, co, baud, parity, bits, flow);
 }
 
-- 
1.7.12.4

  parent reply	other threads:[~2012-11-07  6:59 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-07  6:57 [PATCH 00/10] serial: sh-sci fixes - console PM, SCIFB, SMP lockup, etc Shinya Kuribayashi
2012-11-07  6:57 ` Shinya Kuribayashi
2012-11-07  6:57 ` Shinya Kuribayashi
2012-11-07  6:58 ` [PATCH 01/10] Revert "sh-sci / PM: Avoid deadlocking runtime PM" Shinya Kuribayashi
2012-11-07  6:58   ` Shinya Kuribayashi
2012-11-07  6:58   ` Shinya Kuribayashi
2012-11-07  6:58 ` [PATCH 02/10] Revert "sh-sci / PM: Use power.irq_safe" Shinya Kuribayashi
2012-11-07  6:58   ` Shinya Kuribayashi
2012-11-07  6:58   ` Shinya Kuribayashi
2012-11-07  6:58 ` [PATCH 03/10] Partially revert "serial: sh-sci: console Runtime PM support" Shinya Kuribayashi
2012-11-07  6:58   ` Shinya Kuribayashi
2012-11-07  6:58   ` Shinya Kuribayashi
2012-11-07  6:59 ` Shinya Kuribayashi [this message]
2012-11-07  6:59   ` [PATCH 04/10] serial: sh-sci: console runtime PM support (revisit) Shinya Kuribayashi
2012-11-07  6:59   ` Shinya Kuribayashi
2012-11-07  6:59 ` [PATCH 05/10] serial: sh-sci: fix condition test to set SCBRR Shinya Kuribayashi
2012-11-07  6:59   ` Shinya Kuribayashi
2012-11-07  6:59   ` Shinya Kuribayashi
2012-11-07  6:59 ` [PATCH 06/10] serial: sh-sci: support lower baud rate Shinya Kuribayashi
2012-11-07  6:59   ` Shinya Kuribayashi
2012-11-07  6:59   ` Shinya Kuribayashi
2012-11-07  7:00 ` [PATCH 07/10] serial: sh-sci: mask SCTFDR/RFDR according to fifosize Shinya Kuribayashi
2012-11-07  7:00   ` Shinya Kuribayashi
2012-11-07  7:00   ` Shinya Kuribayashi
2012-11-07  7:00 ` [PATCH 08/10] serial: sh-sci: fix common SCIFB regmap definition Shinya Kuribayashi
2012-11-07  7:00   ` Shinya Kuribayashi
2012-11-07  7:00   ` Shinya Kuribayashi
2012-11-07  7:00 ` [PATCH 09/10] serial: sh-sci: add locking to console write function to avoid SMP lockup Shinya Kuribayashi
2012-11-07  7:00   ` Shinya Kuribayashi
2012-11-07  7:00   ` Shinya Kuribayashi
2012-11-07  7:01 ` [PATCH 10/10] serial: sh-sci: fix possible race cases on SCSCR register accesses Shinya Kuribayashi
2012-11-07  7:01   ` Shinya Kuribayashi
2012-11-07  7:01   ` Shinya Kuribayashi
2012-11-07  7:18 ` [PATCH 00/10] serial: sh-sci fixes - console PM, SCIFB, SMP lockup, etc Shinya Kuribayashi
2012-11-07  7:18   ` Shinya Kuribayashi
2012-11-07  7:18   ` Shinya Kuribayashi
2012-11-16  1:01   ` Greg KH
2012-11-16  1:01     ` Greg KH
2012-11-16  1:01     ` Greg KH
2012-11-16  1:49     ` [PATCH v2 " Shinya Kuribayashi
2012-11-16  1:49       ` Shinya Kuribayashi
2012-11-16  1:49       ` Shinya Kuribayashi
2012-11-16  1:50       ` [PATCH v2 01/10] Revert "sh-sci / PM: Avoid deadlocking runtime PM" Shinya Kuribayashi
2012-11-16  1:50         ` Shinya Kuribayashi
2012-11-16  1:50         ` Shinya Kuribayashi
2012-11-16  1:51       ` [PATCH v2 02/10] Revert "sh-sci / PM: Use power.irq_safe" Shinya Kuribayashi
2012-11-16  1:51         ` Shinya Kuribayashi
2012-11-16  1:51         ` Shinya Kuribayashi
2012-11-16  1:51       ` [PATCH v2 03/10] Partially revert "serial: sh-sci: console Runtime PM support" Shinya Kuribayashi
2012-11-16  1:51         ` Shinya Kuribayashi
2012-11-16  1:51         ` Shinya Kuribayashi
2012-11-16  1:51       ` [PATCH v2 04/10] serial: sh-sci: console runtime PM support (revisit) Shinya Kuribayashi
2012-11-16  1:51         ` Shinya Kuribayashi
2012-11-16  1:51         ` Shinya Kuribayashi
2012-11-16  1:52       ` [PATCH v2 05/10] serial: sh-sci: fix condition test to set SCBRR Shinya Kuribayashi
2012-11-16  1:52         ` Shinya Kuribayashi
2012-11-16  1:52         ` Shinya Kuribayashi
2012-11-16  1:52       ` [PATCH v2 06/10] serial: sh-sci: support lower baud rate Shinya Kuribayashi
2012-11-16  1:52         ` Shinya Kuribayashi
2012-11-16  1:52         ` Shinya Kuribayashi
2012-11-16  1:53       ` [PATCH v2 07/10] serial: sh-sci: mask SCTFDR/RFDR according to fifosize Shinya Kuribayashi
2012-11-16  1:53         ` Shinya Kuribayashi
2012-11-16  1:53         ` Shinya Kuribayashi
2012-11-16  1:53       ` [PATCH v2 08/10] serial: sh-sci: fix common SCIFB regmap definition Shinya Kuribayashi
2012-11-16  1:53         ` Shinya Kuribayashi
2012-11-16  1:53         ` Shinya Kuribayashi
2012-11-16  1:54       ` [PATCH v2 09/10] serial: sh-sci: add locking to console write function to avoid SMP lockup Shinya Kuribayashi
2012-11-16  1:54         ` Shinya Kuribayashi
2012-11-16  1:54         ` Shinya Kuribayashi
2012-11-16  1:54       ` [PATCH v2 10/10] serial: sh-sci: fix possible race cases on SCSCR register accesses Shinya Kuribayashi
2012-11-16  1:54         ` Shinya Kuribayashi
2012-11-16  1:54         ` Shinya Kuribayashi
2012-11-16  2:04       ` [PATCH v2 00/10] serial: sh-sci fixes - console PM, SCIFB, SMP lockup, etc Greg KH
2012-11-16  2:04         ` Greg KH
2012-11-16  2:04         ` Greg KH

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=509A06BA.30101@renesas.com \
    --to=shinya.kuribayashi.px@renesas.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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.