kernel: armsr: Renesas: RZ: Ethernet module and ttySC0
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / build / 200-Revert-wifi-iwlwifi-Use-generic-thermal_zone_get_tri.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 17 Apr 2023 19:42:38 +0200
3 Subject: [PATCH] Revert "wifi: iwlwifi: Use generic thermal_zone_get_trip()
4 function"
5
6 This reverts commit 3d2f20ad46f83b333025f5e8e4afc34be8f13c4c.
7 ---
8
9 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
10 +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
11 @@ -531,7 +531,7 @@ struct iwl_mvm_tt_mgmt {
12 * @tzone: thermal zone device data
13 */
14 struct iwl_mvm_thermal_device {
15 - struct thermal_trip trips[IWL_MAX_DTS_TRIPS];
16 + s16 temp_trips[IWL_MAX_DTS_TRIPS];
17 u8 fw_trips_index[IWL_MAX_DTS_TRIPS];
18 struct thermal_zone_device *tzone;
19 };
20 --- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
21 +++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
22 @@ -573,11 +573,11 @@ int iwl_mvm_send_temp_report_ths_cmd(str
23 * and uncompressed, the FW should get it compressed and sorted
24 */
25
26 - /* compress trips to cmd array, remove uninitialized values*/
27 + /* compress temp_trips to cmd array, remove uninitialized values*/
28 for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) {
29 - if (mvm->tz_device.trips[i].temperature != INT_MIN) {
30 + if (mvm->tz_device.temp_trips[i] != S16_MIN) {
31 cmd.thresholds[idx++] =
32 - cpu_to_le16((s16)(mvm->tz_device.trips[i].temperature / 1000));
33 + cpu_to_le16(mvm->tz_device.temp_trips[i]);
34 }
35 }
36 cmd.num_temps = cpu_to_le32(idx);
37 @@ -593,8 +593,8 @@ int iwl_mvm_send_temp_report_ths_cmd(str
38 */
39 for (i = 0; i < idx; i++) {
40 for (j = 0; j < IWL_MAX_DTS_TRIPS; j++) {
41 - if ((int)(le16_to_cpu(cmd.thresholds[i]) * 1000) ==
42 - mvm->tz_device.trips[j].temperature)
43 + if (le16_to_cpu(cmd.thresholds[i]) ==
44 + mvm->tz_device.temp_trips[j])
45 mvm->tz_device.fw_trips_index[i] = j;
46 }
47 }
48 @@ -638,12 +638,37 @@ out:
49 return ret;
50 }
51
52 +static int iwl_mvm_tzone_get_trip_temp(struct thermal_zone_device *device,
53 + int trip, int *temp)
54 +{
55 + struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;
56 +
57 + if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS)
58 + return -EINVAL;
59 +
60 + *temp = mvm->tz_device.temp_trips[trip] * 1000;
61 +
62 + return 0;
63 +}
64 +
65 +static int iwl_mvm_tzone_get_trip_type(struct thermal_zone_device *device,
66 + int trip, enum thermal_trip_type *type)
67 +{
68 + if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS)
69 + return -EINVAL;
70 +
71 + *type = THERMAL_TRIP_PASSIVE;
72 +
73 + return 0;
74 +}
75 +
76 static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
77 int trip, int temp)
78 {
79 struct iwl_mvm *mvm = thermal_zone_device_priv(device);
80 struct iwl_mvm_thermal_device *tzone;
81 - int ret;
82 + int i, ret;
83 + s16 temperature;
84
85 mutex_lock(&mvm->mutex);
86
87 @@ -653,17 +678,40 @@ static int iwl_mvm_tzone_set_trip_temp(s
88 goto out;
89 }
90
91 + if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS) {
92 + ret = -EINVAL;
93 + goto out;
94 + }
95 +
96 if ((temp / 1000) > S16_MAX) {
97 ret = -EINVAL;
98 goto out;
99 }
100
101 + temperature = (s16)(temp / 1000);
102 tzone = &mvm->tz_device;
103 +
104 if (!tzone) {
105 ret = -EIO;
106 goto out;
107 }
108
109 + /* no updates*/
110 + if (tzone->temp_trips[trip] == temperature) {
111 + ret = 0;
112 + goto out;
113 + }
114 +
115 + /* already existing temperature */
116 + for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) {
117 + if (tzone->temp_trips[i] == temperature) {
118 + ret = -EINVAL;
119 + goto out;
120 + }
121 + }
122 +
123 + tzone->temp_trips[trip] = temperature;
124 +
125 ret = iwl_mvm_send_temp_report_ths_cmd(mvm);
126 out:
127 mutex_unlock(&mvm->mutex);
128 @@ -672,6 +720,8 @@ out:
129
130 static struct thermal_zone_device_ops tzone_ops = {
131 .get_temp = iwl_mvm_tzone_get_temp,
132 + .get_trip_temp = iwl_mvm_tzone_get_trip_temp,
133 + .get_trip_type = iwl_mvm_tzone_get_trip_type,
134 .set_trip_temp = iwl_mvm_tzone_set_trip_temp,
135 };
136
137 @@ -693,8 +743,7 @@ static void iwl_mvm_thermal_zone_registe
138 BUILD_BUG_ON(ARRAY_SIZE(name) >= THERMAL_NAME_LENGTH);
139
140 sprintf(name, "iwlwifi_%u", atomic_inc_return(&counter) & 0xFF);
141 - mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name,
142 - mvm->tz_device.trips,
143 + mvm->tz_device.tzone = thermal_zone_device_register(name,
144 IWL_MAX_DTS_TRIPS,
145 IWL_WRITABLE_TRIPS_MSK,
146 mvm, &tzone_ops,
147 @@ -717,10 +766,8 @@ static void iwl_mvm_thermal_zone_registe
148 /* 0 is a valid temperature,
149 * so initialize the array with S16_MIN which invalid temperature
150 */
151 - for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) {
152 - mvm->tz_device.trips[i].temperature = INT_MIN;
153 - mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE;
154 - }
155 + for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++)
156 + mvm->tz_device.temp_trips[i] = S16_MIN;
157 }
158
159 static int iwl_mvm_tcool_get_max_state(struct thermal_cooling_device *cdev,