Skip to contentSkip to conversation

RTC polling mode broken

Qemu-devel Bernhard Kauer 3 participants 5 messages Jul 15, 2009 – Aug 27, 2009

lore
Share & tools
lore
#0 lore raw

The RTC emulation does not set the IRQ flags independent of the IRQ enable bits.

The original MC146818A datasheet from 1964 notes:
"flag bits in Register C [...] are set independent of the state of the corresponding enable bits in Register B"
Similar sections can be found in newer documentation e.g. in rtc82885.

Qemu and Bochs set the IRQ flags only if they are enabled, which breaks drivers polling on them.

The following patch corrects this for the update-ended-flag in Qemu only. It currently does not fix the handling of the other flags.

hw/mc146818rtc.c +3 -2
index 2022548..2b040a7 100644
@@ -421,9 +421,10 @@ static void rtc_update_second2(void *opaque)
     }
 
     /* update ended interrupt */
+    s->cmos_data[RTC_REG_C] |= REG_C_UF;
     if (s->cmos_data[RTC_REG_B] & REG_B_UIE) {
-        s->cmos_data[RTC_REG_C] |= 0x90;
-        rtc_irq_raise(s->irq);
+      s->cmos_data[RTC_REG_C] |= REG_C_IRQF;
+      rtc_irq_raise(s->irq);
     }
 
     /* clear update in progress bit */
#1 lore raw

Suppose I have some software that does not run with Qemu and I have done the following steps:

1. found that it is bug in Qemu and not in my software
2. produced a patch that fixed the problem for my test-case
3. send the patch with an explanation to the mailinglist
4. waited 6 weeks for comments or inclusion in Qemu

Now what should I do, to get the bug fixed?

Thanks,

Bernhard

Quoted 34 lines · Bernhard Kauer

The RTC emulation does not set the IRQ flags independent of the IRQ enable bits.

The original MC146818A datasheet from 1984 notes:
"flag bits in Register C [...] are set independent of the state of the corresponding enable bits in Register B"
Similar sections can be found in newer documentation e.g. in rtc82885.

Qemu and Bochs set the IRQ flags only if they are enabled, which breaks drivers polling on them.

The following patch corrects this for the update-ended-flag in Qemu only. It currently does not fix the handling of the other flags.

hw/mc146818rtc.c +3 -2
index 2022548..2b040a7 100644
@@ -421,9 +421,10 @@ static void rtc_update_second2(void *opaque)
     }
 
     /* update ended interrupt */
+    s->cmos_data[RTC_REG_C] |= REG_C_UF;
     if (s->cmos_data[RTC_REG_B] & REG_B_UIE) {
-        s->cmos_data[RTC_REG_C] |= 0x90;
-        rtc_irq_raise(s->irq);
+      s->cmos_data[RTC_REG_C] |= REG_C_IRQF;
+      rtc_irq_raise(s->irq);
     }
 
     /* clear update in progress bit */
#2 lore raw
Quoted 10 lines · Bernhard Kauer

Suppose I have some software that does not run with Qemu and I have done the following steps:

1. found that it is bug in Qemu and not in my software
2. produced a patch that fixed the problem for my test-case
3. send the patch with an explanation to the mailinglist
4. waited 6 weeks for comments or inclusion in Qemu

Now what should I do, to get the bug fixed?

Resend the patch? (no need to what for 6 week to do that BTW)

Quoted 43 lines

Thanks,

Bernhard

Quoted 33 lines · Bernhard Kauer

The RTC emulation does not set the IRQ flags independent of the IRQ enable bits.

The original MC146818A datasheet from 1984 notes:
"flag bits in Register C [...] are set independent of the state of the corresponding enable bits in Register B"
Similar sections can be found in newer documentation e.g. in rtc82885.

Qemu and Bochs set the IRQ flags only if they are enabled, which breaks drivers polling on them.

The following patch corrects this for the update-ended-flag in Qemu only. It currently does not fix the handling of the other flags.

hw/mc146818rtc.c +3 -2
index 2022548..2b040a7 100644
@@ -421,9 +421,10 @@ static void rtc_update_second2(void *opaque)
     }
 
     /* update ended interrupt */
