* [PATCH] hw/char/pl011: fix baud rate calculation
@ 2022-10-06 10:19 Baruch Siach
2022-10-06 10:51 ` Peter Maydell
2022-10-14 18:01 ` Peter Maydell
0 siblings, 2 replies; 4+ messages in thread
From: Baruch Siach @ 2022-10-06 10:19 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-arm, qemu-devel, Baruch Siach
The PL011 TRM says that "UARTIBRD = 0 is invalid and UARTFBRD is ignored
when this is the case". But the code looks at FBRD for the invalid case.
Fix this.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
hw/char/pl011.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/char/pl011.c b/hw/char/pl011.c
index 6e2d7f75095c..c076813423fc 100644
--- a/hw/char/pl011.c
+++ b/hw/char/pl011.c
@@ -176,7 +176,7 @@ static unsigned int pl011_get_baudrate(const PL011State *s)
{
uint64_t clk;
- if (s->fbrd == 0) {
+ if (s->ibrd == 0) {
return 0;
}
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] hw/char/pl011: fix baud rate calculation
2022-10-06 10:19 [PATCH] hw/char/pl011: fix baud rate calculation Baruch Siach
@ 2022-10-06 10:51 ` Peter Maydell
2022-10-06 11:12 ` Baruch Siach
2022-10-14 18:01 ` Peter Maydell
1 sibling, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2022-10-06 10:51 UTC (permalink / raw)
To: Baruch Siach; +Cc: qemu-arm, qemu-devel
On Thu, 6 Oct 2022 at 11:20, Baruch Siach <baruch@tkos.co.il> wrote:
>
> The PL011 TRM says that "UARTIBRD = 0 is invalid and UARTFBRD is ignored
> when this is the case". But the code looks at FBRD for the invalid case.
> Fix this.
>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
> hw/char/pl011.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks for this patch (I'll review it in a bit). Did you find this
because it caused problems for a guest, or just because you were
looking at the QEMU source code? (If it's the former, we like to
include some details of that in the commit message.)
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hw/char/pl011: fix baud rate calculation
2022-10-06 10:51 ` Peter Maydell
@ 2022-10-06 11:12 ` Baruch Siach
0 siblings, 0 replies; 4+ messages in thread
From: Baruch Siach @ 2022-10-06 11:12 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-arm, qemu-devel
Hi Peter,
On Thu, Oct 06 2022, Peter Maydell wrote:
> On Thu, 6 Oct 2022 at 11:20, Baruch Siach <baruch@tkos.co.il> wrote:
>>
>> The PL011 TRM says that "UARTIBRD = 0 is invalid and UARTFBRD is ignored
>> when this is the case". But the code looks at FBRD for the invalid case.
>> Fix this.
>>
>> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
>> ---
>> hw/char/pl011.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Thanks for this patch (I'll review it in a bit). Did you find this
> because it caused problems for a guest, or just because you were
> looking at the QEMU source code? (If it's the former, we like to
> include some details of that in the commit message.)
Initially I only looked at the source code while trying to understand
how clock initialization and use is meant to work. Once I figured that
out I confirmed the issue with ATF code that first sets IBRD and then
FBRD.
Before patch:
pl011_baudrate_change new baudrate 0 (clk: 100000000hz, ibrd: 54, fbrd: 0)
pl011_baudrate_change new baudrate 115204 (clk: 100000000hz, ibrd: 54, fbrd: 16)
With patch:
pl011_baudrate_change new baudrate 115740 (clk: 100000000hz, ibrd: 54, fbrd: 0)
pl011_baudrate_change new baudrate 115204 (clk: 100000000hz, ibrd: 54, fbrd: 16)
baruch
--
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hw/char/pl011: fix baud rate calculation
2022-10-06 10:19 [PATCH] hw/char/pl011: fix baud rate calculation Baruch Siach
2022-10-06 10:51 ` Peter Maydell
@ 2022-10-14 18:01 ` Peter Maydell
1 sibling, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2022-10-14 18:01 UTC (permalink / raw)
To: Baruch Siach; +Cc: qemu-arm, qemu-devel
On Thu, 6 Oct 2022 at 11:20, Baruch Siach <baruch@tkos.co.il> wrote:
>
> The PL011 TRM says that "UARTIBRD = 0 is invalid and UARTFBRD is ignored
> when this is the case". But the code looks at FBRD for the invalid case.
> Fix this.
>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
> hw/char/pl011.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/char/pl011.c b/hw/char/pl011.c
> index 6e2d7f75095c..c076813423fc 100644
> --- a/hw/char/pl011.c
> +++ b/hw/char/pl011.c
> @@ -176,7 +176,7 @@ static unsigned int pl011_get_baudrate(const PL011State *s)
> {
> uint64_t clk;
>
> - if (s->fbrd == 0) {
> + if (s->ibrd == 0) {
> return 0;
> }
Applied to target-arm.next, thanks. (The only thing we do with the
calculated baud rate is trace it, so the bug wouldn't have had any
bad effects on the guest.)
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-10-14 18:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-06 10:19 [PATCH] hw/char/pl011: fix baud rate calculation Baruch Siach
2022-10-06 10:51 ` Peter Maydell
2022-10-06 11:12 ` Baruch Siach
2022-10-14 18:01 ` Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).