Skip to content

Commit 7b14580

Browse files
spandruvadarafaeljw
authored andcommitted
thermal: int340x: Mode setting with new OS handshake
With the new OS handshake introduced by commit: "c7ff29763989 ("thermal: int340x: Update OS policy capability handshake")", the "enabled" thermal zone mode doesn't work in the same way as previously. The "enabled" mode fails with -EINVAL when the new handshake is used. To address this issue, when the new OS UUID mask is set: - When the mode is "enabled", return 0 as the firmware already has the latest policy mask. - When the mode is "disabled", update the firmware with the UUID mask of zero. This way, the firmware can take over the thermal control. Also reset the OS UUID mask, which allows user space to update with new set of policies. Fixes: c7ff297 ("thermal: int340x: Update OS policy capability handshake") Signed-off-by: Srinivas Pandruvada <[email protected]> [ rjw: Changelog edits, removed unneeded parens ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent c5eb0a6 commit 7b14580

File tree

1 file changed

+32
-16
lines changed

1 file changed

+32
-16
lines changed

drivers/thermal/intel/int340x_thermal/int3400_thermal.c

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,31 @@ static int int3400_thermal_run_osc(acpi_handle handle, char *uuid_str, int *enab
194194
return result;
195195
}
196196

197+
static int set_os_uuid_mask(struct int3400_thermal_priv *priv, u32 mask)
198+
{
199+
int cap = 0;
200+
201+
/*
202+
* Capability bits:
203+
* Bit 0: set to 1 to indicate DPTF is active
204+
* Bi1 1: set to 1 to active cooling is supported by user space daemon
205+
* Bit 2: set to 1 to passive cooling is supported by user space daemon
206+
* Bit 3: set to 1 to critical trip is handled by user space daemon
207+
*/
208+
if (mask)
209+
cap = (priv->os_uuid_mask << 1) | 0x01;
210+
211+
return int3400_thermal_run_osc(priv->adev->handle,
212+
"b23ba85d-c8b7-3542-88de-8de2ffcfd698",
213+
&cap);
214+
}
215+
197216
static ssize_t current_uuid_store(struct device *dev,
198217
struct device_attribute *attr,
199218
const char *buf, size_t count)
200219
{
201220
struct int3400_thermal_priv *priv = dev_get_drvdata(dev);
202-
int i;
221+
int ret, i;
203222

204223
for (i = 0; i < INT3400_THERMAL_MAXIMUM_UUID; ++i) {
205224
if (!strncmp(buf, int3400_thermal_uuids[i],
@@ -231,19 +250,7 @@ static ssize_t current_uuid_store(struct device *dev,
231250
}
232251

233252
if (priv->os_uuid_mask) {
234-
int cap, ret;
235-
236-
/*
237-
* Capability bits:
238-
* Bit 0: set to 1 to indicate DPTF is active
239-
* Bi1 1: set to 1 to active cooling is supported by user space daemon
240-
* Bit 2: set to 1 to passive cooling is supported by user space daemon
241-
* Bit 3: set to 1 to critical trip is handled by user space daemon
242-
*/
243-
cap = ((priv->os_uuid_mask << 1) | 0x01);
244-
ret = int3400_thermal_run_osc(priv->adev->handle,
245-
"b23ba85d-c8b7-3542-88de-8de2ffcfd698",
246-
&cap);
253+
ret = set_os_uuid_mask(priv, priv->os_uuid_mask);
247254
if (ret)
248255
return ret;
249256
}
@@ -469,17 +476,26 @@ static int int3400_thermal_change_mode(struct thermal_zone_device *thermal,
469476
if (mode != thermal->mode) {
470477
int enabled;
471478

479+
enabled = mode == THERMAL_DEVICE_ENABLED;
480+
481+
if (priv->os_uuid_mask) {
482+
if (!enabled) {
483+
priv->os_uuid_mask = 0;
484+
result = set_os_uuid_mask(priv, priv->os_uuid_mask);
485+
}
486+
goto eval_odvp;
487+
}
488+
472489
if (priv->current_uuid_index < 0 ||
473490
priv->current_uuid_index >= INT3400_THERMAL_MAXIMUM_UUID)
474491
return -EINVAL;
475492

476-
enabled = (mode == THERMAL_DEVICE_ENABLED);
477493
result = int3400_thermal_run_osc(priv->adev->handle,
478494
int3400_thermal_uuids[priv->current_uuid_index],
479495
&enabled);
480496
}
481497

482-
498+
eval_odvp:
483499
evaluate_odvp(priv);
484500

485501
return result;

0 commit comments

Comments
 (0)