From: Linkui Xiao <xiaolinkui@126.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: maxime.chevallier@bootlin.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, mcoquelin.stm32@gmail.com,
alexandre.torgue@foss.st.com, netdev@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Linkui Xiao <xiaolinkui@kylinos.cn>,
stable@vger.kernel.org
Subject: Re: [PATCH net] net: stmmac: ethtool: validate TX coalesce before reprogramming RX
Date: Fri, 18 Sep 2026 15:03:18 +0800 [thread overview]
Message-ID: <cf1a87f3-acd5-4959-bd42-b88b25f48311@126.com> (raw)
In-Reply-To: <15b8cbc2-f3ca-4845-9a93-7fff6c5aede6@lunn.ch>
Hi Andrew,
On 2026/9/17 23:05, Andrew Lunn wrote:
> On Thu, Sep 17, 2026 at 09:12:35PM +0800, Linkui Xiao wrote:
>> From: Linkui Xiao <xiaolinkui@kylinos.cn>
>>
>> __stmmac_set_coalesce() applies the RX part of the request first and
>> only afterwards checks the TX parameters. The RX path already calls
>> stmmac_rx_watchdog() and stores rx_riwt[] and rx_coal_frames[], so when
>> the TX check rejects the request the driver returns -EINVAL after having
>> silently changed the hardware. A following ethtool -c then reports the
>> new RX values even though the command failed.
>>
>> This became easy to hit once the per-queue interface was added.
>> __stmmac_get_coalesce() reports tx-usecs and tx-frames as 0 for a queue
>> index that is RX-only, and ethtool applies per-queue coalesce by reading
>> the current values first and sending them straight back. The next set is
>> therefore guaranteed to trip the test for both TX fields being zero,
>> right after the RX watchdog has been reprogrammed.
>>
>> Move both TX checks in front of the RX block so a request is either
>> applied completely or rejected without touching the device.
>>
>> Fixes: db2f2842e6f5 ("net: stmmac: add per-queue TX & RX coalesce ethtool support")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Linkui Xiao <xiaolinkui@kylinos.cn>
>> ---
>> .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 21 ++++++++++++-------
>> 1 file changed, 13 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
>> index 154cc0c7623d..325db062f72a 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
>> @@ -850,6 +850,19 @@ static int __stmmac_set_coalesce(struct net_device *dev,
>> else if (queue >= max_cnt)
>> return -EINVAL;
>>
>> + /* Check the TX parameters before anything is applied: the RX part
>> + * below already writes to the hardware, so rejecting the request
>> + * afterwards would leave the device with only half of the settings
>> + * the caller asked for while reporting a failure.
>> + */
>
> Why such a verbose comment? Look at the rest of the code and make your
> comments similar in verbosity.
Thanks for the review. You're right, the comment is far more verbose
than the surrounding code, and the rationale is already covered by the
commit message.
I'll shorten it to a single line in v2 and send it shortly.
Thanks,
Linkui
>
> Andrew
>
> ---
> pw-bot: cr
>
prev parent reply other threads:[~2026-09-18 7:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 13:12 Linkui Xiao
2026-09-17 15:05 ` Andrew Lunn
2026-09-18 7:03 ` Linkui Xiao [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=cf1a87f3-acd5-4959-bd42-b88b25f48311@126.com \
--to=xiaolinkui@126.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=xiaolinkui@kylinos.cn \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®