From patchwork Wed Nov 29 21:25:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 171570 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp628760vqn; Wed, 29 Nov 2023 13:26:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHI3gOIR2VfrwwEod/A1C22nHashklDmtV1cTzkKkXRxtSZmBDHG73K4rKIElWcxtSniqNJ X-Received: by 2002:a05:6a00:3018:b0:6cb:6a4d:3a80 with SMTP id ay24-20020a056a00301800b006cb6a4d3a80mr26661820pfb.5.1701293204313; Wed, 29 Nov 2023 13:26:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701293204; cv=none; d=google.com; s=arc-20160816; b=vYJOGWdxpqzbFzIVwTkgBkbc7G8o201sJQrFF8UO/ynSTs2Mecio+PMi/qGyqrpWBp kdiRqLxmkSDbjsaOSLOR8qKPTn67IhkziKCzNypAGGqq+P+zvxZIbuc4tvsxNFG/F/np JctIiY+LsZjxNQPbQHzTS1TE+j1mlTVtn2dWQx1bx6YLfzn1aIxD67Sl090Ame0GmevY sGkDMmYrXn8LL8yP/7wxckNFVXgpA6gKgZYUJyz0j5VZHA2apelqVpiAm8hf+U365TPW +T0jmkejPint7dbF244WAgrmFBjVDX6P3tyGRDX8Oi1Lbu0pQTMINoHUFBujuUy5azhL pjFg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=XNCUzlT66xSSzQeRG+3/Vjdg0+tkFMt3clYOj0yBxCw=; fh=mRHaPBoaK/yKIiTe7zbQTMuaXdIOIrIp8KgHhHuSvhs=; b=Gaj2+fH9XL7vKvR3DGXxuLps2dajL9LBCmeLI00KYj9oBl2ERPfaHd+Vsap9YsAtNu Y935lZ1QW5GWjp+Tw94TcQ2aEY1V03MVF0RLjU1mNtom428KZf2i8yHF1MFk943aV94k Npv4Z9OSQsxyEyA+1TriBwvabVDW/A7ycJ1/ZISazjkuYZ06Ock6FbaYTAC/H6woLWoQ PBlT7Ub/dMb6h9UuZfppRnf5vtlAgkPCa8xK/QzWaGlQJmQDNLdnaHpvLOMXR1l+LZIc jKl4bWxmbWZ4TcYO4Yo6MhfB8D8WoqkWDvj+tgeQsUlo5NYzJoOzED+xZskh/Y+Xe6WL bZeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZPvbimEB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id h69-20020a638348000000b005bda018db99si14208633pge.451.2023.11.29.13.26.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 13:26:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZPvbimEB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 9DEF881F32A5; Wed, 29 Nov 2023 13:26:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234382AbjK2V0V (ORCPT + 99 others); Wed, 29 Nov 2023 16:26:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229847AbjK2V0S (ORCPT ); Wed, 29 Nov 2023 16:26:18 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DE06D7D for ; Wed, 29 Nov 2023 13:26:22 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-5c27ee9c36bso213679a12.1 for ; Wed, 29 Nov 2023 13:26:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701293182; x=1701897982; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=XNCUzlT66xSSzQeRG+3/Vjdg0+tkFMt3clYOj0yBxCw=; b=ZPvbimEBh8xSzwTEtOWWe8MrLkwmup8mXmlIf/LDDw3wIQZtQKqvu4z4cZG3icQ545 xazyz2ORF4ObT7bM6rXCBKc1U1zseYGa29BjCouutJ6/+yohq4zgKUds36bgl4iOPy6B 4+ds8kxiTIR0fxRSi5Pz+t2uldV7nCBzVbQk4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701293182; x=1701897982; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XNCUzlT66xSSzQeRG+3/Vjdg0+tkFMt3clYOj0yBxCw=; b=AqFbuVF0nS9hdTWqMCYjmYATGcY1QmevrFn6KxhljFvi/UXqDCRofcLegg5/6Z/Y9y eK0Vv0y9ZDBhoFFIgrAbblXVsMIx6Pk3Z78aanGtq/fjsJ8L16sWRdP7bdrOgjinvM4L qB4mzxbhMJ6OPcoR3QAEIBZUbnbkJ2BDlhqtBssa/yxSkT9bwanFPXblbQYkDPVqn4fk aWUqiQS46wu7bT0AfrHr37Rf6XvsqTcRf5CCCIhOIu1PK90/LKL/Z66ozXP1r8olB0Q+ pOE57N6Lbx8qNYVbJD4d6lGTcQYJ233yCN7Ls+psIS0BPW82LdH0wPWOJYCVhRYOHvQI FTIQ== X-Gm-Message-State: AOJu0Yx5EHanU/w1UXeJNP0apJ2ZDDVzslZ0Q5An1NruOUBCBPss850f qZQYHNQLgLB/0qwe+jsfXnbATg== X-Received: by 2002:a05:6a20:244b:b0:18c:fa:17f7 with SMTP id t11-20020a056a20244b00b0018c00fa17f7mr24241206pzc.46.1701293181673; Wed, 29 Nov 2023 13:26:21 -0800 (PST) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:dcf:15e4:5f50:e692]) by smtp.gmail.com with ESMTPSA id t22-20020a634616000000b005c215baacc1sm11816336pga.70.2023.11.29.13.26.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 13:26:21 -0800 (PST) From: Douglas Anderson To: Jakub Kicinski , Hayes Wang , "David S . Miller" Cc: linux-usb@vger.kernel.org, Grant Grundler , Laura Nao , Edward Hill , Alan Stern , Simon Horman , Douglas Anderson , =?utf-8?q?Bj=C3=B8rn_Mork?= , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net v3 1/5] r8152: Hold the rtnl_lock for all of reset Date: Wed, 29 Nov 2023 13:25:20 -0800 Message-ID: <20231129132521.net.v3.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Wed, 29 Nov 2023 13:26:32 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783935222957389654 X-GMAIL-MSGID: 1783935222957389654 As of commit d9962b0d4202 ("r8152: Block future register access if register access fails") there is a race condition that can happen between the USB device reset thread and napi_enable() (not) getting called during rtl8152_open(). Specifically: * While rtl8152_open() is running we get a register access error that's _not_ -ENODEV and queue up a USB reset. * rtl8152_open() exits before calling napi_enable() due to any reason (including usb_submit_urb() returning an error). In that case: * Since the USB reset is perform in a separate thread asynchronously, it can run at anytime USB device lock is not held - even before rtl8152_open() has exited with an error and caused __dev_open() to clear the __LINK_STATE_START bit. * The rtl8152_pre_reset() will notice that the netif_running() returns true (since __LINK_STATE_START wasn't cleared) so it won't exit early. * rtl8152_pre_reset() will then hang in napi_disable() because napi_enable() was never called. We can fix the race by making sure that the r8152 reset routines don't run at the same time as we're opening the device. Specifically we need the reset routines in their entirety rely on the return value of netif_running(). The only way to reliably depend on that is for them to hold the rntl_lock() mutex for the duration of reset. Grabbing the rntl_lock() mutex for the duration of reset seems like a long time, but reset is not expected to be common and the rtnl_lock() mutex is already held for long durations since the core grabs it around the open/close calls. Fixes: d9962b0d4202 ("r8152: Block future register access if register access fails") Reviewed-by: Grant Grundler Signed-off-by: Douglas Anderson --- In response to v1 Paolo questioned the wisdom of grabbing the rtnl_lock in the USB pre_reset() and releasing it in the USB post_reset() [1]. While his concern is a legitimate one because this looks a bit fragile, I'm still of the belief that the current patch is the best solution. This patch has been tested with lockdep and I saw no splats about it. I've also read through the usb core code twice and I don't see any way that post_reset() won't be called if pre_reset() was called, assuming that the pre_reset() doesn't return an error (we never return an error from pre_reset()). If folks have some example of something that's broken by the current rtnl_lock strategy used by this patch (or if folks feel very strongly that it needs to be changed) then I can spin another version. ...but as per my reply to Paolo [2] I think that does have some minor downsides. [1] https://lore.kernel.org/r/f8c1979e2c71d871998aec0126dd87adb5e76cce.camel@redhat.com [2] https://lore.kernel.org/r/CAD=FV=VqZq33eLiFPNiZCJmewQ1hxECmUnwbjVbvdJiDkQMAJA@mail.gmail.com (no changes since v2) Changes in v2: - Added "after the cut" notes about rtnl lock strategy. drivers/net/usb/r8152.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 2c5c1e91ded6..d6edf0254599 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -8397,6 +8397,8 @@ static int rtl8152_pre_reset(struct usb_interface *intf) struct r8152 *tp = usb_get_intfdata(intf); struct net_device *netdev; + rtnl_lock(); + if (!tp || !test_bit(PROBED_WITH_NO_ERRORS, &tp->flags)) return 0; @@ -8428,20 +8430,17 @@ static int rtl8152_post_reset(struct usb_interface *intf) struct sockaddr sa; if (!tp || !test_bit(PROBED_WITH_NO_ERRORS, &tp->flags)) - return 0; + goto exit; rtl_set_accessible(tp); /* reset the MAC address in case of policy change */ - if (determine_ethernet_addr(tp, &sa) >= 0) { - rtnl_lock(); + if (determine_ethernet_addr(tp, &sa) >= 0) dev_set_mac_address (tp->netdev, &sa, NULL); - rtnl_unlock(); - } netdev = tp->netdev; if (!netif_running(netdev)) - return 0; + goto exit; set_bit(WORK_ENABLE, &tp->flags); if (netif_carrier_ok(netdev)) { @@ -8460,6 +8459,8 @@ static int rtl8152_post_reset(struct usb_interface *intf) if (!list_empty(&tp->rx_done)) napi_schedule(&tp->napi); +exit: + rtnl_unlock(); return 0; } From patchwork Wed Nov 29 21:25:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 171569 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp628674vqn; Wed, 29 Nov 2023 13:26:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IH55Lug29gy8Wi7KELgojtHQLlOn2gQE3AVGJzDf49H3vFUAlSgfn+cQEzokTJeNU/zh3gv X-Received: by 2002:a05:6a20:5521:b0:18a:de88:e0d with SMTP id ko33-20020a056a20552100b0018ade880e0dmr16609753pzb.15.1701293192952; Wed, 29 Nov 2023 13:26:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701293192; cv=none; d=google.com; s=arc-20160816; b=ZK5NaZ8xEZDAvc7e7+hXQQFqkIROJ1jeFZ784EwyERNkKZ4JwS0YHRi8YHfCHM1Ksi /iEGcPtncfsveF4GJb+PeLFeGx2ib7SYCAgJh/dtJ7x5csWlMI4Mejte+0cAFbQa4EML 4otEj7f4hha8/6hQEc5NpmYnFd2M8XVdk2dU5mVARhk2ISITVpIYSV405r4knkNg1+Os XAX5+82gb8tt9qbfr4y7OE7a307zdHzmVU2sJA4ZtUXKoGxpUQsXsuZfsX6gE1XxQtkL O4tg0Edc6S6mcNTgs02EkqAHzS7+p7B7lYhbGRgg1ZaCLpG9Uci+J9Pzw78Q5xpuiZvG DHeQ== 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=7sCyYkRoGgiDRrKxcp8ji3Yt467zSBtV+G7Y08/1tlE=; fh=mRHaPBoaK/yKIiTe7zbQTMuaXdIOIrIp8KgHhHuSvhs=; b=hiyvrBwHXb/6qfvyFCbyuw1WRXe+FaE+M6zJcSaeKD4yxwqzoG/bMIZ9p0obU9yEyW yT4kZZfUasgGuodx4aEc52hokd0A9esJxfdwYD4x/WBq5u74CQTqSmAwkyxBVgjJUA/S xxGzgApjB0VvNOCm9d0ej1cBuwhMVqnlqRf6B407O4/txugRA7ZeyLDymBtUELFMnIxY NqmKIkPf69fosbAm13DHxJNxUFUunW7oZi30lgc7dp+81rMMPCEZpLtg4JW7DDXCfk8Y SLS1NfdYD9A9N3xjxJxoM43pOXJQFwuyMc/9HLqbosDAROsGmrqFk7oF57/pt00rxg8X 3ERA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dVKQ8Mix; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id y15-20020a056a00190f00b006cbe3c123a6si15056558pfi.9.2023.11.29.13.26.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 13:26:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dVKQ8Mix; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 7698D80C6E94; Wed, 29 Nov 2023 13:26:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233852AbjK2V0T (ORCPT + 99 others); Wed, 29 Nov 2023 16:26:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbjK2V0S (ORCPT ); Wed, 29 Nov 2023 16:26:18 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02DF410C3 for ; Wed, 29 Nov 2023 13:26:24 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6cd8ce7bf7fso261948b3a.0 for ; Wed, 29 Nov 2023 13:26:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701293183; x=1701897983; 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=7sCyYkRoGgiDRrKxcp8ji3Yt467zSBtV+G7Y08/1tlE=; b=dVKQ8MixDcLZ2oSabxC+7x6RrFJL047Gu8zum68hWW+AzR+BD2+QpqUDXLj1t1lzi+ 6nO4NRw2Uimzsl6KnyJue0QEKfJPTgWIhPXeGwgBWpjm1ccBT3edLWDkMjq/63+t8A4c Mfb2WNVDVoHz+YiVDdMjKxStJxLMVQFTl7B5c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701293183; x=1701897983; 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=7sCyYkRoGgiDRrKxcp8ji3Yt467zSBtV+G7Y08/1tlE=; b=tWJ/GwDAYHTpSyO0S1QEBusPaBFkipN6tOKST3tQ04ZduJ/a3fiFauEy6h36ER61Ng kdF0lpDQuFFOctndUpLQj1za9ZrfpLpKiJG+JcMFZz0LsIAOnWqGpX+nE+tygbHl8XFr xhkctTsGl/eE/827H0jYO53KhP+VrdA0oGG/UCMjTHH8NJH1YWwGmOxeln7BXbD6dmUw CInmPPy5E0JL8ISY6bFXES/ApxRYKqxXn4+4inwttLDwYX7v/tALpoEVlzyoLaqO9jMU qJmVJOXAwYERLWpxc135oKvn+dDbV971qHIqg5l3Ahed4NFNC1L0NbZwlkc5GiRUGDLx L/pA== X-Gm-Message-State: AOJu0YyeEKgqvv0d5g4pYMGzJtRwtaWabmIUwrUmJSUfa3+S6LjPqkVZ i3aXEX8Z9WzWVHyxiiQbZsN2jw== X-Received: by 2002:a05:6a20:3d0b:b0:18c:90f9:5084 with SMTP id y11-20020a056a203d0b00b0018c90f95084mr14166441pzi.27.1701293183515; Wed, 29 Nov 2023 13:26:23 -0800 (PST) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:dcf:15e4:5f50:e692]) by smtp.gmail.com with ESMTPSA id t22-20020a634616000000b005c215baacc1sm11816336pga.70.2023.11.29.13.26.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 13:26:23 -0800 (PST) From: Douglas Anderson To: Jakub Kicinski , Hayes Wang , "David S . Miller" Cc: linux-usb@vger.kernel.org, Grant Grundler , Laura Nao , Edward Hill , Alan Stern , Simon Horman , Douglas Anderson , =?utf-8?q?Bj=C3=B8rn_Mork?= , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net v3 2/5] r8152: Add RTL8152_INACCESSIBLE checks to more loops Date: Wed, 29 Nov 2023 13:25:21 -0800 Message-ID: <20231129132521.net.v3.2.I79c8a6c8cafd89979af5407d77a6eda589833dca@changeid> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231129132521.net.v3.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> References: <20231129132521.net.v3.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Wed, 29 Nov 2023 13:26:28 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783935211164776678 X-GMAIL-MSGID: 1783935211164776678 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. All the loops that are part of this commit existed in some form or another since the r8152 driver was first introduced, though RTL8152_INACCESSIBLE was known as RTL8152_UNPLUG before commit 715f67f33af4 ("r8152: Rename RTL8152_UNPLUG to RTL8152_INACCESSIBLE") Fixes: ac718b69301c ("net/usb: new driver for RTL8152") Reviewed-by: Grant Grundler Signed-off-by: Douglas Anderson Acked-by: Hayes Wang --- Changes in v3: - Use `break` when we see RTL8152_INACCESSIBLE, not `return`. Changes in v2: - Added Fixes tag to RTL8152_INACCESSIBLE patches. - Split RTL8152_INACCESSIBLE patches by the commit the loop came from. drivers/net/usb/r8152.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index d6edf0254599..e9955701f455 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)) + break; 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)) + break; 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)) + break; 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)) + break; ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); if (ocp_data & LINK_LIST_READY) break; From patchwork Wed Nov 29 21:25:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 171571 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp628761vqn; Wed, 29 Nov 2023 13:26:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IH2std9t/DsohbNFyPNaLuqruy5GnwP6Oby4nAzTHSQvFsCEAGN2D9rBRnzYNLVxmMXA+yB X-Received: by 2002:a17:902:ee82:b0:1cc:1490:e7bf with SMTP id a2-20020a170902ee8200b001cc1490e7bfmr21357710pld.30.1701293204327; Wed, 29 Nov 2023 13:26:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701293204; cv=none; d=google.com; s=arc-20160816; b=CsRggMrkgFbXnnXH0JNouslmd3E+h3uLOfT0ihtb+5le9c3TFGB2tSFVtaG3SbP6um Dbpicqb7+PxkCETc+SqVFgoBloYiXOAkDHXKdr6+GkFkg81yD1wPYj/pOqgKNX7RBiyp erYB3WFTJY4di14dZSjzaCQ9uTMxKop5uLILLN8hF7fwfYGR4ErjiAdq2V1PebumIgzI dmJYnWKFTggZ39E3T5z1dxLqp/pl/PsxsEAaVTNeeo8N2rRFLG5BKxLJf39RM0fWqDhR drzUvAdlau0pD8WuQqkY/BMv0T5pEjmus6L+C88JOCq6WpCgAatdPdw0Lkb/z0suPZKv toBA== 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=oMcpqMy/WvMvoKWfDIGBKOAFuUqj17oPCULwBqejJlE=; fh=mRHaPBoaK/yKIiTe7zbQTMuaXdIOIrIp8KgHhHuSvhs=; b=lmpDfgRbhucfcgORhx/qFRHlq3X8vcfQcORp5gCKYj8e8TfXrNi4CvBUmKccU+B4Jn XpclEDuh036+pO+eVP9mfjVqErcblEF8XOJwVYoE+o7R7DCWEjS/24eKg+J0AjFpjVwb yR9SODfFcVnvvDxlMrRdlzCB8wbQA0z33d0v9gmPbw9q3+0u9aNwFeZj1PqjfoNhKfDg DBD8+CwrJ/LDpi7s7e9T3B48pC/a64/T6cIamFWL6+eQGmpXQtHo0Vr64h+z9qbrCQcF DoM063uGKMGEoXpWvlY3xJz8hyFr3LKR5wjPf89GAizwhYDvUGXHyGCl8gBjxh65EAKf nfFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=C4lVJORK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id f15-20020a170902ce8f00b001cfaf05da38si12700065plg.58.2023.11.29.13.26.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 13:26:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=C4lVJORK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 1D4F0802DAB4; Wed, 29 Nov 2023 13:26:40 -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 S234440AbjK2V0Y (ORCPT + 99 others); Wed, 29 Nov 2023 16:26:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234361AbjK2V0V (ORCPT ); Wed, 29 Nov 2023 16:26:21 -0500 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 902EC10D0 for ; Wed, 29 Nov 2023 13:26:26 -0800 (PST) Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3b844e3e817so150104b6e.0 for ; Wed, 29 Nov 2023 13:26:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701293186; x=1701897986; 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=oMcpqMy/WvMvoKWfDIGBKOAFuUqj17oPCULwBqejJlE=; b=C4lVJORKiRKQoLOQRaMC0SKViy4tj5C4e1iiha9OLbp2gviPXgdHl7Xarh4ln2cEkD mS2A2YJWz12HOoP8DMLXJjMrGizPLGZm87yzy6xoItNNbf82ynA+kLSGoiu3ZcR56wux fK0Y6KaA80U64dwQzXNWcokDnh5vYwmj/VnBc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701293186; x=1701897986; 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=oMcpqMy/WvMvoKWfDIGBKOAFuUqj17oPCULwBqejJlE=; b=bn+5DuUc8fskVyHtFGi+wnqDpGtFnVm9XFV8gpkJzrVxQyOli1LVY5CJ3Y+kIx9sKf dE6fumlfVnPDKunZ6lKcPT6ashp2T240Z6zXFtfScyI00bNnP6/6aoLOOxuo6lv5GXX/ 20OyBV/DLIoToF5xk+LbwwGMGNmQ8MdCAMuVaUp6+GoNqUbsDlbRhJrVIIm3slSFZROX i+Qp7Hp9uZsMvvysUsy0ppX0ldMd13LmnBqG7OoWMH9FEbc6ArzuPKv4G0YIu8RTE1Df tr0S7AlGJkKbXifbLSq7auq/1z/R6IykT9pbKyqTmn56eoTQ/Ob2qHxdYdx+wNjy7mYF 98/A== X-Gm-Message-State: AOJu0YxkBF+E66sig1PUV4+l95BgH7U3rL+eK1F1j18biNkrI+ap5L3g X4ZfJ+dzGASlf6VE4iZ1lwf+mw== X-Received: by 2002:a54:4587:0:b0:3b8:37ba:7c73 with SMTP id z7-20020a544587000000b003b837ba7c73mr21628925oib.53.1701293185870; Wed, 29 Nov 2023 13:26:25 -0800 (PST) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:dcf:15e4:5f50:e692]) by smtp.gmail.com with ESMTPSA id t22-20020a634616000000b005c215baacc1sm11816336pga.70.2023.11.29.13.26.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 13:26:25 -0800 (PST) From: Douglas Anderson To: Jakub Kicinski , Hayes Wang , "David S . Miller" Cc: linux-usb@vger.kernel.org, Grant Grundler , Laura Nao , Edward Hill , Alan Stern , Simon Horman , Douglas Anderson , =?utf-8?q?Bj=C3=B8rn_Mork?= , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net v3 3/5] r8152: Add RTL8152_INACCESSIBLE to r8156b_wait_loading_flash() Date: Wed, 29 Nov 2023 13:25:22 -0800 Message-ID: <20231129132521.net.v3.3.Ib839d9adc704a04f99743f070d6c8e39dec6a1aa@changeid> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231129132521.net.v3.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> References: <20231129132521.net.v3.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_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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]); Wed, 29 Nov 2023 13:26:40 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783935222782250220 X-GMAIL-MSGID: 1783935222782250220 Delay loops in r8152 should break out if RTL8152_INACCESSIBLE is set so that they don't delay too long if the device becomes inaccessible. Add the break to the loop in r8156b_wait_loading_flash(). Fixes: 195aae321c82 ("r8152: support new chips") Reviewed-by: Grant Grundler Signed-off-by: Douglas Anderson Acked-by: Hayes Wang --- Changes in v3: - Use `break` when we see RTL8152_INACCESSIBLE, not `return`. Changes in v2: - Added Fixes tag to RTL8152_INACCESSIBLE patches. - Split RTL8152_INACCESSIBLE patches by the commit the loop came from. drivers/net/usb/r8152.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index e9955701f455..c4dd81e2421f 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -5521,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)) + break; if (ocp_read_word(tp, MCU_TYPE_USB, USB_GPHY_CTRL) & GPHY_PATCH_DONE) break; usleep_range(1000, 2000); From patchwork Wed Nov 29 21:25:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 171572 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp628823vqn; Wed, 29 Nov 2023 13:26:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IG4ziTdFFSfdIYxjfQei/rVjmNjlDRGaDu1obUQsR9EA3BQoZbQysq0XaWo9dq0BrNrW2OB X-Received: by 2002:a17:90a:1a03:b0:280:2652:d4e with SMTP id 3-20020a17090a1a0300b0028026520d4emr19827577pjk.29.1701293215226; Wed, 29 Nov 2023 13:26:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701293215; cv=none; d=google.com; s=arc-20160816; b=F9i51+yeLECRk+FqKh43kyuN7gxGxH840If6ndlRoZ3Dht5xDsRCPNREmsdSykXXAR bsdnLznBIsMhzSzeLFfd0lJkF/3HMQoj66cU853zlzTMWjWQ4ooEgq3RiKYuv8rXoTt9 oY2z0wVpW3Opr2E11uv4OfZRKxWVzStd8DZ25EtRtttMj0gtoVYlKhPHiTyFIDOjXkLM w1oGVg2vxX4fGl0Irt+Y5v8/m1H6GW+2nq3TqXNISv7TRSbUu2Ng7eLO+ITupF/0N7cB mvUUOa9fpEEMToS3jdwQkIxPtieuD/fwXAlvpq8syCsGSAZfqT5tB0VFYwHIQQih/E/Z QEjw== 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=YbdqD7No7SCueAxJzZPzHLsBDwHJFNtjAFZMErwtoME=; fh=VdJ77sXi4YbaXhBycfIaOIRg0WShF8sXRrTaiSi1nOI=; b=uqsl2d8THVMh8hamSqUE6ZkDpQL+Vrrb6sPXHWFp4BFF6GRQtmIsUjIpH3Tx1DrJJw n6541M1JfNnt/F17sJYltEsbkMqHMIxm94IxAHgF4jGCTBc2O5TLtKc1hUpuv6TOT8rk lEnwt8sQEUJKsCK05EtLL/0DQW5xqesytKpxQKf/8zC4wOKMnj2TkYU/tGUwxl06EFQN 90pa9t+3W0EW7Jo4kssdUoZvWxG0CcKGcHGmMDQpE/eF/LyawiDGzIRTllt27Ip5aDTi MkI35kPwpTz0QCW/TBQpkvXZ9XkFzmfFTmbBnGzo7J9JamFeGfLDxWboKiL7KWOV3wvU T+7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LKw4kFTK; 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 q15-20020a17090a68cf00b0028571ddddfasi1980201pjj.146.2023.11.29.13.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 13:26:55 -0800 (PST) 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=LKw4kFTK; 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 072B38032A21; Wed, 29 Nov 2023 13:26:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234491AbjK2V01 (ORCPT + 99 others); Wed, 29 Nov 2023 16:26:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234427AbjK2V0W (ORCPT ); Wed, 29 Nov 2023 16:26:22 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CD8C10DB for ; Wed, 29 Nov 2023 13:26:28 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6cde104293fso261549b3a.0 for ; Wed, 29 Nov 2023 13:26:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701293188; x=1701897988; 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=YbdqD7No7SCueAxJzZPzHLsBDwHJFNtjAFZMErwtoME=; b=LKw4kFTKjkUYR/kWCjARKDyu5veQQCEcUP2K1je3QBwvmlW6e6ceZ67Rf0IGyDpAly ByojlZg1en/fr8ZOPzWdq7gyZeS3/iHEW54WLHwxVcE41eTkpRYGlcrkoqYbfkZLVVx4 IHfOJsXjCA74y9yYlzAJ8KoHaGlVN7fflVfgg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701293188; x=1701897988; 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=YbdqD7No7SCueAxJzZPzHLsBDwHJFNtjAFZMErwtoME=; b=PCdIekZ8JRJz77J6gR2RHwkweSlKve2Zn3c7jV5+zn4Jl+D0H4YTm60j2lURhddG/3 U9ZWkajxDy9RPyth4x6QmgmNcNELt3g8BVcW8VF5TnFzJYiNMNNDf3q1KNXvzukXBTf6 DHPEKAn2i06oM+Ife7kfgJaB6M5DNKAbaYBFbBMXKCowr/cC33FOXJSi3EbxUmFXKG52 rwhiBs3N/h2AQhjYHzm2jZzLP5zpgfEFs6JjGjbcX7lE2fb5jIjZ0uVcZRBxe+az+zHf /rNrITEQNJtPImZory7eVBUn47L1VTK4+0NwGAIi1fQAMRnsnGdyoXIb4zpEmzh6E2VK X8uQ== X-Gm-Message-State: AOJu0YwRza+fVSY71AqJQyEvVb8GRFGSDYNRUu6eU84KqR9/WPEJ1ujf WB5/l3RLGuDsp3K4ptyeM7EekA== X-Received: by 2002:a05:6a20:1581:b0:18c:c37:35fb with SMTP id h1-20020a056a20158100b0018c0c3735fbmr19950181pzj.40.1701293187747; Wed, 29 Nov 2023 13:26:27 -0800 (PST) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:dcf:15e4:5f50:e692]) by smtp.gmail.com with ESMTPSA id t22-20020a634616000000b005c215baacc1sm11816336pga.70.2023.11.29.13.26.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 13:26:27 -0800 (PST) From: Douglas Anderson To: Jakub Kicinski , Hayes Wang , "David S . Miller" Cc: linux-usb@vger.kernel.org, Grant Grundler , Laura Nao , Edward Hill , Alan Stern , Simon Horman , Douglas Anderson , =?utf-8?q?Bj=C3=B8rn_Mork?= , Eric Dumazet , Paolo Abeni , Prashant Malani , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net v3 4/5] r8152: Add RTL8152_INACCESSIBLE to r8153_pre_firmware_1() Date: Wed, 29 Nov 2023 13:25:23 -0800 Message-ID: <20231129132521.net.v3.4.I9c7bfe6fb76850f0323b3996e25a10ef0281fb7a@changeid> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231129132521.net.v3.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> References: <20231129132521.net.v3.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> 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,T_SCC_BODY_TEXT_LINE 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]); Wed, 29 Nov 2023 13:26:48 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783935234018948739 X-GMAIL-MSGID: 1783935234018948739 Delay loops in r8152 should break out if RTL8152_INACCESSIBLE is set so that they don't delay too long if the device becomes inaccessible. Add the break to the loop in r8153_pre_firmware_1(). Fixes: 9370f2d05a2a ("r8152: support request_firmware for RTL8153") Reviewed-by: Grant Grundler Signed-off-by: Douglas Anderson Acked-by: Hayes Wang --- (no changes since v2) Changes in v2: - Added Fixes tag to RTL8152_INACCESSIBLE patches. - Split RTL8152_INACCESSIBLE patches by the commit the loop came from. drivers/net/usb/r8152.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index c4dd81e2421f..3958eb622d47 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -5645,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); From patchwork Wed Nov 29 21:25:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 171573 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp628862vqn; Wed, 29 Nov 2023 13:27:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3vNUT68es4/0fUFDgEQ+igRRfny7FlngTz0nYuBq9Y0pmid8iVM24rrpVDirPKlJ9Sn8R X-Received: by 2002:a05:6a00:35c7:b0:6cb:4c60:7398 with SMTP id dc7-20020a056a0035c700b006cb4c607398mr18512177pfb.13.1701293220028; Wed, 29 Nov 2023 13:27:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701293220; cv=none; d=google.com; s=arc-20160816; b=KnHggiTlapZo32xDW2iN7Pw1nI53/KMEp4cgD/zGwN0TsP39MHR2ftJMdPsjlD1o+w KeUFVA2v/qhunHTZGAInWV60Fk0TApkXWgb8mIuYIN33upCfsP80+2L5y5mM57D2YUuv kDCkPt7fXEqnEUVfQlXE6gdtSY5Yl4Ei/qvLM0InSpuhv7SntKyHP1wJnGko4eimijQR FMM8ZtrHo2fwCCkOZVOW+SJZc6pEAc06DkwYV1GYOhKLM1l7RSGYyGWJpoGDWM7+JQ74 bMFf9AZJ+T84G16CyKFpmVPeA7dJY9dsJMubrn1UThlEnWcAQZQbKJnRQ6BN9CwZ9Xic n8wA== 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=MOZ1iLO8KtuEsZF7yZy5/8QOIlpTKo1m7A68f7ka2pI=; fh=mRHaPBoaK/yKIiTe7zbQTMuaXdIOIrIp8KgHhHuSvhs=; b=BrULrCmUBlvGmnGdhnO2t7F4pYe5OPR41wqO7f3eBB2doWw/CBnhqbm7OPLgVZPaoj bxNdLhlr1AdXRvv5PHeC4QAsMYN9zBp00SZLBpDfW/I/sLSDf67z1aomaQ5Cl8TDOj8v O8TuHg1PnppJc8A/GVZLuXeTLEI6ke6ISfyiB++aH7j6zWOfGV7kOsyOiWTbjs3ozMwP 1QFAQV3C3QsIivZIQio8CPR+vJWqihuCDQhBA+LcqvIQf498yIP7qZA9Gdu48wOD7ypp GL4F7mw++YcWAz9UnMsBkKQx6dH1c66TmdNVG8nVEQ5zAjo0bNz4qO/Jqt5rSzc8yzXW 7VjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MJHG3FeN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id f27-20020a63101b000000b005b95f5f8976si15096154pgl.634.2023.11.29.13.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 13:27:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MJHG3FeN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 2854781C394B; Wed, 29 Nov 2023 13:26:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234540AbjK2V03 (ORCPT + 99 others); Wed, 29 Nov 2023 16:26:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234456AbjK2V0Y (ORCPT ); Wed, 29 Nov 2023 16:26:24 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1136510C0 for ; Wed, 29 Nov 2023 13:26:30 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-5c18a3387f5so199689a12.1 for ; Wed, 29 Nov 2023 13:26:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701293189; x=1701897989; 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=MOZ1iLO8KtuEsZF7yZy5/8QOIlpTKo1m7A68f7ka2pI=; b=MJHG3FeNRJCV08bAES4RXwkf/jmlD7P+a2DJaKxg4x3vMs+05LcH+QtFy6akdFQxNB GAiYp/SgiSOcPphniGk4d5fikI0D3hXbOwqQqZ6fEN+PsdOdJ9QFKYkGgjSE5/FljEDN 5YZqk667LykslGSxFsmP6n2C6HeqJDnuk3XsQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701293189; x=1701897989; 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=MOZ1iLO8KtuEsZF7yZy5/8QOIlpTKo1m7A68f7ka2pI=; b=VrrWqGyWAK76LYkUKgqnT7ybSoPCduPaPA8NsZBz/K6Y/7AGf2n99x/FUzfbWDdcCI rre5p42Q++Mm2jUXtGE31H/0jaCuzl+geT5Ls46DC8IA3WLOS1wmwo2nfZ1FZaEfQpAF nteETSVVcDT1boglVvHBbVMKa37KeivbpzztEHveG6PNiE8UPvdLtHHO2zg0IS16yYdZ mV2TlL6L6ghyzyoU1pJmBHEYi3Ez0UpTrnNcWNv8yeYS89e0Y0xKkMwi/21JYITZBEDG cMgmnjdYdB8RzZGALpZ72iAl152NnSQzEFB1/i1hdRT+dU/egT+q0IvPm/NtxZk3acK1 6EJg== X-Gm-Message-State: AOJu0YwmPts4070BqyXJpclz0BVFW0Uq42wuXDtz2OalrRxIrxIiHMXL z99afX5Rr4fdXaMOvJUokUZnjw== X-Received: by 2002:a05:6a20:9698:b0:18b:4dc2:a4e1 with SMTP id hp24-20020a056a20969800b0018b4dc2a4e1mr18432953pzc.55.1701293189548; Wed, 29 Nov 2023 13:26:29 -0800 (PST) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:dcf:15e4:5f50:e692]) by smtp.gmail.com with ESMTPSA id t22-20020a634616000000b005c215baacc1sm11816336pga.70.2023.11.29.13.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 13:26:29 -0800 (PST) From: Douglas Anderson To: Jakub Kicinski , Hayes Wang , "David S . Miller" Cc: linux-usb@vger.kernel.org, Grant Grundler , Laura Nao , Edward Hill , Alan Stern , Simon Horman , Douglas Anderson , =?utf-8?q?Bj=C3=B8rn_Mork?= , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net v3 5/5] r8152: Add RTL8152_INACCESSIBLE to r8153_aldps_en() Date: Wed, 29 Nov 2023 13:25:24 -0800 Message-ID: <20231129132521.net.v3.5.I1306b6432228404d6e61b2d43c2f71885292e972@changeid> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231129132521.net.v3.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> References: <20231129132521.net.v3.1.I77097aa9ec01aeca1b3c75fde4ba5007a17fdf76@changeid> 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Wed, 29 Nov 2023 13:26:52 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783935239687019916 X-GMAIL-MSGID: 1783935239687019916 Delay loops in r8152 should break out if RTL8152_INACCESSIBLE is set so that they don't delay too long if the device becomes inaccessible. Add the break to the loop in r8153_aldps_en(). Fixes: 4214cc550bf9 ("r8152: check if disabling ALDPS is finished") Reviewed-by: Grant Grundler Signed-off-by: Douglas Anderson Acked-by: Hayes Wang --- (no changes since v2) Changes in v2: - Added Fixes tag to RTL8152_INACCESSIBLE patches. - Split RTL8152_INACCESSIBLE patches by the commit the loop came from. drivers/net/usb/r8152.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 3958eb622d47..fcdc9ba0f826 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -5803,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;