From patchwork Tue Nov 28 21:38:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 171002 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp4244526vqx; Tue, 28 Nov 2023 13:41:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFzULXbvbp/2D3CxL6HmhWUILWKE+gEdb11cULze2GqIL/VOe1yPB5WFFWqkCWmbk/Uu39f X-Received: by 2002:a05:6a20:8f01:b0:18c:a983:a5f6 with SMTP id b1-20020a056a208f0100b0018ca983a5f6mr8511840pzk.23.1701207675457; Tue, 28 Nov 2023 13:41:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701207675; cv=none; d=google.com; s=arc-20160816; b=PtKYcvlLskSZbj4e7mju9AoXr0YT80PlPAeXd2QtuN55Yf7Qg9nSr9DGYS8L4dNDv/ 9RzHmR1d2TU4qOIL8XSg4AG4aTahQhsB2NCnXIIZ7p+cKX69/wxEMWGExdviCJKdoHSb U//qHf6nlIAM+880vgdPDL4pw5ZASPqIAQeV/Lz68judnQWihoWJS/xBNglhM9Fl6GF+ e0y6VpT/lj7kg7vW4M5zP2psb8y9NfZiQN2GbM7h4gMWp6plsqbmMvpqxfNQFCToRCPB 8wy22GJ7OWXWeQQNVieFKlRFXxIU15kb/RS60if+dlQeJ9UrgM3lsvdZYOZvjv91cPYT hlnw== 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=Y7WtPwx8R41CBpic3+n2/ppAFMVmBycWDouGl52CdYE=; fh=D9dulkN/zvJqgx62bWffkTYlpM2spfXLLqBXpsKZOmw=; b=ZrnhhNfq5vk+bMZlZ2rhXLbl2KJ0rECfhql0Uc+7ZJXinQaZ1HDZZ0rfYS4OvNVj5N R8JXEDOlX4ypByGYB0ejnwVPAdFvwYCe2Wb81YuM2KTVZTJa8lwDIIXIBUlXjNXqMZBs RLizKr8J8TUoVA/8k2gaj9iiQffo6i8Uw+pGsY85IprIuN18kt4EV2euyphfQxrANOh2 wNJbEhCIj3xkkZhvhCpikYLIWURYtYa9jE1EpfdjscRz0TfEVfqx8Y4Yotf8zL1Wsld5 dyjg+xLI0/f716V4cj0HshUUbVV6WcD126apzK3/jvyLRwpPTcAJgU17SCQkWQdwYDue hdmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Cded5Gje; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id l30-20020a63ba5e000000b005b861478b70si13298564pgu.341.2023.11.28.13.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 13:41:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Cded5Gje; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 14A77807D42F; Tue, 28 Nov 2023 13:40:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344804AbjK1Vk1 (ORCPT + 99 others); Tue, 28 Nov 2023 16:40:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjK1VkZ (ORCPT ); Tue, 28 Nov 2023 16:40:25 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52943AF for ; Tue, 28 Nov 2023 13:40:31 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1cf7a8ab047so46540705ad.1 for ; Tue, 28 Nov 2023 13:40:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701207631; x=1701812431; 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=Y7WtPwx8R41CBpic3+n2/ppAFMVmBycWDouGl52CdYE=; b=Cded5GjeiRvP8FmVaTNAkOTsvBgLg0RUOr0dNLlcDn6uzNeSqOzge5GakbuAQtYfHv Y8A33OD3UR9clg0H3XBJTJqsRCDCkBZjtOwQvatqQCrtFnYADgakYFKwx0tl0ROEHqpl bdtBMqsQgNYBXoMG4lpdLvmW5/3AzOmfVR878= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701207631; x=1701812431; 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=Y7WtPwx8R41CBpic3+n2/ppAFMVmBycWDouGl52CdYE=; b=voeDiWSaf1TZxcwz6Wen2Zm2vBf7dmoMyZUIdXX3T3XeSxos9k/Hy0QqU9AXfjG+JI ffSDKGLhKnrNDFcTe5hTeAIALHqmnPMzdtyJHKh48lDI6YyRrsU7h5i+OPZoTKMrE3b8 KZSX5zcTO9CslCPWD0aiMLD72KWJNOgTcxD9eMCjUI/gOep/2dibyOntHv1auT+9n+PY nsWPa4S3OdHj+SwrR8qatUhdFJw7T9cWfH3Wrn+JxJbCkULlUjlg8s4zgZFdfUxl2Hy1 33Upgfo6/syjiQtD8pO3i+j3PMTWpEorixUlO5UVQzSJiZg3VDtFzFWARG1/tHBm4Dg0 YSDw== X-Gm-Message-State: AOJu0Yz1idG4ZSliPkRuYrSRRnVAVTDgMDztKWF2EhQE39AfBL6NM0P0 JldGANg52Qa2jKN1Iuq09rI2oSDwuijHEvdQqrpWRS5J X-Received: by 2002:a17:90b:314a:b0:285:ada5:94e with SMTP id ip10-20020a17090b314a00b00285ada5094emr12093978pjb.32.1701207630705; Tue, 28 Nov 2023 13:40:30 -0800 (PST) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:fc3a:13ce:3ee3:339f]) by smtp.gmail.com with ESMTPSA id ie24-20020a17090b401800b002609cadc56esm9634285pjb.11.2023.11.28.13.40.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 13:40:29 -0800 (PST) From: Douglas Anderson To: Jakub Kicinski , Hayes Wang , "David S . Miller" Cc: Laura Nao , Edward Hill , Alan Stern , Grant Grundler , linux-usb@vger.kernel.org, Simon Horman , Douglas Anderson , =?utf-8?q?Bj=C3=B8rn_Mork?= , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net v2 1/5] r8152: Hold the rtnl_lock for all of reset Date: Tue, 28 Nov 2023 13:38:10 -0800 Message-ID: <20231128133811.net.v2.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog 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,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 pete.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 (pete.vger.email [0.0.0.0]); Tue, 28 Nov 2023 13:40:37 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783845539570667873 X-GMAIL-MSGID: 1783845539570667873 As of commit d9962b0d4202 ("r8152: Block future register access if register access fails") there is a race condition that can happen between the USB device reset thread and napi_enable() (not) getting called during rtl8152_open(). Specifically: * While rtl8152_open() is running we get a register access error that's _not_ -ENODEV and queue up a USB reset. * rtl8152_open() exits before calling napi_enable() due to any reason (including usb_submit_urb() returning an error). In that case: * Since the USB reset is perform in a separate thread asynchronously, it can run at anytime USB device lock is not held - even before rtl8152_open() has exited with an error and caused __dev_open() to clear the __LINK_STATE_START bit. * The rtl8152_pre_reset() will notice that the netif_running() returns true (since __LINK_STATE_START wasn't cleared) so it won't exit early. * rtl8152_pre_reset() will then hang in napi_disable() because napi_enable() was never called. We can fix the race by making sure that the r8152 reset routines don't run at the same time as we're opening the device. Specifically we need the reset routines in their entirety rely on the return value of netif_running(). The only way to reliably depend on that is for them to hold the rntl_lock() mutex for the duration of reset. Grabbing the rntl_lock() mutex for the duration of reset seems like a long time, but reset is not expected to be common and the rtnl_lock() mutex is already held for long durations since the core grabs it around the open/close calls. Fixes: d9962b0d4202 ("r8152: Block future register access if register access fails") Reviewed-by: Grant Grundler Signed-off-by: Douglas Anderson --- In response to v1 Paolo questioned the wisdom of grabbing the rtnl_lock in the USB pre_reset() and releasing it in the USB post_reset() [1]. While his concern is a legitimate one because this looks a bit fragile, I'm still of the belief that the current patch is the best solution. This patch has been tested with lockdep and I saw no splats about it. I've also read through the usb core code twice and I don't see any way that post_reset() won't be called if pre_reset() was called, assuming that the pre_reset() doesn't return an error (we never return an error from pre_reset()). If folks have some example of something that's broken by the current rtnl_lock strategy used by this patch (or if folks feel very strongly that it needs to be changed) then I can spin another version. ...but as per my reply to Paolo [2] I think that does have some minor downsides. [1] https://lore.kernel.org/r/f8c1979e2c71d871998aec0126dd87adb5e76cce.camel@redhat.com [2] https://lore.kernel.org/r/CAD=FV=VqZq33eLiFPNiZCJmewQ1hxECmUnwbjVbvdJiDkQMAJA@mail.gmail.com Changes in v2: - Added "after the cut" notes about rtnl lock strategy. drivers/net/usb/r8152.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 2c5c1e91ded6..d6edf0254599 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -8397,6 +8397,8 @@ static int rtl8152_pre_reset(struct usb_interface *intf) struct r8152 *tp = usb_get_intfdata(intf); struct net_device *netdev; + rtnl_lock(); + if (!tp || !test_bit(PROBED_WITH_NO_ERRORS, &tp->flags)) return 0; @@ -8428,20 +8430,17 @@ static int rtl8152_post_reset(struct usb_interface *intf) struct sockaddr sa; if (!tp || !test_bit(PROBED_WITH_NO_ERRORS, &tp->flags)) - return 0; + goto exit; rtl_set_accessible(tp); /* reset the MAC address in case of policy change */ - if (determine_ethernet_addr(tp, &sa) >= 0) { - rtnl_lock(); + if (determine_ethernet_addr(tp, &sa) >= 0) dev_set_mac_address (tp->netdev, &sa, NULL); - rtnl_unlock(); - } netdev = tp->netdev; if (!netif_running(netdev)) - return 0; + goto exit; set_bit(WORK_ENABLE, &tp->flags); if (netif_carrier_ok(netdev)) { @@ -8460,6 +8459,8 @@ static int rtl8152_post_reset(struct usb_interface *intf) if (!list_empty(&tp->rx_done)) napi_schedule(&tp->napi); +exit: + rtnl_unlock(); return 0; } From patchwork Tue Nov 28 21:38:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 171000 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp4244483vqx; Tue, 28 Nov 2023 13:41:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFKNwG3KqhLZETzx+yZYeZMqbvUy+8cb1VPKQtcVnlPJR3RGfVq5ubZaJCY4orCstlPP+un X-Received: by 2002:a05:6a00:1813:b0:6be:43f8:4e0b with SMTP id y19-20020a056a00181300b006be43f84e0bmr16814292pfa.24.1701207667690; Tue, 28 Nov 2023 13:41:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701207667; cv=none; d=google.com; s=arc-20160816; b=NE73lC4VzaQVEnZa5F+YhWDdr71YFtBihMmIIkDnuZSH545fcvN7OV85JI8jZ7ZCGc JwN8+Zgq481Fl0MrW6XsXOVHGiyUek91KLy1wTLxsuyp5uB68SqXN7A+zhuvOsen0KPC uAmpp1T0nNIKlKdsCHegH0AEE9Jl14m0t1j1patSHW/lVtr1amjtZ5+PNLnkXlzHYYVO EUK9E+9tl2ukN8efEMgIIVDT84g6l7dfAu7Xw1oBmBQlafVxrjo/W7d8eLnya4kMZppi wDSRyQFSzKQU9FGH97Pxw3+Ebw13E1lWUHoCg/q6YtuxdzPm0hzmty78hhHa+oo4gP30 rwHQ== 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=CTf7laEeUj3qSMIeKUNEYkxSf/20WZAuUqY6YHsPieM=; fh=D9dulkN/zvJqgx62bWffkTYlpM2spfXLLqBXpsKZOmw=; b=en55ejcxxJS6rR6R/LQV/hB22UhmrUMs2esF3qJ1h+q7A+qZoT2t6tgSy9FY5cetGo qv2madJAue8fG8gQ9y1YubVrIjX9z5VXJaYbN6Un31kIOqx2ZM6qFpGn15/idQVy4pgO +SInvf5eVbVzNMQ1b3w2G1JDGktKMZ5VbBYF7QgkAXZD39k6na0fQJsUERsZJvnPXLOB /+f9ho1ofFi8fIQcbcey2e57ZQrJklK3uCL8crckeKiCepYv6Issl1ET6F1L5Q7suDYE cWYKZo0kjZdeoocmEW6deArilIaqCQBcdMub+MBaN5tlAcX+7GCg5tDxfoKtV2QvxbQm 9bXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Khu2gVAl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id s13-20020a63e80d000000b005c212ebb55csi13168123pgh.691.2023.11.28.13.41.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 13:41:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Khu2gVAl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 9BFE880A418B; Tue, 28 Nov 2023 13:40:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345696AbjK1Vk3 (ORCPT + 99 others); Tue, 28 Nov 2023 16:40:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbjK1Vk0 (ORCPT ); Tue, 28 Nov 2023 16:40:26 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07F68BD for ; Tue, 28 Nov 2023 13:40:33 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-285be6134ecso2293420a91.2 for ; Tue, 28 Nov 2023 13:40:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701207632; x=1701812432; 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=CTf7laEeUj3qSMIeKUNEYkxSf/20WZAuUqY6YHsPieM=; b=Khu2gVAlHD+csXXo0q1xO4/jkNS+ILEY+a2xvftWq4m/28tdnrOepKj1qgU7HZ1d6T oaXEBgQY6M/H4A8WW9JpF9T5tTfuJeQ5+NOBhTlRE4XDuohHbiU7c3uIuNHTloaBsWcT /D0AlcRn/ZXvbP6IiJVuyOCcugMFRU3SzLjWs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701207632; x=1701812432; 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=CTf7laEeUj3qSMIeKUNEYkxSf/20WZAuUqY6YHsPieM=; b=mT1g6ZWS7idKSIAXjGF1qFGQK+2uhh/4wBC69yvjuzI8Y9FaloaveAWBg+SJ/CV7G7 isYinCYDaj8O8HCfisHsRjjIjkmV9TAOlYh+3InhPFTcwB505+6dHx7aBEzaawPlAJde uMWo8QNO+688Y6+9VohDI5XsJsFUVkuZavwFBBdRWtLsOOUjBnXheR+aWtlTrl7vyxvH AMxawSnYJH9jdT1V8lCXlXxOpWyq7R4i6ZmLz5YzJ0F63E/mTPZoHYuOFFwxzmFk0j5P n85za2ZRFGD7WszWXo4Wd9yUyCufL5kXTdDU1EyFAfS1aLk7UHy62oF7SP587H2Ny9/r j3TQ== X-Gm-Message-State: AOJu0Yy0jpZa1MCkHuEEruv+jHwe/Y83Bk5T0O5UH61ITR4ioncsw99d pPZDr4uwLy227BbmA3nM4xZp2w== X-Received: by 2002:a17:90a:d14f:b0:285:8a2a:1744 with SMTP id t15-20020a17090ad14f00b002858a2a1744mr15751836pjw.0.1701207632515; Tue, 28 Nov 2023 13:40:32 -0800 (PST) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:fc3a:13ce:3ee3:339f]) by smtp.gmail.com with ESMTPSA id ie24-20020a17090b401800b002609cadc56esm9634285pjb.11.2023.11.28.13.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 13:40:32 -0800 (PST) From: Douglas Anderson To: Jakub Kicinski , Hayes Wang , "David S . Miller" Cc: Laura Nao , Edward Hill , Alan Stern , Grant Grundler , linux-usb@vger.kernel.org, Simon Horman , Douglas Anderson , =?utf-8?q?Bj=C3=B8rn_Mork?= , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net v2 2/5] r8152: Add RTL8152_INACCESSIBLE checks to more loops Date: Tue, 28 Nov 2023 13:38:11 -0800 Message-ID: <20231128133811.net.v2.2.I79c8a6c8cafd89979af5407d77a6eda589833dca@changeid> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231128133811.net.v2.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> References: <20231128133811.net.v2.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> 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,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 fry.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 (fry.vger.email [0.0.0.0]); Tue, 28 Nov 2023 13:40:42 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783845531337005840 X-GMAIL-MSGID: 1783845531337005840 Previous commits added checks for RTL8152_INACCESSIBLE in the loops in the driver. There are still a few more that keep tripping the driver up in error cases and make things take longer than they should. Add those in. All the loops that are part of this commit existed in some form or another since the r8152 driver was first introduced, though RTL8152_INACCESSIBLE was known as RTL8152_UNPLUG before commit 715f67f33af4 ("r8152: Rename RTL8152_UNPLUG to RTL8152_INACCESSIBLE") Fixes: ac718b69301c ("net/usb: new driver for RTL8152") Reviewed-by: Grant Grundler Signed-off-by: Douglas Anderson --- Changes in v2: - Added Fixes tag to RTL8152_INACCESSIBLE patches. - Split RTL8152_INACCESSIBLE patches by the commit the loop came from. drivers/net/usb/r8152.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index d6edf0254599..5a9c5b790508 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -3000,6 +3000,8 @@ static void rtl8152_nic_reset(struct r8152 *tp) ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CR, CR_RST); for (i = 0; i < 1000; i++) { + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) + return; if (!(ocp_read_byte(tp, MCU_TYPE_PLA, PLA_CR) & CR_RST)) break; usleep_range(100, 400); @@ -3329,6 +3331,8 @@ static void rtl_disable(struct r8152 *tp) rxdy_gated_en(tp, true); for (i = 0; i < 1000; i++) { + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) + return; ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); if ((ocp_data & FIFO_EMPTY) == FIFO_EMPTY) break; @@ -3336,6 +3340,8 @@ static void rtl_disable(struct r8152 *tp) } for (i = 0; i < 1000; i++) { + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) + return; if (ocp_read_word(tp, MCU_TYPE_PLA, PLA_TCR0) & TCR0_TX_EMPTY) break; usleep_range(1000, 2000); @@ -5499,6 +5505,8 @@ static void wait_oob_link_list_ready(struct r8152 *tp) int i; for (i = 0; i < 1000; i++) { + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) + return; ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); if (ocp_data & LINK_LIST_READY) break; From patchwork Tue Nov 28 21:38:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 171003 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp4244560vqx; Tue, 28 Nov 2023 13:41:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfWyzJR7wwVg5b0FDR9hwH1MAFdFATFJtip1dBTrNKunAzkwy2yB3n21F1spGHQILfrsZB X-Received: by 2002:a05:6808:101:b0:3b8:4127:e48d with SMTP id b1-20020a056808010100b003b84127e48dmr18696979oie.21.1701207678757; Tue, 28 Nov 2023 13:41:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701207678; cv=none; d=google.com; s=arc-20160816; b=RnuMavoCwMTapwCpqRg6+dij+9Tk8dMts99XOsXnpbzVFxKsKsXe0iq3IiEOgn4ct2 PldHdii6InzpwY9f4OyrzpL4Q8ggPlclJEbV6vCkV9NQ1bEXR9eAxg+wivt//Vx9VNcU jWx1dpY73gZ4EvsG59Yhn/yUi71/YJd+5XBXuIalXtDXG0/De1M+a/wxj5W2C9NNxOhu Fa9sVSYq8Ru9gHp0vYA4cTkl6W8iuBOZ4yVFLzt1Ve+7YUud6/jgNttafqKl9oj0ewqP d/JZwwT/Y+cVTzESCViCb0Qqze7pq7UTIVAbSosrYcbtN2aDemWO8NmEXgaOSr0myfDm KjPg== 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=oQusyzrWbRXd2hWyvgtHM4eFYw/jkvHj52PFedjE4u8=; fh=D9dulkN/zvJqgx62bWffkTYlpM2spfXLLqBXpsKZOmw=; b=FfL+PmG7ta8j/U5BxQZqv4w6Tvzmem1kz7ih8UkE4KstEMoDOSc6rq/hNMnD/89ODc kmHDnpU4MCZCCuSJq7OtYczUjNTFeLD0MonAI5u2vWfOY7lwFfEuz8huzYCyomtZHdMg 9ha5J0OyCwBvvDljnBEEVfoHaNRph6kD/iHeyx8OjqseE3Osz/4S4Ugokish5ZZH3mjS LQ6lAp3gGN6CuCD9eZ7KJ8C8FwCCIbOt6jckd7a/Dv8ztFbmvok03FbumBuu1cRjq9O2 3L+lgutrAOFiu5luhZu5A8HtOz2hJ9yq289tzM13MzILuEJMqKGH31WvhdgQyesFRvB4 sgqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MNzPDxQQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bw9-20020a056a02048900b005bdf5961d93si14556327pgb.387.2023.11.28.13.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 13:41:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MNzPDxQQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id DA68F80A418C; Tue, 28 Nov 2023 13:41:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346327AbjK1Vkd (ORCPT + 99 others); Tue, 28 Nov 2023 16:40:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjK1Vk3 (ORCPT ); Tue, 28 Nov 2023 16:40:29 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D94F99 for ; Tue, 28 Nov 2023 13:40:35 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1cfc2d03b3aso23062885ad.1 for ; Tue, 28 Nov 2023 13:40:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701207635; x=1701812435; 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=oQusyzrWbRXd2hWyvgtHM4eFYw/jkvHj52PFedjE4u8=; b=MNzPDxQQog82ruT0Pm86elahz2XWC9NgB+Nn6hJoKHKqMOhqgb6dksbftGKJSRVUSQ VWZZ5tdg8mEjIfj32a1vIinHRAVpbvALXGQ4Ncaboa0w8S1Ji6/AG49Un6J1PfJD3x8I a+EQtpP0JeS4nbS5CHHQgkxMAo2TmA3RGWD6E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701207635; x=1701812435; 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=oQusyzrWbRXd2hWyvgtHM4eFYw/jkvHj52PFedjE4u8=; b=joChyCfNrgUd6JLo2xm4SlE7Df2OPk3/gw0PkPk+W6h4UTv8hdMDUIQKLlwK7bGk2F EOnt1lTDygJKVAx9q8ZTUXDEjFFICXb6VTf9YUMxwfr0LKW+GI8t+vSY+jpH1DVMdHHP wOlTPQ6tdeL9o8nxIDeHy9xZEUd7gmukIGS2Waj4POKWVT5DGY2YhzvRyWxaT1OMCo+J AEBLhlp/9VsLvD2BV0UVYjhhKILhEr++zrpvyg2UHAfLBQ1L0s0E0FrUTiCeigKyJoBW mTZZv18KOTmStc2hNYJzT0cddWRc+ISJmZRh5BrCJKTQvABsnVI4HDhVS9Pdwx0Lo5ny FwDw== X-Gm-Message-State: AOJu0YxnPyKUdIhhPmBANPUOknQoCapVgCBqCcry8LGNPPnNye3n4O+I xVeeSJ5PnGrpZm7rmgk+Gd6lM6hnaxMgxC22qmQDSzyp X-Received: by 2002:a17:90b:3846:b0:285:9408:2fb8 with SMTP id nl6-20020a17090b384600b0028594082fb8mr15411756pjb.43.1701207634922; Tue, 28 Nov 2023 13:40:34 -0800 (PST) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:fc3a:13ce:3ee3:339f]) by smtp.gmail.com with ESMTPSA id ie24-20020a17090b401800b002609cadc56esm9634285pjb.11.2023.11.28.13.40.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 13:40:34 -0800 (PST) From: Douglas Anderson To: Jakub Kicinski , Hayes Wang , "David S . Miller" Cc: Laura Nao , Edward Hill , Alan Stern , Grant Grundler , linux-usb@vger.kernel.org, Simon Horman , Douglas Anderson , =?utf-8?q?Bj=C3=B8rn_Mork?= , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net v2 3/5] r8152: Add RTL8152_INACCESSIBLE to r8156b_wait_loading_flash() Date: Tue, 28 Nov 2023 13:38:12 -0800 Message-ID: <20231128133811.net.v2.3.Ib839d9adc704a04f99743f070d6c8e39dec6a1aa@changeid> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231128133811.net.v2.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> References: <20231128133811.net.v2.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> 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,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 fry.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 (fry.vger.email [0.0.0.0]); Tue, 28 Nov 2023 13:41:16 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783845542695358927 X-GMAIL-MSGID: 1783845542695358927 Delay loops in r8152 should break out if RTL8152_INACCESSIBLE is set so that they don't delay too long if the device becomes inaccessible. Add the break to the loop in r8156b_wait_loading_flash(). Fixes: 195aae321c82 ("r8152: support new chips") Reviewed-by: Grant Grundler Signed-off-by: Douglas Anderson --- Changes in v2: - Added Fixes tag to RTL8152_INACCESSIBLE patches. - Split RTL8152_INACCESSIBLE patches by the commit the loop came from. drivers/net/usb/r8152.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 5a9c5b790508..b7bbebf09d85 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -5521,6 +5521,8 @@ static void r8156b_wait_loading_flash(struct r8152 *tp) int i; for (i = 0; i < 100; i++) { + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) + return; if (ocp_read_word(tp, MCU_TYPE_USB, USB_GPHY_CTRL) & GPHY_PATCH_DONE) break; usleep_range(1000, 2000); From patchwork Tue Nov 28 21:38:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 171004 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp4244746vqx; Tue, 28 Nov 2023 13:41:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IGEjQ0BJTjeCyWXCtslTTOakJ7Um1eLZ9gG6RgPzpIkMvUxt4qHpnUIZ7gbrHDq85+L/Vgs X-Received: by 2002:a05:6a20:4423:b0:187:a6ee:9d6f with SMTP id ce35-20020a056a20442300b00187a6ee9d6fmr29335343pzb.0.1701207707596; Tue, 28 Nov 2023 13:41:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701207707; cv=none; d=google.com; s=arc-20160816; b=lY8DTX4VaT7Urnt4Or9YMxjel/wMUyctXm6wab19IfM8VTxfyL7FxP/09DZ5rEDzKG Ie5zHcFLMPuaWfQHI6ZCeNmxvUL4LCEjwlVTqxc+mo8WgQRvy9npDyRW98VT0RPP+Vu8 ggMekAkF1HnUviUVz5sj5Ur5UCQ2fStsxW9ibiU4jKa8wuE0D4FnlvvuJHcpptqk03Is Dt6S8Agv34jzzxVWceZUBwzMmFcbyV0bozdwqv8e7OsfNXXSAspP003PUAnIQd3rl97C q2X49sota+13SxILa3/iotRhQCWlaXBJUVAJYX+E5Y0X7SzJOsog6q+D4DjORuPSQb1u PMlA== 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=fdYFcaVqzynOfnyusz8jDR2UhNqPzUcp03x21uK643I=; fh=22hb6jpa3U0O3+lqzBmww6ef3+b+RiaWxLVxVjCvsvk=; b=o2dn4ygTpejZY+iu3t3JKZIA4Nj5mZrCZSp3lM5rsdWLtMKMqJ6oSI4kE4cRUvnWZ1 JyMQnGG3+TlJTB8mVXj4feUYO5r77ETUvkxDOK5t5Y6K5cf1L/refplwbbDxzbfKSqsA ayNeihk5+bjjL3xV/nFpSWLSTknvlqnZ8s8LXPSIylXqYKkIrd30lJFqqcV3M3hWhAt7 0wmMp8brVMgQDAfa6kNlbxyX7RhEGIQ4KpGDdRdOeJZ6j0hftt51mpmKSE+8kis4A72v ZXdwwI5dCmZQbTjEAfwRDUWTsmPTSxfc1VVsYAJ7+Rcih/u2rtGs0SRap5BYBHSmTB6Y O3cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KwXj6vzw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id g23-20020a63f417000000b005b106cd44d1si12890166pgi.486.2023.11.28.13.41.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 13:41:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KwXj6vzw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 3642C8090054; Tue, 28 Nov 2023 13:40:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346561AbjK1Vkh (ORCPT + 99 others); Tue, 28 Nov 2023 16:40:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346227AbjK1Vka (ORCPT ); Tue, 28 Nov 2023 16:40:30 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F988AF for ; Tue, 28 Nov 2023 13:40:37 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-285699ebabcso194519a91.0 for ; Tue, 28 Nov 2023 13:40:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701207637; x=1701812437; 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=fdYFcaVqzynOfnyusz8jDR2UhNqPzUcp03x21uK643I=; b=KwXj6vzwnAzCxZVnBkxy9sUifv4hVmU8/mAmFjpVsWTM2piSNBFene7KvluylT9APd EmtauclLAcFPAbqT53jQakuUt0y1jMNFS2P12ktGFM35hqutbY9oIGAGQdPO9c+YPFQM Fkd398kFP06nTYMPl47Y1cQNG4yt/aPLfVUeM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701207637; x=1701812437; 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=fdYFcaVqzynOfnyusz8jDR2UhNqPzUcp03x21uK643I=; b=t8u+ACvtZglO5NPVUj1W4CzZWjUAvNA74x16L5fHSNoI7kZyDrsXhNF8s0abZ8uVYN lRRv1JycAtx/vunBeOnvzX/QM+CayyZUh7Gk5m/4RY46GrqJiz27Pvu8ntW0+7c+/SrW OtJCtfd0eTZ6h+jT3RW3Xmks6U9ZkixrFZ8n3mDUxCsXXStswmEmv9NQTU4ne9Sg/kdC D4C6IfSXYYD7Co/LX1OOr9wol87D0H6+7iwNy0e8keZ9iODPcF9MAVpxFzpy6IkdfhaV NZaxg/tu4XxtjvQxUYvUZOU8zvPK/vrh0x5v7Gpz75cNmeQIOEGqjjb0I1G1BN+GdXz7 BS/w== X-Gm-Message-State: AOJu0YzCa4dm7kbo3WKbnCPfLqEZZtSe/21PYBaDl8oK0givOEmNxj3v /kXxF6q6BDC3U88Z35xOxMk/Mg== X-Received: by 2002:a17:90a:ce81:b0:281:3a5:d2ec with SMTP id g1-20020a17090ace8100b0028103a5d2ecmr27744675pju.8.1701207636843; Tue, 28 Nov 2023 13:40:36 -0800 (PST) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:fc3a:13ce:3ee3:339f]) by smtp.gmail.com with ESMTPSA id ie24-20020a17090b401800b002609cadc56esm9634285pjb.11.2023.11.28.13.40.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 13:40:36 -0800 (PST) From: Douglas Anderson To: Jakub Kicinski , Hayes Wang , "David S . Miller" Cc: Laura Nao , Edward Hill , Alan Stern , Grant Grundler , linux-usb@vger.kernel.org, Simon Horman , Douglas Anderson , =?utf-8?q?Bj=C3=B8rn_Mork?= , Eric Dumazet , Paolo Abeni , Prashant Malani , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net v2 4/5] r8152: Add RTL8152_INACCESSIBLE to r8153_pre_firmware_1() Date: Tue, 28 Nov 2023 13:38:13 -0800 Message-ID: <20231128133811.net.v2.4.I9c7bfe6fb76850f0323b3996e25a10ef0281fb7a@changeid> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231128133811.net.v2.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> References: <20231128133811.net.v2.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 28 Nov 2023 13:40:55 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783845573221545934 X-GMAIL-MSGID: 1783845573221545934 Delay loops in r8152 should break out if RTL8152_INACCESSIBLE is set so that they don't delay too long if the device becomes inaccessible. Add the break to the loop in r8153_pre_firmware_1(). Fixes: 9370f2d05a2a ("r8152: support request_firmware for RTL8153") Reviewed-by: Grant Grundler Signed-off-by: Douglas Anderson --- Changes in v2: - Added Fixes tag to RTL8152_INACCESSIBLE patches. - Split RTL8152_INACCESSIBLE patches by the commit the loop came from. drivers/net/usb/r8152.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index b7bbebf09d85..26db3f6b3aa1 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -5645,6 +5645,8 @@ static int r8153_pre_firmware_1(struct r8152 *tp) for (i = 0; i < 104; i++) { u32 ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_WDT1_CTRL); + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) + return -ENODEV; if (!(ocp_data & WTD1_EN)) break; usleep_range(1000, 2000); From patchwork Tue Nov 28 21:38:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 171001 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp4244524vqx; Tue, 28 Nov 2023 13:41:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IHK2latvLq/2TlctUXaiQzDkY7+rTKIv+eY6SqsnVrcfGPr3LwfIFjMMpej/4MDIlro5ghW X-Received: by 2002:a17:902:c405:b0:1cf:a70f:3a2d with SMTP id k5-20020a170902c40500b001cfa70f3a2dmr20379796plk.63.1701207675360; Tue, 28 Nov 2023 13:41:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701207675; cv=none; d=google.com; s=arc-20160816; b=z8Kgi5KRM00nsm6c+4EwC4jY3i2ax2vV2iYlANZthzYAamHdBLqwcu9W75KcLrqsh8 54fdbUW2lRYAjSlc8LP6bz+oJ2uDFwNnDk4BZbZw5UMaPjvGcd9pIAS4m1LLvXatyka6 QDep8SltBVd1mozn1ZFf2eEhXkJEAkIoRMFOCi933WlruLSe5jpN0okYMTV+s0178uyE EJegJSVZRveuGzucNLnHCRvfWRJlHhPWyYY95AXpG34nXVPWB66mmHKOFjYwXhSbFmOu XaFs6MmceEzCgdArigvwuxdYtbAFfP1AHY6YnQHfwIsdwFYeOaOy+BiV6CPuYSkGB9yU GYMA== 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=NQpgB0hpYD1c6hlujz/aWaKFzOCbCq1mG9ijFrvdnyY=; fh=D9dulkN/zvJqgx62bWffkTYlpM2spfXLLqBXpsKZOmw=; b=F4brsL33NGae33HQ3mQYmrsiEUimolglOlhFQU6Z0cNN9TLSLRn+PF1M4T/KPRknsa sIbJbnJN4PpVWlm4gm8692rTpwPi/fCd2CPSh8YxgLbJhHnm4SsOXWbFKsy8Q7ElmVrU S4La9KkaEqVoo4UKRnkQZrQZ+uzSiuvYrZAoVtYqC4oH2QL1J3LssV/IWzftabNf+rDN 7vj+iexVDMwCmof8h49EF59lAJ9zFLNuHo5nqyE38jZBJVMTU7yZcgeaXA0ZNuelNi53 WDlXiwcQ9QcpbcahscfscBnKPVHrVzjoje/FwnUTvn2tPudxD83MMpK7/Yg+a2UQ4UJw MErQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=QKBAge7S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id u13-20020a170903124d00b001b045d65aedsi13086234plh.228.2023.11.28.13.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 13:41:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=QKBAge7S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 076D9807F48A; Tue, 28 Nov 2023 13:40:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234935AbjK1Vkp (ORCPT + 99 others); Tue, 28 Nov 2023 16:40:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346486AbjK1Vkf (ORCPT ); Tue, 28 Nov 2023 16:40:35 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4235D100 for ; Tue, 28 Nov 2023 13:40:39 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-285b926e5deso3019388a91.0 for ; Tue, 28 Nov 2023 13:40:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701207639; x=1701812439; 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=NQpgB0hpYD1c6hlujz/aWaKFzOCbCq1mG9ijFrvdnyY=; b=QKBAge7SioihvVYTJUi05Yn5Bn9zeEOnfUYcXt3FvjWfrjySzZRNsKb9E3gQUikNpE 0VWMg4qMHdBvsMqsZEtXSNGLUByzNdV/d+Q0YxbyXZTChLYxKjE8+H13qpuZjm5hCB5v 1RH/TcQydFs38goys7py72n3XAbLte1AHFJcw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701207639; x=1701812439; 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=NQpgB0hpYD1c6hlujz/aWaKFzOCbCq1mG9ijFrvdnyY=; b=G5rhau3WcMLWQOst1mw3XFkMLAn7rpzz+cXvrIjYsYD7oR+asLlFH5B8GzgPLAFCyh X8Mq5dLhDFFnXjG/z1mD2apOgPswzvnH+DF3uFcr6JqWMCatAQql/UFq/z2EgcZOJHGH gYp7ICujYe6ew6h51LG+p84fjiyNkCcc0gwucMlkWKTIVSmbh4kRpjN0//07H0afZ9r9 O3SST2h20rBp+ZucQzh4YqwGsU/KgNGT0jJR0f3Ig4WankQOsVDnv2HBlffGW3q67J9s zNQ7B95vyhA6H7mG6DnuNZWYX+efxKCLLdpJB7yPLxI3oBX3fVAdc72GLDeH/JHGyGIK buQQ== X-Gm-Message-State: AOJu0YwLG826pr9IEBwKBNMTe9JdExf6FxiA3UvCSVb5HRCgy3/eit3I I18/xb7g6c6FUyRCA2yXeYTI5A== X-Received: by 2002:a17:90b:4c50:b0:285:8407:6152 with SMTP id np16-20020a17090b4c5000b0028584076152mr17639969pjb.8.1701207638788; Tue, 28 Nov 2023 13:40:38 -0800 (PST) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:fc3a:13ce:3ee3:339f]) by smtp.gmail.com with ESMTPSA id ie24-20020a17090b401800b002609cadc56esm9634285pjb.11.2023.11.28.13.40.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 13:40:38 -0800 (PST) From: Douglas Anderson To: Jakub Kicinski , Hayes Wang , "David S . Miller" Cc: Laura Nao , Edward Hill , Alan Stern , Grant Grundler , linux-usb@vger.kernel.org, Simon Horman , Douglas Anderson , =?utf-8?q?Bj=C3=B8rn_Mork?= , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net v2 5/5] r8152: Add RTL8152_INACCESSIBLE to r8153_aldps_en() Date: Tue, 28 Nov 2023 13:38:14 -0800 Message-ID: <20231128133811.net.v2.5.I1306b6432228404d6e61b2d43c2f71885292e972@changeid> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231128133811.net.v2.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> References: <20231128133811.net.v2.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> 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,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 howler.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 (howler.vger.email [0.0.0.0]); Tue, 28 Nov 2023 13:40:55 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783845539191291999 X-GMAIL-MSGID: 1783845539191291999 Delay loops in r8152 should break out if RTL8152_INACCESSIBLE is set so that they don't delay too long if the device becomes inaccessible. Add the break to the loop in r8153_aldps_en(). Fixes: 4214cc550bf9 ("r8152: check if disabling ALDPS is finished") Reviewed-by: Grant Grundler Signed-off-by: Douglas Anderson --- Changes in v2: - Added Fixes tag to RTL8152_INACCESSIBLE patches. - Split RTL8152_INACCESSIBLE patches by the commit the loop came from. drivers/net/usb/r8152.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 26db3f6b3aa1..aca7dd7b4090 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -5803,6 +5803,8 @@ static void r8153_aldps_en(struct r8152 *tp, bool enable) data &= ~EN_ALDPS; ocp_reg_write(tp, OCP_POWER_CFG, data); for (i = 0; i < 20; i++) { + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) + return; usleep_range(1000, 2000); if (ocp_read_word(tp, MCU_TYPE_PLA, 0xe000) & 0x0100) break;