From patchwork Tue Nov 19 13:46:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Krzysztof_Ha=C5=82asa?= X-Patchwork-Id: 13879940 Received: from ni.piap.pl (ni.piap.pl [195.187.100.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4851154670; Tue, 19 Nov 2024 13:55:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.187.100.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732024516; cv=none; b=q4bxsV/fTr02O3l/yjUD7yQgFbeuBtBX9IhP27T6wbQD/TsgtTLYsDY/Ffu5ta2S7M7qtbrp4pCqjCJfO28/FfD5Lyh9pBOKbDON7q4BI9HS6r+3S3FEWTC+9OVeJTyVzi4FsJvr4vWRnwj0EMxEG+qdlgrx2FlGsAa5EiFywkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732024516; c=relaxed/simple; bh=SLr8wLJHObtcmee23pr+3IM8O4qo1N6BBgQ9Io8vn78=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=GPTdByZIiUwrIYk1wjJIjERQP05tesQn7ea1H05cPYppD4gCNwycHzJQCOVYVexwpakDafhrS90+I5OX5YtpvrYBqx/jS4P33N40HMeTXMoBFTxCrVOvgg3MPfIkUoAHcEQyzXjEIxSdb0n0U9AMIDLQ2t6yTpI6u4bjoMhSzC4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=piap.pl; spf=pass smtp.mailfrom=piap.pl; arc=none smtp.client-ip=195.187.100.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=piap.pl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=piap.pl Received: from t19.piap.pl (OSB1819.piap.pl [10.0.9.19]) by ni.piap.pl (Postfix) with ESMTPS id C067BC3EEAC5; Tue, 19 Nov 2024 14:47:00 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 ni.piap.pl C067BC3EEAC5 From: =?utf-8?q?Krzysztof_Ha=C5=82asa?= To: netdev Cc: Oliver Neukum , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Jose Ignacio Tornos Martinez , Ming Lei Subject: [PATCH] usbnet_link_change() fails to call netif_carrier_on() Sender: khalasa@piap.pl Date: Tue, 19 Nov 2024 14:46:59 +0100 Message-ID: Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Hi, ASIX AX88772B based USB 10/100 Ethernet adapter doesn't come up ("carrier off"), despite the built-in 100BASE-FX PHY positive link indication. The problem appears to be in usbnet.c framework: void usbnet_link_change(struct usbnet *dev, bool link, bool need_reset) { /* update link after link is reseted */ if (link && !need_reset) netif_carrier_on(dev->net); else netif_carrier_off(dev->net); if (need_reset && link) usbnet_defer_kevent(dev, EVENT_LINK_RESET); else usbnet_defer_kevent(dev, EVENT_LINK_CHANGE); } I think the author's idea was a bit different than what the code really ended doing. Especially when called with link = 1 and need_reset = 1. It seems it may have already caused problems - possible workarounds: - commit 7be4cb7189f7 ("net: usb: ax88179_178a: improve reset check") - commit ecf848eb934b ("net: usb: ax88179_178a: fix link status when link is set to down/up") Can't check those due to -ENOHW but ax88179_link_reset() adds a netif_carrier_on() call on link ups. Not sure about the "reset" name, though (and the comment in usbnet_link_change()). It seems it's when the link goes up. Signed-off-by: Krzysztof HaƂasa Fixes: ac64995da872 ("usbnet: introduce usbnet_link_change API") Fixes: 4b49f58fff00 ("usbnet: handle link change") The code has been introduced in 2013, by 4b49f58fff00 and a bunch of related commits. Perhaps it visibly affects only AXIS and dm9601 adapters, though. --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -1978,16 +1978,18 @@ EXPORT_SYMBOL(usbnet_manage_power); void usbnet_link_change(struct usbnet *dev, bool link, bool need_reset) { - /* update link after link is reseted */ - if (link && !need_reset) + if (link) netif_carrier_on(dev->net); else netif_carrier_off(dev->net); - if (need_reset && link) - usbnet_defer_kevent(dev, EVENT_LINK_RESET); - else - usbnet_defer_kevent(dev, EVENT_LINK_CHANGE); + if (need_reset) { + /* update link after link is reset */ + if (link) + usbnet_defer_kevent(dev, EVENT_LINK_RESET); + else + usbnet_defer_kevent(dev, EVENT_LINK_CHANGE); + } } EXPORT_SYMBOL(usbnet_link_change);