Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'thermal-5.16-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 two issues in the thermal core and one in the int340x
thermal driver.

Specifics:

- Replace pr_warn() with pr_warn_once() in user_space_bind() to
reduce kernel log noise (Rafael Wysocki).

- Extend the RFIM mailbox interface in the int340x thermal driver to
return 64 bit values to allow all values returned by the hardware
to be handled correctly (Srinivas Pandruvada).

- Fix possible NULL pointer dereferences in the of_thermal_ family of
functions (Subbaraman Narayanamurthy)"

* tag 'thermal-5.16-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
thermal: Replace pr_warn() with pr_warn_once() in user_space_bind()
thermal: Fix NULL pointer dereferences in of_thermal_ functions
thermal/drivers/int340x: processor_thermal: Suppot 64 bit RFIM responses

+27 -20
+2 -2
drivers/thermal/gov_user_space.c
··· 17 17 18 18 static int user_space_bind(struct thermal_zone_device *tz) 19 19 { 20 - pr_warn("Userspace governor deprecated: use thermal netlink " \ 21 - "notification instead\n"); 20 + pr_warn_once("Userspace governor deprecated: use thermal netlink " \ 21 + "notification instead\n"); 22 22 23 23 return 0; 24 24 }
+1 -1
drivers/thermal/intel/int340x_thermal/processor_thermal_device.h
··· 80 80 int proc_thermal_mbox_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv); 81 81 void proc_thermal_mbox_remove(struct pci_dev *pdev); 82 82 83 - int processor_thermal_send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u32 *cmd_resp); 83 + int processor_thermal_send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u64 *cmd_resp); 84 84 int proc_thermal_add(struct device *dev, struct proc_thermal_device *priv); 85 85 void proc_thermal_remove(struct proc_thermal_device *proc_priv); 86 86 int proc_thermal_suspend(struct device *dev);
+13 -9
drivers/thermal/intel/int340x_thermal/processor_thermal_mbox.c
··· 23 23 24 24 static DEFINE_MUTEX(mbox_lock); 25 25 26 - static int send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u32 *cmd_resp) 26 + static int send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u64 *cmd_resp) 27 27 { 28 28 struct proc_thermal_device *proc_priv; 29 29 u32 retries, data; ··· 68 68 goto unlock_mbox; 69 69 } 70 70 71 - if (cmd_id == MBOX_CMD_WORKLOAD_TYPE_READ) { 72 - data = readl((void __iomem *) (proc_priv->mmio_base + MBOX_OFFSET_DATA)); 73 - *cmd_resp = data & 0xff; 74 - } 75 - 76 71 ret = 0; 72 + 73 + if (!cmd_resp) 74 + break; 75 + 76 + if (cmd_id == MBOX_CMD_WORKLOAD_TYPE_READ) 77 + *cmd_resp = readl((void __iomem *) (proc_priv->mmio_base + MBOX_OFFSET_DATA)); 78 + else 79 + *cmd_resp = readq((void __iomem *) (proc_priv->mmio_base + MBOX_OFFSET_DATA)); 80 + 77 81 break; 78 82 } while (--retries); 79 83 ··· 86 82 return ret; 87 83 } 88 84 89 - int processor_thermal_send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u32 *cmd_resp) 85 + int processor_thermal_send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u64 *cmd_resp) 90 86 { 91 87 return send_mbox_cmd(pdev, cmd_id, cmd_data, cmd_resp); 92 88 } ··· 157 153 char *buf) 158 154 { 159 155 struct pci_dev *pdev = to_pci_dev(dev); 160 - u32 cmd_resp; 156 + u64 cmd_resp; 161 157 int ret; 162 158 163 159 ret = send_mbox_cmd(pdev, MBOX_CMD_WORKLOAD_TYPE_READ, 0, &cmd_resp); ··· 191 187 192 188 int proc_thermal_mbox_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv) 193 189 { 194 - u32 cmd_resp; 190 + u64 cmd_resp; 195 191 int ret; 196 192 197 193 /* Check if there is a mailbox support, if fails return success */
+5 -5
drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c
··· 195 195 const char *buf, size_t count) 196 196 { 197 197 u16 cmd_id = 0x0008; 198 - u32 cmd_resp; 198 + u64 cmd_resp; 199 199 u32 input; 200 200 int ret; 201 201 ··· 215 215 char *buf) 216 216 { 217 217 u16 cmd_id = 0x0007; 218 - u32 cmd_resp; 218 + u64 cmd_resp; 219 219 int ret; 220 220 221 221 ret = processor_thermal_send_mbox_cmd(to_pci_dev(dev), cmd_id, 0, &cmd_resp); 222 222 if (ret) 223 223 return ret; 224 224 225 - return sprintf(buf, "%u\n", cmd_resp); 225 + return sprintf(buf, "%llu\n", cmd_resp); 226 226 } 227 227 228 228 static ssize_t ddr_data_rate_show(struct device *dev, ··· 230 230 char *buf) 231 231 { 232 232 u16 cmd_id = 0x0107; 233 - u32 cmd_resp; 233 + u64 cmd_resp; 234 234 int ret; 235 235 236 236 ret = processor_thermal_send_mbox_cmd(to_pci_dev(dev), cmd_id, 0, &cmd_resp); 237 237 if (ret) 238 238 return ret; 239 239 240 - return sprintf(buf, "%u\n", cmd_resp); 240 + return sprintf(buf, "%llu\n", cmd_resp); 241 241 } 242 242 243 243 static DEVICE_ATTR_RW(rfi_restriction);
+6 -3
drivers/thermal/thermal_of.c
··· 89 89 { 90 90 struct __thermal_zone *data = tz->devdata; 91 91 92 - if (!data->ops->get_temp) 92 + if (!data->ops || !data->ops->get_temp) 93 93 return -EINVAL; 94 94 95 95 return data->ops->get_temp(data->sensor_data, temp); ··· 186 186 { 187 187 struct __thermal_zone *data = tz->devdata; 188 188 189 + if (!data->ops || !data->ops->set_emul_temp) 190 + return -EINVAL; 191 + 189 192 return data->ops->set_emul_temp(data->sensor_data, temp); 190 193 } 191 194 ··· 197 194 { 198 195 struct __thermal_zone *data = tz->devdata; 199 196 200 - if (!data->ops->get_trend) 197 + if (!data->ops || !data->ops->get_trend) 201 198 return -EINVAL; 202 199 203 200 return data->ops->get_trend(data->sensor_data, trip, trend); ··· 304 301 if (trip >= data->ntrips || trip < 0) 305 302 return -EDOM; 306 303 307 - if (data->ops->set_trip_temp) { 304 + if (data->ops && data->ops->set_trip_temp) { 308 305 int ret; 309 306 310 307 ret = data->ops->set_trip_temp(data->sensor_data, trip, temp);