Linux-ARM-MSM Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v6 1/5] Revert "tty: serial: qcom_geni_serial: Wakeup over UART RX"
       [not found] <1574432266-20732-1-git-send-email-akashast@codeaurora.org>
@ 2019-11-22 14:18 ` Akash Asthana
  2019-11-22 14:18 ` [PATCH v6 2/5] Revert "tty: serial: qcom_geni_serial: IRQ cleanup" Akash Asthana
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Akash Asthana @ 2019-11-22 14:18 UTC (permalink / raw)
  To: gregkh; +Cc: swboyd, mgautam, linux-arm-msm, linux-serial, Akash Asthana

This reverts commit 8b7103f31950443fd5727d7d80d3c65416b5a390.

To apply v6 patches cleanly on tty-next, revert v2 patches.

Signed-off-by: Akash Asthana <akashast@codeaurora.org>
---
 drivers/tty/serial/qcom_geni_serial.c | 44 +----------------------------------
 1 file changed, 1 insertion(+), 43 deletions(-)

diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index ff63728..5180cd8 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -14,7 +14,6 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
-#include <linux/pm_wakeirq.h>
 #include <linux/qcom-geni-se.h>
 #include <linux/serial.h>
 #include <linux/serial_core.h>
@@ -117,7 +116,6 @@ struct qcom_geni_serial_port {
 	bool brk;
 
 	unsigned int tx_remaining;
-	int wakeup_irq;
 };
 
 static const struct uart_ops qcom_geni_console_pops;
@@ -757,15 +755,6 @@ static void qcom_geni_serial_handle_tx(struct uart_port *uport, bool done,
 		uart_write_wakeup(uport);
 }
 
-static irqreturn_t qcom_geni_serial_wakeup_isr(int isr, void *dev)
-{
-	struct uart_port *uport = dev;
-
-	pm_wakeup_event(uport->dev, 2000);
-
-	return IRQ_HANDLED;
-}
-
 static irqreturn_t qcom_geni_serial_isr(int isr, void *dev)
 {
 	u32 m_irq_en;
@@ -1317,29 +1306,6 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	if (!console) {
-		port->wakeup_irq = platform_get_irq(pdev, 1);
-		if (port->wakeup_irq < 0) {
-			dev_err(&pdev->dev, "Failed to get wakeup IRQ %d\n",
-					port->wakeup_irq);
-		} else {
-			irq_set_status_flags(port->wakeup_irq, IRQ_NOAUTOEN);
-			ret = devm_request_irq(uport->dev, port->wakeup_irq,
-				qcom_geni_serial_wakeup_isr,
-				IRQF_TRIGGER_FALLING, "uart_wakeup", uport);
-			if (ret) {
-				dev_err(uport->dev, "Failed to register wakeup IRQ ret %d\n",
-						ret);
-				return ret;
-			}
-
-			device_init_wakeup(&pdev->dev, true);
-			ret = dev_pm_set_wake_irq(&pdev->dev, port->wakeup_irq);
-			if (unlikely(ret))
-				dev_err(uport->dev, "%s:Failed to set IRQ wake:%d\n",
-						__func__, ret);
-		}
-	}
 	uport->private_data = drv;
 	platform_set_drvdata(pdev, port);
 	port->handle_rx = console ? handle_rx_console : handle_rx_uart;
@@ -1362,12 +1328,7 @@ static int __maybe_unused qcom_geni_serial_sys_suspend(struct device *dev)
 	struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
 	struct uart_port *uport = &port->uport;
 
-	uart_suspend_port(uport->private_data, uport);
-
-	if (port->wakeup_irq > 0)
-		enable_irq(port->wakeup_irq);
-
-	return 0;
+	return uart_suspend_port(uport->private_data, uport);
 }
 
 static int __maybe_unused qcom_geni_serial_sys_resume(struct device *dev)
@@ -1375,9 +1336,6 @@ static int __maybe_unused qcom_geni_serial_sys_resume(struct device *dev)
 	struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
 	struct uart_port *uport = &port->uport;
 
