mirror of
https://github.com/torvalds/linux.git
synced 2026-05-02 05:22:49 -04:00
drm/lima: Add optional devfreq and cooling device support
Most platforms with a Mali-400 or Mali-450 GPU also have support for changing the GPU clock frequency. Add devfreq support so the GPU clock rate is updated based on the actual GPU usage when the "operating-points-v2" property is present in the board.dts. The actual devfreq code is taken from panfrost_devfreq.c and modified so it matches what the lima hardware needs: - a call to dev_pm_opp_set_clkname() during initialization because there are two clocks on Mali-4x0 IPs. "core" is the one that actually clocks the GPU so we need to control it using devfreq. - locking when reading or writing the devfreq statistics because (unlike than panfrost) we have multiple PP and GP IRQs which may finish jobs concurrently. Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Signed-off-by: Qiang Yu <yuq825@gmail.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200319203427.2259891-3-martin.blumenstingl@googlemail.com
This commit is contained in:
committed by
Qiang Yu
parent
6bb0942e8f
commit
1996970773
41
drivers/gpu/drm/lima/lima_devfreq.h
Normal file
41
drivers/gpu/drm/lima/lima_devfreq.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/* Copyright 2020 Martin Blumenstingl <martin.blumenstingl@googlemail.com> */
|
||||
|
||||
#ifndef __LIMA_DEVFREQ_H__
|
||||
#define __LIMA_DEVFREQ_H__
|
||||
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/ktime.h>
|
||||
|
||||
struct devfreq;
|
||||
struct opp_table;
|
||||
struct thermal_cooling_device;
|
||||
|
||||
struct lima_device;
|
||||
|
||||
struct lima_devfreq {
|
||||
struct devfreq *devfreq;
|
||||
struct opp_table *clkname_opp_table;
|
||||
struct opp_table *regulators_opp_table;
|
||||
struct thermal_cooling_device *cooling;
|
||||
bool opp_of_table_added;
|
||||
|
||||
ktime_t busy_time;
|
||||
ktime_t idle_time;
|
||||
ktime_t time_last_update;
|
||||
int busy_count;
|
||||
/*
|
||||
* Protect busy_time, idle_time, time_last_update and busy_count
|
||||
* because these can be updated concurrently, for example by the GP
|
||||
* and PP interrupts.
|
||||
*/
|
||||
spinlock_t lock;
|
||||
};
|
||||
|
||||
int lima_devfreq_init(struct lima_device *ldev);
|
||||
void lima_devfreq_fini(struct lima_device *ldev);
|
||||
|
||||
void lima_devfreq_record_busy(struct lima_devfreq *devfreq);
|
||||
void lima_devfreq_record_idle(struct lima_devfreq *devfreq);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user