Skip to contentSkip to conversation

lsi53c895a: fix Phase Mismatch Jump

PATCH Superseded Paolo Bonzini 4 participants 9 messages Jun 14, 2010 – Jun 29, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lsi53c895a: fix Phase Mismatch Jump

lsi_bad_phase has a bug in the choice of pmjad1/pmjad2. This does not matter with Linux guests because it uses just one routine for both, but it breaks Windows 64-bit guests. This is the text from the spec:

"[The PMJCTL] bit controls which decision mechanism is used when jumping on phase mismatch. When this bit is cleared the LSI53C895A will use Phase Mismatch Jump Address 1 (PMJAD1) when the WSR bit is cleared and Phase Mismatch Jump Address 2 (PMJAD2) when the WSR bit is set. When this bit is set the LSI53C895A will use jump address one (PMJAD1) on data out (data out, command, message out) transfers and jump address two (PMJAD2) on data in (data in, status, message in) transfers."

Which means:

CCNTL0.PMJCTL
0 SCNTL2.WSR = 0 PMJAD1
0 SCNTL2.WSR = 1 PMJAD2
1 out PMJAD1
1 in PMJAD2

In qemu, what you get instead is:

CCNTL0.PMJCTL
0 out PMJAD1
0 in PMJAD2 <<<<<
1 out PMJAD1
1 in PMJAD1 <<<<<

Considering that qemu always has SCNTL2.WSR cleared, the two marked cases (corresponding to phase mismatch on input) are always jumping to the wrong PMJAD register. The patch implements the correct semantics.

---
 hw/lsi53c895a.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
