From patchwork Fri Nov 17 21:08:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 166340 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp814841vqn; Fri, 17 Nov 2023 13:10:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdJyRnebphlgvV8efgPn0Gw4Gpi+Ze2G3C0x0d5XGPUxG5Yw7lgr7wfHdct89t6ZYB15YG X-Received: by 2002:a17:902:968f:b0:1cc:d981:a399 with SMTP id n15-20020a170902968f00b001ccd981a399mr786868plp.31.1700255437870; Fri, 17 Nov 2023 13:10:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700255437; cv=none; d=google.com; s=arc-20160816; b=ZbDCgkIuizRjqJpVP10v0JW0p3hD5svBInROlWu/lGwtNW0HlSZ2NZNRGpiyb8Hovo W6YMs5FPuXNy3NSFWhW7KtY9uhnxHC4r+jxjr/d0SVDmEXJUqNULJ7tOWR/LjKwzWBb7 s+1p/DtLwROlV+hyzWwWFnBlBpYPBDzRK00N2dDaFJ7xNHubTEikVbwoZszkGP2VTn6j HOZhBlzbWnASUEvMt/yN6issZRvWlgST3c1ywXztsjpNDh99ERzrBRme5RRVTLT9JKdn LtGEqh2dkOXfqCQY84UdfMnE2xaFnvUS0gb0zR1Rk85GK+7+IR1LKbFvplu00xwxwshV zU9w== 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=DL5piRnOOgGpwdkxQbi83S5rjEjfPe4DjTzZgACvY58=; fh=YpCq/PBTQvS6gw+eWmaXDTpICRmZ9tZKQpE2Dguby3c=; b=V1u50WQLVsg0pjwFSw78QZLEY5ix9TRQTZu2iihzFmR4PdGdzHTelxbs5dDxr5x9q0 YL3UydlfsXgw+9KMgSGm0PhM8yZfCHvJ0xGvIjfC0ZDFsq3RWhX9Anydl3yMO6ExS8HS HSOab4lyjGrXDYZudYJ9PKYIACYE6wXfhK4HSLk30JH1nxPCq/uZSx0m/KHN27xYB7Sn wqAjzcBw7pkkvNl/EC/gJQCioQ60um2KN77YG9rBKFw/AJj2a5i0SnVRW9JPIChNKJKC h0M+Li6kKCdLlFuSa3Ilqh6mUUkPMgtNz5ZG9KTic0z+I9p+bYMUDjHoNT7YhwpqGtvd JQww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EIyHVlKi; 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 u4-20020a17090282c400b001cc47d6f4absi2527397plz.107.2023.11.17.13.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 13:10:37 -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=EIyHVlKi; 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 21D47826751A; Fri, 17 Nov 2023 13:10:37 -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 S1346236AbjKQVKb (ORCPT + 29 others); Fri, 17 Nov 2023 16:10:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235563AbjKQVKX (ORCPT ); Fri, 17 Nov 2023 16:10:23 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1EE91735 for ; Fri, 17 Nov 2023 13:09:59 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6b20577ef7bso2241588b3a.3 for ; Fri, 17 Nov 2023 13:09:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1700255399; x=1700860199; 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=DL5piRnOOgGpwdkxQbi83S5rjEjfPe4DjTzZgACvY58=; b=EIyHVlKiSNhvyjB29Mm9SC2Cksbkw8cRh8ped9kyLt/tn60jK6yxzAb2qdMZtQdb1G 51IIH5TP0BVhDyAqHpBM6rPpMeXP3vUF8fDSc1FaRS9BnrfWDm95Rvvqu9qbD7y3X/+o hKacmxm77F7aStYWW/MvaHgM6GYgYNZbIt2Pw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700255399; x=1700860199; 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=DL5piRnOOgGpwdkxQbi83S5rjEjfPe4DjTzZgACvY58=; b=HdZFsIHwCpIdiB7erP4uTyXrwSnZORJaA/hyYWMYVD68fA4+eY5W4ca2/egMX4JYaI AMoccZIeOgB18Si+H7SY0jSYdVFmNHdkEXkiJxO4WJWY7ZulaJvNjNiqDwgVRFJ+ar/q FnKR9kDpqUKqFgWRkMWiQgy8JDZArYfviNuHBRNvdNwH2fDDVPvVJ/2T4oDLqaiXuKjf vKGNx4nJ1dK/COKQk0Re65OmbFWZOAYqVLTtbJvqJBXnBwGbNPx69k+OQUeLhhdFokA8 kbsrWPJQStq3JAA9DtcJ4SNTX4UhZvnApFHub+onmt1qlSkvlLKea+h1Zffo9LQVBcmh CXUw== X-Gm-Message-State: AOJu0YyuAufDmg1Mq55iBq5MYksuwhMdBbKUug77VDG99LtrODjnP+Yl r4cKCs+DVA3zY1UP/Yj9ztDyCQ== X-Received: by 2002:a05:6a20:bea5:b0:187:652d:95b5 with SMTP id gf37-20020a056a20bea500b00187652d95b5mr289192pzb.62.1700255398792; Fri, 17 Nov 2023 13:09:58 -0800 (PST) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:b953:95f4:4240:7018]) by smtp.gmail.com with ESMTPSA id h20-20020a056a00219400b006c624e8e7e8sm1780587pfi.83.2023.11.17.13.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 13:09:58 -0800 (PST) From: Douglas Anderson To: Jakub Kicinski , Hayes Wang , "David S . Miller" Cc: Grant Grundler , Simon Horman , Edward Hill , linux-usb@vger.kernel.org, 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 2/2] r8152: Add RTL8152_INACCESSIBLE checks to more loops Date: Fri, 17 Nov 2023 13:08:42 -0800 Message-ID: <20231117130836.2.I79c8a6c8cafd89979af5407d77a6eda589833dca@changeid> X-Mailer: git-send-email 2.43.0.rc0.421.g78406f8d94-goog In-Reply-To: <20231117130836.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> References: <20231117130836.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_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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]); Fri, 17 Nov 2023 13:10:37 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782847046147559327 X-GMAIL-MSGID: 1782847046147559327 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. Signed-off-by: Douglas Anderson Reviewed-by: Grant Grundler --- drivers/net/usb/r8152.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index d6edf0254599..aca7dd7b4090 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; @@ -5513,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); @@ -5635,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); @@ -5791,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;