* [PATCH 1/3] serial-uartlite: Disable clocks in the error path
@ 2020-12-09 12:18 Shubhrajyoti Datta
2020-12-09 12:18 ` [PATCH 2/3] serial-uartlite: Add runtime pm support Shubhrajyoti Datta
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Shubhrajyoti Datta @ 2020-12-09 12:18 UTC (permalink / raw)
To: linux-serial; +Cc: git, jacmet, linuxfoundation.org, Shubhrajyoti Datta
Disable clocks in the error path.
Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
---
drivers/tty/serial/uartlite.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index 09379db..ab4954f 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -799,7 +799,7 @@ static int ulite_probe(struct platform_device *pdev)
ret = uart_register_driver(&ulite_uart_driver);
if (ret < 0) {
dev_err(&pdev->dev, "Failed to register driver\n");
- return ret;
+ goto err_out_clk_disable;
}
}
@@ -808,6 +808,10 @@ static int ulite_probe(struct platform_device *pdev)
clk_disable(pdata->clk);
return ret;
+
+err_out_clk_disable:
+ clk_disable_unprepare(pdata->clk);
+ return ret;
}
static int ulite_remove(struct platform_device *pdev)
--
2.1.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] serial-uartlite: Add runtime pm support
2020-12-09 12:18 [PATCH 1/3] serial-uartlite: Disable clocks in the error path Shubhrajyoti Datta
@ 2020-12-09 12:18 ` Shubhrajyoti Datta
2020-12-09 14:33 ` Greg KH
2020-12-09 12:18 ` [PATCH 3/3] serial-uartlite: Remove an un-necessary read of control register Shubhrajyoti Datta
2020-12-09 14:32 ` [PATCH 1/3] serial-uartlite: Disable clocks in the error path Greg KH
2 siblings, 1 reply; 6+ messages in thread
From: Shubhrajyoti Datta @ 2020-12-09 12:18 UTC (permalink / raw)
To: linux-serial; +Cc: git, jacmet, linuxfoundation.org, Shubhrajyoti Datta
Add runtime pm support
Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
---
drivers/tty/serial/uartlite.c | 59 +++++++++++++++++++++++++++++++++++++------
1 file changed, 51 insertions(+), 8 deletions(-)
diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index ab4954f..92dd528 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -22,6 +22,7 @@
#include <linux/of_device.h>
#include <linux/of_platform.h>
#include <linux/clk.h>
+#include <linux/pm_runtime.h>
#define ULITE_NAME "ttyUL"
#define ULITE_MAJOR 204
@@ -54,6 +55,7 @@
#define ULITE_CONTROL_RST_TX 0x01
#define ULITE_CONTROL_RST_RX 0x02
#define ULITE_CONTROL_IE 0x10
+#define UART_AUTOSUSPEND_TIMEOUT 3000
/* Static pointer to console port */
#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
@@ -390,12 +392,16 @@ static int ulite_verify_port(struct uart_port *port, struct serial_struct *ser)
static void ulite_pm(struct uart_port *port, unsigned int state,
unsigned int oldstate)
{
- struct uartlite_data *pdata = port->private_data;
+ int ret;
- if (!state)
- clk_enable(pdata->clk);
- else
- clk_disable(pdata->clk);
+ if (!state) {
+ ret = pm_runtime_get_sync(port->dev);
+ if (ret < 0)
+ dev_err(port->dev, "Failed to enable clocks\n");
+ } else {
+ pm_runtime_mark_last_busy(port->dev);
+ pm_runtime_put_autosuspend(port->dev);
+ }
}
#ifdef CONFIG_CONSOLE_POLL
@@ -734,11 +740,37 @@ static int __maybe_unused ulite_resume(struct device *dev)
return 0;
}
+static int __maybe_unused ulite_runtime_suspend(struct device *dev)
+{
+ struct uart_port *port = dev_get_drvdata(dev);
+ struct uartlite_data *pdata = port->private_data;
+
+ clk_disable(pdata->clk);
+ return 0;
+};
+
+static int __maybe_unused ulite_runtime_resume(struct device *dev)
+{
+ struct uart_port *port = dev_get_drvdata(dev);
+ struct uartlite_data *pdata = port->private_data;
+ int ret;
+
+ ret = clk_enable(pdata->clk);
+ if (ret) {
+ dev_err(dev, "Cannot enable clock.\n");
+ return ret;
+ }
+ return 0;
+}
/* ---------------------------------------------------------------------
* Platform bus binding
*/
-static SIMPLE_DEV_PM_OPS(ulite_pm_ops, ulite_suspend, ulite_resume);
+static const struct dev_pm_ops ulite_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(ulite_suspend, ulite_resume)
+ SET_RUNTIME_PM_OPS(ulite_runtime_suspend,
+ ulite_runtime_resume, NULL)
+};
#if defined(CONFIG_OF)
/* Match table for of_platform binding */
@@ -803,9 +835,15 @@ static int ulite_probe(struct platform_device *pdev)
}
}
+ pm_runtime_use_autosuspend(&pdev->dev);
+ pm_runtime_set_autosuspend_delay(&pdev->dev, UART_AUTOSUSPEND_TIMEOUT);
+ pm_runtime_set_active(&pdev->dev);
+ pm_runtime_enable(&pdev->dev);
+
ret = ulite_assign(&pdev->dev, id, res->start, irq, pdata);
- clk_disable(pdata->clk);
+ pm_runtime_mark_last_busy(&pdev->dev);
+ pm_runtime_put_autosuspend(&pdev->dev);
return ret;
@@ -818,9 +856,14 @@ static int ulite_remove(struct platform_device *pdev)
{
struct uart_port *port = dev_get_drvdata(&pdev->dev);
struct uartlite_data *pdata = port->private_data;
+ int rc;
clk_disable_unprepare(pdata->clk);
- return ulite_release(&pdev->dev);
+ rc = ulite_release(&pdev->dev);
+ pm_runtime_disable(&pdev->dev);
+ pm_runtime_set_suspended(&pdev->dev);
+ pm_runtime_dont_use_autosuspend(&pdev->dev);
+ return rc;
}
/* work with hotplug and coldplug */
--
2.1.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] serial-uartlite: Remove an un-necessary read of control register
2020-12-09 12:18 [PATCH 1/3] serial-uartlite: Disable clocks in the error path Shubhrajyoti Datta
2020-12-09 12:18 ` [PATCH 2/3] serial-uartlite: Add runtime pm support Shubhrajyoti Datta
@ 2020-12-09 12:18 ` Shubhrajyoti Datta
2020-12-09 14:33 ` Greg KH
2020-12-09 14:32 ` [PATCH 1/3] serial-uartlite: Disable clocks in the error path Greg KH
2 siblings, 1 reply; 6+ messages in thread
From: Shubhrajyoti Datta @ 2020-12-09 12:18 UTC (permalink / raw)
To: linux-serial; +Cc: git, jacmet, linuxfoundation.org, Shubhrajyoti Datta
The control register is a writeonly register that's why reading it
doesn't make any sense.
Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
---
drivers/tty/serial/uartlite.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index 92dd528..52c223f 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -296,7 +296,6 @@ static void ulite_shutdown(struct uart_port *port)
struct uartlite_data *pdata = port->private_data;
uart_out32(0, ULITE_CONTROL, port);
- uart_in32(ULITE_CONTROL, port); /* dummy */
free_irq(port->irq, port);
clk_disable(pdata->clk);
}
@@ -367,7 +366,6 @@ static int ulite_request_port(struct uart_port *port)
}
pdata->reg_ops = &uartlite_be;
- ret = uart_in32(ULITE_CONTROL, port);
uart_out32(ULITE_CONTROL_RST_TX, ULITE_CONTROL, port);
ret = uart_in32(ULITE_STATUS, port);
/* Endianess detection */
--
2.1.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] serial-uartlite: Disable clocks in the error path
2020-12-09 12:18 [PATCH 1/3] serial-uartlite: Disable clocks in the error path Shubhrajyoti Datta
2020-12-09 12:18 ` [PATCH 2/3] serial-uartlite: Add runtime pm support Shubhrajyoti Datta
2020-12-09 12:18 ` [PATCH 3/3] serial-uartlite: Remove an un-necessary read of control register Shubhrajyoti Datta
@ 2020-12-09 14:32 ` Greg KH
2 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2020-12-09 14:32 UTC (permalink / raw)
To: Shubhrajyoti Datta; +Cc: linux-serial, git, jacmet, linuxfoundation.org
On Wed, Dec 09, 2020 at 05:48:19PM +0530, Shubhrajyoti Datta wrote:
> Disable clocks in the error path.
That says _what_ y ou did, but not _why_ you did it.
And please, check your cc: addresses, I think one of them is very
wrong...
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/3] serial-uartlite: Add runtime pm support
2020-12-09 12:18 ` [PATCH 2/3] serial-uartlite: Add runtime pm support Shubhrajyoti Datta
@ 2020-12-09 14:33 ` Greg KH
0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2020-12-09 14:33 UTC (permalink / raw)
To: Shubhrajyoti Datta; +Cc: linux-serial, git, jacmet, linuxfoundation.org
On Wed, Dec 09, 2020 at 05:48:20PM +0530, Shubhrajyoti Datta wrote:
> Add runtime pm support
Again, we need more information here.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] serial-uartlite: Remove an un-necessary read of control register
2020-12-09 12:18 ` [PATCH 3/3] serial-uartlite: Remove an un-necessary read of control register Shubhrajyoti Datta
@ 2020-12-09 14:33 ` Greg KH
0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2020-12-09 14:33 UTC (permalink / raw)
To: Shubhrajyoti Datta; +Cc: linux-serial, git, jacmet, linuxfoundation.org
On Wed, Dec 09, 2020 at 05:48:21PM +0530, Shubhrajyoti Datta wrote:
> The control register is a writeonly register that's why reading it
> doesn't make any sense.
Are you _SURE_? Many times this is needed for hardware control...
Can you point to the documentation that says this is ok to remove?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-12-09 14:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09 12:18 [PATCH 1/3] serial-uartlite: Disable clocks in the error path Shubhrajyoti Datta
2020-12-09 12:18 ` [PATCH 2/3] serial-uartlite: Add runtime pm support Shubhrajyoti Datta
2020-12-09 14:33 ` Greg KH
2020-12-09 12:18 ` [PATCH 3/3] serial-uartlite: Remove an un-necessary read of control register Shubhrajyoti Datta
2020-12-09 14:33 ` Greg KH
2020-12-09 14:32 ` [PATCH 1/3] serial-uartlite: Disable clocks in the error path Greg KH
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.