Skip to contentSkip to conversation

AHCI emulation support v2

PATCH In review Alexander Graf 6 participants 30 messages Nov 18, 2010 – Nov 22, 2010 Kbuild

lore
Share & tools
lore
#7 lore raw

PATCH 7/10 pci: add ich7 pci id

In reply to Alexander Graf

We need a PCI ID for our new AHCI adapter. I just picked an ICH-7M because that's the one built into the first Macbooks.

This patch adds a PCI ID define for an ICH-7M AHCI adapter.

---
 hw/pci.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
hw/pci.h +1 -0
index 7100804..be0f9c2 100644
@@ -62,6 +62,7 @@
 /* Intel (0x8086) */
 #define PCI_DEVICE_ID_INTEL_82551IT      0x1209
 #define PCI_DEVICE_ID_INTEL_82557        0x1229
+#define PCI_DEVICE_ID_INTEL_ICH7M_AHCI   0x27c5
 
 /* Red Hat / Qumranet (for QEMU) -- see pci-ids.txt */
 #define PCI_VENDOR_ID_REDHAT_QUMRANET    0x1af4
Signature · 1 line
1.6.0.2
#0 lore raw

cover AHCI emulation support v2

This patch adds support for AHCI emulation. I have tested and verified it works in Linux, OpenBSD, Windows Vista and Windows 7. This AHCI emulation supports NCQ, so multiple read or write requests can be outstanding at the same time.

The code is however not fully optimized yet. I'm fairly sure that there are low hanging performance fruits to be found still :). In my simple benchmarks I achieved about 2/3rd of virtio performance.

Also, this AHCI emulation layer does not support legacy mode. So if you're using a disk with this emulation, you do not get it exposed using the legacy IDE interfaces.

Another nitpick is CD-ROM support in Windows. Somehow it doesn't detect a CD-ROM drive attached to AHCI. At least it doesn't list it.

To attach an AHCI disk to your VM, please use

-drive file=...,if=sata

This should do the trick for x86. On other platforms, you might need to add the ahci host controller using -device.

This patch set is based on work done during the Google Summer of Code. I was mentoring a student, Roland Elek, who wrote most of the AHCI emulation code based on a patch from Chong Qiao. A bunch of other people were also involved, so everybody who I didn't mention - thanks a lot!

v1 -> v2:

- rename IDEExtender to IDEBusOps and make a pointer (kraxel)
- make dma hooks explicit by putting them into ops struct (stefanha)
- use qdev buses (kraxel)
- minor cleanups
- dprintf overhaul
- add reset function

Alex

Alexander Graf (8):
ide: split ide command interpretation off
ide: fix whitespace gap in ide_exec_cmd
ide: add DMA hooks to bus ops
pci: add storage class for sata
pci: add ich7 pci id
ahci: add ahci emulation
ahci: add -drive support
ahci: spawn controller on demand

Roland Elek (2):
ide: add support for ide bus ops
ide: add ncq identify data for ahci sata drives

 Makefile.objs                      |    1 +
 Makefile.target                    |    4 +
 blockdev.c                         |    6 +-
 blockdev.h                         |    1 +
 default-configs/i386-softmmu.mak   |    1 +
 default-configs/x86_64-softmmu.mak |    1 +
 hw/ahci.c                          | 1280 ++++++++++++++++++++++++++++++++++++
 hw/ide/core.c                      |  800 ++++++++++++-----------
 hw/ide/internal.h                  |   34 +-
 hw/pc.c                            |    5 +
 hw/pci.h                           |    1 +
 hw/pci_ids.h                       |    1 +
 qemu-common.h                      |    2 +-
 13 files changed, 1754 insertions(+), 383 deletions(-)
 create mode 100644 hw/ahci.c
#1 lore raw

PATCH 1/10 ide: split ide command interpretation off

The ATA command interpretation code can be used for PATA and SATA interfaces alike. So let's split it out into a separate function.

---
 hw/ide/core.c     |   20 ++++++++++++++------
 hw/ide/internal.h |    2 ++
 2 files changed, 16 insertions(+), 6 deletions(-)
hw/ide/core.c +14 -6
index 484e0ca..ee551ac 100644
@@ -1790,9 +1790,6 @@ static void ide_clear_hob(IDEBus *bus)
 void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
 {
     IDEBus *bus = opaque;
-    IDEState *s;
-    int n;
-    int lba48 = 0;
 
 #ifdef DEBUG_IDE
     printf("IDE: write addr=0x%x val=0x%02x\n", addr, val);
@@ -1853,17 +1850,29 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
     default:
     case 7:
         /* command */
+        ide_exec_cmd(opaque, val);
+        break;
+    }
+}
+
+
+void ide_exec_cmd(IDEBus *bus, uint32_t val)
+{
+    IDEState *s;
+    int n;
+    int lba48 = 0;
+
 #if defined(DEBUG_IDE)
         printf("ide: CMD=%02x\n", val);
 #endif
         s = idebus_active_if(bus);
         /* ignore commands to non existant slave */
         if (s != bus->ifs && !s->bs)
-            break;
+            return;
 
         /* Only DEVICE RESET is allowed while BSY or/and DRQ are set */
         if ((s->status & (BUSY_STAT|DRQ_STAT)) && val != WIN_DEVICE_RESET)
-            break;
+            return;
 
         switch(val) {
         case WIN_IDENTIFY:
@@ -2354,7 +2363,6 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
             ide_set_irq(s->bus);
             break;
         }
-    }
 }
 
 uint32_t ide_ioport_read(void *opaque, uint32_t addr1)
hw/ide/internal.h +2 -0
index d652e06..e7e1f80 100644
@@ -564,6 +564,8 @@ void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0,
                                     DriveInfo *hd1, qemu_irq irq);
 void ide_init_ioport(IDEBus *bus, int iobase, int iobase2);
 
+void ide_exec_cmd(IDEBus *bus, uint32_t val);
+
 /* hw/ide/qdev.c */
 void ide_bus_new(IDEBus *idebus, DeviceState *dev);
 IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo *drive);
Signature · 1 line
1.6.0.2
#13 lore raw

PATCH 9/10 ahci: add -drive support

In reply to Alexander Graf

We need to be able to spawn new AHCI drives, so let's add AHCI support to the -drive option.

---
 blockdev.c    |    6 +++++-
 blockdev.h    |    1 +
 qemu-common.h |    2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)
blockdev.c +5 -1
index 6cb179a..5ce90cc 100644
@@ -209,6 +209,9 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi, int *fatal_error)
 	} else if (!strcmp(buf, "xen")) {
 	    type = IF_XEN;
             max_devs = 0;
+        } else if (!strcmp(buf, "sata")) {
+            type = IF_SATA;
+            max_devs = MAX_SATA_DEVS;
 	} else if (!strcmp(buf, "none")) {
 	    type = IF_NONE;
             max_devs = 0;
@@ -402,7 +405,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi, int *fatal_error)
     } else {
         /* no id supplied -> create one */
         dinfo->id = qemu_mallocz(32);
-        if (type == IF_IDE || type == IF_SCSI)
+        if (type == IF_IDE || type == IF_SCSI || type == IF_SATA)
             mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd";
         if (max_devs)
             snprintf(dinfo->id, 32, "%s%i%s%i",
@@ -427,6 +430,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi, int *fatal_error)
     case IF_IDE:
     case IF_SCSI:
     case IF_XEN:
+    case IF_SATA:
     case IF_NONE:
         switch(media) {
 	case MEDIA_DISK:
blockdev.h +1 -0
index 653affc..f50a15e 100644
@@ -33,6 +33,7 @@ struct DriveInfo {
 
 #define MAX_IDE_DEVS	2
 #define MAX_SCSI_DEVS	7
+#define MAX_SATA_DEVS   4
 
 DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit);
 int drive_get_max_bus(BlockInterfaceType type);
qemu-common.h +1 -1
index b3957f1..ae1cfca 100644
@@ -257,7 +257,7 @@ typedef uint64_t pcibus_t;
 typedef enum {
     IF_NONE,
     IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN,
-    IF_COUNT
+    IF_SATA, IF_COUNT
 } BlockInterfaceType;
 
 void cpu_exec_init_all(unsigned long tb_size);
Signature · 1 line
1.6.0.2
#3 lore raw

PATCH 3/10 ide: add support for ide bus ops

In reply to Alexander Graf

From: Roland Elek <[email protected]>

We need to hook into some of the core IDE functionality for AHCI. To do that, the easiest way is to make explicit functions calls be implicit through a function call struct.

---

v1 -> v2:

- rename IDEExtender to IDEBusOps and make a pointer (kraxel)

---
 hw/ide/core.c     |   36 +++++++++++++++++++++++++++++++++++-
 hw/ide/internal.h |   26 +++++++++++++++++++-------
 2 files changed, 54 insertions(+), 8 deletions(-)
hw/ide/core.c +35 -1
index 1849069..c8d7810 100644
@@ -67,6 +67,8 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret);
 static int ide_handle_rw_error(IDEState *s, int error, int op);
 static void ide_flush_cache(IDEState *s);
 
+static void pata_dma_start(IDEState *s, BlockDriverCompletionFunc *dma_cb);
+
 static void padstr(char *str, const char *src, int len)
 {
     int i, v;
@@ -325,6 +327,12 @@ static inline void ide_dma_submit_check(IDEState *s,
 static void ide_transfer_start(IDEState *s, uint8_t *buf, int size,
                                EndTransferFunc *end_transfer_func)
 {
+    s->bus->ops->transfer_start_fn(s,buf,size,end_transfer_func);
+}
+
+static void pata_transfer_start(IDEState *s, uint8_t *buf, int size,
+                               EndTransferFunc *end_transfer_func)
+{
     s->end_transfer_func = end_transfer_func;
     s->data_ptr = buf;
     s->data_end = buf + size;
@@ -2580,6 +2588,18 @@ static void ide_dummy_transfer_stop(IDEState *s)
     s->io_buffer[3] = 0xff;
 }
 
+static void pata_set_irq(IDEBus *bus)
+{
+    BMDMAState *bm = bus->bmdma;
+
+    if (!(bus->cmd & IDE_CMD_DISABLE_IRQ)) {
+        if (bm) {
+            bm->status |= BM_STATUS_INT;
+        }
+        qemu_irq_raise(bus->irq);
+    }
+}
+
 static void ide_reset(IDEState *s)
 {
 #ifdef DEBUG_IDE
@@ -2716,6 +2736,12 @@ static void ide_init1(IDEBus *bus, int unit)
                                            ide_sector_write_timer_cb, s);
 }
 
+static IDEBusOps ide_bus_ops = {
+    .transfer_start_fn = pata_transfer_start,
+    .irq_set_fn = pata_set_irq,
+    .dma_start_fn = pata_dma_start,
+};
+
 void ide_init2(IDEBus *bus, qemu_irq irq)
 {
     int i;
@@ -2725,6 +2751,7 @@ void ide_init2(IDEBus *bus, qemu_irq irq)
         ide_reset(&bus->ifs[i]);
     }
     bus->irq = irq;
+    bus->ops = &ide_bus_ops;
 }
 
 /* TODO convert users to qdev and remove */
@@ -2748,6 +2775,7 @@ void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0,
         }
     }
     bus->irq = irq;
+    bus->ops = &ide_bus_ops;
 }
 
 void ide_init_ioport(IDEBus *bus, int iobase, int iobase2)
@@ -2919,9 +2947,10 @@ const VMStateDescription vmstate_ide_bus = {
 /***********************************************************/
 /* PCI IDE definitions */
 
-static void ide_dma_start(IDEState *s, BlockDriverCompletionFunc *dma_cb)
+static void pata_dma_start(IDEState *s, BlockDriverCompletionFunc *dma_cb)
 {
     BMDMAState *bm = s->bus->bmdma;
+
     if(!bm)
         return;
     bm->unit = s->unit;
@@ -2936,6 +2965,11 @@ static void ide_dma_start(IDEState *s, BlockDriverCompletionFunc *dma_cb)
     }
 }
 
+static void ide_dma_start(IDEState *s, BlockDriverCompletionFunc *dma_cb)
+{
+    s->bus->ops->dma_start_fn(s,dma_cb);
+}
+
 static void ide_dma_restart(IDEState *s, int is_read)
 {
     BMDMAState *bm = s->bus->bmdma;
hw/ide/internal.h +19 -7
index e7e1f80..ee7e13e 100644
@@ -20,6 +20,7 @@ typedef struct IDEDevice IDEDevice;
 typedef struct IDEDeviceInfo IDEDeviceInfo;
 typedef struct IDEState IDEState;
 typedef struct BMDMAState BMDMAState;
+typedef struct IDEBusOps IDEBusOps;
 
 /* Bits of HD_STATUS */
 #define ERR_STAT		0x01
@@ -366,6 +367,14 @@ typedef enum { IDE_HD, IDE_CD, IDE_CFATA } IDEDriveKind;
 
 typedef void EndTransferFunc(IDEState *);
 
+
+typedef void TransferStartFunc(IDEState *,
+                             uint8_t *,
+                             int,
+                             EndTransferFunc *);
+typedef void IRQSetFunc(IDEBus *);
+typedef void DMAStartFunc(IDEState *, BlockDriverCompletionFunc *);
+
 /* NOTE: IDEState represents in fact one drive */
 struct IDEState {
     IDEBus *bus;
@@ -442,12 +451,21 @@ struct IDEState {
     uint8_t *smart_selftest_data;
 };
 
+/* This struct represents a device that uses an IDE bus, but requires
+ * modifications to how it works. An example is AHCI. */
+struct IDEBusOps {
+    TransferStartFunc *transfer_start_fn;
+    IRQSetFunc *irq_set_fn;
+    DMAStartFunc *dma_start_fn;
+};
+
 struct IDEBus {
     BusState qbus;
     IDEDevice *master;
     IDEDevice *slave;
     BMDMAState *bmdma;
     IDEState ifs[2];
+    IDEBusOps *ops;
     uint8_t unit;
     uint8_t cmd;
     qemu_irq irq;
@@ -512,13 +530,7 @@ static inline IDEState *bmdma_active_if(BMDMAState *bmdma)
 
 static inline void ide_set_irq(IDEBus *bus)
 {
-    BMDMAState *bm = bus->bmdma;
-    if (!(bus->cmd & IDE_CMD_DISABLE_IRQ)) {
-        if (bm) {
-            bm->status |= BM_STATUS_INT;
-        }
-        qemu_irq_raise(bus->irq);
-    }
+    bus->ops->irq_set_fn(bus);
 }
 
 /* hw/ide/core.c */
Signature · 1 line
1.6.0.2
#4 lore raw

PATCH 4/10 ide: add DMA hooks to bus ops

In reply to Alexander Graf

For DMA operations, we need to hook into even more IDE functionality.

This patch adds the respective hooking points, allowing us to handle SG lists ourselves in the AHCI code.

---

v1 -> v2:

- make dma hooks explicit by putting them into ops struct (stefanha)

---
 hw/ide/core.c     |    9 ++++++---
 hw/ide/internal.h |    4 ++++
 2 files changed, 10 insertions(+), 3 deletions(-)
hw/ide/core.c +6 -3
index c8d7810..04190d2 100644
@@ -607,7 +607,7 @@ static void ide_read_dma_cb(void *opaque, int ret)
     n = s->nsector;
     s->io_buffer_index = 0;
     s->io_buffer_size = n * 512;
-    if (dma_buf_prepare(bm, 1) == 0)
+    if (s->bus->ops->dma_prepare_fn(bm, 1) == 0)
         goto eot;
 #ifdef DEBUG_AIO
     printf("aio_read: sector_num=%" PRId64 " n=%d\n", sector_num, n);
@@ -752,7 +752,7 @@ static void ide_write_dma_cb(void *opaque, int ret)
     n = s->nsector;
     s->io_buffer_size = n * 512;
     /* launch next transfer */
-    if (dma_buf_prepare(bm, 0) == 0)
+    if (s->bus->ops->dma_prepare_fn(bm, 0) == 0)
         goto eot;
 #ifdef DEBUG_AIO
     printf("aio_write: sector_num=%" PRId64 " n=%d\n", sector_num, n);
@@ -1060,7 +1060,7 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret)
 	    s->lba += n;
 	}
         s->packet_transfer_size -= s->io_buffer_size;
-        if (dma_buf_rw(bm, 1) == 0)
+        if (s->bus->ops->dma_rw_fn(bm, 1) == 0)
             goto eot;
     }
 
@@ -2715,6 +2715,7 @@ int ide_init_drive(IDEState *s, BlockDriverState *bs,
     } else {
         pstrcpy(s->version, sizeof(s->version), QEMU_VERSION);
     }
+
     ide_reset(s);
     bdrv_set_removable(bs, s->drive_kind == IDE_CD);
     return 0;
@@ -2740,6 +2741,8 @@ static IDEBusOps ide_bus_ops = {
     .transfer_start_fn = pata_transfer_start,
     .irq_set_fn = pata_set_irq,
     .dma_start_fn = pata_dma_start,
+    .dma_prepare_fn = dma_buf_prepare,
+    .dma_rw_fn = dma_buf_rw,
 };
 
 void ide_init2(IDEBus *bus, qemu_irq irq)
hw/ide/internal.h +4 -0
index ee7e13e..4bee636 100644
@@ -374,6 +374,8 @@ typedef void TransferStartFunc(IDEState *,
                              EndTransferFunc *);
 typedef void IRQSetFunc(IDEBus *);
 typedef void DMAStartFunc(IDEState *, BlockDriverCompletionFunc *);
+typedef int DMAPrepareFunc(BMDMAState *, int);
+typedef int DMARWFunc(BMDMAState *, int);
 
 /* NOTE: IDEState represents in fact one drive */
 struct IDEState {
@@ -457,6 +459,8 @@ struct IDEBusOps {
     TransferStartFunc *transfer_start_fn;
     IRQSetFunc *irq_set_fn;
     DMAStartFunc *dma_start_fn;
+    DMAPrepareFunc *dma_prepare_fn;
+    DMARWFunc *dma_rw_fn;
 };
 
 struct IDEBus {
Signature · 1 line
1.6.0.2
#5 lore raw

PATCH 5/10 ide: add ncq identify data for ahci sata drives

In reply to Alexander Graf

From: Roland Elek <[email protected]>

I modified ide_identify() to include the zero-based queue length value in word 75, and set bit 8 in word 76 to signal NCQ support in the identify data for AHCI SATA drives.

---
 hw/ide/core.c     |    7 +++++++
 hw/ide/internal.h |    2 ++
 2 files changed, 9 insertions(+), 0 deletions(-)
hw/ide/core.c +7 -0
index 04190d2..073c038 100644
@@ -147,6 +147,13 @@ static void ide_identify(IDEState *s)
     put_le16(p + 66, 120);
     put_le16(p + 67, 120);
     put_le16(p + 68, 120);
+
+    if (s->ncq_queues) {
+        put_le16(p + 75, s->ncq_queues - 1);
+        /* NCQ supported */
+        put_le16(p + 76, (1 << 8));
+    }
+
     put_le16(p + 80, 0xf0); /* ata3 -> ata6 supported */
     put_le16(p + 81, 0x16); /* conforms to ata5 */
     /* 14=NOP supported, 5=WCACHE supported, 0=SMART supported */
hw/ide/internal.h +2 -0
index 4bee636..1261eea 100644
@@ -451,6 +451,8 @@ struct IDEState {
     int smart_errors;
     uint8_t smart_selftest_count;
     uint8_t *smart_selftest_data;
+    /* AHCI */
+    int ncq_queues;
 };
 
 /* This struct represents a device that uses an IDE bus, but requires
Signature · 1 line
1.6.0.2
#6 lore raw

PATCH 6/10 pci: add storage class for sata

In reply to Alexander Graf

This patch adds the storage sata class id.

---
 hw/pci_ids.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
hw/pci_ids.h +1 -0
index 82cba7e..ea3418c 100644
@@ -15,6 +15,7 @@
 
 #define PCI_CLASS_STORAGE_SCSI           0x0100
 #define PCI_CLASS_STORAGE_IDE            0x0101
+#define PCI_CLASS_STORAGE_SATA           0x0106
 #define PCI_CLASS_STORAGE_OTHER          0x0180
 
 #define PCI_CLASS_NETWORK_ETHERNET       0x0200
Signature · 1 line
1.6.0.2
#14 lore raw

PATCH 10/10 ahci: spawn controller on demand

In reply to Alexander Graf

When we add a device using -drive to the guest, we also need to create a new SATA bus to handle the device. This patch does it the same way SCSI does it today.

---
 hw/pc.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
hw/pc.c +5 -0
index 69b13bf..d0320c4 100644
@@ -1075,4 +1075,9 @@ void pc_pci_device_init(PCIBus *pci_bus)
     for (bus = 0; bus <= max_bus; bus++) {
         pci_create_simple(pci_bus, -1, "lsi53c895a");
     }
+
+    max_bus = drive_get_max_bus(IF_SATA);
+    for (bus = 0; bus <= max_bus; bus++) {
+        pci_create_simple(pci_bus, -1, "ahci");
+    }
 }
Signature · 1 line
1.6.0.2
#2 lore raw

PATCH 2/10 ide: fix whitespace gap in ide_exec_cmd

In reply to Alexander Graf

Now that we have the function split out, we have to reindent it. In order to increase the readability of the actual functional change, this is split out.

---
 hw/ide/core.c |  734 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 367 insertions(+), 367 deletions(-)
hw/ide/core.c +367 -367
index ee551ac..1849069 100644
@@ -1863,423 +1863,423 @@ void ide_exec_cmd(IDEBus *bus, uint32_t val)
     int lba48 = 0;
 
 #if defined(DEBUG_IDE)
-        printf("ide: CMD=%02x\n", val);
+    printf("ide: CMD=%02x\n", val);
 #endif
-        s = idebus_active_if(bus);
-        /* ignore commands to non existant slave */
-        if (s != bus->ifs && !s->bs)
-            return;
+    s = idebus_active_if(bus);
+    /* ignore commands to non existant slave */
+    if (s != bus->ifs && !s->bs)
+        return;
 
-        /* Only DEVICE RESET is allowed while BSY or/and DRQ are set */
-        if ((s->status & (BUSY_STAT|DRQ_STAT)) && val != WIN_DEVICE_RESET)
-            return;
+    /* Only DEVICE RESET is allowed while BSY or/and DRQ are set */
+    if ((s->status & (BUSY_STAT|DRQ_STAT)) && val != WIN_DEVICE_RESET)
+        return;
 
-        switch(val) {
-        case WIN_IDENTIFY:
-            if (s->bs && s->drive_kind != IDE_CD) {
-                if (s->drive_kind != IDE_CFATA)
-                    ide_identify(s);
-                else
-                    ide_cfata_identify(s);
-                s->status = READY_STAT | SEEK_STAT;
-                ide_transfer_start(s, s->io_buffer, 512, ide_transfer_stop);
-            } else {
-                if (s->drive_kind == IDE_CD) {
-                    ide_set_signature(s);
-                }
-                ide_abort_command(s);
-            }
-            ide_set_irq(s->bus);
-            break;
-        case WIN_SPECIFY:
-        case WIN_RECAL:
-            s->error = 0;
+    switch(val) {
+    case WIN_IDENTIFY:
+        if (s->bs && s->drive_kind != IDE_CD) {
+            if (s->drive_kind != IDE_CFATA)
+                ide_identify(s);
+            else
+                ide_cfata_identify(s);
             s->status = READY_STAT | SEEK_STAT;
-            ide_set_irq(s->bus);
-            break;
-        case WIN_SETMULT:
-            if (s->drive_kind == IDE_CFATA && s->nsector == 0) {
-                /* Disable Read and Write Multiple */
-                s->mult_sectors = 0;
-                s->status = READY_STAT | SEEK_STAT;
-            } else if ((s->nsector & 0xff) != 0 &&
-                ((s->nsector & 0xff) > MAX_MULT_SECTORS ||
-                 (s->nsector & (s->nsector - 1)) != 0)) {
-                ide_abort_command(s);
-            } else {
-                s->mult_sectors = s->nsector & 0xff;
-                s->status = READY_STAT | SEEK_STAT;
+            ide_transfer_start(s, s->io_buffer, 512, ide_transfer_stop);
+        } else {
+            if (s->drive_kind == IDE_CD) {
+                ide_set_signature(s);
             }
-            ide_set_irq(s->bus);
-            break;
-        case WIN_VERIFY_EXT:
-	    lba48 = 1;
-        case WIN_VERIFY:
-        case WIN_VERIFY_ONCE:
-            /* do sector number check ? */
-	    ide_cmd_lba48_transform(s, lba48);
+            ide_abort_command(s);
+        }
+        ide_set_irq(s->bus);
+        break;
+    case WIN_SPECIFY:
+    case WIN_RECAL:
+        s->error = 0;
+        s->status = READY_STAT | SEEK_STAT;
+        ide_set_irq(s->bus);
+        break;
+    case WIN_SETMULT:
+        if (s->drive_kind == IDE_CFATA && s->nsector == 0) {
+            /* Disable Read and Write Multiple */
+            s->mult_sectors = 0;
             s->status = READY_STAT | SEEK_STAT;
-            ide_set_irq(s->bus);
-            break;
+        } else if ((s->nsector & 0xff) != 0 &&
+            ((s->nsector & 0xff) > MAX_MULT_SECTORS ||
+             (s->nsector & (s->nsector - 1)) != 0)) {
+            ide_abort_command(s);
+        } else {
+            s->mult_sectors = s->nsector & 0xff;
+            s->status = READY_STAT | SEEK_STAT;
+        }
+        ide_set_irq(s->bus);
+        break;
+    case WIN_VERIFY_EXT:
+	lba48 = 1;
+    case WIN_VERIFY:
+    case WIN_VERIFY_ONCE:
+        /* do sector number check ? */
+	ide_cmd_lba48_transform(s, lba48);
+        s->status = READY_STAT | SEEK_STAT;
+        ide_set_irq(s->bus);
+        break;
 	case WIN_READ_EXT:
-	    lba48 = 1;
-        case WIN_READ:
-        case WIN_READ_ONCE:
-            if (!s->bs)
-                goto abort_cmd;
-	    ide_cmd_lba48_transform(s, lba48);
-            s->req_nb_sectors = 1;
-            ide_sector_read(s);
-            break;
+	lba48 = 1;
+    case WIN_READ:
+    case WIN_READ_ONCE:
+        if (!s->bs)
+            goto abort_cmd;
+	ide_cmd_lba48_transform(s, lba48);
+        s->req_nb_sectors = 1;
+        ide_sector_read(s);
+        break;
 	case WIN_WRITE_EXT:
-	    lba48 = 1;
-        case WIN_WRITE:
-        case WIN_WRITE_ONCE:
-        case CFA_WRITE_SECT_WO_ERASE:
-        case WIN_WRITE_VERIFY:
-	    ide_cmd_lba48_transform(s, lba48);
-            s->error = 0;
-            s->status = SEEK_STAT | READY_STAT;
-            s->req_nb_sectors = 1;
-            ide_transfer_start(s, s->io_buffer, 512, ide_sector_write);
-            s->media_changed = 1;
-            break;
+	lba48 = 1;
+    case WIN_WRITE:
+    case WIN_WRITE_ONCE:
+    case CFA_WRITE_SECT_WO_ERASE:
+    case WIN_WRITE_VERIFY:
+	ide_cmd_lba48_transform(s, lba48);
+        s->error = 0;
+        s->status = SEEK_STAT | READY_STAT;
+        s->req_nb_sectors = 1;
+        ide_transfer_start(s, s->io_buffer, 512, ide_sector_write);
+        s->media_changed = 1;
+        break;
 	case WIN_MULTREAD_EXT:
-	    lba48 = 1;
-        case WIN_MULTREAD:
-            if (!s->mult_sectors)
-                goto abort_cmd;
-	    ide_cmd_lba48_transform(s, lba48);
-            s->req_nb_sectors = s->mult_sectors;
-            ide_sector_read(s);
-            break;
-        case WIN_MULTWRITE_EXT:
-	    lba48 = 1;
-        case WIN_MULTWRITE:
-        case CFA_WRITE_MULTI_WO_ERASE:
-            if (!s->mult_sectors)
-                goto abort_cmd;
-	    ide_cmd_lba48_transform(s, lba48);
-            s->error = 0;
-            s->status = SEEK_STAT | READY_STAT;
-            s->req_nb_sectors = s->mult_sectors;
-            n = s->nsector;
-            if (n > s->req_nb_sectors)
-                n = s->req_nb_sectors;
-            ide_transfer_start(s, s->io_buffer, 512 * n, ide_sector_write);
-            s->media_changed = 1;
-            break;
+	lba48 = 1;
+    case WIN_MULTREAD:
+        if (!s->mult_sectors)
+            goto abort_cmd;
+	ide_cmd_lba48_transform(s, lba48);
+        s->req_nb_sectors = s->mult_sectors;
+        ide_sector_read(s);
+        break;
+    case WIN_MULTWRITE_EXT:
+	lba48 = 1;
+    case WIN_MULTWRITE:
+    case CFA_WRITE_MULTI_WO_ERASE:
+        if (!s->mult_sectors)
+            goto abort_cmd;
+	ide_cmd_lba48_transform(s, lba48);
+        s->error = 0;
+        s->status = SEEK_STAT | READY_STAT;
+        s->req_nb_sectors = s->mult_sectors;
+        n = s->nsector;
+        if (n > s->req_nb_sectors)
+            n = s->req_nb_sectors;
+        ide_transfer_start(s, s->io_buffer, 512 * n, ide_sector_write);
+        s->media_changed = 1;
+        break;
 	case WIN_READDMA_EXT:
-	    lba48 = 1;
-        case WIN_READDMA:
-        case WIN_READDMA_ONCE:
-            if (!s->bs)
-                goto abort_cmd;
-	    ide_cmd_lba48_transform(s, lba48);
-            ide_sector_read_dma(s);
-            break;
+	lba48 = 1;
+    case WIN_READDMA:
+    case WIN_READDMA_ONCE:
+        if (!s->bs)
+            goto abort_cmd;
+	ide_cmd_lba48_transform(s, lba48);
+        ide_sector_read_dma(s);
+        break;
 	case WIN_WRITEDMA_EXT:
-	    lba48 = 1;
-        case WIN_WRITEDMA:
-        case WIN_WRITEDMA_ONCE:
-            if (!s->bs)
-                goto abort_cmd;
-	    ide_cmd_lba48_transform(s, lba48);
-            ide_sector_write_dma(s);
-            s->media_changed = 1;
-            break;
-        case WIN_READ_NATIVE_MAX_EXT:
-	    lba48 = 1;
-        case WIN_READ_NATIVE_MAX:
-	    ide_cmd_lba48_transform(s, lba48);
-            ide_set_sector(s, s->nb_sectors - 1);
-            s->status = READY_STAT | SEEK_STAT;
-            ide_set_irq(s->bus);
-            break;
-        case WIN_CHECKPOWERMODE1:
-        case WIN_CHECKPOWERMODE2:
-            s->nsector = 0xff; /* device active or idle */
+	lba48 = 1;
+    case WIN_WRITEDMA:
+    case WIN_WRITEDMA_ONCE:
+        if (!s->bs)
+            goto abort_cmd;
+	ide_cmd_lba48_transform(s, lba48);
+        ide_sector_write_dma(s);
+        s->media_changed = 1;
+        break;
+    case WIN_READ_NATIVE_MAX_EXT:
+	lba48 = 1;
+    case WIN_READ_NATIVE_MAX:
+	ide_cmd_lba48_transform(s, lba48);
+        ide_set_sector(s, s->nb_sectors - 1);
+        s->status = READY_STAT | SEEK_STAT;
+        ide_set_irq(s->bus);
+        break;
+    case WIN_CHECKPOWERMODE1:
+    case WIN_CHECKPOWERMODE2:
+        s->nsector = 0xff; /* device active or idle */
+        s->status = READY_STAT | SEEK_STAT;
+        ide_set_irq(s->bus);
+        break;
+    case WIN_SETFEATURES:
+        if (!s->bs)
+            goto abort_cmd;
+        /* XXX: valid for CDROM ? */
+        switch(s->feature) {
+        case 0xcc: /* reverting to power-on defaults enable */
+        case 0x66: /* reverting to power-on defaults disable */
+        case 0x02: /* write cache enable */
+        case 0x82: /* write cache disable */
+        case 0xaa: /* read look-ahead enable */
+        case 0x55: /* read look-ahead disable */
+        case 0x05: /* set advanced power management mode */
+        case 0x85: /* disable advanced power management mode */
+        case 0x69: /* NOP */
+        case 0x67: /* NOP */
+        case 0x96: /* NOP */
+        case 0x9a: /* NOP */
+        case 0x42: /* enable Automatic Acoustic Mode */
+        case 0xc2: /* disable Automatic Acoustic Mode */
             s->status = READY_STAT | SEEK_STAT;
             ide_set_irq(s->bus);
             break;
-        case WIN_SETFEATURES:
-            if (!s->bs)
-                goto abort_cmd;
-            /* XXX: valid for CDROM ? */
-            switch(s->feature) {
-            case 0xcc: /* reverting to power-on defaults enable */
-            case 0x66: /* reverting to power-on defaults disable */
-            case 0x02: /* write cache enable */
-            case 0x82: /* write cache disable */
-            case 0xaa: /* read look-ahead enable */
-            case 0x55: /* read look-ahead disable */
-            case 0x05: /* set advanced power management mode */
-            case 0x85: /* disable advanced power management mode */
-            case 0x69: /* NOP */
-            case 0x67: /* NOP */
-            case 0x96: /* NOP */
-            case 0x9a: /* NOP */
-            case 0x42: /* enable Automatic Acoustic Mode */
-            case 0xc2: /* disable Automatic Acoustic Mode */
-                s->status = READY_STAT | SEEK_STAT;
-                ide_set_irq(s->bus);
-                break;
-            case 0x03: { /* set transfer mode */
+        case 0x03: { /* set transfer mode */
 		uint8_t val = s->nsector & 0x07;
-                uint16_t *identify_data = (uint16_t *)s->identify_data;
+            uint16_t *identify_data = (uint16_t *)s->identify_data;
 
 		switch (s->nsector >> 3) {
-		    case 0x00: /* pio default */
-		    case 0x01: /* pio mode */
+		case 0x00: /* pio default */
+		case 0x01: /* pio mode */
 			put_le16(identify_data + 62,0x07);
 			put_le16(identify_data + 63,0x07);
 			put_le16(identify_data + 88,0x3f);
 			break;
-                    case 0x02: /* sigle word dma mode*/
+                case 0x02: /* sigle word dma mode*/
 			put_le16(identify_data + 62,0x07 | (1 << (val + 8)));
 			put_le16(identify_data + 63,0x07);
 			put_le16(identify_data + 88,0x3f);
 			break;
-		    case 0x04: /* mdma mode */
+		case 0x04: /* mdma mode */
 			put_le16(identify_data + 62,0x07);
 			put_le16(identify_data + 63,0x07 | (1 << (val + 8)));
 			put_le16(identify_data + 88,0x3f);
 			break;
-		    case 0x08: /* udma mode */
+		case 0x08: /* udma mode */
 			put_le16(identify_data + 62,0x07);
 			put_le16(identify_data + 63,0x07);
 			put_le16(identify_data + 88,0x3f | (1 << (val + 8)));
 			break;
-		    default:
+		default:
 			goto abort_cmd;
 		}
-                s->status = READY_STAT | SEEK_STAT;
-                ide_set_irq(s->bus);
-                break;
-	    }
-            default:
-                goto abort_cmd;
-            }
-            break;
-        case WIN_FLUSH_CACHE:
-        case WIN_FLUSH_CACHE_EXT:
-            ide_flush_cache(s);
-            break;
-        case WIN_STANDBY:
-        case WIN_STANDBY2:
-        case WIN_STANDBYNOW1:
-        case WIN_STANDBYNOW2:
-        case WIN_IDLEIMMEDIATE:
-        case CFA_IDLEIMMEDIATE:
-        case WIN_SETIDLE1:
-        case WIN_SETIDLE2:
-        case WIN_SLEEPNOW1:
-        case WIN_SLEEPNOW2:
-            s->status = READY_STAT;
-            ide_set_irq(s->bus);
-            break;
-        case WIN_SEEK:
-            if(s->drive_kind == IDE_CD)
-                goto abort_cmd;
-            /* XXX: Check that seek is within bounds */
             s->status = READY_STAT | SEEK_STAT;
             ide_set_irq(s->bus);
             break;
-            /* ATAPI commands */
-        case WIN_PIDENTIFY:
-            if (s->drive_kind == IDE_CD) {
-                ide_atapi_identify(s);
-                s->status = READY_STAT | SEEK_STAT;
-                ide_transfer_start(s, s->io_buffer, 512, ide_transfer_stop);
-            } else {
-                ide_abort_command(s);
-            }
-            ide_set_irq(s->bus);
-            break;
-        case WIN_DIAGNOSE:
-            ide_set_signature(s);
-            if (s->drive_kind == IDE_CD)
-                s->status = 0; /* ATAPI spec (v6) section 9.10 defines packet
-                                * devices to return a clear status register
-                                * with READY_STAT *not* set. */
-            else
-                s->status = READY_STAT | SEEK_STAT;
-            s->error = 0x01; /* Device 0 passed, Device 1 passed or not
-                              * present. 
-                              */
-            ide_set_irq(s->bus);
-            break;
-        case WIN_SRST:
-            if (s->drive_kind != IDE_CD)
-                goto abort_cmd;
-            ide_set_signature(s);
-            s->status = 0x00; /* NOTE: READY is _not_ set */
-            s->error = 0x01;
-            break;
-        case WIN_PACKETCMD:
-            if (s->drive_kind != IDE_CD)
-                goto abort_cmd;
-            /* overlapping commands not supported */
-            if (s->feature & 0x02)
-                goto abort_cmd;
+	}
+        default:
+            goto abort_cmd;
+        }
+        break;
+    case WIN_FLUSH_CACHE:
+    case WIN_FLUSH_CACHE_EXT:
+        ide_flush_cache(s);
+        break;
+    case WIN_STANDBY:
+    case WIN_STANDBY2:
+    case WIN_STANDBYNOW1:
+    case WIN_STANDBYNOW2:
+    case WIN_IDLEIMMEDIATE:
+    case CFA_IDLEIMMEDIATE:
+    case WIN_SETIDLE1:
+    case WIN_SETIDLE2:
+    case WIN_SLEEPNOW1:
+    case WIN_SLEEPNOW2:
+        s->status = READY_STAT;
+        ide_set_irq(s->bus);
+        break;
+    case WIN_SEEK:
+        if(s->drive_kind == IDE_CD)
+            goto abort_cmd;
+        /* XXX: Check that seek is within bounds */
+        s->status = READY_STAT | SEEK_STAT;
+        ide_set_irq(s->bus);
+        break;
+        /* ATAPI commands */
+    case WIN_PIDENTIFY:
+        if (s->drive_kind == IDE_CD) {
+            ide_atapi_identify(s);
             s->status = READY_STAT | SEEK_STAT;
-            s->atapi_dma = s->feature & 1;
-            s->nsector = 1;
-            ide_transfer_start(s, s->io_buffer, ATAPI_PACKET_SIZE,
-                               ide_atapi_cmd);
-            break;
-        /* CF-ATA commands */
-        case CFA_REQ_EXT_ERROR_CODE:
-            if (s->drive_kind != IDE_CFATA)
-                goto abort_cmd;
-            s->error = 0x09;    /* miscellaneous error */
+            ide_transfer_start(s, s->io_buffer, 512, ide_transfer_stop);
+        } else {
+            ide_abort_command(s);
+        }
+        ide_set_irq(s->bus);
+        break;
+    case WIN_DIAGNOSE:
+        ide_set_signature(s);
+        if (s->drive_kind == IDE_CD)
+            s->status = 0; /* ATAPI spec (v6) section 9.10 defines packet
+                            * devices to return a clear status register
+                            * with READY_STAT *not* set. */
+        else
             s->status = READY_STAT | SEEK_STAT;
-            ide_set_irq(s->bus);
+        s->error = 0x01; /* Device 0 passed, Device 1 passed or not
+                          * present. 
+                          */
+        ide_set_irq(s->bus);
+        break;
+    case WIN_SRST:
+        if (s->drive_kind != IDE_CD)
+            goto abort_cmd;
+        ide_set_signature(s);
+        s->status = 0x00; /* NOTE: READY is _not_ set */
+        s->error = 0x01;
+        break;
+    case WIN_PACKETCMD:
+        if (s->drive_kind != IDE_CD)
+            goto abort_cmd;
+        /* overlapping commands not supported */
+        if (s->feature & 0x02)
+            goto abort_cmd;
+        s->status = READY_STAT | SEEK_STAT;
+        s->atapi_dma = s->feature & 1;
+        s->nsector = 1;
+        ide_transfer_start(s, s->io_buffer, ATAPI_PACKET_SIZE,
+                           ide_atapi_cmd);
+        break;
+    /* CF-ATA commands */
+    case CFA_REQ_EXT_ERROR_CODE:
+        if (s->drive_kind != IDE_CFATA)
+            goto abort_cmd;
+        s->error = 0x09;    /* miscellaneous error */
+        s->status = READY_STAT | SEEK_STAT;
+        ide_set_irq(s->bus);
+        break;
+    case CFA_ERASE_SECTORS:
+    case CFA_WEAR_LEVEL:
+        if (s->drive_kind != IDE_CFATA)
+            goto abort_cmd;
+        if (val == CFA_WEAR_LEVEL)
+            s->nsector = 0;
+        if (val == CFA_ERASE_SECTORS)
+            s->media_changed = 1;
+        s->error = 0x00;
+        s->status = READY_STAT | SEEK_STAT;
+        ide_set_irq(s->bus);
+        break;
+    case CFA_TRANSLATE_SECTOR:
+        if (s->drive_kind != IDE_CFATA)
+            goto abort_cmd;
+        s->error = 0x00;
+        s->status = READY_STAT | SEEK_STAT;
+        memset(s->io_buffer, 0, 0x200);
+        s->io_buffer[0x00] = s->hcyl;			/* Cyl MSB */
+        s->io_buffer[0x01] = s->lcyl;			/* Cyl LSB */
+        s->io_buffer[0x02] = s->select;			/* Head */
+        s->io_buffer[0x03] = s->sector;			/* Sector */
+        s->io_buffer[0x04] = ide_get_sector(s) >> 16;	/* LBA MSB */
+        s->io_buffer[0x05] = ide_get_sector(s) >> 8;	/* LBA */
+        s->io_buffer[0x06] = ide_get_sector(s) >> 0;	/* LBA LSB */
+        s->io_buffer[0x13] = 0x00;				/* Erase flag */
+        s->io_buffer[0x18] = 0x00;				/* Hot count */
+        s->io_buffer[0x19] = 0x00;				/* Hot count */
+        s->io_buffer[0x1a] = 0x01;				/* Hot count */
+        ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
+        ide_set_irq(s->bus);
+        break;
+    case CFA_ACCESS_METADATA_STORAGE:
+        if (s->drive_kind != IDE_CFATA)
+            goto abort_cmd;
+        switch (s->feature) {
+        case 0x02:	/* Inquiry Metadata Storage */
+            ide_cfata_metadata_inquiry(s);
             break;
-        case CFA_ERASE_SECTORS:
-        case CFA_WEAR_LEVEL:
-            if (s->drive_kind != IDE_CFATA)
-                goto abort_cmd;
-            if (val == CFA_WEAR_LEVEL)
-                s->nsector = 0;
-            if (val == CFA_ERASE_SECTORS)
-                s->media_changed = 1;
-            s->error = 0x00;
-            s->status = READY_STAT | SEEK_STAT;
-            ide_set_irq(s->bus);
+        case 0x03:	/* Read Metadata Storage */
+            ide_cfata_metadata_read(s);
             break;
-        case CFA_TRANSLATE_SECTOR:
-            if (s->drive_kind != IDE_CFATA)
-                goto abort_cmd;
-            s->error = 0x00;
-            s->status = READY_STAT | SEEK_STAT;
-            memset(s->io_buffer, 0, 0x200);
-            s->io_buffer[0x00] = s->hcyl;			/* Cyl MSB */
-            s->io_buffer[0x01] = s->lcyl;			/* Cyl LSB */
-            s->io_buffer[0x02] = s->select;			/* Head */
-            s->io_buffer[0x03] = s->sector;			/* Sector */
-            s->io_buffer[0x04] = ide_get_sector(s) >> 16;	/* LBA MSB */
-            s->io_buffer[0x05] = ide_get_sector(s) >> 8;	/* LBA */
-            s->io_buffer[0x06] = ide_get_sector(s) >> 0;	/* LBA LSB */
-            s->io_buffer[0x13] = 0x00;				/* Erase flag */
-            s->io_buffer[0x18] = 0x00;				/* Hot count */
-            s->io_buffer[0x19] = 0x00;				/* Hot count */
-            s->io_buffer[0x1a] = 0x01;				/* Hot count */
-            ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
-            ide_set_irq(s->bus);
+        case 0x04:	/* Write Metadata Storage */
+            ide_cfata_metadata_write(s);
             break;
-        case CFA_ACCESS_METADATA_STORAGE:
-            if (s->drive_kind != IDE_CFATA)
-                goto abort_cmd;
-            switch (s->feature) {
-            case 0x02:	/* Inquiry Metadata Storage */
-                ide_cfata_metadata_inquiry(s);
-                break;
-            case 0x03:	/* Read Metadata Storage */
-                ide_cfata_metadata_read(s);
-                break;
-            case 0x04:	/* Write Metadata Storage */
-                ide_cfata_metadata_write(s);
-                break;
-            default:
-                goto abort_cmd;
-            }
-            ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
-            s->status = 0x00; /* NOTE: READY is _not_ set */
-            ide_set_irq(s->bus);
-            break;
-        case IBM_SENSE_CONDITION:
-            if (s->drive_kind != IDE_CFATA)
-                goto abort_cmd;
-            switch (s->feature) {
-            case 0x01:  /* sense temperature in device */
-                s->nsector = 0x50;      /* +20 C */
-                break;
-            default:
-                goto abort_cmd;
-            }
-            s->status = READY_STAT | SEEK_STAT;
-            ide_set_irq(s->bus);
+        default:
+            goto abort_cmd;
+        }
+        ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
+        s->status = 0x00; /* NOTE: READY is _not_ set */
+        ide_set_irq(s->bus);
+        break;
+    case IBM_SENSE_CONDITION:
+        if (s->drive_kind != IDE_CFATA)
+            goto abort_cmd;
+        switch (s->feature) {
+        case 0x01:  /* sense temperature in device */
+            s->nsector = 0x50;      /* +20 C */
             break;
+        default:
+            goto abort_cmd;
+        }
+        s->status = READY_STAT | SEEK_STAT;
+        ide_set_irq(s->bus);
+        break;
 
 	case WIN_SMART:
-	    if (s->drive_kind == IDE_CD)
+	if (s->drive_kind == IDE_CD)
 		goto abort_cmd;
-	    if (s->hcyl != 0xc2 || s->lcyl != 0x4f)
+	if (s->hcyl != 0xc2 || s->lcyl != 0x4f)
 		goto abort_cmd;
-	    if (!s->smart_enabled && s->feature != SMART_ENABLE)
+	if (!s->smart_enabled && s->feature != SMART_ENABLE)
 		goto abort_cmd;
-	    switch (s->feature) {
-	    case SMART_DISABLE:
+	switch (s->feature) {
+	case SMART_DISABLE:
 		s->smart_enabled = 0;
 		s->status = READY_STAT | SEEK_STAT;
 		ide_set_irq(s->bus);
 		break;
-	    case SMART_ENABLE:
+	case SMART_ENABLE:
 		s->smart_enabled = 1;
 		s->status = READY_STAT | SEEK_STAT;
 		ide_set_irq(s->bus);
 		break;
-	    case SMART_ATTR_AUTOSAVE:
+	case SMART_ATTR_AUTOSAVE:
 		switch (s->sector) {
 		case 0x00:
-		    s->smart_autosave = 0;
-		    break;
+		s->smart_autosave = 0;
+		break;
 		case 0xf1:
-		    s->smart_autosave = 1;
-		    break;
+		s->smart_autosave = 1;
+		break;
 		default:
-		    goto abort_cmd;
+		goto abort_cmd;
 		}
 		s->status = READY_STAT | SEEK_STAT;
 		ide_set_irq(s->bus);
 		break;
-	    case SMART_STATUS:
+	case SMART_STATUS:
 		if (!s->smart_errors) {
-		    s->hcyl = 0xc2;
-		    s->lcyl = 0x4f;
+		s->hcyl = 0xc2;
+		s->lcyl = 0x4f;
 		} else {
-		    s->hcyl = 0x2c;
-		    s->lcyl = 0xf4;
+		s->hcyl = 0x2c;
+		s->lcyl = 0xf4;
 		}
 		s->status = READY_STAT | SEEK_STAT;
 		ide_set_irq(s->bus);
 		break;
-	    case SMART_READ_THRESH:
+	case SMART_READ_THRESH:
 		memset(s->io_buffer, 0, 0x200);
 		s->io_buffer[0] = 0x01; /* smart struct version */
 		for (n=0; n<30; n++) {
-		    if (smart_attributes[n][0] == 0)
+		if (smart_attributes[n][0] == 0)
 			break;
-		    s->io_buffer[2+0+(n*12)] = smart_attributes[n][0];
-		    s->io_buffer[2+1+(n*12)] = smart_attributes[n][4];
+		s->io_buffer[2+0+(n*12)] = smart_attributes[n][0];
+		s->io_buffer[2+1+(n*12)] = smart_attributes[n][4];
 		}
 		for (n=0; n<511; n++) /* checksum */
-		    s->io_buffer[511] += s->io_buffer[n];
+		s->io_buffer[511] += s->io_buffer[n];
 		s->io_buffer[511] = 0x100 - s->io_buffer[511];
 		s->status = READY_STAT | SEEK_STAT;
 		ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
 		ide_set_irq(s->bus);
 		break;
-	    case SMART_READ_DATA:
+	case SMART_READ_DATA:
 		memset(s->io_buffer, 0, 0x200);
 		s->io_buffer[0] = 0x01; /* smart struct version */
 		for (n=0; n<30; n++) {
-		    if (smart_attributes[n][0] == 0)
+		if (smart_attributes[n][0] == 0)
 			break;
-		    s->io_buffer[2+0+(n*12)] = smart_attributes[n][0];
-		    s->io_buffer[2+1+(n*12)] = smart_attributes[n][1];
-		    s->io_buffer[2+3+(n*12)] = smart_attributes[n][2];
-		    s->io_buffer[2+4+(n*12)] = smart_attributes[n][3];
+		s->io_buffer[2+0+(n*12)] = smart_attributes[n][0];
+		s->io_buffer[2+1+(n*12)] = smart_attributes[n][1];
+		s->io_buffer[2+3+(n*12)] = smart_attributes[n][2];
+		s->io_buffer[2+4+(n*12)] = smart_attributes[n][3];
 		}
 		s->io_buffer[362] = 0x02 | (s->smart_autosave?0x80:0x00);
 		if (s->smart_selftest_count == 0) {
-		    s->io_buffer[363] = 0;
+		s->io_buffer[363] = 0;
 		} else {
-		    s->io_buffer[363] = 
+		s->io_buffer[363] = 
 			s->smart_selftest_data[3 + 
-					       (s->smart_selftest_count - 1) * 
-					       24];
+					   (s->smart_selftest_count - 1) * 
+					   24];
 		}
 		s->io_buffer[364] = 0x20; 
 		s->io_buffer[365] = 0x01; 
@@ -2293,76 +2293,76 @@ void ide_exec_cmd(IDEBus *bus, uint32_t val)
 		s->io_buffer[374] = 0x01; /* minutes for poll conveyance */
 
 		for (n=0; n<511; n++) 
-		    s->io_buffer[511] += s->io_buffer[n];
+		s->io_buffer[511] += s->io_buffer[n];
 		s->io_buffer[511] = 0x100 - s->io_buffer[511];
 		s->status = READY_STAT | SEEK_STAT;
 		ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
 		ide_set_irq(s->bus);
 		break;
-	    case SMART_READ_LOG:
+	case SMART_READ_LOG:
 		switch (s->sector) {
 		case 0x01: /* summary smart error log */
-		    memset(s->io_buffer, 0, 0x200);
-		    s->io_buffer[0] = 0x01;
-		    s->io_buffer[1] = 0x00; /* no error entries */
-		    s->io_buffer[452] = s->smart_errors & 0xff;
-		    s->io_buffer[453] = (s->smart_errors & 0xff00) >> 8;
+		memset(s->io_buffer, 0, 0x200);
+		s->io_buffer[0] = 0x01;
+		s->io_buffer[1] = 0x00; /* no error entries */
+		s->io_buffer[452] = s->smart_errors & 0xff;
+		s->io_buffer[453] = (s->smart_errors & 0xff00) >> 8;
 
-		    for (n=0; n<511; n++)
+		for (n=0; n<511; n++)
 			s->io_buffer[511] += s->io_buffer[n];
-		    s->io_buffer[511] = 0x100 - s->io_buffer[511];
-		    break;
+		s->io_buffer[511] = 0x100 - s->io_buffer[511];
+		break;
 		case 0x06: /* smart self test log */
-		    memset(s->io_buffer, 0, 0x200);
-		    s->io_buffer[0] = 0x01; 
-		    if (s->smart_selftest_count == 0) {
+		memset(s->io_buffer, 0, 0x200);
+		s->io_buffer[0] = 0x01; 
+		if (s->smart_selftest_count == 0) {
 			s->io_buffer[508] = 0;
-		    } else {
+		} else {
 			s->io_buffer[508] = s->smart_selftest_count;
 			for (n=2; n<506; n++) 
-			    s->io_buffer[n] = s->smart_selftest_data[n];
-		    }		    
-		    for (n=0; n<511; n++)
+			s->io_buffer[n] = s->smart_selftest_data[n];
+		}		    
+		for (n=0; n<511; n++)
 			s->io_buffer[511] += s->io_buffer[n];
-		    s->io_buffer[511] = 0x100 - s->io_buffer[511];
-		    break;
+		s->io_buffer[511] = 0x100 - s->io_buffer[511];
+		break;
 		default:
-		    goto abort_cmd;
+		goto abort_cmd;
 		}
 		s->status = READY_STAT | SEEK_STAT;
 		ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
 		ide_set_irq(s->bus);
 		break;
-	    case SMART_EXECUTE_OFFLINE:
+	case SMART_EXECUTE_OFFLINE:
 		switch (s->sector) {
 		case 0: /* off-line routine */
 		case 1: /* short self test */
 		case 2: /* extended self test */
-		    s->smart_selftest_count++;
-		    if(s->smart_selftest_count > 21)
+		s->smart_selftest_count++;
+		if(s->smart_selftest_count > 21)
 			s->smart_selftest_count = 0;
-		    n = 2 + (s->smart_selftest_count - 1) * 24;
-		    s->smart_selftest_data[n] = s->sector;
-		    s->smart_selftest_data[n+1] = 0x00; /* OK and finished */
-		    s->smart_selftest_data[n+2] = 0x34; /* hour count lsb */
-		    s->smart_selftest_data[n+3] = 0x12; /* hour count msb */
-		    s->status = READY_STAT | SEEK_STAT;
-		    ide_set_irq(s->bus);
-		    break;
+		n = 2 + (s->smart_selftest_count - 1) * 24;
+		s->smart_selftest_data[n] = s->sector;
+		s->smart_selftest_data[n+1] = 0x00; /* OK and finished */
+		s->smart_selftest_data[n+2] = 0x34; /* hour count lsb */
+		s->smart_selftest_data[n+3] = 0x12; /* hour count msb */
+		s->status = READY_STAT | SEEK_STAT;
+		ide_set_irq(s->bus);
+		break;
 		default:
-		    goto abort_cmd;
+		goto abort_cmd;
 		}
 		break;
-	    default:
+	default:
 		goto abort_cmd;
-	    }
-	    break;
-        default:
-        abort_cmd:
-            ide_abort_command(s);
-            ide_set_irq(s->bus);
-            break;
-        }
+	}
+	break;
+    default:
+    abort_cmd:
+        ide_abort_command(s);
+        ide_set_irq(s->bus);
+        break;
+    }
 }
 
 uint32_t ide_ioport_read(void *opaque, uint32_t addr1)
Signature · 1 line
1.6.0.2
#8 lore raw

PATCH 8/10 ahci: add ahci emulation

In reply to Alexander Graf

This patch adds an emulation layer for an ICH-7M AHCI controller. For now this controller does not do IDE legacy emulation. It is a pure AHCI controller.

---

v1 -> v2:

- rename IDEExtender to IDEBusOps and make a pointer (kraxel)
- make dma hooks explicit by putting them into ops struct (stefanha)
- use qdev buses (kraxel)
- minor cleanups
- dprintf overhaul
- add reset function

---
 Makefile.objs                      |    1 +
 Makefile.target                    |    4 +
 default-configs/i386-softmmu.mak   |    1 +
 default-configs/x86_64-softmmu.mak |    1 +
 hw/ahci.c                          | 1280 ++++++++++++++++++++++++++++++++++++
 5 files changed, 1287 insertions(+), 0 deletions(-)
 create mode 100644 hw/ahci.c
Makefile.objs +1 -0
index 15569af..8dfcefa 100644
@@ -229,6 +229,7 @@ hw-obj-$(CONFIG_IDE_PIIX) += ide/piix.o
 hw-obj-$(CONFIG_IDE_CMD646) += ide/cmd646.o
 hw-obj-$(CONFIG_IDE_MACIO) += ide/macio.o
 hw-obj-$(CONFIG_IDE_VIA) += ide/via.o
+hw-obj-$(CONFIG_AHCI) += ahci.o
 
 # SCSI layer
 hw-obj-y += lsi53c895a.o
Makefile.target +4 -0
index 91e6e74..bd899cd 100644
@@ -195,6 +195,10 @@ obj-y += e1000.o
 # Inter-VM PCI shared memory
 obj-$(CONFIG_KVM) += ivshmem.o
 
+# ahci
+#
+obj-$(CONFIG_AHCI) += ahci.o
+
 # Hardware support
 obj-i386-y += vga.o
 obj-i386-y += mc146818rtc.o i8259.o pc.o
default-configs/i386-softmmu.mak +1 -0
index ed00471..66b92af 100644
@@ -19,6 +19,7 @@ CONFIG_IDE_QDEV=y
 CONFIG_IDE_PCI=y
 CONFIG_IDE_ISA=y
 CONFIG_IDE_PIIX=y
+CONFIG_AHCI=y
 CONFIG_NE2000_ISA=y
 CONFIG_PIIX_PCI=y
 CONFIG_SOUND=y
default-configs/x86_64-softmmu.mak +1 -0
index 5183203..508e843 100644
@@ -19,6 +19,7 @@ CONFIG_IDE_QDEV=y
 CONFIG_IDE_PCI=y
 CONFIG_IDE_ISA=y
 CONFIG_IDE_PIIX=y
+CONFIG_AHCI=y
 CONFIG_NE2000_ISA=y
 CONFIG_PIIX_PCI=y
 CONFIG_SOUND=y
hw/ahci.c new file +1280 -0

1,280 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#9 lore raw

[Qemu-devel] Re: [PATCH 08/10] ahci: add ahci emulation

Hi,

hw/ahci.c line 404

Quoted 4 lines
hw/ahci.c new file +3 -0
+static void ahci_trigger_irq(AHCIState *s, AHCIDevice *d,
+                             int irq_type)
 
+static void ahci_check_irq(AHCIState *s)

MSI support would be nice to have.

hw/ahci.c line 623

Quoted 3 lines
hw/ahci.c new file +3 -0
+#ifndef min
+#define min(a, b) ((a)<  (b) ? (a) : (b))
+#endif

osdep.h has MIN/MAX macros.

hw/ahci.c line 1191

Quoted 5 lines
hw/ahci.c new file +4 -0
+static void ahci_init(AHCIState *s, DeviceState *qdev)
+{
 
+        ide_bus_new(&ad->port, qdev);
+        ide_init2(&ad->port, 0);

Good.

hw/ahci.c line 1195

Quoted 3 lines
hw/ahci.c new file +3 -0
+        if (dinfo) {
+            ide_create_drive(&ad->port, 0, dinfo);
+        }

That doesn't belong into the qdev init function.

Look how ide/isa.c handles it: The qdev init function (isa_ide_initfn) doesn't create ide-drives at all. And there is a convinience function (isa_ide_init) which first creates the controller, then attaches the drives. The later is called from pc_init() with the drives specified via -drive if=ide (or -hda).

Does AHCI support drive hotplug btw?

hw/ahci.c line 1241

Quoted 11 lines
hw/ahci.c new file +8 -0
+static void ahci_reset(void *opaque)
+{
 
+    pci_config_set_vendor_id(d->card.config, PCI_VENDOR_ID_INTEL);
+    pci_config_set_device_id(d->card.config, PCI_DEVICE_ID_INTEL_ICH7M_AHCI);
 
+    pci_config_set_class(d->card.config, PCI_CLASS_STORAGE_SATA);
+    pci_config_set_prog_interface(d->card.config, AHCI_PROGMODE_MAJOR_REV_1);
 
+    d->card.config[PCI_HEADER_TYPE]     = PCI_HEADER_TYPE_NORMAL;
+    d->card.config[PCI_INTERRUPT_PIN]   = 1;     /* interrupt pin 0 */

Why is that in the reset function instead of init? It should never ever change, should it?

hw/ahci.c line 1272

Quoted 8 lines
hw/ahci.c new file +8 -0
+static PCIDeviceInfo ahci_info = {
+    .qdev.name  = "ahci",
+    .qdev.size  = sizeof(AHCIPciState),
+    .init       = pci_ahci_init,
+    .exit       = pci_ahci_uninit,
+    .qdev.props = (Property[]) {
+        DEFINE_PROP_END_OF_LIST(),
+    }

If there are no properties you can zap the last tree lines altogether ;)

cheers,
Gerd

#16 lore raw
In reply to Alexander Graf

Hi Alex,

Am 18.11.2010 04:27, schrieb Alexander Graf:

Quoted 19 lines

This patch adds support for AHCI emulation. I have tested and verified it works in Linux, OpenBSD, Windows Vista and Windows 7. This AHCI emulation supports NCQ, so multiple read or write requests can be outstanding at the same time.

The code is however not fully optimized yet. I'm fairly sure that there are low hanging performance fruits to be found still :). In my simple benchmarks I achieved about 2/3rd of virtio performance.

Also, this AHCI emulation layer does not support legacy mode. So if you're using a disk with this emulation, you do not get it exposed using the legacy IDE interfaces.

Another nitpick is CD-ROM support in Windows. Somehow it doesn't detect a CD-ROM drive attached to AHCI. At least it doesn't list it.

To attach an AHCI disk to your VM, please use

-drive file=...,if=sata

Quoted 8 lines

This should do the trick for x86. On other platforms, you might need to add the ahci host controller using -device.

This patch set is based on work done during the Google Summer of Code. I was mentoring a student, Roland Elek, who wrote most of the AHCI emulation code based on a patch from Chong Qiao. A bunch of other people were also involved, so everybody who I didn't mention - thanks a lot!

I'm not completely sure about the relationship between the AHCI emulation and our existing IDE emulation. First thing I noticed is that AHCI wants to be independent and resides in hw/ instead of hw/ide/, but it still include ide/internal.h. Do you think it would make sense to move AHCI into hw/ide?

Then I believe that core.c is now a mixture of some generic ATA code (that is also used by SATA) and the Legacy IDE code. SATA doesn't seem to interact with the generic code through clean interfaces, but by accessing internal data structures and calls to somewhere in the middle of the existing IDE emultion. I think we should get a clean abstraction there and have a clean split between SATA, PATA and common code, with each of them sitting in its own file in hw/ide.

I haven't reviewed the patches in detail but just had a quick look at them, so my impressions might be wrong. If so, please correct me.

Kevin

#10 lore raw

[Qemu-devel] Re: [PATCH 08/10] ahci: add ahci emulation

In reply to Gerd Hoffmann
Quoted 8 lines · Gerd Hoffmann

Hi,

hw/ahci.c line 404

Quoted 4 lines
hw/ahci.c new file +3 -0
+static void ahci_trigger_irq(AHCIState *s, AHCIDevice *d,
+                             int irq_type)
 
+static void ahci_check_irq(AHCIState *s)

MSI support would be nice to have.

Alrighty, I added MSI support. But I only have a single vector in use atm as nvec > 0 doesn't get written to the PCI config space so the code trips on that later on.

[...]

Quoted 5 lines

hw/ahci.c line 1195

Quoted 4 lines
hw/ahci.c new file +3 -0
+        if (dinfo) {
+            ide_create_drive(&ad->port, 0, dinfo);
+        }
Quoted 7 lines

That doesn't belong into the qdev init function.

Look how ide/isa.c handles it: The qdev init function (isa_ide_initfn) doesn't create ide-drives at all. And there is a convinience function (isa_ide_init) which first creates the controller, then attaches the drives. The later is called from pc_init() with the drives specified via -drive if=ide (or -hda).

Hrm. I guess I'll just put it into the PC specific initialization function :).

Quoted 2 lines

Does AHCI support drive hotplug btw?

AHCI does, my code does not yet :). Feel free to add support for it! :D

Alex

#17 lore raw
In reply to Kevin Wolf
Quoted 31 lines · Kevin Wolf

Hi Alex,

Am 18.11.2010 04:27, schrieb Alexander Graf:

Quoted 19 lines

This patch adds support for AHCI emulation. I have tested and verified it works in Linux, OpenBSD, Windows Vista and Windows 7. This AHCI emulation supports NCQ, so multiple read or write requests can be outstanding at the same time.

The code is however not fully optimized yet. I'm fairly sure that there are low hanging performance fruits to be found still :). In my simple benchmarks I achieved about 2/3rd of virtio performance.

Also, this AHCI emulation layer does not support legacy mode. So if you're using a disk with this emulation, you do not get it exposed using the legacy IDE interfaces.

Another nitpick is CD-ROM support in Windows. Somehow it doesn't detect a CD-ROM drive attached to AHCI. At least it doesn't list it.

To attach an AHCI disk to your VM, please use

-drive file=...,if=sata

Quoted 8 lines

This should do the trick for x86. On other platforms, you might need to add the ahci host controller using -device.

This patch set is based on work done during the Google Summer of Code. I was mentoring a student, Roland Elek, who wrote most of the AHCI emulation code based on a patch from Chong Qiao. A bunch of other people were also involved, so everybody who I didn't mention - thanks a lot!

Quoted 5 lines

I'm not completely sure about the relationship between the AHCI emulation and our existing IDE emulation. First thing I noticed is that AHCI wants to be independent and resides in hw/ instead of hw/ide/, but it still include ide/internal.h. Do you think it would make sense to move AHCI into hw/ide?

Both ahci and ide implement ata. I guess the best thing to do would be to completely refactor all ide code into ata and pata code, then add ahci (sata) to the game. Estimated working time: ~1 month. :)

As I would rather have something working we can base on in the tree, so whoever volunteers for the refactoring (hint!) knows how to design the interfaces, I am not sure how much is reasonable within this patch set.

Moving the file to ide/ does sound like a good idea however.

Quoted 11 lines

Then I believe that core.c is now a mixture of some generic ATA code (that is also used by SATA) and the Legacy IDE code. SATA doesn't seem to interact with the generic code through clean interfaces, but by accessing internal data structures and calls to somewhere in the middle of the existing IDE emultion. I think we should get a clean abstraction there and have a clean split between SATA, PATA and common code, with each of them sitting in its own file in hw/ide.

I haven't reviewed the patches in detail but just had a quick look at them, so my impressions might be wrong. If so, please correct me.

No, you're completely right. We're in a chicken and egg situation. We don't have ahci, but the ide code is ugly. We would probably do a bad job at refactoring the ata code if we don't know which interfaces to design for.

So IMHO the only way we can really go is to implement sata, take the uglyness it adds to the already ugly ide code and use all of that for a working state we can start to refactor from.

So yes, while I agree with your obversations, I do not believe we will get there until at least 0.16 or so. And I'd rather like to see a fast default block driver in gueast sooner than later :)

Alex

Quoted 1 line
#18 lore raw
Quoted 58 lines · Alexander Graf
Quoted 31 lines · Kevin Wolf

Hi Alex,

Am 18.11.2010 04:27, schrieb Alexander Graf:

Quoted 19 lines

This patch adds support for AHCI emulation. I have tested and verified it works in Linux, OpenBSD, Windows Vista and Windows 7. This AHCI emulation supports NCQ, so multiple read or write requests can be outstanding at the same time.

The code is however not fully optimized yet. I'm fairly sure that there are low hanging performance fruits to be found still :). In my simple benchmarks I achieved about 2/3rd of virtio performance.

Also, this AHCI emulation layer does not support legacy mode. So if you're using a disk with this emulation, you do not get it exposed using the legacy IDE interfaces.

Another nitpick is CD-ROM support in Windows. Somehow it doesn't detect a CD-ROM drive attached to AHCI. At least it doesn't list it.

To attach an AHCI disk to your VM, please use

-drive file=...,if=sata

Quoted 8 lines

This should do the trick for x86. On other platforms, you might need to add the ahci host controller using -device.

This patch set is based on work done during the Google Summer of Code. I was mentoring a student, Roland Elek, who wrote most of the AHCI emulation code based on a patch from Chong Qiao. A bunch of other people were also involved, so everybody who I didn't mention - thanks a lot!

Quoted 5 lines

I'm not completely sure about the relationship between the AHCI emulation and our existing IDE emulation. First thing I noticed is that AHCI wants to be independent and resides in hw/ instead of hw/ide/, but it still include ide/internal.h. Do you think it would make sense to move AHCI into hw/ide?

Both ahci and ide implement ata. I guess the best thing to do would be to completely refactor all ide code into ata and pata code, then add ahci (sata) to the game. Estimated working time: ~1 month. :)

As I would rather have something working we can base on in the tree, so whoever volunteers for the refactoring (hint!) knows how to design the interfaces, I am not sure how much is reasonable within this patch set.

Moving the file to ide/ does sound like a good idea however.

Quoted 11 lines

Then I believe that core.c is now a mixture of some generic ATA code (that is also used by SATA) and the Legacy IDE code. SATA doesn't seem to interact with the generic code through clean interfaces, but by accessing internal data structures and calls to somewhere in the middle of the existing IDE emultion. I think we should get a clean abstraction there and have a clean split between SATA, PATA and common code, with each of them sitting in its own file in hw/ide.

I haven't reviewed the patches in detail but just had a quick look at them, so my impressions might be wrong. If so, please correct me.

Quoted 8 lines

No, you're completely right. We're in a chicken and egg situation. We don't have ahci, but the ide code is ugly. We would probably do a bad job at refactoring the ata code if we don't know which interfaces to design for.

So IMHO the only way we can really go is to implement sata, take the uglyness it adds to the already ugly ide code and use all of that for a working state we can start to refactor from.

So yes, while I agree with your obversations, I do not believe we will get there until at least 0.16 or so. And I'd rather like to see a fast default block driver in gueast sooner than later :)

Speaking of fast, do you have any numbers around ACHI vs IDE (not that I need any convincing that we can do better than IDE); just curious.

Quoted 4 lines

Alex

Quoted 1 line
Signature · 4 lines
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
[email protected]
#19 lore raw
Quoted 2 lines · Ryan Harper

Speaking of fast, do you have any numbers around ACHI vs IDE (not that I need any convincing that we can do better than IDE); just curious.

To test the raw link speed, I usually take a tmpfs backed sparse raw file and pass it to the guest. Inside the guest, I then dd the device to /dev/null with iflag=direct, so we don't get the guest page cache involved.

ide:

linux-uztg:~ # dd if=/dev/sdc of=/dev/null bs=10M count=300 iflag=direct 300+0 records in
300+0 records out
3145728000 bytes (3.1 GB) copied, 2.06424 s, 1.5 GB/s

ahci:

linux-uztg:~ # dd if=/dev/sda of=/dev/null bs=10M count=300 iflag=direct 300+0 records in
300+0 records out
3145728000 bytes (3.1 GB) copied, 1.40743 s, 2.2 GB/s

virtio:

linux-uztg:~ # dd if=/dev/vda of=/dev/null bs=10M count=300 iflag=direct 300+0 records in
300+0 records out
3145728000 bytes (3.1 GB) copied, 0.851306 s, 3.7 GB/s

Obviously, the main benefit of ahci over ide is that ahci can have multiple outstanding read/write requests at the same time. So even with the same link speed, you would see improvements because the backend can be partially cached or striped over different volumes which make simultaneous requests crucial for performance.

