From patchwork Thu Oct 12 19:25:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 152127 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1454836vqb; Thu, 12 Oct 2023 12:31:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4EmxM6bmtx/fASCek/EfVfDWC+xxWaNOU06t8bfJVmgdyINxvZ/1DhHOtlVzrnJ2iF8mv X-Received: by 2002:a05:6a20:9393:b0:16c:b95c:6d38 with SMTP id x19-20020a056a20939300b0016cb95c6d38mr17906392pzh.2.1697139066980; Thu, 12 Oct 2023 12:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697139066; cv=none; d=google.com; s=arc-20160816; b=fvnDLMU+HE/L+T/DtSw601BWgYuJWhWWDE3vo9DuouExkwchf8Hz3M7XxTXXiMfxqt V15tpP5aB2zEvEmYyLxt6vpyrsgZboQI4RWMvjIW+iYlWRZuFC3DVgzTAgzbqfuJQ8nd UlgECxpwAu0U2DKl6paZAVfa3VhJjQ4PGhI/0vV5+UzDqptF+j+ur1mphCY7OvBBul2Q K/UyOk0sYdSEE9wPyCpOu83TQskB9IcCe9KEZLAG08TP3VcUDD8yOLVxAM4dqNaH/MlE UoGlXkwmNAKB4QSJe9j5M8PTUjcR9VEiTz/6I92IRq1Ay58KJ+K7sbvUc8q+kwVK3sRB 27qg== 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=5zajPA0tvu72pt5bpzc8dJBpNP+YUOKi2eBcYHy9Hcw=; fh=B0Kr+W4P+gDWCh4uaZww8C7+cggdkGoCsVYEV5mipv8=; b=weUEJKw7K+PhEwzsAbBri/wMYPHevlSDtbbwe8BJTvGZlT17OCfPHWDprnn9bEckt1 de+0rx+vZt8ipi2Ss0zv31ckeCk7wZ/zViO5EfzBEwj2YtrH17OkGjc/XbxRT0Ht4xkn UxROtXrqgLwdo6zisl8GmNUwuNOoyFohytZsCqWFKS+8PRI4hWKuJnpecEC8bphEa40Q y4X22pKg8bwi6mokGROEEMuX3dQcRRhvCqaA6VXASC+b0/yvRIFRCEq4lwYYAQbpXcV1 QM70a65M2LycfTfLFsp35PoWRQPBTpyz7fN9FnBjL2k6blVzzC3AnhpfN4MXK0IjRHlf 3/3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Si8r9BfD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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. [23.128.96.33]) by mx.google.com with ESMTPS id l12-20020a17090aec0c00b0027d0b9c0b90si2739452pjy.153.2023.10.12.12.31.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:31:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Si8r9BfD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 6DA29808E667; Thu, 12 Oct 2023 12:30:44 -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 S1442181AbjJLTaY (ORCPT + 19 others); Thu, 12 Oct 2023 15:30:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1441868AbjJLTaV (ORCPT ); Thu, 12 Oct 2023 15:30:21 -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 47CC8B7 for ; Thu, 12 Oct 2023 12:30:20 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-690bccb0d8aso1153077b3a.0 for ; Thu, 12 Oct 2023 12:30:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1697139020; x=1697743820; 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=5zajPA0tvu72pt5bpzc8dJBpNP+YUOKi2eBcYHy9Hcw=; b=Si8r9BfDBfRo/07TbOXurfEXpVpk2YVQaEi60b/Lj35WBoQdbwBuUobcM0M7rBFdlL sMM4fyZVD+slnoSxaOzShM1AcItMD/fSw614qhQ909HzAtyDgrSzSLHJ53hXjjsb79Rt Te7FbWESWFO1+nLSINfB/pCqI2mjvVa+s/SRc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697139020; x=1697743820; 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=5zajPA0tvu72pt5bpzc8dJBpNP+YUOKi2eBcYHy9Hcw=; b=Fyu7CQilhRzg+1OLgtlYfu8+0Itiowda6cl5TkCCbaUVvP4lgpEM4oTCVLu4hsUbhC mH5hex19sHcROAaTiWuGhlnJ1mjjzR5R4jSzdk+i9zdO77qwBwh3vdZu2Ux7Hxpojq4M 8Stl3srJm6Xfd4D7OhLsXhL5WGLNeyugl2ptWSyxCdoQdOV+rtS+2lknSnba8NdmIokC 3wqu6dO3ulmUl58YXwRSa/6EGJZKi5KbqSIn/RvgHYkxF4ntGU8OBP3iYrdf5Zm2esgW S9hP6iNpJo9M8S48G/wM+IKIJP1MZVcEOBxv77kLZtKP2IYPhTP6TBY9VBPxTl0xRDmW iRzw== X-Gm-Message-State: AOJu0YxrFzsvG8aMKFPRhVoPuMXqMZz0iwvwIcB1A946Ny7GWtWduiP+ E3pCTvnB4a7LxZRhc5PtttpoJw== X-Received: by 2002:a05:6a20:6a23:b0:13e:9dba:ea52 with SMTP id p35-20020a056a206a2300b0013e9dbaea52mr27470979pzk.13.1697139019812; Thu, 12 Oct 2023 12:30:19 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:30:19 -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 2/5] r8152: Check for unplug in rtl_phy_patch_request() Date: Thu, 12 Oct 2023 12:25:01 -0700 Message-ID: <20231012122458.v3.2.I300ed6c3269c77756bdd10dd0d6f97db85470186@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:44 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779579294227625262 X-GMAIL-MSGID: 1779579294227625262 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 --- (no changes since v2) 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)