qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: mst@redhat.com
Subject: [Qemu-devel] [PATCH 21/24] ide: replace set_unit callback with more IDEBus state
Date: Mon, 28 Oct 2013 17:43:37 +0100	[thread overview]
Message-ID: <1382978620-16641-22-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1382978620-16641-1-git-send-email-pbonzini@redhat.com>

Start moving the initial state of the current request to IDEBus, so that
AHCI can use it.  The set_unit callback is not used anymore once this is
done.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/ide/ahci.c     |  7 -------
 hw/ide/core.c     |  6 ++++--
 hw/ide/internal.h |  2 +-
 hw/ide/macio.c    |  1 -
 hw/ide/pci.c      | 19 ++++++-------------
 hw/ide/pci.h      |  7 ++++---
 6 files changed, 15 insertions(+), 27 deletions(-)

diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 9cafee9..b7e0d18 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -1086,12 +1086,6 @@ static int ahci_dma_rw_buf(IDEDMA *dma, int is_write)
     return 1;
 }
 
-static int ahci_dma_set_unit(IDEDMA *dma, int unit)
-{
-    /* only a single unit per link */
-    return 0;
-}
-
 static void ahci_dma_trigger_irq(IDEDMA *dma)
 {
     AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
@@ -1124,7 +1118,6 @@ static const IDEDMAOps ahci_dma_ops = {
     .start_transfer = ahci_start_transfer,
     .prepare_buf = ahci_dma_prepare_buf,
     .rw_buf = ahci_dma_rw_buf,
-    .set_unit = ahci_dma_set_unit,
     .trigger_irq = ahci_dma_trigger_irq,
     .async_cmd_done = ahci_async_cmd_done,
 };
diff --git a/hw/ide/core.c b/hw/ide/core.c
index c07c0d1..970f372 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -580,6 +580,7 @@ static void ide_async_cmd_done(IDEState *s)
 void ide_set_inactive(IDEState *s, bool more)
 {
     s->bus->dma->aiocb = NULL;
+    s->bus->retry_unit = -1;
     if (s->bus->dma->ops->set_inactive) {
         s->bus->dma->ops->set_inactive(s->bus->dma, more);
     }
@@ -601,7 +602,7 @@ static int ide_handle_rw_error(IDEState *s, int error, int op)
     BlockErrorAction action = bdrv_get_error_action(s->bs, is_read, error);
 
     if (action == BDRV_ACTION_STOP) {
-        s->bus->dma->ops->set_unit(s->bus->dma, s->unit);
+        assert(s->bus->retry_unit == s->unit);
         s->bus->error_status = op;
     } else if (action == BDRV_ACTION_REPORT) {
         if (op & IDE_RETRY_DMA) {
@@ -724,6 +725,7 @@ static void ide_sector_start_dma(IDEState *s, enum ide_dma_cmd dma_cmd)
 
 void ide_start_dma(IDEState *s, BlockDriverCompletionFunc *cb)
 {
+    s->bus->retry_unit = s->unit;
     if (s->bus->dma->ops->start_dma) {
         s->bus->dma->ops->start_dma(s->bus->dma, s, cb);
     }
@@ -2185,11 +2187,11 @@ static int ide_nop_int(IDEDMA *dma, int x)
 static const IDEDMAOps ide_dma_nop_ops = {
     .prepare_buf    = ide_nop_int,
     .rw_buf         = ide_nop_int,
-    .set_unit       = ide_nop_int,
 };
 
 static void ide_restart_dma(IDEState *s, enum ide_dma_cmd dma_cmd)
 {
+    s->unit = s->bus->retry_unit;
     s->bus->dma->ops->restart_dma(s->bus->dma);
     s->io_buffer_index = 0;
     s->io_buffer_size = 0;
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index 1c77ad9..b1529be 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -431,7 +431,6 @@ struct IDEDMAOps {
     DMAVoidFunc *start_transfer;
     DMAIntFunc *prepare_buf;
     DMAIntFunc *rw_buf;
-    DMAIntFunc *set_unit;
     DMAVoidFunc *restart_dma;
     DMAVoidFunc *trigger_irq;
     DMAStopFunc *set_inactive;
@@ -461,6 +460,7 @@ struct IDEBus {
     qemu_irq irq;
 
     int error_status;
+    uint8_t retry_unit;
 };
 
 #define TYPE_IDE_DEVICE "ide-device"
diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index d1d40d8..c41706c 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -514,7 +514,6 @@ static const IDEDMAOps dbdma_ops = {
     .start_dma      = ide_dbdma_start,
     .prepare_buf    = ide_nop_int,
     .rw_buf         = ide_nop_int,
-    .set_unit       = ide_nop_int,
 };
 
 static void macio_ide_realizefn(DeviceState *dev, Error **errp)
diff --git a/hw/ide/pci.c b/hw/ide/pci.c
index 7568f1e..43507ec 100644
--- a/hw/ide/pci.c
+++ b/hw/ide/pci.c
@@ -42,7 +42,6 @@ static void bmdma_start_dma(IDEDMA *dma, IDEState *s,
 {
     BMDMAState *bm = DO_UPCAST(BMDMAState, dma, dma);
 
-    bm->unit = s->unit;
     bm->dma_cb = dma_cb;
     bm->cur_prd_last = 0;
     bm->cur_prd_addr = 0;
@@ -148,14 +147,6 @@ static int bmdma_rw_buf(IDEDMA *dma, int is_write)
     return 1;
 }
 
-static int bmdma_set_unit(IDEDMA *dma, int unit)
-{
-    BMDMAState *bm = DO_UPCAST(BMDMAState, dma, dma);
-    bm->unit = unit;
-
-    return 0;
-}
-
 static void bmdma_trigger_irq(IDEDMA *dma)
 {
     BMDMAState *bm = DO_UPCAST(BMDMAState, dma, dma);
@@ -167,7 +158,6 @@ static void bmdma_set_inactive(IDEDMA *dma, bool more)
     BMDMAState *bm = DO_UPCAST(BMDMAState, dma, dma);
 
     bm->dma_cb = NULL;
-    bm->unit = -1;
     if (more) {
         bm->status |= BM_STATUS_DMAING;
     } else {
@@ -326,6 +316,7 @@ static void ide_bmdma_pre_save(void *opaque)
     BMDMAState *bm = opaque;
     uint8_t abused_bits = BM_MIGRATION_COMPAT_STATUS_BITS;
 
+    bm->migration_retry_unit = bm->bus->retry_unit;
     bm->migration_compat_status =
         (bm->status & ~abused_bits) | (bm->bus->error_status & abused_bits);
 }
@@ -342,6 +333,9 @@ static int ide_bmdma_post_load(void *opaque, int version_id)
         bm->status = bm->migration_compat_status & ~abused_bits;
         bm->bus->error_status |= bm->migration_compat_status & abused_bits;
     }
+    if (bm->bus->error_status) {
+        bm->bus->retry_unit = bm->migration_retry_unit;
+    }
 
     return 0;
 }
@@ -383,7 +377,7 @@ static const VMStateDescription vmstate_bmdma = {
         VMSTATE_UINT32(addr, BMDMAState),
         VMSTATE_INT64(sector_num, BMDMAState),
         VMSTATE_UINT32(nsector, BMDMAState),
-        VMSTATE_UINT8(unit, BMDMAState),
+        VMSTATE_UINT8(migration_retry_unit, BMDMAState),
         VMSTATE_END_OF_LIST()
     },
     .subsections = (VMStateSubsection []) {
@@ -407,7 +401,7 @@ static int ide_pci_post_load(void *opaque, int version_id)
     for(i = 0; i < 2; i++) {
         /* current versions always store 0/1, but older version
            stored bigger values. We only need last bit */
-        d->bmdma[i].unit &= 1;
+        d->bmdma[i].migration_retry_unit &= 1;
         ide_bmdma_post_load(&d->bmdma[i], -1);
     }
 
@@ -449,7 +443,6 @@ static const struct IDEDMAOps bmdma_ops = {
     .start_dma = bmdma_start_dma,
     .prepare_buf = bmdma_prepare_buf,
     .rw_buf = bmdma_rw_buf,
-    .set_unit = bmdma_set_unit,
     .restart_dma = bmdma_restart_dma,
     .trigger_irq = bmdma_trigger_irq,
     .set_inactive = bmdma_set_inactive,
diff --git a/hw/ide/pci.h b/hw/ide/pci.h
index 78e5550..6f28ce4 100644
--- a/hw/ide/pci.h
+++ b/hw/ide/pci.h
@@ -22,7 +22,6 @@ typedef struct BMDMAState {
     uint32_t cur_prd_last;
     uint32_t cur_prd_addr;
     uint32_t cur_prd_len;
-    uint8_t unit;
     BlockDriverCompletionFunc *dma_cb;
     int64_t sector_num;
     uint32_t nsector;
@@ -33,6 +32,8 @@ typedef struct BMDMAState {
     /* Bit 0-2 and 7:   BM status register
      * Bit 3-6:         bus->error_status */
     uint8_t migration_compat_status;
+    uint8_t migration_retry_unit;
+
     struct PCIIDEState *pci_dev;
 } BMDMAState;
 
@@ -61,8 +62,8 @@ typedef struct PCIIDEState {
 
 static inline IDEState *bmdma_active_if(BMDMAState *bmdma)
 {
-    assert(bmdma->unit != (uint8_t)-1);
-    return bmdma->bus->ifs + bmdma->unit;
+    assert(bmdma->bus->dma->aiocb != NULL);
+    return bmdma->bus->ifs + bmdma->bus->retry_unit;
 }
 
 
-- 
1.8.3.1

  parent reply	other threads:[~2013-10-28 16:44 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-28 16:43 [Qemu-devel] [WIP PATCH 00/24] IDE cleanups, initial work on AHCI rerror/werror=stop Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 01/24] blkdebug: report errors on flush too Paolo Bonzini
2013-10-30 12:01   ` Kevin Wolf
2013-10-28 16:43 ` [Qemu-devel] [PATCH 02/24] libqtest: return progress from qmp/qmpv Paolo Bonzini
2013-10-30 12:06   ` Kevin Wolf
2013-10-30 12:10     ` Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 03/24] libqtest: add QTEST_LOG for debugging qtest testcases Paolo Bonzini
2013-10-30 12:08   ` Kevin Wolf
2013-10-28 16:43 ` [Qemu-devel] [PATCH 04/24] ide-test: add test for werror=stop Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 05/24] ide: simplify reset callbacks Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 06/24] ide: simplify set_inactive callbacks Paolo Bonzini
2013-10-30 12:20   ` Kevin Wolf
2013-10-28 16:43 ` [Qemu-devel] [PATCH 07/24] ide: simplify async_cmd_done callbacks Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 08/24] ide: simplify start_transfer callbacks Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 09/24] ide: wrap start_dma callback Paolo Bonzini
2013-10-30 12:29   ` Kevin Wolf
2013-10-30 12:44     ` Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 10/24] ide: add trigger_irq callback Paolo Bonzini
2013-10-30 12:47   ` Kevin Wolf
2013-10-30 13:16     ` Paolo Bonzini
2013-10-30 13:34       ` Kevin Wolf
2013-10-30 14:33         ` Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 11/24] ide: fold add_status callback into set_inactive Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 12/24] ide: move BM_STATUS bits to pci.[ch] Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 13/24] ide: move retry constants out of BM_STATUS_* namespace Paolo Bonzini
2013-10-30 12:55   ` Kevin Wolf
2013-10-28 16:43 ` [Qemu-devel] [PATCH 14/24] ide: start extracting ide_restart_dma out of bmdma_restart_dma Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 15/24] ide: prepare to move restart to common code Paolo Bonzini
2013-10-30 12:14   ` Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 16/24] ide: introduce ide_register_restart_cb Paolo Bonzini
2013-10-30 13:13   ` Kevin Wolf
2013-10-30 13:19     ` Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 17/24] ide: do not use BMDMA in restart callback Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 18/24] ide: pass IDEBus to the restart_cb Paolo Bonzini
2013-10-30 12:19   ` Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 19/24] ide: move restart callback to common code Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 20/24] ide: remove restart_cb callback Paolo Bonzini
2013-10-28 16:43 ` Paolo Bonzini [this message]
2013-10-28 16:43 ` [Qemu-devel] [PATCH 22/24] ide: place initial state of the current request to IDEBus Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 23/24] ide: migrate initial request state via IDEBus Paolo Bonzini
2013-10-28 16:43 ` [Qemu-devel] [PATCH 24/24] ide: commonize io_buffer_index initialization Paolo Bonzini
2013-10-28 17:16 ` [Qemu-devel] [WIP PATCH 00/24] IDE cleanups, initial work on AHCI rerror/werror=stop Michael S. Tsirkin
2013-10-28 17:26   ` Paolo Bonzini
2013-10-28 18:00     ` Michael S. Tsirkin
2013-10-28 18:36       ` Paolo Bonzini
2013-10-28 18:42         ` Michael S. Tsirkin
2013-10-29  9:10           ` Paolo Bonzini
2013-10-29 18:30 ` Kevin Wolf
2013-10-30 16:56   ` Paolo Bonzini

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=1382978620-16641-22-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=mst@redhat.com \
    --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).