Skip to content

Commit c39dc15

Browse files
Karol Wachowskisgruszka
authored andcommitted
accel/ivpu: Read clock rate only if device is up
Do not unnecessarily wake up device to read clock rate. Return 0 as clk_rate if device is suspended. Signed-off-by: Karol Wachowski <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]> Reviewed-by: Jeffrey Hugo <[email protected]> Signed-off-by: Stanislaw Gruszka <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 74ce0f3 commit c39dc15

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

drivers/accel/ivpu/ivpu_drv.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,22 @@ static int ivpu_get_capabilities(struct ivpu_device *vdev, struct drm_ivpu_param
131131
return 0;
132132
}
133133

134+
static int ivpu_get_core_clock_rate(struct ivpu_device *vdev, u64 *clk_rate)
135+
{
136+
int ret;
137+
138+
ret = ivpu_rpm_get_if_active(vdev);
139+
if (ret < 0)
140+
return ret;
141+
142+
*clk_rate = ret ? ivpu_hw_reg_pll_freq_get(vdev) : 0;
143+
144+
if (ret)
145+
ivpu_rpm_put(vdev);
146+
147+
return 0;
148+
}
149+
134150
static int ivpu_get_param_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
135151
{
136152
struct ivpu_file_priv *file_priv = file->driver_priv;
@@ -154,7 +170,7 @@ static int ivpu_get_param_ioctl(struct drm_device *dev, void *data, struct drm_f
154170
args->value = vdev->platform;
155171
break;
156172
case DRM_IVPU_PARAM_CORE_CLOCK_RATE:
157-
args->value = ivpu_hw_reg_pll_freq_get(vdev);
173+
ret = ivpu_get_core_clock_rate(vdev, &args->value);
158174
break;
159175
case DRM_IVPU_PARAM_NUM_CONTEXTS:
160176
args->value = ivpu_get_context_count(vdev);

drivers/accel/ivpu/ivpu_pm.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,19 @@ int ivpu_rpm_get(struct ivpu_device *vdev)
246246
return ret;
247247
}
248248

249+
int ivpu_rpm_get_if_active(struct ivpu_device *vdev)
250+
{
251+
int ret;
252+
253+
ivpu_dbg(vdev, RPM, "rpm_get_if_active count %d\n",
254+
atomic_read(&vdev->drm.dev->power.usage_count));
255+
256+
ret = pm_runtime_get_if_active(vdev->drm.dev, false);
257+
drm_WARN_ON(&vdev->drm, ret < 0);
258+
259+
return ret;
260+
}
261+
249262
void ivpu_rpm_put(struct ivpu_device *vdev)
250263
{
251264
pm_runtime_mark_last_busy(vdev->drm.dev);

drivers/accel/ivpu/ivpu_pm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ void ivpu_pm_reset_prepare_cb(struct pci_dev *pdev);
3333
void ivpu_pm_reset_done_cb(struct pci_dev *pdev);
3434

3535
int __must_check ivpu_rpm_get(struct ivpu_device *vdev);
36+
int __must_check ivpu_rpm_get_if_active(struct ivpu_device *vdev);
3637
void ivpu_rpm_put(struct ivpu_device *vdev);
3738

3839
void ivpu_pm_schedule_recovery(struct ivpu_device *vdev);

0 commit comments

Comments
 (0)