Netdev List
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: lawson.fidelio@gmail.com
Cc: woojung.huh@microchip.com, UNGLinuxDriver@microchip.com,
	andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	marex@denx.de, maxime.chevallier@bootlin.com, horms@kernel.org,
	hkallweit1@gmail.com, linux@armlinux.org.uk,
	Tristram.Ha@microchip.com, Woojung.Huh@microchip.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	nb@tipi-net.de, fidelio.lawson@exotec.com, marex@nabladev.com
Subject: Re: [PATCH net-next v9 2/3] net: ethtool: add KSZ87xx low-loss cable PHY tunables
Date: Thu,  4 Jun 2026 13:41:19 +0200	[thread overview]
Message-ID: <20260604114119.170747-1-pabeni@redhat.com> (raw)
In-Reply-To: <20260601-ksz87xx_errata_low_loss_connections-v9-2-fdbbb15592cb@exotec.com>

From: AI Reviewer <ai@example.com>

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
Full review at: https://sashiko.dev/
---
net: ethtool: add KSZ87xx low-loss cable PHY tunables

Introduce vendor-specific PHY tunable identifiers to control the
KSZ87xx low-loss cable erratum handling through the ethtool PHY
tunable interface.

> diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
> index 1cdfb8341df24..a2091d4e00f3f 100644
> --- a/include/uapi/linux/ethtool.h
> +++ b/include/uapi/linux/ethtool.h
> @@ -291,6 +291,9 @@ enum phy_tunable_id {
>  	ETHTOOL_PHY_DOWNSHIFT,
>  	ETHTOOL_PHY_FAST_LINK_DOWN,
>  	ETHTOOL_PHY_EDPD,
> +	ETHTOOL_PHY_SHORT_CABLE_PRESET,
> +	ETHTOOL_PHY_LPF_BW,
> +	ETHTOOL_PHY_DSP_EQ_INIT_VALUE,

[Severity: High]
Are these vendor-specific hardware erratum tunables appropriate for the 
generic global ethtool UAPI? 

These tunables use generic names for device-specific KSZ87xx workarounds. 
Since UAPI is permanent, adding hardware-tied erratum parameters without a 
vendor prefix or standard abstraction could lead to namespace pollution. Would 
devlink param or device tree properties be a better fit for this?

[ ... ]

> diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
> index bd97f9b9bf182..fc25424228246 100644
> --- a/net/ethtool/ioctl.c
> +++ b/net/ethtool/ioctl.c
> @@ -3114,6 +3114,9 @@ static int ethtool_phy_tunable_valid(const struct ethtool_tunable *tuna)
>  	switch (tuna->id) {
>  	case ETHTOOL_PHY_DOWNSHIFT:
>  	case ETHTOOL_PHY_FAST_LINK_DOWN:
> +	case ETHTOOL_PHY_SHORT_CABLE_PRESET:
> +	case ETHTOOL_PHY_LPF_BW:
> +	case ETHTOOL_PHY_DSP_EQ_INIT_VALUE:
>  		if (tuna->len != sizeof(u8) ||
>  		    tuna->type_id != ETHTOOL_TUNABLE_U8)
>  			return -EINVAL;

[Severity: High]
Is it intentional to enforce an 8-bit type constraint for bandwidth and DSP
equalizer tunables?

This heavily couples the global API to the 8-bit register layout of the
KSZ87xx hardware without defining generic units like Hz for bandwidth. 

Also, in the same file:

> net/ethtool/ioctl.c:set_phy_tunable() {
> ...
> 	phy_drv_tunable = phydev && phydev->drv && phydev->drv->get_tunable;
> 	if (!phy_drv_tunable && !dev->ethtool_ops->set_phy_tunable)
> 		return -EOPNOTSUPP;
> ...
> 	if (phy_drv_tunable) {
> 		mutex_lock(&phydev->lock);
> 		ret = phydev->drv->set_tunable(phydev, &tuna, data);
> 		mutex_unlock(&phydev->lock);
> 	}
> ...
> }

[Severity: High]
This is a pre-existing issue, but does this code unconditionally dereference
set_tunable if get_tunable is present?

In set_phy_tunable(), phy_drv_tunable is determined by checking
phydev->drv->get_tunable instead of set_tunable. If a driver implements
get_tunable but leaves set_tunable as NULL, the capability check passes, which
would result in a NULL pointer dereference when set_tunable is called.
-- 
This is an AI-generated review.


  reply	other threads:[~2026-06-04 11:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01 15:19 [PATCH net-next v9 0/3] ksz87xx: add support for low-loss cable equalizer errata Fidelio Lawson
2026-06-01 15:19 ` [PATCH net-next v9 1/3] net: dsa: microchip: implement KSZ87xx Module 3 low-loss cable errata Fidelio Lawson
2026-06-01 15:19 ` [PATCH net-next v9 2/3] net: ethtool: add KSZ87xx low-loss cable PHY tunables Fidelio Lawson
2026-06-04 11:41   ` Paolo Abeni [this message]
2026-06-04 12:11     ` Andrew Lunn
2026-06-05  2:35     ` Jakub Kicinski
2026-06-05  3:16       ` Marek Vasut
2026-06-01 15:19 ` [PATCH net-next v9 3/3] net: phy: micrel: expose KSZ87xx low-loss cable tunables Fidelio Lawson
2026-06-04 11:41   ` Paolo Abeni
2026-06-04 12:15     ` Andrew Lunn
2026-06-01 15:43 ` [PATCH net-next v9 0/3] ksz87xx: add support for low-loss cable equalizer errata Nicolai Buchwitz

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=20260604114119.170747-1-pabeni@redhat.com \
    --to=pabeni@redhat.com \
    --cc=Tristram.Ha@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fidelio.lawson@exotec.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=lawson.fidelio@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=marex@denx.de \
    --cc=marex@nabladev.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=nb@tipi-net.de \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=woojung.huh@microchip.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