-	if (port->wakeup_irq > 0)
-		disable_irq(port->wakeup_irq);
-
 	return uart_resume_port(uport->private_data, uport);
 }
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,\na Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v6 2/5] Revert "tty: serial: qcom_geni_serial: IRQ cleanup"
       [not found] <1574432266-20732-1-git-send-email-akashast@codeaurora.org>
  2019-11-22 14:18 ` [PATCH v6 1/5] Revert "tty: serial: qcom_geni_serial: Wakeup over UART RX" Akash Asthana
@ 2019-11-22 14:18 ` Akash Asthana
  2019-11-22 14:18 ` [PATCH v6 3/5] tty: serial: qcom_geni_serial: IRQ cleanup Akash Asthana
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Akash Asthana @ 2019-11-22 14:18 UTC (permalink / raw)
  To: gregkh; +Cc: swboyd, mgautam, linux-arm-msm, linux-serial, Akash Asthana

This reverts commit 3e4aaea7a0391d47f6ffff1f10594c658a67c881.

To apply v6 patches cleanly on tty-next branch, revert v2 patches.

Signed-off-by: Akash Asthana <akashast@codeaurora.org>
---
 drivers/tty/serial/qcom_geni_serial.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index 5180cd8..14c6306 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -9,7 +9,6 @@
 #include <linux/console.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
-#include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -831,7 +830,7 @@ static void qcom_geni_serial_shutdown(struct uart_port *uport)
 	if (uart_console(uport))
 		console_stop(uport->cons);
 
-	disable_irq(uport->irq);
+	free_irq(uport->irq, uport);
 	spin_lock_irqsave(&uport->lock, flags);
 	qcom_geni_serial_stop_tx(uport);
 	qcom_geni_serial_stop_rx(uport);
@@ -891,14 +890,21 @@ static int qcom_geni_serial_startup(struct uart_port *uport)
 	int ret;
 	struct qcom_geni_serial_port *port = to_dev_port(uport, uport);
 
+	scnprintf(port->name, sizeof(port->name),
+		  "qcom_serial_%s%d",
+		(uart_console(uport) ? "console" : "uart"), uport->line);
+
 	if (!port->setup) {
 		ret = qcom_geni_serial_port_setup(uport);
 		if (ret)
 			return ret;
 	}
-	enable_irq(uport->irq);
 
-	return 0;
+	ret = request_irq(uport->irq, qcom_geni_serial_isr, IRQF_TRIGGER_HIGH,
+							port->name, uport);
+	if (ret)
+		dev_err(uport->dev, "Failed to get IRQ ret %d\n", ret);
+	return ret;
 }
 
 static unsigned long get_clk_cfg(unsigned long clk_freq)
@@ -1291,21 +1297,11 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 	port->rx_fifo_depth = DEF_FIFO_DEPTH_WORDS;
 	port->tx_fifo_width = DEF_FIFO_WIDTH_BITS;
 
-	scnprintf(port->name, sizeof(port->name), "qcom_geni_serial_%s%d",
-		(uart_console(uport) ? "console" : "uart"), uport->line);
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
 	uport->irq = irq;
 
-	irq_set_status_flags(uport->irq, IRQ_NOAUTOEN);
-	ret = devm_request_irq(uport->dev, uport->irq, qcom_geni_serial_isr,
-			IRQF_TRIGGER_HIGH, port->name, uport);
-	if (ret) {
-		dev_err(uport->dev, "Failed to get IRQ ret %d\n", ret);
-		return ret;
-	}
-
 	uport->private_data = drv;
 	platform_set_drvdata(pdev, port);
 	port->handle_rx = console ? handle_rx_console : handle_rx_uart;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,\na Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v6 3/5] tty: serial: qcom_geni_serial: IRQ cleanup
       [not found] <1574432266-20732-1-git-send-email-akashast@codeaurora.org>
  2019-11-22 14:18 ` [PATCH v6 1/5] Revert "tty: serial: qcom_geni_serial: Wakeup over UART RX" Akash Asthana
  2019-11-22 14:18 ` [PATCH v6 2/5] Revert "tty: serial: qcom_geni_serial: IRQ cleanup" Akash Asthana
@ 2019-11-22 14:18 ` Akash Asthana
  2019-11-22 18:46   ` Matthias Kaehlcke
  2019-11-22 14:18 ` [PATCH v6 4/5] tty: serial: qcom_geni_serial: Wakeup over UART RX Akash Asthana
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Akash Asthana @ 2019-11-22 14:18 UTC (permalink / raw)
  To: gregkh; +Cc: swboyd, mgautam, linux-arm-msm, linux-serial, Akash Asthana

Move ISR registration from startup to probe function to avoid registering
it everytime when the port open is called for driver.

Signed-off-by: Akash Asthana <akashast@codeaurora.org>
---
Changes in v6:
 - Rebased on tty-next branch

Changes in v5:
 - No change.

Changes in v4:
 - As per Stephen's comment, move ISR registration(later in probe) after
   registering uart port with serial core.
 - As per Greg's comment, corrected returning of PTR value from integer type
   function(probe).

Changes in v3:
 - As per Stephen's comment, using devm_kasprintf instead of scnprintf API.

 drivers/tty/serial/qcom_geni_serial.c | 38 ++++++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index 14c6306..634054a 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -9,6 +9,7 @@
 #include <linux/console.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
+#include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -101,7 +102,7 @@
 struct qcom_geni_serial_port {
 	struct uart_port uport;
 	struct geni_se se;
-	char name[20];
+	const char *name;
 	u32 tx_fifo_depth;
 	u32 tx_fifo_width;
 	u32 rx_fifo_depth;
@@ -830,7 +831,7 @@ static void qcom_geni_serial_shutdown(struct uart_port *uport)
 	if (uart_console(uport))
 		console_stop(uport->cons);
 
-	free_irq(uport->irq, uport);
+	disable_irq(uport->irq);
 	spin_lock_irqsave(&uport->lock, flags);
 	qcom_geni_serial_stop_tx(uport);
 	qcom_geni_serial_stop_rx(uport);
@@ -890,21 +891,14 @@ static int qcom_geni_serial_startup(struct uart_port *uport)
 	int ret;
 	struct qcom_geni_serial_port *port = to_dev_port(uport, uport);
 
-	scnprintf(port->name, sizeof(port->name),
-		  "qcom_serial_%s%d",
-		(uart_console(uport) ? "console" : "uart"), uport->line);
-
 	if (!port->setup) {
 		ret = qcom_geni_serial_port_setup(uport);
 		if (ret)
 			return ret;
 	}
+	enable_irq(uport->irq);
 
-	ret = request_irq(uport->irq, qcom_geni_serial_isr, IRQF_TRIGGER_HIGH,
-							port->name, uport);
-	if (ret)
-		dev_err(uport->dev, "Failed to get IRQ ret %d\n", ret);
-	return ret;
+	return 0;
 }
 
 static unsigned long get_clk_cfg(unsigned long clk_freq)
@@ -1297,6 +1291,12 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 	port->rx_fifo_depth = DEF_FIFO_DEPTH_WORDS;
 	port->tx_fifo_width = DEF_FIFO_WIDTH_BITS;
 
+	port->name = devm_kasprintf(uport->dev, GFP_KERNEL,
+			"qcom_geni_serial_%s%d",
+			uart_console(uport) ? "console" : "uart", uport->line);
+	if (!port->name)
+		return -ENOMEM;
+
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
@@ -1307,7 +1307,21 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 	port->handle_rx = console ? handle_rx_console : handle_rx_uart;
 	if (!console)
 		device_create_file(uport->dev, &dev_attr_loopback);
-	return uart_add_one_port(drv, uport);
+
+	ret = uart_add_one_port(drv, uport);
+	if (ret)
+		return ret;
+
+	irq_set_status_flags(uport->irq, IRQ_NOAUTOEN);
+	ret = devm_request_irq(uport->dev, uport->irq, qcom_geni_serial_isr,
+			IRQF_TRIGGER_HIGH, port->name, uport);
+	if (ret) {
+		dev_err(uport->dev, "Failed to get IRQ ret %d\n", ret);
+		uart_remove_one_port(drv, uport);
+		return ret;
+	}
+
+	return ret;
 }
 
 static int qcom_geni_serial_remove(struct platform_device *pdev)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,\na Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v6 4/5] tty: serial: qcom_geni_serial: Wakeup over UART RX
       [not found] <1574432266-20732-1-git-send-email-akashast@codeaurora.org>
                   ` (2 preceding siblings ...)
  2019-11-22 14:18 ` [PATCH v6 3/5] tty: serial: qcom_geni_serial: IRQ cleanup Akash Asthana
@ 2019-11-22 14:18 ` Akash Asthana
  2019-11-22 18:22   ` Stephen Boyd
  2019-11-22 19:11   ` Matthias Kaehlcke
  2019-11-22 14:18 ` [PATCH v6 5/5] tty: serial: qcom_geni_serial: Move loopback support to TIOCM_LOOP Akash Asthana
       [not found] ` <0101016e937a3f78-11fa1469-8c73-4f56-a3de-3221dcf6f0e3-000000@us-west-2.amazonses.com>
  5 siblings, 2 replies; 13+ messages in thread
From: Akash Asthana @ 2019-11-22 14:18 UTC (permalink / raw)
  To: gregkh; +Cc: swboyd, mgautam, linux-arm-msm, linux-serial, Akash Asthana

Add system wakeup capability over UART RX line for wakeup capable UART.
When system is suspended, RX line act as an interrupt to wakeup system
for any communication requests from peer.

Signed-off-by: Akash Asthana <akashast@codeaurora.org>
---
Changes in V6:
 - Rebased on top of tty-next branch.
 - As per stephen's comment mark devices runtime status as active
   irrespective of wakeup feature.

Changes in V5:
 - No change.

Changes in V4:
 - As per Greg's comment, removed extra dev_err logging.
 - As per Stephen's comment, using common code that manage wakeirq irqs for
   devices. Using dev_pm_set_dedicated_wake_irq API that will take care of
   requesting and attaching wakeup irqs for devices. Also, it sets wakeirq
   status to WAKE_IRQ_DEDICATED_ALLOCATED as a result enabling/disabling of
   wake irq will be managed by suspend/resume framework so, removed the code
   for enabling and disabling of wake irq from the driver.

Changes in V3:
 - As per Stephen's comment, using platform_get_irq_optional API to get wakeup
   IRQ for device.

Changes in V2:
 - As per Stephen's comment, splitted V1 patch into 2 seperate patch.
   a) Clean up of core IRQ registration b) Add wakeup feature.

 drivers/tty/serial/qcom_geni_serial.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index 634054a..b952509 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -14,6 +14,8 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/pm_wakeirq.h>
 #include <linux/qcom-geni-se.h>
 #include <linux/serial.h>
 #include <linux/serial_core.h>
@@ -116,6 +118,7 @@ struct qcom_geni_serial_port {
 	bool brk;
 
 	unsigned int tx_remaining;
+	int wakeup_irq;
 };
 
 static const struct uart_ops qcom_geni_console_pops;
@@ -1302,6 +1305,9 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 		return irq;
 	uport->irq = irq;
 
+	if (!console)
+		port->wakeup_irq = platform_get_irq_optional(pdev, 1);
+
 	uport->private_data = drv;
 	platform_set_drvdata(pdev, port);
 	port->handle_rx = console ? handle_rx_console : handle_rx_uart;
@@ -1321,6 +1327,24 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	/*
+	 * Set pm_runtime status as ACTIVE so that wakeup_irq gets
+	 * enabled/disabled from dev_pm_arm_wake_irq  during  system
+	 * suspend/resume respectively.
+	 */
+	pm_runtime_set_active(&pdev->dev);
+
+	if (port->wakeup_irq > 0) {
+		device_init_wakeup(&pdev->dev, true);
+		ret = dev_pm_set_dedicated_wake_irq(&pdev->dev,
+						port->wakeup_irq);
+		if (ret) {
+			device_init_wakeup(&pdev->dev, false);
+			uart_remove_one_port(drv, uport);
+			return ret;
+		}
+	}
+
 	return ret;
 }
 
@@ -1330,6 +1354,10 @@ static int qcom_geni_serial_remove(struct platform_device *pdev)
 	struct uart_driver *drv = port->uport.private_data;
 
 	uart_remove_one_port(drv, &port->uport);
+
+	device_init_wakeup(&pdev->dev, false);
+	dev_pm_clear_wake_irq(&pdev->dev);
+
 	return 0;
 }
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,\na Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v6 5/5] tty: serial: qcom_geni_serial: Move loopback support to TIOCM_LOOP
       [not found] <1574432266-20732-1-git-send-email-akashast@codeaurora.org>
                   ` (3 preceding siblings ...)
  2019-11-22 14:18 ` [PATCH v6 4/5] tty: serial: qcom_geni_serial: Wakeup over UART RX Akash Asthana
@ 2019-11-22 14:18 ` Akash Asthana
  2019-11-22 18:07   ` Stephen Boyd
       [not found] ` <0101016e937a3f78-11fa1469-8c73-4f56-a3de-3221dcf6f0e3-000000@us-west-2.amazonses.com>
  5 siblings, 1 reply; 13+ messages in thread
