384bf55084f307509f8eaa4adc5d49e972e7e171
[openwrt/staging/xback.git] /
1 From 9ac53d5532cc4bb595bbee86ccba2172ccc336c3 Mon Sep 17 00:00:00 2001
2 From: Mark Brown <broonie@kernel.org>
3 Date: Tue, 23 Jan 2024 23:33:07 +0000
4 Subject: [PATCH] thermal/drivers/sun8i: Don't fail probe due to zone
5 registration failure
6
7 Currently the sun8i thermal driver will fail to probe if any of the
8 thermal zones it is registering fails to register with the thermal core.
9 Since we currently do not define any trip points for the GPU thermal
10 zones on at least A64 or H5 this means that we have no thermal support
11 on these platforms:
12
13 [ 1.698703] thermal_sys: Failed to find 'trips' node
14 [ 1.698707] thermal_sys: Failed to find trip points for thermal-sensor id=1
15
16 even though the main CPU thermal zone on both SoCs is fully configured.
17 This does not seem ideal, while we may not be able to use all the zones
18 it seems better to have those zones which are usable be operational.
19 Instead just carry on registering zones if we get any non-deferral
20 error, allowing use of those zones which are usable.
21
22 This means that we also need to update the interrupt handler to not
23 attempt to notify the core for events on zones which we have not
24 registered, I didn't see an ability to mask individual interrupts and
25 I would expect that interrupts would still be indicated in the ISR even
26 if they were masked.
27
28 Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
29 Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
30 Signed-off-by: Mark Brown <broonie@kernel.org>
31 Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
32 Link: https://lore.kernel.org/r/20240123-thermal-sun8i-registration-v3-1-3e5771b1bbdd@kernel.org
33 ---
34 drivers/thermal/sun8i_thermal.c | 16 ++++++++++++++--
35 1 file changed, 14 insertions(+), 2 deletions(-)
36
37 --- a/drivers/thermal/sun8i_thermal.c
38 +++ b/drivers/thermal/sun8i_thermal.c
39 @@ -197,6 +197,9 @@ static irqreturn_t sun8i_irq_thread(int
40 int i;
41
42 for_each_set_bit(i, &irq_bitmap, tmdev->chip->sensor_num) {
43 + /* We allow some zones to not register. */
44 + if (IS_ERR(tmdev->sensor[i].tzd))
45 + continue;
46 thermal_zone_device_update(tmdev->sensor[i].tzd,
47 THERMAL_EVENT_UNSPECIFIED);
48 }
49 @@ -531,8 +534,17 @@ static int sun8i_ths_register(struct ths
50 i,
51 &tmdev->sensor[i],
52 &ths_ops);
53 - if (IS_ERR(tmdev->sensor[i].tzd))
54 - return PTR_ERR(tmdev->sensor[i].tzd);
55 +
56 + /*
57 + * If an individual zone fails to register for reasons
58 + * other than probe deferral (eg, a bad DT) then carry
59 + * on, other zones might register successfully.
60 + */
61 + if (IS_ERR(tmdev->sensor[i].tzd)) {
62 + if (PTR_ERR(tmdev->sensor[i].tzd) == -EPROBE_DEFER)
63 + return PTR_ERR(tmdev->sensor[i].tzd);
64 + continue;
65 + }
66
67 if (devm_thermal_add_hwmon_sysfs(tmdev->sensor[i].tzd))
68 dev_warn(tmdev->dev,