linux-next: manual merge of the drm tree with the drm-misc-fixes tree
From: Mark Brown
Date: Wed Nov 18 2026 - 09:53:42 EST
Hi all,
Today's linux-next merge of the drm tree got a conflict in:
drivers/accel/rocket/rocket_job.c
between commits:
9bca2b5f1a4fa ("accel/rocket: Keep scheduler allocation in rocket_file_priv")
d341ef030f3ce ("accel/rocket: Check allocations before use")
from the drm-misc-fixes tree and commits:
be22e979c18f5 ("accel/rocket: Check allocations before use")
91c7da1f42cad ("drm/rocket: Keep scheduler allocation in rocket_file_priv")
from the drm tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
diff --combined drivers/accel/rocket/rocket_job.c
index 7b798a90bc492,b2a00992c8894..0000000000000
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@@ -201,13 -201,12 +201,13 @@@ static int rocket_acquire_object_fences
static void rocket_attach_object_fences(struct drm_gem_object **bos,
int bo_count,
- struct dma_fence *fence)
+ struct dma_fence *fence,
+ enum dma_resv_usage usage)
{
int i;
for (i = 0; i < bo_count; i++)
- dma_resv_add_fence(bos[i]->resv, fence, DMA_RESV_USAGE_WRITE);
+ dma_resv_add_fence(bos[i]->resv, fence, usage);
}
static int rocket_job_push(struct rocket_job *job)
@@@ -215,7 -214,7 +215,7 @@@
struct rocket_device *rdev = job->rdev;
struct drm_gem_object **bos;
struct ww_acquire_ctx acquire_ctx;
- u32 bo_count;
+ int bo_count;
int ret = 0;
if (check_add_overflow(job->in_bo_count, job->out_bo_count, &bo_count))
@@@ -231,28 -230,27 +231,30 @@@
if (ret)
goto err;
+ ret = rocket_acquire_object_fences(job->in_bos, job->in_bo_count,
+ &job->base, false);
+ if (ret)
+ goto err_unlock;
+
+ ret = rocket_acquire_object_fences(job->out_bos, job->out_bo_count,
+ &job->base, true);
+ if (ret)
+ goto err_unlock;
+
scoped_guard(mutex, &rdev->sched_lock) {
drm_sched_job_arm(&job->base);
job->inference_done_fence = dma_fence_get(&job->base.s_fence->finished);
- ret = rocket_acquire_object_fences(job->in_bos, job->in_bo_count, &job->base, false);
- if (ret)
- goto err_unlock;
-
- ret = rocket_acquire_object_fences(job->out_bos, job->out_bo_count, &job->base, true);
- if (ret)
- goto err_unlock;
-
kref_get(&job->refcount); /* put by scheduler job completion */
drm_sched_entity_push_job(&job->base);
}
- rocket_attach_object_fences(job->out_bos, job->out_bo_count, job->inference_done_fence);
+ rocket_attach_object_fences(job->in_bos, job->in_bo_count,
+ job->inference_done_fence, DMA_RESV_USAGE_READ);
+ rocket_attach_object_fences(job->out_bos, job->out_bo_count,
+ job->inference_done_fence, DMA_RESV_USAGE_WRITE);
err_unlock:
drm_gem_unlock_reservations(bos, bo_count, &acquire_ctx);
@@@ -268,7 -266,7 +270,7 @@@ static void rocket_job_cleanup(struct k
refcount);
unsigned int i;
- rocket_iommu_domain_put(job->domain);
+ rocket_vm_put(job->vm);
dma_fence_put(job->done_fence);
dma_fence_put(job->inference_done_fence);
@@@ -349,7 -347,7 +351,7 @@@ static struct dma_fence *rocket_job_run
if (ret < 0)
goto err_put_fences;
- ret = iommu_attach_group(job->domain->domain, core->iommu_group);
+ ret = iommu_attach_group(job->vm->domain, core->iommu_group);
if (ret < 0)
goto err_put_pm;
@@@ -373,56 -371,39 +375,56 @@@ static void rocket_job_handle_irq(struc
{
pm_runtime_mark_last_busy(core->dev);
- rocket_pc_writel(core, OPERATION_ENABLE, 0x0);
- rocket_pc_writel(core, INTERRUPT_CLEAR, 0x1ffff);
+ scoped_guard(mutex, &core->job_lock) {
+ /*
+ * Stopping the block belongs under the lock. hw_submit() writes
+ * OPERATION_ENABLE too, and outside the lock this zero can land
+ * after that one and stop a task that has only just started.
+ */
+ rocket_pc_writel(core, OPERATION_ENABLE, 0x0);
+ rocket_pc_writel(core, INTERRUPT_CLEAR, 0x1ffff);
- scoped_guard(mutex, &core->job_lock)
if (core->in_flight_job) {
if (core->in_flight_job->next_task_idx < core->in_flight_job->task_count) {
rocket_job_hw_submit(core, core->in_flight_job);
return;
}
- iommu_detach_group(NULL, iommu_group_get(core->dev));
+ iommu_detach_group(NULL, core->iommu_group);
dma_fence_signal(core->in_flight_job->done_fence);
pm_runtime_put_autosuspend(core->dev);
core->in_flight_job = NULL;
}
+ }
}
static void
rocket_reset(struct rocket_core *core, struct drm_sched_job *bad)
{
+ bool put_job_ref;
+
if (!atomic_read(&core->reset.pending))
return;
drm_sched_stop(&core->sched, bad);
+ scoped_guard(mutex, &core->job_lock) {
+ if (pm_runtime_get_if_active(core->dev) > 0) {
+ rocket_pc_writel(core, INTERRUPT_MASK, 0x0);
+ rocket_pc_writel(core, INTERRUPT_CLEAR, 0x1ffff);
+ pm_runtime_put_autosuspend(core->dev);
+ }
+ }
+
+ synchronize_irq(core->irq);
+
/*
* Remaining interrupts have been handled, but we might still have
* stuck jobs. Let's make sure the PM counters stay balanced by
- * manually calling pm_runtime_put_noidle().
+ * dropping the job's reference once the core has been reset.
*/
scoped_guard(mutex, &core->job_lock) {
- if (core->in_flight_job)
- pm_runtime_put_noidle(core->dev);
+ put_job_ref = core->in_flight_job;
iommu_detach_group(NULL, core->iommu_group);
@@@ -432,9 -413,6 +434,9 @@@
/* Proceed with reset now. */
rocket_core_reset(core);
+ if (put_job_ref)
+ pm_runtime_put_autosuspend(core->dev);
+
/* NPU has been reset, we can clear the reset pending bit. */
atomic_set(&core->reset.pending, 0);
@@@ -572,7 -550,7 +574,7 @@@ int rocket_job_open(struct rocket_file_
DRM_SCHED_PRIORITY_NORMAL,
scheds,
rdev->num_cores, NULL);
- if (WARN_ON(ret))
+ if (ret)
kfree(scheds);
else
rocket_priv->scheds = scheds;
@@@ -584,8 -562,8 +586,8 @@@ void rocket_job_close(struct rocket_fil
{
struct drm_sched_entity *entity = &rocket_priv->sched_entity;
- kfree(rocket_priv->scheds);
drm_sched_entity_destroy(entity);
+ kfree(rocket_priv->scheds);
}
int rocket_job_is_idle(struct rocket_core *core)
@@@ -608,6 -586,11 +610,11 @@@ static int rocket_ioctl_submit_job(stru
if (job->task_count == 0)
return -EINVAL;
+ /* GEM lookup takes a signed object count. */
+ if (job->in_bo_handle_count > INT_MAX ||
+ job->out_bo_handle_count > INT_MAX)
+ return -EINVAL;
+
rjob = kzalloc_obj(*rjob);
if (!rjob)
return -ENOMEM;
@@@ -615,7 -598,7 +622,7 @@@
kref_init(&rjob->refcount);
rjob->rdev = rdev;
- rjob->domain = rocket_iommu_domain_get(file_priv);
+ rjob->vm = rocket_vm_get(file_priv);
ret = drm_sched_job_init(&rjob->base,
&file_priv->sched_entity,
@@@ -691,8 -674,11 +698,11 @@@ int rocket_ioctl_submit(struct drm_devi
}
- for (i = 0; i < args->job_count; i++)
- rocket_ioctl_submit_job(dev, file, &jobs[i]);
+ for (i = 0; i < args->job_count; i++) {
+ ret = rocket_ioctl_submit_job(dev, file, &jobs[i]);
+ if (ret)
+ goto exit;
+ }
exit:
kvfree(jobs);
Attachment:
signature.asc
Description: PGP signature