Skip to contentSkip to conversation

Enable QUPs and Serial on SA8255p Qualcomm platforms

PATCH In review Praveen Talari 4 participants 23 messages Jul 21, 2025 – Aug 28, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v7 cover Enable QUPs and Serial on SA8255p Qualcomm platforms

The Qualcomm automotive SA8255p SoC relies on firmware to configure platform resources, including clocks, interconnects and TLMM. The device drivers request resources operations over SCMI using power and performance protocols.

The SCMI power protocol enables or disables resources like clocks, interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs, such as resume/suspend, to control power states(on/off).

The SCMI performance protocol manages UART baud rates, with each baud rate represented by a performance level. Drivers use the dev_pm_opp_set_level() API to request the desired baud rate by specifying the performance level.

The QUP drivers are SCMI clients, with clocks, interconnects, pinctrl and power-domains abstracted by a SCMI server.

The serial driver has a dependency on the dev_pm_opp_set_level() function, which is applied in the OPP tree's linux-next branch.

Nikunj Kela (2):
dt-bindings: serial: describe SA8255p
dt-bindings: qcom: geni-se: describe SA8255p

Praveen Talari (6):
soc: qcom: geni-se: Enable QUPs on SA8255p Qualcomm platforms
serial: qcom-geni: move resource initialization to separate function
serial: qcom-geni: move resource control logic to separate functions
serial: qcom-geni: move clock-rate logic to separate function
serial: qcom-geni: Enable PM runtime for serial driver
serial: qcom-geni: Enable Serial on SA8255p Qualcomm platforms
---
v3 -> v4
- removed patch "[PATCH v3 1/9] opp: add new helper API dev_pm_opp_set_level()" from series and serial driver has dependency of this API which is applied in the OPP tree's linux-next branch.
---

 .../serial/qcom,sa8255p-geni-uart.yaml        |  69 ++++
 .../soc/qcom/qcom,sa8255p-geni-se-qup.yaml    | 107 ++++++
 drivers/soc/qcom/qcom-geni-se.c               |  13 +-
 drivers/tty/serial/qcom_geni_serial.c         | 338 ++++++++++++++----
 4 files changed, 452 insertions(+), 75 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/serial/qcom,sa8255p-geni-uart.yaml
 create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,sa8255p-geni-se-qup.yaml

base-commit: 97987520025658f30bb787a99ffbd9bbff9ffc9d

Signature · 1 line
2.17.1
#1 lore raw

PATCH v7 1/8 dt-bindings: serial: describe SA8255p

From: Nikunj Kela <[email protected]>

SA8255p platform abstracts resources such as clocks, interconnect and GPIO pins configuration in Firmware. SCMI power and perf protocols are used to send request for resource configurations.

Add DT bindings for the QUP GENI UART controller on sa8255p platform.

The wakeup interrupt (IRQ) is treated as optional, as not all UART instances have a wakeup-capable interrupt routed via the PDC.

---
v6 -> v7
From Krzysztof:
- added minItems in interrupt-names

v5 -> v6
- added description for interrupt-names
- added wakeup irq as optional information in commit text and property description.
- removed wake irq form example node.

v4 -> v5
- added wake irq in example node

v3 -> v4
- added version log after ---

v2 -> v3
- dropped description for interrupt-names
- rebased reg property order in required option

v1 -> v2
- reorder sequence of tags in commit text
- moved reg property after compatible field
- added interrupt-names property

---
 .../serial/qcom,sa8255p-geni-uart.yaml        | 69 +++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/serial/qcom,sa8255p-geni-uart.yaml
Documentation/devicetree/bindings/serial/qcom,sa8255p-geni-uart.yaml new file +69 -0
new file mode 100644
index 000000000000..c8f01923cb25
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/serial/qcom,sa8255p-geni-uart.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm Geni based QUP UART interface
+
+maintainers:
+  - Praveen Talari <[email protected]>
+
+allOf:
+  - $ref: /schemas/serial/serial.yaml#
+
+properties:
+  compatible:
+    enum:
+      - qcom,sa8255p-geni-uart
+      - qcom,sa8255p-geni-debug-uart
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    minItems: 1
+    items:
+      - description: UART core irq
+      - description: Wakeup irq (RX GPIO)
+
+  interrupt-names:
+    description:
+      The UART interrupt and optionally the RX in-band wakeup interrupt
+      as not all UART instances have a wakeup-capable interrupt routed
+      via the PDC.
+    minItems: 1
+    items:
+      - const: uart
+      - const: wakeup
+
+  power-domains:
+    minItems: 2
+    maxItems: 2
+
+  power-domain-names:
+    items:
+      - const: power
+      - const: perf
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - power-domains
+  - power-domain-names
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    serial@990000 {
+        compatible = "qcom,sa8255p-geni-uart";
+        reg = <0x990000 0x4000>;
+        interrupts = <GIC_SPI 531 IRQ_TYPE_LEVEL_HIGH>;
+        power-domains = <&scmi0_pd 0>, <&scmi0_dvfs 0>;
+        power-domain-names = "power", "perf";
+    };
+...
Signature · 1 line
2.17.1
Reviewed-by on v7 1/8
#2 lore raw

Re: [PATCH v7 1/8] dt-bindings: serial: describe SA8255p

Quoted 8 lines · Praveen Talari

From: Nikunj Kela <[email protected]>

SA8255p platform abstracts resources such as clocks, interconnect and GPIO pins configuration in Firmware. SCMI power and perf protocols are used to send request for resource configurations.

Add DT bindings for the QUP GENI UART controller on sa8255p platform.

Quoted 7 lines

The wakeup interrupt (IRQ) is treated as optional, as not all UART instances have a wakeup-capable interrupt routed via the PDC.

---

Place the review tag in correct place, not in random or before you received this patch.

Best regards,
Krzysztof

#3 lore raw

PATCH v7 2/8 dt-bindings: qcom: geni-se: describe SA8255p

In reply to Praveen Talari

From: Nikunj Kela <[email protected]>

SA8255p platform abstracts resources such as clocks, interconnect configuration in Firmware.

Add DT bindings for the QUP Wrapper on sa8255p platform.

---
v5 -> v6
- added Reviewed-by tag in commit

v3 -> v4
- reordered required: after properties and patternproperties
- added version log after ---

v2 -> v3
- reordered required option

v1 -> v2
- reorder sequence of tags in commit text
- resolved waring errors while encountered in dt binding and dtb check.

---
 .../soc/qcom/qcom,sa8255p-geni-se-qup.yaml    | 107 ++++++++++++++++++
 1 file changed, 107 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,sa8255p-geni-se-qup.yaml
Documentation/devicetree/bindings/soc/qcom/qcom,sa8255p-geni-se-qup.yaml new file +107 -0
new file mode 100644
index 000000000000..352af3426d34
@@ -0,0 +1,107 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/qcom/qcom,sa8255p-geni-se-qup.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: GENI Serial Engine QUP Wrapper Controller
+
+maintainers:
+  - Praveen Talari <[email protected]>
+
+description:
+  Generic Interface (GENI) based Qualcomm Universal Peripheral (QUP) wrapper
+  is a programmable module for supporting a wide range of serial interfaces
+  like UART, SPI, I2C, I3C, etc. A single QUP module can provide up to 8 Serial
+  Interfaces, using its internal Serial Engines. The GENI Serial Engine QUP
+  Wrapper controller is modeled as a node with zero or more child nodes each
+  representing a serial engine.
+
+properties:
+  compatible:
+    const: qcom,sa8255p-geni-se-qup
+
+  reg:
+    description: QUP wrapper common register address and length.
+    maxItems: 1
+
+  "#address-cells":
+    const: 2
+
+  "#size-cells":
+    const: 2
+
+  ranges: true
+
+  iommus:
+    maxItems: 1
+
+  dma-coherent: true
+
+patternProperties:
+  "spi@[0-9a-f]+$":
+    type: object
+    description: GENI serial engine based SPI controller. SPI in master mode
+                 supports up to 50MHz, up to four chip selects, programmable
+                 data path from 4 bits to 32 bits and numerous protocol
+                 variants.
+    additionalProperties: true
+
+    properties:
+      compatible:
+        const: qcom,sa8255p-geni-spi
+
+  "i2c@[0-9a-f]+$":
+    type: object
+    description: GENI serial engine based I2C controller.
+    additionalProperties: true
+
+    properties:
+      compatible:
+        const: qcom,sa8255p-geni-i2c
+
+  "serial@[0-9a-f]+$":
+    type: object
+    description: GENI Serial Engine based UART Controller.
+    additionalProperties: true
+
+    properties:
+      compatible:
+        enum:
+          - qcom,sa8255p-geni-uart
+          - qcom,sa8255p-geni-debug-uart
+
+required:
+  - compatible
+  - reg
+  - "#address-cells"
+  - "#size-cells"
+  - ranges
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    soc {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        geniqup@9c0000 {
+            compatible = "qcom,sa8255p-geni-se-qup";
+            reg = <0 0x9c0000 0 0x6000>;
+            #address-cells = <2>;
+            #size-cells = <2>;
+            ranges;
+
+            serial@990000 {
+                compatible = "qcom,sa8255p-geni-uart";
+                reg = <0 0x990000 0 0x4000>;
+                interrupts = <GIC_SPI 531 IRQ_TYPE_LEVEL_HIGH>;
+                power-domains = <&scmi0_pd 0>, <&scmi0_dvfs 0>;
+                power-domain-names = "power", "perf";
+            };
+        };
+    };
+...
Signature · 1 line
2.17.1
#4 lore raw

Re: [PATCH v7 2/8] dt-bindings: qcom: geni-se: describe SA8255p

Quoted 8 lines · Praveen Talari

From: Nikunj Kela <[email protected]>

SA8255p platform abstracts resources such as clocks, interconnect configuration in Firmware.

Add DT bindings for the QUP Wrapper on sa8255p platform.

How the tag could be placed here?

Quoted 3 lines

This is really oddly managed. Can you finally start using b4?

Best regards,
Krzysztof

#5 lore raw

PATCH v7 3/8 soc: qcom: geni-se: Enable QUPs on SA8255p Qualcomm platforms

In reply to Praveen Talari

On the sa8255p platform, resources such as clocks,interconnects and TLMM (GPIO) configurations are managed by firmware.

Use the num_clks field in platform data to distinguish whether resource control is performed by firmware or directly by the driver in linux.

---
v6 -> v7
From Bjorn:
- removed resources_init() callback function from platform data
- removed geni_se_resource_init() and just add the additional expression to the condition
- added sa8255p_qup_desc = {};
- updated commit text based on code changes

v5 -> v6
- replaced dev_err with dev_err_probe
- added a check for desc->num_clks with MAX_CLKS, an error if the specified num_clks in descriptor exceeds defined MAX_CLKS.
- removed min_t which is not necessary.
- renamed callback function names to resources_init.
- resolved kernel bot warning error by documenting function pointer in geni_se_desc structure.

