From patchwork Thu Oct 19 21:20:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 155711 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp659396vqb; Thu, 19 Oct 2023 14:23:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0yZIvbRovxAonotKhsIK05wmq8/+L384Oe4Qdxszos/B3w9eEdkTI2qfgHZc+cY/fDSXK X-Received: by 2002:a05:6a20:e10f:b0:16b:8b16:bfad with SMTP id kr15-20020a056a20e10f00b0016b8b16bfadmr4600627pzb.32.1697750614671; Thu, 19 Oct 2023 14:23:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697750614; cv=none; d=google.com; s=arc-20160816; b=VVWu7WqzcCwneEdued9YyFEMv2WAZ3ZKZDfvVn5TqXi28kbrnsY+YQqfhXybMNFd0/ 5dljAlvPXQAvoxf7ZLlTsuLtataXts6HPhVt/Y4q0TbGWYj6bR+ZZzGT+Wrx0Tck1+8Q 3mjAfb3RWwDCSRKqpzCPdtSwgzciY2lVZQo/C5ZT8bNTNYGSYyku5sfv6Yc8Uu7pVYqp fiK+YtvnJdF/AjDNsImoVGRJxCdrDl2NnN5fy0xfO2R63qnTknvrie48AZzFFOpa7I1b +zmg7Ku1gVzXuy31j71yLtBGEei/oXlxsTUM/zMzr6BugTT5FJwIKRBy1ZzoPokzQ3oW VdcQ== 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=99XDTyUCvOUhQUp0MWN4ekbCgPLwBk+829H/gHSUoe4=; fh=iQz8TR/TEhrJ65P6O6F77LKl82gG554r6Y3izUu7t+g=; b=V1sUH4ArpPfxaRGD2uTfiOm21bOAkkOqxSTRTnfOdlvQEJxQwGf+OK6OReSqa/BMTd SPKYQWgZ2r/8i+B7YXkTynh/3thC+PCid48GJfa07eqd7dQ7JvlMPCnVSzZp/bro0ZFN wi5sMrvNOQlH414DLTl2xXdLNukdQtaS5k3ZWmIgEhtC091AGwNbSvtaHA+76YmrpphS mFGhGs0iIFwbBpxI61QyOxntVIrh173BlaqGm6VVv0iHjs1rd4NyUhHPc0SYDDXRXg6g c0w9bP+Tf4qkQLawJ8mTaCJnKjubxaK84j1WkpbrzgdBMw1u8qoUNS5nWOGskT3HxzVp yn9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MPcZ51HN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id y64-20020a638a43000000b00578f7063adasi438099pgd.33.2023.10.19.14.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 14:23:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MPcZ51HN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 1CC28836C018; Thu, 19 Oct 2023 14:23:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235549AbjJSVWz (ORCPT + 26 others); Thu, 19 Oct 2023 17:22:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346598AbjJSVWh (ORCPT ); Thu, 19 Oct 2023 17:22:37 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02D6E10F0 for ; Thu, 19 Oct 2023 14:21:55 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1caa7597af9so890865ad.1 for ; Thu, 19 Oct 2023 14:21:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1697750515; x=1698355315; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=99XDTyUCvOUhQUp0MWN4ekbCgPLwBk+829H/gHSUoe4=; b=MPcZ51HNc62moeK+/HePn0XOKEHJX/127aI6KsxoMr0BIV9AkaT9ImsCYxCC0jAXUV 3ZznDtvUVFzDoSdxlMhQvO8fXUCOK2ccN762TnO8JMzZajWOF0IWh6JPZ1NuY1mqOEMo WobmXd56f4+WENYmSJfy7D/y8DA3xgWDEL21c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697750515; x=1698355315; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=99XDTyUCvOUhQUp0MWN4ekbCgPLwBk+829H/gHSUoe4=; b=KpVCDMR18oJSMzqRZkWI2em0MKCTi7bSCGF/uTByBhqil5IXMomhdF49MTKbUn7LgO MWBWPozxCuA7uzC3BAzOrcWmOYGXyayeEvwAQ37imdRdGybqIm8JbPz9ODA7q5kGqfPg 0nDjcspOtzMSF3betMAiZVCMrVnIe/j3Cp7u653BhpQt+/IO7vDJUAzJeyXjkBzEoR1F 1GZ0eJbgDSOwvCKpxeRkxFpVcmGdgUON3U/pIuFEdC8tzhfLELT3jNMqzjfxGqGr0T6R NuGZOoJmmnIrXa6vSZWYGd46gdycIFJkdNBi6gc8nKSN0MPgoJQG7Yjn6wOn9otvVOKf Xc8A== X-Gm-Message-State: AOJu0Yy2zYbYRjZjwLaOG791nArbfPHw6BcDyELUdHBAva3Cg5CQUq54 WQwmiRLt0mVSrSas8IJdaBkqTg== X-Received: by 2002:a17:902:e204:b0:1c9:ccbc:4c98 with SMTP id u4-20020a170902e20400b001c9ccbc4c98mr75405plb.37.1697750515162; Thu, 19 Oct 2023 14:21:55 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:a6da:6f08:412:e04b]) by smtp.gmail.com with ESMTPSA id l2-20020a170902d34200b001bbdd44bbb6sm154100plk.136.2023.10.19.14.21.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 14:21:54 -0700 (PDT) From: Douglas Anderson To: Jakub Kicinski , Hayes Wang , "David S . Miller" Cc: Grant Grundler , Edward Hill , linux-usb@vger.kernel.org, Simon Horman , Laura Nao , Alan Stern , Douglas Anderson , =?utf-8?q?Bj=C3=B8rn_Mork?= , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v4 1/5] r8152: Increase USB control msg timeout to 5000ms as per spec Date: Thu, 19 Oct 2023 14:20:20 -0700 Message-ID: <20231019142019.v4.1.I6e4fb5ae61b4c6ab32058cb12228fd5bd32da676@changeid> X-Mailer: git-send-email 2.42.0.758.gaed0368e0e-goog In-Reply-To: <20231019212130.3146151-1-dianders@chromium.org> References: <20231019212130.3146151-1-dianders@chromium.org> MIME-Version: 1.0 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 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]); Thu, 19 Oct 2023 14:23:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780220548522402339 X-GMAIL-MSGID: 1780220548522402339 According to the comment next to USB_CTRL_GET_TIMEOUT and USB_CTRL_SET_TIMEOUT, although sending/receiving control messages is usually quite fast, the spec allows them to take up to 5 seconds. Let's increase the timeout in the Realtek driver from 500ms to 5000ms (using the #defines) to account for this. This is not just a theoretical change. The need for the longer timeout was seen in testing. Specifically, if you drop a sc7180-trogdor based Chromebook into the kdb debugger and then "go" again after sitting in the debugger for a while, the next USB control message takes a long time. Out of ~40 tests the slowest USB control message was 4.5 seconds. While dropping into kdb is not exactly an end-user scenario, the above is similar to what could happen due to an temporary interrupt storm, what could happen if there was a host controller (HW or SW) issue, or what could happen if the Realtek device got into a confused state and needed time to recover. This change is fairly critical since the r8152 driver in Linux doesn't expect register reads/writes (which are backed by USB control messages) to fail. Fixes: ac718b69301c ("net/usb: new driver for RTL8152") Suggested-by: Hayes Wang Signed-off-by: Douglas Anderson --- (no changes since v1) drivers/net/usb/r8152.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 0c13d9950cd8..482957beae66 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -1212,7 +1212,7 @@ int get_registers(struct r8152 *tp, u16 value, u16 index, u16 size, void *data) ret = usb_control_msg(tp->udev, tp->pipe_ctrl_in, RTL8152_REQ_GET_REGS, RTL8152_REQT_READ, - value, index, tmp, size, 500); + value, index, tmp, size, USB_CTRL_GET_TIMEOUT); if (ret < 0) memset(data, 0xff, size); else @@ -1235,7 +1235,7 @@ int set_registers(struct r8152 *tp, u16 value, u16 index, u16 size, void *data) ret = usb_control_msg(tp->udev, tp->pipe_ctrl_out, RTL8152_REQ_SET_REGS, RTL8152_REQT_WRITE, - value, index, tmp, size, 500); + value, index, tmp, size, USB_CTRL_SET_TIMEOUT); kfree(tmp); @@ -9494,7 +9494,8 @@ static u8 __rtl_get_hw_ver(struct usb_device *udev) ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8152_REQ_GET_REGS, RTL8152_REQT_READ, - PLA_TCR0, MCU_TYPE_PLA, tmp, sizeof(*tmp), 500); + PLA_TCR0, MCU_TYPE_PLA, tmp, sizeof(*tmp), + USB_CTRL_GET_TIMEOUT); if (ret > 0) ocp_data = (__le32_to_cpu(*tmp) >> 16) & VERSION_MASK;