@@ -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
@@ -483,6 +487,10 @@ void devfreq_monitor_start(struct devfreq *devfreq)
483
487
if (IS_SUPPORTED_FLAG (devfreq -> governor -> flags , IRQ_DRIVEN ))
484
488
return ;
485
489
490
+ mutex_lock (& devfreq -> lock );
491
+ if (delayed_work_pending (& devfreq -> work ))
492
+ goto out ;
493
+
486
494
switch (devfreq -> profile -> timer ) {
487
495
case DEVFREQ_TIMER_DEFERRABLE :
488
496
INIT_DEFERRABLE_WORK (& devfreq -> work , devfreq_monitor );
@@ -491,12 +499,16 @@ void devfreq_monitor_start(struct devfreq *devfreq)
491
499
INIT_DELAYED_WORK (& devfreq -> work , devfreq_monitor );
492
500
break ;
493
501
default :
494
- return ;
502
+ goto out ;
495
503
}
496
504
497
505
if (devfreq -> profile -> polling_ms )
498
506
queue_delayed_work (devfreq_wq , & devfreq -> work ,
499
507
msecs_to_jiffies (devfreq -> profile -> polling_ms ));
508
+
509
+ out :
510
+ devfreq -> stop_polling = false;
511
+ mutex_unlock (& devfreq -> lock );
500
512
}
501
513
EXPORT_SYMBOL (devfreq_monitor_start );
502
514
@@ -513,6 +525,14 @@ void devfreq_monitor_stop(struct devfreq *devfreq)
513
525
if (IS_SUPPORTED_FLAG (devfreq -> governor -> flags , IRQ_DRIVEN ))
514
526
return ;
515
527
528
+ mutex_lock (& devfreq -> lock );
529
+ if (devfreq -> stop_polling ) {
530
+ mutex_unlock (& devfreq -> lock );
531
+ return ;
532
+ }
533
+
534
+ devfreq -> stop_polling = true;
535
+ mutex_unlock (& devfreq -> lock );
516
536
cancel_delayed_work_sync (& devfreq -> work );
517
537
}
518
538
EXPORT_SYMBOL (devfreq_monitor_stop );
0 commit comments