Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: Selvamani.Rajagopal@onsemi.com
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
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	[thread overview]
Message-ID: <179631999370.3146.17088902225862685906@kernel.org> (raw)
In-Reply-To: <20261202-s2500-mac-phy-support-v13-10-a2908fad2693@onsemi.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] 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

  reply	other threads:[~2026-12-03 17:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 17:37 [PATCH net-next v13 00/15] Support for onsemi's S2500 10BASE-T1S MAC-PHY Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 01/15] dt-bindings: net: add onsemi's S2500 Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 02/15] Documentation: networking: Add timestamp related APIs to OA TC6 framework Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 03/15] net: ethernet: oa_tc6: Move oa_tc6.c to its own directory Selvamani Rajagopal via B4 Relay
2026-12-03 17:46   ` netdev-bot+sashiko
2026-12-02 17:37 ` [PATCH net-next v13 04/15] net: ethernet: oa_tc6: Move constant definitions to header file Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 05/15] net: ethernet: microchip: lan865x: Depends on PTP_1588_CLOCK_OPTIONAL Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 06/15] net: ethernet: adi: adin1140: " Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 07/15] net: ethernet: oa_tc6: Support for hardware timestamp Selvamani Rajagopal via B4 Relay
2026-12-03 17:46   ` netdev-bot+sashiko
2026-12-02 17:37 ` [PATCH net-next v13 08/15] net: ethernet: oa_tc6: Drop frames if footer has FD bit set Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 09/15] net: ethernet: oa_tc6: Support for vendor specific MMS Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 10/15] net: ethernet: oa_tc6: APIs to customize CONFIG0 settings Selvamani Rajagopal via B4 Relay
2026-12-03 17:46   ` netdev-bot+sashiko [this message]
2026-12-02 17:37 ` [PATCH net-next v13 11/15] net: phy: ncn26000: Enable enhanced noise immunity Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 12/15] net: phy: Add helper to modify only the PHY loopback bit Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 13/15] net: phy: ncn26000: Support for onsemi's S2500 internal phy Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 14/15] net: phy: dp83867: Use genphy_loopback_no_speed() Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 15/15] net: ethernet: onsemi: s2500: Add driver support for S2500 Selvamani Rajagopal via B4 Relay
2026-12-03 17:46   ` netdev-bot+sashiko

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=179631999370.3146.17088902225862685906@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=Selvamani.Rajagopal@onsemi.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=ciprian.regus@analog.com \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@kernel.org \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=jerry.ray@microchip.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=parthiban.veerasooran@microchip.com \
    --cc=piergiorgio.beruto@gmail.com \
    --cc=rdunlap@infradead.org \
    --cc=richardcochran@gmail.com \
    --cc=robh@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=willemb@google.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