v3 -> v4
- declared an empty struct for sa8255p and added check as num clks.
- Added version log after ---

v1 -> v2
- changed datatype of i from int to unsigned int as per comment.

---
 drivers/soc/qcom/qcom-geni-se.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/soc/qcom/qcom-geni-se.c +7 -6
index 4cb959106efa..3c3b796333a6 100644
@@ -895,6 +895,7 @@ static int geni_se_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct geni_wrapper *wrapper;
+	const struct geni_se_desc *desc;
 	int ret;
 
 	wrapper = devm_kzalloc(dev, sizeof(*wrapper), GFP_KERNEL);
@@ -906,13 +907,10 @@ static int geni_se_probe(struct platform_device *pdev)
 	if (IS_ERR(wrapper->base))
 		return PTR_ERR(wrapper->base);
 
-	if (!has_acpi_companion(&pdev->dev)) {
-		const struct geni_se_desc *desc;
-		int i;
+	desc = device_get_match_data(&pdev->dev);
 
-		desc = device_get_match_data(&pdev->dev);
-		if (!desc)
-			return -EINVAL;
+	if (!has_acpi_companion(&pdev->dev) && desc->num_clks) {
+		int i;
 
 		wrapper->num_clks = min_t(unsigned int, desc->num_clks, MAX_CLKS);
 
@@ -953,6 +951,8 @@ static const struct geni_se_desc qup_desc = {
 	.num_clks = ARRAY_SIZE(qup_clks),
 };
 
+static const struct geni_se_desc sa8255p_qup_desc = {};
+
 static const char * const i2c_master_hub_clks[] = {
 	"s-ahb",
 };
@@ -965,6 +965,7 @@ static const struct geni_se_desc i2c_master_hub_desc = {
 static const struct of_device_id geni_se_dt_match[] = {
 	{ .compatible = "qcom,geni-se-qup", .data = &qup_desc },
 	{ .compatible = "qcom,geni-se-i2c-master-hub", .data = &i2c_master_hub_desc },
+	{ .compatible = "qcom,sa8255p-geni-se-qup", .data = &sa8255p_qup_desc },
 	{}
 };
 MODULE_DEVICE_TABLE(of, geni_se_dt_match);
Signature · 1 line
2.17.1
#6 lore raw

PATCH v7 4/8 serial: qcom-geni: move resource initialization to separate function

In reply to Praveen Talari

Enhances code readability and future modifications within the new API.

Move the code that handles the actual initialization of resources like clock and ICC paths to a separate function, making the probe function cleaner.

---
v5 -> v6
- added reviewed-by tag

v3 -> v4
- added version log after ---

v1 -> v2
- updated subject description.
- added a new line after function end

---
 drivers/tty/serial/qcom_geni_serial.c | 66 ++++++++++++++++-----------
 1 file changed, 40 insertions(+), 26 deletions(-)
drivers/tty/serial/qcom_geni_serial.c +40 -26
index 004f9a0d80f7..1e1c60d7aced 100644
@@ -1619,6 +1619,43 @@ static struct uart_driver qcom_geni_uart_driver = {
 	.nr =  GENI_UART_PORTS,
 };
 
+static int geni_serial_resource_init(struct qcom_geni_serial_port *port)
+{
+	int ret;
+
+	port->se.clk = devm_clk_get(port->se.dev, "se");
+	if (IS_ERR(port->se.clk)) {
+		ret = PTR_ERR(port->se.clk);
+		dev_err(port->se.dev, "Err getting SE Core clk %d\n", ret);
+		return ret;
+	}
+
+	ret = geni_icc_get(&port->se, NULL);
+	if (ret)
+		return ret;
+
+	port->se.icc_paths[GENI_TO_CORE].avg_bw = GENI_DEFAULT_BW;
+	port->se.icc_paths[CPU_TO_GENI].avg_bw = GENI_DEFAULT_BW;
+
+	/* Set BW for register access */
+	ret = geni_icc_set_bw(&port->se);
+	if (ret)
+		return ret;
+
+	ret = devm_pm_opp_set_clkname(port->se.dev, "se");
+	if (ret)
+		return ret;
+
+	/* OPP table is optional */
+	ret = devm_pm_opp_of_add_table(port->se.dev);
+	if (ret && ret != -ENODEV) {
+		dev_err(port->se.dev, "invalid OPP table in device tree\n");
+		return ret;
+	}
+
+	return 0;
+}
+
 static void qcom_geni_serial_pm(struct uart_port *uport,
 		unsigned int new_state, unsigned int old_state)
 {
@@ -1739,12 +1776,10 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 	port->dev_data = data;
 	port->se.dev = &pdev->dev;
 	port->se.wrapper = dev_get_drvdata(pdev->dev.parent);
-	port->se.clk = devm_clk_get(&pdev->dev, "se");
-	if (IS_ERR(port->se.clk)) {
-		ret = PTR_ERR(port->se.clk);
-		dev_err(&pdev->dev, "Err getting SE Core clk %d\n", ret);
+
+	ret = geni_serial_resource_init(port);
+	if (ret)
 		return ret;
-	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res)
@@ -1764,17 +1799,6 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 			return -ENOMEM;
 	}
 
-	ret = geni_icc_get(&port->se, NULL);
-	if (ret)
-		return ret;
-	port->se.icc_paths[GENI_TO_CORE].avg_bw = GENI_DEFAULT_BW;
-	port->se.icc_paths[CPU_TO_GENI].avg_bw = GENI_DEFAULT_BW;
-
-	/* Set BW for register access */
-	ret = geni_icc_set_bw(&port->se);
-	if (ret)
-		return ret;
-
 	port->name = devm_kasprintf(uport->dev, GFP_KERNEL,
 			"qcom_geni_serial_%s%d",
 			uart_console(uport) ? "console" : "uart", uport->line);
@@ -1796,16 +1820,6 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 	if (of_property_read_bool(pdev->dev.of_node, "cts-rts-swap"))
 		port->cts_rts_swap = true;
 
-	ret = devm_pm_opp_set_clkname(&pdev->dev, "se");
-	if (ret)
-		return ret;
-	/* OPP table is optional */
-	ret = devm_pm_opp_of_add_table(&pdev->dev);
-	if (ret && ret != -ENODEV) {
-		dev_err(&pdev->dev, "invalid OPP table in device tree\n");
-		return ret;
-	}
-
 	port->private_data.drv = drv;
 	uport->private_data = &port->private_data;
 	platform_set_drvdata(pdev, port);
Signature · 1 line
2.17.1
#7 lore raw

PATCH v7 5/8 serial: qcom-geni: move resource control logic to separate functions

In reply to Praveen Talari

Supports use in PM system/runtime frameworks, helping to distinguish new resource control mechanisms and facilitate future modifications within the new API.

The code that handles the actual enable or disable of resources like clock and ICC paths to a separate function (geni_serial_resources_on() and geni_serial_resources_off()) which enhances code readability.

Introduced minor return checks in newly added function APIs to enhance error detection and prevent silent failures.

---
v5 -> v6
- updated commit text for checks in newly added function APIs
- fiexd alignment
- reordered newly added function API definations.

v3 -> v4
- added version log after ---

v1 -> v2
- returned 0 instead of ret variable

---
 drivers/tty/serial/qcom_geni_serial.c | 54 +++++++++++++++++++++------
 1 file changed, 42 insertions(+), 12 deletions(-)
drivers/tty/serial/qcom_geni_serial.c +42 -12
index 1e1c60d7aced..45d9735247f8 100644
@@ -1619,6 +1619,42 @@ static struct uart_driver qcom_geni_uart_driver = {
 	.nr =  GENI_UART_PORTS,
 };
 
+static int geni_serial_resources_on(struct uart_port *uport)
+{
+	struct qcom_geni_serial_port *port = to_dev_port(uport);
+	int ret;
+
+	ret = geni_icc_enable(&port->se);
+	if (ret)
+		return ret;
+
+	ret = geni_se_resources_on(&port->se);
+	if (ret) {
+		geni_icc_disable(&port->se);
+		return ret;
+	}
+
+	if (port->clk_rate)
+		dev_pm_opp_set_rate(uport->dev, port->clk_rate);
+
+	return 0;
+}
+
+static int geni_serial_resources_off(struct uart_port *uport)
+{
+	struct qcom_geni_serial_port *port = to_dev_port(uport);
+	int ret;
+
+	dev_pm_opp_set_rate(uport->dev, 0);
+	ret = geni_se_resources_off(&port->se);
+	if (ret)
+		return ret;
+
+	geni_icc_disable(&port->se);
+
+	return 0;
+}
+
 static int geni_serial_resource_init(struct qcom_geni_serial_port *port)
 {
 	int ret;
@@ -1659,23 +1695,17 @@ static int geni_serial_resource_init(struct qcom_geni_serial_port *port)
 static void qcom_geni_serial_pm(struct uart_port *uport,
 		unsigned int new_state, unsigned int old_state)
 {
-	struct qcom_geni_serial_port *port = to_dev_port(uport);
 
 	/* If we've never been called, treat it as off */
 	if (old_state == UART_PM_STATE_UNDEFINED)
 		old_state = UART_PM_STATE_OFF;
 
-	if (new_state == UART_PM_STATE_ON && old_state == UART_PM_STATE_OFF) {
-		geni_icc_enable(&port->se);
-		if (port->clk_rate)
-			dev_pm_opp_set_rate(uport->dev, port->clk_rate);
-		geni_se_resources_on(&port->se);
-	} else if (new_state == UART_PM_STATE_OFF &&
-			old_state == UART_PM_STATE_ON) {
-		geni_se_resources_off(&port->se);
-		dev_pm_opp_set_rate(uport->dev, 0);
-		geni_icc_disable(&port->se);
-	}
+	if (new_state == UART_PM_STATE_ON && old_state == UART_PM_STATE_OFF)
+		geni_serial_resources_on(uport);
+	else if (new_state == UART_PM_STATE_OFF &&
+		 old_state == UART_PM_STATE_ON)
+		geni_serial_resources_off(uport);
+
 }
 
 /**
Signature · 1 line
2.17.1
#8 lore raw

PATCH v7 6/8 serial: qcom-geni: move clock-rate logic to separate function

In reply to Praveen Talari

Facilitates future modifications within the new function, leading to better readability and maintainability of the code.

Move the code that handles the actual logic of clock-rate calculations to a separate function geni_serial_set_rate() which enhances code readability.

---
v6 -> v7
From Bjorn:
- removed error log from qcom_geni_serial_set_termios().

v5 -> v6
- used "unsigned int" instead of "unsigned long" in newly added API function params to avoid the format specifier warnings.

v3 -> v4
- added version log after ---

v1 -> v2
- resolved build warnings for datatype format specifiers
- removed double spaces in log

---
 drivers/tty/serial/qcom_geni_serial.c | 52 ++++++++++++++++-----------
 1 file changed, 32 insertions(+), 20 deletions(-)
drivers/tty/serial/qcom_geni_serial.c +32 -20
index 45d9735247f8..81f385d900d0 100644
@@ -1314,27 +1314,14 @@ static unsigned long get_clk_div_rate(struct clk *clk, unsigned int baud,
 	return ser_clk;
 }
 
-static void qcom_geni_serial_set_termios(struct uart_port *uport,
-					 struct ktermios *termios,
-					 const struct ktermios *old)
+static int geni_serial_set_rate(struct uart_port *uport, unsigned int baud)
 {
-	unsigned int baud;
-	u32 bits_per_char;
-	u32 tx_trans_cfg;
-	u32 tx_parity_cfg;
-	u32 rx_trans_cfg;
-	u32 rx_parity_cfg;
-	u32 stop_bit_len;
-	unsigned int clk_div;
-	u32 ser_clk_cfg;
 	struct qcom_geni_serial_port *port = to_dev_port(uport);
 	unsigned long clk_rate;
-	u32 ver, sampling_rate;
 	unsigned int avg_bw_core;
-	unsigned long timeout;
-
-	/* baud rate */
-	baud = uart_get_baud_rate(uport, termios, old, 300, 8000000);
+	unsigned int clk_div;
+	u32 ver, sampling_rate;
+	u32 ser_clk_cfg;
 
 	sampling_rate = UART_OVERSAMPLING;
 	/* Sampling rate is halved for IP versions >= 2.5 */
@@ -1348,7 +1335,7 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
 		dev_err(port->se.dev,
 			"Couldn't find suitable clock rate for %u\n",
 			baud * sampling_rate);
-		return;
+		return -EINVAL;
 	}
 
 	dev_dbg(port->se.dev, "desired_rate = %u, clk_rate = %lu, clk_div = %u\n",
@@ -1370,6 +1357,33 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
 	port->se.icc_paths[CPU_TO_GENI].avg_bw = Bps_to_icc(baud);
 	geni_icc_set_bw(&port->se);
 
+	writel(ser_clk_cfg, uport->membase + GENI_SER_M_CLK_CFG);
+	writel(ser_clk_cfg, uport->membase + GENI_SER_S_CLK_CFG);
+	return 0;
+}
+
+static void qcom_geni_serial_set_termios(struct uart_port *uport,
+					 struct ktermios *termios,
+					 const struct ktermios *old)
+{
+	struct qcom_geni_serial_port *port = to_dev_port(uport);
+	unsigned int baud;
+	unsigned long timeout;
+	u32 bits_per_char;
+	u32 tx_trans_cfg;
+	u32 tx_parity_cfg;
+	u32 rx_trans_cfg;
+	u32 rx_parity_cfg;
+	u32 stop_bit_len;
+	int ret = 0;
+
+	/* baud rate */
+	baud = uart_get_baud_rate(uport, termios, old, 300, 8000000);
+
+	ret = geni_serial_set_rate(uport, baud);
+	if (ret)
+		return;
+
 	/* parity */
 	tx_trans_cfg = readl(uport->membase + SE_UART_TX_TRANS_CFG);
 	tx_parity_cfg = readl(uport->membase + SE_UART_TX_PARITY_CFG);
@@ -1437,8 +1451,6 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
 	writel(bits_per_char, uport->membase + SE_UART_TX_WORD_LEN);
 	writel(bits_per_char, uport->membase + SE_UART_RX_WORD_LEN);
 	writel(stop_bit_len, uport->membase + SE_UART_TX_STOP_BIT_LEN);
-	writel(ser_clk_cfg, uport->membase + GENI_SER_M_CLK_CFG);
-	writel(ser_clk_cfg, uport->membase + GENI_SER_S_CLK_CFG);
 }
 
 #ifdef CONFIG_SERIAL_QCOM_GENI_CONSOLE
Signature · 1 line
2.17.1
#9 lore raw

PATCH v7 7/8 serial: qcom-geni: Enable PM runtime for serial driver

In reply to Praveen Talari

The GENI serial driver currently handles power resource management through calls to the statically defined geni_serial_resources_on() and geni_serial_resources_off() functions. This approach reduces modularity and limits support for platforms with diverse power management mechanisms, including resource managed by firmware.

Improve modularity and enable better integration with platform-specific power management, introduce support for runtime PM. Use pm_runtime_resume_and_get() and pm_runtime_put_sync() within the qcom_geni_serial_pm() callback to control resource power state transitions based on UART power state changes.

---
v6 -> v7
From Bjorn:
- used devm_pm_runtime_enable() instead of pm_runtime_enable()
- updated commit text.

v5 -> v6
- added reviewed-by tag in commit
- added __maybe_unused to PM callback functions to avoid warnings of defined but not used

---
 drivers/tty/serial/qcom_geni_serial.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
drivers/tty/serial/qcom_geni_serial.c +22 -2
index 81f385d900d0..aa08de659e34 100644
@@ -1713,10 +1713,10 @@ static void qcom_geni_serial_pm(struct uart_port *uport,
 		old_state = UART_PM_STATE_OFF;
 
 	if (new_state == UART_PM_STATE_ON && old_state == UART_PM_STATE_OFF)
-		geni_serial_resources_on(uport);
+		pm_runtime_resume_and_get(uport->dev);
 	else if (new_state == UART_PM_STATE_OFF &&
 		 old_state == UART_PM_STATE_ON)
-		geni_serial_resources_off(uport);
+		pm_runtime_put_sync(uport->dev);
 
 }
 
@@ -1878,6 +1878,8 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	devm_pm_runtime_enable(port->se.dev);
+
 	ret = uart_add_one_port(drv, uport);
 	if (ret)
 		return ret;
@@ -1909,6 +1911,22 @@ static void qcom_geni_serial_remove(struct platform_device *pdev)
 	uart_remove_one_port(drv, &port->uport);
 }
 
+static int __maybe_unused qcom_geni_serial_runtime_suspend(struct device *dev)
+{
+	struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
+	struct uart_port *uport = &port->uport;
+
+	return geni_serial_resources_off(uport);
+}
+
+static int __maybe_unused qcom_geni_serial_runtime_resume(struct device *dev)
+{
+	struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
+	struct uart_port *uport = &port->uport;
+
+	return geni_serial_resources_on(uport);
+}
+
 static int qcom_geni_serial_suspend(struct device *dev)
 {
 	struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
@@ -1952,6 +1970,8 @@ static const struct qcom_geni_device_data qcom_geni_uart_data = {
 };
 
 static const struct dev_pm_ops qcom_geni_serial_pm_ops = {
+	SET_RUNTIME_PM_OPS(qcom_geni_serial_runtime_suspend,
+			   qcom_geni_serial_runtime_resume, NULL)
 	SYSTEM_SLEEP_PM_OPS(qcom_geni_serial_suspend, qcom_geni_serial_resume)
 };
 
Signature · 1 line
2.17.1
#10 lore raw

Re: [PATCH v7 7/8] serial: qcom-geni: Enable PM runtime for serial driver

(c/c Neil and Srini)

Quoted 6 lines · Praveen Talari

The GENI serial driver currently handles power resource management through calls to the statically defined geni_serial_resources_on() and geni_serial_resources_off() functions. This approach reduces modularity and limits support for platforms with diverse power management mechanisms, including resource managed by firmware.

Quoted 8 lines

Improve modularity and enable better integration with platform-specific power management, introduce support for runtime PM. Use pm_runtime_resume_and_get() and pm_runtime_put_sync() within the qcom_geni_serial_pm() callback to control resource power state transitions based on UART power state changes.

This breaks at least RB1 (QRB2210), maybe others.
Currently broken on -master and on linux-next.

Upon login prompt random parts of kernel seems to be off/failed and debugging led to udev being stuck:

[   85.369834] INFO: task kworker/u16:0:12 blocked for more than 42 seconds.
[   85.376699]       Not tainted 6.17.0-rc1-00004-g53e760d89498 #9
[   85.382660] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[   85.390547] task:kworker/u16:0   state:D stack:0     pid:12    tgid:12    ppid:2      task_flags:0x4208060 flags:0x00000010
[   85.401748] Workqueue: async async_run_entry_fn
[   85.406349] Call trace:
[   85.408828]  __switch_to+0xe8/0x1a0 (T)
[   85.412724]  __schedule+0x290/0x7c0
[   85.416275]  schedule+0x34/0x118
[   85.419554]  rpm_resume+0x14c/0x66c
[   85.423111]  rpm_resume+0x2a4/0x66c
[   85.426647]  rpm_resume+0x2a4/0x66c
[   85.430188]  rpm_resume+0x2a4/0x66c
[   85.433722]  __pm_runtime_resume+0x50/0x9c
[   85.437869]  __driver_probe_device+0x58/0x120
[   85.442287]  driver_probe_device+0x3c/0x154
[   85.446523]  __driver_attach_async_helper+0x4c/0xc0
[   85.451446]  async_run_entry_fn+0x34/0xe0
[   85.455504]  process_one_work+0x148/0x290
[   85.459565]  worker_thread+0x2c4/0x3e0
[   85.463368]  kthread+0x118/0x1c0
[   85.466651]  ret_from_fork+0x10/0x20
[   85.470337] INFO: task irq/92-4a8c000.:71 blocked for more than 42 seconds.
[   85.477351]       Not tainted 6.17.0-rc1-00004-g53e760d89498 #9
[   85.483323] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[   85.491195] task:irq/92-4a8c000. state:D stack:0     pid:71    tgid:71    ppid:2      task_flags:0x208040 flags:0x00000010
[   85.502290] Call trace:
[   85.504786]  __switch_to+0xe8/0x1a0 (T)
[   85.508687]  __schedule+0x290/0x7c0
[   85.512231]  schedule+0x34/0x118
[   85.515504]  __synchronize_irq+0x60/0xa0
[   85.519483]  disable_irq+0x3c/0x4c
[   85.522929]  msm_pinmux_set_mux+0x3a8/0x44c
[   85.527167]  pinmux_enable_setting+0x1c4/0x28c
[   85.531665]  pinctrl_commit_state+0xa0/0x260
[   85.535989]  pinctrl_pm_select_default_state+0x4c/0xa0
[   85.541182]  geni_se_resources_on+0xd0/0x15c
[   85.545522]  geni_serial_resource_state+0x8c/0xbc
[   85.550282]  qcom_geni_serial_runtime_resume+0x24/0x3c
[   85.555470]  pm_generic_runtime_resume+0x2c/0x44
[   85.560139]  __rpm_callback+0x48/0x1e0
[   85.563949]  rpm_callback+0x74/0x80
[   85.567494]  rpm_resume+0x39c/0x66c
[   85.571040]  __pm_runtime_resume+0x50/0x9c
[   85.575193]  handle_threaded_wake_irq+0x30/0x80
[   85.579771]  irq_thread_fn+0x2c/0xb0
[   85.583443]  irq_thread+0x16c/0x278
[   85.587003]  kthread+0x118/0x1c0
[   85.590283]  ret_from_fork+0x10/0x20
[   85.593943] INFO: task (udev-worker):228 blocked for more than 42 seconds.
[   85.600873]       Not tainted 6.17.0-rc1-00004-g53e760d89498 #9
[   85.606846] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[   85.614717] task:(udev-worker)   state:D stack:0     pid:228   tgid:228   ppid:222    task_flags:0x400140 flags:0x00000818
[   85.625823] Call trace:
[   85.628316]  __switch_to+0xe8/0x1a0 (T)
[   85.632217]  __schedule+0x290/0x7c0
[   85.635765]  schedule+0x34/0x118
[   85.639044]  async_synchronize_cookie_domain.part.0+0x50/0xa4
[   85.644854]  async_synchronize_full+0x78/0xa0
[   85.649270]  do_init_module+0x190/0x23c
[   85.653154]  load_module+0x1708/0x1ca0
[   85.656952]  init_module_from_file+0x74/0xa0
[   85.661273]  __arm64_sys_finit_module+0x130/0x2f8
[   85.666023]  invoke_syscall+0x48/0x104
[   85.669842]  el0_svc_common.constprop.0+0xc0/0xe0
[   85.674604]  do_el0_svc+0x1c/0x28
[   85.677973]  el0_svc+0x2c/0x84
[   85.681078]  el0t_64_sync_handler+0xa0/0xe4
[   85.685316]  el0t_64_sync+0x198/0x19c
[   85.689032] INFO: task (udev-worker):229 blocked for more than 42 seconds.

Usually wifi, all remoteprocs and anything that depends on lpass/pinctrl fail to probe.

Reverting these:
86fa39dd6fb7 serial: qcom-geni: Enable Serial on SA8255p Qualcomm platforms 1afa70632c39 serial: qcom-geni: Enable PM runtime for serial driver

resolves the regression. Couldn't say if we should go with reverting since 86fa39dd6fb7 adds support of serial on SA8255p and for clean revert both have to be reverted.

Any thoughts?

Best regards,
Alexey

Quoted 72 lines

---
v6 -> v7
From Bjorn:
- used devm_pm_runtime_enable() instead of pm_runtime_enable()
- updated commit text.

v5 -> v6
- added reviewed-by tag in commit
- added __maybe_unused to PM callback functions to avoid warnings of defined but not used

---
 drivers/tty/serial/qcom_geni_serial.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
drivers/tty/serial/qcom_geni_serial.c +22 -2
index 81f385d900d0..aa08de659e34 100644
@@ -1713,10 +1713,10 @@ static void qcom_geni_serial_pm(struct uart_port *uport,
 		old_state = UART_PM_STATE_OFF;
 
 	if (new_state == UART_PM_STATE_ON && old_state == UART_PM_STATE_OFF)
-		geni_serial_resources_on(uport);
+		pm_runtime_resume_and_get(uport->dev);
 	else if (new_state == UART_PM_STATE_OFF &&
 		 old_state == UART_PM_STATE_ON)
-		geni_serial_resources_off(uport);
+		pm_runtime_put_sync(uport->dev);
 
 }
 
@@ -1878,6 +1878,8 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	devm_pm_runtime_enable(port->se.dev);
+
 	ret = uart_add_one_port(drv, uport);
 	if (ret)
 		return ret;
@@ -1909,6 +1911,22 @@ static void qcom_geni_serial_remove(struct platform_device *pdev)
 	uart_remove_one_port(drv, &port->uport);
 }
 
+static int __maybe_unused qcom_geni_serial_runtime_suspend(struct device *dev)
+{
+	struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
+	struct uart_port *uport = &port->uport;
+
+	return geni_serial_resources_off(uport);
+}
+
+static int __maybe_unused qcom_geni_serial_runtime_resume(struct device *dev)
+{
+	struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
+	struct uart_port *uport = &port->uport;
+
+	return geni_serial_resources_on(uport);
+}
+
 static int qcom_geni_serial_suspend(struct device *dev)
 {
 	struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
@@ -1952,6 +1970,8 @@ static const struct qcom_geni_device_data qcom_geni_uart_data = {
 };
 
 static const struct dev_pm_ops qcom_geni_serial_pm_ops = {
+	SET_RUNTIME_PM_OPS(qcom_geni_serial_runtime_suspend,
+			   qcom_geni_serial_runtime_resume, NULL)
 	SYSTEM_SLEEP_PM_OPS(qcom_geni_serial_suspend, qcom_geni_serial_resume)
 };
 
#11 lore raw

Re: [PATCH v7 7/8] serial: qcom-geni: Enable PM runtime for serial driver

Hi Alexey.

Thank you for your patience,

Quoted 97 lines · Alexey Klimov

(c/c Neil and Srini)

Quoted 6 lines · Praveen Talari

The GENI serial driver currently handles power resource management through calls to the statically defined geni_serial_resources_on() and geni_serial_resources_off() functions. This approach reduces modularity and limits support for platforms with diverse power management mechanisms, including resource managed by firmware.

Quoted 8 lines

Improve modularity and enable better integration with platform-specific power management, introduce support for runtime PM. Use pm_runtime_resume_and_get() and pm_runtime_put_sync() within the qcom_geni_serial_pm() callback to control resource power state transitions based on UART power state changes.

This breaks at least RB1 (QRB2210), maybe others.
Currently broken on -master and on linux-next.

Upon login prompt random parts of kernel seems to be off/failed and debugging led to udev being stuck:

[   85.369834] INFO: task kworker/u16:0:12 blocked for more than 42 seconds.
[   85.376699]       Not tainted 6.17.0-rc1-00004-g53e760d89498 #9
[   85.382660] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[   85.390547] task:kworker/u16:0   state:D stack:0     pid:12    tgid:12    ppid:2      task_flags:0x4208060 flags:0x00000010
[   85.401748] Workqueue: async async_run_entry_fn
[   85.406349] Call trace:
[   85.408828]  __switch_to+0xe8/0x1a0 (T)
[   85.412724]  __schedule+0x290/0x7c0
[   85.416275]  schedule+0x34/0x118
[   85.419554]  rpm_resume+0x14c/0x66c
[   85.423111]  rpm_resume+0x2a4/0x66c
[   85.426647]  rpm_resume+0x2a4/0x66c
[   85.430188]  rpm_resume+0x2a4/0x66c
[   85.433722]  __pm_runtime_resume+0x50/0x9c
[   85.437869]  __driver_probe_device+0x58/0x120
[   85.442287]  driver_probe_device+0x3c/0x154
[   85.446523]  __driver_attach_async_helper+0x4c/0xc0
[   85.451446]  async_run_entry_fn+0x34/0xe0
[   85.455504]  process_one_work+0x148/0x290
[   85.459565]  worker_thread+0x2c4/0x3e0
[   85.463368]  kthread+0x118/0x1c0
[   85.466651]  ret_from_fork+0x10/0x20
[   85.470337] INFO: task irq/92-4a8c000.:71 blocked for more than 42 seconds.
[   85.477351]       Not tainted 6.17.0-rc1-00004-g53e760d89498 #9
[   85.483323] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[   85.491195] task:irq/92-4a8c000. state:D stack:0     pid:71    tgid:71    ppid:2      task_flags:0x208040 flags:0x00000010
[   85.502290] Call trace:
[   85.504786]  __switch_to+0xe8/0x1a0 (T)
[   85.508687]  __schedule+0x290/0x7c0
[   85.512231]  schedule+0x34/0x118
[   85.515504]  __synchronize_irq+0x60/0xa0
[   85.519483]  disable_irq+0x3c/0x4c
[   85.522929]  msm_pinmux_set_mux+0x3a8/0x44c
[   85.527167]  pinmux_enable_setting+0x1c4/0x28c
[   85.531665]  pinctrl_commit_state+0xa0/0x260
[   85.535989]  pinctrl_pm_select_default_state+0x4c/0xa0
[   85.541182]  geni_se_resources_on+0xd0/0x15c
[   85.545522]  geni_serial_resource_state+0x8c/0xbc
[   85.550282]  qcom_geni_serial_runtime_resume+0x24/0x3c
[   85.555470]  pm_generic_runtime_resume+0x2c/0x44
[   85.560139]  __rpm_callback+0x48/0x1e0
[   85.563949]  rpm_callback+0x74/0x80
[   85.567494]  rpm_resume+0x39c/0x66c
[   85.571040]  __pm_runtime_resume+0x50/0x9c
[   85.575193]  handle_threaded_wake_irq+0x30/0x80
[   85.579771]  irq_thread_fn+0x2c/0xb0
[   85.583443]  irq_thread+0x16c/0x278
[   85.587003]  kthread+0x118/0x1c0
[   85.590283]  ret_from_fork+0x10/0x20
[   85.593943] INFO: task (udev-worker):228 blocked for more than 42 seconds.
[   85.600873]       Not tainted 6.17.0-rc1-00004-g53e760d89498 #9
[   85.606846] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[   85.614717] task:(udev-worker)   state:D stack:0     pid:228   tgid:228   ppid:222    task_flags:0x400140 flags:0x00000818
[   85.625823] Call trace:
[   85.628316]  __switch_to+0xe8/0x1a0 (T)
[   85.632217]  __schedule+0x290/0x7c0
[   85.635765]  schedule+0x34/0x118
[   85.639044]  async_synchronize_cookie_domain.part.0+0x50/0xa4
[   85.644854]  async_synchronize_full+0x78/0xa0
[   85.649270]  do_init_module+0x190/0x23c
[   85.653154]  load_module+0x1708/0x1ca0
[   85.656952]  init_module_from_file+0x74/0xa0
[   85.661273]  __arm64_sys_finit_module+0x130/0x2f8
[   85.666023]  invoke_syscall+0x48/0x104
[   85.669842]  el0_svc_common.constprop.0+0xc0/0xe0
[   85.674604]  do_el0_svc+0x1c/0x28
[   85.677973]  el0_svc+0x2c/0x84
[   85.681078]  el0t_64_sync_handler+0xa0/0xe4
[   85.685316]  el0t_64_sync+0x198/0x19c
[   85.689032] INFO: task (udev-worker):229 blocked for more than 42 seconds.
Quoted 1 line

Usually wifi, all remoteprocs and anything that depends on lpass/pinctrl fail to probe.

May i know what is testcase which you are running on target? what is target?
Which usecase is this issue occurring in?

Thanks,
Praveen Talari

Quoted 90 lines

Reverting these:
86fa39dd6fb7 serial: qcom-geni: Enable Serial on SA8255p Qualcomm platforms 1afa70632c39 serial: qcom-geni: Enable PM runtime for serial driver

resolves the regression. Couldn't say if we should go with reverting since 86fa39dd6fb7 adds support of serial on SA8255p and for clean revert both have to be reverted.

Any thoughts?

Best regards,
Alexey

Quoted 72 lines

---
v6 -> v7
From Bjorn:
- used devm_pm_runtime_enable() instead of pm_runtime_enable()
- updated commit text.

v5 -> v6
- added reviewed-by tag in commit
- added __maybe_unused to PM callback functions to avoid warnings of defined but not used

---
  drivers/tty/serial/qcom_geni_serial.c | 24 ++++++++++++++++++++++--
  1 file changed, 22 insertions(+), 2 deletions(-)
drivers/tty/serial/qcom_geni_serial.c +22 -2
index 81f385d900d0..aa08de659e34 100644
@@ -1713,10 +1713,10 @@ static void qcom_geni_serial_pm(struct uart_port *uport,
  		old_state = UART_PM_STATE_OFF;
 
  	if (new_state == UART_PM_STATE_ON && old_state == UART_PM_STATE_OFF)
-		geni_serial_resources_on(uport);
+		pm_runtime_resume_and_get(uport->dev);
  	else if (new_state == UART_PM_STATE_OFF &&
  		 old_state == UART_PM_STATE_ON)
-		geni_serial_resources_off(uport);
+		pm_runtime_put_sync(uport->dev);
 
  }
 
@@ -1878,6 +1878,8 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
  	if (ret)
  		return ret;
 
+	devm_pm_runtime_enable(port->se.dev);
+
  	ret = uart_add_one_port(drv, uport);
  	if (ret)
  		return ret;
@@ -1909,6 +1911,22 @@ static void qcom_geni_serial_remove(struct platform_device *pdev)
  	uart_remove_one_port(drv, &port->uport);
  }
 
+static int __maybe_unused qcom_geni_serial_runtime_suspend(struct device *dev)
+{
+	struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
+	struct uart_port *uport = &port->uport;
+
+	return geni_serial_resources_off(uport);
+}
+
+static int __maybe_unused qcom_geni_serial_runtime_resume(struct device *dev)
+{
+	struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
+	struct uart_port *uport = &port->uport;
+
+	return geni_serial_resources_on(uport);
+}
+
  static int qcom_geni_serial_suspend(struct device *dev)
  {
  	struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
@@ -1952,6 +1970,8 @@ static const struct qcom_geni_device_data qcom_geni_uart_data = {
  };
 
  static const struct dev_pm_ops qcom_geni_serial_pm_ops = {
+	SET_RUNTIME_PM_OPS(qcom_geni_serial_runtime_suspend,
+			   qcom_geni_serial_runtime_resume, NULL)
  	SYSTEM_SLEEP_PM_OPS(qcom_geni_serial_suspend, qcom_geni_serial_resume)
  };
 
#12 lore raw

Re: [PATCH v7 7/8] serial: qcom-geni: Enable PM runtime for serial driver

Quoted 102 lines · Praveen Talari

Hi Alexey.

Thank you for your patience,

Quoted 97 lines · Alexey Klimov

(c/c Neil and Srini)

Quoted 6 lines · Praveen Talari

The GENI serial driver currently handles power resource management through calls to the statically defined geni_serial_resources_on() and geni_serial_resources_off() functions. This approach reduces modularity and limits support for platforms with diverse power management mechanisms, including resource managed by firmware.

Quoted 8 lines

Improve modularity and enable better integration with platform-specific power management, introduce support for runtime PM. Use pm_runtime_resume_and_get() and pm_runtime_put_sync() within the qcom_geni_serial_pm() callback to control resource power state transitions based on UART power state changes.

This breaks at least RB1 (QRB2210), maybe others.
Currently broken on -master and on linux-next.

Upon login prompt random parts of kernel seems to be off/failed and debugging led to udev being stuck:

[   85.369834] INFO: task kworker/u16:0:12 blocked for more than 42 seconds.
[   85.376699]       Not tainted 6.17.0-rc1-00004-g53e760d89498 #9
[   85.382660] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[   85.390547] task:kworker/u16:0   state:D stack:0     pid:12    tgid:12    ppid:2      task_flags:0x4208060 flags:0x00000010
[   85.401748] Workqueue: async async_run_entry_fn
[   85.406349] Call trace:
[   85.408828]  __switch_to+0xe8/0x1a0 (T)
[   85.412724]  __schedule+0x290/0x7c0
[   85.416275]  schedule+0x34/0x118
[   85.419554]  rpm_resume+0x14c/0x66c
[   85.423111]  rpm_resume+0x2a4/0x66c
[   85.426647]  rpm_resume+0x2a4/0x66c
[   85.430188]  rpm_resume+0x2a4/0x66c
[   85.433722]  __pm_runtime_resume+0x50/0x9c
[   85.437869]  __driver_probe_device+0x58/0x120
[   85.442287]  driver_probe_device+0x3c/0x154
[   85.446523]  __driver_attach_async_helper+0x4c/0xc0
[   85.451446]  async_run_entry_fn+0x34/0xe0
[   85.455504]  process_one_work+0x148/0x290
[   85.459565]  worker_thread+0x2c4/0x3e0
[   85.463368]  kthread+0x118/0x1c0
[   85.466651]  ret_from_fork+0x10/0x20
[   85.470337] INFO: task irq/92-4a8c000.:71 blocked for more than 42 seconds.
[   85.477351]       Not tainted 6.17.0-rc1-00004-g53e760d89498 #9
[   85.483323] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[   85.491195] task:irq/92-4a8c000. state:D stack:0     pid:71    tgid:71    ppid:2      task_flags:0x208040 flags:0x00000010
[   85.502290] Call trace:
[   85.504786]  __switch_to+0xe8/0x1a0 (T)
[   85.508687]  __schedule+0x290/0x7c0
[   85.512231]  schedule+0x34/0x118
[   85.515504]  __synchronize_irq+0x60/0xa0
[   85.519483]  disable_irq+0x3c/0x4c
[   85.522929]  msm_pinmux_set_mux+0x3a8/0x44c
[   85.527167]  pinmux_enable_setting+0x1c4/0x28c
[   85.531665]  pinctrl_commit_state+0xa0/0x260
[   85.535989]  pinctrl_pm_select_default_state+0x4c/0xa0
[   85.541182]  geni_se_resources_on+0xd0/0x15c
[   85.545522]  geni_serial_resource_state+0x8c/0xbc
[   85.550282]  qcom_geni_serial_runtime_resume+0x24/0x3c
[   85.555470]  pm_generic_runtime_resume+0x2c/0x44
[   85.560139]  __rpm_callback+0x48/0x1e0
[   85.563949]  rpm_callback+0x74/0x80
[   85.567494]  rpm_resume+0x39c/0x66c
[   85.571040]  __pm_runtime_resume+0x50/0x9c
[   85.575193]  handle_threaded_wake_irq+0x30/0x80
[   85.579771]  irq_thread_fn+0x2c/0xb0
[   85.583443]  irq_thread+0x16c/0x278
[   85.587003]  kthread+0x118/0x1c0
[   85.590283]  ret_from_fork+0x10/0x20
[   85.593943] INFO: task (udev-worker):228 blocked for more than 42 seconds.
[   85.600873]       Not tainted 6.17.0-rc1-00004-g53e760d89498 #9
[   85.606846] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[   85.614717] task:(udev-worker)   state:D stack:0     pid:228   tgid:228   ppid:222    task_flags:0x400140 flags:0x00000818
[   85.625823] Call trace:
[   85.628316]  __switch_to+0xe8/0x1a0 (T)
[   85.632217]  __schedule+0x290/0x7c0
[   85.635765]  schedule+0x34/0x118
[   85.639044]  async_synchronize_cookie_domain.part.0+0x50/0xa4
[   85.644854]  async_synchronize_full+0x78/0xa0
[   85.649270]  do_init_module+0x190/0x23c
[   85.653154]  load_module+0x1708/0x1ca0
[   85.656952]  init_module_from_file+0x74/0xa0
[   85.661273]  __arm64_sys_finit_module+0x130/0x2f8
[   85.666023]  invoke_syscall+0x48/0x104
[   85.669842]  el0_svc_common.constprop.0+0xc0/0xe0
[   85.674604]  do_el0_svc+0x1c/0x28
[   85.677973]  el0_svc+0x2c/0x84
[   85.681078]  el0t_64_sync_handler+0xa0/0xe4
[   85.685316]  el0t_64_sync+0x198/0x19c
[   85.689032] INFO: task (udev-worker):229 blocked for more than 42 seconds.
Quoted 3 lines
Quoted 1 line

Usually wifi, all remoteprocs and anything that depends on lpass/pinctrl fail to probe.

May i know what is testcase which you are running on target?

Boot the board?

Quoted 1 line

what is target?

It is written in original report. Did you even read it?

Quoted 1 line

Which usecase is this issue occurring in?

Boot?

Best regards,
Krzysztof

#13 lore raw

Re: [PATCH v7 7/8] serial: qcom-geni: Enable PM runtime for serial driver

Hi Praveen,

Hi Praveen,

Quoted 4 lines · Krzysztof Kozlowski
Quoted 3 lines · Praveen Talari

Hi Alexey.

Thank you for your patience,

Well, any update on this?

Quoted 104 lines
Quoted 98 lines · Alexey Klimov
Quoted 97 lines

(c/c Neil and Srini)

Quoted 6 lines · Praveen Talari

The GENI serial driver currently handles power resource management through calls to the statically defined geni_serial_resources_on() and geni_serial_resources_off() functions. This approach reduces modularity and limits support for platforms with diverse power management mechanisms, including resource managed by firmware.

Quoted 8 lines

Improve modularity and enable better integration with platform-specific power management, introduce support for runtime PM. Use pm_runtime_resume_and_get() and pm_runtime_put_sync() within the qcom_geni_serial_pm() callback to control resource power state transitions based on UART power state changes.

This breaks at least RB1 (QRB2210), maybe others.
Currently broken on -master and on linux-next.

Upon login prompt random parts of kernel seems to be off/failed and debugging led to udev being stuck:

[   85.369834] INFO: task kworker/u16:0:12 blocked for more than 42 seconds.
[   85.376699]       Not tainted 6.17.0-rc1-00004-g53e760d89498 #9
[   85.382660] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[   85.390547] task:kworker/u16:0   state:D stack:0     pid:12    tgid:12    ppid:2      task_flags:0x4208060 flags:0x00000010
[   85.401748] Workqueue: async async_run_entry_fn
[   85.406349] Call trace:
[   85.408828]  __switch_to+0xe8/0x1a0 (T)
[   85.412724]  __schedule+0x290/0x7c0
[   85.416275]  schedule+0x34/0x118
[   85.419554]  rpm_resume+0x14c/0x66c
[   85.423111]  rpm_resume+0x2a4/0x66c
[   85.426647]  rpm_resume+0x2a4/0x66c
[   85.430188]  rpm_resume+0x2a4/0x66c
[   85.433722]  __pm_runtime_resume+0x50/0x9c
[   85.437869]  __driver_probe_device+0x58/0x120
[   85.442287]  driver_probe_device+0x3c/0x154
[   85.446523]  __driver_attach_async_helper+0x4c/0xc0
[   85.451446]  async_run_entry_fn+0x34/0xe0
[   85.455504]  process_one_work+0x148/0x290
[   85.459565]  worker_thread+0x2c4/0x3e0
[   85.463368]  kthread+0x118/0x1c0
[   85.466651]  ret_from_fork+0x10/0x20
[   85.470337] INFO: task irq/92-4a8c000.:71 blocked for more than 42 seconds.
[   85.477351]       Not tainted 6.17.0-rc1-00004-g53e760d89498 #9
[   85.483323] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[   85.491195] task:irq/92-4a8c000. state:D stack:0     pid:71    tgid:71    ppid:2      task_flags:0x208040 flags:0x00000010
[   85.502290] Call trace:
[   85.504786]  __switch_to+0xe8/0x1a0 (T)
[   85.508687]  __schedule+0x290/0x7c0
[   85.512231]  schedule+0x34/0x118
[   85.515504]  __synchronize_irq+0x60/0xa0
[   85.519483]  disable_irq+0x3c/0x4c
[   85.522929]  msm_pinmux_set_mux+0x3a8/0x44c
[   85.527167]  pinmux_enable_setting+0x1c4/0x28c
[   85.531665]  pinctrl_commit_state+0xa0/0x260
[   85.535989]  pinctrl_pm_select_default_state+0x4c/0xa0
[   85.541182]  geni_se_resources_on+0xd0/0x15c
[   85.545522]  geni_serial_resource_state+0x8c/0xbc
[   85.550282]  qcom_geni_serial_runtime_resume+0x24/0x3c
[   85.555470]  pm_generic_runtime_resume+0x2c/0x44
[   85.560139]  __rpm_callback+0x48/0x1e0
[   85.563949]  rpm_callback+0x74/0x80
[   85.567494]  rpm_resume+0x39c/0x66c
[   85.571040]  __pm_runtime_resume+0x50/0x9c
[   85.575193]  handle_threaded_wake_irq+0x30/0x80
[   85.579771]  irq_thread_fn+0x2c/0xb0
[   85.583443]  irq_thread+0x16c/0x278
[   85.587003]  kthread+0x118/0x1c0
[   85.590283]  ret_from_fork+0x10/0x20
[   85.593943] INFO: task (udev-worker):228 blocked for more than 42 seconds.
[   85.600873]       Not tainted 6.17.0-rc1-00004-g53e760d89498 #9
[   85.606846] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[   85.614717] task:(udev-worker)   state:D stack:0     pid:228   tgid:228   ppid:222    task_flags:0x400140 flags:0x00000818
[   85.625823] Call trace:
[   85.628316]  __switch_to+0xe8/0x1a0 (T)
[   85.632217]  __schedule+0x290/0x7c0
[   85.635765]  schedule+0x34/0x118
[   85.639044]  async_synchronize_cookie_domain.part.0+0x50/0xa4
[   85.644854]  async_synchronize_full+0x78/0xa0
[   85.649270]  do_init_module+0x190/0x23c
[   85.653154]  load_module+0x1708/0x1ca0
[   85.656952]  init_module_from_file+0x74/0xa0
[   85.661273]  __arm64_sys_finit_module+0x130/0x2f8
[   85.666023]  invoke_syscall+0x48/0x104
[   85.669842]  el0_svc_common.constprop.0+0xc0/0xe0
[   85.674604]  do_el0_svc+0x1c/0x28
[   85.677973]  el0_svc+0x2c/0x84
[   85.681078]  el0t_64_sync_handler+0xa0/0xe4
[   85.685316]  el0t_64_sync+0x198/0x19c
[   85.689032] INFO: task (udev-worker):229 blocked for more than 42 seconds.
Quoted 3 lines
Quoted 1 line

Usually wifi, all remoteprocs and anything that depends on lpass/pinctrl fail to probe.

May i know what is testcase which you are running on target?

Boot the board?

Quoted 7 lines
Quoted 1 line

what is target?

It is written in original report. Did you even read it?

Quoted 1 line

Which usecase is this issue occurring in?

Boot?

FWIW, what said above by Krzysztof is correct, there is no usecase, just booting the board.

Best regards,
Alexey

#14 lore raw

Re: [PATCH v7 7/8] serial: qcom-geni: Enable PM runtime for serial driver

Quoted 6 lines · Alexey Klimov
Quoted 6 lines
Quoted 1 line

May i know what is testcase which you are running on target?

Boot the board?

Quoted 1 line

what is target?

Quoted 8 lines
Quoted 5 lines

It is written in original report. Did you even read it?

Quoted 1 line

Which usecase is this issue occurring in?

Boot?

FWIW, what said above by Krzysztof is correct, there is no usecase, just booting the board.

12 days and nothing improved, right? if this was not dropped now, Alexey, can you send a revert? Author clearly approches stability with a very relaxed way and is just happy that patch was thrown over the wall and job is done.

If you do not want to send revert, let me know, I will do it.

Best regards,
Krzysztof

#15 lore raw

Re: [PATCH v7 7/8] serial: qcom-geni: Enable PM runtime for serial driver

Quoted 15 lines · Krzysztof Kozlowski
Quoted 6 lines · Alexey Klimov
Quoted 6 lines
Quoted 1 line

May i know what is testcase which you are running on target?

Boot the board?

Quoted 1 line

what is target?

Quoted 8 lines
Quoted 5 lines

It is written in original report. Did you even read it?

Quoted 1 line

Which usecase is this issue occurring in?

Boot?

FWIW, what said above by Krzysztof is correct, there is no usecase, just booting the board.

Quoted 7 lines

12 days and nothing improved, right? if this was not dropped now, Alexey, can you send a revert? Author clearly approches stability with a very relaxed way and is just happy that patch was thrown over the wall and job is done.

If you do not want to send revert, let me know, I will do it.

I am okay with sending revert, just trying to see if there is any interest in fixing this.

Thanks,
Alexey

#16 lore raw

Re: [PATCH v7 7/8] serial: qcom-geni: Enable PM runtime for serial driver

Quoted 22 lines · Alexey Klimov
Quoted 21 lines · Krzysztof Kozlowski
Quoted 6 lines · Alexey Klimov
Quoted 6 lines
Quoted 1 line

May i know what is testcase which you are running on target?

Boot the board?

Quoted 1 line

what is target?

Quoted 8 lines
Quoted 5 lines

It is written in original report. Did you even read it?

Quoted 1 line

Which usecase is this issue occurring in?

Boot?

FWIW, what said above by Krzysztof is correct, there is no usecase, just booting the board.

12 days and nothing improved, right? if this was not dropped now, Alexey, can you send a revert? Author clearly approches stability with a very relaxed way and is just happy that patch was thrown over the wall and job is done.

Quoted 4 lines
Quoted 1 line

If you do not want to send revert, let me know, I will do it.

I am okay with sending revert, just trying to see if there is any interest in fixing this.

Any interest should have happened after 1 day of reporting linux-next breakage. It has been like what? 12 days?

That's typical throw the patch over the wall. Revert. Best regards,
Krzysztof

#17 lore raw

Re: [PATCH v7 7/8] serial: qcom-geni: Enable PM runtime for serial driver

Hi Alexey/Krzysztof,

Quoted 25 lines · Krzysztof Kozlowski
Quoted 24 lines · Alexey Klimov
Quoted 22 lines · Krzysztof Kozlowski
Quoted 6 lines · Alexey Klimov
Quoted 6 lines
Quoted 1 line

May i know what is testcase which you are running on target?

Boot the board?

Quoted 1 line

what is target?

Quoted 8 lines
Quoted 5 lines

It is written in original report. Did you even read it?

Quoted 1 line

Which usecase is this issue occurring in?

Boot?

FWIW, what said above by Krzysztof is correct, there is no usecase, just booting the board.

12 days and nothing improved, right? if this was not dropped now, Alexey, can you send a revert? Author clearly approches stability with a very relaxed way and is just happy that patch was thrown over the wall and job is done.

If you do not want to send revert, let me know, I will do it.

Quoted 7 lines
Quoted 2 lines

I am okay with sending revert, just trying to see if there is any interest in fixing this.

Any interest should have happened after 1 day of reporting linux-next breakage. It has been like what? 12 days?

That's typical throw the patch over the wall. Revert.

Really sorry for the delay.

I forgot to mention earlier that I’ve been actively investigating this issue across different platform SoCs. I was able to reproduce the problem on the SC7280.

Here’s a summary of the observed behavior:

The issue appears to originate from the qcom_geni_serial driver during device runtime resume. It results in a blocked IRQ thread, which in turn causes system instability.

The call trace suggests a deadlock scenario where the IRQ thread—responsible for handling wake-up events—becomes unresponsive while interacting with the pinctrl subsystem.

Specifically, the msm_pinmux_set_mux function attempts to invoke disable_irq, which is problematic when called from an IRQ thread context. Since the IRQ itself is a wake-up source, this leads to contention or a self-deadlock situation.

I have verified below diff and about to post it

drivers/tty/serial/qcom_geni_serial.c +11 -1
index c9c52c52a98d..cb3b4febd8c2 100644
@@ -1848,16 +1848,36 @@ static int __maybe_unused qcom_geni_serial_runtime_suspend(struct device *dev)
 {
        struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
        struct uart_port *uport = &port->uport;
+       int ret;
+
+       ret = geni_serial_resources_off(uport);
+       if(ret) {
+               if (device_may_wakeup(dev))
+                       disable_irq_wake(port->wakeup_irq);
+       }
 
-       return geni_serial_resources_off(uport);
+       if (device_may_wakeup(dev))
+               enable_irq_wake(port->wakeup_irq);
+
+       return ret;
 }
 
 static int __maybe_unused qcom_geni_serial_runtime_resume(struct 

device *dev)

 {
        struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
        struct uart_port *uport = &port->uport;

+ int ret;
+
+ if (device_may_wakeup(dev))
+ disable_irq_wake(port->wakeup_irq);

-       return geni_serial_resources_on(uport);
+       ret = geni_serial_resources_on(uport);
+       if(ret) {

+ if (device_may_wakeup(dev))
+ enable_irq_wake(port->wakeup_irq);
+ }
+
+ return ret;
}

Thanks,
Praveen Talari

Quoted 2 lines

Best regards,
Krzysztof

#18 lore raw

Re: [PATCH v7 7/8] serial: qcom-geni: Enable PM runtime for serial driver

Quoted 104 lines · Praveen Talari

Hi Alexey/Krzysztof,

Quoted 25 lines · Krzysztof Kozlowski
Quoted 24 lines · Alexey Klimov
Quoted 22 lines · Krzysztof Kozlowski
Quoted 6 lines · Alexey Klimov
Quoted 6 lines
Quoted 1 line

May i know what is testcase which you are running on target?

Boot the board?

Quoted 1 line

what is target?

Quoted 8 lines
Quoted 5 lines

It is written in original report. Did you even read it?

Quoted 1 line

Which usecase is this issue occurring in?

Boot?

FWIW, what said above by Krzysztof is correct, there is no usecase, just booting the board.

12 days and nothing improved, right? if this was not dropped now, Alexey, can you send a revert? Author clearly approches stability with a very relaxed way and is just happy that patch was thrown over the wall and job is done.

If you do not want to send revert, let me know, I will do it.

Quoted 7 lines
Quoted 2 lines

I am okay with sending revert, just trying to see if there is any interest in fixing this.

Any interest should have happened after 1 day of reporting linux-next breakage. It has been like what? 12 days?

That's typical throw the patch over the wall. Revert.

Really sorry for the delay.

I forgot to mention earlier that I’ve been actively investigating this issue across different platform SoCs. I was able to reproduce the problem on the SC7280.

Here’s a summary of the observed behavior:

The issue appears to originate from the qcom_geni_serial driver during device runtime resume. It results in a blocked IRQ thread, which in turn causes system instability.

The call trace suggests a deadlock scenario where the IRQ thread—responsible for handling wake-up events—becomes unresponsive while interacting with the pinctrl subsystem.

Specifically, the msm_pinmux_set_mux function attempts to invoke disable_irq, which is problematic when called from an IRQ thread context. Since the IRQ itself is a wake-up source, this leads to contention or a self-deadlock situation.

I have verified below diff and about to post it

drivers/tty/serial/qcom_geni_serial.c +22 -2
index c9c52c52a98d..cb3b4febd8c2 100644
@@ -1848,16 +1848,36 @@ static int __maybe_unused 
 qcom_geni_serial_runtime_suspend(struct device *dev)
  {
         struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
         struct uart_port *uport = &port->uport;
+       int ret;
+
+       ret = geni_serial_resources_off(uport);
+       if(ret) {
+               if (device_may_wakeup(dev))
+                       disable_irq_wake(port->wakeup_irq);
+       }
 
-       return geni_serial_resources_off(uport);
+       if (device_may_wakeup(dev))
+               enable_irq_wake(port->wakeup_irq);
+
+       return ret;
  }
 
  static int __maybe_unused qcom_geni_serial_runtime_resume(struct 
 device *dev)
  {
         struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
         struct uart_port *uport = &port->uport;
+       int ret;
+
+       if (device_may_wakeup(dev))
+               disable_irq_wake(port->wakeup_irq);
 
-       return geni_serial_resources_on(uport);
+       ret = geni_serial_resources_on(uport);
+       if(ret) {
+               if (device_may_wakeup(dev))
+                       enable_irq_wake(port->wakeup_irq);
+       }
+
+       return ret;
  }
Quoted 5 lines

Thanks,
Praveen Talari

Quoted 2 lines

Best regards,
Krzysztof

Don't forget to include a Fixes: tag for this change.

---
bod

#19 lore raw

Re: [PATCH v7 7/8] serial: qcom-geni: Enable PM runtime for serial driver

In reply to Praveen Talari
Quoted 53 lines · Praveen Talari

Hi Alexey/Krzysztof,

Quoted 25 lines · Krzysztof Kozlowski
Quoted 24 lines · Alexey Klimov
Quoted 22 lines · Krzysztof Kozlowski
Quoted 6 lines · Alexey Klimov
Quoted 6 lines
Quoted 1 line

May i know what is testcase which you are running on target?

Boot the board?

Quoted 1 line

what is target?

Quoted 8 lines
Quoted 5 lines

It is written in original report. Did you even read it?

Quoted 1 line

Which usecase is this issue occurring in?

Boot?

FWIW, what said above by Krzysztof is correct, there is no usecase, just booting the board.

12 days and nothing improved, right? if this was not dropped now, Alexey, can you send a revert? Author clearly approches stability with a very relaxed way and is just happy that patch was thrown over the wall and job is done.

If you do not want to send revert, let me know, I will do it.

Quoted 7 lines
Quoted 2 lines

I am okay with sending revert, just trying to see if there is any interest in fixing this.

Any interest should have happened after 1 day of reporting linux-next breakage. It has been like what? 12 days?

That's typical throw the patch over the wall. Revert.

Really sorry for the delay.

I forgot to mention earlier that I’ve been actively investigating this issue across different platform SoCs. I was able to reproduce the problem on the SC7280.

Here’s a summary of the observed behavior:

The issue appears to originate from the qcom_geni_serial driver during device runtime resume. It results in a blocked IRQ thread, which in turn causes system instability.

The call trace suggests a deadlock scenario where the IRQ thread—responsible for handling wake-up events—becomes unresponsive while interacting with the pinctrl subsystem.

Quoted 6 lines

Specifically, the msm_pinmux_set_mux function attempts to invoke disable_irq, which is problematic when called from an IRQ thread context. Since the IRQ itself is a wake-up source, this leads to contention or a self-deadlock situation.

I have verified below diff and about to post it

Was the original patch, that introduced the regression, also created by AI tools? Just trying to understand how we ended up with untested commit in -master.

Did you test the change below on real hardware?

Quoted 34 lines
drivers/tty/serial/qcom_geni_serial.c +15 -1
index c9c52c52a98d..cb3b4febd8c2 100644
@@ -1848,16 +1848,36 @@ static int __maybe_unused 
 qcom_geni_serial_runtime_suspend(struct device *dev)
  {
         struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
         struct uart_port *uport = &port->uport;
+       int ret;
+
+       ret = geni_serial_resources_off(uport);
+       if(ret) {
+               if (device_may_wakeup(dev))
+                       disable_irq_wake(port->wakeup_irq);
+       }
 
-       return geni_serial_resources_off(uport);
+       if (device_may_wakeup(dev))
+               enable_irq_wake(port->wakeup_irq);
+
+       return ret;
  }
 
  static int __maybe_unused qcom_geni_serial_runtime_resume(struct 
 device *dev)
  {
         struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
         struct uart_port *uport = &port->uport;
+       int ret;
+
+       if (device_may_wakeup(dev))
+               disable_irq_wake(port->wakeup_irq);

drivers/tty/serial/qcom_geni_serial.c static int __maybe_unused · line 1883

Quoted 10 lines
drivers/tty/serial/qcom_geni_serial.c +7 -1
 
-       return geni_serial_resources_on(uport);
+       ret = geni_serial_resources_on(uport);
+       if(ret) {
+               if (device_may_wakeup(dev))
+                       enable_irq_wake(port->wakeup_irq);
+       }
+
+       return ret;
  }

Best regards,
Alexey

#20 lore raw

Re: [PATCH v7 7/8] serial: qcom-geni: Enable PM runtime for serial driver

HI Alexey,

Quoted 59 lines · Alexey Klimov
Quoted 58 lines · Praveen Talari

Hi Alexey/Krzysztof,

Quoted 25 lines · Krzysztof Kozlowski
Quoted 24 lines · Alexey Klimov
Quoted 22 lines · Krzysztof Kozlowski
Quoted 6 lines · Alexey Klimov
Quoted 6 lines
Quoted 1 line

May i know what is testcase which you are running on target?

Boot the board?

Quoted 1 line

what is target?

Quoted 8 lines
Quoted 5 lines

It is written in original report. Did you even read it?

Quoted 1 line

Which usecase is this issue occurring in?

Boot?

FWIW, what said above by Krzysztof is correct, there is no usecase, just booting the board.

12 days and nothing improved, right? if this was not dropped now, Alexey, can you send a revert? Author clearly approches stability with a very relaxed way and is just happy that patch was thrown over the wall and job is done.

If you do not want to send revert, let me know, I will do it.

Quoted 7 lines
Quoted 2 lines

I am okay with sending revert, just trying to see if there is any interest in fixing this.

Any interest should have happened after 1 day of reporting linux-next breakage. It has been like what? 12 days?

That's typical throw the patch over the wall. Revert.

Really sorry for the delay.

I forgot to mention earlier that I’ve been actively investigating this issue across different platform SoCs. I was able to reproduce the problem on the SC7280.

Here’s a summary of the observed behavior:

The issue appears to originate from the qcom_geni_serial driver during device runtime resume. It results in a blocked IRQ thread, which in turn causes system instability.

The call trace suggests a deadlock scenario where the IRQ thread—responsible for handling wake-up events—becomes unresponsive while interacting with the pinctrl subsystem.

Specifically, the msm_pinmux_set_mux function attempts to invoke disable_irq, which is problematic when called from an IRQ thread context. Since the IRQ itself is a wake-up source, this leads to contention or a self-deadlock situation.

Quoted 6 lines
Quoted 1 line

I have verified below diff and about to post it

Was the original patch, that introduced the regression, also created by AI tools? Just trying to understand how we ended up with untested commit in -master.

Did you test the change below on real hardware?

Yes, i have tested on SA7280 SOC.

Thanks,
Praveen Talari

Quoted 50 lines
Quoted 36 lines
drivers/tty/serial/qcom_geni_serial.c +15 -1
index c9c52c52a98d..cb3b4febd8c2 100644
@@ -1848,16 +1848,36 @@ static int __maybe_unused
 qcom_geni_serial_runtime_suspend(struct device *dev)
   {
          struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
          struct uart_port *uport = &port->uport;
+       int ret;
+
+       ret = geni_serial_resources_off(uport);
+       if(ret) {
+               if (device_may_wakeup(dev))
+                       disable_irq_wake(port->wakeup_irq);
+       }
 
-       return geni_serial_resources_off(uport);
+       if (device_may_wakeup(dev))
+               enable_irq_wake(port->wakeup_irq);
+
+       return ret;
   }
 
   static int __maybe_unused qcom_geni_serial_runtime_resume(struct
 device *dev)
   {
          struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
          struct uart_port *uport = &port->uport;
+       int ret;
+
+       if (device_may_wakeup(dev))
+               disable_irq_wake(port->wakeup_irq);

drivers/tty/serial/qcom_geni_serial.c static int __maybe_unused · line 1883

Quoted 10 lines
drivers/tty/serial/qcom_geni_serial.c +7 -1
 
-       return geni_serial_resources_on(uport);
+       ret = geni_serial_resources_on(uport);
+       if(ret) {
+               if (device_may_wakeup(dev))
+                       enable_irq_wake(port->wakeup_irq);
+       }
+
+       return ret;
   }

Best regards,
Alexey

#21 lore raw

PATCH v7 8/8 serial: qcom-geni: Enable Serial on SA8255p Qualcomm platforms

In reply to Praveen Talari

The Qualcomm automotive SA8255p SoC relies on firmware to configure platform resources, including clocks, interconnects and TLMM. The driver requests resources operations over SCMI using power and performance protocols.

The SCMI power protocol enables or disables resources like clocks, interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs, such as resume/suspend, to control power states(on/off).

The SCMI performance protocol manages UART baud rates, with each baud rate represented by a performance level. The driver uses the dev_pm_opp_set_level() API to request the desired baud rate by specifying the performance level.

---
v5 -> v6
- added reviewed-by tag in commit
- used "unsigned int" instead of "unsigned long" in set_rate callback and geni_serial_set_level to avoid build warnings.

v3 -> v4
- renamed callback function names to resources_init, set_rate and power_state

---
 drivers/tty/serial/qcom_geni_serial.c | 156 +++++++++++++++++++++++---
 1 file changed, 140 insertions(+), 16 deletions(-)
drivers/tty/serial/qcom_geni_serial.c +140 -16
index aa08de659e34..32ec632fd080 100644
@@ -11,6 +11,7 @@
 #include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/pm_domain.h>
 #include <linux/pm_opp.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
@@ -99,10 +100,16 @@
 #define DMA_RX_BUF_SIZE		2048
 
 static DEFINE_IDA(port_ida);
+#define DOMAIN_IDX_POWER	0
+#define DOMAIN_IDX_PERF		1
 
 struct qcom_geni_device_data {
 	bool console;
 	enum geni_se_xfer_mode mode;
+	struct dev_pm_domain_attach_data pd_data;
+	int (*resources_init)(struct uart_port *uport);
+	int (*set_rate)(struct uart_port *uport, unsigned int baud);
+	int (*power_state)(struct uart_port *uport, bool state);
 };
 
 struct qcom_geni_private_data {
@@ -140,6 +147,7 @@ struct qcom_geni_serial_port {
 
 	struct qcom_geni_private_data private_data;
 	const struct qcom_geni_device_data *dev_data;
+	struct dev_pm_domain_list *pd_list;
 };
 
 static const struct uart_ops qcom_geni_console_pops;
@@ -1362,6 +1370,42 @@ static int geni_serial_set_rate(struct uart_port *uport, unsigned int baud)
 	return 0;
 }
 
+static int geni_serial_set_level(struct uart_port *uport, unsigned int baud)
+{
+	struct qcom_geni_serial_port *port = to_dev_port(uport);
+	struct device *perf_dev = port->pd_list->pd_devs[DOMAIN_IDX_PERF];
+
+	/*
+	 * The performance protocol sets UART communication
+	 * speeds by selecting different performance levels
+	 * through the OPP framework.
+	 *
+	 * Supported perf levels for baudrates in firmware are below
+	 * +---------------------+--------------------+
+	 * |  Perf level value   |  Baudrate values   |
+	 * +---------------------+--------------------+
+	 * |      300            |      300           |
+	 * |      1200           |      1200          |
+	 * |      2400           |      2400          |
+	 * |      4800           |      4800          |
+	 * |      9600           |      9600          |
+	 * |      19200          |      19200         |
+	 * |      38400          |      38400         |
+	 * |      57600          |      57600         |
+	 * |      115200         |      115200        |
+	 * |      230400         |      230400        |
+	 * |      460800         |      460800        |
+	 * |      921600         |      921600        |
+	 * |      2000000        |      2000000       |
+	 * |      3000000        |      3000000       |
+	 * |      3200000        |      3200000       |
+	 * |      4000000        |      4000000       |
+	 * +---------------------+--------------------+
+	 */
+
+	return dev_pm_opp_set_level(perf_dev, baud);
+}
+
 static void qcom_geni_serial_set_termios(struct uart_port *uport,
 					 struct ktermios *termios,
 					 const struct ktermios *old)
@@ -1380,7 +1424,7 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
 	/* baud rate */
 	baud = uart_get_baud_rate(uport, termios, old, 300, 8000000);
 
-	ret = geni_serial_set_rate(uport, baud);
+	ret = port->dev_data->set_rate(uport, baud);
 	if (ret)
 		return;
 
@@ -1667,8 +1711,27 @@ static int geni_serial_resources_off(struct uart_port *uport)
 	return 0;
 }
 
-static int geni_serial_resource_init(struct qcom_geni_serial_port *port)
+static int geni_serial_resource_state(struct uart_port *uport, bool power_on)
+{
+	return power_on ? geni_serial_resources_on(uport) : geni_serial_resources_off(uport);
+}
+
+static int geni_serial_pwr_init(struct uart_port *uport)
+{
+	struct qcom_geni_serial_port *port = to_dev_port(uport);
+	int ret;
+
+	ret = dev_pm_domain_attach_list(port->se.dev,
+					&port->dev_data->pd_data, &port->pd_list);
+	if (ret <= 0)
+		return -EINVAL;
+
+	return 0;
+}
+
+static int geni_serial_resource_init(struct uart_port *uport)
 {
+	struct qcom_geni_serial_port *port = to_dev_port(uport);
 	int ret;
 
 	port->se.clk = devm_clk_get(port->se.dev, "se");
@@ -1819,13 +1882,16 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 	port->se.dev = &pdev->dev;
 	port->se.wrapper = dev_get_drvdata(pdev->dev.parent);
 
-	ret = geni_serial_resource_init(port);
+	ret = port->dev_data->resources_init(uport);
 	if (ret)
 		return ret;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -EINVAL;
+	if (!res) {
+		ret = -EINVAL;
+		goto error;
+	}
+
 	uport->mapbase = res->start;
 
 	uport->rs485_config = qcom_geni_rs485_config;
@@ -1837,19 +1903,26 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 	if (!data->console) {
 		port->rx_buf = devm_kzalloc(uport->dev,
 					    DMA_RX_BUF_SIZE, GFP_KERNEL);
-		if (!port->rx_buf)
-			return -ENOMEM;
+		if (!port->rx_buf) {
+			ret = -ENOMEM;
+			goto error;
+		}
 	}
 
 	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;
+	if (!port->name) {
+		ret = -ENOMEM;
+		goto error;
+	}
 
 	irq = platform_get_irq(pdev, 0);
-	if (irq < 0)
-		return irq;
+	if (irq < 0) {
+		ret = irq;
+		goto error;
+	}
+
 	uport->irq = irq;
 	uport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_QCOM_GENI_CONSOLE);
 
@@ -1871,7 +1944,7 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 			IRQF_TRIGGER_HIGH, port->name, uport);
 	if (ret) {
 		dev_err(uport->dev, "Failed to get IRQ ret %d\n", ret);
-		return ret;
+		goto error;
 	}
 
 	ret = uart_get_rs485_mode(uport);
@@ -1882,7 +1955,7 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 
 	ret = uart_add_one_port(drv, uport);
 	if (ret)
-		return ret;
+		goto error;
 
 	if (port->wakeup_irq > 0) {
 		device_init_wakeup(&pdev->dev, true);
@@ -1892,11 +1965,15 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 			device_init_wakeup(&pdev->dev, false);
 			ida_free(&port_ida, uport->line);
 			uart_remove_one_port(drv, uport);
-			return ret;
+			goto error;
 		}
 	}
 
 	return 0;
+
+error:
+	dev_pm_domain_detach_list(port->pd_list);
+	return ret;
 }
 
 static void qcom_geni_serial_remove(struct platform_device *pdev)
@@ -1909,22 +1986,31 @@ static void qcom_geni_serial_remove(struct platform_device *pdev)
 	device_init_wakeup(&pdev->dev, false);
 	ida_free(&port_ida, uport->line);
 	uart_remove_one_port(drv, &port->uport);
+	dev_pm_domain_detach_list(port->pd_list);
 }
 
 static int __maybe_unused qcom_geni_serial_runtime_suspend(struct device *dev)
 {
 	struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
 	struct uart_port *uport = &port->uport;
+	int ret = 0;
+
+	if (port->dev_data->power_state)
+		ret = port->dev_data->power_state(uport, false);
 
-	return geni_serial_resources_off(uport);
+	return ret;
 }
 
 static int __maybe_unused qcom_geni_serial_runtime_resume(struct device *dev)
 {
 	struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
 	struct uart_port *uport = &port->uport;
+	int ret = 0;
 
-	return geni_serial_resources_on(uport);
+	if (port->dev_data->power_state)
+		ret = port->dev_data->power_state(uport, true);
+
+	return ret;
 }
 
 static int qcom_geni_serial_suspend(struct device *dev)
@@ -1962,11 +2048,41 @@ static int qcom_geni_serial_resume(struct device *dev)
 static const struct qcom_geni_device_data qcom_geni_console_data = {
 	.console = true,
 	.mode = GENI_SE_FIFO,
+	.resources_init = geni_serial_resource_init,
+	.set_rate = geni_serial_set_rate,
+	.power_state = geni_serial_resource_state,
 };
 
 static const struct qcom_geni_device_data qcom_geni_uart_data = {
 	.console = false,
 	.mode = GENI_SE_DMA,
+	.resources_init = geni_serial_resource_init,
+	.set_rate = geni_serial_set_rate,
+	.power_state = geni_serial_resource_state,
+};
+
+static const struct qcom_geni_device_data sa8255p_qcom_geni_console_data = {
+	.console = true,
+	.mode = GENI_SE_FIFO,
+	.pd_data = {
+		.pd_flags = PD_FLAG_DEV_LINK_ON,
+		.pd_names = (const char*[]) { "power", "perf" },
+		.num_pd_names = 2,
+	},
+	.resources_init = geni_serial_pwr_init,
+	.set_rate = geni_serial_set_level,
+};
+
+static const struct qcom_geni_device_data sa8255p_qcom_geni_uart_data = {
+	.console = false,
+	.mode = GENI_SE_DMA,
+	.pd_data = {
+		.pd_flags = PD_FLAG_DEV_LINK_ON,
+		.pd_names = (const char*[]) { "power", "perf" },
+		.num_pd_names = 2,
+	},
+	.resources_init = geni_serial_pwr_init,
+	.set_rate = geni_serial_set_level,
 };
 
 static const struct dev_pm_ops qcom_geni_serial_pm_ops = {
@@ -1980,10 +2096,18 @@ static const struct of_device_id qcom_geni_serial_match_table[] = {
 		.compatible = "qcom,geni-debug-uart",
 		.data = &qcom_geni_console_data,
 	},
+	{
+		.compatible = "qcom,sa8255p-geni-debug-uart",
+		.data = &sa8255p_qcom_geni_console_data,
+	},
 	{
 		.compatible = "qcom,geni-uart",
 		.data = &qcom_geni_uart_data,
 	},
+	{
+		.compatible = "qcom,sa8255p-geni-uart",
+		.data = &sa8255p_qcom_geni_uart_data,
+	},
 	{}
 };
 MODULE_DEVICE_TABLE(of, qcom_geni_serial_match_table);
Signature · 1 line
2.17.1
#22 lore raw
In reply to Praveen Talari
Quoted 14 lines · Praveen Talari

The Qualcomm automotive SA8255p SoC relies on firmware to configure platform resources, including clocks, interconnects and TLMM. The device drivers request resources operations over SCMI using power and performance protocols.

The SCMI power protocol enables or disables resources like clocks, interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs, such as resume/suspend, to control power states(on/off).

The SCMI performance protocol manages UART baud rates, with each baud rate represented by a performance level. Drivers use the dev_pm_opp_set_level() API to request the desired baud rate by specifying the performance level.

Quoted 5 lines

The QUP drivers are SCMI clients, with clocks, interconnects, pinctrl and power-domains abstracted by a SCMI server.

The serial driver has a dependency on the dev_pm_opp_set_level() function, which is applied in the OPP tree's linux-next branch.

Where is the changelog with lore links?

Best regards,
Krzysztof