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

From: netdev-bot+sashiko

Date: Thu Dec 03 2026 - 12:46:52 EST


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