<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From 4827886c00a10778efd3fefbac82476ea603656a Mon Sep 17 00:00:00 2001
From: Kevin Wolf &lt;kwolf@redhat.com&gt;
Date: Thu, 5 May 2011 09:34:45 -0300
Subject: [RHEL6 qemu-kvm PATCH 1/6] ide: Factor ide_dma_set_inactive out

RH-Author: Kevin Wolf &lt;kwolf@redhat.com&gt;
Message-id: &lt;1304588087-6055-2-git-send-email-kwolf@redhat.com&gt;
Patchwork-id: 23637
O-Subject: [RHEL-6.2 qemu-kvm PATCH 1/3] ide: Factor ide_dma_set_inactive out
Bugzilla: 701775
RH-Acked-by: Jes Sorensen &lt;Jes.Sorensen@redhat.com&gt;
RH-Acked-by: Andrea Arcangeli &lt;aarcange@redhat.com&gt;
RH-Acked-by: Markus Armbruster &lt;armbru@redhat.com&gt;

Bugzilla: 701775

Several places that stop a DMA transfer duplicate this code. Factor it out into
a common function.

Signed-off-by: Kevin Wolf &lt;kwolf@redhat.com&gt;
Reviewed-by: Stefan Hajnoczi &lt;stefanha@linux.vnet.ibm.com&gt;
(cherry picked from commit 8337606d3588f80aea656db74127423bd6b61443)
---
 hw/ide/core.c |   29 +++++++++++++----------------
 1 files changed, 13 insertions(+), 16 deletions(-)

Signed-off-by: Eduardo Habkost &lt;ehabkost@redhat.com&gt;
---
 hw/ide/core.c |   29 +++++++++++++----------------
 1 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/hw/ide/core.c b/hw/ide/core.c
index f76e5f6..9807398 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -473,6 +473,14 @@ static void dma_buf_commit(IDEState *s, int is_write)
     qemu_sglist_destroy(&amp;s-&gt;sg);
 }
 
+static void ide_dma_set_inactive(BMDMAState *bm)
+{
+    bm-&gt;status &amp;= ~BM_STATUS_DMAING;
+    bm-&gt;dma_cb = NULL;
+    bm-&gt;unit = -1;
+    bm-&gt;aiocb = NULL;
+}
+
 void ide_dma_error(IDEState *s)
 {
     ide_transfer_stop(s);
@@ -587,11 +595,8 @@ static void ide_read_dma_cb(void *opaque, int ret)
         s-&gt;status = READY_STAT | SEEK_STAT;
         ide_set_irq(s-&gt;bus);
     eot:
-        bm-&gt;status &amp;= ~BM_STATUS_DMAING;
         bm-&gt;status |= BM_STATUS_INT;
-        bm-&gt;dma_cb = NULL;
-        bm-&gt;unit = -1;
-        bm-&gt;aiocb = NULL;
+        ide_dma_set_inactive(bm);
         return;
     }
 
@@ -736,11 +741,8 @@ static void ide_write_dma_cb(void *opaque, int ret)
         s-&gt;status = READY_STAT | SEEK_STAT;
         ide_set_irq(s-&gt;bus);
     eot:
-        bm-&gt;status &amp;= ~BM_STATUS_DMAING;
         bm-&gt;status |= BM_STATUS_INT;
-        bm-&gt;dma_cb = NULL;
-        bm-&gt;unit = -1;
-        bm-&gt;aiocb = NULL;
+        ide_dma_set_inactive(bm);
         return;
     }
 
@@ -1064,11 +1066,8 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret)
         s-&gt;nsector = (s-&gt;nsector &amp; ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD;
         ide_set_irq(s-&gt;bus);
     eot:
-        bm-&gt;status &amp;= ~BM_STATUS_DMAING;
         bm-&gt;status |= BM_STATUS_INT;
-        bm-&gt;dma_cb = NULL;
-        bm-&gt;unit = -1;
-        bm-&gt;aiocb = NULL;
+        ide_dma_set_inactive(bm);
         return;
     }
 
@@ -3118,12 +3117,10 @@ void ide_dma_cancel(BMDMAState *bm)
             printf("aio_cancel\n");
 #endif
             bdrv_aio_cancel(bm-&gt;aiocb);
-            bm-&gt;aiocb = NULL;
         }
-        bm-&gt;status &amp;= ~BM_STATUS_DMAING;
+
         /* cancel DMA request */
-        bm-&gt;unit = -1;
-        bm-&gt;dma_cb = NULL;
+        ide_dma_set_inactive(bm);
     }
 }
 
-- 
1.7.3.2

</pre></body></html>