From: Akash Asthana @ 2019-11-22 14:18 UTC (permalink / raw)
  To: gregkh; +Cc: swboyd, mgautam, linux-arm-msm, linux-serial, Akash Asthana

Remove code from the driver that create and maintain loopback sysfs node.
Instead use the ioctl TIOCMSET with TIOCM_LOOP argument to set HW to
loopback mode.

Signed-off-by: Akash Asthana <akashast@codeaurora.org>
---
Change in V6:
 - As per stephen's comment corrected commit subject.
 - As per stephen's comment defined new macros for different loopback mode.

 drivers/tty/serial/qcom_geni_serial.c | 36 +++++++++--------------------------
 1 file changed, 9 insertions(+), 27 deletions(-)

diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index b952509..3e84192 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -93,7 +93,11 @@
 #define DEF_TX_WM		2
 #define DEF_FIFO_WIDTH_BITS	32
 #define UART_RX_WM		2
-#define MAX_LOOPBACK_CFG	3
+
+/* SE_UART_LOOPBACK_CFG */
+#define RX_TX_SORTED	BIT(0)
+#define CTS_RTS_SORTED	BIT(1)
+#define RX_TX_CTS_RTS_SORTED	(RX_TX_SORTED | CTS_RTS_SORTED)
 
 #ifdef CONFIG_CONSOLE_POLL
 #define CONSOLE_RX_BYTES_PW 1
@@ -165,30 +169,6 @@ static struct qcom_geni_serial_port qcom_geni_uart_ports[GENI_UART_PORTS] = {
 	},
 };
 
-static ssize_t loopback_show(struct device *dev,
-				struct device_attribute *attr, char *buf)
-{
-	struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
-
-	return snprintf(buf, sizeof(u32), "%d\n", port->loopback);
-}
-
-static ssize_t loopback_store(struct device *dev,
-				struct device_attribute *attr, const char *buf,
-				size_t size)
-{
-	struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
-	u32 loopback;
-
-	if (kstrtoint(buf, 0, &loopback) || loopback > MAX_LOOPBACK_CFG) {
-		dev_err(dev, "Invalid input\n");
-		return -EINVAL;
-	}
-	port->loopback = loopback;
-	return size;
-}
-static DEVICE_ATTR_RW(loopback);
-
 static struct qcom_geni_serial_port qcom_geni_console_port = {
 	.uport = {
 		.iotype = UPIO_MEM,
@@ -238,10 +218,14 @@ static void qcom_geni_serial_set_mctrl(struct uart_port *uport,
 							unsigned int mctrl)
 {
 	u32 uart_manual_rfr = 0;
+	struct qcom_geni_serial_port *port = to_dev_port(uport, uport);
 
 	if (uart_console(uport))
 		return;
 
+	if (mctrl & TIOCM_LOOP)
+		port->loopback = RX_TX_CTS_RTS_SORTED;
+
 	if (!(mctrl & TIOCM_RTS))
 		uart_manual_rfr = UART_MANUAL_RFR_EN | UART_RFR_NOT_READY;
 	writel(uart_manual_rfr, uport->membase + SE_UART_MANUAL_RFR);
@@ -1311,8 +1295,6 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 	uport->private_data = drv;
 	platform_set_drvdata(pdev, port);
 	port->handle_rx = console ? handle_rx_console : handle_rx_uart;
-	if (!console)
-		device_create_file(uport->dev, &dev_attr_loopback);
 
 	ret = uart_add_one_port(drv, uport);
 	if (ret)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,\na Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v6 5/5] tty: serial: qcom_geni_serial: Move loopback support to TIOCM_LOOP
  2019-11-22 14:18 ` [PATCH v6 5/5] tty: serial: qcom_geni_serial: Move loopback support to TIOCM_LOOP Akash Asthana
@ 2019-11-22 18:07   ` Stephen Boyd
  0 siblings, 0 replies; 13+ messages in thread
From: Stephen Boyd @ 2019-11-22 18:07 UTC (permalink / raw)
  To: Akash Asthana, gregkh; +Cc: mgautam, linux-arm-msm, linux-serial, Akash Asthana

Quoting Akash Asthana (2019-11-22 06:18:24)
> Remove code from the driver that create and maintain loopback sysfs node.
> Instead use the ioctl TIOCMSET with TIOCM_LOOP argument to set HW to
> loopback mode.
> 
> Signed-off-by: Akash Asthana <akashast@codeaurora.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v6 3/5] tty: serial: qcom_geni_serial: IRQ cleanup
       [not found] ` <0101016e937a3f78-11fa1469-8c73-4f56-a3de-3221dcf6f0e3-000000@us-west-2.amazonses.com>
@ 2019-11-22 18:15   ` Stephen Boyd
  0 siblings, 0 replies; 13+ messages in thread
From: Stephen Boyd @ 2019-11-22 18:15 UTC (permalink / raw)
  To: Akash Asthana, gregkh; +Cc: mgautam, linux-arm-msm, linux-serial, Akash Asthana

Quoting Akash Asthana (2019-11-22 06:18:12)
> Move ISR registration from startup to probe function to avoid registering
> it everytime when the port open is called for driver.
> 
> Signed-off-by: Akash Asthana <akashast@codeaurora.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v6 4/5] tty: serial: qcom_geni_serial: Wakeup over UART RX
  2019-11-22 14:18 ` [PATCH v6 4/5] tty: serial: qcom_geni_serial: Wakeup over UART RX Akash Asthana
@ 2019-11-22 18:22   ` Stephen Boyd
  2019-11-25 12:06     ` Akash Asthana
  2019-11-22 19:11   ` Matthias Kaehlcke
  1 sibling, 1 reply; 13+ messages in thread
