From patchwork Wed Oct 4 19:24:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 148575 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp357696vqb; Wed, 4 Oct 2023 12:28:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYPqIsHtELkbMSTrDyORfQ7mVMKSGoznGXsEt1ZDPpo4PZrqhSl9PLCtvYd6JDT1wbCGh5 X-Received: by 2002:a17:902:cecb:b0:1c8:7d41:5b87 with SMTP id d11-20020a170902cecb00b001c87d415b87mr1827153plg.50.1696447724555; Wed, 04 Oct 2023 12:28:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696447724; cv=none; d=google.com; s=arc-20160816; b=bKWGXcHZLyjtE+F/EV9/tU0fB5o3/zKVW1ipkyJw+JAB8azyEe3bFwqeg0+ji+Zf1h q9wvQXAU/ks599yD3vF1Qruy7DxSmpKoXEUTAN/GhPvQWBP7Tw8/gPlLQrYyyndc/ImE 2eLwHJeA7tnBDOhgB0fGYHmr7kMuCShcEkgda9hXs/H2Vypz+E2BkA1GSnbUkWpVyguj sDLn+8zXa0VCX9+X0mnk+BsHrXR84aJGdOU8pbtMeA0XYf+hps+xg+Vt15lGunzRN0OA uOirMozJfX0sug4mAUkRogwJt0LpdfzHC00wDBpu2T543mbgp1k4ozLwqwjO9+JAMR+/ 39Yw== 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=uvVPnlQORTCK7kqZ53cdR5dJ01wpTJ+M1zt/QBCKOzQ=; fh=KEqf2HNItobic0TkOsvToOuTvuaOsOQxODg7+A5rZ0A=; b=BWIvnS7cmabFsGz0A60wjv2hH6s7YL96NZTLWggklXNDjFc7/cjay+heWkKsuRpUzv La4qe9jxHn8eCUbevrgAbYMsIuHDILJwGBnBjtKQAqToHtQSSxSycwDpNl3l597BqkDe jNAeNBWVeLfOxTDRf2B+wyWddChcDkPH1If+/wGh3x88tW1w6FaEqs6QL1ZZ5Vh4fd72 tJE/jlgpdXvGZAf+5ZV3DO1xfumKgfx+aIYYaooKzBTQq9nOIa5RNOs6BJTQQ/Em967c ZvqULZi45rq0IbVy4b2zWV6pQJE808jQDKP6aLiKp6NHONftldb54wubBPyKewQZeT+H MHJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aVnDf9y9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ij5-20020a170902ab4500b001c3bd544f9fsi4131421plb.523.2023.10.04.12.28.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 12:28:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aVnDf9y9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 6568281CFEB4; Wed, 4 Oct 2023 12:28:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244467AbjJDT1E (ORCPT + 18 others); Wed, 4 Oct 2023 15:27:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244240AbjJDT05 (ORCPT ); Wed, 4 Oct 2023 15:26:57 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 652A2E9 for ; Wed, 4 Oct 2023 12:26:52 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-690ce3c55f1so154020b3a.0 for ; Wed, 04 Oct 2023 12:26:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696447612; x=1697052412; 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=uvVPnlQORTCK7kqZ53cdR5dJ01wpTJ+M1zt/QBCKOzQ=; b=aVnDf9y9ppcLZrN0TfKGyYX1Agu3ULIUVQcZD0//g5CNVy8EK8vseFYuKlT5OtvBq7 w2ThnvRjVQLSH4Jh03j4SDvO6avZNJwmQFxTPCsZhvToA12XzvFcHSfXbLesNrJVa/MS gCw/fkN29F1tJmDV5lQ0OISzxdQCgt7V/4dHk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696447612; x=1697052412; 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=uvVPnlQORTCK7kqZ53cdR5dJ01wpTJ+M1zt/QBCKOzQ=; b=lSBvA2+UPM1nIc/+ZqzKZbLidFo0tfu6/od+KxwdUIJHPPM3kc55aXr7sGF4KMitRt DAOWBIuOCB9C9KgZCa2URM+ohGn43DmolTcAamoMXwfgUw1tLIJd3ak0UvPwcrROzf2b 5n+7Jd4LH+pdO+AVL0TEbst2ipfdukz8WdF3jYUeOMKeu5D/4X0L5Va6D5skTai+TkKK wvWy0faU63WI3HjRJOIeOoLgtdOPavFimu3k8/jXGK8PolsgYd5fZXJiZD7PG0lVgXYN UwiWb0QjxQIEXw1TJHgTj/x5MjdPRKfABuBIoIBJacrWb/Er+xSoD09fFeZtmNFI7epT SVSQ== X-Gm-Message-State: AOJu0Yzpw8/KsnOD2RucWvhWv8wplheUa+Oi4pXocfb3sA59o3iLDfM3 hSe1ZGeHZhWBoCvO2uLXcb33Xw== X-Received: by 2002:a05:6a21:6811:b0:15e:b8a1:57b0 with SMTP id wr17-20020a056a21681100b0015eb8a157b0mr2585287pzb.39.1696447611832; Wed, 04 Oct 2023 12:26:51 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 12:26:51 -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 2/5] r8152: Check for unplug in rtl_phy_patch_request() Date: Wed, 4 Oct 2023 12:24:39 -0700 Message-ID: <20231004122435.v2.2.I300ed6c3269c77756bdd10dd0d6f97db85470186@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.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 04 Oct 2023 12:28:40 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778854368699013785 X-GMAIL-MSGID: 1778854368699013785 If the adapter is unplugged while we're looping in rtl_phy_patch_request() we could end up looping for 10 seconds (2 ms * 5000 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 rtl_phy_patch_request()") new for v2. drivers/net/usb/r8152.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 482957beae66..fff2f9e67b5f 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -4046,6 +4046,9 @@ static int rtl_phy_patch_request(struct r8152 *tp, bool request, bool wait) for (i = 0; wait && i < 5000; i++) { u32 ocp_data; + if (test_bit(RTL8152_UNPLUG, &tp->flags)) + break; + usleep_range(1000, 2000); ocp_data = ocp_reg_read(tp, OCP_PHY_PATCH_STAT); if ((ocp_data & PATCH_READY) ^ check)