@@ -32,8 +32,16 @@ static int bnxt_hwrm_temp_query(struct bnxt *bp, u8 *temp)
32
32
if (rc )
33
33
goto drop_req ;
34
34
35
- * temp = resp -> temp ;
36
-
35
+ if (temp ) {
36
+ * temp = resp -> temp ;
37
+ } else if (resp -> flags &
38
+ TEMP_MONITOR_QUERY_RESP_FLAGS_THRESHOLD_VALUES_AVAILABLE ) {
39
+ bp -> fw_cap |= BNXT_FW_CAP_THRESHOLD_TEMP_SUPPORTED ;
40
+ bp -> warn_thresh_temp = resp -> warn_threshold ;
41
+ bp -> crit_thresh_temp = resp -> critical_threshold ;
42
+ bp -> fatal_thresh_temp = resp -> fatal_threshold ;
43
+ bp -> shutdown_thresh_temp = resp -> shutdown_threshold ;
44
+ }
37
45
drop_req :
38
46
hwrm_req_drop (bp , req );
39
47
return rc ;
@@ -42,12 +50,23 @@ static int bnxt_hwrm_temp_query(struct bnxt *bp, u8 *temp)
42
50
static umode_t bnxt_hwmon_is_visible (const void * _data , enum hwmon_sensor_types type ,
43
51
u32 attr , int channel )
44
52
{
53
+ const struct bnxt * bp = _data ;
54
+
45
55
if (type != hwmon_temp )
46
56
return 0 ;
47
57
48
58
switch (attr ) {
49
59
case hwmon_temp_input :
50
60
return 0444 ;
61
+ case hwmon_temp_max :
62
+ case hwmon_temp_crit :
63
+ case hwmon_temp_emergency :
64
+ case hwmon_temp_max_alarm :
65
+ case hwmon_temp_crit_alarm :
66
+ case hwmon_temp_emergency_alarm :
67
+ if (!(bp -> fw_cap & BNXT_FW_CAP_THRESHOLD_TEMP_SUPPORTED ))
68
+ return 0 ;
69
+ return 0444 ;
51
70
default :
52
71
return 0 ;
53
72
}
@@ -66,13 +85,39 @@ static int bnxt_hwmon_read(struct device *dev, enum hwmon_sensor_types type, u32
66
85
if (!rc )
67
86
* val = temp * 1000 ;
68
87
return rc ;
88
+ case hwmon_temp_max :
89
+ * val = bp -> warn_thresh_temp * 1000 ;
90
+ return 0 ;
91
+ case hwmon_temp_crit :
92
+ * val = bp -> crit_thresh_temp * 1000 ;
93
+ return 0 ;
94
+ case hwmon_temp_emergency :
95
+ * val = bp -> fatal_thresh_temp * 1000 ;
96
+ return 0 ;
97
+ case hwmon_temp_max_alarm :
98
+ rc = bnxt_hwrm_temp_query (bp , & temp );
99
+ if (!rc )
100
+ * val = temp >= bp -> warn_thresh_temp ;
101
+ return rc ;
102
+ case hwmon_temp_crit_alarm :
103
+ rc = bnxt_hwrm_temp_query (bp , & temp );
104
+ if (!rc )
105
+ * val = temp >= bp -> crit_thresh_temp ;
106
+ return rc ;
107
+ case hwmon_temp_emergency_alarm :
108
+ rc = bnxt_hwrm_temp_query (bp , & temp );
109
+ if (!rc )
110
+ * val = temp >= bp -> fatal_thresh_temp ;
111
+ return rc ;
69
112
default :
70
113
return - EOPNOTSUPP ;
71
114
}
72
115
}
73
116
74
117
static const struct hwmon_channel_info * bnxt_hwmon_info [] = {
75
- HWMON_CHANNEL_INFO (temp , HWMON_T_INPUT ),
118
+ HWMON_CHANNEL_INFO (temp , HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_CRIT |
119
+ HWMON_T_EMERGENCY | HWMON_T_MAX_ALARM |
120
+ HWMON_T_CRIT_ALARM | HWMON_T_EMERGENCY_ALARM ),
76
121
NULL
77
122
};
78
123
@@ -96,13 +141,11 @@ void bnxt_hwmon_uninit(struct bnxt *bp)
96
141
97
142
void bnxt_hwmon_init (struct bnxt * bp )
98
143
{
99
- struct hwrm_temp_monitor_query_input * req ;
100
144
struct pci_dev * pdev = bp -> pdev ;
101
145
int rc ;
102
146
103
- rc = hwrm_req_init (bp , req , HWRM_TEMP_MONITOR_QUERY );
104
- if (!rc )
105
- rc = hwrm_req_send_silent (bp , req );
147
+ /* temp1_xxx is only sensor, ensure not registered if it will fail */
148
+ rc = bnxt_hwrm_temp_query (bp , NULL );
106
149
if (rc == - EACCES || rc == - EOPNOTSUPP ) {
107
150
bnxt_hwmon_uninit (bp );
108
151
return ;
0 commit comments