public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Ezequiel Garcia <ezequiel@collabora.com>
To: linux-media@vger.kernel.org
Cc: Hans Verkuil <hverkuil@xs4all.nl>,
	kernel@collabora.com, paul.kocialkowski@bootlin.com,
	maxime.ripard@bootlin.com, Hans Verkuil <hans.verkuil@cisco.com>,
	Shuah Khan <shuah@kernel.org>,
	linux-kselftest@vger.kernel.org,
	Ezequiel Garcia <ezequiel@collabora.com>
Subject: [PATCH v3 0/4] Make sure .device_run is always called in non-atomic context
Date: Wed,  1 Aug 2018 18:50:22 -0300	[thread overview]
Message-ID: <20180801215026.27809-1-ezequiel@collabora.com> (raw)

This series goal is to avoid drivers from having ad-hoc code
to call .device_run in non-atomic context. Currently, .device_run
can be called via v4l2_m2m_job_finish(), potentially running
in interrupt context.

This series will be useful for the upcoming Request API, where drivers
typically require .device_run to be called in non-atomic context for
v4l2_ctrl_request_setup() calls.

The solution is to add a per-device worker that is scheduled
by v4l2_m2m_job_finish, which replaces drivers having a threaded interrupt
or similar.

This change allows v4l2_m2m_job_finish() to be called in interrupt
context, separating .device_run and v4l2_m2m_job_finish() contexts.

It's worth mentioning that v4l2_m2m_cancel_job() doesn't need
to flush or cancel the new worker, because the job_spinlock
synchronizes both and also because the core prevents simultaneous
jobs. Either v4l2_m2m_cancel_job() will wait for the worker, or the
worker will be unable to run a new job.

Testing
-------

In order to test the change, and make sure no regressions are
introduced, a kselftest test is added to stress the mem2mem framework.

Note that this series rework the kselftest media_tests target.
Those tests that need hardware and human intervention are now
marked as _EXTENDED, and a frontend script is added to run those
tests that can run without hardware or human intervention.

This will allow the media_tests target to be included in
automatic regression testing setups.

Hopefully, we will be able to introduce more and more automatic
regression tests. Currently, our self-test run looks like:

    $ make TARGETS=media_tests kselftest 
    make[1]: Entering directory '/home/zeta/repos/builds/virtme-x86_64'
    make[3]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
    make[3]: Nothing to be done for 'all'.
    make[3]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
    TAP version 13
    selftests: media_tests: m2m_job_test.sh
    ========================================
    -------------------
    running media tests
    -------------------
    media_device : no video4linux drivers loaded, vim2m is needed
    not ok 1..1 selftests: media_tests: m2m_job_test.sh [SKIP]
    make[1]: Leaving directory '/home/zeta/repos/builds/virtme-x86_64'

Ezequiel Garcia (3):
  v4l2-mem2mem: Avoid v4l2_m2m_prepare_buf from scheduling a job
  v4l2-mem2mem: Avoid calling .device_run in v4l2_m2m_job_finish
  selftests: media_tests: Add a memory-to-memory concurrent stress test

Sakari Ailus (1):
  v4l2-mem2mem: Simplify exiting the function in __v4l2_m2m_try_schedule

 drivers/media/v4l2-core/v4l2-mem2mem.c        |  72 +++--
 .../testing/selftests/media_tests/.gitignore  |   1 +
 tools/testing/selftests/media_tests/Makefile  |   5 +-
 .../selftests/media_tests/m2m_job_test.c      | 287 ++++++++++++++++++
 .../selftests/media_tests/m2m_job_test.sh     |  32 ++
 5 files changed, 371 insertions(+), 26 deletions(-)
 create mode 100644 tools/testing/selftests/media_tests/m2m_job_test.c
 create mode 100755 tools/testing/selftests/media_tests/m2m_job_test.sh

-- 
2.18.0

             reply	other threads:[~2018-08-01 23:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-01 21:50 Ezequiel Garcia [this message]
2018-08-01 21:50 ` [PATCH v3 1/4] v4l2-mem2mem: Avoid v4l2_m2m_prepare_buf from scheduling a job Ezequiel Garcia
2018-08-01 21:50 ` [PATCH v3 2/4] v4l2-mem2mem: Simplify exiting the function in __v4l2_m2m_try_schedule Ezequiel Garcia
2018-08-01 21:50 ` [PATCH v3 3/4] v4l2-mem2mem: Avoid calling .device_run in v4l2_m2m_job_finish Ezequiel Garcia
2018-08-02  8:02   ` Hans Verkuil
2018-08-02 15:06     ` Ezequiel Garcia
2018-08-01 21:50 ` [PATCH v3 4/4] selftests: media_tests: Add a memory-to-memory concurrent stress test Ezequiel Garcia
2018-08-03 11:15   ` Guillaume Tucker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180801215026.27809-1-ezequiel@collabora.com \
    --to=ezequiel@collabora.com \
    --cc=hans.verkuil@cisco.com \
    --cc=hverkuil@xs4all.nl \
    --cc=kernel@collabora.com \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=maxime.ripard@bootlin.com \
    --cc=paul.kocialkowski@bootlin.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox