Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp525877rdg; Thu, 12 Oct 2023 12:31:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGNvuXTtuSQoZHPNfe+OkR2LGUo3gTIXC2VQPJ1exAlqIrgCyUiiItmMzVp9Bre7mHBD23 X-Received: by 2002:a17:90b:3505:b0:278:faf8:af9f with SMTP id ls5-20020a17090b350500b00278faf8af9fmr23133805pjb.20.1697139060408; Thu, 12 Oct 2023 12:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697139060; cv=none; d=google.com; s=arc-20160816; b=G/P7CnrkqT2Hzs5IlIlCHN3nBm4cIUZ8wphOe1utT2KyUjucntyoa2r/fQNDHixTWh rHCaHYPL1w10xwld32DFGax/iIrfC76MVe6Pgvv98WnCzPDeUMdXLOkpByNWJ8xJRCLS F7NMA2XhdXNRDJTgFhKA+4VdvuargnmnvHuBZvHNH3ymJXnzQgonPZuX8As35c4DfY85 G2S6K9A6hhe6DzMXK8nRP09m4tGyXJKWS2iKTYujKcwDtvRnA2az/AKj5fj5kT/s71Hz 9b9J45hLVnHApq1O8ioAWUXdEDoWYKcRRrKD4A9BMc9dN1Bx5Teu0PEHvCdUHl6O5xwg PATg== 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=PIPGKLqX4lqtP5rqVW/Z8WpP9n2U6+vzX9cu74+l4o8=; fh=B0Kr+W4P+gDWCh4uaZww8C7+cggdkGoCsVYEV5mipv8=; b=opaPSf/b+iIXVJAZ3Tnd5fQESD0q0nqyZ2xisF29wk/ouPD5x9t2LhU54Q0uqHYwfu bQvRtYzuovDm91KRUouiF7aDR8NpPwgrtPQX7L7hXZhuHNvF5gL+G6xibKV7EDMzXENj zMQXHbyu6kPnbIZsox5OchJ0neNymi1HDsyJadhmGL9Gyg54uJi7o2y7oHdApUCYmhK+ PmYAONQOcK1QpanM83gd+AYo/OKN3klBoyFmb7fBIUtkldodov10i6PQtV6tLtTqLu8o crck+jr4WV6z/7ojbbrJVm2bKC2Rv/DxvzngZoloX72DIGpGD2QzRCcip2Fo2Lp4y9iy 4pAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ClwdjZhH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id 16-20020a17090a195000b00276bf69ac44si2789777pjh.5.2023.10.12.12.31.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:31:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ClwdjZhH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 66FD180740EA; Thu, 12 Oct 2023 12:30:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442098AbjJLTaS (ORCPT + 99 others); Thu, 12 Oct 2023 15:30:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1441868AbjJLTaR (ORCPT ); Thu, 12 Oct 2023 15:30:17 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78D3ABB for ; Thu, 12 Oct 2023 12:30:16 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6b1df4ebd52so72139b3a.2 for ; Thu, 12 Oct 2023 12:30:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1697139016; x=1697743816; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=PIPGKLqX4lqtP5rqVW/Z8WpP9n2U6+vzX9cu74+l4o8=; b=ClwdjZhHqjwVWio4JhMuQOREFoSrMk1z46czHsayyHLj3fLWFYQ282jFfOtwAl0BVe n0FSgg1bBaRBtHKQUvGzhpJgEQs2gaBawGQNHBDZ/ypg2HTnPKFfn8gd8h+OpG/r0l7n M89PgIVrMXRZ5/pBOcFhp0wCwuuR0SuXMaD2Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697139016; x=1697743816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PIPGKLqX4lqtP5rqVW/Z8WpP9n2U6+vzX9cu74+l4o8=; b=EpVuMdidtWeUeNBs2Ek+Is5Zklrq+xgvLD0/9WmQsVY6J0LOyRbk5Po3NmDcZ1xnIm 9kEK0ml8uEl472S1kp9YiDt9UZl3VosWGYQsGLMY6DvaiGAJ8rSAWPJABGH/61kGXaCS EGyh4JfsVxyxyJBVmtAOpXwmY9IZynBiKMjV3ytpO1+azXlbwB5t4yIECwbdI24PNbal r4W4wmvuQlSHH7KT+m3Kg5eys9vPtzPiK72VAMctaTnne/H0LR5PFqr3Bfw8wK1hiAJt i40mpVZvA/6XrC6SaOmxA+jlguggxucEwcEZR+FoaXrxAGlX1PcNp2xTqhl8yqMsb2TM UwcQ== X-Gm-Message-State: AOJu0YyYAAcXW1fDlukq5ZhdZyV2h4QO23uf/8EVFac5HS6QW5DA/RD4 dbbxb5We78ASZG3LpoWy1CBoqQ== X-Received: by 2002:a05:6a20:7286:b0:15e:7323:5c0f with SMTP id o6-20020a056a20728600b0015e73235c0fmr30788570pzk.16.1697139015932; Thu, 12 Oct 2023 12:30:15 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:7c85:4a99:f03e:6f30]) by smtp.gmail.com with ESMTPSA id b3-20020a639303000000b0057c25885fcfsm2075720pge.10.2023.10.12.12.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:30:15 -0700 (PDT) From: Douglas Anderson To: Jakub Kicinski , Hayes Wang , "David S . Miller" Cc: Alan Stern , Simon Horman , Edward Hill , Laura Nao , linux-usb@vger.kernel.org, Grant Grundler , Douglas Anderson , =?UTF-8?q?Bj=C3=B8rn=20Mork?= , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v3 0/5] r8152: Avoid writing garbage to the adapter's registers Date: Thu, 12 Oct 2023 12:24:59 -0700 Message-ID: <20231012192552.3900360-1-dianders@chromium.org> X-Mailer: git-send-email 2.42.0.655.g421f12c284-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Thu, 12 Oct 2023 12:30:29 -0700 (PDT) This series is the result of a cooperative debug effort between Realtek and the ChromeOS team. On ChromeOS, we've noticed that Realtek Ethernet adapters can sometimes get so wedged that even a reboot of the host can't get them to enumerate again, assuming that the adapter was on a powered hub and din't lose power when the host rebooted. This is sometimes seen in the ChromeOS automated testing lab. The only way to recover adapters in this state is to manually power cycle them. I managed to reproduce one instance of this wedging (unknown if this is truly related to what the test lab sees) by doing this: 1. Start a flood ping from a host to the device. 2. Drop the device into kdb. 3. Wait 90 seconds. 4. Resume from kdb (the "g" command). 5. Wait another 45 seconds. Upon analysis, Realtek realized this was happening: 1. The Linux driver was getting a "Tx timeout" after resuming from kdb and then trying to reset itself. 2. As part of the reset, the Linux driver was attempting to do a read-modify-write of the adapter's registers. 3. The read would fail (due to a timeout) and the driver pretended that the register contained all 0xFFs. See commit f53a7ad18959 ("r8152: Set memory to all 0xFFs on failed reg reads") 4. The driver would take this value of all 0xFFs, modify it, and attempt to write it back to the adapter. 5. By this time the USB channel seemed to recover and thus we'd successfully write a value that was mostly 0xFFs to the adpater. 6. The adapter didn't like this and would wedge itself. Another Engineer also managed to reproduce wedging of the Realtek Ethernet adpater during a reboot test on an AMD Chromebook. In that case he was sometimes seeing -EPIPE returned from the control transfers. This patch series fixes both issues. Changes in v3: - Fixed v2 changelog ending up in the commit message. - farmework -> framework in comments. Changes in v2: - ("Check for unplug in rtl_phy_patch_request()") new for v2. - ("Check for unplug in r8153b_ups_en() / r8153c_ups_en()") new for v2. - ("Rename RTL8152_UNPLUG to RTL8152_INACCESSIBLE") new for v2. - Reset patch no longer based on retry patch, since that was dropped. - Reset patch should be robust even if failures happen in probe. - Switched booleans to bits in the "flags" variable. - Check for -ENODEV instead of "udev->state == USB_STATE_NOTATTACHED" Douglas Anderson (5): r8152: Increase USB control msg timeout to 5000ms as per spec r8152: Check for unplug in rtl_phy_patch_request() r8152: Check for unplug in r8153b_ups_en() / r8153c_ups_en() r8152: Rename RTL8152_UNPLUG to RTL8152_INACCESSIBLE r8152: Block future register access if register access fails drivers/net/usb/r8152.c | 268 +++++++++++++++++++++++++++++++--------- 1 file changed, 209 insertions(+), 59 deletions(-) -- 2.42.0.655.g421f12c284-goog