Patchwork [3/4] ide: wire up setfeatures cache control

login
register
mail settings
Submitter Christoph Hellwig
Date March 15, 2011, 2:11 p.m.
Message ID <20110315141142.GC30710@lst.de>
Download mbox | patch
Permalink /patch/86988/
State New
Headers show

Comments

Christoph Hellwig - March 15, 2011, 2:11 p.m.
Wire up the ATA SETFEATURES subcalls that control the volatile write cache
to the new bdrv_change_cache helper.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Patch

Index: qemu/hw/ide/core.c
===================================================================
--- qemu.orig/hw/ide/core.c	2011-03-15 11:47:18.569636140 +0100
+++ qemu/hw/ide/core.c	2011-03-15 13:07:21.464634347 +0100
@@ -1700,6 +1700,19 @@  void ide_ioport_write(void *opaque, uint
     }
 }
 
+static void ide_setcache(IDEState *s, bool enable)
+{
+    if (bdrv_change_cache(s->bs, enable)) {
+        ide_abort_command(s);
+        ide_set_irq(s->bus);
+        return;
+    }
+
+    s->identify_set = 0;
+
+    s->status = READY_STAT | SEEK_STAT;
+    ide_set_irq(s->bus);
+}
 
 void ide_exec_cmd(IDEBus *bus, uint32_t val)
 {
@@ -1855,7 +1868,11 @@  void ide_exec_cmd(IDEBus *bus, uint32_t
         case 0xcc: /* reverting to power-on defaults enable */
         case 0x66: /* reverting to power-on defaults disable */
         case 0x02: /* write cache enable */
+            ide_setcache(s, true);
+            break;
         case 0x82: /* write cache disable */
+            ide_setcache(s, false);
+            break;
         case 0xaa: /* read look-ahead enable */
         case 0x55: /* read look-ahead disable */
         case 0x05: /* set advanced power management mode */