hw/lsi53c895a.c +6 -3
index f5a91ba..00df2bd 100644
@@ -490,11 +490,14 @@ static void lsi_bad_phase(LSIState *s, int out, int new_phase)
 {
     /* Trigger a phase mismatch.  */
     if (s->ccntl0 & LSI_CCNTL0_ENPMJ) {
-        if ((s->ccntl0 & LSI_CCNTL0_PMJCTL) || out) {
-            s->dsp = s->pmjad1;
+        int dest;
+        if ((s->ccntl0 & LSI_CCNTL0_PMJCTL)) {
+            dest = out ? 1 : 2;
         } else {
-            s->dsp = s->pmjad2;
+            dest = (s->scntl2 & LSI_SCNTL2_WSR ? 2 : 1);
         }
+
+        s->dsp = (dest == 1) ? s->pmjad1 : s->pmjad2;
         DPRINTF("Data phase mismatch jump to %08x\n", s->dsp);
     } else {
         DPRINTF("Phase mismatch interrupt\n");
Signature · 1 line
1.7.0.1
#1 lore raw
Quoted 51 lines · Paolo Bonzini

lsi_bad_phase has a bug in the choice of pmjad1/pmjad2. This does not matter with Linux guests because it uses just one routine for both, but it breaks Windows 64-bit guests. This is the text from the spec:

"[The PMJCTL] bit controls which decision mechanism is used when jumping on phase mismatch. When this bit is cleared the LSI53C895A will use Phase Mismatch Jump Address 1 (PMJAD1) when the WSR bit is cleared and Phase Mismatch Jump Address 2 (PMJAD2) when the WSR bit is set. When this bit is set the LSI53C895A will use jump address one (PMJAD1) on data out (data out, command, message out) transfers and jump address two (PMJAD2) on data in (data in, status, message in) transfers."

Which means:

CCNTL0.PMJCTL
0 SCNTL2.WSR = 0 PMJAD1
0 SCNTL2.WSR = 1 PMJAD2
1 out PMJAD1
1 in PMJAD2

In qemu, what you get instead is:

CCNTL0.PMJCTL
0 out PMJAD1
0 in PMJAD2 <<<<<
1 out PMJAD1
1 in PMJAD1 <<<<<

Considering that qemu always has SCNTL2.WSR cleared, the two marked cases (corresponding to phase mismatch on input) are always jumping to the wrong PMJAD register. The patch implements the correct semantics.

---
 hw/lsi53c895a.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
hw/lsi53c895a.c +2 -2
index f5a91ba..00df2bd 100644
@@ -490,11 +490,14 @@ static void lsi_bad_phase(LSIState *s, int out, int new_phase)
 {
     /* Trigger a phase mismatch.  */
     if (s->ccntl0 & LSI_CCNTL0_ENPMJ) {
-        if ((s->ccntl0 & LSI_CCNTL0_PMJCTL) || out) {
-            s->dsp = s->pmjad1;
+        int dest;
+        if ((s->ccntl0 & LSI_CCNTL0_PMJCTL)) {

hw/lsi53c895a.c static void lsi_bad_phase(LSIState *s, int out, int new_phase) · line 503

Quoted 10 lines
hw/lsi53c895a.c +4 -1
+            dest = out ? 1 : 2;
         } else {
-            s->dsp = s->pmjad2;
+            dest = (s->scntl2 & LSI_SCNTL2_WSR ? 2 : 1);
         }
+
+        s->dsp = (dest == 1) ? s->pmjad1 : s->pmjad2;
         DPRINTF("Data phase mismatch jump to %08x\n", s->dsp);
     } else {
         DPRINTF("Phase mismatch interrupt\n");

Looks correct. But why not assigning s->pmjad[12] directly? Would improve readability IMO.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#2 lore raw
Quoted 67 lines · Jan Kiszka
Quoted 52 lines · Paolo Bonzini

lsi_bad_phase has a bug in the choice of pmjad1/pmjad2. This does not matter with Linux guests because it uses just one routine for both, but it breaks Windows 64-bit guests. This is the text from the spec:

"[The PMJCTL] bit controls which decision mechanism is used when jumping on phase mismatch. When this bit is cleared the LSI53C895A will use Phase Mismatch Jump Address 1 (PMJAD1) when the WSR bit is cleared and Phase Mismatch Jump Address 2 (PMJAD2) when the WSR bit is set. When this bit is set the LSI53C895A will use jump address one (PMJAD1) on data out (data out, command, message out) transfers and jump address two (PMJAD2) on data in (data in, status, message in) transfers."

Which means:

CCNTL0.PMJCTL
0 SCNTL2.WSR = 0 PMJAD1
0 SCNTL2.WSR = 1 PMJAD2
1 out PMJAD1
1 in PMJAD2

In qemu, what you get instead is:

CCNTL0.PMJCTL
0 out PMJAD1
0 in PMJAD2<<<<<
1 out PMJAD1
1 in PMJAD1<<<<<

Considering that qemu always has SCNTL2.WSR cleared, the two marked cases (corresponding to phase mismatch on input) are always jumping to the wrong PMJAD register. The patch implements the correct semantics.

---
  hw/lsi53c895a.c |   12 +++++++++---
  1 files changed, 9 insertions(+), 3 deletions(-)
hw/lsi53c895a.c +2 -2
index f5a91ba..00df2bd 100644
@@ -490,11 +490,14 @@ static void lsi_bad_phase(LSIState *s, int out, int new_phase)
  {
      /* Trigger a phase mismatch.  */
      if (s->ccntl0&  LSI_CCNTL0_ENPMJ) {
-        if ((s->ccntl0&  LSI_CCNTL0_PMJCTL) || out) {
-            s->dsp = s->pmjad1;
+        int dest;
+        if ((s->ccntl0&  LSI_CCNTL0_PMJCTL)) {

hw/lsi53c895a.c static void lsi_bad_phase(LSIState *s, int out, int new_phase) · line 503

Quoted 10 lines
hw/lsi53c895a.c +4 -1
+            dest = out ? 1 : 2;
          } else {
-            s->dsp = s->pmjad2;
+            dest = (s->scntl2&  LSI_SCNTL2_WSR ? 2 : 1);
          }
+
+        s->dsp = (dest == 1) ? s->pmjad1 : s->pmjad2;
          DPRINTF("Data phase mismatch jump to %08x\n", s->dsp);
      } else {
          DPRINTF("Phase mismatch interrupt\n");

Looks correct. But why not assigning s->pmjad[12] directly? Would improve readability IMO.

Quoted 3 lines

Jan

Jan,
I think this is better since if something goes wrong it could be easier to just put dest variable to DPRINTF() macro, like:

DPRINTF("Data phase mismatch jump to %08x (== pmjad%d)\n", s->dsp, dest);

rather than implementing it some other way. Now it could be easier to just know what the problem is - i.e. whether it's accessing the wrong register or now.

Michal

Signature · 2 lines
Michal Novotny<[email protected]>, RHCE
Virtualization Team (xen userspace), Red Hat
#3 lore raw
Quoted 75 lines · Michal Novotny
Quoted 67 lines · Jan Kiszka
Quoted 52 lines · Paolo Bonzini

lsi_bad_phase has a bug in the choice of pmjad1/pmjad2. This does not matter with Linux guests because it uses just one routine for both, but it breaks Windows 64-bit guests. This is the text from the spec:

"[The PMJCTL] bit controls which decision mechanism is used when jumping on phase mismatch. When this bit is cleared the LSI53C895A will use Phase Mismatch Jump Address 1 (PMJAD1) when the WSR bit is cleared and Phase Mismatch Jump Address 2 (PMJAD2) when the WSR bit is set. When this bit is set the LSI53C895A will use jump address one (PMJAD1) on data out (data out, command, message out) transfers and jump address two (PMJAD2) on data in (data in, status, message in) transfers."

Which means:

CCNTL0.PMJCTL
0 SCNTL2.WSR = 0 PMJAD1
0 SCNTL2.WSR = 1 PMJAD2
1 out PMJAD1
1 in PMJAD2

In qemu, what you get instead is:

CCNTL0.PMJCTL
0 out PMJAD1
0 in PMJAD2<<<<<
1 out PMJAD1
1 in PMJAD1<<<<<

Considering that qemu always has SCNTL2.WSR cleared, the two marked cases (corresponding to phase mismatch on input) are always jumping to the wrong PMJAD register. The patch implements the correct semantics.

---
  hw/lsi53c895a.c |   12 +++++++++---
  1 files changed, 9 insertions(+), 3 deletions(-)
hw/lsi53c895a.c +2 -2
index f5a91ba..00df2bd 100644
@@ -490,11 +490,14 @@ static void lsi_bad_phase(LSIState *s, int out, int new_phase)
  {
      /* Trigger a phase mismatch.  */
      if (s->ccntl0&  LSI_CCNTL0_ENPMJ) {
-        if ((s->ccntl0&  LSI_CCNTL0_PMJCTL) || out) {
-            s->dsp = s->pmjad1;
+        int dest;
+        if ((s->ccntl0&  LSI_CCNTL0_PMJCTL)) {

hw/lsi53c895a.c static void lsi_bad_phase(LSIState *s, int out, int new_phase) · line 503

Quoted 10 lines
hw/lsi53c895a.c +4 -1
+            dest = out ? 1 : 2;
          } else {
-            s->dsp = s->pmjad2;
+            dest = (s->scntl2&  LSI_SCNTL2_WSR ? 2 : 1);
          }
+
+        s->dsp = (dest == 1) ? s->pmjad1 : s->pmjad2;
          DPRINTF("Data phase mismatch jump to %08x\n", s->dsp);
      } else {
          DPRINTF("Phase mismatch interrupt\n");

Looks correct. But why not assigning s->pmjad[12] directly? Would improve readability IMO.

Quoted 3 lines

Jan

Jan,
I think this is better since if something goes wrong it could be easier to just put dest variable to DPRINTF() macro, like:

Quoted 5 lines

DPRINTF("Data phase mismatch jump to %08x (== pmjad%d)\n", s->dsp, dest);

rather than implementing it some other way. Now it could be easier to just know what the problem is - i.e. whether it's accessing the wrong register or now.

I don't mind. But if you have a use case for that separate variable, then include it. No one can read your mind, and even less once this patch is long merged.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#4 lore raw
Quoted 87 lines · Jan Kiszka
Quoted 79 lines · Michal Novotny
Quoted 69 lines · Jan Kiszka
Quoted 53 lines · Paolo Bonzini

lsi_bad_phase has a bug in the choice of pmjad1/pmjad2. This does not matter with Linux guests because it uses just one routine for both, but it breaks Windows 64-bit guests. This is the text from the spec:

"[The PMJCTL] bit controls which decision mechanism is used when jumping on phase mismatch. When this bit is cleared the LSI53C895A will use Phase Mismatch Jump Address 1 (PMJAD1) when the WSR bit is cleared and Phase Mismatch Jump Address 2 (PMJAD2) when the WSR bit is set. When this bit is set the LSI53C895A will use jump address one (PMJAD1) on data out (data out, command, message out) transfers and jump address two (PMJAD2) on data in (data in, status, message in) transfers."

Which means:

CCNTL0.PMJCTL
0 SCNTL2.WSR = 0 PMJAD1
0 SCNTL2.WSR = 1 PMJAD2
1 out PMJAD1
1 in PMJAD2

In qemu, what you get instead is:

CCNTL0.PMJCTL
0 out PMJAD1
0 in PMJAD2<<<<<
1 out PMJAD1
1 in PMJAD1<<<<<

Considering that qemu always has SCNTL2.WSR cleared, the two marked cases (corresponding to phase mismatch on input) are always jumping to the wrong PMJAD register. The patch implements the correct semantics.

---
   hw/lsi53c895a.c |   12 +++++++++---
   1 files changed, 9 insertions(+), 3 deletions(-)
hw/lsi53c895a.c +2 -2
index f5a91ba..00df2bd 100644
@@ -490,11 +490,14 @@ static void lsi_bad_phase(LSIState *s, int out, int new_phase)
   {
       /* Trigger a phase mismatch.  */
       if (s->ccntl0&   LSI_CCNTL0_ENPMJ) {
-        if ((s->ccntl0&   LSI_CCNTL0_PMJCTL) || out) {
-            s->dsp = s->pmjad1;
+        int dest;
+        if ((s->ccntl0&   LSI_CCNTL0_PMJCTL)) {

hw/lsi53c895a.c static void lsi_bad_phase(LSIState *s, int out, int new_phase) · line 503

Quoted 10 lines
hw/lsi53c895a.c +4 -1
+            dest = out ? 1 : 2;
           } else {
-            s->dsp = s->pmjad2;
+            dest = (s->scntl2&   LSI_SCNTL2_WSR ? 2 : 1);
           }
+
+        s->dsp = (dest == 1) ? s->pmjad1 : s->pmjad2;
           DPRINTF("Data phase mismatch jump to %08x\n", s->dsp);
       } else {
           DPRINTF("Phase mismatch interrupt\n");

Looks correct. But why not assigning s->pmjad[12] directly? Would improve readability IMO.

Quoted 4 lines

Jan

Jan,
I think this is better since if something goes wrong it could be easier to just put dest variable to DPRINTF() macro, like:

Quoted 6 lines

DPRINTF("Data phase mismatch jump to %08x (== pmjad%d)\n", s->dsp, dest);

rather than implementing it some other way. Now it could be easier to just know what the problem is - i.e. whether it's accessing the wrong register or now.

Quoted 7 lines

I don't mind. But if you have a use case for that separate variable, then include it. No one can read your mind, and even less once this patch is long merged.

Jan

This is not my patch, it's Paolo's but I'm just telling you I can see it useful. If it's not used in the DPRINTF() it's being optimized by gcc anyway so not a big deal ;)

Michal

Signature · 2 lines
Michal Novotny<[email protected]>, RHCE
Virtualization Team (xen userspace), Red Hat
#5 lore raw

PATCH v2 1/1 lsi53c895a: fix Phase Mismatch Jump

In reply to Jan Kiszka

lsi_bad_phase has a bug in the choice of pmjad1/pmjad2. This does not matter with Linux guests because it uses just one routine for both, but it breaks Windows 64-bit guests. This is the text from the spec:

"[The PMJCTL] bit controls which decision mechanism is used when jumping on phase mismatch. When this bit is cleared the LSI53C895A will use Phase Mismatch Jump Address 1 (PMJAD1) when the WSR bit is cleared and Phase Mismatch Jump Address 2 (PMJAD2) when the WSR bit is set. When this bit is set the LSI53C895A will use jump address one (PMJAD1) on data out (data out, command, message out) transfers and jump address two (PMJAD2) on data in (data in, status, message in) transfers."

Which means:

CCNTL0.PMJCTL
0 SCNTL2.WSR = 0 PMJAD1
0 SCNTL2.WSR = 1 PMJAD2
1 out PMJAD1
1 in PMJAD2

In qemu, what you get instead is:

CCNTL0.PMJCTL
0 out PMJAD1
0 in PMJAD2 <<<<<
1 out PMJAD1
1 in PMJAD1 <<<<<

Considering that qemu always has SCNTL2.WSR cleared, the two marked cases (corresponding to phase mismatch on input) are always jumping to the wrong PMJAD register. The patch implements the correct semantics.

---
> Looks correct. But why not assigning s->pmjad[12] directly? Would > improve readability IMO.

No particular reason, hence fine by me.

 hw/lsi53c895a.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
hw/lsi53c895a.c +3 -3
index f5a91ba..9a37fed 100644
@@ -490,10 +490,10 @@ static void lsi_bad_phase(LSIState *s, int out, int new_phase)
 {
     /* Trigger a phase mismatch.  */
     if (s->ccntl0 & LSI_CCNTL0_ENPMJ) {
-        if ((s->ccntl0 & LSI_CCNTL0_PMJCTL) || out) {
-            s->dsp = s->pmjad1;
+        if ((s->ccntl0 & LSI_CCNTL0_PMJCTL)) {
+            s->dsp = out ? s->pmjad1 : s->pmjad2;
         } else {
-            s->dsp = s->pmjad2;
+            s->dsp = (s->scntl2 & LSI_SCNTL2_WSR ? s->pmjad2 : s->pmjad1);
         }
         DPRINTF("Data phase mismatch jump to %08x\n", s->dsp);
     } else {
Signature · 1 line
1.7.0.1
#6 lore raw
Quoted 52 lines · Paolo Bonzini

lsi_bad_phase has a bug in the choice of pmjad1/pmjad2. This does not matter with Linux guests because it uses just one routine for both, but it breaks Windows 64-bit guests. This is the text from the spec:

"[The PMJCTL] bit controls which decision mechanism is used when jumping on phase mismatch. When this bit is cleared the LSI53C895A will use Phase Mismatch Jump Address 1 (PMJAD1) when the WSR bit is cleared and Phase Mismatch Jump Address 2 (PMJAD2) when the WSR bit is set. When this bit is set the LSI53C895A will use jump address one (PMJAD1) on data out (data out, command, message out) transfers and jump address two (PMJAD2) on data in (data in, status, message in) transfers."

Which means:

CCNTL0.PMJCTL
0 SCNTL2.WSR = 0 PMJAD1
0 SCNTL2.WSR = 1 PMJAD2
1 out PMJAD1
1 in PMJAD2

In qemu, what you get instead is:

CCNTL0.PMJCTL
0 out PMJAD1
0 in PMJAD2<<<<<
1 out PMJAD1
1 in PMJAD1<<<<<

Considering that qemu always has SCNTL2.WSR cleared, the two marked cases (corresponding to phase mismatch on input) are always jumping to the wrong PMJAD register. The patch implements the correct semantics.

---
> Looks correct. But why not assigning s->pmjad[12] directly? Would > improve readability IMO.

No particular reason, hence fine by me.

  hw/lsi53c895a.c |    6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)
hw/lsi53c895a.c +0 -0
index f5a91ba..9a37fed 100644
@@ -490,10 +490,10 @@ static void lsi_bad_phase(LSIState *s, int out, int new_phase)
  {
      /* Trigger a phase mismatch.  */
      if (s->ccntl0&  LSI_CCNTL0_ENPMJ) {

hw/lsi53c895a.c static void lsi_bad_phase(LSIState *s, int out, int new_phase) · line 499

Quoted 10 lines
hw/lsi53c895a.c +3 -3
-        if ((s->ccntl0&  LSI_CCNTL0_PMJCTL) || out) {
-            s->dsp = s->pmjad1;
+        if ((s->ccntl0&  LSI_CCNTL0_PMJCTL)) {
+            s->dsp = out ? s->pmjad1 : s->pmjad2;
          } else {
-            s->dsp = s->pmjad2;
+            s->dsp = (s->scntl2&  LSI_SCNTL2_WSR ? s->pmjad2 : s->pmjad1);
          }
          DPRINTF("Data phase mismatch jump to %08x\n", s->dsp);
      } else {

PING

Paolo

#7 lore raw
In reply to Paolo Bonzini
Quoted 34 lines · Paolo Bonzini

lsi_bad_phase has a bug in the choice of pmjad1/pmjad2. This does not matter with Linux guests because it uses just one routine for both, but it breaks Windows 64-bit guests. This is the text from the spec:

"[The PMJCTL] bit controls which decision mechanism is used when jumping on phase mismatch. When this bit is cleared the LSI53C895A will use Phase Mismatch Jump Address 1 (PMJAD1) when the WSR bit is cleared and Phase Mismatch Jump Address 2 (PMJAD2) when the WSR bit is set. When this bit is set the LSI53C895A will use jump address one (PMJAD1) on data out (data out, command, message out) transfers and jump address two (PMJAD2) on data in (data in, status, message in) transfers."

Which means:

CCNTL0.PMJCTL
0 SCNTL2.WSR = 0 PMJAD1
0 SCNTL2.WSR = 1 PMJAD2
1 out PMJAD1
1 in PMJAD2

In qemu, what you get instead is:

CCNTL0.PMJCTL
0 out PMJAD1
0 in PMJAD2 <<<<<
1 out PMJAD1
1 in PMJAD1 <<<<<

Considering that qemu always has SCNTL2.WSR cleared, the two marked cases (corresponding to phase mismatch on input) are always jumping to the wrong PMJAD register. The patch implements the correct semantics.

Quoted 6 lines

---
> Looks correct. But why not assigning s->pmjad[12] directly? Would > improve readability IMO.

No particular reason, hence fine by me.

Thanks, applied.

Quoted 26 lines
 hw/lsi53c895a.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
hw/lsi53c895a.c +3 -3
index f5a91ba..9a37fed 100644
@@ -490,10 +490,10 @@ static void lsi_bad_phase(LSIState *s, int out, int new_phase)
 {
     /* Trigger a phase mismatch.  */
     if (s->ccntl0 & LSI_CCNTL0_ENPMJ) {
-        if ((s->ccntl0 & LSI_CCNTL0_PMJCTL) || out) {
-            s->dsp = s->pmjad1;
+        if ((s->ccntl0 & LSI_CCNTL0_PMJCTL)) {
+            s->dsp = out ? s->pmjad1 : s->pmjad2;
         } else {
-            s->dsp = s->pmjad2;
+            s->dsp = (s->scntl2 & LSI_SCNTL2_WSR ? s->pmjad2 : s->pmjad1);
         }
         DPRINTF("Data phase mismatch jump to %08x\n", s->dsp);
     } else {
Signature · 1 line
1.7.0.1
Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#8 lore raw
In reply to Jan Kiszka
Quoted 67 lines · Jan Kiszka
Quoted 52 lines · Paolo Bonzini

lsi_bad_phase has a bug in the choice of pmjad1/pmjad2. This does not matter with Linux guests because it uses just one routine for both, but it breaks Windows 64-bit guests. This is the text from the spec:

"[The PMJCTL] bit controls which decision mechanism is used when jumping on phase mismatch. When this bit is cleared the LSI53C895A will use Phase Mismatch Jump Address 1 (PMJAD1) when the WSR bit is cleared and Phase Mismatch Jump Address 2 (PMJAD2) when the WSR bit is set. When this bit is set the LSI53C895A will use jump address one (PMJAD1) on data out (data out, command, message out) transfers and jump address two (PMJAD2) on data in (data in, status, message in) transfers."

Which means:

CCNTL0.PMJCTL
0 SCNTL2.WSR = 0 PMJAD1
0 SCNTL2.WSR = 1 PMJAD2
1 out PMJAD1
1 in PMJAD2

In qemu, what you get instead is:

CCNTL0.PMJCTL
0 out PMJAD1
0 in PMJAD2<<<<<
1 out PMJAD1
1 in PMJAD1<<<<<

Considering that qemu always has SCNTL2.WSR cleared, the two marked cases (corresponding to phase mismatch on input) are always jumping to the wrong PMJAD register. The patch implements the correct semantics.

---
  hw/lsi53c895a.c |   12 +++++++++---
  1 files changed, 9 insertions(+), 3 deletions(-)
hw/lsi53c895a.c +2 -2
index f5a91ba..00df2bd 100644
@@ -490,11 +490,14 @@ static void lsi_bad_phase(LSIState *s, int out, int new_phase)
  {
      /* Trigger a phase mismatch.  */
      if (s->ccntl0&  LSI_CCNTL0_ENPMJ) {
-        if ((s->ccntl0&  LSI_CCNTL0_PMJCTL) || out) {
-            s->dsp = s->pmjad1;
+        int dest;
+        if ((s->ccntl0&  LSI_CCNTL0_PMJCTL)) {

hw/lsi53c895a.c static void lsi_bad_phase(LSIState *s, int out, int new_phase) · line 503

Quoted 10 lines
hw/lsi53c895a.c +4 -1
+            dest = out ? 1 : 2;
          } else {
-            s->dsp = s->pmjad2;
+            dest = (s->scntl2&  LSI_SCNTL2_WSR ? 2 : 1);
          }
+
+        s->dsp = (dest == 1) ? s->pmjad1 : s->pmjad2;
          DPRINTF("Data phase mismatch jump to %08x\n", s->dsp);
      } else {
          DPRINTF("Phase mismatch interrupt\n");

Looks correct. But why not assigning s->pmjad[12] directly? Would improve readability IMO.

Quoted 3 lines

Jan

Jan, I think this is better readable since something goes wrong it could be easier to just put dest to DPRINTF() macro, like:

DPRINTF("Data phase mismatch jump to %08x (== pmjad%d)\n", s->dsp, dest);

rather than implementing it some other way.

Michal

Signature · 2 lines
Michal Novotny<[email protected]>, RHCE
Virtualization Team (xen userspace), Red Hat