🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26536

Re: [PATCH net-next v13 10/15] net: ethernet: oa_tc6: APIs to customize CONFIG0 settings

#26536
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 17:46
161 lines
14164 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] oa_tc6_tx_credit_threshold_set()
  (drivers/net/ethernet/oa_tc6/oa_tc6_main.c) only checks that the…
- [Low] include/linux/oa_tc6.h adds OA_TC6_CONFIG0_TXCTHRESH_8 (2) and
  OA_TC6_CONFIG0_TXCTHRESH_16 (3) to the OA_TC6_CONFIG0_* block.
- [Low] oa_tc6_tx_credit_threshold_set() reads, modifies and writes back
  CONFIG0 using two separate spi_ctrl_lock critical sections…

--

net: ethernet: oa_tc6: APIs to customize CONFIG0 settings

This adds oa_tc6_tx_credit_threshold_set(), which lets a vendor driver
program the TXCTHRESH field of CONFIG0. It also adds the
OA_TC6_CONFIG_RX_CUT_THROUGH quirk flag. When the flag is set and the
MAC-PHY reports cut-through capability, oa_tc6_init() sets RXCTE before
the SYNC bit.

> diff --git a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c
> index e9e7b4ad3b2c1..a60bdb857fa4d 100644
> --- a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c
> +++ b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c

[ ... ]

> @@ -1629,6 +1649,39 @@ int oa_tc6_zero_align_receive_frame_enable(struct oa_tc6 *tc6)
>  }
>  EXPORT_SYMBOL_GPL(oa_tc6_zero_align_receive_frame_enable);
>  
> +/**
> + * oa_tc6_tx_credit_threshold_set - function to set the minimum number of
> + * free transmit credits needed before the MAC-PHY asserts the interrupt.
> + * @tc6: oa_tc6 struct.
> + * @thresh: transmit credit threshold field value, e.g.
> + *	OA_TC6_CONFIG0_TXCTHRESH_8.
> + *
> + * Calling from probe is recommended to avoid concurrent CONFIG0 updates
> + * during the read-modify-write operation.
> + *
> + * Return: 0 on success, -EINVAL if @thresh does not fit the TXCTHRESH
> + * field, otherwise a negative error code from the register access.
> + */
> +int oa_tc6_tx_credit_threshold_set(struct oa_tc6 *tc6, u8 thresh)
> +{
> +	u32 regval;
> +	int ret;
> +
> +	if (thresh > OA_TC6_CONFIG0_TXCTHRESH_16)
> +		return -EINVAL;

[Severity: Low]
This only checks that thresh fits in the 2-bit field. Should it also be
checked against the device's transmit credit capacity?

The framework already reads the initial credit count in
oa_tc6_update_buffer_status_from_register():

	tc6->tx_credits = FIELD_GET(OA_TC6_BUFFER_STATUS_TX_CREDITS_AVAILABLE,
				    value);

oa_tc6_macphy_threaded_irq() stops once the cached credits reach zero.
It then waits for the MAC-PHY interrupt, which TXCTHRESH controls, to
start again:

	while (tc6->int_flag ||
	       (tc6->waiting_tx_skb && tc6->tx_credits)) {

Suppose a vendor driver picked a threshold larger than its TX buffer
depth. Could the interrupt then never fire, so TX stalls on a link with
no RX traffic?

The only caller in the series is s2500_init(), which passes
OA_TC6_CONFIG0_TXCTHRESH_8. Nothing suggests the S2500 has fewer than 8
credits, so this may only matter for future users. Would it be worth
mentioning this in the kernel-doc?

> +
> +	ret = oa_tc6_read_register(tc6, OA_TC6_REG_CONFIG0, &regval);
> +	if (ret)
> +		return ret;
> +
> +	/* Set Transmit Credit Threshold */
> +	regval &= ~OA_TC6_CONFIG0_TXCTHRESH_MASK;
> +	regval |= FIELD_PREP(OA_TC6_CONFIG0_TXCTHRESH_MASK, thresh);
> +
> +	return oa_tc6_write_register(tc6, OA_TC6_REG_CONFIG0, regval);

[Severity: Low]
The read and the write-back each take spi_ctrl_lock on their own, so
this read-modify-write of CONFIG0 is not atomic.

oa_tc6_set_hwtstamp_settings() also does a read-modify-write of CONFIG0.
It runs from the threaded IRQ handler when a SIOCSHWTSTAMP request is
pending:

	ret = oa_tc6_read_registers(tc6, OA_TC6_REG_CONFIG0, regs,
				    ARRAY_SIZE(regs));
	...
	ret = oa_tc6_write_register(tc6, OA_TC6_REG_CONFIG0, cfg0);

What happens if this exported helper is called while the netdev is
live? Could the two sequences interleave and lose either the TXCTHRESH
update or the FTSE/FTSS timestamp bits?

This can't happen in the series today. The only caller, s2500_init(),
runs from s2500_probe() before register_netdev(), and the kernel-doc
recommends calling from probe.

That rule is only a recommendation in a public API, though. Would it
make sense to state it as a requirement, or to serialize CONFIG0
updates?

> +}
> +EXPORT_SYMBOL_GPL(oa_tc6_tx_credit_threshold_set);

[ ... ]

> diff --git a/include/linux/oa_tc6.h b/include/linux/oa_tc6.h
> index f34ed8218a7c4..35b536741d016 100644
> --- a/include/linux/oa_tc6.h
> +++ b/include/linux/oa_tc6.h

[ ... ]

> @@ -30,6 +31,10 @@
>  #define OA_TC6_REG_CONFIG0			0x0004
>  #define OA_TC6_CONFIG0_SYNC			BIT(15)
>  #define OA_TC6_CONFIG0_ZARFE_ENABLE		BIT(12)
> +#define OA_TC6_CONFIG0_TXCTHRESH_MASK		GENMASK(11, 10)
> +#define OA_TC6_CONFIG0_TXCTHRESH_8		2	/* 0b10: >=8 credits */
> +#define OA_TC6_CONFIG0_TXCTHRESH_16		3	/* 0b11: >=16 credits */

[Severity: Low]
This isn't a bug, but these are unshifted field values. Every other
OA_TC6_CONFIG0_* macro here is a BIT(n) register mask, and callers OR
those straight into CONFIG0. For example,
oa_tc6_zero_align_receive_frame_enable() does:

	regval |= OA_TC6_CONFIG0_ZARFE_ENABLE;

If a vendor driver did the same with OA_TC6_CONFIG0_TXCTHRESH_16, it
would set CONFIG0[1:0], the block payload size field, instead of
TXCTHRESH[11:10].

Would a different name, such as OA_TC6_TXCTHRESH_8_CREDITS, or
pre-shifted values built with FIELD_PREP_CONST() avoid this confusion?

Encodings 0 (one or more credits) and 1 (four or more credits) also
have no named constants.

> +#define OA_TC6_CONFIG0_RXCTE			BIT(8)
>  #define OA_TC6_CONFIG0_FTSE_ENABLE		BIT(7)

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-s2500-mac-phy-support-v13-0-a2908fad2693%40onsemi.com
Technical Details
Message-ID: <179631999370.3146.17088902225862685906@kernel.org>
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376801-linux-kernel-netdev=dewy.ru
References: <20261202-s2500-mac-phy-support-v13-10-a2908fad2693@onsemi.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376801-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v13 10/15] net: ethernet: oa_tc6: APIs to
 customize CONFIG0 settings
Date: Thu, 03 Dec 2026 17:46:33 +0000
Organization: Usenet Network
Message-ID: <179631999370.3146.17088902225862685906@kernel.org>
References: <20261202-s2500-mac-phy-support-v13-10-a2908fad2693@onsemi.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2557690"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:cJ7wPqU2m1CTVodlVOcOSMWLejs= sha256:g5oHU1TBlfX4mWjtOAGzoNyU7oDQdFPF6D01FrHnJUA=
	sha1:ZWxA1WumCorSsWm8yyoD48uqVac= sha256:uyo1hJ5GJdpVkM948jfmEBESXxJ4grsbrY9T/MazOTM=
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 03A7F1179F9; Thu,  3 Dec 2026 20:46:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.74
X-Spam-Status: No, score=-3.74 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.24, 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 wIIPfTnB-gn2;
	Thu,  3 Dec 2026 20:46:50 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-376801-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 288E01179D4; Thu,  3 Dec 2026 20:46:42 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 72433601B30; Thu,  3 Dec 2026 17:46:41 +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=1796319996;
	b=mo27NJ1C7vap9j1LBqNhCghU1mIFZ6MAKlneYWkn7/7Jle8c7E/WjrTaZGvzgwgzoi10
	 RLlhrsXfn0bFyXPRv0MOLIfzit45FRa78JTHI/cF3ixo4yVoHEE/VEasN2xtgLI7uUQjv
	 BrXnFUpH9H11W9lVnyM9j3gwLLQywlMzVWNA4+Amuy2Vqg6pj7Gw+mU+0RNV7FLuMKZ/V
	 jdZa/lAMmfFJyxQxbfs25b42pYywZ1E/9Gfb74TC3ihh2uKf/zFBkBJR7xTIqbLLKRTyU
	 /0kEbtycMBJCRynMdK8PT0MpBHcbzdjpP0WhfNQXgBq09vn2qMdiVFGWCWf36Octo2Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796319996;
	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=8I7W01X0AE6ahyx4llSbQHBtu40349GoqZVzAJAEzJw=;
	b=pnOpfNMUn4yaSK28r4mK+pXAKyNEUetAc8PMYWX24bIRvDgqgYwZxpucPTNaHC01F8gV
	 whtLKsPzcfETNlFI+5FaFk/SkzQV1tRJDV6XPegwxybDysOG1wctRoJjweMjY6ptEZtf6
	 RR59bVe3bnyGl/Da5N5EajqlxHcOhWGK7jZyqurZ8AJuF6SIDidDo5KwjWVBGiKpPPHmr
	 GOgGc+IJRiDmtzgOW/QSOvtwMjb92eXTjpsfp5W4k/YtxJjsbtjUp1O1MKK3S/vzNpH0O
	 kzLMPJQxdlNxrcP0mr1j6/dCXrFQIGNyOqVEKeCLig1R/dkrhtxZENHkXxIdgUYKB7A==
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=W73tAmOz;
	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 8C3A5606A69D;
	Thu,  3 Dec 2026 17:46:36 +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=W73tAmOz
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=1796319995;
	b=ookOSJNoQfVMY+VbGmckG8t9BRODitT+/sjsSwUIeO2V5zKwXmqN+m3AreJ2BbkuR8zg
	 q1iR2XBfiWjmG+WhaU7KgiwxrMDBqxv3ure6TglR00DI7I91eppBmJTYaQObQ1aCwFQ1M
	 Oe0Ncp/QHwJK19JN2G/zAlu8wQf6r/LHsjQ5arKgYn5xQT6JDksM9ZtUM8PJrWUQshMT1
	 YYBmj6wO9IGmgviuJAPZ2GUhhPXHBUKpyGJzuXrv/MwHDEqQfp676Y561nH8EitXEi/UT
	 QMSW64b4wlePipA9ir44XBatSxOBZySt9HJ8HZ4tWQJFEeiATcFrOc/JeAHviFNF2OA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796319995;
	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=8I7W01X0AE6ahyx4llSbQHBtu40349GoqZVzAJAEzJw=;
	b=dtdpOV3sudEuCd00RwcH156PvwwpH6ZD7IMgImEnnfAv+TATvH3B4uP/vscW8XJgstnn
	 N1npwLE/KrJ/e0d3J6HFDLJ0ZjNGuPN2ZrPLQ/jtl8Pnpjetm4C+g3IEdEZXjhJ/V5TYA
	 fuN+N4pjytKhv64IjZDRxPgCrWqNw1euw2xKUQub2p5VpKfu1c6R0BSmrw5EVg/efDr6i
	 3O3KmD2JMyilY5dyLc6JfbnhVKFz/91jxGb+MAXnlR3DwtC/jv2bIvX56Q+gI+wRSgRcO
	 GuMrmtD//phcz4D/QaPub8E/cSUxEgasRv057YFfH0xJhvY3BQrcsLByuR4O5fKWVkw==
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=W73tAmOz;
	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 ABE75606A32F;
	Thu,  3 Dec 2026 17:46:35 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28E1D1F00893;
	Thu,  3 Dec 2026 17:46:34 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796319995;
	bh=8I7W01X0AE6ahyx4llSbQHBtu40349GoqZVzAJAEzJw=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=W73tAmOzfUfhPewMaDb2fzmCyrRS0DjLiiQrhXbfwZfsGqHxh5CkNHkhsOIHDvGtw
	 UfCUvxlitBg8P+2jWvF+30MHGV3ZeiJxbfpFCSOtaY14uDoILKdkMVZRb63icUK0Md
	 Us4BjPsJRoDQmpP2WdSuUmgR7QjCQdlUaBfZdNPb71CrdEOgoTiypbjrGKo5QQLM+r
	 Goj7zIy07neMIgxthlgWOHZonAxIHzV6FxJzhB71WH7ZWokvBmtL3qZRzWOUsMjeaa
	 oERMOEneEdT+ndUySYakz6UPCkhCFoijxasZhdBh9jGiuQ2Cz38IJYwTpQJ6vTsZH8
	 A0kXD3MYaDFEw==
X-Cc: andrew+netdev@lunn.ch, davem@davemloft.net, kuba@kernel.org,
 pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
 parthiban.veerasooran@microchip.com, horms@kernel.org, corbet@lwn.net,
 skhan@linuxfoundation.org, rdunlap@infradead.org, richardcochran@gmail.com,
 andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
 edumazet@kernel.org, piergiorgio.beruto@gmail.com, willemb@google.com,
 netdev@vger.kernel.org, devicetree@vger.kernel.org,
 linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
 jerry.ray@microchip.com, ciprian.regus@analog.com
X-In-Reply-To: <20261202-s2500-mac-phy-support-v13-10-a2908fad2693@onsemi.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