Alex

#20 lore raw
Quoted 1 line · Alexander Graf

linux-uztg:~ # dd if=/dev/sdc of=/dev/null bs=10M count=300 iflag=direct

That's a big block size. bs=8k is interesting too because we see the per-request overhead. Since IDE, SATA, and virtio have different hardware interfaces that the guest drives we may see an interesting picture with small block sizes.

Stefan

#11 lore raw

[Qemu-devel] Re: [PATCH 08/10] ahci: add ahci emulation

In reply to Alexander Graf
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

+static void ahci_check_irq(AHCIState *s)

MSI support would be nice to have.

Alrighty, I added MSI support. But I only have a single vector in use atm as nvec> 0 doesn't get written to the PCI config space so the code trips on that later on.

For multiple vectors MSI-X is the best choice as it fixes a few design issues MSI has when it comes to multiple vectors. I think linux never ever uses MSI with multiple vectors anyway.

cheers,
Gerd

#22 lore raw
In reply to Alexander Graf

Am 18.11.2010 19:43, schrieb Alexander Graf:

Quoted 40 lines · Kevin Wolf
Quoted 32 lines

Hi Alex,

Am 18.11.2010 04:27, schrieb Alexander Graf:

Quoted 19 lines

This patch adds support for AHCI emulation. I have tested and verified it works in Linux, OpenBSD, Windows Vista and Windows 7. This AHCI emulation supports NCQ, so multiple read or write requests can be outstanding at the same time.

