Skip to content

Commit

Permalink
drm/panthor: record current and maximum device clock frequencies
Browse files Browse the repository at this point in the history
In order to support UM in calculating rates of GPU utilisation, the current
operating and maximum GPU clock frequencies must be recorded during device
initialisation, and also during OPP state transitions.

Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240923230912.2207320-3-adrian.larumbe@collabora.com
  • Loading branch information
Adrián Larumbe authored and Boris Brezillon committed Oct 2, 2024
1 parent f8ff51a commit 37591ae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
18 changes: 17 additions & 1 deletion drivers/gpu/drm/panthor/panthor_devfreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,20 @@ static void panthor_devfreq_update_utilization(struct panthor_devfreq *pdevfreq)
static int panthor_devfreq_target(struct device *dev, unsigned long *freq,
u32 flags)
{
struct panthor_device *ptdev = dev_get_drvdata(dev);
struct dev_pm_opp *opp;
int err;

opp = devfreq_recommended_opp(dev, freq, flags);
if (IS_ERR(opp))
return PTR_ERR(opp);
dev_pm_opp_put(opp);

return dev_pm_opp_set_rate(dev, *freq);
err = dev_pm_opp_set_rate(dev, *freq);
if (!err)
ptdev->current_frequency = *freq;

return err;
}

static void panthor_devfreq_reset(struct panthor_devfreq *pdevfreq)
Expand Down Expand Up @@ -130,6 +136,7 @@ int panthor_devfreq_init(struct panthor_device *ptdev)
struct panthor_devfreq *pdevfreq;
struct dev_pm_opp *opp;
unsigned long cur_freq;
unsigned long freq = ULONG_MAX;
int ret;

pdevfreq = drmm_kzalloc(&ptdev->base, sizeof(*ptdev->devfreq), GFP_KERNEL);
Expand Down Expand Up @@ -161,6 +168,7 @@ int panthor_devfreq_init(struct panthor_device *ptdev)
return PTR_ERR(opp);

panthor_devfreq_profile.initial_freq = cur_freq;
ptdev->current_frequency = cur_freq;

/* Regulator coupling only takes care of synchronizing/balancing voltage
* updates, but the coupled regulator needs to be enabled manually.
Expand Down Expand Up @@ -204,6 +212,14 @@ int panthor_devfreq_init(struct panthor_device *ptdev)

dev_pm_opp_put(opp);

/* Find the fastest defined rate */
opp = dev_pm_opp_find_freq_floor(dev, &freq);
if (IS_ERR(opp))
return PTR_ERR(opp);
ptdev->fast_rate = freq;

dev_pm_opp_put(opp);

/*
* Setup default thresholds for the simple_ondemand governor.
* The values are chosen based on experiments.
Expand Down
6 changes: 6 additions & 0 deletions drivers/gpu/drm/panthor/panthor_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ struct panthor_device {

/** @profile_mask: User-set profiling flags for job accounting. */
u32 profile_mask;

/** @current_frequency: Device clock frequency at present. Set by DVFS*/
unsigned long current_frequency;

/** @fast_rate: Maximum device clock frequency. Set by DVFS */
unsigned long fast_rate;
};

/**
Expand Down

0 comments on commit 37591ae

Please sign in to comment.