Lines Matching refs:pfdevfreq
13 static void panfrost_devfreq_update_utilization(struct panfrost_devfreq *pfdevfreq) in panfrost_devfreq_update_utilization() argument
18 last = pfdevfreq->time_last_update; in panfrost_devfreq_update_utilization()
20 if (pfdevfreq->busy_count > 0) in panfrost_devfreq_update_utilization()
21 pfdevfreq->busy_time += ktime_sub(now, last); in panfrost_devfreq_update_utilization()
23 pfdevfreq->idle_time += ktime_sub(now, last); in panfrost_devfreq_update_utilization()
25 pfdevfreq->time_last_update = now; in panfrost_devfreq_update_utilization()
41 static void panfrost_devfreq_reset(struct panfrost_devfreq *pfdevfreq) in panfrost_devfreq_reset() argument
43 pfdevfreq->busy_time = 0; in panfrost_devfreq_reset()
44 pfdevfreq->idle_time = 0; in panfrost_devfreq_reset()
45 pfdevfreq->time_last_update = ktime_get(); in panfrost_devfreq_reset()
52 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_get_dev_status() local
57 spin_lock_irqsave(&pfdevfreq->lock, irqflags); in panfrost_devfreq_get_dev_status()
59 panfrost_devfreq_update_utilization(pfdevfreq); in panfrost_devfreq_get_dev_status()
61 status->total_time = ktime_to_ns(ktime_add(pfdevfreq->busy_time, in panfrost_devfreq_get_dev_status()
62 pfdevfreq->idle_time)); in panfrost_devfreq_get_dev_status()
64 status->busy_time = ktime_to_ns(pfdevfreq->busy_time); in panfrost_devfreq_get_dev_status()
66 panfrost_devfreq_reset(pfdevfreq); in panfrost_devfreq_get_dev_status()
68 spin_unlock_irqrestore(&pfdevfreq->lock, irqflags); in panfrost_devfreq_get_dev_status()
93 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_init() local
122 pfdevfreq->opp_of_table_added = true; in panfrost_devfreq_init()
124 spin_lock_init(&pfdevfreq->lock); in panfrost_devfreq_init()
126 panfrost_devfreq_reset(pfdevfreq); in panfrost_devfreq_init()
141 pfdevfreq->gov_data.upthreshold = 45; in panfrost_devfreq_init()
142 pfdevfreq->gov_data.downdifferential = 5; in panfrost_devfreq_init()
146 &pfdevfreq->gov_data); in panfrost_devfreq_init()
151 pfdevfreq->devfreq = devfreq; in panfrost_devfreq_init()
157 pfdevfreq->cooling = cooling; in panfrost_devfreq_init()
164 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_fini() local
166 if (pfdevfreq->cooling) { in panfrost_devfreq_fini()
167 devfreq_cooling_unregister(pfdevfreq->cooling); in panfrost_devfreq_fini()
168 pfdevfreq->cooling = NULL; in panfrost_devfreq_fini()
174 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_resume() local
176 if (!pfdevfreq->devfreq) in panfrost_devfreq_resume()
179 panfrost_devfreq_reset(pfdevfreq); in panfrost_devfreq_resume()
181 devfreq_resume_device(pfdevfreq->devfreq); in panfrost_devfreq_resume()
186 struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; in panfrost_devfreq_suspend() local
188 if (!pfdevfreq->devfreq) in panfrost_devfreq_suspend()
191 devfreq_suspend_device(pfdevfreq->devfreq); in panfrost_devfreq_suspend()
194 void panfrost_devfreq_record_busy(struct panfrost_devfreq *pfdevfreq) in panfrost_devfreq_record_busy() argument
198 if (!pfdevfreq->devfreq) in panfrost_devfreq_record_busy()
201 spin_lock_irqsave(&pfdevfreq->lock, irqflags); in panfrost_devfreq_record_busy()
203 panfrost_devfreq_update_utilization(pfdevfreq); in panfrost_devfreq_record_busy()
205 pfdevfreq->busy_count++; in panfrost_devfreq_record_busy()
207 spin_unlock_irqrestore(&pfdevfreq->lock, irqflags); in panfrost_devfreq_record_busy()
210 void panfrost_devfreq_record_idle(struct panfrost_devfreq *pfdevfreq) in panfrost_devfreq_record_idle() argument
214 if (!pfdevfreq->devfreq) in panfrost_devfreq_record_idle()
217 spin_lock_irqsave(&pfdevfreq->lock, irqflags); in panfrost_devfreq_record_idle()
219 panfrost_devfreq_update_utilization(pfdevfreq); in panfrost_devfreq_record_idle()
221 WARN_ON(--pfdevfreq->busy_count < 0); in panfrost_devfreq_record_idle()
223 spin_unlock_irqrestore(&pfdevfreq->lock, irqflags); in panfrost_devfreq_record_idle()