Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2697736lqo; Mon, 20 May 2024 13:42:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV5HnMGeSDni78DoM3PnMZJTp6WCIOZRTxFm4xsME45kuHrLI3jsDSbDlMvUJm2xzKWw1eGrASOYiXIbHO8sT34vwV8uLXnnKs0nPnpfA== X-Google-Smtp-Source: AGHT+IGkJwsAMX+q7mf1FFWy1mA6mzxUBe0quLgP+DL3Zql2cPJH7d27S76KmtjXQYW1tVfGXmgD X-Received: by 2002:a05:6359:5a8c:b0:183:e72e:ce04 with SMTP id e5c5f4694b2df-193bb656ac6mr3154107055d.16.1716237773336; Mon, 20 May 2024 13:42:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716237773; cv=pass; d=google.com; s=arc-20160816; b=KcKDYcBJd5b1H0t/sbm+U4LAtsr1r16BCGGpI6VjqkXRJvljt9uK5s8CGJN/uDVgJF W8GIrGsX1cCGRd/4APVrn6c9834ZCOyVz1PQNjm4mnDIz2HYtOhZb6dpOZlSkTwpiouf lx6psP6x373OTxX0+ck7s8zxe3803I0u2eYkai490/gkzx/FZoJlEy1gnzBMglqaBe8J RdnQj1Wam02aeH+aTa1kFgU7VbXWw9XM9EMfLkzr19rW5FB54ardHqPMG6zSGAS/oU9y oMPI0khHaz4o/AjOT3iYIn1R/CTeKXo4a3MYGxecpdr9qvcCFP9aN0SM6svVxFWkY3Vh H2Zg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=P7tYjQOKUhhyypRv+20xcgSB/ZPEIGDyWUW6MmS8mUM=; fh=dzwAgxUNodH8N8F8ep5FXnV2OaJKOeFR0Nje1h7A8pU=; b=fePLmTR159YlPkhT2Ewn+BNMYOG/cbuNK1JhqoiPgClMzmABwvRwRqqKRjxm3siapm 57NhB20UgaExHbN8IMBKvK7urBSaE5YkdfM8DdXa72A+1hZiWhGWnIRPkp41+7qRSCxq DLvSjHBKWFOzg3w6vSLNAAvnuA18Q4+jCMrZ1agZGIHqexa29J5+XugAfB3j4mT6LsLl OUXqa9sj0miEtHfD3Pzqa0yL8ONFyFtqIqIgUbCIaCemoFdqI8YSGtSYTvKHGps+8Z0U VshJf8aHxmjEQB161x57yRHi9DUxf+VPvR4/2i9rkQN5e/ORILdplOLPgh1hHNiX6+hd ut7w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=c5qDFkTd; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-184169-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184169-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-639c8a877d0si21466865a12.228.2024.05.20.13.42.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 13:42:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184169-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=c5qDFkTd; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-184169-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184169-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7EFFB280D8A for ; Mon, 20 May 2024 20:42:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B2B9013A415; Mon, 20 May 2024 20:42:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="c5qDFkTd" Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69AFC13A3EF for ; Mon, 20 May 2024 20:41:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716237719; cv=none; b=A/XIw+nqTEOmdTeB+jgveuEy9g/VhKxp1JvDs8TWZE6+faZETtvehcZbjSI0AiCPB8Al7Gc5LC8HxDdYEY5sRFW66GSkP6+qSazfZHZdaeXa17s8bHgcjO0Rl3dw3I5ZO5Y48GvAonJIRDlvuOWdPCusK/Jm578YgxR98EXhsuU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716237719; c=relaxed/simple; bh=KLAoNg3lNimMGEM1iK1E2E71QyftAe7H7PKPd5zQpd0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ZhhsOogI3eYFHd8TYFWWuykm/HSEbpJfKNL10RqS41IOR6Vx9kqX/0dju4BPpCm+TWaubR72k/zgJeGd8GHPoe3Fsa+3z9UWzhXGn26kdOGejvsIdx7COBOR83b08uPS4SUAm+ZzgtgDQFu5mL8EdpV+UjvhYj+YMqCfmoskPIg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=c5qDFkTd; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1ed0abbf706so19641885ad.2 for ; Mon, 20 May 2024 13:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1716237717; x=1716842517; 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=P7tYjQOKUhhyypRv+20xcgSB/ZPEIGDyWUW6MmS8mUM=; b=c5qDFkTdGW/PkzxKKeC19A10gpemAfXqRD6QFIiBGcrWjQH1Yk+DMgRZ3sUkWVjUvl uLnSjKX+gueJ2JS0QjrZNiYu46IoGMT9W2buQcHovUkMTpVVJET65QI083rLJGQheHly WwaDX5m+tO054qE1Ukf/NgHLlcam90K0hLJGQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716237717; x=1716842517; 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=P7tYjQOKUhhyypRv+20xcgSB/ZPEIGDyWUW6MmS8mUM=; b=iuX9lkItSHErOroFeAo5JWLvfbmrqYNc8jyXlJUqCD/dEnYfPj5WgppiOV2xo2LW1r R+85Afd1bByLDaTIcvqncBrp4dlte3/StUv37ZYNu0v9Z8eQjq75eNRepbqByIPACL5D nAK1kbY7QvG4jqLop5egJDMmm2oOUH9z2WI3oBjt0pgRqv7iIV47w40VqT52l0CGkRWj zaT37rvynZ4Mx6TE0UhUXCGjS3PhjWjc7UPC8V6F0tpw87BuloiYpVU1Hzjo9zXibs67 htOXAInlAtXp9R5qZrHK9774SS+vWuU47uK9CR4jPfzItUeaOpMb67OfyY/faNJuCPeI hKEA== X-Forwarded-Encrypted: i=1; AJvYcCU6ywVmhBEbjhRWbMR4Hs5nW4o8H9S5V46Oo3e6nUvk5PvF4wjftQgA/43+C4JH2jcUCKrbzNCApeamvuLxL3PHx1PczwI3sDcIJKCx X-Gm-Message-State: AOJu0Yxarx96tLcS0b5MevTk2Q6Km5wFxyuCYNc3d5sUyFtrNquxpsXQ 9mnx8cBEwJp1EyTP233V5lAoBXBT+hsLxX2zxkv6KZoBVLPMjibqBLfTzZZymw== X-Received: by 2002:a17:902:e54d:b0:1f3:590:71d9 with SMTP id d9443c01a7336-1f3059073f7mr34219075ad.2.1716237717581; Mon, 20 May 2024 13:41:57 -0700 (PDT) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:cd20:112a:72ca:4425]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0bbde9d7sm213068255ad.106.2024.05.20.13.41.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 13:41:57 -0700 (PDT) From: Douglas Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Hayes Wang Cc: danielgeorgem@google.com, Douglas Anderson , Andrew Lunn , Grant Grundler , Heiner Kallweit , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next 1/2] r8152: If inaccessible at resume time, issue a reset Date: Mon, 20 May 2024 13:41:11 -0700 Message-ID: <20240520134108.net-next.1.Ibeda5c0772812ce18953150da5a0888d2d875150@changeid> X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit If we happened to get a USB transfer error during the transition to suspend then the usb_queue_reset_device() that r8152_control_msg() calls will get dropped on the floor. This is because usb_lock_device_for_reset() (which usb_queue_reset_device() uses) silently fails if it's called when a device is suspended or if too much time passes. Let's resolve this by resetting the device ourselves in r8152's resume() function. NOTE: due to timing, it's _possible_ that we could end up with two USB resets: the one queued previously and the one called from the resume() patch. This didn't happen in test cases I ran, though it's conceivably possible. We can't easily know if this happened since usb_queue_reset_device() can just silently drop the reset request. In any case, it's not expected that this is a problem since the two resets can't run at the same time (because of the device lock) and it should be OK to reset the device twice. If somehow the double-reset causes problems we could prevent resets from being queued up while suspend is running. Signed-off-by: Douglas Anderson --- drivers/net/usb/r8152.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 19df1cd9f072..6a3f4b2114ee 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -8554,6 +8554,19 @@ static int rtl8152_system_resume(struct r8152 *tp) usb_submit_urb(tp->intr_urb, GFP_NOIO); } + /* If the device is RTL8152_INACCESSIBLE here then we should do a + * reset. This is important because the usb_lock_device_for_reset() + * that happens as a result of usb_queue_reset_device() will silently + * fail if the device was suspended or if too much time passed. + * + * NOTE: The device is locked here so we can directly do the reset. + * We don't need usb_lock_device_for_reset() because that's just a + * wrapper over device_lock() and device_resume() (which calls us) + * does that for us. + */ + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) + usb_reset_device(tp->udev); + return 0; } -- 2.45.0.rc1.225.g2a3ae87e7f-goog