015-v6.9-thermal-drivers-sun8i-Dont-fail-probe-due-to-zone-registra.patch 2.7 KB

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