All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Aleksandr Loktionov" <aleksandr.loktionov@intel.com>,
	intel-wired-lan@lists.osuosl.org
Subject: Re: [PATCH iwl-next 6/8] ixgbe: extract ixgbe_restart_auto_neg() to avoid code duplication
Date: Fri, 30 Oct 2026 04:54:00 +0000	[thread overview]
Message-ID: <sashiko-outbox-190394@kernel.org> (raw)
In-Reply-To: <20260508031226.3601800-7-aleksandr.loktionov@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unchecked register read failures cause cross-register PHY corruption.
--

commit bb1b6f6954d948eeebea8f8bf0a9c8bd82cf6d54
Author: Jakub Chylkowski <jakubx.chylkowski@intel.com>

ixgbe: extract ixgbe_restart_auto_neg() to avoid code duplication

This commit factors out the PHY autonegotiation restart sequence into a
helper function to avoid code duplication. It also updates the sequence to
check the return value of read_reg() to avoid writing stale values on read
failure.

> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
[ ... ]
> @@ -1089,6 +1089,26 @@ int ixgbe_mii_bus_init(struct ixgbe_hw *hw)
>  	return mdiobus_register(bus);
>  }
>  
> +/**
> + * ixgbe_restart_auto_neg - restart PHY autonegotiation
> + * @hw: pointer to hardware structure
> + *
> + * Sets the restart autoneg bit in MDIO_CTRL1 to trigger a new
> + * autonegotiation cycle.
> + **/
> +static void ixgbe_restart_auto_neg(struct ixgbe_hw *hw)
> +{
> +	u16 autoneg_reg;
> +	int status;
> +
> +	status = hw->phy.ops.read_reg(hw, MDIO_CTRL1, MDIO_MMD_AN,
> +				      &autoneg_reg);
> +	if (status)
> +		return;
> +	autoneg_reg |= MDIO_AN_CTRL1_RESTART;
> +	hw->phy.ops.write_reg(hw, MDIO_CTRL1, MDIO_MMD_AN, autoneg_reg);
> +}

The commit message correctly notes that ignoring the read_reg() result can
cause a stale autoneg_reg value from a prior register access to be
unconditionally written back.

Since autoneg_reg is shared across multiple operations earlier in the caller
functions, does this same cross-register corruption still occur if one of
those prior reads fails?

For example, earlier in ixgbe_setup_phy_link_generic():

ixgbe_setup_phy_link_generic() {
        u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
        ...
        hw->phy.ops.read_reg(hw, MDIO_AN_10GBT_CTRL, MDIO_MMD_AN, &autoneg_reg);
        ...
        hw->phy.ops.write_reg(hw, MDIO_AN_10GBT_CTRL, MDIO_MMD_AN, autoneg_reg);

        hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
                             MDIO_MMD_AN, &autoneg_reg);
        ...
        hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
                              MDIO_MMD_AN, autoneg_reg);
        ...
}

If the second read fails, won't it retain the value read from
MDIO_AN_10GBT_CTRL and blindly write it into
IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG?

Should these earlier register accesses also check the return value of
read_reg() to prevent similar corruption?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260508031226.3601800-1-aleksandr.loktionov@intel.com?part=6

  parent reply	other threads:[~2026-10-30  4:54 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08  3:12 [Intel-wired-lan] [PATCH iwl-next 0/8] ixgbe: small cleanups and improvements Aleksandr Loktionov
2026-05-08  3:12 ` Aleksandr Loktionov
2026-05-08  3:12 ` [Intel-wired-lan] [PATCH iwl-next 1/8] ixgbe: rename numa_node to node in struct ixgbe_q_vector Aleksandr Loktionov
2026-05-08  3:12   ` Aleksandr Loktionov
2026-05-11 15:27   ` Simon Horman
2026-05-11 15:27     ` [Intel-wired-lan] " Simon Horman
2026-05-08  3:12 ` [Intel-wired-lan] [PATCH iwl-next 2/8] ixgbe: use int instead of u32 for error code variables Aleksandr Loktionov
2026-05-08  3:12   ` Aleksandr Loktionov
2026-05-08  4:15   ` [Intel-wired-lan] " Przemek Kitszel
2026-05-08  4:15     ` Przemek Kitszel
2026-05-08  3:12 ` [Intel-wired-lan] [PATCH iwl-next 3/8] ixgbe: prevent adding duplicate FDIR perfect filter rules Aleksandr Loktionov
2026-05-08  3:12   ` Aleksandr Loktionov
2026-05-08  4:44   ` [Intel-wired-lan] " Przemek Kitszel
2026-05-08  4:44     ` Przemek Kitszel
2026-05-08  3:12 ` [Intel-wired-lan] [PATCH iwl-next 4/8] ixgbe: increase SECRX_RDY polling frequency in ixgbe_disable_rx_buff_generic Aleksandr Loktionov
2026-05-08  3:12   ` Aleksandr Loktionov
2026-05-11 15:30   ` Simon Horman
2026-05-11 15:30     ` [Intel-wired-lan] " Simon Horman
2026-10-30  4:53   ` sashiko-bot
2026-05-08  3:12 ` [Intel-wired-lan] [PATCH iwl-next 5/8] ixgbe: use ktime_get_real_ns() in ixgbe_ptp_reset() Aleksandr Loktionov
2026-05-08  3:12   ` Aleksandr Loktionov
2026-05-08  3:12 ` [Intel-wired-lan] [PATCH iwl-next 6/8] ixgbe: extract ixgbe_restart_auto_neg() to avoid code duplication Aleksandr Loktionov
2026-05-08  3:12   ` Aleksandr Loktionov
2026-05-11 15:40   ` Simon Horman
2026-05-11 15:40     ` [Intel-wired-lan] " Simon Horman
2026-05-12 13:42     ` Loktionov, Aleksandr
2026-05-12 13:42       ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-05-13 12:13       ` Simon Horman
2026-05-13 12:13         ` [Intel-wired-lan] " Simon Horman
2026-10-30  4:54   ` sashiko-bot [this message]
2026-05-08  3:12 ` [Intel-wired-lan] [PATCH iwl-next 7/8] ixgbe: limit ITR decrease in latency mode to prevent ACK overdrive Aleksandr Loktionov
2026-05-08  3:12   ` Aleksandr Loktionov
2026-05-11 15:47   ` Simon Horman
2026-05-11 15:47     ` [Intel-wired-lan] " Simon Horman
2026-05-08  3:12 ` [Intel-wired-lan] [PATCH iwl-next 8/8] ixgbe: add IXGBE_ITR_ADAPTIVE_MASK_USECS constant Aleksandr Loktionov
2026-05-08  3:12   ` Aleksandr Loktionov
2026-05-11 15:52   ` Simon Horman
2026-05-11 15:52     ` [Intel-wired-lan] " Simon Horman
2026-10-30  4:54   ` sashiko-bot

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=sashiko-outbox-190394@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=aleksandr.loktionov@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.