More thermal control updates for 5.20-rc1
- Fix NULL pointer dereference in the thermal sysfs interface that results from an error code path mishandling (Rafael Wysocki). - Drop COMPILE_TEST dependency that's not needed any more from two thermal Kconfig entries (Jean Delvare). - Make the Intel TCC cooling driver support Alder Lake-N and Raptor Lake-P (Sumeet Pawnikar). - Fix possible path truncations in the tmon utility (Florian Fainelli). -----BEGIN PGP SIGNATURE----- iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmLxT1USHHJqd0Byand5 c29ja2kubmV0AAoJEILEb/54YlRxj5UP/j2uxSAZC0OpyS/wRP9PmzTJKaUdofD8 BhQ6jvVu1wcQ+zG2MGrLUw9mOTEfd6dDfDUMnwiSAoHKvtUpEM7hsRa9wEGjXZoN mJYzRFtWT8cqNA4WaVV9UjmTLVRvswXQ25ExumydCoXMHzk8ZSwkslq0rIfPlHWa NpqraiXdmqG5qFlfQR1AhnLF3IXbogrxWbXqJRDatxwb7m4VEqy7TKQYKBozpWu6 0SfnGOrW6WqL5YaNCO2Q2cbRNRlVnS1gaGTfowMGAR5IRRz0MYmoHAvRIQzpigJI VaTShIh3LQi+ud2dHsyeBZn95r35JgUQB716CHsZkkPB7WJx+Jj68K/u+TpsV8bV KHTS7H1if2jugv0duC/ZSMqrN9Kqam2rjPnAtjK+Eo6gzWYP77Ha+yjkHTcWfICB b7WargRB3tqj9Rsczl6bozQ4x6djYZAB4I0dZffdenbuees7U4qsmrSi2Z/3jta1 zZz5yPM15ZaESGAKr0ECiHD45Lgf7+ZCqS0oMMVNIaCXQyDUInpaR28t9YLQeIg/ h8uPIJ+AONdgNs6XKZ96AGpOZHJG+pszSIMVM8bPYCsy56bXBDI8m2NVlKXp58WF N4fimjv97MCDLxxua6SuwWVhy8FHlv+OW3zCAiGJ2mOHvoO2E/nLoeOQkC//03zn MIayMXpCTYRM =8JEE -----END PGP SIGNATURE----- Merge tag 'thermal-5.20-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm Pull more thermal control updates from Rafael Wysocki: "These fix an error code path issue leading to a NULL pointer dereference, drop Kconfig dependencies that are not needed any more after recent changes, add CPU IDs for new chips to a driver and fix up the tmon utility. Specifics: - Fix NULL pointer dereference in the thermal sysfs interface that results from an error code path mishandling (Rafael Wysocki). - Drop COMPILE_TEST dependency that's not needed any more from two thermal Kconfig entries (Jean Delvare). - Make the Intel TCC cooling driver support Alder Lake-N and Raptor Lake-P (Sumeet Pawnikar). - Fix possible path truncations in the tmon utility (Florian Fainelli)" * tag 'thermal-5.20-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: tools/thermal: Fix possible path truncations thermal: Drop obsolete dependency on COMPILE_TEST thermal: sysfs: Fix cooling_device_stats_setup() error code path thermal: intel: Add TCC cooling support for Alder Lake-N and Raptor Lake-P
This commit is contained in:
commit
033c88d58b
|
@ -221,7 +221,7 @@ config THERMAL_EMULATION
|
|||
|
||||
config THERMAL_MMIO
|
||||
tristate "Generic Thermal MMIO driver"
|
||||
depends on OF || COMPILE_TEST
|
||||
depends on OF
|
||||
depends on HAS_IOMEM
|
||||
help
|
||||
This option enables the generic thermal MMIO driver that will use
|
||||
|
@ -496,7 +496,7 @@ config SPRD_THERMAL
|
|||
|
||||
config KHADAS_MCU_FAN_THERMAL
|
||||
tristate "Khadas MCU controller FAN cooling support"
|
||||
depends on OF || COMPILE_TEST
|
||||
depends on OF
|
||||
depends on MFD_KHADAS_MCU
|
||||
select MFD_CORE
|
||||
select REGMAP
|
||||
|
|
|
@ -81,7 +81,9 @@ static const struct x86_cpu_id tcc_ids[] __initconst = {
|
|||
X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE, NULL),
|
||||
X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE, NULL),
|
||||
X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_L, NULL),
|
||||
X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_N, NULL),
|
||||
X86_MATCH_INTEL_FAM6_MODEL(RAPTORLAKE, NULL),
|
||||
X86_MATCH_INTEL_FAM6_MODEL(RAPTORLAKE_P, NULL),
|
||||
{}
|
||||
};
|
||||
|
||||
|
|
|
@ -813,12 +813,13 @@ static const struct attribute_group cooling_device_stats_attr_group = {
|
|||
|
||||
static void cooling_device_stats_setup(struct thermal_cooling_device *cdev)
|
||||
{
|
||||
const struct attribute_group *stats_attr_group = NULL;
|
||||
struct cooling_dev_stats *stats;
|
||||
unsigned long states;
|
||||
int var;
|
||||
|
||||
if (cdev->ops->get_max_state(cdev, &states))
|
||||
return;
|
||||
goto out;
|
||||
|
||||
states++; /* Total number of states is highest state + 1 */
|
||||
|
||||
|
@ -828,7 +829,7 @@ static void cooling_device_stats_setup(struct thermal_cooling_device *cdev)
|
|||
|
||||
stats = kzalloc(var, GFP_KERNEL);
|
||||
if (!stats)
|
||||
return;
|
||||
goto out;
|
||||
|
||||
stats->time_in_state = (ktime_t *)(stats + 1);
|
||||
stats->trans_table = (unsigned int *)(stats->time_in_state + states);
|
||||
|
@ -838,9 +839,12 @@ static void cooling_device_stats_setup(struct thermal_cooling_device *cdev)
|
|||
|
||||
spin_lock_init(&stats->lock);
|
||||
|
||||
stats_attr_group = &cooling_device_stats_attr_group;
|
||||
|
||||
out:
|
||||
/* Fill the empty slot left in cooling_device_attr_groups */
|
||||
var = ARRAY_SIZE(cooling_device_attr_groups) - 2;
|
||||
cooling_device_attr_groups[var] = &cooling_device_stats_attr_group;
|
||||
cooling_device_attr_groups[var] = stats_attr_group;
|
||||
}
|
||||
|
||||
static void cooling_device_stats_destroy(struct thermal_cooling_device *cdev)
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <stdint.h>
|
||||
#include <dirent.h>
|
||||
#include <libintl.h>
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <syslog.h>
|
||||
|
@ -33,9 +34,9 @@ int sysfs_set_ulong(char *path, char *filename, unsigned long val)
|
|||
{
|
||||
FILE *fd;
|
||||
int ret = -1;
|
||||
char filepath[256];
|
||||
char filepath[PATH_MAX + 2]; /* NUL and '/' */
|
||||
|
||||
snprintf(filepath, 256, "%s/%s", path, filename);
|
||||
snprintf(filepath, sizeof(filepath), "%s/%s", path, filename);
|
||||
|
||||
fd = fopen(filepath, "w");
|
||||
if (!fd) {
|
||||
|
@ -57,9 +58,9 @@ static int sysfs_get_ulong(char *path, char *filename, unsigned long *p_ulong)
|
|||
{
|
||||
FILE *fd;
|
||||
int ret = -1;
|
||||
char filepath[256];
|
||||
char filepath[PATH_MAX + 2]; /* NUL and '/' */
|
||||
|
||||
snprintf(filepath, 256, "%s/%s", path, filename);
|
||||
snprintf(filepath, sizeof(filepath), "%s/%s", path, filename);
|
||||
|
||||
fd = fopen(filepath, "r");
|
||||
if (!fd) {
|
||||
|
@ -76,9 +77,9 @@ static int sysfs_get_string(char *path, char *filename, char *str)
|
|||
{
|
||||
FILE *fd;
|
||||
int ret = -1;
|
||||
char filepath[256];
|
||||
char filepath[PATH_MAX + 2]; /* NUL and '/' */
|
||||
|
||||
snprintf(filepath, 256, "%s/%s", path, filename);
|
||||
snprintf(filepath, sizeof(filepath), "%s/%s", path, filename);
|
||||
|
||||
fd = fopen(filepath, "r");
|
||||
if (!fd) {
|
||||
|
@ -199,8 +200,8 @@ static int find_tzone_cdev(struct dirent *nl, char *tz_name,
|
|||
{
|
||||
unsigned long trip_instance = 0;
|
||||
char cdev_name_linked[256];
|
||||
char cdev_name[256];
|
||||
char cdev_trip_name[256];
|
||||
char cdev_name[PATH_MAX];
|
||||
char cdev_trip_name[PATH_MAX];
|
||||
int cdev_id;
|
||||
|
||||
if (nl->d_type == DT_LNK) {
|
||||
|
@ -213,7 +214,8 @@ static int find_tzone_cdev(struct dirent *nl, char *tz_name,
|
|||
return -EINVAL;
|
||||
}
|
||||
/* find the link to real cooling device record binding */
|
||||
snprintf(cdev_name, 256, "%s/%s", tz_name, nl->d_name);
|
||||
snprintf(cdev_name, sizeof(cdev_name) - 2, "%s/%s",
|
||||
tz_name, nl->d_name);
|
||||
memset(cdev_name_linked, 0, sizeof(cdev_name_linked));
|
||||
if (readlink(cdev_name, cdev_name_linked,
|
||||
sizeof(cdev_name_linked) - 1) != -1) {
|
||||
|
@ -226,8 +228,8 @@ static int find_tzone_cdev(struct dirent *nl, char *tz_name,
|
|||
/* find the trip point in which the cdev is binded to
|
||||
* in this tzone
|
||||
*/
|
||||
snprintf(cdev_trip_name, 256, "%s%s", nl->d_name,
|
||||
"_trip_point");
|
||||
snprintf(cdev_trip_name, sizeof(cdev_trip_name) - 1,
|
||||
"%s%s", nl->d_name, "_trip_point");
|
||||
sysfs_get_ulong(tz_name, cdev_trip_name,
|
||||
&trip_instance);
|
||||
/* validate trip point range, e.g. trip could return -1
|
||||
|
|
Loading…
Reference in New Issue