From patchwork Wed Nov 29 21:25:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 171569 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp628674vqn; Wed, 29 Nov 2023 13:26:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IH55Lug29gy8Wi7KELgojtHQLlOn2gQE3AVGJzDf49H3vFUAlSgfn+cQEzokTJeNU/zh3gv X-Received: by 2002:a05:6a20:5521:b0:18a:de88:e0d with SMTP id ko33-20020a056a20552100b0018ade880e0dmr16609753pzb.15.1701293192952; Wed, 29 Nov 2023 13:26:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701293192; cv=none; d=google.com; s=arc-20160816; b=ZK5NaZ8xEZDAvc7e7+hXQQFqkIROJ1jeFZ784EwyERNkKZ4JwS0YHRi8YHfCHM1Ksi /iEGcPtncfsveF4GJb+PeLFeGx2ib7SYCAgJh/dtJ7x5csWlMI4Mejte+0cAFbQa4EML 4otEj7f4hha8/6hQEc5NpmYnFd2M8XVdk2dU5mVARhk2ISITVpIYSV405r4knkNg1+Os XAX5+82gb8tt9qbfr4y7OE7a307zdHzmVU2sJA4ZtUXKoGxpUQsXsuZfsX6gE1XxQtkL O4tg0Edc6S6mcNTgs02EkqAHzS7+p7B7lYhbGRgg1ZaCLpG9Uci+J9Pzw78Q5xpuiZvG DHeQ== 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=7sCyYkRoGgiDRrKxcp8ji3Yt467zSBtV+G7Y08/1tlE=; fh=mRHaPBoaK/yKIiTe7zbQTMuaXdIOIrIp8KgHhHuSvhs=; b=hiyvrBwHXb/6qfvyFCbyuw1WRXe+FaE+M6zJcSaeKD4yxwqzoG/bMIZ9p0obU9yEyW yT4kZZfUasgGuodx4aEc52hokd0A9esJxfdwYD4x/WBq5u74CQTqSmAwkyxBVgjJUA/S xxGzgApjB0VvNOCm9d0ej1cBuwhMVqnlqRf6B407O4/txugRA7ZeyLDymBtUELFMnIxY NqmKIkPf69fosbAm13DHxJNxUFUunW7oZi30lgc7dp+81rMMPCEZpLtg4JW7DDXCfk8Y SLS1NfdYD9A9N3xjxJxoM43pOXJQFwuyMc/9HLqbosDAROsGmrqFk7oF57/pt00rxg8X 3ERA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dVKQ8Mix; 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id y15-20020a056a00190f00b006cbe3c123a6si15056558pfi.9.2023.11.29.13.26.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 13:26:32 -0800 (PST) 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=dVKQ8Mix; 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 7698D80C6E94; Wed, 29 Nov 2023 13:26:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233852AbjK2V0T (ORCPT + 99 others); Wed, 29 Nov 2023 16:26:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbjK2V0S (ORCPT ); Wed, 29 Nov 2023 16:26:18 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02DF410C3 for ; Wed, 29 Nov 2023 13:26:24 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6cd8ce7bf7fso261948b3a.0 for ; Wed, 29 Nov 2023 13:26:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701293183; x=1701897983; 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=7sCyYkRoGgiDRrKxcp8ji3Yt467zSBtV+G7Y08/1tlE=; b=dVKQ8MixDcLZ2oSabxC+7x6RrFJL047Gu8zum68hWW+AzR+BD2+QpqUDXLj1t1lzi+ 6nO4NRw2Uimzsl6KnyJue0QEKfJPTgWIhPXeGwgBWpjm1ccBT3edLWDkMjq/63+t8A4c Mfb2WNVDVoHz+YiVDdMjKxStJxLMVQFTl7B5c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701293183; x=1701897983; 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=7sCyYkRoGgiDRrKxcp8ji3Yt467zSBtV+G7Y08/1tlE=; b=tWJ/GwDAYHTpSyO0S1QEBusPaBFkipN6tOKST3tQ04ZduJ/a3fiFauEy6h36ER61Ng kdF0lpDQuFFOctndUpLQj1za9ZrfpLpKiJG+JcMFZz0LsIAOnWqGpX+nE+tygbHl8XFr xhkctTsGl/eE/827H0jYO53KhP+VrdA0oGG/UCMjTHH8NJH1YWwGmOxeln7BXbD6dmUw CInmPPy5E0JL8ISY6bFXES/ApxRYKqxXn4+4inwttLDwYX7v/tALpoEVlzyoLaqO9jMU qJmVJOXAwYERLWpxc135oKvn+dDbV971qHIqg5l3Ahed4NFNC1L0NbZwlkc5GiRUGDLx L/pA== X-Gm-Message-State: AOJu0YyeEKgqvv0d5g4pYMGzJtRwtaWabmIUwrUmJSUfa3+S6LjPqkVZ i3aXEX8Z9WzWVHyxiiQbZsN2jw== X-Received: by 2002:a05:6a20:3d0b:b0:18c:90f9:5084 with SMTP id y11-20020a056a203d0b00b0018c90f95084mr14166441pzi.27.1701293183515; Wed, 29 Nov 2023 13:26:23 -0800 (PST) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:dcf:15e4:5f50:e692]) by smtp.gmail.com with ESMTPSA id t22-20020a634616000000b005c215baacc1sm11816336pga.70.2023.11.29.13.26.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 13:26:23 -0800 (PST) From: Douglas Anderson To: Jakub Kicinski , Hayes Wang , "David S . Miller" Cc: linux-usb@vger.kernel.org, Grant Grundler , Laura Nao , Edward Hill , Alan Stern , 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 v3 2/5] r8152: Add RTL8152_INACCESSIBLE checks to more loops Date: Wed, 29 Nov 2023 13:25:21 -0800 Message-ID: <20231129132521.net.v3.2.I79c8a6c8cafd89979af5407d77a6eda589833dca@changeid> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231129132521.net.v3.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> References: <20231129132521.net.v3.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 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]); Wed, 29 Nov 2023 13:26:28 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783935211164776678 X-GMAIL-MSGID: 1783935211164776678 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 Acked-by: Hayes Wang --- Changes in v3: - Use `break` when we see RTL8152_INACCESSIBLE, not `return`. 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..e9955701f455 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)) + break; 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)) + break; 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)) + break; 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)) + break; ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); if (ocp_data & LINK_LIST_READY) break;