From: Kevin Wolf <kwolf@redhat.com>
To: anthony@codemonkey.ws
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 13/16] ide: Factor ide_dma_set_inactive out
Date: Tue, 30 Nov 2010 18:58:17 +0100 [thread overview]
Message-ID: <1291139900-20329-14-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1291139900-20329-1-git-send-email-kwolf@redhat.com>
Several places that stop a DMA transfer duplicate this code. Factor it out into
a common function.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
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 484e0ca..7136ade 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(&s->sg);
}
+static void ide_dma_set_inactive(BMDMAState *bm)
+{
+ bm->status &= ~BM_STATUS_DMAING;
+ bm->dma_cb = NULL;
+ bm->unit = -1;
+ bm->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->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
eot:
- bm->status &= ~BM_STATUS_DMAING;
bm->status |= BM_STATUS_INT;
- bm->dma_cb = NULL;
- bm->unit = -1;
- bm->aiocb = NULL;
+ ide_dma_set_inactive(bm);
return;
}
@@ -733,11 +738,8 @@ static void ide_write_dma_cb(void *opaque, int ret)
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
eot:
- bm->status &= ~BM_STATUS_DMAING;
bm->status |= BM_STATUS_INT;
- bm->dma_cb = NULL;
- bm->unit = -1;
- bm->aiocb = NULL;
+ ide_dma_set_inactive(bm);
return;
}
@@ -1061,11 +1063,8 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret)
s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD;
ide_set_irq(s->bus);
eot:
- bm->status &= ~BM_STATUS_DMAING;
bm->status |= BM_STATUS_INT;
- bm->dma_cb = NULL;
- bm->unit = -1;
- bm->aiocb = NULL;
+ ide_dma_set_inactive(bm);
return;
}
@@ -2954,12 +2953,10 @@ void ide_dma_cancel(BMDMAState *bm)
printf("aio_cancel\n");
#endif
bdrv_aio_cancel(bm->aiocb);
- bm->aiocb = NULL;
}
- bm->status &= ~BM_STATUS_DMAING;
+
/* cancel DMA request */
- bm->unit = -1;
- bm->dma_cb = NULL;
+ ide_dma_set_inactive(bm);
}
}
--
1.7.2.3
next prev parent reply other threads:[~2010-12-01 4:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-30 17:58 [Qemu-devel] [PULL 00/16] Block patches Kevin Wolf
2010-11-30 17:58 ` [Qemu-devel] [PATCH 01/16] scsi-disk: Move active request asserts Kevin Wolf
2010-11-30 17:58 ` [Qemu-devel] [PATCH 02/16] Implement drive_del to decouple block removal from device removal Kevin Wolf
2010-11-30 17:58 ` [Qemu-devel] [PATCH 03/16] block migration: do not submit multiple AIOs for same sector (v2) Kevin Wolf
2010-11-30 17:58 ` [Qemu-devel] [PATCH 04/16] ide: convert bmdma address ioport to ioport_register() Kevin Wolf
2010-11-30 17:58 ` [Qemu-devel] [PATCH 05/16] qemu and qemu-xen: support empty write barriers in xen_disk Kevin Wolf
2010-11-30 17:58 ` [Qemu-devel] [PATCH 06/16] block: Remove unused s->hd in various drivers Kevin Wolf
2010-11-30 17:58 ` [Qemu-devel] [PATCH 07/16] scsi: Increase the number of possible devices Kevin Wolf
2010-11-30 17:58 ` [Qemu-devel] [PATCH 08/16] scsi: Return SAM status codes Kevin Wolf
2010-11-30 17:58 ` [Qemu-devel] [PATCH 09/16] scsi: INQUIRY VPD fixes Kevin Wolf
2010-11-30 17:58 ` [Qemu-devel] [PATCH 10/16] scsi: Move sense handling into the driver Kevin Wolf
2010-11-30 17:58 ` [Qemu-devel] [PATCH 11/16] scsi-disk: Remove duplicate cdb parsing Kevin Wolf
2010-11-30 17:58 ` [Qemu-devel] [PATCH 12/16] raw-posix: raw_pwrite comment fixup Kevin Wolf
2010-11-30 17:58 ` Kevin Wolf [this message]
2010-11-30 17:58 ` [Qemu-devel] [PATCH 14/16] ide: Set bus master inactive on error Kevin Wolf
2010-11-30 17:58 ` [Qemu-devel] [PATCH 15/16] ide: Ignore double DMA transfer starts/stops Kevin Wolf
2010-11-30 17:58 ` [Qemu-devel] [PATCH 16/16] ide: Reset current_addr after stopping DMA Kevin Wolf
2010-12-06 13:32 ` [Qemu-devel] [PULL 00/16] Block patches Anthony Liguori
2010-12-06 13:41 ` Kevin Wolf
2010-12-06 14:09 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1291139900-20329-14-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).