From: Stephen Boyd @ 2019-11-22 18:22 UTC (permalink / raw)
  To: Akash Asthana, gregkh; +Cc: mgautam, linux-arm-msm, linux-serial, Akash Asthana

Quoting Akash Asthana (2019-11-22 06:18:19)
> Add system wakeup capability over UART RX line for wakeup capable UART.
> When system is suspended, RX line act as an interrupt to wakeup system
> for any communication requests from peer.
> 
> Signed-off-by: Akash Asthana <akashast@codeaurora.org>

Reviewed-by: Stephen Boyd <swboyd@chromium.org>

One question below.

> @@ -1330,6 +1354,10 @@ static int qcom_geni_serial_remove(struct platform_device *pdev)
>         struct uart_driver *drv = port->uport.private_data;
>  
>         uart_remove_one_port(drv, &port->uport);
> +
> +       device_init_wakeup(&pdev->dev, false);
> +       dev_pm_clear_wake_irq(&pdev->dev);

Should this order be swapped? Usually remove is done in reverse of probe
order, so clear_wake_irq, init wakeup, and remove uart port. I'm not
convinced it will actually matter though so maybe this isn't a problem.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v6 3/5] tty: serial: qcom_geni_serial: IRQ cleanup
  2019-11-22 14:18 ` [PATCH v6 3/5] tty: serial: qcom_geni_serial: IRQ cleanup Akash Asthana
@ 2019-11-22 18:46   ` Matthias Kaehlcke
  2019-11-25 12:04     ` Akash Asthana
  0 siblings, 1 reply; 13+ messages in thread
From: Matthias Kaehlcke @ 2019-11-22 18:46 UTC (permalink / raw)
  To: Akash Asthana; +Cc: gregkh, swboyd, mgautam, linux-arm-msm, linux-serial

On Fri, Nov 22, 2019 at 02:18:12PM +0000, Akash Asthana wrote:
> Move ISR registration from startup to probe function to avoid registering
> it everytime when the port open is called for driver.
> 
> Signed-off-by: Akash Asthana <akashast@codeaurora.org>
> ---
> Changes in v6:
>  - Rebased on tty-next branch
> 
> Changes in v5:
>  - No change.
> 
> Changes in v4:
>  - As per Stephen's comment, move ISR registration(later in probe) after
>    registering uart port with serial core.
>  - As per Greg's comment, corrected returning of PTR value from integer type
>    function(probe).
> 
> Changes in v3:
>  - As per Stephen's comment, using devm_kasprintf instead of scnprintf API.
> 
>  drivers/tty/serial/qcom_geni_serial.c | 38 ++++++++++++++++++++++++-----------
>  1 file changed, 26 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
> index 14c6306..634054a 100644
> --- a/drivers/tty/serial/qcom_geni_serial.c
> +++ b/drivers/tty/serial/qcom_geni_serial.c
>
> ...
>
> @@ -1307,7 +1307,21 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
>  	port->handle_rx = console ? handle_rx_console : handle_rx_uart;
>  	if (!console)
>  		device_create_file(uport->dev, &dev_attr_loopback);
> -	return uart_add_one_port(drv, uport);
> +
> +	ret = uart_add_one_port(drv, uport);
> +	if (ret)
> +		return ret;
> +
> +	irq_set_status_flags(uport->irq, IRQ_NOAUTOEN);
> +	ret = devm_request_irq(uport->dev, uport->irq, qcom_geni_serial_isr,
> +			IRQF_TRIGGER_HIGH, port->name, uport);
> +	if (ret) {
> +		dev_err(uport->dev, "Failed to get IRQ ret %d\n", ret);
> +		uart_remove_one_port(drv, uport);
> +		return ret;

nit: could fall through

> +	}
> +
> +	return ret;

nit: if not falling through above this could/should be 0.

Reviewed-by: Matthias Kaehlcke <mka@chromium.org>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v6 4/5] tty: serial: qcom_geni_serial: Wakeup over UART RX
  2019-11-22 14:18 ` [PATCH v6 4/5] tty: serial: qcom_geni_serial: Wakeup over UART RX Akash Asthana
  2019-11-22 18:22   ` Stephen Boyd
@ 2019-11-22 19:11   ` Matthias Kaehlcke
  2019-11-25 12:06     ` Akash Asthana
  1 sibling, 1 reply; 13+ messages in thread
From: Matthias Kaehlcke @ 2019-11-22 19:11 UTC (permalink / raw)
  To: Akash Asthana; +Cc: gregkh, swboyd, mgautam, linux-arm-msm, linux-serial

On Fri, Nov 22, 2019 at 02:18:19PM +0000, Akash Asthana wrote:
> Add system wakeup capability over UART RX line for wakeup capable UART.
> When system is suspended, RX line act as an interrupt to wakeup system
> for any communication requests from peer.
> 
> Signed-off-by: Akash Asthana <akashast@codeaurora.org>
> ---
> Changes in V6:
>  - Rebased on top of tty-next branch.
>  - As per stephen's comment mark devices runtime status as active
>    irrespective of wakeup feature.
> 
> Changes in V5:
>  - No change.
> 
> Changes in V4:
>  - As per Greg's comment, removed extra dev_err logging.
>  - As per Stephen's comment, using common code that manage wakeirq irqs for
>    devices. Using dev_pm_set_dedicated_wake_irq API that will take care of
>    requesting and attaching wakeup irqs for devices. Also, it sets wakeirq
>    status to WAKE_IRQ_DEDICATED_ALLOCATED as a result enabling/disabling of
>    wake irq will be managed by suspend/resume framework so, removed the code
>    for enabling and disabling of wake irq from the driver.
> 
> Changes in V3:
>  - As per Stephen's comment, using platform_get_irq_optional API to get wakeup
>    IRQ for device.
> 
> Changes in V2:
>  - As per Stephen's comment, splitted V1 patch into 2 seperate patch.
>    a) Clean up of core IRQ registration b) Add wakeup feature.
> 
>  drivers/tty/serial/qcom_geni_serial.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
> index 634054a..b952509 100644
> --- a/drivers/tty/serial/qcom_geni_serial.c
> +++ b/drivers/tty/serial/qcom_geni_serial.c
> @@ -14,6 +14,8 @@
>  #include <linux/of.h>
>  #include <linux/of_device.h>
>  #include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>
> +#include <linux/pm_wakeirq.h>
>  #include <linux/qcom-geni-se.h>
>  #include <linux/serial.h>
>  #include <linux/serial_core.h>
> @@ -116,6 +118,7 @@ struct qcom_geni_serial_port {
>  	bool brk;
>  
>  	unsigned int tx_remaining;
> +	int wakeup_irq;
>  };
>  
>  static const struct uart_ops qcom_geni_console_pops;
> @@ -1302,6 +1305,9 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
>  		return irq;
>  	uport->irq = irq;
>  
> +	if (!console)
> +		port->wakeup_irq = platform_get_irq_optional(pdev, 1);
> +
>  	uport->private_data = drv;
>  	platform_set_drvdata(pdev, port);
>  	port->handle_rx = console ? handle_rx_console : handle_rx_uart;
> @@ -1321,6 +1327,24 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> +	/*
> +	 * Set pm_runtime status as ACTIVE so that wakeup_irq gets
> +	 * enabled/disabled from dev_pm_arm_wake_irq  during  system

nit: remove one of the two blanks before/after 'during'.

> +	 * suspend/resume respectively.
> +	 */
> +	pm_runtime_set_active(&pdev->dev);
> +
> +	if (port->wakeup_irq > 0) {
> +		device_init_wakeup(&pdev->dev, true);
> +		ret = dev_pm_set_dedicated_wake_irq(&pdev->dev,
> +						port->wakeup_irq);
> +		if (ret) {
> +			device_init_wakeup(&pdev->dev, false);
> +			uart_remove_one_port(drv, uport);
> +			return ret;
> +		}
> +	}
> +
>  	return ret;
>  }
>  
> @@ -1330,6 +1354,10 @@ static int qcom_geni_serial_remove(struct platform_device *pdev)
>  	struct uart_driver *drv = port->uport.private_data;
>  
>  	uart_remove_one_port(drv, &port->uport);
> +
> +	device_init_wakeup(&pdev->dev, false);
> +	dev_pm_clear_wake_irq(&pdev->dev);
> +
>  	return 0;
>  }

Reviewed-by: Matthias Kaehlcke <mka@chromium.org>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v6 3/5] tty: serial: qcom_geni_serial: IRQ cleanup
  2019-11-22 18:46   ` Matthias Kaehlcke
