Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2302958pxb; Mon, 18 Jan 2021 14:07:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJykGo4KUzRboDbuP5tSNMqXD9v1ZVyRipjX+nDaaNbTeXjKC2cnl7tvC+wZ9BUUXjROxDTL X-Received: by 2002:a05:6402:4310:: with SMTP id m16mr1128525edc.207.1611007630560; Mon, 18 Jan 2021 14:07:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611007630; cv=none; d=google.com; s=arc-20160816; b=YzccUk4QKWieDc/UWpqzBYNorrCDLSaEwAp6nKGWIQBn+rdjJYN5cVgP/fCDgloZTV yvwUJtT/hTFVydA0bmqrl9rhaXArB78ZOHLdw+C8zwIg93fFDhXSNqWsPycokVRTzb4j AcCr3FPyx5STA/LQatA3KtHtX1XNa+7JeiYWEsJVqY/VLKbMb4mrW8UYBSym6fshFJSZ RI1DxE3/06Hy/Teud8q8iFOmKIBL/1NP/UfZeQtsr4iQsJLMeBQuwY2IAbC++XplzMox wkI3MppMsiAeGE0qbAjYAHnmarigjPQeZzOeoeD23+EA1h6KT+ajfmQkMhkm5m37MLkO JSHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9BjWeKnLhtX9WXPmjSXlj5EkkOdetRobr1udf+4AmzQ=; b=sxkMprV+rKgoYs47ylNSvFacl26IleEM+p7ahBkwqfJcFbLL5PItCH4R+lngm2dhjR llXbHjS33I1kmQPF1Dh7rqhkfnDlFwe8YaOXc6uLk4eHKdVDqDjFGLILY+MIcPBgPM0z oCuhi1HyZgme+RXWJD9gN0GE2n0Ajqk9nXnQwO6mzDxMHEtiO/7pIHXOHnpFBgo/57Ir K6drWAMNYe0SUJ1feJBW2F7ECsQgN6Uf+6N4EZawxJpX1jN7WT888dyYb0pW8yHvXQ+2 1W/MSbPC7rRt61EbDsPkVvy9QsFw1AFG98aFTAJFLYiV5wAwDpATmKiwgd21DgUlwXYE yoUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=a+9n5eZg; 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 33si2415572edq.416.2021.01.18.14.06.46; Mon, 18 Jan 2021 14:07:10 -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=a+9n5eZg; 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 S2388105AbhARWDf (ORCPT + 99 others); Mon, 18 Jan 2021 17:03:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387894AbhARWD0 (ORCPT ); Mon, 18 Jan 2021 17:03:26 -0500 Received: from mail-ua1-x930.google.com (mail-ua1-x930.google.com [IPv6:2607:f8b0:4864:20::930]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3225C0613C1 for ; Mon, 18 Jan 2021 14:02:45 -0800 (PST) Received: by mail-ua1-x930.google.com with SMTP id u27so2549244uaa.13 for ; Mon, 18 Jan 2021 14:02:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9BjWeKnLhtX9WXPmjSXlj5EkkOdetRobr1udf+4AmzQ=; b=a+9n5eZgCWi/s4vOPejRYrhDUcnrW08Zt0Nbg4Vzc+dhj8SIke/Z96SUBtUSWulSz0 MUYd3MF5e44z88vDRzUNpWZOO6I4kZHXLwldldcl1xmRhrsd5lodyqaJtcLzk8P/6GoS o4N+ejsO0uBBQ1QpQCXmiLNjYZGOd6qC954c0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9BjWeKnLhtX9WXPmjSXlj5EkkOdetRobr1udf+4AmzQ=; b=BQ0pEVsZm84bffSKAh0mm+eij3YSZWzhIV+qzfUdD5GjVrDSBDI25S7cAPz7OB6jY7 ChA85BHPpdS4IkbGrSiO9hGDU9+XWfA7prsMi4GwR/f3PPaMCYvLU3qF0eqlB3VLd6fH qiloeG24DUwhIH+wOnExZo7B6wW3dyKKl4JCPgL590yzGkeEK54Vk7CxVBVGqpcXl9qo ldxomQjtq29JVugU9zM9mV+7rjxUd3mT1oCGlopgC7dUlbh5vlf+iavMgGxUPrItf8RX p5kHa/A3wIuZpW6+aC2SQiyk6B3Z1MLtOTzxcJm/LaT4oRcBxxZ0Cnj0l+A/KSvD4who CEkg== X-Gm-Message-State: AOAM530DUwD9cU2eMGdh2UTyc5u9feppb+ApiMZc1f0V1ZhGNcLZlgtS sPO0c6fJ5sYw2RKgcxl6GbvdTRZTySjm6ToFChmFEA== X-Received: by 2002:ab0:cb:: with SMTP id 69mr821626uaj.10.1611007364845; Mon, 18 Jan 2021 14:02:44 -0800 (PST) MIME-Version: 1.0 References: <20210116052623.3196274-1-grundler@chromium.org> <20210116052623.3196274-3-grundler@chromium.org> In-Reply-To: <20210116052623.3196274-3-grundler@chromium.org> From: Grant Grundler Date: Mon, 18 Jan 2021 22:02:33 +0000 Message-ID: Subject: Re: [PATCH 3/3] net: usb: cdc_ncm: don't spew notifications To: Grant Grundler , nic_swsd Cc: Oliver Neukum , "David S. Miller" , Jakub Kicinski , Greg Kroah-Hartman , linux-usb@vger.kernel.org, netdev , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +nic_swsd [adding per Realtek developer team request] On Sat, Jan 16, 2021 at 5:27 AM Grant Grundler wrote: > > 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 >