media: pisp_be: Split jobs creation and scheduling
authorJacopo Mondi <jacopo.mondi@ideasonboard.com>
Mon, 5 Aug 2024 14:55:35 +0000 (16:55 +0200)
committerHans Verkuil <hverkuil@xs4all.nl>
Thu, 3 Jul 2025 07:25:01 +0000 (09:25 +0200)
commit972eed08261fb1048afea8e8f7db05b5531eed66
tree245206dbb2b2d416d71406e0aad503e62c35ff1e
parenta773b6141610e625abedaff29ac674a75c77a609
media: pisp_be: Split jobs creation and scheduling

Currently the 'pispbe_schedule()' function does two things:

1) Tries to assemble a job by inspecting all the video node queues
   to make sure all the required buffers are available
2) Submit the job to the hardware

The pispbe_schedule() function is called at:

- video device start_streaming() time
- video device qbuf() time
- irq handler

As assembling a job requires inspecting all queues, it is a rather
time consuming operation which is better not run in IRQ context.

To avoid executing the time consuming job creation in interrupt
context split the job creation and job scheduling in two distinct
operations. When a well-formed job is created, append it to the
newly introduced 'pispbe->job_queue' where it will be dequeued from
by the scheduling routine.

As the per-node 'ready_queue' buffer list is only accessed in vb2 ops
callbacks, protected by the node->queue_lock mutex, it is not necessary
to guard it with a dedicated spinlock so drop it. Also use the
spin_lock_irq() variant in all functions not called from an IRQ context
where the spin_lock_irqsave() version was used.

Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/platform/raspberrypi/pisp_be/pisp_be.c