Linux USB
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: hsu.chih.kai@realtek.com
Cc: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org,
	nic_swsd@realtek.com, linux-kernel@vger.kernel.org,
	linux-usb@vger.kernel.org, edumazet@google.com, bjorn@mork.no,
	pabeni@redhat.com, andrew+netdev@lunn.ch, mail@birger-koblitz.de
Subject: Re: [PATCH net-next v8 04/11] r8152: fix flow control for RTL8156/RTL8156B/RTL8157/RTL8159
Date: Sat, 14 Nov 2026 09:28:33 +0000	[thread overview]
Message-ID: <179464851357.2199510.561254259862841249@kernel.org> (raw)
In-Reply-To: <20261110032416.16968-5-nic_swsd@realtek.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] On RTL8157/RTL8159 (RTL_VER_16/RTL_VER_17), rtl_fc_pause_pkt_en()
  in drivers/net/usb/r8152.c clears SLOT_EN in PLA_RCR (line 6006).
- [Low] In rtl_fc_pause_pkt_en() (drivers/net/usb/r8152.c, lines
  6023-6031), the fallback branch of the new VER_16/17 speed decode has…

--

r8152: fix flow control for RTL8156/RTL8156B/RTL8157/RTL8159

This commit moves the per-chip flow control setup into a new helper,
rtl_fc_pause_pkt_en(). It adds the missing FC timer and
FLOW_CTRL_PATCH_OPT setup for RTL8156A (VER_10/11). For RTL8157/RTL8159
(VER_16/17) it programs a pause packet limit from rtl8156_enable(),
using the new PLA_PAUSE_LIMIT register and a count that depends on the
link speed.

> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index 1517753f843ef..6f55aed4709e1 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c

[ ... ]

> @@ -5961,6 +5966,103 @@ static void r8152b_enter_oob(struct r8152 *tp)
>  			   RCR_APM | RCR_AM | RCR_AB);
>  }
>  
> +static void rtl_fc_pause_pkt_en(struct r8152 *tp, u16 speed)
> +{

[ ... ]

> +	case RTL_VER_16:
> +	case RTL_VER_17:
> +		ocp_word_clr_bits(tp, MCU_TYPE_PLA, PLA_RCR, SLOT_EN);

[Severity: Low]
This isn't a functional bug as far as I can tell, but is clearing
SLOT_EN on RTL_VER_16/RTL_VER_17 intended to be part of this fix? For
these chips the commit message only says:

    VER_16/17: limit pause packets with the new PLA_PAUSE_LIMIT register
    instead of the FW patch.

Before this patch, the only place that cleared SLOT_EN was r8156_init(),
and only for RTL_VER_12..RTL_VER_15. So this changes the receive config
on RTL8157/RTL8159 for the first time.

This helper is called from rtl8156_enable() for these chips. That means
the clear now runs on every enable: set_carrier(), rtl8152_change_mtu(),
rtl8152_set_coalesce() and rtl8152_post_reset(). It also runs on the
"Unknown link speed" path.

Could the commit message mention the PLA_RCR change and say why the
pause frame fix needs it? The code is the same at the end of the series,
where rtl8157_enable() calls the helper for RTL_VER_16 and
RTL_VER_17_QFN68/QFN100.

> +
> +		num_pause_pkts = 0xa;
> +		ratio = 10000;
> +
> +		if (speed & _10bps) {
> +			ratio /= 10;
> +		} else if (speed & _100bps) {
> +			ratio /= 100;
> +		} else if (speed & _1000bps) {
> +			ratio /= 1000;
> +		} else if (speed & _2500bps) {
> +			ratio /= 2500;
> +		} else if (speed & _5000bps) {
> +			ratio /= 5000;
> +		} else if (speed & _10000bps) {
> +			ratio /= 10000;
> +		} else {
> +			/* No rate bit is set, e.g. a 500 or 1250 Mbit/s
> +			 * sub-rate, which the driver does not advertise.
> +			 * Disarm the limit.
> +			 */
> +			dev_err(&tp->intf->dev, "Unknown link speed\n");
> +			ocp_word_clr_bits(tp, MCU_TYPE_PLA, PLA_PAUSE_LIMIT,
> +					  PAUSE_LIMIT_EN);
> +			break;
> +		}

[Severity: Low]
Is this comment accurate? The driver already defines rate bits for both
of these speeds in enum rtl_register_content:

	_1250bps	= BIT(9),
	_500bps		= BIT(8),

Also, rtl8156_enable() already tests speed & _500bps for VER_10/11. At
500 or 1250 Mbit/s a rate bit is set. The if/else chain just doesn't
check for it.

The case where no rate bit is set looks like link down instead.
rtl8156_enable() passes the raw rtl8152_get_speed() value here without
checking LINK_STATUS.

rtl8152_change_mtu(), rtl8152_set_coalesce() and rtl8152_post_reset()
decide whether to call rtl_ops.enable() using only netif_carrier_ok().
The link change work updates that state later:

rtl8152_change_mtu() {
    ...
	if (netif_carrier_ok(dev)) {
		...
		tp->rtl_ops.disable(tp);
		tp->rtl_ops.enable(tp);
    ...
}

Suppose the cable is unplugged and the MTU or coalesce settings change
before set_carrier() runs. Wouldn't this print "Unknown link speed" with
dev_err() for what is really a link down?

The next real link up reprograms PLA_PAUSE_LIMIT, so only the comment
and the log message are affected. The code is unchanged at the end of
the series, where rtl8157_enable() calls rtl_fc_pause_pkt_en() the same
way.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261110032416.16968-1-nic_swsd%40realtek.com

  parent reply	other threads:[~2026-11-14  9:28 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10  3:24 [PATCH net-next v8 00/11] r8152: refactor and extend RTL8157/8159 support Chih Kai Hsu
2026-11-10  3:24 ` [PATCH net-next v8 01/11] r8152: fix RTL8156/RTL8156B/RTL8157/RTL8159 up and down settings Chih Kai Hsu
2026-11-11  3:25   ` sashiko-bot
2026-11-14  9:28   ` netdev-bot+sashiko
2026-11-10  3:24 ` [PATCH net-next v8 02/11] r8152: add rtl8157_unload() for RTL8157 and RTL8159 Chih Kai Hsu
2026-11-11  3:25   ` sashiko-bot
2026-11-14  9:28   ` netdev-bot+sashiko
2026-11-10  3:24 ` [PATCH net-next v8 03/11] r8152: add rtl8157_change_mtu() " Chih Kai Hsu
2026-11-11  3:25   ` sashiko-bot
2026-11-14  9:28   ` netdev-bot+sashiko
2026-11-10  3:24 ` [PATCH net-next v8 04/11] r8152: fix flow control for RTL8156/RTL8156B/RTL8157/RTL8159 Chih Kai Hsu
2026-11-11  3:25   ` sashiko-bot
2026-11-14  9:28   ` netdev-bot+sashiko [this message]
2026-11-10  3:24 ` [PATCH net-next v8 05/11] r8152: split r8156_init by generation and factor out wait_autoload_done Chih Kai Hsu
2026-11-11  3:25   ` sashiko-bot
2026-11-10  3:24 ` [PATCH net-next v8 06/11] r8152: add new init writes for RTL8156/8156B/8157/8159 Chih Kai Hsu
2026-11-11  3:25   ` sashiko-bot
2026-11-14  9:28   ` netdev-bot+sashiko
2026-11-10  3:24 ` [PATCH net-next v8 07/11] r8152: split RTL_VER_17 into QFN68 and QFN100 package variants Chih Kai Hsu
2026-11-11  3:25   ` sashiko-bot
2026-11-14  9:28   ` netdev-bot+sashiko
2026-11-10  3:24 ` [PATCH net-next v8 08/11] r8152: split rtl8156_enable/up/down into per-generation functions Chih Kai Hsu
2026-11-11  3:25   ` sashiko-bot
2026-11-10  3:24 ` [PATCH net-next v8 09/11] r8152: split r8157_hw_phy_cfg into RTL8157 and RTL8159 variants Chih Kai Hsu
2026-11-11  3:25   ` sashiko-bot
2026-11-14  9:28   ` netdev-bot+sashiko
2026-11-10  3:24 ` [PATCH net-next v8 10/11] r8152: add TGPHY register access for RTL8157 and RTL8159 Chih Kai Hsu
2026-11-11  3:25   ` sashiko-bot
2026-11-14  9:28   ` netdev-bot+sashiko
2026-11-10  3:24 ` [PATCH net-next v8 11/11] r8152: enable UPS for RTL8157 and RTL8159 QFN68 Chih Kai Hsu
2026-11-11  3:25   ` sashiko-bot
2026-11-14  9:28   ` netdev-bot+sashiko
2026-11-10  5:04 ` [PATCH net-next v8 00/11] r8152: refactor and extend RTL8157/8159 support netdev-bot+sinfo

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=179464851357.2199510.561254259862841249@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=bjorn@mork.no \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hsu.chih.kai@realtek.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mail@birger-koblitz.de \
    --cc=netdev@vger.kernel.org \
    --cc=nic_swsd@realtek.com \
    --cc=pabeni@redhat.com \
    /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