๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21225

Re: [PATCH net] niu: write back TXC_INT_MASK in niu_txc_set_imask()

#21225
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 18:37
120 lines
12149 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The patch makes niu_txc_set_imask() actually write
  TXC_INT_MASK.
- [Low] niu_init_hw() calls niu_txc_set_imask(np, 0) without first
  clearing any TXC_INT_STAT bits already latched for that port.

--

niu: write back TXC_INT_MASK in niu_txc_set_imask()

This patch adds the missing nw64(TXC_INT_MASK, val) to niu_txc_set_imask()
so the per-port TXC interrupt mask that it computes is actually written to
hardware. The only caller, niu_init_hw(), passes imask=0, so after this
change all of the port's TXC error sources are unmasked.

> diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
> index c74a97fe54641..b2da560edd827 100644
> --- a/drivers/net/ethernet/sun/niu.c
> +++ b/drivers/net/ethernet/sun/niu.c
> @@ -4650,6 +4650,7 @@ static void niu_txc_set_imask(struct niu *np, u64 imask)
>  	val = nr64(TXC_INT_MASK);
>  	val &= ~TXC_INT_MASK_VAL(np->port);
>  	val |= (imask << TXC_INT_MASK_VAL_SHIFT(np->port));
> +	nw64(TXC_INT_MASK, val);

[Severity: Medium]
With this write in place, niu_init_hw() now unmasks all six TXC sources
for the port:

niu_init_hw()
    niu_txc_set_imask(np, 0);

Those sources are SF_CE, SF_UE, RO_CE, RO_UE, REORDER_ERR and PKTASM_DEAD.
niu.h defines TXC_INT_STAT and its per-port bits, but nothing in niu.c
reads, decodes or acknowledges that register.

What happens when one of these sources fires? The only route seems to be
the SYS_ERR_STAT_TXC summary on LDN_DEVICE_ERROR. niu_ldg_init() assigns
that LDN only for port 0. From there:

niu_interrupt()
  niu_slowpath_interrupt()
    if (v2 & 0x0210)
        niu_device_error()     <- logs SYS_ERR_STAT, always returns -ENODEV
    if (err)
        niu_enable_interrupts(np, 0);
  if (err)
      goto out;                <- skips niu_ldg_rearm()

Could one TXC event on any of the four ports turn off all of port 0's
interrupts (RX/TX DMA, MAC, MIF) with no reset or recovery scheduled? That
would also include correctable ECC events (SF_CE/RO_CE) that the hardware
has already corrected.

TXC_INT_STAT is never cleared. Could the same bit fire again as soon as
port 0 is re-armed on the next open?

Before this patch these sources had no effect. The commit message describes
the change as restoring intended behaviour and says it was not tested on
Neptune hardware. It also has a Fixes: tag, which makes it a stable
candidate.

Would it be better to keep the correctable bits masked, for example:

    niu_txc_set_imask(np, TXC_INT_MASK_SF_CE | TXC_INT_MASK_RO_CE);

or to add a TXC_INT_STAT handler that acknowledges events and treats CE as
non-fatal?

[Severity: Low]
Should this port's TXC_INT_STAT be cleared before the mask is opened up?
Elsewhere in this driver, status is cleared before the mask is programmed:

niu_init_zcp() {
    ...
	nw64(ZCP_INT_STAT, ZCP_INT_STAT_ALL);
	(void) nr64(ZCP_INT_STAT);
	nw64(ZCP_INT_MASK, ZCP_INT_MASK_ALL);
    ...
}

niu_init_ipp() {
    ...
	(void) nr64_ipp(IPP_INT_STAT);

	nw64_ipp(IPP_MSK, ~IPP_MSK_ALL);
    ...
}

The TXC mask was never written before this patch. Any TXC status latched
earlier would still be present, whether from previous operation, an
earlier kernel (kexec or module reload), or OBP/firmware use.

Could that stale status assert LDN_DEVICE_ERROR as soon as port 0's LDGs
are armed in niu_open(), and so lead into the niu_device_error() path
described above?

Also, niu_stop_hw() never re-masks the TXC sources, and
niu_txc_enable_port(np, 0) is not called anywhere. IPP and ZCP are not
re-masked on stop either. However, after ifdown of ports 1-3, their TXC
sources would stay armed in the shared register. The latched status is
never acknowledged, and the device error LDN is bound only to port 0.
Could a downed port then keep disrupting port 0?

