Skip to content

Commit ae06e0b

Browse files
kwachowsjlawryno
authored andcommitted
accel/ivpu: Set command queue management capability based on HWS
Control explicit command queue management capability bit based on scheduling mode. Capability will be available only when hardware scheduling mode is set. There is no point of allowing user space to create and destroy command queues with OS schedling mode because FW does not support all required functionalities for correct command queue management with OS scheduling. Return -ENODEV from command queue create/destroy/submit IOCTLs. Remove is_valid field from struct ivpu_job_cmdq Signed-off-by: Karol Wachowski <karol.wachowski@intel.com> Signed-off-by: Maciej Falkowski <maciej.falkowski@linux.intel.com> Reviewed-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com> Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250107173238.381120-10-maciej.falkowski@linux.intel.com
1 parent 353b8f4 commit ae06e0b

File tree

4 files changed

+19
-26
lines changed

4 files changed

+19
-26
lines changed

drivers/accel/ivpu/ivpu_drv.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,18 @@ void ivpu_file_priv_put(struct ivpu_file_priv **link)
127127
kref_put(&file_priv->ref, file_priv_release);
128128
}
129129

130-
static int ivpu_get_capabilities(struct ivpu_device *vdev, struct drm_ivpu_param *args)
130+
bool ivpu_is_capable(struct ivpu_device *vdev, u32 capability)
131131
{
132-
switch (args->index) {
132+
switch (capability) {
133133
case DRM_IVPU_CAP_METRIC_STREAMER:
134-
args->value = 1;
135-
break;
134+
return true;
136135
case DRM_IVPU_CAP_DMA_MEMORY_RANGE:
137-
args->value = 1;
138-
break;
136+
return true;
139137
case DRM_IVPU_CAP_MANAGE_CMDQ:
140-
args->value = 1;
141-
break;
138+
return vdev->fw->sched_mode == VPU_SCHEDULING_MODE_HW;
142139
default:
143-
return -EINVAL;
140+
return false;
144141
}
145-
146-
return 0;
147142
}
148143

149144
static int ivpu_get_param_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
@@ -203,7 +198,7 @@ static int ivpu_get_param_ioctl(struct drm_device *dev, void *data, struct drm_f
203198
args->value = vdev->hw->sku;
204199
break;
205200
case DRM_IVPU_PARAM_CAPABILITIES:
206-
ret = ivpu_get_capabilities(vdev, args);
201+
args->value = ivpu_is_capable(vdev, args->index);
207202
break;
208203
default:
209204
ret = -EINVAL;

drivers/accel/ivpu/ivpu_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ void ivpu_file_priv_put(struct ivpu_file_priv **link);
213213
int ivpu_boot(struct ivpu_device *vdev);
214214
int ivpu_shutdown(struct ivpu_device *vdev);
215215
void ivpu_prepare_for_reset(struct ivpu_device *vdev);
216+
bool ivpu_is_capable(struct ivpu_device *vdev, u32 capability);
216217

217218
static inline u8 ivpu_revision(struct ivpu_device *vdev)
218219
{

drivers/accel/ivpu/ivpu_job.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ static struct ivpu_cmdq *ivpu_cmdq_create(struct ivpu_file_priv *file_priv, u8 p
123123

124124
cmdq->priority = priority;
125125
cmdq->is_legacy = is_legacy;
126-
cmdq->is_valid = true;
127126

128127
ret = xa_alloc_cyclic(&file_priv->cmdq_xa, &cmdq->id, cmdq, file_priv->cmdq_limit,
129128
&file_priv->cmdq_id_next, GFP_KERNEL);
@@ -307,7 +306,7 @@ static struct ivpu_cmdq *ivpu_cmdq_acquire(struct ivpu_file_priv *file_priv, u32
307306
lockdep_assert_held(&file_priv->lock);
308307

309308
cmdq = xa_load(&file_priv->cmdq_xa, cmdq_id);
310-
if (!cmdq || !cmdq->is_valid) {
309+
if (!cmdq) {
311310
ivpu_warn_ratelimited(vdev, "Failed to find command queue with ID: %u\n", cmdq_id);
312311
return NULL;
313312
}
@@ -832,6 +831,9 @@ int ivpu_cmdq_submit_ioctl(struct drm_device *dev, void *data, struct drm_file *
832831
struct ivpu_file_priv *file_priv = file->driver_priv;
833832
struct drm_ivpu_cmdq_submit *args = data;
834833

834+
if (!ivpu_is_capable(file_priv->vdev, DRM_IVPU_CAP_MANAGE_CMDQ))
835+
return -ENODEV;
836+
835837
if (args->cmdq_id < IVPU_CMDQ_MIN_ID || args->cmdq_id > IVPU_CMDQ_MAX_ID)
836838
return -EINVAL;
837839

@@ -857,6 +859,9 @@ int ivpu_cmdq_create_ioctl(struct drm_device *dev, void *data, struct drm_file *
857859
struct drm_ivpu_cmdq_create *args = data;
858860
struct ivpu_cmdq *cmdq;
859861

862+
if (!ivpu_is_capable(file_priv->vdev, DRM_IVPU_CAP_MANAGE_CMDQ))
863+
return -ENODEV;
864+
860865
if (args->priority > DRM_IVPU_JOB_PRIORITY_REALTIME)
861866
return -EINVAL;
862867

@@ -880,24 +885,17 @@ int ivpu_cmdq_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file
880885
u32 cmdq_id;
881886
int ret = 0;
882887

888+
if (!ivpu_is_capable(vdev, DRM_IVPU_CAP_MANAGE_CMDQ))
889+
return -ENODEV;
890+
883891
mutex_lock(&file_priv->lock);
884892

885893
cmdq = xa_load(&file_priv->cmdq_xa, args->cmdq_id);
886-
if (!cmdq || !cmdq->is_valid || cmdq->is_legacy) {
894+
if (!cmdq || cmdq->is_legacy) {
887895
ret = -ENOENT;
888896
goto unlock;
889897
}
890898

891-
/*
892-
* There is no way to stop executing jobs per command queue
893-
* in OS scheduling mode, mark command queue as invalid instead
894-
* and it will be freed together with context release.
895-
*/
896-
if (vdev->fw->sched_mode == VPU_SCHEDULING_MODE_OS) {
897-
cmdq->is_valid = false;
898-
goto unlock;
899-
}
900-
901899
cmdq_id = cmdq->id;
902900
ivpu_cmdq_destroy(file_priv, cmdq);
903901
ivpu_cmdq_abort_all_jobs(vdev, file_priv->ctx.id, cmdq_id);

drivers/accel/ivpu/ivpu_job.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ struct ivpu_cmdq {
3131
u32 id;
3232
u32 db_id;
3333
u8 priority;
34-
bool is_valid;
3534
bool is_legacy;
3635
};
3736

0 commit comments

Comments
 (0)