Linux USB
 help / color / mirror / Atom feed
From: Jianhui Xu <neuromoments@gmail.com>
To: mail@birger-koblitz.de
Cc: andrew+netdev@lunn.ch, andrew@lunn.ch, davem@davemloft.net,
	edumazet@google.com, hkallweit1@gmail.com, kuba@kernel.org,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	linux@armlinux.org.uk, netdev@vger.kernel.org,
	neuromoments@gmail.com, pabeni@redhat.com
Subject: Re: [PATCH net-next v10 00/15] ax88179_178a: Add support for AX88179A-based chips
Date: Sun,  6 Sep 2026 18:40:31 +0800	[thread overview]
Message-ID: <20260906104031.78051-1-neuromoments@gmail.com> (raw)
In-Reply-To: <20260904-ax88179a-v10-0-b5e60eca7690@birger-koblitz.de>

Hi Birger,

I tested v9 on the same ASIX AX88179B adapter. By the time you read this,
v10 has already been posted. Given the relatively small differences between
v9 and v10, I expect the issue I found in v9 to apply to v10 as well.

First, as you already noticed, `data` is undeclared.

For QEMU runtime testing I also had to apply Chen-Yu Tsai's unrelated
`usb: xhci: Fix HCS_ERST_MAX conversion` patch. Without it, this base kernel
fails to initialize QEMU's xHCI controller before the network driver is
reached.

All three fresh functional starts completed cold DHCP at 1000baseT/Full
without reloading the driver and passed the normal 1000/100/10/1000 Mbit/s
matrix, EEE disable/restore, pause enable/restore, and EEPROM read.

During repeated speed transitions, I observed one intermittent carrier-loss
failure. Of 19 normally initiated restores from 100/full to the default
1000/full advertisement, 18 passed and one failed to regain carrier. After
that failure, ethtool reported unknown speed and no link, and further
advertisement changes did not recover it. Dmesg showed the preceding
100-Mbit Link Up followed by Link Down, with no subsequent Link Up before
the device was reattached.

I could not reproduce the failure in two later fresh starts or in a further
90 unmodified-v9 stress cycles. Counting the normal matrix and stress
points, all 22 tested 100/full points passed, so I also did not reproduce
the earlier 100-Mbit carrier-without-RX failure.

I repeated the QEMU deep-S3 tests as well. One fresh `wol d` cycle and five
fresh `wol g` cycles all passed. After `system_wakeup`, management SSH
returned, the adapter regained carrier at 1000baseT/Full, and gateway and
test-host traffic increased RX. These tests use QEMU-emulated xHCI and
monitor-triggered wake, not a physical xHCI controller or an actual magic
packet.

I then investigated the intermittent carrier loss with function tracing.
Each advertisement change generates hardware link-down and link-up status
notifications. V9 forwards both to phylib even though the ethtool-triggered
PHY state-machine run has already taken the link down before the hardware
down notification is handled. This results in three PHY state/read-status
runs per advertisement change, including a redundant read while
autonegotiation and controller link setup are still in progress.

In light of your previous observation [1]:

> There is a race condition between the controller of the AX88179A
> trying to set up and optimize the link and phylink trying to
> configure the link on the mac-side.
>
> At this point, the PHY may report that the link is up before the
> controller is actually finished configuring it.

I suspected that the redundant PHY read during autonegotiation might
interact badly with the controller's own link-setup sequence.

As a focused experiment, I changed ax88179a_status() to inspect
AX_INT_PPLS_LINK and track whether phylink currently considers the MAC link
active. A down notification is ignored if phylink has already taken the MAC
down, while up notifications are always forwarded. mac_link_up() marks the
state active before configuring the MAC, so a genuine down event during
configuration is still forwarded.

The experimental kernel built successfully, including focused W=1 checks,
and strict checkpatch reported no findings. I then ran:

- 100 rapid 100/full -> 1000/full cycles;
- 30 paced cycles, holding each endpoint for 8 seconds;
- a 2-cycle trace smoke test.

All 264 requested-speed endpoints reached carrier at the correct speed. The
fixed traces consistently showed four raw status callbacks but only two
phylink interrupts and four PHY reads per complete cycle.

But this does not necessarily prove that the change fixes the original rare
failure: that failure occurred only once in 19 normally initiated restores
and could not be reproduced in another 90 unmodified-v9 stress cycles.

The experimental patch follows for review.

Thanks,
Jianhui

[1] https://lore.kernel.org/netdev/5b2c4498-2e3c-4ae6-b078-deeccf8b7a5c@birger-koblitz.de/

---
 drivers/net/usb/ax88179_lib.h      |  1 +
 drivers/net/usb/ax88179a_devices.c | 19 +++++++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/ax88179_lib.h b/drivers/net/usb/ax88179_lib.h
--- a/drivers/net/usb/ax88179_lib.h
+++ b/drivers/net/usb/ax88179_lib.h
@@ -306,6 +306,7 @@ struct ax88179_data {
 	u8 is_ax88772d;
 	u8 ip_align;
 	u8 link;
+	bool mac_link_active;
 	u8 speed;
 	u8 full_duplex;
 	u8 rx_checksum;
diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c
--- a/drivers/net/usb/ax88179a_devices.c
+++ b/drivers/net/usb/ax88179a_devices.c
@@ -118,11 +118,22 @@ static int ax88179_mdiobus_write_c45(struct mii_bus *bus, int addr, int devnum,
 static void ax88179a_status(struct usbnet *dev, struct urb *urb)
 {
 	struct ax88179_data *data = dev->driver_priv;
+	struct ax88179_int_data *event;
+	bool link;
 
 	if (urb->actual_length < 8)
 		return;
 
-	phylink_mac_interrupt(data->phylink);
+	event = urb->transfer_buffer;
+	link = le32_to_cpu(event->intdata1) & AX_INT_PPLS_LINK;
+
+	/* Changing the advertisement has already told phylib that the link is
+	 * down. Avoid another PHY read while the controller is still setting up
+	 * the new link, but always process link-up notifications so that speed
+	 * changes cannot be missed.
+	 */
+	if (link || READ_ONCE(data->mac_link_active))
+		phylink_mac_interrupt(data->phylink);
 }
 
 static int ax88179a_suspend(struct usb_interface *intf, pm_message_t message)
@@ -437,7 +448,9 @@ static void ax88179a_mac_config(struct phylink_config *config, unsigned int mode,
 static void ax88179a_mac_link_down(struct phylink_config *config,
 				   unsigned int mode, phy_interface_t interface)
 {
-	/* Nothing to do */
+	struct ax88179_data *data = netdev2data(to_net_dev(config->dev));
+
+	WRITE_ONCE(data->mac_link_active, false);
 }
 
 static void ax88179a_mac_link_up(struct phylink_config *config,
@@ -448,9 +461,11 @@ static void ax88179a_mac_link_up(struct phylink_config *config,
 {
 	struct usbnet *dev = netdev_priv(to_net_dev(config->dev));
 	struct ax88179_data *ax179_data = dev->driver_priv;
 	u8 tmp8, link_sts, reg8[3];
 	u8 bulk_config_speed = 0;
 	u16 tmp16, mode;
 
+	WRITE_ONCE(ax179_data->mac_link_active, true);
+
 	/* Stop RX/TX for link configuration */
 	tmp16 = AX_RX_CTL_STOP;

  parent reply	other threads:[~2026-09-06 10:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 17:28 [PATCH net-next v10 00/15] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
2026-09-04 17:28 ` [PATCH net-next v10 01/15] phylink: Add phylink_mac_interrupt Birger Koblitz
2026-09-04 17:28 ` [PATCH net-next v10 02/15] phylib: Add support for PHYs with broken forced mode Birger Koblitz
2026-09-04 17:28 ` [PATCH net-next v10 03/15] ax88179_178a: Fix endianness of pause watermark register Birger Koblitz
2026-09-04 17:28 ` [PATCH net-next v10 04/15] ax88179_178a: Split driver into library and device specific code Birger Koblitz
2026-09-04 17:28 ` [PATCH net-next v10 05/15] ax88179_178a: Add netdev2data() convenience function Birger Koblitz
2026-09-04 17:28 ` [PATCH net-next v10 06/15] ax88179_178a: Add HW support for AX179A-based chips Birger Koblitz
2026-09-11  0:00   ` Jakub Kicinski
2026-09-04 17:28 ` [PATCH net-next v10 07/15] ax88179_178a: Add EEE configuration support for AX88179A MACs Birger Koblitz
2026-09-04 17:28 ` [PATCH net-next v10 08/15] ax88179_178a: Add EEE configuration support for AX88179A PHYs Birger Koblitz
2026-09-04 17:28 ` [PATCH net-next v10 09/15] ax88179_178a: Add VLAN offload support for AX88179A Birger Koblitz
2026-09-04 17:28 ` [PATCH net-next v10 10/15] ax88179_178a: Add AX179A/AX279 multicast configuration Birger Koblitz
2026-09-04 17:28 ` [PATCH net-next v10 11/15] ax88179_178a: Add Suspend/resume support for AX88179A/772D/279 Birger Koblitz
2026-09-04 17:28 ` [PATCH net-next v10 12/15] ax88179_178a: Add ethtool get_drvinfo Birger Koblitz
2026-09-04 17:28 ` [PATCH net-next v10 13/15] ax88179_178a: Update driver name and information Birger Koblitz
2026-09-04 17:28 ` [PATCH net-next v10 14/15] ax88179_178a: Add support for AX88179A/772D/279 EEPROM access Birger Koblitz
2026-09-04 17:28 ` [PATCH net-next v10 15/15] ax88796b: Add support for AX88772D, AX88179A and AX88279 Birger Koblitz
2026-09-06 10:40 ` Jianhui Xu [this message]
2026-09-06 18:56   ` [PATCH net-next v10 00/15] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
2026-09-07  5:04     ` Jianhui Xu

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=20260906104031.78051-1-neuromoments@gmail.com \
    --to=neuromoments@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mail@birger-koblitz.de \
    --cc=netdev@vger.kernel.org \
    --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