From nobody Mon Jun 8 12:11:46 2026 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 6DABA3B8BA5 for ; Fri, 29 May 2026 09:05:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780045518; cv=none; b=oAkhaiYtrcRPSZtdLV+nT+Z4OQYtpx5QLJcITKXgkQ4zNzcvkLl5MQuGD2dintWNY2TAih6noLvF0MxPBEqETy/9vXfKEOmndFlaCIiiEIAgNKbRn5BiCT5JatwEvz7fMqNCw1lgVXbJtbQbihGmum5Khi2jb7fsu0yfh9jhFOU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780045518; c=relaxed/simple; bh=6/4ydw5s/iaq6poXIuJBHDyGmmyhrg0/yKjMttGBOBE=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=jedqiSL3ONlyxvpwmN/rGcrecvmbMt1lOugZDb7y4lYWLWZhgUj3jQsHEQsNeRdHIl7lGyGOjqGhP2mL+u5bpzGN02iGQogADduuqKWkqFU5Lyl+v6gL1Vw/96EGpKvqICgUO/6j7fRQdkQqDKOuvVjvtmtflPdJahnfiYZSDpo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=pKyCcyXK; arc=none smtp.client-ip=209.85.128.49 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.b="pKyCcyXK" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-49039a8851fso80659075e9.2 for ; Fri, 29 May 2026 02:05:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780045516; x=1780650316; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:subject:cc:to :from:date:from:to:cc:subject:date:message-id:reply-to; bh=YHQcc7Z4aI0VEcc8CWWx1n+N4u8iP52vYgOu5CKwS8s=; b=pKyCcyXKV8C6D4divL2SLjcOiXJnJ7NhAcjsJ+f8SHfQdhTLsS+JuuP20NSQS5ShSo XEAkvDULoyU25CexVjFWH9V5Wmig69kd1z7FGcckPZzGbz6ifsclyzZMfsvNQtcEWTnN M2JgJAHVbU6LT0u7moNq94qXZ3q7FZ0wbApp8zh4tw/+GaDNF4fpgvF1nrv7goDLxLZ0 rCkhqARaZn6StpMQ1Yei2IWYGJrZNd23DgUInCtMmW3Ch65t7mMcH8XthkJQg8jGZegp aHYgFxJzK7ZPm09JEGbBBKo7fSk3j/jgepY9lxWueoFoAKlGibnjJp89ZMfmvalzHyMb SXqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780045516; x=1780650316; h=content-transfer-encoding:mime-version:message-id:subject:cc:to :from:date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YHQcc7Z4aI0VEcc8CWWx1n+N4u8iP52vYgOu5CKwS8s=; b=KW0whCCyXNUKR9ed5iqDt6h+n6x7cy2moiDVxsEL9+dGwIv4mI/YoDDaR5aMQI14Tg 2NuiZ50Z3tIBpG3QGXJ03XskPQxcGl/XV1eZO2CmQiiSDplxbN8ZQ3qaqEptYQTGDlKj A6cyzWFIpjAvGpEmRKnekbEmTUmLesac6EERdG1rPzdP+bXRC98ja2yGeNYghoYGLrRi J8Ul8pFhnSjlpYv5/1LB1YIi0giFxI94YnrQcs0Q7yk31IiLlKN9itRlqVwAQw0tp/iU ZZ1kwWehsmKfTQGD9RCGa4a0BLVhfOf9o8ItED+gi5iT46tO8QkQaKDfNvtf2hjPvYBT W4Ig== X-Forwarded-Encrypted: i=1; AFNElJ8wPom4hB352B+rMjVNwAty0mPv1B0NEEs7smRYkVKVRqWsAsKm38eCvGs+r/v3jvHlJZw/Lw/MPA0Pas8=@vger.kernel.org X-Gm-Message-State: AOJu0YwIUo1c9mnBVYlxHYHR6SW28XGntsn4rdXkab1t+be7/F7i2RZg mdA+Btvsg+ATOciOjRelUhfNM4pqcjjKuRWM3t0fF76oNyt9Tsff7ibuJHTQrg== X-Gm-Gg: Acq92OGofohgPbFjWiIWMV+25YySV2r3F2WawDeh6yddbJhWviL/2A9/2EHqIJsPD7C FQf9YMmqcGCZesmtntp6yOApK5NUFOW/rTqVzhqxYlnLbc7P3uG5lV4yXqgb7wRLcA/H140an2V LCwSVSXWQLBX5o7viJkzWCbXKzJZpwvrazpYwBYv7eu/mdRYevekEzHTAiowoitY6VEfLle8qpX Bbq+O4ML9315N9zGqAjWIPJIfvOSvTX1o+106zJYFt8pgnaP5f7mdAzEqDng/CTrlcFnFgmXoGa Dei7k7pmiOkv3iLfoe7eGY76S9YC5jfR+HH7h/nHjV3P/CbgL8SD59qiBlYBoqHOfYJWOdGbYj/ 5TWQKnpZc3KFcR4U0ibguU/hnbOz6LOGD7KMxu/qKHnccRyDsWY+T6Kb9MxbXC+2ouahmC2tTJu nq69DFaHBBGutuvJRiyz7WYcbJFB1ZiWEHUJl+e3qUdNYPCGJr6Y0myEEC X-Received: by 2002:a05:600c:6287:b0:48a:58ae:993b with SMTP id 5b1f17b1804b1-4909c0ac81bmr36499935e9.16.1780045515518; Fri, 29 May 2026 02:05:15 -0700 (PDT) Received: from foxbook (bfe246.neoplus.adsl.tpnet.pl. [83.28.42.246]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45ef34bcc30sm1987465f8f.12.2026.05.29.02.05.14 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 29 May 2026 02:05:15 -0700 (PDT) Date: Fri, 29 May 2026 11:05:10 +0200 From: Michal Pecio To: Mathias Nyman , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: xhci: Simplify xhci_quiesce() Message-ID: <20260529110510.64115fce.michal.pecio@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The function reads USBCMD, clears some bits and writes it back. Its treatment of the Run bit is weird: the bit is usually written as 0, as we would expect, but it may also be written as 1 if both its current value and USBSTS.HCHalted are observed as 1. Per xHCI 5.4.2, HCHalted is 0 whenever Run is 1, so the above can only happen due to buggy HW or SW, e.g. concurrent xhci_quiesce() and xhci_start() execution. It's unclear why we should treat such cases specially and write the bit as 1. The logic comes from original PoC implementation and has never been explained. Just write 0 every time, which looks like the safer choice when the intent is to stop the xHC. We could get in trouble if clearing Run causes some very broken xHC to start running after it was halted, but no such case has been documented. It seems the logic was just poorly thought out. Signed-off-by: Michal Pecio --- Hi Mathias, I'm not aware of this causing any problem. But I wasted a few minutes trying to understand the point of this code, until I was forced to conclude that it doesn't seem to have any point whatsoever. Maybe getting rid of it will save somebody else another few minutes. The removal seems harmless. drivers/usb/host/xhci.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index ccd07e4495cb..acdc9254b92c 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -102,17 +102,10 @@ int xhci_handshake(void __iomem *ptr, u32 mask, u32 d= one, u64 timeout_us) */ void xhci_quiesce(struct xhci_hcd *xhci) { - u32 halted; u32 cmd; - u32 mask; - - mask =3D ~(XHCI_IRQS); - halted =3D readl(&xhci->op_regs->status) & STS_HALT; - if (!halted) - mask &=3D ~CMD_RUN; =20 cmd =3D readl(&xhci->op_regs->command); - cmd &=3D mask; + cmd &=3D ~(CMD_RUN | XHCI_IRQS); writel(cmd, &xhci->op_regs->command); } =20 --=20 2.48.1