Patchwork [08/11] QEMU NVMe: Enqueue critial temperature event

login
register
mail settings
Submitter Keith Busch
Date Feb. 27, 2013, 12:47 a.m.
Message ID <1361926034-21824-9-git-send-email-keith.busch@intel.com>
Download mbox | patch
Permalink /patch/223439/
State New
Headers show

Comments

Keith Busch - Feb. 27, 2013, 12:47 a.m.
If the temperature threshold warning is set below the controller temperature,
enqueue the async event warning.

Signed-off-by: Keith Busch <keith.busch@intel.com>
---
 hw/nvme.c |    9 +++++++++
 hw/nvme.h |    1 +
 2 files changed, 10 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/nvme.c b/hw/nvme.c
index c65c179..3e5cfc0 100644
--- a/hw/nvme.c
+++ b/hw/nvme.c
@@ -792,6 +792,15 @@  static uint16_t nvme_set_feature(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
                 DMA_DIRECTION_TO_DEVICE);
     case NVME_TEMPERATURE_THRESHOLD:
         n->features.temp_thresh = dw11;
+        if (n->features.temp_thresh <= n->temperature && !n->temp_warn_issued) {
+            n->temp_warn_issued = 1;
+            nvme_enqueue_event(n, NVME_AER_TYPE_SMART,
+                    NVME_AER_INFO_SMART_TEMP_THRESH,
+                    NVME_LOG_SMART_INFO);
+        } else if (n->features.temp_thresh > n->temperature &&
+                !(n->aer_mask & 1 << NVME_AER_TYPE_SMART)) {
+            n->temp_warn_issued = 0;
+        }
         break;
     case NVME_ERROR_RECOVERY:
         n->features.err_rec = dw11;
diff --git a/hw/nvme.h b/hw/nvme.h
index 53c0f39..b7d6615 100644
--- a/hw/nvme.h
+++ b/hw/nvme.h
@@ -684,6 +684,7 @@  typedef struct NvmeCtrl {
     uint8_t     vwc;
     uint8_t     lba_index;
     uint8_t     outstanding_aers;
+    uint8_t     temp_warn_issued;
 
     NvmeErrorLog    *elpes;
     NvmeRequest     **aer_reqs;