From: Eduardo Valentin <edubezval@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.com>, Fabio Estevam <festevam@gmail.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>,
Linux PM <linux-pm@vger.kernel.org>,
linux-serial@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
Eduardo Valentin <edubezval@gmail.com>
Subject: [PATCHv2 7/8] serial: imx: add pm_qos request
Date: Mon, 10 Aug 2015 18:35:48 -0700 [thread overview]
Message-ID: <1439256949-626-8-git-send-email-edubezval@gmail.com> (raw)
In-Reply-To: <1439256949-626-1-git-send-email-edubezval@gmail.com>
This change introduces pm_qos requests in the imx serial driver.
The idea is to skip deeper C-state in case we need a strict
latency requirement in the uart port. The latency is
computed based on the buffer size and the current baud rate.
We schedule a work queue to set the pm qos requirement.
Cc: Fabio Estevam <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 | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 7d97a26..5053c82 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -42,6 +42,7 @@
#include <linux/pm.h>
#include <linux/pm_runtime.h>
#include <linux/pm_wakeup.h>
+#include <linux/pm_qos.h>
#include <asm/irq.h>
#include <linux/platform_data/serial-imx.h>
@@ -223,6 +224,10 @@ struct imx_port {
bool context_saved;
struct device *dev;
+ struct pm_qos_request pm_qos_request;
+ u32 latency;
+ u32 calc_latency;
+ struct work_struct qos_work;
bool is_suspending;
};
@@ -1321,6 +1326,14 @@ static void imx_flush_buffer(struct uart_port *port)
pm_runtime_put_autosuspend(sport->dev);
}
+static void serial_imx_uart_qos_work(struct work_struct *work)
+{
+ struct imx_port *sport = container_of(work, struct imx_port,
+ qos_work);
+
+ pm_qos_update_request(&sport->pm_qos_request, sport->latency);
+}
+
static void
imx_set_termios(struct uart_port *port, struct ktermios *termios,
struct ktermios *old)
@@ -1394,6 +1407,12 @@ imx_set_termios(struct uart_port *port, struct ktermios *termios,
baud = uart_get_baud_rate(port, termios, old, 50, port->uartclk / 16);
quot = uart_get_divisor(port, baud);
+ /* calculate wakeup latency constraint */
+ sport->calc_latency = (USEC_PER_SEC * sport->port.fifosize) /
+ (baud / 8);
+ sport->latency = sport->calc_latency;
+ schedule_work(&sport->qos_work);
+
spin_lock_irqsave(&sport->port.lock, flags);
sport->port.read_status_mask = 0;
@@ -2011,7 +2030,12 @@ static int serial_imx_probe(struct platform_device *pdev)
imx_ports[sport->port.line] = sport;
+ sport->latency = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE;
+ sport->calc_latency = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE;
sport->dev = &pdev->dev;
+ pm_qos_add_request(&sport->pm_qos_request, PM_QOS_CPU_DMA_LATENCY,
+ sport->latency);
+ INIT_WORK(&sport->qos_work, serial_imx_uart_qos_work);
platform_set_drvdata(pdev, sport);
device_init_wakeup(sport->dev, true);
@@ -2041,6 +2065,7 @@ static int serial_imx_remove(struct platform_device *pdev)
clk_unprepare(sport->clk_per);
clk_unprepare(sport->clk_ipg);
ret = uart_remove_one_port(&imx_reg, &sport->port);
+ pm_qos_remove_request(&sport->pm_qos_request);
device_init_wakeup(&pdev->dev, false);
return ret;
--
2.5.0
next prev parent reply other threads:[~2015-08-11 1:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-11 1:35 [PATCHv2 0/8] serial: imx: rework pm support and add runtime pm Eduardo Valentin
2015-08-11 1:35 ` [PATCHv2 1/8] serial: imx: remove unbalanced clk_prepare Eduardo Valentin
2015-08-11 1:35 ` [PATCHv2 2/8] serial: imx: introduce serial_imx_enable_wakeup() Eduardo Valentin
2015-08-11 1:35 ` [PATCHv2 3/8] serial: imx: allow waking up on RTSD Eduardo Valentin
2015-08-11 1:35 ` [PATCHv2 4/8] serial: imx: save and restore context in the suspend path Eduardo Valentin
2015-08-11 1:35 ` [PATCHv2 5/8] serial: imx: add a flag to indicate we are " Eduardo Valentin
2015-08-11 1:35 ` [PATCHv2 6/8] serial: imx: add runtime pm support Eduardo Valentin
2015-08-11 3:02 ` Fabio Estevam
2015-08-11 16:51 ` Eduardo Valentin
2015-08-12 19:32 ` Kevin Hilman
2015-08-11 1:35 ` Eduardo Valentin [this message]
2015-08-11 1:35 ` [PATCHv2 8/8] serial: imx: use SET_*SYSTEM_PM_OPS helper functions Eduardo Valentin
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=1439256949-626-8-git-send-email-edubezval@gmail.com \
--to=edubezval@gmail.com \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
/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 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).