Skip to content

Commit 8810075

Browse files
committed
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
2 parents d422555 + 61988e0 commit 8810075

File tree

5 files changed

+27
-20
lines changed

5 files changed

+27
-20
lines changed

drivers/thermal/gov_user_space.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
static int user_space_bind(struct thermal_zone_device *tz)
1919
{
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");
2222

2323
return 0;
2424
}

drivers/thermal/intel/int340x_thermal/processor_thermal_device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void proc_thermal_rfim_remove(struct pci_dev *pdev);
8080
int proc_thermal_mbox_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
8181
void proc_thermal_mbox_remove(struct pci_dev *pdev);
8282

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);
8484
int proc_thermal_add(struct device *dev, struct proc_thermal_device *priv);
8585
void proc_thermal_remove(struct proc_thermal_device *proc_priv);
8686
int proc_thermal_suspend(struct device *dev);

drivers/thermal/intel/int340x_thermal/processor_thermal_mbox.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
static DEFINE_MUTEX(mbox_lock);
2525

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)
2727
{
2828
struct proc_thermal_device *proc_priv;
2929
u32 retries, data;
@@ -68,12 +68,16 @@ static int send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u32 *cm
6868
goto unlock_mbox;
6969
}
7070

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-
7671
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+
7781
break;
7882
} while (--retries);
7983

@@ -82,7 +86,7 @@ static int send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u32 *cm
8286
return ret;
8387
}
8488

85-
int processor_thermal_send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u32 *cmd_resp)
89+
int processor_thermal_send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u64 *cmd_resp)
8690
{
8791
return send_mbox_cmd(pdev, cmd_id, cmd_data, cmd_resp);
8892
}
@@ -153,7 +157,7 @@ static ssize_t workload_type_show(struct device *dev,
153157
char *buf)
154158
{
155159
struct pci_dev *pdev = to_pci_dev(dev);
156-
u32 cmd_resp;
160+
u64 cmd_resp;
157161
int ret;
158162

159163
ret = send_mbox_cmd(pdev, MBOX_CMD_WORKLOAD_TYPE_READ, 0, &cmd_resp);
@@ -187,7 +191,7 @@ static bool workload_req_created;
187191

188192
int proc_thermal_mbox_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv)
189193
{
190-
u32 cmd_resp;
194+
u64 cmd_resp;
191195
int ret;
192196

193197
/* Check if there is a mailbox support, if fails return success */

drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static ssize_t rfi_restriction_store(struct device *dev,
195195
const char *buf, size_t count)
196196
{
197197
u16 cmd_id = 0x0008;
198-
u32 cmd_resp;
198+
u64 cmd_resp;
199199
u32 input;
200200
int ret;
201201

@@ -215,29 +215,29 @@ static ssize_t rfi_restriction_show(struct device *dev,
215215
char *buf)
216216
{
217217
u16 cmd_id = 0x0007;
218-
u32 cmd_resp;
218+
u64 cmd_resp;
219219
int ret;
220220

221221
ret = processor_thermal_send_mbox_cmd(to_pci_dev(dev), cmd_id, 0, &cmd_resp);
222222
if (ret)
223223
return ret;
224224

225-
return sprintf(buf, "%u\n", cmd_resp);
225+
return sprintf(buf, "%llu\n", cmd_resp);
226226
}
227227

228228
static ssize_t ddr_data_rate_show(struct device *dev,
229229
struct device_attribute *attr,
230230
char *buf)
231231
{
232232
u16 cmd_id = 0x0107;
233-
u32 cmd_resp;
233+
u64 cmd_resp;
234234
int ret;
235235

236236
ret = processor_thermal_send_mbox_cmd(to_pci_dev(dev), cmd_id, 0, &cmd_resp);
237237
if (ret)
238238
return ret;
239239

240-
return sprintf(buf, "%u\n", cmd_resp);
240+
return sprintf(buf, "%llu\n", cmd_resp);
241241
}
242242

243243
static DEVICE_ATTR_RW(rfi_restriction);

drivers/thermal/thermal_of.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz,
8989
{
9090
struct __thermal_zone *data = tz->devdata;
9191

92-
if (!data->ops->get_temp)
92+
if (!data->ops || !data->ops->get_temp)
9393
return -EINVAL;
9494

9595
return data->ops->get_temp(data->sensor_data, temp);
@@ -186,6 +186,9 @@ static int of_thermal_set_emul_temp(struct thermal_zone_device *tz,
186186
{
187187
struct __thermal_zone *data = tz->devdata;
188188

189+
if (!data->ops || !data->ops->set_emul_temp)
190+
return -EINVAL;
191+
189192
return data->ops->set_emul_temp(data->sensor_data, temp);
190193
}
191194

@@ -194,7 +197,7 @@ static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
194197
{
195198
struct __thermal_zone *data = tz->devdata;
196199

197-
if (!data->ops->get_trend)
200+
if (!data->ops || !data->ops->get_trend)
198201
return -EINVAL;
199202

200203
return data->ops->get_trend(data->sensor_data, trip, trend);
@@ -301,7 +304,7 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
301304
if (trip >= data->ntrips || trip < 0)
302305
return -EDOM;
303306

304-
if (data->ops->set_trip_temp) {
307+
if (data->ops && data->ops->set_trip_temp) {
305308
int ret;
306309

307310
ret = data->ops->set_trip_temp(data->sensor_data, trip, temp);

0 commit comments

Comments
 (0)