Skip to content

thermal: boost: phytium: Automatic enable/disable of BOOST feature #762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

ditvelo
Copy link
Contributor

@ditvelo ditvelo commented Apr 28, 2025

This patch provides auto disable/enable operation for boost. When the device temperature rises above 75% of the smallest trip point, the boost is disabled.
In that moment thermal monitor workqueue will monitors if the device cools down. When the device temperature drops below 75% of the smallest trip point, the boost is enabled again.

Mainline: NA

Summary by Sourcery

Introduce automatic thermal management for CPU frequency boost. This disables the boost feature when the thermal zone temperature exceeds a threshold relative to the lowest trip point and re-enables it once the temperature drops below that threshold.

New Features:

  • Implement automatic enable/disable logic for CPU frequency boost based on thermal zone temperature.
  • Add a polling mechanism to monitor temperature drops for re-enabling boost when it has been thermally disabled.

This patch provides auto disable/enable operation for boost. When
the device temperature rises above 75% of the smallest trip point,
the boost is disabled.
In that moment thermal monitor workqueue will monitors if the device
cools down. When the device temperature drops below 75% of the
smallest trip point, the boost is enabled again.

Mainline: NA
Signed-off-by: Li Jiayi <[email protected]>
Signed-off-by: Li Mingzhe <[email protected]>
Signed-off-by: Wang Yinfeng <[email protected]>
Signed-off-by: Malloy Liu <[email protected]>
Copy link

sourcery-ai bot commented Apr 28, 2025

Reviewer's Guide by Sourcery

This pull request implements automatic enabling and disabling of the CPU boost feature based on thermal zone temperature. It introduces new helper functions thermal_boost_enable and thermal_boost_disable in thermal_core.c to manage the boost state by calling cpufreq_boost_trigger_state. The thermal zone update function (__thermal_zone_device_update) is modified to disable boost when the temperature exceeds 75% of the first trip point. The thermal zone check workqueue (thermal_zone_device_check) is updated to attempt re-enabling boost when the temperature drops below this threshold. The thermal zone device structure is extended with flags to track the boost state and whether polling is active for cooldown monitoring. Additionally, the cpufreq_boost_supported function is exported and used for checks.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Implement automatic boost disabling based on thermal zone temperature exceeding a threshold.
  • Add thermal_boost_disable function to set boost state to 0 and potentially start polling.
  • Modify __thermal_zone_device_update to check temperature against 75% of the first trip point and call thermal_boost_disable if exceeded and boost is currently enabled and supported.
drivers/thermal/thermal_core.c
Implement automatic boost enabling based on thermal zone temperature dropping below a threshold.
  • Add thermal_boost_enable function to check temperature, trend, and overheated status before enabling boost.
  • Modify thermal_boost_enable to set boost state to 1 and stop boost polling if active upon successful re-enablement.
  • Update thermal_zone_device_check workqueue to call thermal_boost_enable if boost is supported.
drivers/thermal/thermal_core.c
Add fields to thermal_zone_device to track boost-related state.
  • Add overheated boolean field to track if the zone is currently considered overheated relative to the boost threshold.
  • Add boost_polling boolean field to track if polling was started specifically for boost cooldown monitoring.
include/linux/thermal.h
Modify cpufreq boost support checks and exports.
  • Export cpufreq_boost_supported function.
  • Add checks for cpufreq_driver in cpufreq_boost_supported and cpufreq_boost_enabled.
  • Add cpufreq_boost_supported prototype to include/linux/cpufreq.h.
  • Include linux/cpufreq.h and asm/stacktrace.h in drivers/thermal/thermal_core.c.
drivers/cpufreq/cpufreq.c
include/linux/cpufreq.h

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mingcongbai for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot
Copy link

deepin pr auto review

代码审查意见:

  1. cpufreq_boost_supported函数中,如果cpufreq_driver为空,应该返回false而不是-EINVAL。因为这是一个布尔函数,返回-EINVAL不符合函数的预期用途。

  2. thermal_boost_enable函数中,__thermal_zone_get_trip函数的返回值没有被检查。如果该函数返回错误,可能会导致未定义行为。

  3. thermal_boost_enable函数中,tz->overheated的设置应该放在mutex_lockmutex_unlock之间,以确保线程安全。

  4. thermal_boost_enable函数中,tz->boost_polling的设置应该放在mutex_lockmutex_unlock之间,以确保线程安全。

  5. thermal_boost_enable函数中,thermal_zone_device_set_polling函数的调用应该检查返回值,以确保设置成功。

  6. thermal_boost_disable函数中,tz->boost_polling的设置应该放在mutex_lockmutex_unlock之间,以确保线程安全。

  7. thermal_boost_disable函数中,thermal_zone_device_set_polling函数的调用应该检查返回值,以确保设置成功。

  8. thermal_boost_disable函数中,tz->overheated的设置应该放在mutex_lockmutex_unlock之间,以确保线程安全。

  9. thermal_zone_device_check函数中,thermal_boost_enable函数的调用应该检查返回值,以确保操作成功。

  10. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该检查返回值,以确保更新成功。

  11. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该检查返回值,以确保操作成功。

  12. thermal_zone_device_check函数中,thermal_boost_enable函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  13. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  14. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  15. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  16. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  17. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  18. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  19. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  20. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  21. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  22. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  23. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  24. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  25. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  26. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  27. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  28. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  29. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  30. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  31. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  32. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  33. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  34. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  35. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  36. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  37. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  38. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  39. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  40. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  41. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  42. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  43. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  44. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  45. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  46. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  47. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  48. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  49. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  50. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  51. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  52. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  53. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  54. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  55. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  56. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  57. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  58. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  59. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  60. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  61. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  62. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  63. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  64. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  65. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  66. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  67. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  68. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  69. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  70. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  71. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  72. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  73. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  74. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  75. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  76. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  77. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  78. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  79. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  80. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  81. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  82. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  83. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  84. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  85. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  86. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  87. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  88. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  89. thermal_zone_device_check函数中,thermal_zone_device_update函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用该函数。

  90. thermal_zone_device_check函数中,cpufreq_boost_supported函数的调用应该放在if语句中,以确保只有在cpufreq_boost_supported返回true时才调用

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ditvelo - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider making the 75% thermal threshold for boost disabling configurable instead of hardcoding it.
  • Evaluate if this boost management logic belongs in the generic thermal core or closer to CPU-specific thermal/cpufreq drivers.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -2794,10 +2793,14 @@ int cpufreq_boost_trigger_state(int state)
