Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Birger Koblitz" <mail@birger-koblitz.de>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH net-next v17 09/13] ax88179_178a: Add Suspend/resume support for AX88179A/772D/279
Date: Wed, 07 Oct 2026 03:05:42 +0000	[thread overview]
Message-ID: <sashiko-outbox-162606@kernel.org> (raw)
In-Reply-To: <20261006-ax88179a-v17-9-252814fe35ea@birger-koblitz.de>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] pm: pm_runtime_get_noresume usage count leak on unbind
- [High] net: ax88179a: in_pm state leak prevents PHY recovery on suspend error
- [Medium] net: ax88179a: unbalanced phylink_resume on suspend error path
- [Medium] net: ax88179a: missing usbnet_resume on resume error path
--

commit a41c6d9493f6bfa6db95add83f5f79963fe546ba
Author: Birger Koblitz <mail@birger-koblitz.de>

ax88179_178a: Add Suspend/resume support for AX88179A/772D/279

This commit adds suspend and resume functionality for the AX88179A, AX88772D,
and AX88279 architectures. It implements wrapper functions in the shared
library to call the specific suspend and resume implementations.

> diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c
> index e592382692c74..aa5f2d6e42e76 100644
> --- a/drivers/net/usb/ax88179a_devices.c
> +++ b/drivers/net/usb/ax88179a_devices.c
[ ... ]
> @@ -126,6 +128,62 @@ static void ax88179a_status(struct usbnet *dev, struct urb *urb)
>  	phylink_mac_interrupt(data->phylink);
>  }
>  
> +static int ax88179a_suspend(struct usb_interface *intf, pm_message_t message)
> +{
> +	struct usbnet *dev = usb_get_intfdata(intf);
> +	struct ax88179_data *priv;
> +	u8 tmp8 = 0;
> +	u16 tmp16;
> +	int ret;
> +
> +	priv = dev->driver_priv;
> +	ax88179_set_pm_mode(dev, true);
> +
> +	if (netif_running(dev->net)) {
> +		rtnl_lock();
> +		phylink_suspend(priv->phylink, !!priv->wolopts);
> +		rtnl_unlock();
> +	}
> +
> +	ret = usbnet_suspend(intf, message);
> +	if (ret) {
> +		rtnl_lock();
> +		phylink_resume(priv->phylink);

[Severity: Medium]
Could this unconditionally start the phylink state machine on an interface
that is administratively down?

In ax88179a_suspend(), phylink_suspend() is only called if netif_running()
is true, but if usbnet_suspend() subsequently fails, the error recovery path
here calls phylink_resume() regardless.

[Severity: High]
Does this error path leak the in_pm state?

During ax88179a_suspend(), in_pm is set to true. If usbnet_suspend() returns
an error, the function returns early without resetting in_pm to false via
ax88179_set_pm_mode(). If an autosuspend or system suspend is aborted due to
this error, subsequent calls to ax88179a_reset() will permanently skip
phylink_start() because in_pm is incorrectly left as true.

> +		rtnl_unlock();
> +		return ret;
> +	}
> +
> +	/* Enable WoL */
[ ... ]
> +static int ax88179a_resume(struct usb_interface *intf)
> +{
> +	struct usbnet *dev = usb_get_intfdata(intf);
> +	struct ax88179_data *ax179_data;
> +	u8 reg8 = 0;
> +	int ret;
> +
> +	ax179_data = dev->driver_priv;
> +	ax88179_set_pm_mode(dev, true);
> +
> +	ret = ax88179_read_cmd(dev, AX88179A_PHY_POWER, 0, 0, 1, &reg8);
> +	if (ret < 0) {
> +		ax88179_set_pm_mode(dev, false);
> +		return ret;

[Severity: Medium]
If ax88179_read_cmd() fails, does returning early here leave the
dev->suspend_count permanently unbalanced?

The usbnet_suspend() function increments dev->suspend_count and stops the
queues. Because this error path bypasses usbnet_resume(), the count is never
decremented.

> +	}
> +	if (!(reg8 & AX_PHY_POWER)) {
[ ... ]
> @@ -784,6 +886,13 @@ static int ax88179a_bind(struct usbnet *dev, struct usb_interface *intf)
>  	if (ret)
>  		goto initphy_err;
>  
> +	/* Keep this interface runtime-PM active by taking a usage ref.
> +	 * Prevents runtime suspend while bound and avoids resume paths
> +	 * that could deadlock (autoresume under RTNL while USB PM lock
> +	 * is held, phylink/MDIO wants RTNL).
> +	 */
> +	pm_runtime_get_noresume(&intf->dev);

[Severity: High]
Does this leak the PM usage counter?

The usage reference is acquired here to prevent runtime autosuspend, but the
unbind path (ax88179a_unbind()) does not seem to drop this reference via
pm_runtime_put_noidle(). Rebinding the driver or initiating a software
unbind/bind cycle could repeatedly leak the PM reference, permanently
preventing the device and its parent USB hubs from entering runtime suspend.

> +
>  	return 0;
>  
>  initphy_err:

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261006-ax88179a-v17-0-252814fe35ea@birger-koblitz.de?part=9

  reply	other threads:[~2026-10-07  3:05 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06  3:05 [PATCH net-next v17 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 01/13] phylink: Add phylink_mac_interrupt Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-07  3:55     ` Fwd: " Birger Koblitz
2026-10-07 12:18       ` Andrew Lunn
2026-10-07 14:16         ` Birger Koblitz
2026-10-08  3:34     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 02/13] phylib: Add support for PHYs with broken forced mode Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:36     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 03/13] ax88179_178a: Split driver into library and device specific code Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:38     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 04/13] ax88179_178a: Add HW support for AX179A-based chips Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:41     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 05/13] ax88179_178a: Add EEE configuration support for AX88179A MACs Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 06/13] ax88179_178a: Add EEE configuration support for AX88179A PHYs Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 07/13] ax88179_178a: Add VLAN offload support for AX88179A Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:44     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 08/13] ax88179_178a: Add AX179A/AX279 multicast configuration Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 09/13] ax88179_178a: Add Suspend/resume support for AX88179A/772D/279 Birger Koblitz
2026-10-07  3:05   ` sashiko-bot [this message]
2026-10-08  3:47     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 10/13] ax88179_178a: Add ethtool get_drvinfo Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 11/13] ax88179_178a: Update driver name and information Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:48     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 12/13] ax88179_178a: Add support for AX88179A/772D/279 EEPROM access Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 13/13] ax88796b: Add support for AX88772D, AX88179A and AX88279 Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:50     ` Birger Koblitz

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-162606@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mail@birger-koblitz.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox