* [PATCH qemu] timer/i8254: Fix one shot PIT mode
@ 2023-02-26 1:58 Damien Zammit
2023-02-26 8:51 ` Michael S. Tsirkin
2023-05-15 16:15 ` Michael Tokarev
0 siblings, 2 replies; 9+ messages in thread
From: Damien Zammit @ 2023-02-26 1:58 UTC (permalink / raw)
To: qemu-devel; +Cc: Damien Zammit, Michael S . Tsirkin, Paolo Bonzini
Currently, the one-shot (mode 1) PIT expires far too quickly,
due to the output being set under the wrong logic.
This change fixes the one-shot PIT mode to behave similarly to mode 0.
TESTED: using the one-shot PIT mode to calibrate a local apic timer.
Signed-off-by: Damien Zammit <damien@zamaudio.com>
---
hw/timer/i8254_common.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/hw/timer/i8254_common.c b/hw/timer/i8254_common.c
index 050875b497..9164576ca9 100644
--- a/hw/timer/i8254_common.c
+++ b/hw/timer/i8254_common.c
@@ -52,10 +52,8 @@ int pit_get_out(PITChannelState *s, int64_t current_time)
switch (s->mode) {
default:
case 0:
- out = (d >= s->count);
- break;
case 1:
- out = (d < s->count);
+ out = (d >= s->count);
break;
case 2:
if ((d % s->count) == 0 && d != 0) {
--
2.39.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH qemu] timer/i8254: Fix one shot PIT mode
2023-02-26 1:58 [PATCH qemu] timer/i8254: Fix one shot PIT mode Damien Zammit
@ 2023-02-26 8:51 ` Michael S. Tsirkin
2023-02-26 9:17 ` Damien Zammit
2023-05-15 16:15 ` Michael Tokarev
1 sibling, 1 reply; 9+ messages in thread
From: Michael S. Tsirkin @ 2023-02-26 8:51 UTC (permalink / raw)
To: Damien Zammit; +Cc: qemu-devel, Paolo Bonzini
On Sun, Feb 26, 2023 at 01:58:10AM +0000, Damien Zammit wrote:
> Currently, the one-shot (mode 1) PIT expires far too quickly,
> due to the output being set under the wrong logic.
> This change fixes the one-shot PIT mode to behave similarly to mode 0.
>
> TESTED: using the one-shot PIT mode to calibrate a local apic timer.
>
> Signed-off-by: Damien Zammit <damien@zamaudio.com>
>
> ---
> hw/timer/i8254_common.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/hw/timer/i8254_common.c b/hw/timer/i8254_common.c
> index 050875b497..9164576ca9 100644
> --- a/hw/timer/i8254_common.c
> +++ b/hw/timer/i8254_common.c
> @@ -52,10 +52,8 @@ int pit_get_out(PITChannelState *s, int64_t current_time)
> switch (s->mode) {
> default:
> case 0:
> - out = (d >= s->count);
> - break;
I think you need something like
/* FALLTHRU */
here otherwise some gcc versions will warn.
> case 1:
> - out = (d < s->count);
> + out = (d >= s->count);
> break;
> case 2:
> if ((d % s->count) == 0 && d != 0) {
> --
> 2.39.0
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH qemu] timer/i8254: Fix one shot PIT mode
2023-02-26 8:51 ` Michael S. Tsirkin
@ 2023-02-26 9:17 ` Damien Zammit
2023-02-26 9:45 ` Max Filippov
0 siblings, 1 reply; 9+ messages in thread
From: Damien Zammit @ 2023-02-26 9:17 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel, Paolo Bonzini
Hi Michael,
Thanks for reviewing this on a weekend!
On 26/2/23 19:51, Michael S. Tsirkin wrote:
> On Sun, Feb 26, 2023 at 01:58:10AM +0000, Damien Zammit wrote:
>> case 0:
>> - out = (d >= s->count);
>> - break;
>
>
> I think you need something like
> /* FALLTHRU */
> here otherwise some gcc versions will warn.
>
>> case 1:
>> - out = (d < s->count);
>> + out = (d >= s->count);
It seems that there are quite a number of these consecutive fallthrough cases
without /* FALLTHRU */ in i8254_common.c
Can these be fixed in a separate patch?
Damien
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH qemu] timer/i8254: Fix one shot PIT mode
2023-02-26 9:17 ` Damien Zammit
@ 2023-02-26 9:45 ` Max Filippov
2023-02-26 12:11 ` BALATON Zoltan
0 siblings, 1 reply; 9+ messages in thread
From: Max Filippov @ 2023-02-26 9:45 UTC (permalink / raw)
To: Damien Zammit; +Cc: Michael S. Tsirkin, qemu-devel, Paolo Bonzini
On Sun, Feb 26, 2023 at 1:18 AM Damien Zammit <damien@zamaudio.com> wrote:
>
> Hi Michael,
>
> Thanks for reviewing this on a weekend!
>
> On 26/2/23 19:51, Michael S. Tsirkin wrote:
> > On Sun, Feb 26, 2023 at 01:58:10AM +0000, Damien Zammit wrote:
> >> case 0:
> >> - out = (d >= s->count);
> >> - break;
> >
> >
> > I think you need something like
> > /* FALLTHRU */
> > here otherwise some gcc versions will warn.
> >
> >> case 1:
> >> - out = (d < s->count);
> >> + out = (d >= s->count);
>
> It seems that there are quite a number of these consecutive fallthrough cases
> without /* FALLTHRU */ in i8254_common.c
>
> Can these be fixed in a separate patch?
I believe that the comment is only needed when there's code
between the labels and is not needed between the labels that
follow each other.
--
Thanks.
-- Max
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH qemu] timer/i8254: Fix one shot PIT mode
2023-02-26 9:45 ` Max Filippov
@ 2023-02-26 12:11 ` BALATON Zoltan
2023-02-26 13:03 ` Michael S. Tsirkin
0 siblings, 1 reply; 9+ messages in thread
From: BALATON Zoltan @ 2023-02-26 12:11 UTC (permalink / raw)
To: Max Filippov; +Cc: Damien Zammit, Michael S. Tsirkin, qemu-devel, Paolo Bonzini
[-- Attachment #1: Type: text/plain, Size: 1136 bytes --]
On Sun, 26 Feb 2023, Max Filippov wrote:
> On Sun, Feb 26, 2023 at 1:18 AM Damien Zammit <damien@zamaudio.com> wrote:
>>
>> Hi Michael,
>>
>> Thanks for reviewing this on a weekend!
>>
>> On 26/2/23 19:51, Michael S. Tsirkin wrote:
>>> On Sun, Feb 26, 2023 at 01:58:10AM +0000, Damien Zammit wrote:
>>>> case 0:
>>>> - out = (d >= s->count);
>>>> - break;
>>>
>>>
>>> I think you need something like
>>> /* FALLTHRU */
>>> here otherwise some gcc versions will warn.
>>>
>>>> case 1:
>>>> - out = (d < s->count);
>>>> + out = (d >= s->count);
>>
>> It seems that there are quite a number of these consecutive fallthrough cases
>> without /* FALLTHRU */ in i8254_common.c
>>
>> Can these be fixed in a separate patch?
>
> I believe that the comment is only needed when there's code
> between the labels and is not needed between the labels that
> follow each other.
I think so too, I have some of these consecutive case labels in my code
and never had a problem with that. Only when you have a statement between
labels without break is when a comment is needed.
Regards,
BALATON Zoltan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH qemu] timer/i8254: Fix one shot PIT mode
2023-02-26 12:11 ` BALATON Zoltan
@ 2023-02-26 13:03 ` Michael S. Tsirkin
0 siblings, 0 replies; 9+ messages in thread
From: Michael S. Tsirkin @ 2023-02-26 13:03 UTC (permalink / raw)
To: BALATON Zoltan; +Cc: Max Filippov, Damien Zammit, qemu-devel, Paolo Bonzini
On Sun, Feb 26, 2023 at 01:11:19PM +0100, BALATON Zoltan wrote:
> On Sun, 26 Feb 2023, Max Filippov wrote:
> > On Sun, Feb 26, 2023 at 1:18 AM Damien Zammit <damien@zamaudio.com> wrote:
> > >
> > > Hi Michael,
> > >
> > > Thanks for reviewing this on a weekend!
> > >
> > > On 26/2/23 19:51, Michael S. Tsirkin wrote:
> > > > On Sun, Feb 26, 2023 at 01:58:10AM +0000, Damien Zammit wrote:
> > > > > case 0:
> > > > > - out = (d >= s->count);
> > > > > - break;
> > > >
> > > >
> > > > I think you need something like
> > > > /* FALLTHRU */
> > > > here otherwise some gcc versions will warn.
> > > >
> > > > > case 1:
> > > > > - out = (d < s->count);
> > > > > + out = (d >= s->count);
> > >
> > > It seems that there are quite a number of these consecutive fallthrough cases
> > > without /* FALLTHRU */ in i8254_common.c
> > >
> > > Can these be fixed in a separate patch?
> >
> > I believe that the comment is only needed when there's code
> > between the labels and is not needed between the labels that
> > follow each other.
>
> I think so too, I have some of these consecutive case labels in my code and
> never had a problem with that. Only when you have a statement between labels
> without break is when a comment is needed.
>
> Regards,
> BALATON Zoltan
I just tried and it looks like you are right. Pls ignore sorry about the
noise.
--
MST
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH qemu] timer/i8254: Fix one shot PIT mode
2023-02-26 1:58 [PATCH qemu] timer/i8254: Fix one shot PIT mode Damien Zammit
2023-02-26 8:51 ` Michael S. Tsirkin
@ 2023-05-15 16:15 ` Michael Tokarev
1 sibling, 0 replies; 9+ messages in thread
From: Michael Tokarev @ 2023-05-15 16:15 UTC (permalink / raw)
To: Damien Zammit, qemu-devel; +Cc: Michael S . Tsirkin, Paolo Bonzini
26.02.2023 04:58, Damien Zammit wrote:
> Currently, the one-shot (mode 1) PIT expires far too quickly,
> due to the output being set under the wrong logic.
> This change fixes the one-shot PIT mode to behave similarly to mode 0.
>
> TESTED: using the one-shot PIT mode to calibrate a local apic timer.
Has this been forgotten, or is it not needed anymore?
Thanks,
/mjt
> hw/timer/i8254_common.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/hw/timer/i8254_common.c b/hw/timer/i8254_common.c
> index 050875b497..9164576ca9 100644
> --- a/hw/timer/i8254_common.c
> +++ b/hw/timer/i8254_common.c
> @@ -52,10 +52,8 @@ int pit_get_out(PITChannelState *s, int64_t current_time)
> switch (s->mode) {
> default:
> case 0:
> - out = (d >= s->count);
> - break;
> case 1:
> - out = (d < s->count);
> + out = (d >= s->count);
> break;
> case 2:
> if ((d % s->count) == 0 && d != 0) {
> --
> 2.39.0
>
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH qemu] timer/i8254: Fix one shot PIT mode
@ 2023-10-06 2:36 Damien Zammit
2023-10-06 5:19 ` Michael S. Tsirkin
0 siblings, 1 reply; 9+ messages in thread
From: Damien Zammit @ 2023-10-06 2:36 UTC (permalink / raw)
To: mjt; +Cc: damien, mst, pbonzini, qemu-devel
>From: Michael Tokarev <mjt@tls.msk.ru>
>26.02.2023 04:58, Damien Zammit wrote:
>> Currently, the one-shot (mode 1) PIT expires far too quickly,
>> due to the output being set under the wrong logic.
>> This change fixes the one-shot PIT mode to behave similarly to mode 0.
>>
>> TESTED: using the one-shot PIT mode to calibrate a local apic timer.
>
>Has this been forgotten, or is it not needed anymore?
This is still required but nobody uses the
PIT one-shot mode (probably because it *is* currently broken).
Can it be merged?
Thanks,
Damien
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH qemu] timer/i8254: Fix one shot PIT mode
2023-10-06 2:36 Damien Zammit
@ 2023-10-06 5:19 ` Michael S. Tsirkin
0 siblings, 0 replies; 9+ messages in thread
From: Michael S. Tsirkin @ 2023-10-06 5:19 UTC (permalink / raw)
To: Damien Zammit; +Cc: pbonzini, qemu-devel
On Fri, Oct 06, 2023 at 02:36:52AM +0000, Damien Zammit wrote:
> >From: Michael Tokarev <mjt@tls.msk.ru>
> >26.02.2023 04:58, Damien Zammit wrote:
> >> Currently, the one-shot (mode 1) PIT expires far too quickly,
> >> due to the output being set under the wrong logic.
> >> This change fixes the one-shot PIT mode to behave similarly to mode 0.
> >>
> >> TESTED: using the one-shot PIT mode to calibrate a local apic timer.
> >
> >Has this been forgotten, or is it not needed anymore?
>
> This is still required but nobody uses the
> PIT one-shot mode (probably because it *is* currently broken).
>
> Can it be merged?
>
> Thanks,
> Damien
OK, I tagged it. thanks!
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-10-06 5:21 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-26 1:58 [PATCH qemu] timer/i8254: Fix one shot PIT mode Damien Zammit
2023-02-26 8:51 ` Michael S. Tsirkin
2023-02-26 9:17 ` Damien Zammit
2023-02-26 9:45 ` Max Filippov
2023-02-26 12:11 ` BALATON Zoltan
2023-02-26 13:03 ` Michael S. Tsirkin
2023-05-15 16:15 ` Michael Tokarev
-- strict thread matches above, loose matches on Subject: below --
2023-10-06 2:36 Damien Zammit
2023-10-06 5:19 ` Michael S. Tsirkin
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).