The code is however not fully optimized yet. I'm fairly sure that there are low hanging performance fruits to be found still :). In my simple benchmarks I achieved about 2/3rd of virtio performance.

Also, this AHCI emulation layer does not support legacy mode. So if you're using a disk with this emulation, you do not get it exposed using the legacy IDE interfaces.

Another nitpick is CD-ROM support in Windows. Somehow it doesn't detect a CD-ROM drive attached to AHCI. At least it doesn't list it.

To attach an AHCI disk to your VM, please use

-drive file=...,if=sata

Quoted 8 lines

This should do the trick for x86. On other platforms, you might need to add the ahci host controller using -device.

This patch set is based on work done during the Google Summer of Code. I was mentoring a student, Roland Elek, who wrote most of the AHCI emulation code based on a patch from Chong Qiao. A bunch of other people were also involved, so everybody who I didn't mention - thanks a lot!

Quoted 5 lines

I'm not completely sure about the relationship between the AHCI emulation and our existing IDE emulation. First thing I noticed is that AHCI wants to be independent and resides in hw/ instead of hw/ide/, but it still include ide/internal.h. Do you think it would make sense to move AHCI into hw/ide?

Quoted 3 lines

Both ahci and ide implement ata. I guess the best thing to do would be to completely refactor all ide code into ata and pata code, then add ahci (sata) to the game. Estimated working time: ~1 month. :)

As I would rather have something working we can base on in the tree, so whoever volunteers for the refactoring (hint!) knows how to design the interfaces, I am not sure how much is reasonable within this patch set.

I guess I have to read this as: You want to drop the code into the repository, no matter what mess it creates, and leave the cleanup to some volunteer that will never appear. So whoever is in the unfortunate position of having to touch the IDE code afterwards will have the pain because this series is doing only the half of what should be done.

I'm sure that with a working time of only a few days the result could be substantially improved, even if a month would be needed for perfection.

Quoted 11 lines

Moving the file to ide/ does sound like a good idea however.

Quoted 9 lines

Then I believe that core.c is now a mixture of some generic ATA code (that is also used by SATA) and the Legacy IDE code. SATA doesn't seem to interact with the generic code through clean interfaces, but by accessing internal data structures and calls to somewhere in the middle of the existing IDE emultion. I think we should get a clean abstraction there and have a clean split between SATA, PATA and common code, with each of them sitting in its own file in hw/ide.

Quoted 4 lines
Quoted 2 lines

I haven't reviewed the patches in detail but just had a quick look at them, so my impressions might be wrong. If so, please correct me.

No, you're completely right. We're in a chicken and egg situation. We don't have ahci, but the ide code is ugly. We would probably do a bad job at refactoring the ata code if we don't know which interfaces to design for.

That problem is solved. You have posted patches, so you're aware what interfaces you need for AHCI. This awareness doesn't come from putting the code into git master.

Quoted 3 lines

So IMHO the only way we can really go is to implement sata, take the uglyness it adds to the already ugly ide code and use all of that for a working state we can start to refactor from.

So yes, while I agree with your obversations, I do not believe we will get there until at least 0.16 or so. And I'd rather like to see a fast default block driver in gueast sooner than later :)

Note that not doing the refactoring in this patch series means not only that it won't happen, but also that your patches are very hard to review. The order in which I would expect changes is to do the refactoring and then base the SATA code on these clean interfaces - not first creating a mess and then (maybe some time) trying to clean it up.

You always say "we" will refactor and "we" will clean up, so who is this "we"? Will you do it or are you rather trying to put it on my todo list? I must admit that I wouldn't be happy about the latter.

Kevin

#12 lore raw

[Qemu-devel] Re: [PATCH 08/10] ahci: add ahci emulation

In reply to Gerd Hoffmann
Quoted 11 lines · Gerd Hoffmann
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

+static void ahci_check_irq(AHCIState *s)

MSI support would be nice to have.

Alrighty, I added MSI support. But I only have a single vector in use atm as nvec> 0 doesn't get written to the PCI config space so the code trips on that later on.

For multiple vectors MSI-X is the best choice as it fixes a few design issues MSI has when it comes to multiple vectors. I think linux never ever uses MSI with multiple vectors anyway.

Linux doesn't even support MSI with multiple vectors today.

Joerg

Signature · 5 lines
AMD Operating System Research Center

Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632
#23 lore raw
In reply to Kevin Wolf

Hi,

Quoted 11 lines
Quoted 4 lines

As I would rather have something working we can base on in the tree, so whoever volunteers for the refactoring (hint!) knows how to design the interfaces, I am not sure how much is reasonable within this patch set.

I guess I have to read this as: You want to drop the code into the repository, no matter what mess it creates, and leave the cleanup to some volunteer that will never appear. So whoever is in the unfortunate position of having to touch the IDE code afterwards will have the pain because this series is doing only the half of what should be done.

Well, this is how IDE gets cleaned up right now. I was one of the victims ;)

IDE is in a noticeable better state than it used to be two years ago. It is still quite messy though.

Quoted 3 lines

I'm sure that with a working time of only a few days the result could be substantially improved, even if a month would be needed for perfection.

[ disclaimer: didn't look at v3 yet ]

Adding ahci should at least not make it more messy that it already is.

Doing the controller-depending dispatching through a function pointer table (aka IDEBusOps) looks sane to me. SCSI does the same, although without a Ops struct as it needs a single function pointer only.

Moving code shared between sata/ahci and ide to another source file (ata.c ?) makes sense and would be a good start to make clear which code is used for what.

IDEBus must learn some things about sata. For example there is no such thing as a slave device, so a IDEBus representing a sata port must not allow slave devices being attached.

Fixing the IDEState mess would be great. Right now IDEBus carries a array of IDEStates for master and slave for historical reasons: The ide code (used to?) assume that the IDEStates for master and slave are allocated together and that it can easily jump from one to the other and back using pointer arithmetics on the IDEState struct. IDEState doesn't belong there though, it should be part of IDEDrive. Also having a unused slave state doesn't make sense at all for sata. Fixing that without breaking migration could be non-trivial though.

cheers,
Gerd

#24 lore raw

Am 19.11.2010 12:56, schrieb Gerd Hoffmann:

Quoted 14 lines
   Hi,
Quoted 11 lines
Quoted 4 lines

As I would rather have something working we can base on in the tree, so whoever volunteers for the refactoring (hint!) knows how to design the interfaces, I am not sure how much is reasonable within this patch set.

I guess I have to read this as: You want to drop the code into the repository, no matter what mess it creates, and leave the cleanup to some volunteer that will never appear. So whoever is in the unfortunate position of having to touch the IDE code afterwards will have the pain because this series is doing only the half of what should be done.

Quoted 5 lines

Well, this is how IDE gets cleaned up right now. I was one of the victims ;)

IDE is in a noticeable better state than it used to be two years ago. It is still quite messy though.

Sure that's how it works today. We have no choice because we can't change the mistakes that were made in the past. But we can avoid to contribute new mess to it or we'll need even more victims. ;-)

Quoted 11 lines
Quoted 3 lines

I'm sure that with a working time of only a few days the result could be substantially improved, even if a month would be needed for perfection.

