From 56333e69ee1855a8fa74b361742a0a79407846d2 Mon Sep 17 00:00:00 2001 From: George Kennedy Date: Fri, 9 Nov 2018 10:18:12 -0500 Subject: lsi: Reselection needed to remove pending commands from queue Under heavy IO (e.g. fio) the queue is not checked frequently enough for pending commands. As a result some pending commands are timed out by the linux sym53c8xx driver, which sends SCSI Abort messages for the timed out commands. The SCSI Abort messages result in linux errors, which show up on the console and in /var/log/messages. e.g. sd 0:0:3:0: [sdd] tag#33 ABORT operation started scsi target0:0:3: control msgout: 80 20 47 d sd 0:0:3:0: ABORT operation complete. scsi target0:0:4: message d sent on bad reselection Now following a WAIT DISCONNECT Script instruction, and if there is no current command, check for a pending command on the queue and if one exists call lsi_reselect(). Signed-off-by: George Kennedy Message-Id: <1541776692-12271-1-git-send-email-george.kennedy@oracle.com> [For safety, add a s->current check in lsi_update_irq - Paolo] Signed-off-by: Paolo Bonzini --- hw/scsi/lsi53c895a.c | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) (limited to 'hw') diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index 3f207f6..52a3893 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -298,6 +298,18 @@ static inline int lsi_irq_on_rsl(LSIState *s) return (s->sien0 & LSI_SIST0_RSL) && (s->scid & LSI_SCID_RRE); } +static lsi_request *get_pending_req(LSIState *s) +{ + lsi_request *p; + + QTAILQ_FOREACH(p, &s->queue, next) { + if (p->pending) { + return p; + } + } + return NULL; +} + static void lsi_soft_reset(LSIState *s) { trace_lsi_reset(); @@ -446,7 +458,6 @@ static void lsi_update_irq(LSIState *s) { int level; static int last_level; - lsi_request *p; /* It's unclear whether the DIP/SIP bits should be cleared when the Interrupt Status Registers are cleared or when istat0 is read. @@ -476,13 +487,13 @@ static void lsi_update_irq(LSIState *s) } lsi_set_irq(s, level); - if (!level && lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON)) { + if (!s->current && !level && lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON)) { + lsi_request *p; + trace_lsi_update_irq_disconnected(); - QTAILQ_FOREACH(p, &s->queue, next) { - if (p->pending) { - lsi_reselect(s, p); - break; - } + p = get_pending_req(s); + if (p) { + lsi_reselect(s, p); } } } @@ -1065,11 +1076,12 @@ static void lsi_wait_reselect(LSIState *s) trace_lsi_wait_reselect(); - QTAILQ_FOREACH(p, &s->queue, next) { - if (p->pending) { - lsi_reselect(s, p); - break; - } + if (s->current) { + return; + } + p = get_pending_req(s); + if (p) { + lsi_reselect(s, p); } if (s->current == NULL) { s->waiting = 1; @@ -1259,6 +1271,18 @@ again: case 1: /* Disconnect */ trace_lsi_execute_script_io_disconnect(); s->scntl1 &= ~LSI_SCNTL1_CON; + /* FIXME: this is not entirely correct; the target need not ask + * for reselection until it has to send data, while here we force a + * reselection as soon as the bus is free. The correct flow would + * reselect before lsi_transfer_data and disconnect as soon as + * DMA ends. + */ + if (!s->current) { + lsi_request *p = get_pending_req(s); + if (p) { + lsi_reselect(s, p); + } + } break; case 2: /* Wait Reselect */ if (!lsi_irq_on_rsl(s)) { -- cgit v1.1 From 03fee66fde3f9e179e3973e8c50f6fa0a0a14613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Wed, 14 Nov 2018 17:29:30 +0400 Subject: vmstate: constify VMStateField MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because they are supposed to remain const. Signed-off-by: Marc-André Lureau Message-Id: <20181114132931.22624-1-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- hw/display/virtio-gpu.c | 4 ++-- hw/intc/s390_flic_kvm.c | 4 ++-- hw/nvram/eeprom93xx.c | 6 +++--- hw/nvram/fw_cfg.c | 6 +++--- hw/pci/msix.c | 4 ++-- hw/pci/pci.c | 8 ++++---- hw/pci/shpc.c | 7 ++++--- hw/scsi/scsi-bus.c | 4 ++-- hw/timer/twl92230.c | 4 ++-- hw/usb/redirect.c | 12 ++++++------ hw/virtio/virtio.c | 8 ++++---- 11 files changed, 34 insertions(+), 33 deletions(-) (limited to 'hw') diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 7be3a9d..c6fab56 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1073,7 +1073,7 @@ static const VMStateDescription vmstate_virtio_gpu_scanouts = { }; static int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size, - VMStateField *field, QJSON *vmdesc) + const VMStateField *field, QJSON *vmdesc) { VirtIOGPU *g = opaque; struct virtio_gpu_simple_resource *res; @@ -1101,7 +1101,7 @@ static int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size, } static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size, - VMStateField *field) + const VMStateField *field) { VirtIOGPU *g = opaque; struct virtio_gpu_simple_resource *res; diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index 3f804ad..a03df37 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -376,7 +376,7 @@ static void kvm_s390_release_adapter_routes(S390FLICState *fs, * reached */ static int kvm_flic_save(QEMUFile *f, void *opaque, size_t size, - VMStateField *field, QJSON *vmdesc) + const VMStateField *field, QJSON *vmdesc) { KVMS390FLICState *flic = opaque; int len = FLIC_SAVE_INITIAL_SIZE; @@ -426,7 +426,7 @@ static int kvm_flic_save(QEMUFile *f, void *opaque, size_t size, * in QEMUFile */ static int kvm_flic_load(QEMUFile *f, void *opaque, size_t size, - VMStateField *field) + const VMStateField *field) { uint64_t len = 0; uint64_t count = 0; diff --git a/hw/nvram/eeprom93xx.c b/hw/nvram/eeprom93xx.c index 2fd0e3c..2db3d7c 100644 --- a/hw/nvram/eeprom93xx.c +++ b/hw/nvram/eeprom93xx.c @@ -95,15 +95,15 @@ struct _eeprom_t { */ static int get_uint16_from_uint8(QEMUFile *f, void *pv, size_t size, - VMStateField *field) + const VMStateField *field) { uint16_t *v = pv; *v = qemu_get_ubyte(f); return 0; } -static int put_unused(QEMUFile *f, void *pv, size_t size, VMStateField *field, - QJSON *vmdesc) +static int put_unused(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, QJSON *vmdesc) { fprintf(stderr, "uint16_from_uint8 is used only for backwards compatibility.\n"); fprintf(stderr, "Never should be used to write a new state.\n"); diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 946f765..3cb726f 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -520,15 +520,15 @@ static void fw_cfg_reset(DeviceState *d) */ static int get_uint32_as_uint16(QEMUFile *f, void *pv, size_t size, - VMStateField *field) + const VMStateField *field) { uint32_t *v = pv; *v = qemu_get_be16(f); return 0; } -static int put_unused(QEMUFile *f, void *pv, size_t size, VMStateField *field, - QJSON *vmdesc) +static int put_unused(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, QJSON *vmdesc) { fprintf(stderr, "uint32_as_uint16 is only used for backward compatibility.\n"); fprintf(stderr, "This functions shouldn't be called.\n"); diff --git a/hw/pci/msix.c b/hw/pci/msix.c index c944c02..702dac4 100644 --- a/hw/pci/msix.c +++ b/hw/pci/msix.c @@ -625,7 +625,7 @@ void msix_unset_vector_notifiers(PCIDevice *dev) } static int put_msix_state(QEMUFile *f, void *pv, size_t size, - VMStateField *field, QJSON *vmdesc) + const VMStateField *field, QJSON *vmdesc) { msix_save(pv, f); @@ -633,7 +633,7 @@ static int put_msix_state(QEMUFile *f, void *pv, size_t size, } static int get_msix_state(QEMUFile *f, void *pv, size_t size, - VMStateField *field) + const VMStateField *field) { msix_load(pv, f); return 0; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index b937f0d..56b13b3 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -450,7 +450,7 @@ int pci_bus_numa_node(PCIBus *bus) } static int get_pci_config_device(QEMUFile *f, void *pv, size_t size, - VMStateField *field) + const VMStateField *field) { PCIDevice *s = container_of(pv, PCIDevice, config); PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(s); @@ -490,7 +490,7 @@ static int get_pci_config_device(QEMUFile *f, void *pv, size_t size, /* just put buffer */ static int put_pci_config_device(QEMUFile *f, void *pv, size_t size, - VMStateField *field, QJSON *vmdesc) + const VMStateField *field, QJSON *vmdesc) { const uint8_t **v = pv; assert(size == pci_config_size(container_of(pv, PCIDevice, config))); @@ -506,7 +506,7 @@ static VMStateInfo vmstate_info_pci_config = { }; static int get_pci_irq_state(QEMUFile *f, void *pv, size_t size, - VMStateField *field) + const VMStateField *field) { PCIDevice *s = container_of(pv, PCIDevice, irq_state); uint32_t irq_state[PCI_NUM_PINS]; @@ -528,7 +528,7 @@ static int get_pci_irq_state(QEMUFile *f, void *pv, size_t size, } static int put_pci_irq_state(QEMUFile *f, void *pv, size_t size, - VMStateField *field, QJSON *vmdesc) + const VMStateField *field, QJSON *vmdesc) { int i; PCIDevice *s = container_of(pv, PCIDevice, irq_state); diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c index a8462d4..96a43d2 100644 --- a/hw/pci/shpc.c +++ b/hw/pci/shpc.c @@ -688,8 +688,8 @@ void shpc_cap_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l) shpc_cap_update_dword(d); } -static int shpc_save(QEMUFile *f, void *pv, size_t size, VMStateField *field, - QJSON *vmdesc) +static int shpc_save(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, QJSON *vmdesc) { PCIDevice *d = container_of(pv, PCIDevice, shpc); qemu_put_buffer(f, d->shpc->config, SHPC_SIZEOF(d)); @@ -697,7 +697,8 @@ static int shpc_save(QEMUFile *f, void *pv, size_t size, VMStateField *field, return 0; } -static int shpc_load(QEMUFile *f, void *pv, size_t size, VMStateField *field) +static int shpc_load(QEMUFile *f, void *pv, size_t size, + const VMStateField *field) { PCIDevice *d = container_of(pv, PCIDevice, shpc); int ret = qemu_get_buffer(f, d->shpc->config, SHPC_SIZEOF(d)); diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 5905f6b..97cd167 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -1571,7 +1571,7 @@ SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int id, int lun) /* SCSI request list. For simplicity, pv points to the whole device */ static int put_scsi_requests(QEMUFile *f, void *pv, size_t size, - VMStateField *field, QJSON *vmdesc) + const VMStateField *field, QJSON *vmdesc) { SCSIDevice *s = pv; SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, s->qdev.parent_bus); @@ -1599,7 +1599,7 @@ static int put_scsi_requests(QEMUFile *f, void *pv, size_t size, } static int get_scsi_requests(QEMUFile *f, void *pv, size_t size, - VMStateField *field) + const VMStateField *field) { SCSIDevice *s = pv; SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, s->qdev.parent_bus); diff --git a/hw/timer/twl92230.c b/hw/timer/twl92230.c index 3b43b46..51ec355 100644 --- a/hw/timer/twl92230.c +++ b/hw/timer/twl92230.c @@ -750,7 +750,7 @@ static int menelaus_rx(I2CSlave *i2c) */ static int get_int32_as_uint16(QEMUFile *f, void *pv, size_t size, - VMStateField *field) + const VMStateField *field) { int *v = pv; *v = qemu_get_be16(f); @@ -758,7 +758,7 @@ static int get_int32_as_uint16(QEMUFile *f, void *pv, size_t size, } static int put_int32_as_uint16(QEMUFile *f, void *pv, size_t size, - VMStateField *field, QJSON *vmdesc) + const VMStateField *field, QJSON *vmdesc) { int *v = pv; qemu_put_be16(f, *v); diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 99094a7..18a42d1 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -2155,7 +2155,7 @@ static int usbredir_post_load(void *priv, int version_id) /* For usbredirparser migration */ static int usbredir_put_parser(QEMUFile *f, void *priv, size_t unused, - VMStateField *field, QJSON *vmdesc) + const VMStateField *field, QJSON *vmdesc) { USBRedirDevice *dev = priv; uint8_t *data; @@ -2178,7 +2178,7 @@ static int usbredir_put_parser(QEMUFile *f, void *priv, size_t unused, } static int usbredir_get_parser(QEMUFile *f, void *priv, size_t unused, - VMStateField *field) + const VMStateField *field) { USBRedirDevice *dev = priv; uint8_t *data; @@ -2222,7 +2222,7 @@ static const VMStateInfo usbredir_parser_vmstate_info = { /* For buffered packets (iso/irq) queue migration */ static int usbredir_put_bufpq(QEMUFile *f, void *priv, size_t unused, - VMStateField *field, QJSON *vmdesc) + const VMStateField *field, QJSON *vmdesc) { struct endp_data *endp = priv; USBRedirDevice *dev = endp->dev; @@ -2245,7 +2245,7 @@ static int usbredir_put_bufpq(QEMUFile *f, void *priv, size_t unused, } static int usbredir_get_bufpq(QEMUFile *f, void *priv, size_t unused, - VMStateField *field) + const VMStateField *field) { struct endp_data *endp = priv; USBRedirDevice *dev = endp->dev; @@ -2349,7 +2349,7 @@ static const VMStateDescription usbredir_ep_vmstate = { /* For PacketIdQueue migration */ static int usbredir_put_packet_id_q(QEMUFile *f, void *priv, size_t unused, - VMStateField *field, QJSON *vmdesc) + const VMStateField *field, QJSON *vmdesc) { struct PacketIdQueue *q = priv; USBRedirDevice *dev = q->dev; @@ -2368,7 +2368,7 @@ static int usbredir_put_packet_id_q(QEMUFile *f, void *priv, size_t unused, } static int usbredir_get_packet_id_q(QEMUFile *f, void *priv, size_t unused, - VMStateField *field) + const VMStateField *field) { struct PacketIdQueue *q = priv; USBRedirDevice *dev = q->dev; diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 4136d23..5828ed1 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1816,7 +1816,7 @@ static const VMStateDescription vmstate_virtio_ringsize = { }; static int get_extra_state(QEMUFile *f, void *pv, size_t size, - VMStateField *field) + const VMStateField *field) { VirtIODevice *vdev = pv; BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); @@ -1830,7 +1830,7 @@ static int get_extra_state(QEMUFile *f, void *pv, size_t size, } static int put_extra_state(QEMUFile *f, void *pv, size_t size, - VMStateField *field, QJSON *vmdesc) + const VMStateField *field, QJSON *vmdesc) { VirtIODevice *vdev = pv; BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); @@ -1979,14 +1979,14 @@ int virtio_save(VirtIODevice *vdev, QEMUFile *f) /* A wrapper for use as a VMState .put function */ static int virtio_device_put(QEMUFile *f, void *opaque, size_t size, - VMStateField *field, QJSON *vmdesc) + const VMStateField *field, QJSON *vmdesc) { return virtio_save(VIRTIO_DEVICE(opaque), f); } /* A wrapper for use as a VMState .get function */ static int virtio_device_get(QEMUFile *f, void *opaque, size_t size, - VMStateField *field) + const VMStateField *field) { VirtIODevice *vdev = VIRTIO_DEVICE(opaque); DeviceClass *dc = DEVICE_CLASS(VIRTIO_DEVICE_GET_CLASS(vdev)); -- cgit v1.1