Re: [PATCH v2 net-next 02/15] MIPS: SGI-IP27: restructure ioc3 register access

From: Shannon Nelson
Date: Thu Aug 29 2019 - 17:26:41 EST

On 8/29/19 8:50 AM, Thomas Bogendoerfer wrote:
Break up the big ioc3 register struct into functional pieces to
make use in sub-function drivers more straightforward. And while
doing that get rid of all volatile access by using readX/writeX.

Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@xxxxxxx>

diff --git a/arch/mips/sgi-ip27/ip27-console.c b/arch/mips/sgi-ip27/ip27-console.c
index 6bdb48d41276..5886bee89d06 100644
--- a/arch/mips/sgi-ip27/ip27-console.c
+++ b/arch/mips/sgi-ip27/ip27-console.c
@@ -35,6 +35,7 @@ void prom_putchar(char c)
struct ioc3_uartregs *uart = console_uart();
- while ((uart->iu_lsr & 0x20) == 0);
- uart->iu_thr = c;
+ while ((readb(&uart->iu_lsr) & 0x20) == 0)
+ ;
+ writeb(c, &uart->iu_thr);

Is it ever possible to never see your bit get set?
Instead of a tight forever spin, you might add a short delay and a retry limit.

I see this in several other times in the following code as well. It might be interesting to see how many times through and perhaps how many usecs are normally spent in these loops.

Not a binding request, just a thought...