accel/ivpu: Fix PM related deadlocks in MS IOCTLs
Prevent runtime resume/suspend while MS IOCTLs are in progress.
Failed suspend will call ivpu_ms_cleanup() that would try to acquire
file_priv->ms_lock, which is already held by the IOCTLs.
Fixes: cdfad4db77 ("accel/ivpu: Add NPU profiling support")
Cc: stable@vger.kernel.org # v6.11+
Signed-off-by: Maciej Falkowski <maciej.falkowski@linux.intel.com>
Reviewed-by: Lizhi Hou <lizhi.hou@amd.com>
Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Link: https://lore.kernel.org/r/20250325114306.3740022-3-maciej.falkowski@linux.intel.com
pull/1199/head
parent
9a6f56762d
commit
d893da85e0
|
|
@ -331,7 +331,7 @@ ivpu_force_recovery_fn(struct file *file, const char __user *user_buf, size_t si
|
|||
return -EINVAL;
|
||||
|
||||
ret = ivpu_rpm_get(vdev);
|
||||
if (ret)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ivpu_pm_trigger_recovery(vdev, "debugfs");
|
||||
|
|
@ -382,7 +382,7 @@ static int dct_active_set(void *data, u64 active_percent)
|
|||
return -EINVAL;
|
||||
|
||||
ret = ivpu_rpm_get(vdev);
|
||||
if (ret)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (active_percent)
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ int ivpu_ms_start_ioctl(struct drm_device *dev, void *data, struct drm_file *fil
|
|||
args->sampling_period_ns < MS_MIN_SAMPLE_PERIOD_NS)
|
||||
return -EINVAL;
|
||||
|
||||
ret = ivpu_rpm_get(vdev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
mutex_lock(&file_priv->ms_lock);
|
||||
|
||||
if (get_instance_by_mask(file_priv, args->metric_group_mask)) {
|
||||
|
|
@ -97,6 +101,8 @@ err_free_ms:
|
|||
kfree(ms);
|
||||
unlock:
|
||||
mutex_unlock(&file_priv->ms_lock);
|
||||
|
||||
ivpu_rpm_put(vdev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -161,6 +167,10 @@ int ivpu_ms_get_data_ioctl(struct drm_device *dev, void *data, struct drm_file *
|
|||
if (!args->metric_group_mask)
|
||||
return -EINVAL;
|
||||
|
||||
ret = ivpu_rpm_get(vdev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
mutex_lock(&file_priv->ms_lock);
|
||||
|
||||
ms = get_instance_by_mask(file_priv, args->metric_group_mask);
|
||||
|
|
@ -188,6 +198,7 @@ int ivpu_ms_get_data_ioctl(struct drm_device *dev, void *data, struct drm_file *
|
|||
unlock:
|
||||
mutex_unlock(&file_priv->ms_lock);
|
||||
|
||||
ivpu_rpm_put(vdev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -205,11 +216,17 @@ int ivpu_ms_stop_ioctl(struct drm_device *dev, void *data, struct drm_file *file
|
|||
{
|
||||
struct ivpu_file_priv *file_priv = file->driver_priv;
|
||||
struct drm_ivpu_metric_streamer_stop *args = data;
|
||||
struct ivpu_device *vdev = file_priv->vdev;
|
||||
struct ivpu_ms_instance *ms;
|
||||
int ret;
|
||||
|
||||
if (!args->metric_group_mask)
|
||||
return -EINVAL;
|
||||
|
||||
ret = ivpu_rpm_get(vdev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
mutex_lock(&file_priv->ms_lock);
|
||||
|
||||
ms = get_instance_by_mask(file_priv, args->metric_group_mask);
|
||||
|
|
@ -218,6 +235,7 @@ int ivpu_ms_stop_ioctl(struct drm_device *dev, void *data, struct drm_file *file
|
|||
|
||||
mutex_unlock(&file_priv->ms_lock);
|
||||
|
||||
ivpu_rpm_put(vdev);
|
||||
return ms ? 0 : -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue