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;