Lines Matching full:devfreq

9 #include <linux/devfreq.h>
19 static void lima_devfreq_update_utilization(struct lima_devfreq *devfreq) in lima_devfreq_update_utilization() argument
24 last = devfreq->time_last_update; in lima_devfreq_update_utilization()
26 if (devfreq->busy_count > 0) in lima_devfreq_update_utilization()
27 devfreq->busy_time += ktime_sub(now, last); in lima_devfreq_update_utilization()
29 devfreq->idle_time += ktime_sub(now, last); in lima_devfreq_update_utilization()
31 devfreq->time_last_update = now; in lima_devfreq_update_utilization()
47 static void lima_devfreq_reset(struct lima_devfreq *devfreq) in lima_devfreq_reset() argument
49 devfreq->busy_time = 0; in lima_devfreq_reset()
50 devfreq->idle_time = 0; in lima_devfreq_reset()
51 devfreq->time_last_update = ktime_get(); in lima_devfreq_reset()
58 struct lima_devfreq *devfreq = &ldev->devfreq; in lima_devfreq_get_dev_status() local
63 spin_lock_irqsave(&devfreq->lock, irqflags); in lima_devfreq_get_dev_status()
65 lima_devfreq_update_utilization(devfreq); in lima_devfreq_get_dev_status()
67 status->total_time = ktime_to_ns(ktime_add(devfreq->busy_time, in lima_devfreq_get_dev_status()
68 devfreq->idle_time)); in lima_devfreq_get_dev_status()
69 status->busy_time = ktime_to_ns(devfreq->busy_time); in lima_devfreq_get_dev_status()
71 lima_devfreq_reset(devfreq); in lima_devfreq_get_dev_status()
73 spin_unlock_irqrestore(&devfreq->lock, irqflags); in lima_devfreq_get_dev_status()
92 struct lima_devfreq *devfreq = &ldev->devfreq; in lima_devfreq_fini() local
94 if (devfreq->cooling) { in lima_devfreq_fini()
95 devfreq_cooling_unregister(devfreq->cooling); in lima_devfreq_fini()
96 devfreq->cooling = NULL; in lima_devfreq_fini()
99 if (devfreq->devfreq) { in lima_devfreq_fini()
100 devm_devfreq_remove_device(ldev->dev, devfreq->devfreq); in lima_devfreq_fini()
101 devfreq->devfreq = NULL; in lima_devfreq_fini()
109 struct devfreq *devfreq; in lima_devfreq_init() local
110 struct lima_devfreq *ldevfreq = &ldev->devfreq; in lima_devfreq_init()
117 /* Optional, continue without devfreq */ in lima_devfreq_init()
159 devfreq = devm_devfreq_add_device(dev, &lima_devfreq_profile, in lima_devfreq_init()
162 if (IS_ERR(devfreq)) { in lima_devfreq_init()
163 dev_err(dev, "Couldn't initialize GPU devfreq\n"); in lima_devfreq_init()
164 return PTR_ERR(devfreq); in lima_devfreq_init()
167 ldevfreq->devfreq = devfreq; in lima_devfreq_init()
169 cooling = of_devfreq_cooling_register(dev->of_node, devfreq); in lima_devfreq_init()
178 void lima_devfreq_record_busy(struct lima_devfreq *devfreq) in lima_devfreq_record_busy() argument
182 if (!devfreq->devfreq) in lima_devfreq_record_busy()
185 spin_lock_irqsave(&devfreq->lock, irqflags); in lima_devfreq_record_busy()
187 lima_devfreq_update_utilization(devfreq); in lima_devfreq_record_busy()
189 devfreq->busy_count++; in lima_devfreq_record_busy()
191 spin_unlock_irqrestore(&devfreq->lock, irqflags); in lima_devfreq_record_busy()
194 void lima_devfreq_record_idle(struct lima_devfreq *devfreq) in lima_devfreq_record_idle() argument
198 if (!devfreq->devfreq) in lima_devfreq_record_idle()
201 spin_lock_irqsave(&devfreq->lock, irqflags); in lima_devfreq_record_idle()
203 lima_devfreq_update_utilization(devfreq); in lima_devfreq_record_idle()
205 WARN_ON(--devfreq->busy_count < 0); in lima_devfreq_record_idle()
207 spin_unlock_irqrestore(&devfreq->lock, irqflags); in lima_devfreq_record_idle()
210 int lima_devfreq_resume(struct lima_devfreq *devfreq) in lima_devfreq_resume() argument
214 if (!devfreq->devfreq) in lima_devfreq_resume()
217 spin_lock_irqsave(&devfreq->lock, irqflags); in lima_devfreq_resume()
219 lima_devfreq_reset(devfreq); in lima_devfreq_resume()
221 spin_unlock_irqrestore(&devfreq->lock, irqflags); in lima_devfreq_resume()
223 return devfreq_resume_device(devfreq->devfreq); in lima_devfreq_resume()
226 int lima_devfreq_suspend(struct lima_devfreq *devfreq) in lima_devfreq_suspend() argument
228 if (!devfreq->devfreq) in lima_devfreq_suspend()
231 return devfreq_suspend_device(devfreq->devfreq); in lima_devfreq_suspend()