[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 10/35] megasas: Clear unit attention on initial reset
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 10/35] megasas: Clear unit attention on initial reset |
Date: |
Fri, 31 Oct 2014 18:25:48 +0100 |
From: Hannes Reinecke <address@hidden>
The EFI firmware doesn't handle unit attentions properly,
so we need to clear the Power On/Reset unit attention upon
initial reset.
Signed-off-by: Hannes Reinecke <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/scsi/megasas.c | 18 +++++++++++++++++-
hw/scsi/scsi-bus.c | 2 +-
include/hw/scsi/scsi.h | 1 +
trace-events | 2 +-
4 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index 58e29ae..57d5288 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -2202,11 +2202,26 @@ static void megasas_soft_reset(MegasasState *s)
int i;
MegasasCmd *cmd;
- trace_megasas_reset();
+ trace_megasas_reset(s->fw_state);
for (i = 0; i < s->fw_cmds; i++) {
cmd = &s->frames[i];
megasas_abort_command(cmd);
}
+ if (s->fw_state == MFI_FWSTATE_READY) {
+ BusChild *kid;
+
+ /*
+ * The EFI firmware doesn't handle UA,
+ * so we need to clear the Power On/Reset UA
+ * after the initial reset.
+ */
+ QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) {
+ SCSIDevice *sdev = DO_UPCAST(SCSIDevice, qdev, kid->child);
+
+ sdev->unit_attention = SENSE_CODE(NO_SENSE);
+ scsi_device_unit_attention_reported(sdev);
+ }
+ }
megasas_reset_frames(s);
s->reply_queue_len = s->fw_cmds;
s->reply_queue_pa = 0;
@@ -2334,6 +2349,7 @@ static int megasas_scsi_init(PCIDevice *dev)
msix_vector_use(dev, 0);
}
+ s->fw_state = MFI_FWSTATE_READY;
if (!s->sas_addr) {
s->sas_addr = ((NAA_LOCALLY_ASSIGNED_ID << 24) |
IEEE_COMPANY_LOCALLY_ASSIGNED) << 36;
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index 6fce847..6376b88 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -84,7 +84,7 @@ static SCSIRequest *scsi_device_alloc_req(SCSIDevice *s,
uint32_t tag, uint32_t
return NULL;
}
-static void scsi_device_unit_attention_reported(SCSIDevice *s)
+void scsi_device_unit_attention_reported(SCSIDevice *s)
{
SCSIDeviceClass *sc = SCSI_DEVICE_GET_CLASS(s);
if (sc->unit_attention_reported) {
diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
index fd48177..f4aabfd 100644
--- a/include/hw/scsi/scsi.h
+++ b/include/hw/scsi/scsi.h
@@ -272,6 +272,7 @@ void scsi_req_retry(SCSIRequest *req);
void scsi_device_purge_requests(SCSIDevice *sdev, SCSISense sense);
void scsi_device_set_ua(SCSIDevice *sdev, SCSISense sense);
void scsi_device_report_change(SCSIDevice *dev, SCSISense sense);
+void scsi_device_unit_attention_reported(SCSIDevice *dev);
int scsi_device_get_sense(SCSIDevice *dev, uint8_t *buf, int len, bool fixed);
SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int target, int lun);
diff --git a/trace-events b/trace-events
index cd149cb..2ceb8e4 100644
--- a/trace-events
+++ b/trace-events
@@ -754,7 +754,7 @@ megasas_dcmd_unsupported(int cmd, unsigned long size) "scmd
%d: set properties l
megasas_abort_frame(int cmd, int abort_cmd) "scmd %d: frame %x"
megasas_abort_no_cmd(int cmd, uint64_t context) "scmd %d: no active command
for frame context %" PRIx64 ""
megasas_abort_invalid_context(int cmd, uint64_t context, int abort_cmd) "scmd
%d: invalid frame context %" PRIx64 " for abort frame %x"
-megasas_reset(void) "Reset"
+megasas_reset(int fw_state) "firmware state %x"
megasas_init(int sges, int cmds, const char *mode) "Using %d sges, %d cmds, %s
mode"
megasas_msix_raise(int vector) "vector %d"
megasas_msi_raise(int vector) "vector %d"
--
1.8.3.1
- [Qemu-devel] [PULL 00/35] Last batch of SCSI, KVM, ivshmem patches before soft freeze, Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 01/35] rules.mak: Allow .mo-objs and .mo-cflags in -y variables, Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 02/35] ui: Use the new ".mo-cflags" rule syntax for SDL_CFLAGS, Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 03/35] scsi: Rename scsi_*_length() to scsi_*_xfer(), add scsi_cdb_length(), Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 04/35] megasas: fixup MFI_DCMD_LD_LIST_QUERY, Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 05/35] megasas: simplify trace event messages, Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 06/35] megasas: fixup device mapping, Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 07/35] megasas: add MegaRAID SAS 2108 emulation, Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 08/35] megasas: Fix typo in megasas_dcmd_ld_get_list(), Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 09/35] megasas: Decode register names, Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 10/35] megasas: Clear unit attention on initial reset,
Paolo Bonzini <=
- [Qemu-devel] [PULL 11/35] megasas: Ignore duplicate init_firmware commands, Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 12/35] megasas: Implement DCMD_CLUSTER_RESET_LD, Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 13/35] megasas: Update queue logging, Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 14/35] megasas: Rework frame queueing algorithm, Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 15/35] megasas: Fixup MSI-X handling, Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 16/35] -machine vmport=off: Allow disabling of VMWare ioport emulation, Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 17/35] Add skip_dump flag to ignore memory region during dump, Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 18/35] vl.c: Fix Coverity complaining for vmstate_dump_file, Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 19/35] kvmvapic: patch_instruction fix, Paolo Bonzini, 2014/10/31
- [Qemu-devel] [PULL 20/35] iscsi: Refuse to open as writable if the LUN is write protected, Paolo Bonzini, 2014/10/31