+    s->cmos_data[RTC_REG_C] |= REG_C_UF;
     if (s->cmos_data[RTC_REG_B] & REG_B_UIE) {
-        s->cmos_data[RTC_REG_C] |= 0x90;
-        rtc_irq_raise(s->irq);
+      s->cmos_data[RTC_REG_C] |= REG_C_IRQF;
+      rtc_irq_raise(s->irq);
     }
 
Quoted 3 lines

hw/mc146818rtc.c static void rtc_update_second2(void *opaque) · line 430

Quoted 1 line
hw/mc146818rtc.c +0 -0
     /* clear update in progress bit */

--
Gleb.

#3 lore raw
Quoted 4 lines · Gleb Natapov
Quoted 3 lines · Bernhard Kauer

Suppose I have some software that does not run with Qemu and I have done the following steps:

Quoted 8 lines
Quoted 7 lines

1. found that it is bug in Qemu and not in my software
2. produced a patch that fixed the problem for my test-case
3. send the patch with an explanation to the mailinglist
4. waited 6 weeks for comments or inclusion in Qemu

Now what should I do, to get the bug fixed?

Resend the patch? (no need to what for 6 week to do that BTW)

How often?

Bernhard

Quoted 36 lines
Quoted 36 lines · Bernhard Kauer
Quoted 34 lines

The RTC emulation does not set the IRQ flags independent of the IRQ enable bits.

The original MC146818A datasheet from 1984 notes:
"flag bits in Register C [...] are set independent of the state of the corresponding enable bits in Register B"
Similar sections can be found in newer documentation e.g. in rtc82885.

Qemu and Bochs set the IRQ flags only if they are enabled, which breaks drivers polling on them.

The following patch corrects this for the update-ended-flag in Qemu only. It currently does not fix the handling of the other flags.

hw/mc146818rtc.c +3 -2
index 2022548..2b040a7 100644
@@ -421,9 +421,10 @@ static void rtc_update_second2(void *opaque)
     }
 
     /* update ended interrupt */
+    s->cmos_data[RTC_REG_C] |= REG_C_UF;
     if (s->cmos_data[RTC_REG_B] & REG_B_UIE) {
-        s->cmos_data[RTC_REG_C] |= 0x90;
-        rtc_irq_raise(s->irq);
+      s->cmos_data[RTC_REG_C] |= REG_C_IRQF;
+      rtc_irq_raise(s->irq);
     }
 
     /* clear update in progress bit */
#4 lore raw
Quoted 10 lines · Bernhard Kauer
Quoted 9 lines · Gleb Natapov
Quoted 8 lines · Bernhard Kauer

Suppose I have some software that does not run with Qemu and I have done the following steps:

1. found that it is bug in Qemu and not in my software
2. produced a patch that fixed the problem for my test-case
3. send the patch with an explanation to the mailinglist
4. waited 6 weeks for comments or inclusion in Qemu

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

Now what should I do, to get the bug fixed?

Resend the patch? (no need to what for 6 week to do that BTW)

How often?

Once a week till maintainers notice :)

Quoted 35 lines
Quoted 35 lines
Quoted 35 lines · Bernhard Kauer
Quoted 33 lines

The RTC emulation does not set the IRQ flags independent of the IRQ enable bits.

The original MC146818A datasheet from 1984 notes:
"flag bits in Register C [...] are set independent of the state of the corresponding enable bits in Register B"
Similar sections can be found in newer documentation e.g. in rtc82885.

Qemu and Bochs set the IRQ flags only if they are enabled, which breaks drivers polling on them.

The following patch corrects this for the update-ended-flag in Qemu only. It currently does not fix the handling of the other flags.

hw/mc146818rtc.c +3 -2
index 2022548..2b040a7 100644
@@ -421,9 +421,10 @@ static void rtc_update_second2(void *opaque)
     }
 
     /* update ended interrupt */
+    s->cmos_data[RTC_REG_C] |= REG_C_UF;
     if (s->cmos_data[RTC_REG_B] & REG_B_UIE) {
-        s->cmos_data[RTC_REG_C] |= 0x90;
-        rtc_irq_raise(s->irq);
+      s->cmos_data[RTC_REG_C] |= REG_C_IRQF;
+      rtc_irq_raise(s->irq);
     }
 
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

hw/mc146818rtc.c static void rtc_update_second2(void *opaque) · line 430

Quoted 1 line
hw/mc146818rtc.c +0 -0
     /* clear update in progress bit */

--
Gleb.