public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tty: mips_ejtag_fdc: Call cpu_relax() in registers polling busy loops
@ 2024-12-19 12:42 Zhongqiu Han
  2024-12-19 13:28 ` Greg KH
  2024-12-20  7:16 ` Jiri Slaby
  0 siblings, 2 replies; 7+ messages in thread
From: Zhongqiu Han @ 2024-12-19 12:42 UTC (permalink / raw)
  To: gregkh, jirislaby; +Cc: linux-kernel, linux-serial, quic_zhonhan

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, or 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@quicinc.com>
---
 drivers/tty/mips_ejtag_fdc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/mips_ejtag_fdc.c b/drivers/tty/mips_ejtag_fdc.c
index afbf7738c7c4..b17ead1e9698 100644
--- a/drivers/tty/mips_ejtag_fdc.c
+++ b/drivers/tty/mips_ejtag_fdc.c
@@ -346,7 +346,7 @@ static void mips_ejtag_fdc_console_write(struct console *c, const char *s,
 
 		/* Busy wait until there's space in fifo */
 		while (__raw_readl(regs + REG_FDSTAT) & REG_FDSTAT_TXF)
-			;
+			cpu_relax();
 		__raw_writel(word.word, regs + REG_FDTX(c->index));
 	}
 out:
@@ -1233,7 +1233,7 @@ static void kgdbfdc_push_one(void)
 
 	/* Busy wait until there's space in fifo */
 	while (__raw_readl(regs + REG_FDSTAT) & REG_FDSTAT_TXF)
-		;
+		cpu_relax();
 	__raw_writel(word.word,
 		     regs + REG_FDTX(CONFIG_MIPS_EJTAG_FDC_KGDB_CHAN));
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-12-26 13:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-19 12:42 [PATCH] tty: mips_ejtag_fdc: Call cpu_relax() in registers polling busy loops Zhongqiu Han
2024-12-19 13:28 ` Greg KH
2024-12-20 13:46   ` Zhongqiu Han
2024-12-20 15:06     ` Greg KH
2024-12-26 13:38       ` Zhongqiu Han
2024-12-20  7:16 ` Jiri Slaby
2024-12-20 14:37   ` Zhongqiu Han

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox