lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240820121501.3593245-3-quic_zhonhan@quicinc.com>
Date: Tue, 20 Aug 2024 20:15:01 +0800
From: Zhongqiu Han <quic_zhonhan@...cinc.com>
To: <Thinh.Nguyen@...opsys.com>, <gregkh@...uxfoundation.org>,
        <mathias.nyman@...el.com>
CC: <linux-usb@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <quic_zhonhan@...cinc.com>
Subject: [PATCH 2/2] usb: xhci: ext-caps: Use cpu_relax() when polling registers

It is considered good practice to call cpu_relax() in busy loops, see
Documentation/process/volatile-considered-harmful.rst. This can lower
CPU power consumption or yield to a hyperthreaded twin processor and
also serve as a compiler barrier. In addition, if something goes wrong
in the busy loop at least it can prevent things from getting worse.

Signed-off-by: Zhongqiu Han <quic_zhonhan@...cinc.com>
---
 drivers/usb/host/xhci-ext-caps.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h
index 96eb36a58738..25d148d60ab0 100644
--- a/drivers/usb/host/xhci-ext-caps.h
+++ b/drivers/usb/host/xhci-ext-caps.h
@@ -144,6 +144,8 @@ static inline int xhci_find_next_ext_cap(void __iomem *base, u32 start, int id)
 		if (offset != start && (id == 0 || XHCI_EXT_CAPS_ID(val) == id))
 			return offset;
 
+		cpu_relax();
+
 		next = XHCI_EXT_CAPS_NEXT(val);
 		offset += next << 2;
 	} while (next);
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