From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796382795; b=4jMmE6ksCTuNVo3QL35j+aeTgUi1xPL5o2bXVC68NRE6usz3NSL6UjJxa+hR+Sw2bMs2 z1dvvUuIVMOXV6IJpgF3MZ3hdKj6bi8xduV3Wd1mwOX+eH00gp60MOg+UToJK840SaoXt v5tNB2pmLbJYfVgcOTi/toK/O7ZWuJlfehno5Yg0e7TCK8Mj0POYtakkyFs3gyyXZIJrC R5ILg630XDNaMcmtuduKycmzB6tZ0c6wXdTU6Ryp2rLpHhBAmeleUkjJkv94FJMQhIYYs vMafkOtncFFRVlv2MtwMVt34Vf3Lzen4PN+B+zdt+2CQ8DOqh/9X9/oihFZfmHjakPA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382795; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=nVDX6vBrbH39TEeulTTjR/lkPM4uAeYFI+WqhmAgItM=; b=wKdxyLjA2oss1f2lexHUMYcxqg+ZAhMvHYi4ElFGhZOtlwF5ENTEM9cSpCsGbMPhsdHD xHUsik52aKEuOmrpkh9NMMRRYmjlQBP7VfymRacoTT5hlyXUz3RKtM10P7r9b+zQajsNO RjpNXDHqqUzL/H5wVyj07cKDzynq4NfbaVZ/FZTDAmChliuT29XCOpYSMtBISr17Na6cN FytmuZ2Z7bEIX2Oj8z6c19CLdDxiMXsuDuRiw9LT44lAB6V2r35V20okWFuQMGZWj+zXw LnctlUyV6L9gEXpEN+YZJ/QYCh9G/+AR0Dw8P03cYyzrX9i7Io+NqYW4O6VzXPm6V/A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=b9ykws1m; arc=none smtp.remote-ip=209.85.221.50 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3619606A32F for ; Fri, 4 Dec 2026 11:13:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A3619606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=b9ykws1m Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-491971ac844so736045f8f.2 for ; Fri, 04 Dec 2026 03:13:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796382793; x=1796987593; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=nVDX6vBrbH39TEeulTTjR/lkPM4uAeYFI+WqhmAgItM=; b=b9ykws1mWbK/3eaIwBhwXBJadWIDGYKMq6NGomq1QzWd4ITIzLGZj2PC0s+CDlBx3G ilBFdZFqdVYUugLZ72SSnmCqiXiy7MeGvmOtPTjrbiq568puMhElLLpm+/lFpO6mUY1W MWn7joRsjJBBn54u4FMSu88R6NBfNTSdbzJ+RRj0YPmiP/s4rIdV/dsfv65MPhgSmP11 XQNpeBLT7uJOKrZPKrrwDHBdCBgDyYaohXzJN4Mubk2GwcV1Co5et2Vh9gc2CQ8fNzD5 GQ0L60SkduEryOZk7ZX1SLJH/8f3e839FF6LAWCl6ZyX6HX8vTr7DfGfYwR7K9614rEj tcRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796382793; x=1796987593; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=nVDX6vBrbH39TEeulTTjR/lkPM4uAeYFI+WqhmAgItM=; b=DJ89h8RZfG3mMKYbQoHFUY7/ByqH8bNuq+EBWRZoQfY1WdafkwDqgJ+pC5Ymgo/znh 6MDa+mPF6Gl390aV+rPF/AQJ+6tsqpRNNUe8n0VE2VnZYS0lBUEJ/iYhNON01OTmzV0b do+XDDZ0jGxIfpFrY3eaVtA8KSoWZj1sW9ExngTfCQEg80CRdCvPARl8KMsx4WSyemwF YbQFkxHVCGtQrh5J9t9+0iRvAXQpUFkIZID97lCbqrrWZZxZnRAZrc637fU7iNAv0Km2 O5Uyd5reVMxS6cqT4cIr2budpVrUx4+bl7jipm033WV08hkfy1XtYv41Egl0RQ5L7uKh XYwA== X-Forwarded-Encrypted: i=1; AL+hErH/hiIlTBFfFY0iYK2mx5eHB3lYev83Sy3+u4jcucG55DstvaCSSceHRicJd/FoD6oLs1PHzFIkl4M=@vger.kernel.org X-Gm-Message-State: APuU4Z8VNsf92PdQOOnG8vpCk1P9aX/O/RLTBOMY/qyLNu0z6US7l/Xh bUdhql7oqBfyRcHob77u7LHISPUIeRinJElWTAduDjQFJjK/f0tV6GXEmWiptA== X-Gm-Gg: AZFdTZcytqD31KvNLBhwv/W2+mI6RE9MNDkK0vaG0yWQfQ8d1gQcFLGNaL5cRRcTjrf P5AsEnn4RVtgojxP+5oarlXdaiWX88b1elLmITadfcyXf7Ytq10XLdQanuIWBdVn1P5Ifa53zEZ sJIx/cK0kE2y6WeRJklDd3cVr0vrh5n4sRYiGd3TgsMJMCB35MNW4e5aXo8IAVlx9B8NHKJ8JMF RIs2PhPTxT35jL3RoY7d0F2KjDWIwAGcbH9+eGOBq9Iw+nFQQyz32Bd7trqJUVK1nMMtQ7z0+Tl rvrmFWY9R0Exbp7/UEueIglyzexlz5EGIbYvh4fEFNah7i5Bnt3PTcnhmrnNz9XIpECbFuBp/G4 KEpD7aWdIt4pDCUDJFBBEcRS1XN+Ci123r1OcTRoJQrofu3rTYnOAroO9PtiI+VMxPqMNGi6W1A 6zJOj45xmpq9j2XuIGca8M3UUwLeInnIRlOU74AO+U1Xg82Wi2ML30dRSvH/08XKKhfBL3OlJGJ Acw59IE9pcdbp7URqcnxIL60pQ1272028kSOx7Knme+T1Djk6xySwaL3KcaOprHFTU7T1BQ8Zb5 9fubK13+ZEJn/xCYkfmehqSt+KtDtjyO5K7JkjFM5ZuYTmMh0L+/gjv+56o= X-Received: by 2002:a5d:5888:0:b0:487:1ac0:32af with SMTP id ffacd0b85a97d-4d1ec91ac4cmr3130924f8f.51.1796382792954; Fri, 04 Dec 2026 03:13:12 -0800 (PST) Received: from foxbook (bfj60.neoplus.adsl.tpnet.pl. [83.28.47.60]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d174452809sm4852192f8f.53.2026.12.04.03.13.12 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 04 Dec 2026 03:13:12 -0800 (PST) Date: Fri, 4 Dec 2026 12:13:16 +0100 From: Michal Pecio To: Henry Tseng Cc: Mathias Nyman , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: Re: [PATCH 1/2] xhci: make xhci_handshake() timeout wall-clock based again Message-ID: <20261204121316.71a9cf59.michal.pecio@gmail.com> In-Reply-To: <20260930101752.15794-2-henrytseng@qnap.com> References: <20260930101752.15794-1-henrytseng@qnap.com> <20260930101752.15794-2-henrytseng@qnap.com> X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 30 Sep 2026 18:17:51 +0800, Henry Tseng wrote: > xhci_abort_cmd_ring() waits for the command ring to stop with > xhci_handshake() and a 5 s timeout. On an AMD Raven USB 3.1 xHCI > (1022:15e0), after a configure endpoint command failed to complete > during device disconnect, that handshake returned -ETIMEDOUT 15.8 s > later: > > [ 86.086412] xhci_hcd 0000:0c:00.3: Command timeout, USBSTS: 0x00000010 PCD > [ 86.086450] xhci_hcd 0000:0c:00.3: Abort command ring > [ 101.924383] xhci_hcd 0000:0c:00.3: Abort failed to stop command ring: -110 > > xhci_abort_cmd_ring() is called from xhci_handle_command_timeout() with > xhci->lock held, so interrupts were disabled on that CPU for the whole > 15.8 s. > > The timeout budget is no longer tied to elapsed time. xhci_handshake() > originally polled with readl(), udelay(1) and a decrementing > microsecond counter. Commit f7fac17ca925 ("xhci: Convert > xhci_handshake() to use readl_poll_timeout_atomic()") replaced that loop > with readl_poll_timeout_atomic(), which at the time computed its > deadline with ktime_get(). Its commit message notes that this also > fixed a bug on AMD Stoneyridge, where udelay(1) sometimes took over > 10 ms and a 5 s timeout ran for over 15 s, triggering the watchdog. > Commit 7349a69cf312 ("iopoll: Do not use timekeeping in > read_poll_timeout_atomic()") then replaced that deadline with a locally > estimated one, which does not account for the readl(), however long it > takes. > > To fix this, restore the readl() and udelay() loop, with the > decrementing microsecond counter replaced by a ktime deadline. > > Signed-off-by: Henry Tseng These timeouts are indeed longer than intended, I have seen it myself. But there is another option: increase 'delay_us'. For example, going from 1 to 10 reduces abort timeout from 16s to 6s on my system, without reinventing the wheel. Seems good enough? Regards, Michal