@@ -70,8 +70,8 @@ static unsigned int delay_timeout = 100;
7070module_param (delay_timeout , int , 0644 );
7171MODULE_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 ;
7575module_param (delay_cnt , int , 0644 );
7676MODULE_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 */
196197static 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[] = {
495508MODULE_DEVICE_TABLE (pci , intel_pch_thermal_id );
496509
497510static 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