git: c18ebe522814 - stable/13 - bhyve: nvme controller obey async event setting when reporting critical temperature

From: Corvin Köhne <corvink_at_FreeBSD.org>
Date: Wed, 23 Nov 2022 09:44:01 UTC
The branch stable/13 has been updated by corvink:

URL: https://cgit.FreeBSD.org/src/commit/?id=c18ebe522814dd0ec9eee35fd123847cbf3a95ce

commit c18ebe522814dd0ec9eee35fd123847cbf3a95ce
Author:     Wanpeng Qian <wanpengqian@gmail.com>
AuthorDate: 2022-11-14 13:08:52 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2022-11-22 06:51:26 +0000

    bhyve: nvme controller obey async event setting when reporting critical temperature
    
    Async event report is controlled by async event configuration feature
    setting. When reporting a critical temperature warning, check the async
    event configuration.
    
    Approved by:            manu (mentor)
    MFC after:              1 week
    Differential Revision:  https://reviews.freebsd.org/D37355
    
    (cherry picked from commit 10846c53c4569bdf6d6e2b88739a56a8273bce7f)
---
 usr.sbin/bhyve/pci_nvme.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c
index 6004cc91707b..46839078e89d 100644
--- a/usr.sbin/bhyve/pci_nvme.c
+++ b/usr.sbin/bhyve/pci_nvme.c
@@ -1726,6 +1726,7 @@ nvme_feature_temperature(struct pci_nvme_softc *sc,
 	uint8_t		tmpsel; /* Threshold Temperature Select */
 	uint8_t		thsel;  /* Threshold Type Select */
 	bool		set_crit = false;
+	bool		report_crit;
 
 	tmpth  = command->cdw11 & 0xffff;
 	tmpsel = (command->cdw11 >> 16) & 0xf;
@@ -1753,11 +1754,13 @@ nvme_feature_temperature(struct pci_nvme_softc *sc,
 		    ~NVME_CRIT_WARN_ST_TEMPERATURE;
 	pthread_mutex_unlock(&sc->mtx);
 
-	if (set_crit)
+	report_crit = sc->feat[NVME_FEAT_ASYNC_EVENT_CONFIGURATION].cdw11 &
+	    NVME_CRIT_WARN_ST_TEMPERATURE;
+
+	if (set_crit && report_crit)
 		pci_nvme_aen_post(sc, PCI_NVME_AE_TYPE_SMART,
 		    sc->health_log.critical_warning);
 
-
 	DPRINTF("%s: set_crit=%c critical_warning=%#x status=%#x", __func__, set_crit ? 'T':'F', sc->health_log.critical_warning, compl->status);
 }