Devicetree
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Ambarella CV75: 8250_dw UART
@ 2026-08-13 10:35 Long Zhao via B4 Relay
  2026-08-13 10:35 ` [PATCH v3 1/2] dt-bindings: serial: snps-dw-apb-uart: add ambarella,cv75-uart Long Zhao via B4 Relay
  2026-08-13 10:35 ` [PATCH v3 2/2] serial: 8250_dw: add Ambarella CV75 quirks Long Zhao via B4 Relay
  0 siblings, 2 replies; 5+ messages in thread
From: Long Zhao via B4 Relay @ 2026-08-13 10:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Linus Walleij, Ilpo Järvinen, Andy Shevchenko
  Cc: linux-kernel, linux-serial, devicetree, Long Zhao

This is part C of a 3-part CV75 v3 split:

  A: bindings + RCT/CCU clocks + SoC/EVK DT + MAINTAINERS
  B: pinctrl + PL061 GPIO variant
  C: 8250_dw UART quirks  (this series)

Depends on series A:
https://lore.kernel.org/r/20260813-cv75-v3-a-v3-0-cfdd20b1b4dd@ambarella.com

Depends on series B:
https://lore.kernel.org/r/20260813-cv75-v3-b-v3-0-1d82e18da09b@ambarella.com

Link to v2:
https://lore.kernel.org/r/20260806-longzhao-upstream-cv75-v2-v2-0-6b09707c5fe9@ambarella.com

Summary:
- document ambarella,cv75-uart on snps,dw-apb-uart
- Ambarella quirks in 8250_dw

Changes since v2 (C scope):
- drop custom Ambarella UART driver; reuse 8250_dw (Linus)

Verified on CV75 with A+B+C.

Signed-off-by: Long Zhao <longzhao@ambarella.com>

---
Long Zhao (2):
      dt-bindings: serial: snps-dw-apb-uart: add ambarella,cv75-uart
      serial: 8250_dw: add Ambarella CV75 quirks

 .../bindings/serial/snps-dw-apb-uart.yaml          |  1 +
 drivers/tty/serial/8250/8250_dw.c                  | 30 ++++++++++++++++++++++
 2 files changed, 31 insertions(+)
---
base-commit: 378c935cabe003ef440c1c79302a1f8ed7913778
change-id: 20260813-cv75-v3-c-d98a97d0f9f1

Best regards,
--  
Long Zhao <longzhao@ambarella.com>



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

* [PATCH v3 1/2] dt-bindings: serial: snps-dw-apb-uart: add ambarella,cv75-uart
  2026-08-13 10:35 [PATCH v3 0/2] Ambarella CV75: 8250_dw UART Long Zhao via B4 Relay
@ 2026-08-13 10:35 ` Long Zhao via B4 Relay
  2026-08-13 10:42   ` sashiko-bot
  2026-08-13 10:35 ` [PATCH v3 2/2] serial: 8250_dw: add Ambarella CV75 quirks Long Zhao via B4 Relay
  1 sibling, 1 reply; 5+ messages in thread
From: Long Zhao via B4 Relay @ 2026-08-13 10:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Linus Walleij, Ilpo Järvinen, Andy Shevchenko
  Cc: linux-kernel, linux-serial, devicetree, Long Zhao

From: Long Zhao <longzhao@ambarella.com>

Add the Ambarella CV75 compatible string to the Synopsys DW APB UART
binding.

Signed-off-by: Long Zhao <longzhao@ambarella.com>
---
 Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml b/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
index 49f51b002879..cec5c679f1a9 100644
--- a/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
+++ b/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
@@ -51,6 +51,7 @@ properties:
           - const: renesas,rzn1-uart
       - items:
           - enum:
+              - ambarella,cv75-uart
               - anlogic,dr1v90-uart
               - brcm,bcm11351-dw-apb-uart
               - brcm,bcm21664-dw-apb-uart

-- 
2.34.1



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

* [PATCH v3 2/2] serial: 8250_dw: add Ambarella CV75 quirks
  2026-08-13 10:35 [PATCH v3 0/2] Ambarella CV75: 8250_dw UART Long Zhao via B4 Relay
  2026-08-13 10:35 ` [PATCH v3 1/2] dt-bindings: serial: snps-dw-apb-uart: add ambarella,cv75-uart Long Zhao via B4 Relay
@ 2026-08-13 10:35 ` Long Zhao via B4 Relay
  2026-08-13 10:46   ` sashiko-bot
  1 sibling, 1 reply; 5+ messages in thread
From: Long Zhao via B4 Relay @ 2026-08-13 10:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Linus Walleij, Ilpo Järvinen, Andy Shevchenko
  Cc: linux-kernel, linux-serial, devicetree, Long Zhao

From: Long Zhao <longzhao@ambarella.com>

Add CV75 platform data with an ETOI IER mask and skip-set-rate so the
DesignWare 8250 driver can drive the Ambarella UART for console use.

