Skip to contentSkip to conversation

xen/arm: debug-pl011: Use 32-bit accessors for broader compatibility

PATCH In review Michal Orzel 5 participants 11 messages Jun 1, 2023 – Jun 6, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: debug-pl011: Use 32-bit accessors for broader compatibility

There are implementations of the PL011 that can only handle 32-bit accesses (i.e. no 16-bit or 8-bit), usually advertised by 'reg-io-width' dt property set to 4. On such UARTs, the current early printk code for arm64 does not work. To fix this issue, make all the accesses to be 32-bit by using ldr, str without a size field. This makes it possible to use early printk on such platforms, while all the other implementations should generally cope with 32-bit accesses. In case they do not, they would already fail as we explicitly use writel/readl in the runtime driver to maintain broader compatibility and to be SBSAv2 compliant. Therefore, this change makes the runtime/early handling consistent (also it matches the arm32 debug-pl011 code).

---
 xen/arch/arm/arm64/debug-pl011.inc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
xen/arch/arm/arm64/debug-pl011.inc +4 -4
index 6d60e78c8ba3..80eb8fdc1ec7 100644
@@ -25,9 +25,9 @@
  */
 .macro early_uart_init xb, c
         mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE % 16)
-        strh  w\c, [\xb, #FBRD]      /* -> UARTFBRD (Baud divisor fraction) */
+        str   w\c, [\xb, #FBRD]      /* -> UARTFBRD (Baud divisor fraction) */
         mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE / 16)
-        strh  w\c, [\xb, #IBRD]      /* -> UARTIBRD (Baud divisor integer) */
+        str   w\c, [\xb, #IBRD]      /* -> UARTIBRD (Baud divisor integer) */
         mov   x\c, #WLEN_8           /* 8n1 */
         str   w\c, [\xb, #LCR_H]     /* -> UARTLCR_H (Line control) */
         ldr   x\c, =(RXE | TXE | UARTEN)
@@ -41,7 +41,7 @@
  */
 .macro early_uart_ready xb, c
 1:
-        ldrh  w\c, [\xb, #FR]        /* <- UARTFR (Flag register) */
+        ldr   w\c, [\xb, #FR]        /* <- UARTFR (Flag register) */
         tst   w\c, #BUSY             /* Check BUSY bit */
         b.ne  1b                     /* Wait for the UART to be ready */
 .endm
@@ -52,7 +52,7 @@
  * wt: register which contains the character to transmit
  */
 .macro early_uart_transmit xb, wt
-        strb  \wt, [\xb, #DR]        /* -> UARTDR (Data Register) */
+        str   \wt, [\xb, #DR]        /* -> UARTDR (Data Register) */
 .endm
 
 /*
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Michal,

Quoted 16 lines

-----Original Message-----
Subject: [PATCH] xen/arm: debug-pl011: Use 32-bit accessors for broader compatibility

There are implementations of the PL011 that can only handle 32-bit accesses (i.e. no 16-bit or 8-bit), usually advertised by 'reg-io-width' dt property set to 4. On such UARTs, the current early printk code for arm64 does not work. To fix this issue, make all the accesses to be 32-bit by using ldr, str without a size field. This makes it possible to use early printk on such platforms, while all the other implementations should generally cope with 32-bit accesses. In case they do not, they would already fail as we explicitly use writel/readl in the runtime driver to maintain broader compatibility and to be SBSAv2 compliant. Therefore, this change makes the runtime/early handling consistent (also it matches the arm32 debug-pl011 code).

Quoted 1 line

Kind regards,
Henry

#2 lore raw
In reply to Michal Orzel

Hi Michal,

Quoted 48 lines · Michal Orzel

There are implementations of the PL011 that can only handle 32-bit accesses (i.e. no 16-bit or 8-bit), usually advertised by 'reg-io-width' dt property set to 4. On such UARTs, the current early printk code for arm64 does not work. To fix this issue, make all the accesses to be 32-bit by using ldr, str without a size field. This makes it possible to use early printk on such platforms, while all the other implementations should generally cope with 32-bit accesses. In case they do not, they would already fail as we explicitly use writel/readl in the runtime driver to maintain broader compatibility and to be SBSAv2 compliant. Therefore, this change makes the runtime/early handling consistent (also it matches the arm32 debug-pl011 code).

---
xen/arch/arm/arm64/debug-pl011.inc | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
xen/arch/arm/arm64/debug-pl011.inc +0 -0
index 6d60e78c8ba3..80eb8fdc1ec7 100644
@@ -25,9 +25,9 @@
 */

.macro early_uart_init xb, c

        mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE % 16)
xen/arch/arm/arm64/debug-pl011.inc +2 -2
-        strh  w\c, [\xb, #FBRD]      /* -> UARTFBRD (Baud divisor fraction) */
+        str   w\c, [\xb, #FBRD]      /* -> UARTFBRD (Baud divisor fraction) */
        mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE / 16)
-        strh  w\c, [\xb, #IBRD]      /* -> UARTIBRD (Baud divisor integer) */
+        str   w\c, [\xb, #IBRD]      /* -> UARTIBRD (Baud divisor integer) */
        mov   x\c, #WLEN_8           /* 8n1 */
        str   w\c, [\xb, #LCR_H]     /* -> UARTLCR_H (Line control) */
        ldr   x\c, =(RXE | TXE | UARTEN)
@@ -41,7 +41,7 @@
 */

.macro early_uart_ready xb, c
1:

xen/arch/arm/arm64/debug-pl011.inc +1 -1
-        ldrh  w\c, [\xb, #FR]        /* <- UARTFR (Flag register) */
+        ldr   w\c, [\xb, #FR]        /* <- UARTFR (Flag register) */
        tst   w\c, #BUSY             /* Check BUSY bit */
        b.ne  1b                     /* Wait for the UART to be ready */

.endm

xen/arch/arm/arm64/debug-pl011.inc +0 -0
@@ -52,7 +52,7 @@
 * wt: register which contains the character to transmit
 */

.macro early_uart_transmit xb, wt

xen/arch/arm/arm64/debug-pl011.inc line 55

Quoted 2 lines
xen/arch/arm/arm64/debug-pl011.inc +1 -1
-        strb  \wt, [\xb, #DR]        /* -> UARTDR (Data Register) */
+        str   \wt, [\xb, #DR]        /* -> UARTDR (Data Register) */

Is it really ok to drop the 8bit access here ?

Regards
Bertrand

Quoted 6 lines

.endm

/*

Signature · 1 line
2.25.1
#3 lore raw

Hi Bertrand,

Quoted 48 lines · Bertrand Marquis

Hi Michal,

Quoted 44 lines · Michal Orzel

There are implementations of the PL011 that can only handle 32-bit accesses (i.e. no 16-bit or 8-bit), usually advertised by 'reg-io-width' dt property set to 4. On such UARTs, the current early printk code for arm64 does not work. To fix this issue, make all the accesses to be 32-bit by using ldr, str without a size field. This makes it possible to use early printk on such platforms, while all the other implementations should generally cope with 32-bit accesses. In case they do not, they would already fail as we explicitly use writel/readl in the runtime driver to maintain broader compatibility and to be SBSAv2 compliant. Therefore, this change makes the runtime/early handling consistent (also it matches the arm32 debug-pl011 code).

---
xen/arch/arm/arm64/debug-pl011.inc | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
xen/arch/arm/arm64/debug-pl011.inc +0 -0
index 6d60e78c8ba3..80eb8fdc1ec7 100644
@@ -25,9 +25,9 @@
 */

.macro early_uart_init xb, c

        mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE % 16)
xen/arch/arm/arm64/debug-pl011.inc +2 -2
-        strh  w\c, [\xb, #FBRD]      /* -> UARTFBRD (Baud divisor fraction) */
+        str   w\c, [\xb, #FBRD]      /* -> UARTFBRD (Baud divisor fraction) */
        mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE / 16)
-        strh  w\c, [\xb, #IBRD]      /* -> UARTIBRD (Baud divisor integer) */
+        str   w\c, [\xb, #IBRD]      /* -> UARTIBRD (Baud divisor integer) */
        mov   x\c, #WLEN_8           /* 8n1 */
        str   w\c, [\xb, #LCR_H]     /* -> UARTLCR_H (Line control) */
        ldr   x\c, =(RXE | TXE | UARTEN)
@@ -41,7 +41,7 @@
 */

.macro early_uart_ready xb, c
1:

xen/arch/arm/arm64/debug-pl011.inc +1 -1
-        ldrh  w\c, [\xb, #FR]        /* <- UARTFR (Flag register) */
+        ldr   w\c, [\xb, #FR]        /* <- UARTFR (Flag register) */
        tst   w\c, #BUSY             /* Check BUSY bit */
        b.ne  1b                     /* Wait for the UART to be ready */

.endm

Quoted 8 lines

xen/arch/arm/arm64/debug-pl011.inc line 55

Quoted 6 lines
xen/arch/arm/arm64/debug-pl011.inc +0 -0
@@ -52,7 +52,7 @@
 * wt: register which contains the character to transmit
 */

.macro early_uart_transmit xb, wt

xen/arch/arm/arm64/debug-pl011.inc +1 -1
-        strb  \wt, [\xb, #DR]        /* -> UARTDR (Data Register) */
+        str   \wt, [\xb, #DR]        /* -> UARTDR (Data Register) */

Is it really ok to drop the 8bit access here ?

It is not only ok, it is necessary. Otherwise it won't work on the above mentioned UARTs (they can only perform 32-bit access). And following to what I wrote in commit msg:
- we use str already in arm32 which results in 32-bit access
- we use reald/writel that end up as str/ldr in runtime driver
- we are down to SBSAv2 spec that runtime driver follows (meaning we can use early printk for SBSA too)
- this way we support broader list of PL011s consistently (i.e. both early and runtime driver works as oppose to only runtime)

Also, before every early_uart_transmit we use ldrb (to convert to char) which means that the rest of the \wt register (8:31) is zero extended.

~Michal

#4 lore raw

Hi,

Sorry for the formatting.

Quoted 68 lines · Michal Orzel

Hi Bertrand,

Quoted 10 lines · Bertrand Marquis

Hi Michal,

Quoted 6 lines · Michal Orzel

There are implementations of the PL011 that can only handle 32-bit accesses (i.e. no 16-bit or 8-bit), usually advertised by 'reg-io-width' dt property set to 4. On such UARTs, the current early printk code for arm64 does not work. To fix this issue, make all the accesses to be

32-bit

Quoted 2 lines
Quoted 2 lines

by using ldr, str without a size field. This makes it possible to use early printk on such platforms, while all the other implementations

should

Quoted 3 lines
Quoted 3 lines

generally cope with 32-bit accesses. In case they do not, they would already fail as we explicitly use writel/readl in the runtime driver to maintain broader compatibility and to be SBSAv2 compliant. Therefore,

this

Quoted 9 lines

Review

Quoted 9 lines

change makes the runtime/early handling consistent (also it matches the arm32 debug-pl011 code).

---
xen/arch/arm/arm64/debug-pl011.inc | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/xen/arch/arm/arm64/debug-pl011.inc

Quoted 8 lines
Quoted 8 lines

index 6d60e78c8ba3..80eb8fdc1ec7 100644

xen/arch/arm/arm64/debug-pl011.inc +0 -0
@@ -25,9 +25,9 @@
 */

.macro early_uart_init xb, c

        mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE % 16)

- strh w\c, [\xb, #FBRD] /* -> UARTFBRD (Baud divisor

fraction) */

Quoted 1 line
Quoted 1 line

+ str w\c, [\xb, #FBRD] /* -> UARTFBRD (Baud divisor

fraction) */

Quoted 2 lines
Quoted 2 lines
        mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE / 16)

- strh w\c, [\xb, #IBRD] /* -> UARTIBRD (Baud divisor

integer) */

Quoted 1 line
Quoted 1 line

+ str w\c, [\xb, #IBRD] /* -> UARTIBRD (Baud divisor

integer) */

Quoted 11 lines

xen/arch/arm/arm64/debug-pl011.inc

Quoted 11 lines
        mov   x\c, #WLEN_8           /* 8n1 */
        str   w\c, [\xb, #LCR_H]     /* -> UARTLCR_H (Line control) */
        ldr   x\c, =(RXE | TXE | UARTEN)
xen/arch/arm/arm64/debug-pl011.inc +0 -0
@@ -41,7 +41,7 @@
 */

.macro early_uart_ready xb, c
1:

xen/arch/arm/arm64/debug-pl011.inc +1 -1
-        ldrh  w\c, [\xb, #FR]        /* <- UARTFR (Flag register) */
+        ldr   w\c, [\xb, #FR]        /* <- UARTFR (Flag register) */
        tst   w\c, #BUSY             /* Check BUSY bit */
        b.ne  1b                     /* Wait for the UART to be ready

*/

Quoted 9 lines

xen/arch/arm/arm64/debug-pl011.inc line 55

Quoted 7 lines

.endm

xen/arch/arm/arm64/debug-pl011.inc +0 -0
@@ -52,7 +52,7 @@
 * wt: register which contains the character to transmit
 */

.macro early_uart_transmit xb, wt

xen/arch/arm/arm64/debug-pl011.inc +1 -1
-        strb  \wt, [\xb, #DR]        /* -> UARTDR (Data Register) */
+        str   \wt, [\xb, #DR]        /* -> UARTDR (Data Register) */

Is it really ok to drop the 8bit access here ?

Quoted 2 lines

It is not only ok, it is necessary. Otherwise it won't work on the above mentioned UARTs (they can only perform 32-bit access).

IIRC some compilers will complain because you use wN with “str”.

Quoted 9 lines

And following to what I wrote in commit msg:
- we use str already in arm32 which results in 32-bit access

- we use reald/writel that end up as str/ldr in runtime driver

- we are down to SBSAv2 spec that runtime driver follows (meaning we can use early printk for SBSA too)

The runtime driver is meant to follow the PL011 spec first and may have some adaptation for SBSA.

Quoted 2 lines

- this way we support broader list of PL011s consistently (i.e. both early and runtime driver works as oppose to only runtime)

I am not sure I agree here. You are focussing on HW that only support
32-bit access. And, AFAICT this shouldn’t be the norm.

I think it would be best if we have an option to select the width supported and modify the code accordingly.

And yes, I know that there might be some issues in the runtime driver. But they can be handled separately. With that we don’t promote a behaviour that AFAICT is not meant to be normal.

Quoted 6 lines

Also, before every early_uart_transmit we use ldrb (to convert to char) which means that the rest of the \wt register (8:31) is zero extended.

~Michal

#5 lore raw

Hi Julien,

Quoted 71 lines · Julien Grall

Hi,

Sorry for the formatting.

On Thu, 1 Jun 2023 at 12:31, Michal Orzel <[email protected] <mailto:[email protected]>> wrote:

    Hi Bertrand,

    On 01/06/2023 12:19, Bertrand Marquis wrote:
    >
    >
    > Hi Michal,
    >
    >> On 1 Jun 2023, at 10:50, Michal Orzel <[email protected] <mailto:[email protected]>> wrote:
    >>
    >> There are implementations of the PL011 that can only handle 32-bit
    >> accesses (i.e. no 16-bit or 8-bit), usually advertised by 'reg-io-width'
    >> dt property set to 4. On such UARTs, the current early printk code for
    >> arm64 does not work. To fix this issue, make all the accesses to be 32-bit
    >> by using ldr, str without a size field. This makes it possible to use
    >> early printk on such platforms, while all the other implementations should
    >> generally cope with 32-bit accesses. In case they do not, they would
    >> already fail as we explicitly use writel/readl in the runtime driver to
    >> maintain broader compatibility and to be SBSAv2 compliant. Therefore, this
    >> change makes the runtime/early handling consistent (also it matches the
    >> arm32 debug-pl011 code).
    >>
    >> Signed-off-by: Michal Orzel <[email protected] <mailto:[email protected]>>
    >> ---
    >> xen/arch/arm/arm64/debug-pl011.inc | 8 ++++----
    >> 1 file changed, 4 insertions(+), 4 deletions(-)
    >>
    >> diff --git a/xen/arch/arm/arm64/debug-pl011.inc b/xen/arch/arm/arm64/debug-pl011.inc
    >> index 6d60e78c8ba3..80eb8fdc1ec7 100644
    >> --- a/xen/arch/arm/arm64/debug-pl011.inc
    >> +++ b/xen/arch/arm/arm64/debug-pl011.inc
    >> @@ -25,9 +25,9 @@
    >>  */
    >> .macro early_uart_init xb, c
    >>         mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE % 16)
    >> -        strh  w\c, [\xb, #FBRD]      /* -> UARTFBRD (Baud divisor fraction) */
    >> +        str   w\c, [\xb, #FBRD]      /* -> UARTFBRD (Baud divisor fraction) */
    >>         mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE / 16)
    >> -        strh  w\c, [\xb, #IBRD]      /* -> UARTIBRD (Baud divisor integer) */
    >> +        str   w\c, [\xb, #IBRD]      /* -> UARTIBRD (Baud divisor integer) */
    >>         mov   x\c, #WLEN_8           /* 8n1 */
    >>         str   w\c, [\xb, #LCR_H]     /* -> UARTLCR_H (Line control) */
    >>         ldr   x\c, =(RXE | TXE | UARTEN)
    >> @@ -41,7 +41,7 @@
    >>  */
    >> .macro early_uart_ready xb, c
    >> 1:
    >> -        ldrh  w\c, [\xb, #FR]        /* <- UARTFR (Flag register) */
    >> +        ldr   w\c, [\xb, #FR]        /* <- UARTFR (Flag register) */
    >>         tst   w\c, #BUSY             /* Check BUSY bit */
    >>         b.ne <http://b.ne>  1b                     /* Wait for the UART to be ready */
    >> .endm
    >> @@ -52,7 +52,7 @@
    >>  * wt: register which contains the character to transmit
    >>  */
    >> .macro early_uart_transmit xb, wt
    >> -        strb  \wt, [\xb, #DR]        /* -> UARTDR (Data Register) */
    >> +        str   \wt, [\xb, #DR]        /* -> UARTDR (Data Register) */
    >
    > Is it really ok to drop the 8bit access here ?
    It is not only ok, it is necessary. Otherwise it won't work on the above mentioned UARTs (they can only perform 32-bit access).
Quoted 1 line

IIRC some compilers will complain because you use wN with “str”.

Hmm, I would expect it to be totally ok as the size is determined by the reg name. Any reference?

Quoted 12 lines

And following to what I wrote in commit msg:
- we use str already in arm32 which results in 32-bit access

- we use reald/writel that end up as str/ldr in runtime driver

- we are down to SBSAv2 spec that runtime driver follows (meaning we can use early printk for SBSA too)

Quoted 7 lines

The runtime driver is meant to follow the PL011 spec first and may have some adaptation for SBSA.

- this way we support broader list of PL011s consistently (i.e. both early and runtime driver works as oppose to only runtime)

 I am not sure I agree here. You are focussing on HW that only support 32-bit access. And, AFAICT this shouldn’t be the norm.

I'm focusing on supporting wider range of devices.
At the moment Xen PL011 runtime makes 32-bit accesses while early code makes 8/16-bit accesses (arm32 uses 32-bit only as well). So my patch can only improve things and not make them worse. In case of some very old legacy device that cannot cope with 32-bit accesses, such device would not work anyway with the runtime driver. Also, while I'm aware of platforms with 32-bit only UART and the normal one that can cope with 32-bit as well, I'm not aware of any legacy one that cannot do that.

Adding a config option like EARLY_UART_PL011_MMIO32 would be ok but it would require to also modify arm32 early printk and runtime driver. Not mentioning things that we somehow do not want to look at like hardcoded 7372800 HZ frequency for early_uart_init we can just pray to match the HW UART clock or other not PL011 spec things (i.e. incorrect FIFO size for most modern UARTs).

But if this is what you require, I'm somewhat forced to do so just so that our devices can be supported.

~Michal

#6 lore raw
Quoted 95 lines · Michal Orzel

Hi Julien,

Quoted 8 lines · Julien Grall

Hi,

Sorry for the formatting.

On Thu, 1 Jun 2023 at 12:31, Michal Orzel <[email protected] <mailto:

Quoted 9 lines · [email protected]>> wrote:
    Hi Bertrand,

    On 01/06/2023 12:19, Bertrand Marquis wrote:
    >
    >
    > Hi Michal,
    >
    >> On 1 Jun 2023, at 10:50, Michal Orzel <[email protected]
Quoted 3 lines · <mailto:[email protected]>> wrote:
Quoted 3 lines
Quoted 3 lines

There are implementations of the PL011 that can only handle 32-bit accesses (i.e. no 16-bit or 8-bit), usually advertised by

'reg-io-width'

Quoted 1 line
Quoted 1 line
Quoted 1 line

dt property set to 4. On such UARTs, the current early printk

code for

Quoted 1 line
Quoted 1 line
Quoted 1 line

arm64 does not work. To fix this issue, make all the accesses to

be 32-bit

Quoted 1 line
Quoted 1 line
Quoted 1 line

by using ldr, str without a size field. This makes it possible to

use

Quoted 1 line
Quoted 1 line
Quoted 1 line

early printk on such platforms, while all the other

implementations should

Quoted 1 line
Quoted 1 line
Quoted 1 line

generally cope with 32-bit accesses. In case they do not, they

would

Quoted 1 line
Quoted 1 line
Quoted 1 line

already fail as we explicitly use writel/readl in the runtime

driver to

Quoted 1 line
Quoted 1 line
Quoted 1 line

maintain broader compatibility and to be SBSAv2 compliant.

Therefore, this

Quoted 1 line
Quoted 1 line
Quoted 1 line

change makes the runtime/early handling consistent (also it

matches the

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

arm32 debug-pl011 code).

[email protected]>>

Quoted 5 lines
Quoted 5 lines

Review

Quoted 5 lines

---
xen/arch/arm/arm64/debug-pl011.inc | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/xen/arch/arm/arm64/debug-pl011.inc

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

index 6d60e78c8ba3..80eb8fdc1ec7 100644

xen/arch/arm/arm64/debug-pl011.inc +0 -0
@@ -25,9 +25,9 @@
 */

.macro early_uart_init xb, c

        mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE

% 16)

Quoted 1 line
Quoted 1 line
Quoted 1 line

- strh w\c, [\xb, #FBRD] /* -> UARTFBRD (Baud

divisor fraction) */

Quoted 1 line
Quoted 1 line
Quoted 1 line

+ str w\c, [\xb, #FBRD] /* -> UARTFBRD (Baud

divisor fraction) */

Quoted 1 line
Quoted 1 line
Quoted 1 line
        mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE

/ 16)

Quoted 1 line
Quoted 1 line
Quoted 1 line

- strh w\c, [\xb, #IBRD] /* -> UARTIBRD (Baud

divisor integer) */

Quoted 1 line
Quoted 1 line
Quoted 1 line

+ str w\c, [\xb, #IBRD] /* -> UARTIBRD (Baud

divisor integer) */

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
        mov   x\c, #WLEN_8           /* 8n1 */
        str   w\c, [\xb, #LCR_H]     /* -> UARTLCR_H (Line

control) */

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

ldr x\c, =(RXE | TXE | UARTEN)

xen/arch/arm/arm64/debug-pl011.inc +0 -0
@@ -41,7 +41,7 @@
 */

.macro early_uart_ready xb, c
1:
- ldrh w\c, [\xb, #FR] /* <- UARTFR (Flag

register) */

Quoted 1 line
Quoted 1 line
Quoted 1 line

+ ldr w\c, [\xb, #FR] /* <- UARTFR (Flag

register) */

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

tst w\c, #BUSY /* Check BUSY bit */
b.ne <http://b.ne> 1b /* Wait for

the UART to be ready */

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

.endm

xen/arch/arm/arm64/debug-pl011.inc +0 -0
@@ -52,7 +52,7 @@
 * wt: register which contains the character to transmit
 */

.macro early_uart_transmit xb, wt
- strb \wt, [\xb, #DR] /* -> UARTDR (Data

Register) */

Quoted 1 line
Quoted 1 line
Quoted 1 line

+ str \wt, [\xb, #DR] /* -> UARTDR (Data

Register) */

Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
Quoted 1 line

Is it really ok to drop the 8bit access here ?

It is not only ok, it is necessary. Otherwise it won't work on the

above mentioned UARTs (they can only perform 32-bit access).

Quoted 3 lines

IIRC some compilers will complain because you use wN with “str”.

Hmm, I would expect it to be totally ok as the size is determined by the reg name. Any reference?

I don’t have the spec with me. I will have a look on Monday and reply back here.

Quoted 22 lines
Quoted 11 lines

And following to what I wrote in commit msg:
- we use str already in arm32 which results in 32-bit access

- we use reald/writel that end up as str/ldr in runtime driver

- we are down to SBSAv2 spec that runtime driver follows (meaning we

can use early printk for SBSA too)

Quoted 3 lines

The runtime driver is meant to follow the PL011 spec first and may have

some adaptation for SBSA.

Quoted 3 lines

- this way we support broader list of PL011s consistently (i.e. both

early and runtime driver works as oppose to only runtime)

Quoted 2 lines
Quoted 8 lines
Quoted 1 line

I am not sure I agree here. You are focussing on HW that only support

32-bit access. And, AFAICT this shouldn’t be the norm.
I'm focusing on supporting wider range of devices.
At the moment Xen PL011 runtime makes 32-bit accesses while early code makes 8/16-bit accesses (arm32 uses 32-bit only as well).
So my patch can only improve things and not make them worse. In case of some very old legacy device that cannot cope with 32-bit accesses, such device would not work anyway with the runtime driver.

It depends how you approach the problem. From my POV, a user that can’t see logs will likely try to enable the early UART. Then they could debug the runtime driver. With your proposal, this would even be broken.

Also, while I'm aware of platforms with 32-bit only UART and the normal one

Quoted 2 lines

that can cope with 32-bit as well, I'm not aware of any legacy one that cannot do that.

I am under the impression that the default behaviour on Linux is to use non 32-big access. I would not want to diverge from that.

Quoted 3 lines

Adding a config option like EARLY_UART_PL011_MMIO32 would be ok but it would require to also modify arm32 early printk and runtime driver.

I don’t view it as a requirement. It would be OK to have it only available for 64-but at the beginning. Same for the runtime.

Quoted 4 lines

Not mentioning things that we somehow do not want to look at like hardcoded 7372800 HZ frequency for early_uart_init we can just pray to match the HW UART clock or other not PL011 spec things (i.e. incorrect FIFO size for most modern UARTs).

I am aware of this issue but I don’t understand how this is related to this discussion.

My only request is you don’t break the existing behavior of the early PL011 driver on arm64.

Quoted 3 lines

But if this is what you require, I'm somewhat forced to do so just so that our devices can be supported.

See above.

Quoted 3 lines

~Michal

#7 lore raw
Quoted 130 lines · Julien Grall

On Thu, 1 Jun 2023 at 13:48, Michal Orzel <[email protected] <mailto:[email protected]>> wrote:

    Hi Julien,

    On 01/06/2023 13:12, Julien Grall wrote:
    >       
    >
    >
    > Hi,
    >
    > Sorry for the formatting.
    >
    > On Thu, 1 Jun 2023 at 12:31, Michal Orzel <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>> wrote:
    >
    >     Hi Bertrand,
    >
    >     On 01/06/2023 12:19, Bertrand Marquis wrote:
    >     >
    >     >
    >     > Hi Michal,
    >     >
    >     >> On 1 Jun 2023, at 10:50, Michal Orzel <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>> wrote:
    >     >>
    >     >> There are implementations of the PL011 that can only handle 32-bit
    >     >> accesses (i.e. no 16-bit or 8-bit), usually advertised by 'reg-io-width'
    >     >> dt property set to 4. On such UARTs, the current early printk code for
    >     >> arm64 does not work. To fix this issue, make all the accesses to be 32-bit
    >     >> by using ldr, str without a size field. This makes it possible to use
    >     >> early printk on such platforms, while all the other implementations should
    >     >> generally cope with 32-bit accesses. In case they do not, they would
    >     >> already fail as we explicitly use writel/readl in the runtime driver to
    >     >> maintain broader compatibility and to be SBSAv2 compliant. Therefore, this
    >     >> change makes the runtime/early handling consistent (also it matches the
    >     >> arm32 debug-pl011 code).
    >     >>
    >     >> Signed-off-by: Michal Orzel <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>>
    >     >> ---
    >     >> xen/arch/arm/arm64/debug-pl011.inc | 8 ++++----
    >     >> 1 file changed, 4 insertions(+), 4 deletions(-)
    >     >>
    >     >> diff --git a/xen/arch/arm/arm64/debug-pl011.inc b/xen/arch/arm/arm64/debug-pl011.inc
    >     >> index 6d60e78c8ba3..80eb8fdc1ec7 100644
    >     >> --- a/xen/arch/arm/arm64/debug-pl011.inc
    >     >> +++ b/xen/arch/arm/arm64/debug-pl011.inc
    >     >> @@ -25,9 +25,9 @@
    >     >>  */
    >     >> .macro early_uart_init xb, c
    >     >>         mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE % 16)
    >     >> -        strh  w\c, [\xb, #FBRD]      /* -> UARTFBRD (Baud divisor fraction) */
    >     >> +        str   w\c, [\xb, #FBRD]      /* -> UARTFBRD (Baud divisor fraction) */
    >     >>         mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE / 16)
    >     >> -        strh  w\c, [\xb, #IBRD]      /* -> UARTIBRD (Baud divisor integer) */
    >     >> +        str   w\c, [\xb, #IBRD]      /* -> UARTIBRD (Baud divisor integer) */
    >     >>         mov   x\c, #WLEN_8           /* 8n1 */
    >     >>         str   w\c, [\xb, #LCR_H]     /* -> UARTLCR_H (Line control) */
    >     >>         ldr   x\c, =(RXE | TXE | UARTEN)
    >     >> @@ -41,7 +41,7 @@
    >     >>  */
    >     >> .macro early_uart_ready xb, c
    >     >> 1:
    >     >> -        ldrh  w\c, [\xb, #FR]        /* <- UARTFR (Flag register) */
    >     >> +        ldr   w\c, [\xb, #FR]        /* <- UARTFR (Flag register) */
    >     >>         tst   w\c, #BUSY             /* Check BUSY bit */
    >     >>         b.ne <http://b.ne> <http://b.ne <http://b.ne>>  1b                     /* Wait for the UART to be ready */
    >     >> .endm
    >     >> @@ -52,7 +52,7 @@
    >     >>  * wt: register which contains the character to transmit
    >     >>  */
    >     >> .macro early_uart_transmit xb, wt
    >     >> -        strb  \wt, [\xb, #DR]        /* -> UARTDR (Data Register) */
    >     >> +        str   \wt, [\xb, #DR]        /* -> UARTDR (Data Register) */
    >     >
    >     > Is it really ok to drop the 8bit access here ?
    >     It is not only ok, it is necessary. Otherwise it won't work on the above mentioned UARTs (they can only perform 32-bit access).
    >
    >
    > IIRC some compilers will complain because you use wN with “str”.
    Hmm, I would expect it to be totally ok as the size is determined by the reg name. Any reference?

I don’t have the spec with me. I will have a look on Monday and reply back here.

Quoted 12 lines

     And following to what I wrote in commit msg:
     - we use str already in arm32 which results in 32-bit access

     - we use reald/writel that end up as str/ldr in runtime driver

     - we are down to SBSAv2 spec that runtime driver follows (meaning we can use early printk for SBSA too)

Quoted 7 lines

The runtime driver is meant to follow the PL011 spec first and may have some adaptation for SBSA.

     - this way we support broader list of PL011s consistently (i.e. both early and runtime driver works as oppose to only runtime)

 I am not sure I agree here. You are focussing on HW that only support 32-bit access. And, AFAICT this shouldn’t be the norm.

I'm focusing on supporting wider range of devices.
At the moment Xen PL011 runtime makes 32-bit accesses while early code makes 8/16-bit accesses (arm32 uses 32-bit only as well). So my patch can only improve things and not make them worse. In case of some very old legacy device that cannot cope with 32-bit accesses, such device would not work anyway with the runtime driver.

It depends how you approach the problem. From my POV, a user that can’t see logs will likely try to enable the early UART. Then they could debug the runtime driver. With your proposal, this would even be broken.

Also, while I'm aware of platforms with 32-bit only UART and the normal one that can cope with 32-bit as well, I'm not aware of any legacy one that cannot do that.

I am under the impression that the default behaviour on Linux is to use non 32-big access. I would not want to diverge from that.

Adding a config option like EARLY_UART_PL011_MMIO32 would be ok but it would require to also modify arm32 early printk and runtime driver.

I don’t view it as a requirement. It would be OK to have it only available for 64-but at the beginning. Same for the runtime.

Quoted 7 lines

Not mentioning things that we somehow do not want to look at like hardcoded 7372800 HZ frequency for early_uart_init we can just pray to match the HW UART clock or other not PL011 spec things (i.e. incorrect FIFO size for most modern UARTs).

I am aware of this issue but I don’t understand how this is related to this discussion.

My only request is you don’t break the existing behavior of the early PL011 driver on arm64.

I understand your concern about legacy devices and that you do not want to break the existing code on arm64. But please correct me if I'm wrong. These two lines:
str w\c, [\xb, #LCR_H]
str w\c, [\xb, #CR]

already make 32-bit accesses, meaning our early driver does not support legacy devices anyway. You can say it is part of early_uart_init that is not often used but still you cannot really say that our current code supports such devices.

Anyway, I will then first prepare a fix for the current code and then add support for mmio32 only.

~Michal

#8 lore raw

Hi,

Quoted 87 lines · Michal Orzel
Quoted 85 lines · Julien Grall

On Thu, 1 Jun 2023 at 13:48, Michal Orzel <[email protected] <mailto:[email protected]>> wrote:

     Hi Julien,

     On 01/06/2023 13:12, Julien Grall wrote:
     >
     >
     >
     > Hi,
     >
     > Sorry for the formatting.
     >
     > On Thu, 1 Jun 2023 at 12:31, Michal Orzel <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>> wrote:
     >
     >     Hi Bertrand,
     >
     >     On 01/06/2023 12:19, Bertrand Marquis wrote:
     >     >
     >     >
     >     > Hi Michal,
     >     >
     >     >> On 1 Jun 2023, at 10:50, Michal Orzel <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>> wrote:
     >     >>
     >     >> There are implementations of the PL011 that can only handle 32-bit
     >     >> accesses (i.e. no 16-bit or 8-bit), usually advertised by 'reg-io-width'
     >     >> dt property set to 4. On such UARTs, the current early printk code for
     >     >> arm64 does not work. To fix this issue, make all the accesses to be 32-bit
     >     >> by using ldr, str without a size field. This makes it possible to use
     >     >> early printk on such platforms, while all the other implementations should
     >     >> generally cope with 32-bit accesses. In case they do not, they would
     >     >> already fail as we explicitly use writel/readl in the runtime driver to
     >     >> maintain broader compatibility and to be SBSAv2 compliant. Therefore, this
     >     >> change makes the runtime/early handling consistent (also it matches the
     >     >> arm32 debug-pl011 code).
     >     >>
     >     >> Signed-off-by: Michal Orzel <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>>
     >     >> ---
     >     >> xen/arch/arm/arm64/debug-pl011.inc | 8 ++++----
     >     >> 1 file changed, 4 insertions(+), 4 deletions(-)
     >     >>
     >     >> diff --git a/xen/arch/arm/arm64/debug-pl011.inc b/xen/arch/arm/arm64/debug-pl011.inc
     >     >> index 6d60e78c8ba3..80eb8fdc1ec7 100644
     >     >> --- a/xen/arch/arm/arm64/debug-pl011.inc
     >     >> +++ b/xen/arch/arm/arm64/debug-pl011.inc
     >     >> @@ -25,9 +25,9 @@
     >     >>  */
     >     >> .macro early_uart_init xb, c
     >     >>         mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE % 16)
     >     >> -        strh  w\c, [\xb, #FBRD]      /* -> UARTFBRD (Baud divisor fraction) */
     >     >> +        str   w\c, [\xb, #FBRD]      /* -> UARTFBRD (Baud divisor fraction) */
     >     >>         mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE / 16)
     >     >> -        strh  w\c, [\xb, #IBRD]      /* -> UARTIBRD (Baud divisor integer) */
     >     >> +        str   w\c, [\xb, #IBRD]      /* -> UARTIBRD (Baud divisor integer) */
     >     >>         mov   x\c, #WLEN_8           /* 8n1 */
     >     >>         str   w\c, [\xb, #LCR_H]     /* -> UARTLCR_H (Line control) */
     >     >>         ldr   x\c, =(RXE | TXE | UARTEN)
     >     >> @@ -41,7 +41,7 @@
     >     >>  */
     >     >> .macro early_uart_ready xb, c
     >     >> 1:
     >     >> -        ldrh  w\c, [\xb, #FR]        /* <- UARTFR (Flag register) */
     >     >> +        ldr   w\c, [\xb, #FR]        /* <- UARTFR (Flag register) */
     >     >>         tst   w\c, #BUSY             /* Check BUSY bit */
     >     >>         b.ne <http://b.ne> <http://b.ne <http://b.ne>>  1b                     /* Wait for the UART to be ready */
     >     >> .endm
     >     >> @@ -52,7 +52,7 @@
     >     >>  * wt: register which contains the character to transmit
     >     >>  */
     >     >> .macro early_uart_transmit xb, wt
     >     >> -        strb  \wt, [\xb, #DR]        /* -> UARTDR (Data Register) */
     >     >> +        str   \wt, [\xb, #DR]        /* -> UARTDR (Data Register) */
     >     >
     >     > Is it really ok to drop the 8bit access here ?
     >     It is not only ok, it is necessary. Otherwise it won't work on the above mentioned UARTs (they can only perform 32-bit access).
     >
     >
     > IIRC some compilers will complain because you use wN with “str”.
     Hmm, I would expect it to be totally ok as the size is determined by the reg name. Any reference?
Quoted 1 line
Quoted 1 line

I don’t have the spec with me. I will have a look on Monday and reply back here.

I had another look at this. You are right, "str" can work with wN or xN. I got confused because in the past the issue we had was with the asm volatile with 'msr' (see 57e761b60dc9 "xen/arm64: Remove READ/WRITE_SYSREG32 helper macros").

[...]

Quoted 7 lines
Quoted 3 lines

I am aware of this issue but I don’t understand how this is related to this discussion.

My only request is you don’t break the existing behavior of the early PL011 driver on arm64.

I understand your concern about legacy devices and that you do not want to break the existing code on arm64. But please correct me if I'm wrong. These two lines:
str w\c, [\xb, #LCR_H]
str w\c, [\xb, #CR]

Hmmm... Looking at the spec, LCR_H is meant to be 8-bit and CR 16-bit. So I think we need to modify both of them. I am happy to send a patch separately for that either before or after your patch.

Cheers,

Signature · 1 line
Julien Grall
#9 lore raw

Hi Julien,

Quoted 104 lines · Julien Grall

Hi,

Quoted 87 lines · Michal Orzel
Quoted 85 lines · Julien Grall

On Thu, 1 Jun 2023 at 13:48, Michal Orzel <[email protected] <mailto:[email protected]>> wrote:

     Hi Julien,

     On 01/06/2023 13:12, Julien Grall wrote:
     >
     >
     >
     > Hi,
     >
     > Sorry for the formatting.
     >
     > On Thu, 1 Jun 2023 at 12:31, Michal Orzel <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>> wrote:
     >
     >     Hi Bertrand,
     >
     >     On 01/06/2023 12:19, Bertrand Marquis wrote:
     >     >
     >     >
     >     > Hi Michal,
     >     >
     >     >> On 1 Jun 2023, at 10:50, Michal Orzel <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>> wrote:
     >     >>
     >     >> There are implementations of the PL011 that can only handle 32-bit
     >     >> accesses (i.e. no 16-bit or 8-bit), usually advertised by 'reg-io-width'
     >     >> dt property set to 4. On such UARTs, the current early printk code for
     >     >> arm64 does not work. To fix this issue, make all the accesses to be 32-bit
     >     >> by using ldr, str without a size field. This makes it possible to use
     >     >> early printk on such platforms, while all the other implementations should
     >     >> generally cope with 32-bit accesses. In case they do not, they would
     >     >> already fail as we explicitly use writel/readl in the runtime driver to
     >     >> maintain broader compatibility and to be SBSAv2 compliant. Therefore, this
     >     >> change makes the runtime/early handling consistent (also it matches the
     >     >> arm32 debug-pl011 code).
     >     >>
     >     >> Signed-off-by: Michal Orzel <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>>
     >     >> ---
     >     >> xen/arch/arm/arm64/debug-pl011.inc | 8 ++++----
     >     >> 1 file changed, 4 insertions(+), 4 deletions(-)
     >     >>
     >     >> diff --git a/xen/arch/arm/arm64/debug-pl011.inc b/xen/arch/arm/arm64/debug-pl011.inc
     >     >> index 6d60e78c8ba3..80eb8fdc1ec7 100644
     >     >> --- a/xen/arch/arm/arm64/debug-pl011.inc
     >     >> +++ b/xen/arch/arm/arm64/debug-pl011.inc
     >     >> @@ -25,9 +25,9 @@
     >     >>  */
     >     >> .macro early_uart_init xb, c
     >     >>         mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE % 16)
     >     >> -        strh  w\c, [\xb, #FBRD]      /* -> UARTFBRD (Baud divisor fraction) */
     >     >> +        str   w\c, [\xb, #FBRD]      /* -> UARTFBRD (Baud divisor fraction) */
     >     >>         mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE / 16)
     >     >> -        strh  w\c, [\xb, #IBRD]      /* -> UARTIBRD (Baud divisor integer) */
     >     >> +        str   w\c, [\xb, #IBRD]      /* -> UARTIBRD (Baud divisor integer) */
     >     >>         mov   x\c, #WLEN_8           /* 8n1 */
     >     >>         str   w\c, [\xb, #LCR_H]     /* -> UARTLCR_H (Line control) */
     >     >>         ldr   x\c, =(RXE | TXE | UARTEN)
     >     >> @@ -41,7 +41,7 @@
     >     >>  */
     >     >> .macro early_uart_ready xb, c
     >     >> 1:
     >     >> -        ldrh  w\c, [\xb, #FR]        /* <- UARTFR (Flag register) */
     >     >> +        ldr   w\c, [\xb, #FR]        /* <- UARTFR (Flag register) */
     >     >>         tst   w\c, #BUSY             /* Check BUSY bit */
     >     >>         b.ne <http://b.ne> <http://b.ne <http://b.ne>>  1b                     /* Wait for the UART to be ready */
     >     >> .endm
     >     >> @@ -52,7 +52,7 @@
     >     >>  * wt: register which contains the character to transmit
     >     >>  */
     >     >> .macro early_uart_transmit xb, wt
     >     >> -        strb  \wt, [\xb, #DR]        /* -> UARTDR (Data Register) */
     >     >> +        str   \wt, [\xb, #DR]        /* -> UARTDR (Data Register) */
     >     >
     >     > Is it really ok to drop the 8bit access here ?
     >     It is not only ok, it is necessary. Otherwise it won't work on the above mentioned UARTs (they can only perform 32-bit access).
     >
     >
     > IIRC some compilers will complain because you use wN with “str”.
     Hmm, I would expect it to be totally ok as the size is determined by the reg name. Any reference?
Quoted 1 line
Quoted 1 line

I don’t have the spec with me. I will have a look on Monday and reply back here.

I had another look at this. You are right, "str" can work with wN or xN. I got confused because in the past the issue we had was with the asm volatile with 'msr' (see 57e761b60dc9 "xen/arm64: Remove READ/WRITE_SYSREG32 helper macros").

[...]

Quoted 3 lines
Quoted 3 lines

I am aware of this issue but I don’t understand how this is related to this discussion.

My only request is you don’t break the existing behavior of the early PL011 driver on arm64.

Quoted 8 lines
Quoted 4 lines

I understand your concern about legacy devices and that you do not want to break the existing code on arm64. But please correct me if I'm wrong. These two lines:
str w\c, [\xb, #LCR_H]
str w\c, [\xb, #CR]

Hmmm... Looking at the spec, LCR_H is meant to be 8-bit and CR 16-bit. So I think we need to modify both of them. I am happy to send a patch separately for that either before or after your patch.

There are other cases like FBRD being 6bit so we could use strb instead of strh.
In any case, I will handle all of that in a consistent manner by sending a series that should not take much time.

I can think of the following patches:
1) Use correct accessors for early pl011 on arm32 and arm64
- this would use the accessors depending on the given register size (ldrh, strh, strb)
- this would switch arm32 from 32-bit only to the same behavior as arm64

2) Support for 32-bit only PL011 in early pl011 on arm32 and arm64:
- this would result in overwriting the changes done in patch 1 (but I'd prefer not to do all in one patch for better history/backporting) as I'd have to introduce some macros e.g. PL011_STRH that would be defined as strh in normal case and str in mmio32 case, etc. I could also just duplicate all the early functions and use ifdefery if that's what would be preferred.

3) Use correct accessors for runtime pl011:
I would prefer to do what Linux does meaning using the largest-common accessor in normal-case (i.e. readw/writew) so that we can have a generic helpers (i.e. use readl/writel in mmio32 case or readw/writew in normal case). Otherwise we would have to use the accessors depending on the given register size (like in early printk) which destroys the idea of generic helpers. Linux for earlycon also uses per-register size accessor and in runtime - largest-common.

Let me know your thoughts.

~Michal

#10 lore raw
Quoted 1 line · Michal Orzel

Hi Julien,

Hi Michal,

Quoted 10 lines · Julien Grall

I can think of the following patches:
1) Use correct accessors for early pl011 on arm32 and arm64
- this would use the accessors depending on the given register size (ldrh, strh, strb)
- this would switch arm32 from 32-bit only to the same behavior as arm64

2) Support for 32-bit only PL011 in early pl011 on arm32 and arm64:
- this would result in overwriting the changes done in patch 1 (but I'd prefer not to do all in one patch for better history/backporting) as I'd have to introduce some macros e.g. PL011_STRH that would be defined as strh in normal case and str in mmio32 case, etc. I could also just duplicate all the early functions and use ifdefery if that's what would be preferred.

I would be fine with introduce PL011_STRH & co.

Quoted 5 lines

3) Use correct accessors for runtime pl011:
I would prefer to do what Linux does meaning using the largest-common accessor in normal-case (i.e. readw/writew) so that we can have a generic helpers (i.e. use readl/writel in mmio32 case or readw/writew in normal case). Otherwise we would have to use the accessors depending on the given register size (like in early printk) which destroys the idea of generic helpers. Linux for earlycon also uses per-register size accessor and in runtime - largest-common.

Make senses.

Cheers,

Signature · 1 line
Julien Grall