From: sashiko-bot@kernel.org
To: "Jonas Jelonek" <jelonek.jonas@gmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH net-next v6 4/4] net: pse-pd: realtek-pse-mcu: add UART transport
Date: Fri, 10 Jul 2026 19:41:59 +0000 [thread overview]
Message-ID: <20260710194200.690FB1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260709194125.2784507-5-jelonek.jonas@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Delayed MCU responses can silently desynchronize the UART protocol and cause the driver to accept stale data for new requests, leading to silent data corruption (e.g., reporting incorrect port status).
--
--- Patch [4]: [PATCH net-next v6 4/4] net: pse-pd: realtek-pse-mcu: add UART transport ---
commit 4b8238c08610aa670e6bef20fc86bbd99d379d19
Author: Jonas Jelonek <jelonek.jonas@gmail.com>
net: pse-pd: realtek-pse-mcu: add UART transport
This commit adds a serdev (UART) transport for the Realtek PSE MCU core.
It registers the MCU as a serdev device and provides send/receive
callbacks to exchange 12-byte frames asynchronously.
> diff --git a/drivers/net/pse-pd/realtek-pse-mcu-uart.c b/drivers/net/pse-pd/realtek-pse-mcu-uart.c
> new file mode 100644
> --- /dev/null
> +++ b/drivers/net/pse-pd/realtek-pse-mcu-uart.c
[ ... ]
> +static int rtpse_mcu_uart_send(struct rtpse_mcu_ctrl *pse, const struct rtpse_mcu_msg *req)
> +{
> + struct rtpse_mcu_uart *ctx = to_rtpse_mcu_uart(pse);
> + int written;
> +
> + /* clear any leftover rx state before transmitting */
> + scoped_guard(spinlock_irqsave, &ctx->rx_lock) {
> + reinit_completion(&ctx->rx_done);
> + ctx->rx_len = 0;
> + }
[Severity: Medium]
Can a delayed MCU response silently desynchronize the UART protocol here and
cause the driver to accept stale data for new requests?
If a previous request takes longer than RTPSE_MCU_UART_RX_TIMEOUT, it times
out and the operation fails. When the next request is sent, this block
clears ctx->rx_len.
If the delayed 12-byte response from the first request then arrives, it
will fill the newly cleared rx_buf and complete the receive wait. Because
the core driver hardcodes seq_num to 0xff for all messages:
drivers/net/pse-pd/realtek-pse-mcu-core.c:rtpse_mcu_msg_init() {
memset(msg, 0xff, sizeof(*msg));
msg->opcode = opcode;
}
it cannot distinguish the stale response from the new one if the opcodes
match. Would it be safer to flush the serdev buffers before transmitting,
or to implement a rolling sequence number in the core to prevent silent
data corruption?
> +
> + written = serdev_device_write(ctx->serdev, (const u8 *)req, sizeof(*req),
> + RTPSE_MCU_UART_TX_TIMEOUT);
> + if (written < 0)
> + return written;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260709194125.2784507-1-jelonek.jonas@gmail.com?part=4
prev parent reply other threads:[~2026-07-10 19:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 19:41 [PATCH net-next v6 0/4] net: pse-pd: add Realtek PSE MCU support Jonas Jelonek
2026-07-09 19:41 ` [PATCH net-next v6 1/4] dt-bindings: net: pse-pd: add bindings for Realtek PSE MCU Jonas Jelonek
2026-07-10 15:10 ` Conor Dooley
2026-07-09 19:41 ` [PATCH net-next v6 2/4] net: pse-pd: add Realtek PSE MCU core Jonas Jelonek
2026-07-09 19:41 ` [PATCH net-next v6 3/4] net: pse-pd: realtek-pse-mcu: add I2C transport Jonas Jelonek
2026-07-09 19:41 ` [PATCH net-next v6 4/4] net: pse-pd: realtek-pse-mcu: add UART transport Jonas Jelonek
2026-07-10 19:41 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260710194200.690FB1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jelonek.jonas@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.