Signed-off-by: Long Zhao <longzhao@ambarella.com>
---
 drivers/tty/serial/8250/8250_dw.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 5fba913f3301..e8aa592924d4 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -43,6 +43,9 @@
 #define RZN1_UART_xDMACR_8_WORD_BURST	(2 << 1)
 #define RZN1_UART_xDMACR_BLK_SZ(x)	((x) << 3)
 
+/* Ambarella specific register fields */
+#define AMBARELLA_UART_IER_ETOI		BIT(5)
+
 /* Quirks */
 #define DW_UART_QUIRK_OCTEON		BIT(0)
 #define DW_UART_QUIRK_ARMADA_38X	BIT(1)
@@ -60,6 +63,7 @@
 
 struct dw8250_platform_data {
 	u8 usr_reg;
+	u8 ier_mask;
 	u32 cpr_value;
 	unsigned int quirks;
 };
@@ -572,6 +576,23 @@ static void dw8250_prepare_rx_dma(struct uart_8250_port *p)
 	dw8250_writel_ext(up, RZN1_UART_RDMACR, val);
 }
 
+static int dw8250_ier_mask_startup(struct uart_port *p)
+{
+	struct dw8250_data *d = to_dw8250_data(p->private_data);
+	struct uart_8250_port *up = up_to_u8250p(p);
+	int ret;
+
+	ret = serial8250_do_startup(p);
+	if (ret)
+		return ret;
+
+	/* Keep variant-specific bits in the shadow across subsequent updates. */
+	up->ier |= d->pdata->ier_mask;
+	serial_port_out(p, UART_IER, up->ier);
+
+	return 0;
+}
+
 static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data)
 {
 	unsigned int quirks = data->pdata->quirks;
@@ -606,6 +627,8 @@ static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data)
 		p->serial_in = dw8250_serial_in32;
 		data->uart_16550_compatible = true;
 	}
+	if (data->pdata->ier_mask)
+		p->startup = dw8250_ier_mask_startup;
 }
 
 static void dw8250_reset_control_assert(void *data)
@@ -879,6 +902,12 @@ static const struct dw8250_platform_data dw8250_intc10ee = {
 	.quirks = DW_UART_QUIRK_IER_KICK,
 };
 
+static const struct dw8250_platform_data dw8250_ambarella_cv75_data = {
+	.usr_reg = DW_UART_USR,
+	.ier_mask = AMBARELLA_UART_IER_ETOI,
+	.quirks = DW_UART_QUIRK_SKIP_SET_RATE,
+};
+
 static const struct dw8250_platform_data dw8250_ultrarisc_dp1000_data = {
 	.usr_reg = DW_UART_USR,
 	.cpr_value = FIELD_PREP_CONST(DW_UART_CPR_ABP_DATA_WIDTH, 2) |
@@ -889,6 +918,7 @@ static const struct dw8250_platform_data dw8250_ultrarisc_dp1000_data = {
 };
 
 static const struct of_device_id dw8250_of_match[] = {
+	{ .compatible = "ambarella,cv75-uart", .data = &dw8250_ambarella_cv75_data },
 	{ .compatible = "snps,dw-apb-uart", .data = &dw8250_dw_apb },
 	{ .compatible = "cavium,octeon-3860-uart", .data = &dw8250_octeon_3860_data },
 	{ .compatible = "marvell,armada-38x-uart", .data = &dw8250_armada_38x_data },

-- 
2.34.1



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

* Re: [PATCH v3 1/2] dt-bindings: serial: snps-dw-apb-uart: add ambarella,cv75-uart
  2026-08-13 10:35 ` [PATCH v3 1/2] dt-bindings: serial: snps-dw-apb-uart: add ambarella,cv75-uart Long Zhao via B4 Relay
@ 2026-08-13 10:42   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-08-13 10:42 UTC (permalink / raw)
  To: Long Zhao; +Cc: conor+dt, devicetree, robh

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The 'ambarella' vendor prefix is newly introduced in this binding but is not documented in vendor-prefixes.yaml.
--

--- Patch [1]: [PATCH v3 1/2] dt-bindings: serial: snps-dw-apb-uart: add ambarella,cv75-uart ---
commit 09140ea99754febddffd7c03dfcd93c0fffe28fb
Author: Long Zhao <longzhao@ambarella.com>

dt-bindings: serial: snps-dw-apb-uart: add ambarella,cv75-uart

Add the Ambarella CV75 compatible string to the Synopsys DW APB UART
binding.

> diff --git a/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml b/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
> index 49f51b0028795..cec5c679f1a9d 100644
> --- a/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
> +++ b/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
> @@ -51,6 +51,7 @@ properties:
>            - const: renesas,rzn1-uart
>        - items:
>            - enum:
> +              - ambarella,cv75-uart

[Severity: Low]
Has the ambarella vendor prefix added to properties:compatible been formally
documented in vendor-prefixes.yaml?

If this prefix is omitted from vendor-prefixes.yaml, evaluating this schema
with dt-schema will encounter the undocumented ambarella prefix. This will
cause make dt_binding_check to report a schema validation warning or error
during the build.

>                - anlogic,dr1v90-uart
>                - brcm,bcm11351-dw-apb-uart
>                - brcm,bcm21664-dw-apb-uart

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260813-cv75-v3-c-v3-0-9352b3fd6026@ambarella.com?part=1

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

* Re: [PATCH v3 2/2] serial: 8250_dw: add Ambarella CV75 quirks
  2026-08-13 10:35 ` [PATCH v3 2/2] serial: 8250_dw: add Ambarella CV75 quirks Long Zhao via B4 Relay
@ 2026-08-13 10:46   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-08-13 10:46 UTC (permalink / raw)
  To: Long Zhao; +Cc: robh, devicetree, conor+dt

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] Premature and lockless write to UART_IER in dw8250_ier_mask_startup defeats interrupt deferral and introduces race conditions.

Pre-existing issues:
- [High] Runtime PM is enabled after port registration, violating subsystem PM initialization rules and causing circular wait conditions.
--

--- Patch [2]: [PATCH v3 2/2] serial: 8250_dw: add Ambarella CV75 quirks ---
commit 6e65f0f86d7deb4c1cfc42c64f909eb5435425fe
Author: Long Zhao <longzhao@ambarella.com>

serial: 8250_dw: add Ambarella CV75 quirks

Add CV75 platform data with an ETOI IER mask and skip-set-rate so the
DesignWare 8250 driver can drive the Ambarella UART for console use.

> diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
> index 5fba913f33010..e8aa592924d4d 100644
> --- a/drivers/tty/serial/8250/8250_dw.c
> +++ b/drivers/tty/serial/8250/8250_dw.c
[ ... ]
> @@ -572,6 +576,23 @@ static void dw8250_prepare_rx_dma(struct uart_8250_port *p)
>  	dw8250_writel_ext(up, RZN1_UART_RDMACR, val);
>  }
>  
> +static int dw8250_ier_mask_startup(struct uart_port *p)
> +{
> +	struct dw8250_data *d = to_dw8250_data(p->private_data);
> +	struct uart_8250_port *up = up_to_u8250p(p);
> +	int ret;
> +
> +	ret = serial8250_do_startup(p);
> +	if (ret)
> +		return ret;
> +
> +	/* Keep variant-specific bits in the shadow across subsequent updates. */
> +	up->ier |= d->pdata->ier_mask;
> +	serial_port_out(p, UART_IER, up->ier);

[Severity: High]
Does this lockless write to UART_IER introduce a race condition against the
serial console? 

The 8250 core explicitly defers enabling hardware RX interrupts until
set_termios() configures the FIFOs to prevent swamping the interrupt handler.
Writing to UART_IER here defeats that safety mechanism.

Furthermore, if a printk occurs concurrently, serial8250_console_write()
executes on another CPU and performs a read-modify-restore on UART_IER. This
lockless write races with the console driver, which can permanently drop the
ier_mask bits or cause unpredictable hardware behavior.

Should this write be protected by p->lock, and potentially deferred until
the FIFOs are configured?

> +
> +	return 0;
> +}
> +

[Severity: High]
This isn't a bug introduced by this patch, but there is a pre-existing
issue in dw8250_probe() regarding runtime PM initialization:

drivers/tty/serial/8250/8250_dw.c:dw8250_probe() {
    ...
	data->data.line = serial8250_register_8250_port(up);
	if (data->data.line < 0)
		return data->data.line;

	platform_set_drvdata(pdev, data);

	pm_runtime_enable(dev);
    ...
}

Does registering the port before enabling runtime PM cause circular wait
conditions during device probe?

Registration synchronously invokes the driver's pm callback (dw8250_do_pm)
via uart_add_one_port(). The dw8250_do_pm() callback unconditionally calls
pm_runtime_get_sync(port->dev). 

As documented in the TTY subsystem guidelines, invoking runtime PM APIs from
callbacks before pm_runtime_enable() is called leads to circular dependencies,
hanging the probe function indefinitely because the runtime PM infrastructure
is not yet initialized for the device.

Should pm_runtime_enable(dev) be called before serial8250_register_8250_port()?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260813-cv75-v3-c-v3-0-9352b3fd6026@ambarella.com?part=2

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

end of thread, other threads:[~2026-08-13 10:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13 10:35 [PATCH v3 0/2] Ambarella CV75: 8250_dw UART Long Zhao via B4 Relay
2026-08-13 10:35 ` [PATCH v3 1/2] dt-bindings: serial: snps-dw-apb-uart: add ambarella,cv75-uart Long Zhao via B4 Relay
2026-08-13 10:42   ` sashiko-bot
2026-08-13 10:35 ` [PATCH v3 2/2] serial: 8250_dw: add Ambarella CV75 quirks Long Zhao via B4 Relay
2026-08-13 10:46   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox