From patchwork Thu Oct 12 19:25:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 152128 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1454837vqb; Thu, 12 Oct 2023 12:31:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFMYIFA1Q/pNImdHfyKGkCAAIvVlPriPB6de4fSxRpDpRia8e7gSFPFhc+3wy+BxgIYgg9x X-Received: by 2002:a17:90a:2dc5:b0:27c:e2d5:abb6 with SMTP id q5-20020a17090a2dc500b0027ce2d5abb6mr8715355pjm.0.1697139067157; Thu, 12 Oct 2023 12:31:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697139067; cv=none; d=google.com; s=arc-20160816; b=MYDAVurewvt8MtGiD8Dh6sAxuDqqGiyva3SLuyR6e1kNsPYnXTJkAF8dbPbFVz2Gsm IFM1ZpPrwRVb7ntaBFGSDizdTGo3ck/jjfQCBMDF3Nv5Y1WxM75QS0ylvDyzmkBrd7Qn ZmeDl1v4UMTRmvv6FOL9Jt8bq/K3Jid6p9z637zN2kwftE3VpDbZMR3s9rwfaqUzksk+ 3kq5P7n9G1Mt7vqpZFG35ha+245xAgSuxF3QSk1LMc2MsPju+YtNSKeRBJJAwCRHuVZw xsqhVNkMAKOYXl5ZSweabL3JZ5LeOtsr52EIzB2xr8F/DShcmlOkXdem0CglCi+y7Ooo V/bQ== 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=wIBdQHfHPM91+b5JonQNYSwOG95FePEogJzP0FDSRh4=; fh=B0Kr+W4P+gDWCh4uaZww8C7+cggdkGoCsVYEV5mipv8=; b=HnVsE+CY4oNc1d9nE4PWIZMOJD31XHE/pjdSryifFooh3xhylWsXCfR6WbEkq2ivbO JvgCEX9WSwcG7bg1sp0vc9IVJI0u9AFGjo+GabpnwxCv1md9b0X+dzBrUF0cMDhMVVTO upEoqHcS5RsC/zdqXj9lZaD2YxeVBnP7e6tNkjV53HPfB3K9RpEUn4mvlVaxYyG+XrVC fcPl+yMvbaJELeTvA8XEm0+MEytiP5KaW8WQgWGW7vUQOp68xR48X1SIzAsnOIZ2IH2B zPV07Eik2gZKqFvyk1YOKAJiMKIaYeWAHC35R6BoWwv7RMl7yv6hauAcF4x08Wu4Wxhs YR+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Lo4hCg8M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id lw9-20020a17090b180900b0026d034f6baesi174272pjb.117.2023.10.12.12.31.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:31:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Lo4hCg8M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 3CEB3808E665; Thu, 12 Oct 2023 12:30:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442223AbjJLTac (ORCPT + 19 others); Thu, 12 Oct 2023 15:30:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442172AbjJLTaX (ORCPT ); Thu, 12 Oct 2023 15:30:23 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38677BB for ; Thu, 12 Oct 2023 12:30:22 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-69101022969so1210473b3a.3 for ; Thu, 12 Oct 2023 12:30:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1697139022; x=1697743822; 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=wIBdQHfHPM91+b5JonQNYSwOG95FePEogJzP0FDSRh4=; b=Lo4hCg8MjbZ3rjVctuJwOHfdaEbxxPjqg2YWMAVzsSb3nN11ID0NyQsfSnrivseRfd qlus7Z5tDflBYlebtyxxR1gWj9UesmXyTFDKydhLvmZO+OoC5H5tQ8MqFTrSJ/wSizjl BnxHR+d9dsvcIDl/L6uwd59u7d/uhHtknxc8g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697139022; x=1697743822; 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=wIBdQHfHPM91+b5JonQNYSwOG95FePEogJzP0FDSRh4=; b=ZmLsIRuZlvdTUciyvDSD6vGfGhFfTRCzkJKZA1s4N2xOk8nHgNLvJzfwTX2JYTx1FA 7zrB0XQG/LfN4O0l+e68kCMPuR1tWnOLg91hXLUVKkHmpeM9ypfjVuKMbVsZgb906toW j6RPCCeXo76UVgB1qFjyVvDiJz2STpgRdQFlM8gALkyjb+Qz9F193YLhFWqNSsJtLLHY rqm0ppuD3M2TLqgi8U5bDFXqMkL6W8p8bKi4epPEufeMKcjuQGQWFSanbagrm5JRyQ9i U3f6svFui291YFAmuINl6EPf9vBeaPrmByGA/cgM0lZsoiCIlZnBRb5DSry5iaSzcQgl UR+w== X-Gm-Message-State: AOJu0YwH8tsVaYNJMKQyiljDL6kz1rTFBD9r4aIRG/bE5ms44NQJE7zP WubcR0WD2paV+j9/ekpbLU08zQ== X-Received: by 2002:a05:6a20:9385:b0:161:3120:e840 with SMTP id x5-20020a056a20938500b001613120e840mr31028866pzh.2.1697139021715; Thu, 12 Oct 2023 12:30:21 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:7c85:4a99:f03e:6f30]) by smtp.gmail.com with ESMTPSA id b3-20020a639303000000b0057c25885fcfsm2075720pge.10.2023.10.12.12.30.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:30:21 -0700 (PDT) From: Douglas Anderson To: Jakub Kicinski , Hayes Wang , "David S . Miller" Cc: Alan Stern , Simon Horman , Edward Hill , Laura Nao , linux-usb@vger.kernel.org, Grant Grundler , Douglas Anderson , =?utf-8?q?Bj=C3=B8rn_Mork?= , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v3 3/5] r8152: Check for unplug in r8153b_ups_en() / r8153c_ups_en() Date: Thu, 12 Oct 2023 12:25:02 -0700 Message-ID: <20231012122458.v3.3.I6405b1587446c157c6d6263957571f2b11f330a7@changeid> X-Mailer: git-send-email 2.42.0.655.g421f12c284-goog In-Reply-To: <20231012192552.3900360-1-dianders@chromium.org> References: <20231012192552.3900360-1-dianders@chromium.org> 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 12 Oct 2023 12:30:56 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779579294223903799 X-GMAIL-MSGID: 1779579294223903799 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 --- (no changes since v2) 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;