[ disclaimer: didn't look at v3 yet ]

Adding ahci should at least not make it more messy that it already is.

Doing the controller-depending dispatching through a function pointer table (aka IDEBusOps) looks sane to me. SCSI does the same, although without a Ops struct as it needs a single function pointer only.

Yes, I suppose (still haven't looked at it in detail) these interfaces are generally sane, based on your comments and a quick look.

This is also what makes me think that doing the next step shouldn't be too hard. The abstraction is basically in place, the rest should be mostly code movement and maybe splitting up some IDE data structures to make things look more symmetric between PATA and SATA.

Quoted 3 lines

Moving code shared between sata/ahci and ide to another source file (ata.c ?) makes sense and would be a good start to make clear which code is used for what.

I agree (and ata.c would have been my suggestion, too).

Quoted 3 lines

IDEBus must learn some things about sata. For example there is no such thing as a slave device, so a IDEBus representing a sata port must not allow slave devices being attached.

Hm, do the generic functions (i.e. what would end up in ata.c) even need access to the IDEBus? If not, we could leave IDEBus as it is for Legacy IDE and introduce a completely new SATABus.

Most occurrences in core.c seem to use the bus only for ide_set_irq.

Quoted 6 lines

Fixing the IDEState mess would be great. Right now IDEBus carries a array of IDEStates for master and slave for historical reasons: The ide code (used to?) assume that the IDEStates for master and slave are allocated together and that it can easily jump from one to the other and back using pointer arithmetics on the IDEState struct. IDEState doesn't belong there though, it should be part of IDEDrive.

Okay, that makes sense.

Kevin

#25 lore raw
In reply to Kevin Wolf
Quoted 65 lines · Kevin Wolf

Am 18.11.2010 19:43, schrieb Alexander Graf:

Quoted 40 lines · Kevin Wolf
Quoted 32 lines

Hi Alex,

Am 18.11.2010 04:27, schrieb Alexander Graf:

Quoted 19 lines

This patch adds support for AHCI emulation. I have tested and verified it works in Linux, OpenBSD, Windows Vista and Windows 7. This AHCI emulation supports NCQ, so multiple read or write requests can be outstanding at the same time.

The code is however not fully optimized yet. I'm fairly sure that there are low hanging performance fruits to be found still :). In my simple benchmarks I achieved about 2/3rd of virtio performance.

Also, this AHCI emulation layer does not support legacy mode. So if you're using a disk with this emulation, you do not get it exposed using the legacy IDE interfaces.

Another nitpick is CD-ROM support in Windows. Somehow it doesn't detect a CD-ROM drive attached to AHCI. At least it doesn't list it.

To attach an AHCI disk to your VM, please use

-drive file=...,if=sata

Quoted 8 lines

This should do the trick for x86. On other platforms, you might need to add the ahci host controller using -device.

This patch set is based on work done during the Google Summer of Code. I was mentoring a student, Roland Elek, who wrote most of the AHCI emulation code based on a patch from Chong Qiao. A bunch of other people were also involved, so everybody who I didn't mention - thanks a lot!

Quoted 5 lines

I'm not completely sure about the relationship between the AHCI emulation and our existing IDE emulation. First thing I noticed is that AHCI wants to be independent and resides in hw/ instead of hw/ide/, but it still include ide/internal.h. Do you think it would make sense to move AHCI into hw/ide?

Quoted 3 lines

Both ahci and ide implement ata. I guess the best thing to do would be to completely refactor all ide code into ata and pata code, then add ahci (sata) to the game. Estimated working time: ~1 month. :)

As I would rather have something working we can base on in the tree, so whoever volunteers for the refactoring (hint!) knows how to design the interfaces, I am not sure how much is reasonable within this patch set.

I guess I have to read this as: You want to drop the code into the repository, no matter what mess it creates, and leave the cleanup to some volunteer that will never appear. So whoever is in the unfortunate position of having to touch the IDE code afterwards will have the pain because this series is doing only the half of what should be done.

I'm sure that with a working time of only a few days the result could be substantially improved, even if a month would be needed for perfection.

Quoted 11 lines

Moving the file to ide/ does sound like a good idea however.

Quoted 9 lines

Then I believe that core.c is now a mixture of some generic ATA code (that is also used by SATA) and the Legacy IDE code. SATA doesn't seem to interact with the generic code through clean interfaces, but by accessing internal data structures and calls to somewhere in the middle of the existing IDE emultion. I think we should get a clean abstraction there and have a clean split between SATA, PATA and common code, with each of them sitting in its own file in hw/ide.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

I haven't reviewed the patches in detail but just had a quick look at them, so my impressions might be wrong. If so, please correct me.

No, you're completely right. We're in a chicken and egg situation. We don't have ahci, but the ide code is ugly. We would probably do a bad job at refactoring the ata code if we don't know which interfaces to design for.

That problem is solved. You have posted patches, so you're aware what interfaces you need for AHCI. This awareness doesn't come from putting the code into git master.

I guess you should go back and read the "this doesn't work yet" list. There is a lot of stuff that I'm not sure we have all correctly sorted out. The most intrusive one on that side is the legacy IDE compatibility. I don't know what interfaces and what changes we will need for that to become realistic.

Also to catch up on Gerd's point - whatever refactoring we do, we will basically have to break migration. There is no way we can change all the internal state and structure and maintain binary compatibility with the old save states.

Alex

#26 lore raw

Am 19.11.2010 14:08, schrieb Alexander Graf:

Quoted 15 lines · Kevin Wolf
Quoted 13 lines

Am 18.11.2010 19:43, schrieb Alexander Graf:

Quoted 11 lines
Quoted 10 lines

Then I believe that core.c is now a mixture of some generic ATA code (that is also used by SATA) and the Legacy IDE code. SATA doesn't seem to interact with the generic code through clean interfaces, but by accessing internal data structures and calls to somewhere in the middle of the existing IDE emultion. I think we should get a clean abstraction there and have a clean split between SATA, PATA and common code, with each of them sitting in its own file in hw/ide.

I haven't reviewed the patches in detail but just had a quick look at them, so my impressions might be wrong. If so, please correct me.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

No, you're completely right. We're in a chicken and egg situation. We don't have ahci, but the ide code is ugly. We would probably do a bad job at refactoring the ata code if we don't know which interfaces to design for.

That problem is solved. You have posted patches, so you're aware what interfaces you need for AHCI. This awareness doesn't come from putting the code into git master.

I guess you should go back and read the "this doesn't work yet" list. There is a lot of stuff that I'm not sure we have all correctly sorted out. The most intrusive one on that side is the legacy IDE compatibility. I don't know what interfaces and what changes we will need for that to become realistic.

Fair enough. I'll accept that we can't get it sorted out now, but let's try to do the part that we can do. Let's change the split to SATA (ahci.c), Legacy IDE (ide.c?), common code (ata.c) and "don't know yet" (core.c).

A start for that would be if in Patch 2 you moved the function to ata.c instead of just reindenting. We're also probably pretty sure that, for example, the I/O port handling won't need to be shared and can be moved to ide.c. Whenever it becomes clear for a part in which category it belongs, we would move it out of core.c and eventually, I hope, core.c could be removed.

Quoted 1 line

Also to catch up on Gerd's point - whatever refactoring we do, we will basically have to break migration. There is no way we can change all the internal state and structure and maintain binary compatibility with the old save states.

Hm, breaking migration isn't really an option. I'm not familiar with migration code, but maybe Juan can contribute some magic?

Speaking of migration, that seems to be missing for the AHCI yet, too. Are you planning to complete the functionality first before you start with that?

Kevin

#29 lore raw
In reply to Alexander Graf

Hi,

Quoted 4 lines

Also to catch up on Gerd's point - whatever refactoring we do, we will basically have to break migration. There is no way we can change all the internal state and structure and maintain binary compatibility with the old save states.

On the other hand it would be a *real* pity to drag the ide migration mess into ahci ...

Ideally each ide-drive should save its state itself, and likewise each ide/ahci controller. Maybe it would be a good first step to move to such a model in the savevm data format, but keep the current ide data structures for a while so we can easily accept migrations in the old savevm format for the time being.

Then a relase or two away from today we'll drop support for the old ide savevm format, so we can finally tranform the ide data structures to something sane?

Juan? Comments?

cheers,
Gerd

#27 lore raw
In reply to Kevin Wolf
Quoted 29 lines · Kevin Wolf

Am 19.11.2010 14:08, schrieb Alexander Graf:

Quoted 15 lines · Kevin Wolf
Quoted 13 lines

Am 18.11.2010 19:43, schrieb Alexander Graf:

Quoted 11 lines
Quoted 10 lines

Then I believe that core.c is now a mixture of some generic ATA code (that is also used by SATA) and the Legacy IDE code. SATA doesn't seem to interact with the generic code through clean interfaces, but by accessing internal data structures and calls to somewhere in the middle of the existing IDE emultion. I think we should get a clean abstraction there and have a clean split between SATA, PATA and common code, with each of them sitting in its own file in hw/ide.

I haven't reviewed the patches in detail but just had a quick look at them, so my impressions might be wrong. If so, please correct me.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

No, you're completely right. We're in a chicken and egg situation. We don't have ahci, but the ide code is ugly. We would probably do a bad job at refactoring the ata code if we don't know which interfaces to design for.

That problem is solved. You have posted patches, so you're aware what interfaces you need for AHCI. This awareness doesn't come from putting the code into git master.

I guess you should go back and read the "this doesn't work yet" list. There is a lot of stuff that I'm not sure we have all correctly sorted out. The most intrusive one on that side is the legacy IDE compatibility. I don't know what interfaces and what changes we will need for that to become realistic.

Fair enough. I'll accept that we can't get it sorted out now, but let's try to do the part that we can do. Let's change the split to SATA (ahci.c), Legacy IDE (ide.c?), common code (ata.c) and "don't know yet" (core.c).

Quoted 6 lines

A start for that would be if in Patch 2 you moved the function to ata.c instead of just reindenting. We're also probably pretty sure that, for example, the I/O port handling won't need to be shared and can be moved to ide.c. Whenever it becomes clear for a part in which category it belongs, we would move it out of core.c and eventually, I hope, core.c could be removed.

I can certainly move out obviously pata specific pieces to a new file called pata.c. As for the split between ata.c and core.c, I don't think it's useful. Once we moved everything pata specific out or core.c, that file will essentially be ata.c.

Quoted 9 lines
Quoted 2 lines

Also to catch up on Gerd's point - whatever refactoring we do, we will basically have to break migration. There is no way we can change all the internal state and structure and maintain binary compatibility with the old save states.

Hm, breaking migration isn't really an option. I'm not familiar with migration code, but maybe Juan can contribute some magic?

Speaking of migration, that seems to be missing for the AHCI yet, too. Are you planning to complete the functionality first before you start with that?

I'm planning to take baby steps so others can contribute and I don't keep a patch set lying around become more invasive and thus more prone to bitrot every day :). I myself just don't scale well enough for a feature this intrusive and important.

I had the code bitrot for quite a bit already btw. GSoC ended a couple months ago and I just didn't get around to polish the code well enough for upstream submission. And believe me, it rots very fast.

Vmstate is an issue we need to solve. I'm not sure what the right way forward for that would be. I certainly would not recommend declaring the migration protocol for sata even remotely stable for the time being, as we're missing crucial pieces still that might require major restructuring or even duplicating of core ide code. And as long as that's the case, I'm not sure how much sense it really makes to have any at all.

Basically, if there was a CONFIG_EXPERIMENTAL flag, I would set it on ahci. The code is not and will not be 100% stable and well structures and reliable within the next probably 1/2 year to year. But we need to start walking into a direction where it can finally end up being there some day, and that only works by multiple people working together on this, preferably upstream, so we don't collide with other possible ide work.

Of course there's some chance that it won't get there. If there is interest in it though, it will. And from what I've gathered so far, there is interest, as it's a speedup for a lot of guests without the need for special drivers. If it just lies around without getting improved, rip it out again :). If nobody works on it, nobody uses it.

Alex

#21 lore raw
In reply to Stefan Hajnoczi
Quoted 7 lines · Stefan Hajnoczi
Quoted 1 line · Alexander Graf

linux-uztg:~ # dd if=/dev/sdc of=/dev/null bs=10M count=300 iflag=direct

That's a big block size. bs=8k is interesting too because we see the per-request overhead. Since IDE, SATA, and virtio have different hardware interfaces that the guest drives we may see an interesting picture with small block sizes.

IDE: 60MB/s
SATA: 100MB/s
virtio: 120 MB/s

I had a pretty big jitter on that one though, with SATA going between 80MB and 120MB :). But overall, it's the same picture as the one with big block sizes.

Alex

#28 lore raw
In reply to Alexander Graf

Am 21.11.2010 03:19, schrieb Alexander Graf:

Quoted 32 lines · Kevin Wolf
Quoted 30 lines

Am 19.11.2010 14:08, schrieb Alexander Graf:

Quoted 15 lines · Kevin Wolf
Quoted 13 lines

Am 18.11.2010 19:43, schrieb Alexander Graf:

Quoted 11 lines
Quoted 10 lines

Then I believe that core.c is now a mixture of some generic ATA code (that is also used by SATA) and the Legacy IDE code. SATA doesn't seem to interact with the generic code through clean interfaces, but by accessing internal data structures and calls to somewhere in the middle of the existing IDE emultion. I think we should get a clean abstraction there and have a clean split between SATA, PATA and common code, with each of them sitting in its own file in hw/ide.

I haven't reviewed the patches in detail but just had a quick look at them, so my impressions might be wrong. If so, please correct me.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

No, you're completely right. We're in a chicken and egg situation. We don't have ahci, but the ide code is ugly. We would probably do a bad job at refactoring the ata code if we don't know which interfaces to design for.

That problem is solved. You have posted patches, so you're aware what interfaces you need for AHCI. This awareness doesn't come from putting the code into git master.

I guess you should go back and read the "this doesn't work yet" list. There is a lot of stuff that I'm not sure we have all correctly sorted out. The most intrusive one on that side is the legacy IDE compatibility. I don't know what interfaces and what changes we will need for that to become realistic.

Fair enough. I'll accept that we can't get it sorted out now, but let's try to do the part that we can do. Let's change the split to SATA (ahci.c), Legacy IDE (ide.c?), common code (ata.c) and "don't know yet" (core.c).

Quoted 8 lines
Quoted 6 lines

A start for that would be if in Patch 2 you moved the function to ata.c instead of just reindenting. We're also probably pretty sure that, for example, the I/O port handling won't need to be shared and can be moved to ide.c. Whenever it becomes clear for a part in which category it belongs, we would move it out of core.c and eventually, I hope, core.c could be removed.

I can certainly move out obviously pata specific pieces to a new file called pata.c. As for the split between ata.c and core.c, I don't think it's useful. Once we moved everything pata specific out or core.c, that file will essentially be ata.c.

The reason why I suggested ata.c is that core.c would serve as kind of a todo list. But I don't really mind if you wan to keep it in core.c, the important part is getting the split between core/ata and pata.

Quoted 9 lines
Quoted 8 lines
Quoted 1 line

Also to catch up on Gerd's point - whatever refactoring we do, we will basically have to break migration. There is no way we can change all the internal state and structure and maintain binary compatibility with the old save states.

Hm, breaking migration isn't really an option. I'm not familiar with migration code, but maybe Juan can contribute some magic?

Speaking of migration, that seems to be missing for the AHCI yet, too. Are you planning to complete the functionality first before you start with that?

Quoted 5 lines

I'm planning to take baby steps so others can contribute and I don't keep a patch set lying around become more invasive and thus more prone to bitrot every day :). I myself just don't scale well enough for a feature this intrusive and important.

I had the code bitrot for quite a bit already btw. GSoC ended a couple months ago and I just didn't get around to polish the code well enough for upstream submission. And believe me, it rots very fast.

Vmstate is an issue we need to solve. I'm not sure what the right way forward for that would be. I certainly would not recommend declaring the migration protocol for sata even remotely stable for the time being, as we're missing crucial pieces still that might require major restructuring or even duplicating of core ide code. And as long as that's the case, I'm not sure how much sense it really makes to have any at all.

Okay, I think that's a good point.

I was asking because I'm not sure if it wouldn't be easier to have migration working early and then incrementally change it with whatever is added, compared to developing everything and adding migration as the last thing. I haven't done either yet, so I might be wrong.

Quoted 3 lines

Basically, if there was a CONFIG_EXPERIMENTAL flag, I would set it on ahci. The code is not and will not be 100% stable and well structures and reliable within the next probably 1/2 year to year. But we need to start walking into a direction where it can finally end up being there some day, and that only works by multiple people working together on this, preferably upstream, so we don't collide with other possible ide work.

Of course there's some chance that it won't get there. If there is interest in it though, it will. And from what I've gathered so far, there is interest, as it's a speedup for a lot of guests without the need for special drivers. If it just lies around without getting improved, rip it out again :). If nobody works on it, nobody uses it.

Not disagreeing with that. Also, we have a lot of hardware that has only a few users. That's never been a reason for dropping it.

The one important point to me is that AHCI touches IDE and shouldn't leave it in a worse state than before. If AHCI itself in its current state really works well all the time is secondary for me, because, as you say, there's still time to fix and enhance it when it's in.

Kevin