@@ -461,10 +461,14 @@ static void devfreq_monitor(struct work_struct *work)
461
461
if (err )
462
462
dev_err (& devfreq -> dev , "dvfs failed with (%d) error\n" , err );
463
463
464
+ if (devfreq -> stop_polling )
465
+ goto out ;
466
+
464
467
queue_delayed_work (devfreq_wq , & devfreq -> work ,
465
468
msecs_to_jiffies (devfreq -> profile -> polling_ms ));
466
- mutex_unlock (& devfreq -> lock );
467
469
470
+ out :
471
+ mutex_unlock (& devfreq -> lock );
468
472
trace_devfreq_monitor (devfreq );
469
473
}
470
474
@@ -482,6 +486,10 @@ void devfreq_monitor_start(struct devfreq *devfreq)
482
486
if (IS_SUPPORTED_FLAG (devfreq -> governor -> flags , IRQ_DRIVEN ))
483
487
return ;
484
488
489
+ mutex_lock (& devfreq -> lock );
490
+ if (delayed_work_pending (& devfreq -> work ))
491
+ goto out ;
492
+
485
493
switch (devfreq -> profile -> timer ) {
486
494
case DEVFREQ_TIMER_DEFERRABLE :
487
495
INIT_DEFERRABLE_WORK (& devfreq -> work , devfreq_monitor );
@@ -490,12 +498,16 @@ void devfreq_monitor_start(struct devfreq *devfreq)
490
498
INIT_DELAYED_WORK (& devfreq -> work , devfreq_monitor );
491
499
break ;
492
500
default :
493
- return ;
501
+ goto out ;
494
502
}
495
503
496
504
if (devfreq -> profile -> polling_ms )
497
505
queue_delayed_work (devfreq_wq , & devfreq -> work ,
498
506
msecs_to_jiffies (devfreq -> profile -> polling_ms ));
507
+
508
+ out :
509
+ devfreq -> stop_polling = false;
510
+ mutex_unlock (& devfreq -> lock );
499
511
}
500
512
EXPORT_SYMBOL (devfreq_monitor_start );
501
513
@@ -512,6 +524,14 @@ void devfreq_monitor_stop(struct devfreq *devfreq)
512
524
if (IS_SUPPORTED_FLAG (devfreq -> governor -> flags , IRQ_DRIVEN ))
513
525
return ;
514
526
527
+ mutex_lock (& devfreq -> lock );
528
+ if (devfreq -> stop_polling ) {
529
+ mutex_unlock (& devfreq -> lock );
530
+ return ;
531
+ }
532
+
533
+ devfreq -> stop_polling = true;
534
+ mutex_unlock (& devfreq -> lock );
515
535
cancel_delayed_work_sync (& devfreq -> work );
516
536
}
517
537
EXPORT_SYMBOL (devfreq_monitor_stop );
0 commit comments