๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #16194

Re: [PATCH net-next v8 04/11] r8152: fix flow control for RTL8156/RTL8156B/RTL8157/RTL8159

#16194
From: netdev-bot+sashiko
Date: Sat, 14 Nov 2026 09:28
133 lines
12346 bytes
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
Technical Details
Message-ID: <179464851357.2199510.561254259862841249@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363154-linux-kernel-netdev=dewy.ru
References: <20261110032416.16968-5-nic_swsd@realtek.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363154-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179464851357.2199510.561254259862841249@kernel.org>
References: <20261110032416.16968-5-nic_swsd@realtek.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1540403"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:HLEtCF13E7Wn5YZjEy2ScZWA7k0= sha256:rZi5gT5damwbHrX1dIayTL5+56KYg2lUKEz4MMnTI9s=
	sha1:E++uymOyCO2IxFaeu75JI592gDc= sha256:qzYfoWXfHv5QLVXRu4+swa07C1bVwScGCPuDK3hYAlw=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 3A2B1114791; Sat, 14 Nov 2026 12:29:08 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id L_ATrYDZCxOw;
	Sat, 14 Nov 2026 12:29:04 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-363154-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 630D211478C; Sat, 14 Nov 2026 12:28:55 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id EF77630FEE; Sat, 14 Nov 2026 09:28:49 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794648515;
	b=VqUK9r+ts7L7zgmPd9nCY0cXbzmA65URE8kcS4aCXcti+ZS4DvgnZGqBdryqHTngn7yp
	 9dCsw3ImP8IQXdpWzh4Rhjf9FaPP4rGoROM3iB4zmP3esJB7tZ3r0oCSCo3xnHB6wHkL8
	 D/8sq1zcpQvP2eyE8Czd7F3IPtI5t/SD6JdgB05GM57JTDQBYdyM8/XUs8HKorsmWo5LR
	 T+4gz86cKoXyjQGcDEoPLNnONJAfUJXN+Y5n6iWwTMbUgTNv1InSF8n71gIaOgpeVGygd
	 CZtWvyKw16SecKFsD9yu9DK2mnWiFFLCsCO0sobNtSGwFdwUoltFNp8mC957BxD6O6g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794648515;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=XzGBh5VLGXS5UYk8trLl/RJIVJzn2v5v54FjYp8yTLw=;
	b=l/45dh4e7DHGvQH87dr/sNBwxbL99BGew76dsKkgC5r9OEMOh4L03lht9ahPpFj+LlzR
	 pog5bKQI5KbIWAa6qJVIt6kLGDe5UaYobWHu1fBLW/TuBtRNBBlmufZICIwifuj/IUugt
	 N60Ws/4NA/kEeq24kh76eSXt7WFoZYPXGfDF0KdQh9pyoH2H1upXGPT1Q0OEJXc4v6uGM
	 cfx00lppSRzKV51/W69vVKBXY2+wEYNxM+VAx0Q3G39pbvgL5wK3TxN6Qs9VRV9PgQsyW
	 tzf9ZoIbOtbE3uxcfsefGB34jvli2t5RcP7LYfAUoMpOKe+fUi7rX6jqDa4P62Ao6/g==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Hz02Jqla;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 9CE2E606A8BA;
	Sat, 14 Nov 2026 09:28:35 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Hz02Jqla
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794648514;
	b=gkrdyJK9NBOfZ2M22JNCe8JrbW3FKFI+wD4nNdTM7J0z8Ynp1wc00mxvUu7oVj3locgq
	 b4TWsR+v5z0KahqBou11u4M1gAi2XpuzWqvBtZKO4P3Rc2ZGhex3Afl87UIfOH313MqlM
	 sBxIBykWeNmhkbcPKjYvqQVSbwXYx3TJcj+JH8gP6b/LKFxNFs9ty4E0oorGJuczxDriu
	 OUxN+0tkvwwtx0dRMmj/3KQ6SE8/qzqX1mp/JEal35Kd1k7vIzIljyOWqlqJH7SbVu0tZ
	 BadQHh6wuwWrqjiwbPrFw9D4dMRlbHIlgXRPBV5jEOJO4X4JysaZaAFhUXz9Dia/T5w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794648514;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=XzGBh5VLGXS5UYk8trLl/RJIVJzn2v5v54FjYp8yTLw=;
	b=ymPGwJj/wFtVPOaTLwD6W5MixFDYtJOkBOMsXk8F67MQoaHEf7mtACnNPaiBs6+S1s1x
	 bumKjcKpjFanLP0EU+P451cbmOMUvFnZxNQp/dUo563UmoKLsjcLt+HvVBqRhP4gXU6y4
	 rs81DS4iPx+grg7wYlMivjWkUK8hYxq20MA5Jvk574rOm1QmKCl4r6eRvGkOrfk72Okez
	 vOib05OLko6DQafV3daXpYLvnpPGFCguJwMRq127aiWytQhHhWWsO2bLLeoTC0FqP73c4
	 PFg+IUm8yledKJd0OeWNw3iMU7kxdJSBVCZVMzIZ3uzteN8IDpKxKXu5vjD5m2xn1MQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Hz02Jqla;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCEC2606A8AD;
	Sat, 14 Nov 2026 09:28:34 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id F248D1F000C5;
	Sat, 14 Nov 2026 09:28:33 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794648514;
	bh=XzGBh5VLGXS5UYk8trLl/RJIVJzn2v5v54FjYp8yTLw=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Hz02JqlaunqiwXHQIlugOQFde5c3ekg5KgAVPDURJ+wUjobSudEaF+QFBl2s46E+v
	 9zNDXVNpvHi2+1JcRZB38iT5mTfbmOa1lnMnMx8ipDg1lpu98bsRhshwvdB2A664Nv
	 N3V+GJanugNF980VeTEAOMyx4+iFV05ospXjp4HfVe3UN2P1Ags8bQrMC7Pz4QltKn
	 gCglF08BzxslJOoZ/LtlzDIrgQhsrQW86J4gcW+zlxTanromxZhOaNsDJhJpZxmQ4d
	 gR6MhcNHRUY0bngFMHpbtcvJJ1gOMOtcLziplEJZ/sh8170eQJCSUkeFKJ4YZfnDaq
	 ZeHVsYTOCckzQ==
X-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
X-In-Reply-To: <20261110032416.16968-5-nic_swsd@realtek.com>
X-sashiko-severity: Low
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list