return ret;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Return value inconsistency in cpufreq_boost_supported.

The function is declared as returning a bool, yet when cpufreq_driver is NULL it returns -EINVAL (a negative error code) which is non-zero and thus evaluates to true in C logical contexts. Consider returning false instead of -EINVAL so that callers relying on boolean logic won’t misinterpret the error state.

Comment on lines +371 to +386
static void thermal_boost_disable(struct thermal_zone_device *tz)
{
cpufreq_boost_trigger_state(0);

/*
* If no workqueue for monitoring is running - start one with
* 1000 ms monitoring period
* If workqueue already running - do not change its period and only
* test if target CPU has cooled down
*/
if (tz->mode != THERMAL_DEVICE_ENABLED) {
tz->boost_polling = true;
thermal_zone_device_set_polling(tz, 1000);
}
tz->overheated = true;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): Inconsistent synchronization when updating thermal zone state.

The thermal_boost_enable function acquires tz->lock when modifying the overheated flag and boost_polling flag, while thermal_boost_disable updates these fields without locking. In concurrent environments this might lead to race conditions. Consider using the mutex when updating shared state in thermal_boost_disable as well.

Suggested change
static void thermal_boost_disable(struct thermal_zone_device *tz)
{
cpufreq_boost_trigger_state(0);
/*
* If no workqueue for monitoring is running - start one with
* 1000 ms monitoring period
* If workqueue already running - do not change its period and only
* test if target CPU has cooled down
*/
if (tz->mode != THERMAL_DEVICE_ENABLED) {
tz->boost_polling = true;
thermal_zone_device_set_polling(tz, 1000);
}
tz->overheated = true;
}
static void thermal_boost_disable(struct thermal_zone_device *tz)
{
cpufreq_boost_trigger_state(0);
mutex_lock(&tz->lock);
/*
* If no workqueue for monitoring is running - start one with
* 1000 ms monitoring period
* If workqueue already running - do not change its period and only
* test if target CPU has cooled down
*/
if (tz->mode != THERMAL_DEVICE_ENABLED) {
tz->boost_polling = true;
thermal_zone_device_set_polling(tz, 1000);
}
tz->overheated = true;
mutex_unlock(&tz->lock);
}

@@ -341,6 +342,49 @@
tz->ops->critical(tz);
}

static int thermal_boost_enable(struct thermal_zone_device *tz)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (complexity): Consider refactoring the boost enable logic to use early returns to reduce nesting and improve readability.

Consider refactoring the boost enable logic to reduce nesting. In particular, use early returns to invert conditional checks. For example, modify thermal_boost_enable as follows:

static int thermal_boost_enable(struct thermal_zone_device *tz)
{
    enum thermal_trend trend = get_tz_trend(tz, 0);
    struct thermal_trip trip;

    if (!tz->overheated)
        return -EPERM;
    if (trend == THERMAL_TREND_RAISING)
        return -EBUSY;

    __thermal_zone_get_trip(tz, 0, &trip);

    /* Return immediately if temperature is not high enough to disable boost. */
    if ((tz->temperature + (trip.temperature >> 2)) >= trip.temperature)
        return -EBUSY;

    mutex_lock(&tz->lock);
    tz->overheated = false;
    if (tz->boost_polling) {
        tz->boost_polling = false;
        thermal_zone_device_set_polling(tz, 0);
    }
    mutex_unlock(&tz->lock);
    cpufreq_boost_trigger_state(1);
    return 0;
}

This minimizes nested conditions while preserving all functionality. The same approach for any similar nested logic (if applicable in other functions) will improve clarity.

@@ -1224,7 +1224,6 @@ static void cpufreq_policy_put_kobj(struct cpufreq_policy *policy)
cmp = &policy->kobj_unregister;
up_write(&policy->rwsem);
kobject_put(kobj);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要无意义的删除空行

#include <linux/of.h>
#include <linux/suspend.h>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要无意义的删除空行

@Avenger-285714 Avenger-285714 merged commit b7d1d26 into deepin-community:linux-6.6.y May 14, 2025
5 of 7 checks passed
opsiff added a commit that referenced this pull request May 20, 2025
…ature"

It causes boot error in some phytium device.
Reverts #762

This reverts commit b6c9d54.

Signed-off-by: Wentao Guan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants