linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	kernel@pengutronix.de, linux-kernel@vger.kernel.org,
	Russell King <linux@armlinux.org.uk>,
	netdev@vger.kernel.org, Andre Edich <andre.edich@microchip.com>,
	Lukas Wunner <lukas@wunner.de>
Subject: Re: [PATCH net v3 2/3] net: phy: allow drivers to disable polling via get_next_update_time()
Date: Sat, 12 Jul 2025 14:18:48 +0100	[thread overview]
Message-ID: <20250712131848.GA721198@horms.kernel.org> (raw)
In-Reply-To: <20250711094909.1086417-3-o.rempel@pengutronix.de>

On Fri, Jul 11, 2025 at 11:49:08AM +0200, Oleksij Rempel wrote:

...

> @@ -1575,16 +1573,31 @@ static enum phy_state_work _phy_state_machine(struct phy_device *phydev)
>  	phy_process_state_change(phydev, old_state);
>  
>  	/* Only re-schedule a PHY state machine change if we are polling the
> -	 * PHY, if PHY_MAC_INTERRUPT is set, then we will be moving
> -	 * between states from phy_mac_interrupt().
> +	 * PHY. If PHY_MAC_INTERRUPT is set or get_next_update_time() returns
> +	 * PHY_STATE_IRQ, then we rely on interrupts for state changes.
>  	 *
>  	 * In state PHY_HALTED the PHY gets suspended, so rescheduling the
>  	 * state machine would be pointless and possibly error prone when
>  	 * called from phy_disconnect() synchronously.
>  	 */
> -	if (phy_polling_mode(phydev) && phy_is_started(phydev))
> -		phy_queue_state_machine(phydev,
> -					phy_get_next_update_time(phydev));
> +	if (phy_polling_mode(phydev) && phy_is_started(phydev)) {
> +		unsigned int next_time = phy_get_next_update_time(phydev);
> +
> +		if (next_time == PHY_STATE_IRQ) {
> +			/* A driver requesting IRQ mode while also needing
> +			 * polling for stats has a conflicting configuration.
> +			 * Warn about this buggy driver and fall back to
> +			 * polling to ensure stats are updated.
> +			 */
> +			if (phydev->drv->update_stats) {
> +				WARN_ONCE("phy: %s: driver requested IRQ mode but needs polling for stats\n",
> +					  phydev_name(phydev));

The first argument to WARN_ONCE() should be a condition, not a format string.

Flagged by GCC and Clang builds with KCFLAGS=-Wformat-security

> +				phy_queue_state_machine(phydev, PHY_STATE_TIME);
> +			}
> +		} else {
> +			phy_queue_state_machine(phydev, next_time);
> +		}
> +	}
>  
>  	return state_work;
>  }

...

-- 
pw-bot: changes-requested

  reply	other threads:[~2025-07-12 13:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-11  9:49 [PATCH net v3 0/3] net: phy: smsc: use IRQ + relaxed polling to fix missed link-up Oleksij Rempel
2025-07-11  9:49 ` [PATCH net v3 1/3] net: phy: enable polling when driver implements get_next_update_time Oleksij Rempel
2025-07-11  9:49 ` [PATCH net v3 2/3] net: phy: allow drivers to disable polling via get_next_update_time() Oleksij Rempel
2025-07-12 13:18   ` Simon Horman [this message]
2025-07-14  9:53     ` Oleksij Rempel
2025-07-11  9:49 ` [PATCH net v3 3/3] net: phy: smsc: recover missed link-up IRQs on LAN8700 with adaptive polling Oleksij Rempel

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=20250712131848.GA721198@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=andre.edich@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=lukas@wunner.de \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.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;
as well as URLs for NNTP newsgroup(s).