* @curr_ctx:          currently running instance
  * @job_queue:         instances queued to run
  * @job_spinlock:      protects job_queue
+ * @job_work:          worker to run queued jobs.
  * @m2m_ops:           driver callbacks
  */
 struct v4l2_m2m_dev {
 
        struct list_head        job_queue;
        spinlock_t              job_spinlock;
+       struct work_struct      job_work;
 
        const struct v4l2_m2m_ops *m2m_ops;
 };
  * @m2m_dev: per-device context
  *
  * Get next transaction (if present) from the waiting jobs list and run it.
+ *
+ * Note that this function can run on a given v4l2_m2m_ctx context,
+ * but call .device_run for another context.
  */
 static void v4l2_m2m_try_run(struct v4l2_m2m_dev *m2m_dev)
 {
 }
 EXPORT_SYMBOL_GPL(v4l2_m2m_try_schedule);
 
+/**
+ * v4l2_m2m_device_run_work() - run pending jobs for the context
+ * @work: Work structure used for scheduling the execution of this function.
+ */
+static void v4l2_m2m_device_run_work(struct work_struct *work)
+{
+       struct v4l2_m2m_dev *m2m_dev =
+               container_of(work, struct v4l2_m2m_dev, job_work);
+
+       v4l2_m2m_try_run(m2m_dev);
+}
+
 /**
  * v4l2_m2m_cancel_job() - cancel pending jobs for the context
  * @m2m_ctx: m2m context with jobs to be canceled
        /* This instance might have more buffers ready, but since we do not
         * allow more than one job on the job_queue per instance, each has
         * to be scheduled separately after the previous one finishes. */
-       v4l2_m2m_try_schedule(m2m_ctx);
+       __v4l2_m2m_try_queue(m2m_dev, m2m_ctx);
+
+       /* We might be running in atomic context,
+        * but the job must be run in non-atomic context.
+        */
+       schedule_work(&m2m_dev->job_work);
 }
 EXPORT_SYMBOL(v4l2_m2m_job_finish);
 
        m2m_dev->m2m_ops = m2m_ops;
        INIT_LIST_HEAD(&m2m_dev->job_queue);
        spin_lock_init(&m2m_dev->job_spinlock);
+       INIT_WORK(&m2m_dev->job_work, v4l2_m2m_device_run_work);
 
        return m2m_dev;
 }