Skip to content

Commit bbb544f

Browse files
committed
Merge branches 'thermal-int340x', 'thermal-pch' and 'thermal-misc'
Merge int340x thermal driver updates, PCH thermal driver updates and miscellaneous thermal control updates for 5.19-rc1: - Clean up _OSC handling in int340x (Davidlohr Bueso). - Improve overheat condition handling during suspend-to-idle in the Intel PCH thermal driver (Zhang Rui). - Use local ops instead of global ops in devfreq_cooling (Kant Fan). - Switch hisi_termal from CONFIG_PM_SLEEP guards to pm_sleep_ptr() (Hesham Almatary) * thermal-int340x: thermal: int340x: Clean up _OSC context init thermal: int340x: Consolidate freeing of acpi_buffer pointer thermal: int340x: Clean up unnecessary acpi_buffer pointer freeing * thermal-pch: thermal: intel: pch: improve the cooling delay log thermal: intel: pch: enhance overheat handling thermal: intel: pch: move cooling delay to suspend_noirq phase PM: wakeup: expose pm_wakeup_pending to modules * thermal-misc: thermal: devfreq_cooling: use local ops instead of global ops thermal: hisi_termal: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
4 parents 388292d + 7acc8a2 + bd30d07 + b947769 commit bbb544f

File tree

5 files changed

+58
-41
lines changed

5 files changed

+58
-41
lines changed

drivers/base/power/wakeup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,7 @@ bool pm_wakeup_pending(void)
930930

931931
return ret || atomic_read(&pm_abort_suspend) > 0;
932932
}
933+
EXPORT_SYMBOL_GPL(pm_wakeup_pending);
933934

934935
void pm_system_wakeup(void)
935936
{

drivers/thermal/devfreq_cooling.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,21 +358,28 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
358358
struct thermal_cooling_device *cdev;
359359
struct device *dev = df->dev.parent;
360360
struct devfreq_cooling_device *dfc;
361+
struct thermal_cooling_device_ops *ops;
361362
char *name;
362363
int err, num_opps;
363364

364-
dfc = kzalloc(sizeof(*dfc), GFP_KERNEL);
365-
if (!dfc)
365+
ops = kmemdup(&devfreq_cooling_ops, sizeof(*ops), GFP_KERNEL);
366+
if (!ops)
366367
return ERR_PTR(-ENOMEM);
367368

369+
dfc = kzalloc(sizeof(*dfc), GFP_KERNEL);
370+
if (!dfc) {
371+
err = -ENOMEM;
372+
goto free_ops;
373+
}
374+
368375
dfc->devfreq = df;
369376

370377
dfc->em_pd = em_pd_get(dev);
371378
if (dfc->em_pd) {
372-
devfreq_cooling_ops.get_requested_power =
379+
ops->get_requested_power =
373380
devfreq_cooling_get_requested_power;
374-
devfreq_cooling_ops.state2power = devfreq_cooling_state2power;
375-
devfreq_cooling_ops.power2state = devfreq_cooling_power2state;
381+
ops->state2power = devfreq_cooling_state2power;
382+
ops->power2state = devfreq_cooling_power2state;
376383

377384
dfc->power_ops = dfc_power;
378385

@@ -407,8 +414,7 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
407414
if (!name)
408415
goto remove_qos_req;
409416

410-
cdev = thermal_of_cooling_device_register(np, name, dfc,
411-
&devfreq_cooling_ops);
417+
cdev = thermal_of_cooling_device_register(np, name, dfc, ops);
412418
kfree(name);
413419

414420
if (IS_ERR(cdev)) {
@@ -429,6 +435,8 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
429435
kfree(dfc->freq_table);
430436
free_dfc:
431437
kfree(dfc);
438+
free_ops:
439+
kfree(ops);
432440

433441
return ERR_PTR(err);
434442
}
@@ -510,11 +518,13 @@ EXPORT_SYMBOL_GPL(devfreq_cooling_em_register);
510518
void devfreq_cooling_unregister(struct thermal_cooling_device *cdev)
511519
{
512520
struct devfreq_cooling_device *dfc;
521+
const struct thermal_cooling_device_ops *ops;
513522
struct device *dev;
514523

515524
if (IS_ERR_OR_NULL(cdev))
516525
return;
517526

527+
ops = cdev->ops;
518528
dfc = cdev->devdata;
519529
dev = dfc->devfreq->dev.parent;
520530

@@ -525,5 +535,6 @@ void devfreq_cooling_unregister(struct thermal_cooling_device *cdev)
525535

526536
kfree(dfc->freq_table);
527537
kfree(dfc);
538+
kfree(ops);
528539
}
529540
EXPORT_SYMBOL_GPL(devfreq_cooling_unregister);

drivers/thermal/hisi_thermal.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,6 @@ static int hisi_thermal_remove(struct platform_device *pdev)
629629
return 0;
630630
}
631631

632-
#ifdef CONFIG_PM_SLEEP
633632
static int hisi_thermal_suspend(struct device *dev)
634633
{
635634
struct hisi_thermal_data *data = dev_get_drvdata(dev);
@@ -651,15 +650,14 @@ static int hisi_thermal_resume(struct device *dev)
651650

652651
return ret;
653652
}
654-
#endif
655653

656-
static SIMPLE_DEV_PM_OPS(hisi_thermal_pm_ops,
654+
static DEFINE_SIMPLE_DEV_PM_OPS(hisi_thermal_pm_ops,
657655
hisi_thermal_suspend, hisi_thermal_resume);
658656

659657
static struct platform_driver hisi_thermal_driver = {
660658
.driver = {
661659
.name = "hisi_thermal",
662-
.pm = &hisi_thermal_pm_ops,
660+
.pm = pm_sleep_ptr(&hisi_thermal_pm_ops),
663661
.of_match_table = of_hisi_thermal_match,
664662
},
665663
.probe = hisi_thermal_probe,

drivers/thermal/intel/int340x_thermal/int3400_thermal.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -169,28 +169,25 @@ static int int3400_thermal_run_osc(acpi_handle handle, char *uuid_str, int *enab
169169
acpi_status status;
170170
int result = 0;
171171
struct acpi_osc_context context = {
172-
.uuid_str = NULL,
172+
.uuid_str = uuid_str,
173173
.rev = 1,
174174
.cap.length = 8,
175+
.cap.pointer = buf,
175176
};
176177

177-
context.uuid_str = uuid_str;
178-
179178
buf[OSC_QUERY_DWORD] = 0;
180179
buf[OSC_SUPPORT_DWORD] = *enable;
181180

182-
context.cap.pointer = buf;
183-
184181
status = acpi_run_osc(handle, &context);
185182
if (ACPI_SUCCESS(status)) {
186183
ret = *((u32 *)(context.ret.pointer + 4));
187184
if (ret != *enable)
188185
result = -EPERM;
186+
187+
kfree(context.ret.pointer);
189188
} else
190189
result = -EPERM;
191190

192-
kfree(context.ret.pointer);
193-
194191
return result;
195192
}
196193

@@ -524,21 +521,18 @@ static void int3400_setup_gddv(struct int3400_thermal_priv *priv)
524521

525522
obj = buffer.pointer;
526523
if (obj->type != ACPI_TYPE_PACKAGE || obj->package.count != 1
527-
|| obj->package.elements[0].type != ACPI_TYPE_BUFFER) {
528-
kfree(buffer.pointer);
529-
return;
530-
}
524+
|| obj->package.elements[0].type != ACPI_TYPE_BUFFER)
525+
goto out_free;
531526

532527
priv->data_vault = kmemdup(obj->package.elements[0].buffer.pointer,
533528
obj->package.elements[0].buffer.length,
534529
GFP_KERNEL);
535-
if (!priv->data_vault) {
536-
kfree(buffer.pointer);
537-
return;
538-
}
530+
if (!priv->data_vault)
531+
goto out_free;
539532

540533
bin_attr_data_vault.private = priv->data_vault;
541534
bin_attr_data_vault.size = obj->package.elements[0].buffer.length;
535+
out_free:
542536
kfree(buffer.pointer);
543537
}
544538

drivers/thermal/intel/intel_pch_thermal.c

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ static unsigned int delay_timeout = 100;
7070
module_param(delay_timeout, int, 0644);
7171
MODULE_PARM_DESC(delay_timeout, "amount of time delay for each iteration.");
7272

73-
/* Number of iterations for cooling delay, 10 counts by default for now */
74-
static unsigned int delay_cnt = 10;
73+
/* Number of iterations for cooling delay, 600 counts by default for now */
74+
static unsigned int delay_cnt = 600;
7575
module_param(delay_cnt, int, 0644);
7676
MODULE_PARM_DESC(delay_cnt, "total number of iterations for time delay.");
7777

@@ -193,10 +193,11 @@ static int pch_wpt_get_temp(struct pch_thermal_device *ptd, int *temp)
193193
return 0;
194194
}
195195