>  	niu_unlock_parent(np, flags);
>  }

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119170623.1519909-1-irogers%40google.com
Technical Details
Message-ID: <179545903032.3135.12672409534586940438@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369672-linux-kernel-netdev=dewy.ru
References: <20261119170623.1519909-1-irogers@google.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369672-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] niu: write back TXC_INT_MASK in niu_txc_set_imask()
Date: Mon, 23 Nov 2026 18:37:10 +0000
Organization: Usenet Network
Message-ID: <179545903032.3135.12672409534586940438@kernel.org>
References: <20261119170623.1519909-1-irogers@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3954553"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:HTfFSIlczg0iPVzaPcqOzMydqI4= sha256:xVJPSFH+P+KTnGV4oFpl93D733gNzI8XN7McevgZc1Y=
	sha1:jckOuI8XvlX9WnzKjgExJ/7ixvY= sha256:aUvQQ3ZfRkKl7/pvaxmLEUxRdTZWnYAsjZfybc+3pWY=
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 31D61125DC1; Mon, 23 Nov 2026 21:37:39 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 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] 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 GuzicGGzIUFw;
	Mon, 23 Nov 2026 21:37:35 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369672-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id DE77C125DB9; Mon, 23 Nov 2026 21:37:24 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 0ECC434865; Mon, 23 Nov 2026 18:37:20 +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=1795459038;
	b=kD7Vs6VQ2G56EFbkjLHUtREFZJKnBnAn+RLrp6GFetfbrmtA6NiK+VIsUcdUUlJPHQNt
	 y5H8WI4wIugDEfinxBFjH0FC6iBBFruVQNcWzWsJQ//AjuZG/MaPTkWotuOVm1HWzEyYz
	 gvp/bnY+9ZP2diag57XtNajeN4IrovbdHkXKnhi2UuS6cgllROMInoXxg7TRCtqebLq3S
	 GOmA0Ip6Vu/RXIYDaB2dws6CiGZYehGdG4ISSzSrlj7wvcncPd9NpEKXUA3EhRURSIh7t
	 Ae5t72SN9ltpOMPY5OLBJilODmq0L6nLfxYyabEN7R3PgVVtqYmG5TzMW/+Ikjf6IWw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795459038;
	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=8xyeEM4ykdwPci+rPjGEp+xC7znx8Sw7brM4o0kn09Y=;
	b=L9mB9ZjuX/TDhw2Wh8ii/B2Bx8WEchImACuteNAdNsWpBgVSy4V6lfnGtstyCSZ3G0MD
	 2EgWbfo/McaePY+4qfL3fX2qOwVBZU8q4yP8jZYG02h9mXPRIgOZb6qbWMqd78e8PXqhq
	 ZD1JF2UmIauijOOLGTYarVmtbX+drasAv4FlX5M/klVvuApaWhP3WdfGItQwmddqxIQW+
	 bnUyPIiXaUJ9abwmIgg8T/I8OZC3JPdAd4BrCs/Xq8Thns9rAc4dmtZ14N5d5pQTPKtD+
	 ZiM41SE7mglEy39Z2gwGYrlhwAZAWJx052lis2v+nmJlcCpLVFHcvhh9QxkieysRRtw==
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=WqaRTNLx;
	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 1E346606A31F;
	Mon, 23 Nov 2026 18:37:18 +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=WqaRTNLx
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=1795459032;
	b=a7HV63dSgLPxmo0UbcOAiCOnlIt2GEOp9sQ6/hqabzIaZ90+PJ0NmoeZIxRElM2dLmrx
	 TBqVcDtCLGPkkUXlNykFioUslIYEnP2Sb9FMDhAprvAA7vOYb9amWD5ACOVWNJdoE/ML9
	 6uaksHYi2f7B0d7TqOvZj0jFcrwABr2gXBMOiI3LElPWzfcXbAw5rTPZ5/MZECTaDowa5
	 nYp7jgfSLRFfwCqHz3R1kUgEjmPm9ApQb07I6O5ysv4joJzHURolNGe/uMafPnlrQY1hd
	 PSjKKpoOxKQWUAMz+4RFQZ23T7W9uehW820M5VWDx5B5WvXfEv0mlOlkyC67TrxHGjg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795459032;
	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=8xyeEM4ykdwPci+rPjGEp+xC7znx8Sw7brM4o0kn09Y=;
	b=Kta7enilfpF7+qK1xSuMjMkZsXUmzZ9zWKOnz5EoLGmU4lom27+guWJ4IfOz38WAPcsX
	 CUkk3HWTCcSNL7CkpAOEF/i1CHKXD4Eij3uzAPNbPjiSOvk5PouYK5WMURvmcBmFBI2K0
	 W1Gz/bA37DSiPuqx6QrDJgFaIgLZ4gBl/4GkiFPhxFKxHrhlcsnpe2UijqAmO4akdGqR8
	 xFKgA/5LBdOoMvuJJIe3GWhiuF6VP0BtiG9YZ3q6w+Lh+VRBpB82L8MMcdEohlxM+ghEN
	 o71sY042Ocj6P70//NzLc0UwpcvkcU6Ku/op5o3Ot/xxy/t6SlgWFLftPow7opeenBQ==
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=WqaRTNLx;
	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 3B876606A32A;
	Mon, 23 Nov 2026 18:37:11 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0F5C1F000D1;
	Mon, 23 Nov 2026 18:37:10 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795459031;
	bh=8xyeEM4ykdwPci+rPjGEp+xC7znx8Sw7brM4o0kn09Y=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=WqaRTNLxXdPxfWEE53ro5YiW3Xrin2037Hek9KJvPxyI81FdWDqWVsV5fr7zcJWAs
	 tG5GoRuYM5Xmp2OpnaYNODHF6ED3f5vX21V6tEVRflNrV5w6ymqj7cI9U0mCuwrlmm
	 3+sx3BIGh7SHwQoK1kA2PL5X9TRA7/6c3pMNL9+rvKxgAlZVe2qPF8uR5wJyBFiPtW
	 WPuYZZonDttW0Xl4MsWwzduw9+cRbNq1XsGnnZ8isj0wg9D6RKx1kjCpNHE8bqOpEE
	 c39h2Tf9Io+KfIURiWBNn4un4bcT56uNjoYuQwnG0WLSBYkSacUIlMYHgvz+1/x6y8
	 fRz3ll/fBZs5A==
X-Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
 linux-kernel@vger.kernel.org, llvm@lists.linux.dev, elkin@google.com
X-In-Reply-To: <20261119170623.1519909-1-irogers@google.com>
X-sashiko-severity: Medium
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