Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1029170rdb; Fri, 1 Dec 2023 05:27:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPTOLe09WLXzX/zNp+QrN0OZSxZFCj3bIPINe6txpB+5sd+yq+5LNpWlPjHHR7bC0+he2C X-Received: by 2002:a17:902:868a:b0:1cf:e100:a96b with SMTP id g10-20020a170902868a00b001cfe100a96bmr13559177plo.9.1701437252701; Fri, 01 Dec 2023 05:27:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701437252; cv=none; d=google.com; s=arc-20160816; b=chfq7LFAspt5HnWZgJY0xGZyrzanG959CU9AfpAFFE4VW5LgkTfcv8xDRSXe93BjDy dPSk2GppAPgPp5ngzZDlpeYoINK9IIwE8TlMtTsZ0VwWEXQKv/ELg2LuClMNp1KX7HDc g6NOLdnUqcdvNvx3DnH951zNdZVu48Fy9eP77RSHRJqrj8vapjEMUAXpJiZZ/TNisbx3 bms49mxKdq3CYAN3QRJ7WPcU9jZgRCn+7c/Om4XGh6R5503IS25wWNFCjCotsvc9tgYb OqcRKnGu+Iy44P+ojNitr8OZgWm2jw8iDv+XLWzCLkxHwDyo5WzCNbbpzO/RLf2O4v5D 3mrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5i1eC0ROgK2gZ5RGOpll/NrHkavhR+ZFmj0eHmTcPiE=; fh=naCYaO6GiXya+6VRWoWLfkzxVArZsH18RtkUBg83ptc=; b=0KNNY44/cH6rIiDDZ0RUqBt6LVjj3+OKgDyPLZiOFGYJNCq2yxUMVwmDPnetb6apSB LKZ02wVotljHIFWX1wLtPBKINUps7rBtY8Oou3KlwaS4t7vzQXITnjj3gAzbT9PZmtaS LmGLNDLEwUJFsNyGcbhPB6CkwMSOemIbioQ2Bd/4W86eMrttFFpho5pK13Nb4vTRyejq uR2EoR3QrI8s6u2N3NZPHKDSw6xuFbzz4IlI7XvJupZl0OyUlMvgoFQJRs9ibcEk124j SU/q9hoQ7d2GA2h0JyzyeffLYoH7e3ObyzawtjSHiyRXIz6HvLxkd6O4VcQbTTtUExS3 1WIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jPoy4rpb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id i14-20020a17090332ce00b001cfd2b08900si3217278plr.365.2023.12.01.05.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 05:27:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jPoy4rpb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 6ACC2836D63F; Fri, 1 Dec 2023 05:27:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378999AbjLAN1O (ORCPT + 99 others); Fri, 1 Dec 2023 08:27:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378985AbjLAN1N (ORCPT ); Fri, 1 Dec 2023 08:27:13 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB87C10F8 for ; Fri, 1 Dec 2023 05:27:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701437238; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5i1eC0ROgK2gZ5RGOpll/NrHkavhR+ZFmj0eHmTcPiE=; b=jPoy4rpbA5npsIfKoygcXbo7toAsPSkgKYhPQO+xb7WBV5jlJqnTwvc5HYidM6AVlC33wR Oeb3CHFi+jSnc/EQvhQWZkxaZ/6Y0c+wyEQ7NFovzrNk3gWqGFh4SHRSSlKptsXNsbyYZr 7S0QmwEVHAgT9NdSuy+UGquMSar2Bz8= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-232-ANTKSBixPGqBzlomZSIBnA-1; Fri, 01 Dec 2023 08:27:14 -0500 X-MC-Unique: ANTKSBixPGqBzlomZSIBnA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6F2EE381AE57; Fri, 1 Dec 2023 13:27:13 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.39.193.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id F21571C060AE; Fri, 1 Dec 2023 13:27:09 +0000 (UTC) From: Jose Ignacio Tornos Martinez To: greg@kroah.com Cc: davem@davemloft.net, edumazet@google.com, jtornosm@redhat.com, kuba@kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org, oneukum@suse.com, pabeni@redhat.com, stern@rowland.harvard.edu, stable@vger.kernel.org Subject: [PATCH v3] net: usb: ax88179_178a: avoid failed operations when device is disconnected Date: Fri, 1 Dec 2023 14:26:47 +0100 Message-ID: <20231201132647.178979-1-jtornosm@redhat.com> In-Reply-To: <2023120130-repair-tackle-698e@gregkh> References: <2023120130-repair-tackle-698e@gregkh> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 01 Dec 2023 05:27:30 -0800 (PST) When the device is disconnected we get the following messages showing failed operations: Nov 28 20:22:11 localhost kernel: usb 2-3: USB disconnect, device number 2 Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3: unregister 'ax88179_178a' usb-0000:02:00.0-3, ASIX AX88179 USB 3.0 Gigabit Ethernet Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3: Failed to read reg index 0x0002: -19 Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3: Failed to write reg index 0x0002: -19 Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3 (unregistered): Failed to write reg index 0x0002: -19 Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3 (unregistered): Failed to write reg index 0x0001: -19 Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3 (unregistered): Failed to write reg index 0x0002: -19 The reason is that although the device is detached, normal stop and unbind operations are commanded from the driver. These operations are not necessary in this situation, so avoid these logs when the device is detached if the result of the operation is -ENODEV and if the new flag informing about the stopping or unbind operation is enabled. cc: stable@vger.kernel.org Fixes: e2ca90c276e1f ("ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver") Signed-off-by: Jose Ignacio Tornos Martinez --- V1 -> V2: - Follow the suggestions from Alan Stern and Oliver Neukum to check the result of the operations (-ENODEV) and not the internal state of the USB layer (USB_STATE_NOTATTACHED). V2 -> V3 - Add cc: stable line in the signed-off-by area. drivers/net/usb/ax88179_178a.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c index 4ea0e155bb0d..105bae360128 100644 --- a/drivers/net/usb/ax88179_178a.c +++ b/drivers/net/usb/ax88179_178a.c @@ -173,6 +173,7 @@ struct ax88179_data { u8 in_pm; u32 wol_supported; u32 wolopts; + u8 stopping_unbinding; }; struct ax88179_int_data { @@ -208,6 +209,7 @@ static int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, { int ret; int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16); + struct ax88179_data *ax179_data = dev->driver_priv; BUG_ON(!dev); @@ -219,7 +221,7 @@ static int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, ret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, value, index, data, size); - if (unlikely(ret < 0)) + if (unlikely(ret < 0 && !(ret == -ENODEV && ax179_data->stopping_unbinding))) netdev_warn(dev->net, "Failed to read reg index 0x%04x: %d\n", index, ret); @@ -231,6 +233,7 @@ static int __ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, { int ret; int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16); + struct ax88179_data *ax179_data = dev->driver_priv; BUG_ON(!dev); @@ -242,7 +245,7 @@ static int __ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, ret = fn(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, value, index, data, size); - if (unlikely(ret < 0)) + if (unlikely(ret < 0 && !(ret == -ENODEV && ax179_data->stopping_unbinding))) netdev_warn(dev->net, "Failed to write reg index 0x%04x: %d\n", index, ret); @@ -1308,6 +1311,8 @@ static void ax88179_unbind(struct usbnet *dev, struct usb_interface *intf) struct ax88179_data *ax179_data = dev->driver_priv; u16 tmp16; + ax179_data->stopping_unbinding = 1; + /* Configure RX control register => stop operation */ tmp16 = AX_RX_CTL_STOP; ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16); @@ -1319,6 +1324,8 @@ static void ax88179_unbind(struct usbnet *dev, struct usb_interface *intf) tmp16 = 0; ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); + ax179_data->stopping_unbinding = 0; + kfree(ax179_data); } @@ -1661,14 +1668,19 @@ static int ax88179_reset(struct usbnet *dev) static int ax88179_stop(struct usbnet *dev) { + struct ax88179_data *ax179_data = dev->driver_priv; u16 tmp16; + ax179_data->stopping_unbinding = 1; + ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, &tmp16); tmp16 &= ~AX_MEDIUM_RECEIVE_EN; ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, &tmp16); + ax179_data->stopping_unbinding = 0; + return 0; } -- 2.43.0