Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3208029pxb; Tue, 19 Jan 2021 17:19:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxAtnfyFot20JTltA0TmutpVpIiCrWvwg4cu8wOR2Oc0fcgjYyLoKKbS2ed1Yrs/0UYAng3 X-Received: by 2002:a17:906:26ca:: with SMTP id u10mr4633341ejc.165.1611105585106; Tue, 19 Jan 2021 17:19:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611105585; cv=none; d=google.com; s=arc-20160816; b=nEyBcvqRUCIrF4F+U7UfqD18Fz69Jjim0yLuJmhQEQUVjh4IFaikjm+Fr/BzwXaohT naYq6HxEO0bFbdJsGZvkTeJCQVn8uHrupfpYe3JdQKA4JXxrE5Pl1OpXJ+4YpWDNiymM 9nOo9ioiDy3LNvyrqzjQPidP5uGcIh3WrKLq5smpxJuQSG1pxP6WMYQ4oNp2Fcuxap+2 F20/IgAKJb/eDTCj6YK2pl4bZzrmmHxMN928sallMm/oDoPRaYdT+fzu4+2UDx9uDNvK oM7z8x+OJ7GNbumuBmUJccL2RkQ+Qk+JdxShw2qrN/hkUlwri1mD6BYtBOcbjQCGPjHr xu0g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=MQG99hmEs+jm/LvVCjiZprhkiqjwfzt+Jg3xINgEKjM=; b=xpAzteZlqt9Ql2tUbBwMiQ584Jql/XxImjawRqUDohmh11zN/WB0x/KAZsYkMtmBz3 af0ye6FlzhJWa9nPK5Ze01E1eU2cJKC9diUXO+CtUpvxyr53RpaKDChUdVATtTjR9lws v3bk/eavWFLmSviwgrz4biruK5Cx4SVZMFLg6NIBalZQgfHakSlRJchdY/yRim8I3KiS oi0WQM9yrErdnAgYmI6+P2FSgG79T1MHKdHyk8Awp45P9tYmnNyTYDgNbQrfGvarzNuz wRkyRFXRoU3DIOz8qHceplR61vuTYS6WXCHNGXK+byzOdlS8Rb4fgOE2EOYi6D7DNh2n JdjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fktRpbRr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l14si213249edw.437.2021.01.19.17.19.21; Tue, 19 Jan 2021 17:19:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fktRpbRr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726637AbhATBP1 (ORCPT + 99 others); Tue, 19 Jan 2021 20:15:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727738AbhATBPK (ORCPT ); Tue, 19 Jan 2021 20:15:10 -0500 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EFC3C0613D3 for ; Tue, 19 Jan 2021 17:14:05 -0800 (PST) Received: by mail-ot1-x335.google.com with SMTP id e70so6373840ote.11 for ; Tue, 19 Jan 2021 17:14:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MQG99hmEs+jm/LvVCjiZprhkiqjwfzt+Jg3xINgEKjM=; b=fktRpbRrdqUh9fffOuxiRUCGF0pLaneaLg9AZoel1GJVzwwTQy1gO97PVbv4BLkUeO HNRpkT1znzuaDuIF7JImQ8WkPrPzewC/+b4foYX219/lIzgNfCw4x4F+8iSnYot0Bq/1 pi1fkN+fHRU6BZy3FCYVPHDFjOpNDVG+a+C5I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MQG99hmEs+jm/LvVCjiZprhkiqjwfzt+Jg3xINgEKjM=; b=dz+29wUY+TydwQ8s6L/ISwdfrwZJ5i+xkz/UrcwDbsXN4sNmrw4ggdY0r8+toPcljd q9AH9n81wW/ldQV5tdfT4Oh/f9yBVDB01TOENI0uU6+4WtBBTEM9QMDe5ibUGQqCQzji 4TyfP6Am6Oe2JI7/sfA8eHWVsCYo6EayZkKd7iMAoxf43/GujD/lv+iu9Y645Jxsr2Fd 2AnfAoBhFYoxyoes4gAPbE4viwLNfxJCLwu0wdoHcek2xJ35UPfBp6kSwxRbBPA6/yhR qLkFm/EZyUa69bhLIPKYU/WhvC6XbptvZ+NZ3VwwieuedTorKoBov1o7KAVO5bAzTk33 HJjg== X-Gm-Message-State: AOAM532WzQ4o+Fh6orFcRcyceOrv2o83PDd1kYCLUEuJQ1b9/obmMTeq 34HhA0uxRUlSKl2teG8KXP6HpQ== X-Received: by 2002:a9d:2035:: with SMTP id n50mr5215147ota.44.1611105244599; Tue, 19 Jan 2021 17:14:04 -0800 (PST) Received: from grundler-glapstation.lan ([70.134.62.80]) by smtp.gmail.com with ESMTPSA id s204sm80339oib.42.2021.01.19.17.14.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jan 2021 17:14:03 -0800 (PST) From: Grant Grundler To: Jakub Kicinski , Oliver Neukum Cc: "David S. Miller" , nic_swsd@realtek.com, Greg Kroah-Hartman , linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Grant Grundler Subject: [PATCH net] net: usb: cdc_ncm: don't spew notifications Date: Tue, 19 Jan 2021 17:12:08 -0800 Message-Id: <20210120011208.3768105-1-grundler@chromium.org> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org RTL8156 sends notifications about every 32ms. Only display/log notifications when something changes. This issue has been reported by others: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1832472 https://lkml.org/lkml/2020/8/27/1083 ... [785962.779840] usb 1-1: new high-speed USB device number 5 using xhci_hcd [785962.929944] usb 1-1: New USB device found, idVendor=0bda, idProduct=8156, bcdDevice=30.00 [785962.929949] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=6 [785962.929952] usb 1-1: Product: USB 10/100/1G/2.5G LAN [785962.929954] usb 1-1: Manufacturer: Realtek [785962.929956] usb 1-1: SerialNumber: 000000001 [785962.991755] usbcore: registered new interface driver cdc_ether [785963.017068] cdc_ncm 1-1:2.0: MAC-Address: 00:24:27:88:08:15 [785963.017072] cdc_ncm 1-1:2.0: setting rx_max = 16384 [785963.017169] cdc_ncm 1-1:2.0: setting tx_max = 16384 [785963.017682] cdc_ncm 1-1:2.0 usb0: register 'cdc_ncm' at usb-0000:00:14.0-1, CDC NCM, 00:24:27:88:08:15 [785963.019211] usbcore: registered new interface driver cdc_ncm [785963.023856] usbcore: registered new interface driver cdc_wdm [785963.025461] usbcore: registered new interface driver cdc_mbim [785963.038824] cdc_ncm 1-1:2.0 enx002427880815: renamed from usb0 [785963.089586] cdc_ncm 1-1:2.0 enx002427880815: network connection: disconnected [785963.121673] cdc_ncm 1-1:2.0 enx002427880815: network connection: disconnected [785963.153682] cdc_ncm 1-1:2.0 enx002427880815: network connection: disconnected ... This is about 2KB per second and will overwrite all contents of a 1MB dmesg buffer in under 10 minutes rendering them useless for debugging many kernel problems. This is also an extra 180 MB/day in /var/logs (or 1GB per week) rendering the majority of those logs useless too. When the link is up (expected state), spew amount is >2x higher: ... [786139.600992] cdc_ncm 2-1:2.0 enx002427880815: network connection: connected [786139.632997] cdc_ncm 2-1:2.0 enx002427880815: 2500 mbit/s downlink 2500 mbit/s uplink [786139.665097] cdc_ncm 2-1:2.0 enx002427880815: network connection: connected [786139.697100] cdc_ncm 2-1:2.0 enx002427880815: 2500 mbit/s downlink 2500 mbit/s uplink [786139.729094] cdc_ncm 2-1:2.0 enx002427880815: network connection: connected [786139.761108] cdc_ncm 2-1:2.0 enx002427880815: 2500 mbit/s downlink 2500 mbit/s uplink ... Chrome OS cannot support RTL8156 until this is fixed. Signed-off-by: Grant Grundler --- drivers/net/usb/cdc_ncm.c | 12 +++++++++++- include/linux/usb/usbnet.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 25498c311551..5de096545b86 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -1827,6 +1827,15 @@ cdc_ncm_speed_change(struct usbnet *dev, uint32_t rx_speed = le32_to_cpu(data->DLBitRRate); uint32_t tx_speed = le32_to_cpu(data->ULBitRate); + /* if the speed hasn't changed, don't report it. + * RTL8156 shipped before 2021 sends notification about every 32ms. + */ + if (dev->rx_speed == rx_speed && dev->tx_speed == tx_speed) + return; + + dev->rx_speed = rx_speed; + dev->tx_speed = tx_speed; + /* * Currently the USB-NET API does not support reporting the actual * device speed. Do print it instead. @@ -1867,7 +1876,8 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb) * USB_CDC_NOTIFY_NETWORK_CONNECTION notification shall be * sent by device after USB_CDC_NOTIFY_SPEED_CHANGE. */ - usbnet_link_change(dev, !!event->wValue, 0); + if (netif_carrier_ok(dev->net) != !!event->wValue) + usbnet_link_change(dev, !!event->wValue, 0); break; case USB_CDC_NOTIFY_SPEED_CHANGE: diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h index 88a7673894d5..cfbfd6fe01df 100644 --- a/include/linux/usb/usbnet.h +++ b/include/linux/usb/usbnet.h @@ -81,6 +81,8 @@ struct usbnet { # define EVENT_LINK_CHANGE 11 # define EVENT_SET_RX_MODE 12 # define EVENT_NO_IP_ALIGN 13 + u32 rx_speed; /* in bps - NOT Mbps */ + u32 tx_speed; /* in bps - NOT Mbps */ }; static inline struct usb_driver *driver_of(struct usb_interface *intf) -- 2.29.2