196+
/* Cool the PCH when it's overheat in .suspend_noirq phase */
196197
static int pch_wpt_suspend(struct pch_thermal_device *ptd)
197198
{
198199
u8 tsel;
199-
u8 pch_delay_cnt = 1;
200+
int pch_delay_cnt = 0;
200201
u16 pch_thr_temp, pch_cur_temp;
201202

202203
/* Shutdown the thermal sensor if it is not enabled by BIOS */
@@ -232,26 +233,38 @@ static int pch_wpt_suspend(struct pch_thermal_device *ptd)
232233
* temperature stays above threshold, notify the warning message
233234
* which helps to indentify the reason why S0ix entry was rejected.
234235
*/
235-
while (pch_delay_cnt <= delay_cnt) {
236-
if (pch_cur_temp <= pch_thr_temp)
236+
while (pch_delay_cnt < delay_cnt) {
237+
if (pch_cur_temp < pch_thr_temp)
237238
break;
238239

239-
dev_warn(&ptd->pdev->dev,
240+
if (pm_wakeup_pending()) {
241+
dev_warn(&ptd->pdev->dev, "Wakeup event detected, abort cooling\n");
242+
return 0;
243+
}
244+
245+
pch_delay_cnt++;
246+
dev_dbg(&ptd->pdev->dev,
240247
"CPU-PCH current temp [%dC] higher than the threshold temp [%dC], sleep %d times for %d ms duration\n",
241248
pch_cur_temp, pch_thr_temp, pch_delay_cnt, delay_timeout);
242249
msleep(delay_timeout);
243250
/* Read the PCH current temperature for next cycle. */
244251
pch_cur_temp = GET_PCH_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP));
245-
pch_delay_cnt++;
246252
}
247253

248-
if (pch_cur_temp > pch_thr_temp)
254+
if (pch_cur_temp >= pch_thr_temp)
249255
dev_warn(&ptd->pdev->dev,
250-
"CPU-PCH is hot [%dC] even after delay, continue to suspend. S0ix might fail\n",
251-
pch_cur_temp);
252-
else
253-
dev_info(&ptd->pdev->dev,
254-
"CPU-PCH is cool [%dC], continue to suspend\n", pch_cur_temp);
256+
"CPU-PCH is hot [%dC] after %d ms delay. S0ix might fail\n",
257+
pch_cur_temp, pch_delay_cnt * delay_timeout);
258+
else {
259+
if (pch_delay_cnt)
260+
dev_info(&ptd->pdev->dev,
261+
"CPU-PCH is cool [%dC] after %d ms delay\n",
262+
pch_cur_temp, pch_delay_cnt * delay_timeout);
263+
else
264+
dev_info(&ptd->pdev->dev,
265+
"CPU-PCH is cool [%dC]\n",
266+
pch_cur_temp);
267+
}
255268

256269
return 0;
257270
}
@@ -455,7 +468,7 @@ static void intel_pch_thermal_remove(struct pci_dev *pdev)
455468
pci_disable_device(pdev);
456469
}
457470

458-
static int intel_pch_thermal_suspend(struct device *device)
471+
static int intel_pch_thermal_suspend_noirq(struct device *device)
459472
{
460473
struct pch_thermal_device *ptd = dev_get_drvdata(device);
461474

@@ -495,7 +508,7 @@ static const struct pci_device_id intel_pch_thermal_id[] = {
495508
MODULE_DEVICE_TABLE(pci, intel_pch_thermal_id);
496509

497510
static const struct dev_pm_ops intel_pch_pm_ops = {
498-
.suspend = intel_pch_thermal_suspend,
511+
.suspend_noirq = intel_pch_thermal_suspend_noirq,
499512
.resume = intel_pch_thermal_resume,
500513
};
501514

0 commit comments

Comments
 (0)