@ 2019-11-25 12:04     ` Akash Asthana
  0 siblings, 0 replies; 13+ messages in thread
From: Akash Asthana @ 2019-11-25 12:04 UTC (permalink / raw)
  To: Matthias Kaehlcke; +Cc: gregkh, swboyd, mgautam, linux-arm-msm, linux-serial


On 11/23/2019 12:16 AM, Matthias Kaehlcke wrote:
> On Fri, Nov 22, 2019 at 02:18:12PM +0000, Akash Asthana wrote:
>> Move ISR registration from startup to probe function to avoid registering
>> it everytime when the port open is called for driver.
>>
>> Signed-off-by: Akash Asthana <akashast@codeaurora.org>
>> ---
>> Changes in v6:
>>   - Rebased on tty-next branch
>>
>> Changes in v5:
>>   - No change.
>>
>> Changes in v4:
>>   - As per Stephen's comment, move ISR registration(later in probe) after
>>     registering uart port with serial core.
>>   - As per Greg's comment, corrected returning of PTR value from integer type
>>     function(probe).
>>
>> Changes in v3:
>>   - As per Stephen's comment, using devm_kasprintf instead of scnprintf API.
>>
>>   drivers/tty/serial/qcom_geni_serial.c | 38 ++++++++++++++++++++++++-----------
>>   1 file changed, 26 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
>> index 14c6306..634054a 100644
>> --- a/drivers/tty/serial/qcom_geni_serial.c
>> +++ b/drivers/tty/serial/qcom_geni_serial.c
>>
>> ...
>>
>> @@ -1307,7 +1307,21 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
>>   	port->handle_rx = console ? handle_rx_console : handle_rx_uart;
>>   	if (!console)
>>   		device_create_file(uport->dev, &dev_attr_loopback);
>> -	return uart_add_one_port(drv, uport);
>> +
>> +	ret = uart_add_one_port(drv, uport);
>> +	if (ret)
>> +		return ret;
>> +
>> +	irq_set_status_flags(uport->irq, IRQ_NOAUTOEN);
>> +	ret = devm_request_irq(uport->dev, uport->irq, qcom_geni_serial_isr,
>> +			IRQF_TRIGGER_HIGH, port->name, uport);
>> +	if (ret) {
>> +		dev_err(uport->dev, "Failed to get IRQ ret %d\n", ret);
>> +		uart_remove_one_port(drv, uport);
>> +		return ret;
> nit: could fall through
>
>> +	}
>> +
>> +	return ret;
> nit: if not falling through above this could/should be 0.
ok, will change it to return 0;
> Reviewed-by: Matthias Kaehlcke <mka@chromium.org>

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,\na Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v6 4/5] tty: serial: qcom_geni_serial: Wakeup over UART RX
  2019-11-22 18:22   ` Stephen Boyd
@ 2019-11-25 12:06     ` Akash Asthana
  0 siblings, 0 replies; 13+ messages in thread
From: Akash Asthana @ 2019-11-25 12:06 UTC (permalink / raw)
  To: Stephen Boyd, gregkh; +Cc: mgautam, linux-arm-msm, linux-serial


On 11/22/2019 11:52 PM, Stephen Boyd wrote:
> Quoting Akash Asthana (2019-11-22 06:18:19)
>> Add system wakeup capability over UART RX line for wakeup capable UART.
>> When system is suspended, RX line act as an interrupt to wakeup system
>> for any communication requests from peer.
>>
>> Signed-off-by: Akash Asthana <akashast@codeaurora.org>
> Reviewed-by: Stephen Boyd <swboyd@chromium.org>
>
> One question below.
>
>> @@ -1330,6 +1354,10 @@ static int qcom_geni_serial_remove(struct platform_device *pdev)
>>          struct uart_driver *drv = port->uport.private_data;
>>   
>>          uart_remove_one_port(drv, &port->uport);
>> +
>> +       device_init_wakeup(&pdev->dev, false);
>> +       dev_pm_clear_wake_irq(&pdev->dev);
> Should this order be swapped? Usually remove is done in reverse of probe
> order, so clear_wake_irq, init wakeup, and remove uart port. I'm not
> convinced it will actually matter though so maybe this isn't a problem.
Ok, I will update the order here.

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,\na Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v6 4/5] tty: serial: qcom_geni_serial: Wakeup over UART RX
  2019-11-22 19:11   ` Matthias Kaehlcke
@ 2019-11-25 12:06     ` Akash Asthana
  0 siblings, 0 replies; 13+ messages in thread
From: Akash Asthana @ 2019-11-25 12:06 UTC (permalink / raw)
  To: Matthias Kaehlcke; +Cc: gregkh, swboyd, mgautam, linux-arm-msm, linux-serial


On 11/23/2019 12:41 AM, Matthias Kaehlcke wrote:
> On Fri, Nov 22, 2019 at 02:18:19PM +0000, Akash Asthana wrote:
>> Add system wakeup capability over UART RX line for wakeup capable UART.
>> When system is suspended, RX line act as an interrupt to wakeup system
>> for any communication requests from peer.
>>
>> Signed-off-by: Akash Asthana <akashast@codeaurora.org>
>> ---
>> Changes in V6:
>>   - Rebased on top of tty-next branch.
>>   - As per stephen's comment mark devices runtime status as active
>>     irrespective of wakeup feature.
>>
>> Changes in V5:
>>   - No change.
>>
>> Changes in V4:
>>   - As per Greg's comment, removed extra dev_err logging.
>>   - As per Stephen's comment, using common code that manage wakeirq irqs for
>>     devices. Using dev_pm_set_dedicated_wake_irq API that will take care of
>>     requesting and attaching wakeup irqs for devices. Also, it sets wakeirq
>>     status to WAKE_IRQ_DEDICATED_ALLOCATED as a result enabling/disabling of
>>     wake irq will be managed by suspend/resume framework so, removed the code
>>     for enabling and disabling of wake irq from the driver.
>>
>> Changes in V3:
>>   - As per Stephen's comment, using platform_get_irq_optional API to get wakeup
>>     IRQ for device.
>>
>> Changes in V2:
>>   - As per Stephen's comment, splitted V1 patch into 2 seperate patch.
>>     a) Clean up of core IRQ registration b) Add wakeup feature.
>>
>>   drivers/tty/serial/qcom_geni_serial.c | 28 ++++++++++++++++++++++++++++
>>   1 file changed, 28 insertions(+)
>>
>> diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
>> index 634054a..b952509 100644
>> --- a/drivers/tty/serial/qcom_geni_serial.c
>> +++ b/drivers/tty/serial/qcom_geni_serial.c
>> @@ -14,6 +14,8 @@
>>   #include <linux/of.h>
>>   #include <linux/of_device.h>
>>   #include <linux/platform_device.h>
>> +#include <linux/pm_runtime.h>
>> +#include <linux/pm_wakeirq.h>
>>   #include <linux/qcom-geni-se.h>
>>   #include <linux/serial.h>
>>   #include <linux/serial_core.h>
>> @@ -116,6 +118,7 @@ struct qcom_geni_serial_port {
>>   	bool brk;
>>   
>>   	unsigned int tx_remaining;
>> +	int wakeup_irq;
>>   };
>>   
>>   static const struct uart_ops qcom_geni_console_pops;
>> @@ -1302,6 +1305,9 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
>>   		return irq;
>>   	uport->irq = irq;
>>   
>> +	if (!console)
>> +		port->wakeup_irq = platform_get_irq_optional(pdev, 1);
>> +
>>   	uport->private_data = drv;
>>   	platform_set_drvdata(pdev, port);
>>   	port->handle_rx = console ? handle_rx_console : handle_rx_uart;
>> @@ -1321,6 +1327,24 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
>>   		return ret;
>>   	}
>>   
>> +	/*
>> +	 * Set pm_runtime status as ACTIVE so that wakeup_irq gets
>> +	 * enabled/disabled from dev_pm_arm_wake_irq  during  system
> nit: remove one of the two blanks before/after 'during'.
ok
>
>> +	 * suspend/resume respectively.
>> +	 */
>> +	pm_runtime_set_active(&pdev->dev);
>> +
>> +	if (port->wakeup_irq > 0) {
>> +		device_init_wakeup(&pdev->dev, true);
>> +		ret = dev_pm_set_dedicated_wake_irq(&pdev->dev,
>> +						port->wakeup_irq);
>> +		if (ret) {
>> +			device_init_wakeup(&pdev->dev, false);
>> +			uart_remove_one_port(drv, uport);
>> +			return ret;
>> +		}
>> +	}
>> +
>>   	return ret;
>>   }
>>   
>> @@ -1330,6 +1354,10 @@ static int qcom_geni_serial_remove(struct platform_device *pdev)
>>   	struct uart_driver *drv = port->uport.private_data;
>>   
>>   	uart_remove_one_port(drv, &port->uport);
>> +
>> +	device_init_wakeup(&pdev->dev, false);
>> +	dev_pm_clear_wake_irq(&pdev->dev);
>> +
>>   	return 0;
>>   }
> Reviewed-by: Matthias Kaehlcke <mka@chromium.org>

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,\na Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, back to index

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1574432266-20732-1-git-send-email-akashast@codeaurora.org>
2019-11-22 14:18 ` [PATCH v6 1/5] Revert "tty: serial: qcom_geni_serial: Wakeup over UART RX" Akash Asthana
2019-11-22 14:18 ` [PATCH v6 2/5] Revert "tty: serial: qcom_geni_serial: IRQ cleanup" Akash Asthana
2019-11-22 14:18 ` [PATCH v6 3/5] tty: serial: qcom_geni_serial: IRQ cleanup Akash Asthana
2019-11-22 18:46   ` Matthias Kaehlcke
2019-11-25 12:04     ` Akash Asthana
2019-11-22 14:18 ` [PATCH v6 4/5] tty: serial: qcom_geni_serial: Wakeup over UART RX Akash Asthana
2019-11-22 18:22   ` Stephen Boyd
2019-11-25 12:06     ` Akash Asthana
2019-11-22 19:11   ` Matthias Kaehlcke
2019-11-25 12:06     ` Akash Asthana
2019-11-22 14:18 ` [PATCH v6 5/5] tty: serial: qcom_geni_serial: Move loopback support to TIOCM_LOOP Akash Asthana
2019-11-22 18:07   ` Stephen Boyd
     [not found] ` <0101016e937a3f78-11fa1469-8c73-4f56-a3de-3221dcf6f0e3-000000@us-west-2.amazonses.com>
2019-11-22 18:15   ` [PATCH v6 3/5] tty: serial: qcom_geni_serial: IRQ cleanup Stephen Boyd

Linux-ARM-MSM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-msm/0 linux-arm-msm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-msm linux-arm-msm/ https://lore.kernel.org/linux-arm-msm \
		linux-arm-msm@vger.kernel.org
	public-inbox-index linux-arm-msm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-arm-msm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git