return 0;
}
+static int ivpu_get_core_clock_rate(struct ivpu_device *vdev, u64 *clk_rate)
+{
+ int ret;
+
+ ret = ivpu_rpm_get_if_active(vdev);
+ if (ret < 0)
+ return ret;
+
+ *clk_rate = ret ? ivpu_hw_reg_pll_freq_get(vdev) : 0;
+
+ if (ret)
+ ivpu_rpm_put(vdev);
+
+ return 0;
+}
+
static int ivpu_get_param_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
{
struct ivpu_file_priv *file_priv = file->driver_priv;
args->value = vdev->platform;
break;
case DRM_IVPU_PARAM_CORE_CLOCK_RATE:
- args->value = ivpu_hw_reg_pll_freq_get(vdev);
+ ret = ivpu_get_core_clock_rate(vdev, &args->value);
break;
case DRM_IVPU_PARAM_NUM_CONTEXTS:
args->value = ivpu_get_context_count(vdev);
return ret;
}
+int ivpu_rpm_get_if_active(struct ivpu_device *vdev)
+{
+ int ret;
+
+ ivpu_dbg(vdev, RPM, "rpm_get_if_active count %d\n",
+ atomic_read(&vdev->drm.dev->power.usage_count));
+
+ ret = pm_runtime_get_if_active(vdev->drm.dev, false);
+ drm_WARN_ON(&vdev->drm, ret < 0);
+
+ return ret;
+}
+
void ivpu_rpm_put(struct ivpu_device *vdev)
{
pm_runtime_mark_last_busy(vdev->drm.dev);
void ivpu_pm_reset_done_cb(struct pci_dev *pdev);
int __must_check ivpu_rpm_get(struct ivpu_device *vdev);
+int __must_check ivpu_rpm_get_if_active(struct ivpu_device *vdev);
void ivpu_rpm_put(struct ivpu_device *vdev);
void ivpu_pm_schedule_recovery(struct ivpu_device *vdev);