public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: Zhongqiu Han <quic_zhonhan@quicinc.com>, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [PATCH] tty: mips_ejtag_fdc: Call cpu_relax() in registers polling busy loops
Date: Fri, 20 Dec 2024 08:16:34 +0100	[thread overview]
Message-ID: <99b481f1-7e0d-4c78-8099-6a6466f6a87a@kernel.org> (raw)
In-Reply-To: <20241219124254.321778-1-quic_zhonhan@quicinc.com>

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@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();

Can this instead be switched to read_poll_timeout_atomic() or alike? 
Those already contain cpu_relax(), of course...

thanks,
-- 
js
suse labs

  parent reply	other threads:[~2024-12-20  7:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2024-12-20 14:37   ` Zhongqiu Han

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=99b481f1-7e0d-4c78-8099-6a6466f6a87a@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=quic_zhonhan@quicinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox