From patchwork Wed Oct 4 19:24:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 148572 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp357088vqb; Wed, 4 Oct 2023 12:27:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAS1vCZ4S0w6lJqxSrDcthRAaojENDjSOAdZsSr9aJ3KD8foCcAO4v8y3IGZaEaupCWH/B X-Received: by 2002:a17:903:1c9:b0:1c5:f110:efa0 with SMTP id e9-20020a17090301c900b001c5f110efa0mr3848270plh.30.1696447634334; Wed, 04 Oct 2023 12:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696447634; cv=none; d=google.com; s=arc-20160816; b=Lu39NrLDTrGXOlUPacuSiyTVYI44cVrHVOz/DNh2vNh7udFcf6P50kmm09jmhKWvfP 4IV0DUn+mL3TxMgh7l4FAu4tjg6b24W3wEcGwY8BE0V6WujPgg6mNaPjIJwdLKknDd3W mLEtsHCsatrrAcGzsxX5Rr0uRloW4q6rQlbRxJUBsRse/Zq9834t01dYIi+xwDPTFa7a LvB5ALJqLW65Vx3/48Hao98B0CUGIZFLee9PNwP3JYhbMbIaO3yHXmrMa+q3H88EEIbO zV20hhMCR1emBuvfdLGxOaggr1TgGOFfOxtQzXb3szGLXALbRfEcNc/GlsmUNkWfmitx +Gjg== 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=e5PJMycEXBTARd/V1ON7uAyaQyF56XJbZsQp7M/oePc=; fh=KEqf2HNItobic0TkOsvToOuTvuaOsOQxODg7+A5rZ0A=; b=rTYXF4AIreYROa81YUGZ03Tr6r9sNrakzyZT0A+v2h5aLu/eTZ4DsXF9hoT6yaRRtD NAu3aKc4cj+D6vs7+EaYNBDRe4GupvQA//viWpeiJLg0HgK5nZxy+svu3Ve2NMa/qWax 9zZ5P4uD1B4aGyqWHX4bNrvcJUo2jn52WdzI/6m56Jitz3al76192vMpUPy99uE6Rd3r dtjyYFIIOhvyrsYywT0heZvMRkDXIjaYShJ27BLQQ2HJG5WTx+61MpWTLT1bJcil8Jck E8v62IZJbpAS60+B0w4hu3SfHw70dAksRN9ptb6pSSClXv3Cl/QtQ03Asslvy+51DtWp 1sMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dSbYTypp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id lc6-20020a170902fa8600b001c383a64ebesi4063311plb.319.2023.10.04.12.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 12:27:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dSbYTypp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 5C4E48489E6A; Wed, 4 Oct 2023 12:27:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243958AbjJDT1I (ORCPT + 19 others); Wed, 4 Oct 2023 15:27:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244452AbjJDT1C (ORCPT ); Wed, 4 Oct 2023 15:27:02 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16F87F1 for ; Wed, 4 Oct 2023 12:26:55 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-690bd8f89baso120266b3a.2 for ; Wed, 04 Oct 2023 12:26:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696447614; x=1697052414; 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=e5PJMycEXBTARd/V1ON7uAyaQyF56XJbZsQp7M/oePc=; b=dSbYTyppKK6GGdgo/uzVNGfGelV7sntQNk3cCy/W5fvqRYKufRUOlKFkL9tMh1aFEC tbU/1lrT+KQCzUCWSL+1mIoilwkd6SWrTKVairzdJt21mNTydGPmKB1gfO84e5TueYx6 kqo/tJAVzqVuf5SFwj4kk+mOMBNDvC8qmH3Ps= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696447614; x=1697052414; 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=e5PJMycEXBTARd/V1ON7uAyaQyF56XJbZsQp7M/oePc=; b=uEPwEtPe5cvs4oPQQw7YcpGaS/G1bk7ANEgy59juGK019/NGQncpFyqaP2soPrvaNT CXDSd46pPontZagZ+HPNgZhUhfeK3l33yi+CUBOr7IXL8TrSTYpx2NgcGGpHLjecE8Gv WQo6IVsJ7A2w7nwVRefSqYcmsaJrrs/QnyCrsPr/A1UdxZBXGXd4+pfZqw7zD6er5SK+ oQQgxb1mGruWLxDxxmus41XHtlZacEW5J1AX0Y3YAl22IynlqSBKh5ung9VzmPvrQlKC UPdMdw1k7ip6Yqx//spxm29sNvm6Qo96NuY548QdbTpqz5jx8Pr6awferq8cqbCvOsgM KZNg== X-Gm-Message-State: AOJu0Yxg71DsRY1+biL67fr0lgBh4xdWOinGohbAPrFhb0YI8Z2X2QuI ZgsYfSiIfiU2EL2iUY+vlSJK0A== X-Received: by 2002:a05:6a00:1951:b0:68f:ca4a:efd with SMTP id s17-20020a056a00195100b0068fca4a0efdmr3534941pfk.9.1696447614536; Wed, 04 Oct 2023 12:26:54 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:9cce:13a8:f2b8:b799]) by smtp.gmail.com with ESMTPSA id d190-20020a6336c7000000b0057c29fec795sm3649151pga.37.2023.10.04.12.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 12:26:53 -0700 (PDT) From: Douglas Anderson To: Jakub Kicinski , Hayes Wang , "David S . Miller" Cc: linux-usb@vger.kernel.org, Alan Stern , Grant Grundler , Edward Hill , Douglas Anderson , =?utf-8?q?Bj=C3=B8rn_Mork?= , Eric Dumazet , Paolo Abeni , Simon Horman , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v2 3/5] r8152: Check for unplug in r8153b_ups_en() / r8153c_ups_en() Date: Wed, 4 Oct 2023 12:24:40 -0700 Message-ID: <20231004122435.v2.3.I6405b1587446c157c6d6263957571f2b11f330a7@changeid> X-Mailer: git-send-email 2.42.0.582.g8ccd20d70d-goog In-Reply-To: <20231004192622.1093964-1-dianders@chromium.org> References: <20231004192622.1093964-1-dianders@chromium.org> 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,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 (howler.vger.email [0.0.0.0]); Wed, 04 Oct 2023 12:27:13 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778854274531011058 X-GMAIL-MSGID: 1778854274531011058 If the adapter is unplugged while we're looping in r8153b_ups_en() / r8153c_ups_en() we could end up looping for 10 seconds (20 ms * 500 loops). Add code similar to what's done in other places in the driver to check for unplug and bail. Signed-off-by: Douglas Anderson --- Changes in v2: - ("Check for unplug in r8153b_ups_en() / r8153c_ups_en()") new for v2. drivers/net/usb/r8152.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index fff2f9e67b5f..888d3884821e 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -3663,6 +3663,8 @@ static void r8153b_ups_en(struct r8152 *tp, bool enable) int i; for (i = 0; i < 500; i++) { + if (test_bit(RTL8152_UNPLUG, &tp->flags)) + return; if (ocp_read_word(tp, MCU_TYPE_PLA, PLA_BOOT_CTRL) & AUTOLOAD_DONE) break; @@ -3703,6 +3705,8 @@ static void r8153c_ups_en(struct r8152 *tp, bool enable) int i; for (i = 0; i < 500; i++) { + if (test_bit(RTL8152_UNPLUG, &tp->flags)) + return; if (ocp_read_word(tp, MCU_TYPE_PLA, PLA_BOOT_CTRL) & AUTOLOAD_DONE) break;