[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <99b481f1-7e0d-4c78-8099-6a6466f6a87a@kernel.org>
Date: Fri, 20 Dec 2024 08:16:34 +0100
From: Jiri Slaby <jirislaby@...nel.org>
To: Zhongqiu Han <quic_zhonhan@...cinc.com>, gregkh@...uxfoundation.org
Cc: linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org
Subject: Re: [PATCH] tty: mips_ejtag_fdc: Call cpu_relax() in registers
polling busy loops
On 19. 12. 24, 13:42, Zhongqiu Han wrote:
> 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@...cinc.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();
Can this instead be switched to read_poll_timeout_atomic() or alike?
Those already contain cpu_relax(), of course...
thanks,
--
js
suse labs
Powered by blists - more mailing lists