Skip to contentSkip to conversation

lsi: Properly initialize controller state on reset

PATCH In review Jan Kiszka 1 participant 2 messages Apr 29, 2010 – Apr 30, 2010

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 lsi: Properly initialize controller state on reset

The LSI controller was lacking any system reset handler. This is an attempt to fix it.

---
 hw/lsi53c895a.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
hw/lsi53c895a.c +11 -0
index 98b7f54..f328057 100644
@@ -1996,6 +1996,16 @@ static void lsi_mmio_mapfunc(PCIDevice *pci_dev, int region_num,
     cpu_register_physical_memory(addr + 0, 0x400, s->mmio_io_addr);
 }
 
+static void lsi_scsi_reset(DeviceState *dev)
+{
+    LSIState *s = DO_UPCAST(LSIState, dev.qdev, dev);
+
+    s->dma_buf = NULL;
+    s->current_dma_len = 0;
+    s->active_commands = 0;
+    lsi_soft_reset(s);
+}
+
 static void lsi_pre_save(void *opaque)
 {
     LSIState *s = opaque;
@@ -2149,6 +2159,7 @@ static PCIDeviceInfo lsi_info = {
     .qdev.name  = "lsi53c895a",
     .qdev.alias = "lsi",
     .qdev.size  = sizeof(LSIState),
+    .qdev.reset = lsi_scsi_reset,
     .qdev.vmsd  = &vmstate_lsi_scsi,
     .init       = lsi_scsi_init,
     .exit       = lsi_scsi_uninit,
author
#1 lore raw
Quoted 13 lines · Jan Kiszka

The LSI controller was lacking any system reset handler. This is an attempt to fix it.

---
 hw/lsi53c895a.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
hw/lsi53c895a.c +0 -0
index 98b7f54..f328057 100644

hw/lsi53c895a.c static void lsi_mmio_mapfunc(PCIDevice *pci_dev, int region_num, · line 2005

Quoted 10 lines
hw/lsi53c895a.c +7 -0
@@ -1996,6 +1996,16 @@ static void lsi_mmio_mapfunc(PCIDevice *pci_dev, int region_num,
     cpu_register_physical_memory(addr + 0, 0x400, s->mmio_io_addr);
 }
 
+static void lsi_scsi_reset(DeviceState *dev)
+{
+    LSIState *s = DO_UPCAST(LSIState, dev.qdev, dev);
+
+    s->dma_buf = NULL;
+    s->current_dma_len = 0;
+    s->active_commands = 0;

OK, this 0.12 patch obviously no longer applies. And purging the command queue should not only be done on hard reset, but also when software triggered it (ie. move it to lsi_soft_reset). Reworking...

Jan

Quoted 17 lines
hw/lsi53c895a.c +4 -0
+    lsi_soft_reset(s);
+}
+
 static void lsi_pre_save(void *opaque)
 {
     LSIState *s = opaque;
@@ -2149,6 +2159,7 @@ static PCIDeviceInfo lsi_info = {
     .qdev.name  = "lsi53c895a",
     .qdev.alias = "lsi",
     .qdev.size  = sizeof(LSIState),
+    .qdev.reset = lsi_scsi_reset,
     .qdev.vmsd  = &vmstate_lsi_scsi,
     .init       = lsi_scsi_init,
     .exit       = lsi_scsi_uninit,
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux