Skip to contentSkip to conversation

hw/esp.c mishandles commands without dma

Qemu-devel Martin Husemann 1 participant 2 messages Jun 17, 2012

lore
Share & tools
lore
#0 lore raw

The NetBSD driver sometimes uses commands without DMA (for example a simple TEST_UNIT_READY). On esp hardware, the command has a DMA bit (if dma is to be used), and when writing to the command register, the s->dma status is updated accordingly.

When commands with dma are used and dma is disabled, the command is defered untill dma is enabled again. This is all fine. However, the deferal should not happen if the command does not use dma.

This can bee seen by booting NetBSD/sparc: for every scsi device attached there will be a 5 second timeout and an error message.

Here is a trivial patch wich fixes this problem for me:

esp.c renamed from esp.c.orig +3 -3
@@ -270,7 +270,7 @@ static void handle_satn(ESPState *s)
     uint8_t buf[32];
     int len;
 
-    if (!s->dma_enabled) {
+    if (s->dma && !s->dma_enabled) {
         s->dma_cb = handle_satn;
         return;
     }
@@ -284,7 +284,7 @@ static void handle_s_without_atn(ESPStat
     uint8_t buf[32];
     int len;
 
-    if (!s->dma_enabled) {
+    if (s->dma && !s->dma_enabled) {
         s->dma_cb = handle_s_without_atn;
         return;
     }
@@ -296,7 +296,7 @@ static void handle_s_without_atn(ESPStat
 
 static void handle_satn_stop(ESPState *s)
 {
-    if (!s->dma_enabled) {
+    if (s->dma && !s->dma_enabled) {
         s->dma_cb = handle_satn_stop;
         return;
     }

I filed a ticket in the bugtracker for it: #1014099.

Martin

#1 lore raw
Quoted 45 lines · Martin Husemann

The NetBSD driver sometimes uses commands without DMA (for example a simple TEST_UNIT_READY). On esp hardware, the command has a DMA bit (if dma is to be used), and when writing to the command register, the s->dma status is updated accordingly.

When commands with dma are used and dma is disabled, the command is defered untill dma is enabled again. This is all fine. However, the deferal should not happen if the command does not use dma.

This can bee seen by booting NetBSD/sparc: for every scsi device attached there will be a 5 second timeout and an error message.

Here is a trivial patch wich fixes this problem for me:

esp.c renamed from esp.c.orig +3 -3
@@ -270,7 +270,7 @@ static void handle_satn(ESPState *s)
     uint8_t buf[32];
     int len;
 
-    if (!s->dma_enabled) {
+    if (s->dma && !s->dma_enabled) {
         s->dma_cb = handle_satn;
         return;
     }
@@ -284,7 +284,7 @@ static void handle_s_without_atn(ESPStat
     uint8_t buf[32];
     int len;
 
-    if (!s->dma_enabled) {
+    if (s->dma && !s->dma_enabled) {
         s->dma_cb = handle_s_without_atn;
         return;
     }
@@ -296,7 +296,7 @@ static void handle_s_without_atn(ESPStat
 
 static void handle_satn_stop(ESPState *s)
 {
-    if (!s->dma_enabled) {
+    if (s->dma && !s->dma_enabled) {
         s->dma_cb = handle_satn_stop;
         return;
     }
Quoted 4 lines

I filed a ticket in the bugtracker for it: #1014099.

Martin

Forgot to add: