linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: linux-media@vger.kernel.org
Cc: "Sakari Ailus" <sakari.ailus@iki.fi>,
	"Krzysztof Hałasa" <khalasa@piap.pl>,
	"Martin Kepplinger" <martink@posteo.de>,
	"Ricardo Ribalda" <ribalda@kernel.org>,
	"Dave Stevenson" <dave.stevenson@raspberrypi.com>,
	"Bingbu Cao" <bingbu.cao@intel.com>,
	"Paul J. Murphy" <paul.j.murphy@intel.com>,
	"Daniele Alessandrelli" <daniele.alessandrelli@intel.com>,
	"Tianshu Qiu" <tian.shu.qiu@intel.com>,
	"Jimmy Su" <jimmy.su@intel.com>,
	"Jason Chen" <jason.z.chen@intel.com>,
	"Arec Kao" <arec.kao@intel.com>,
	"Shunqian Zheng" <zhengsq@rock-chips.com>,
	"Mikhail Rudenko" <mike.rudenko@gmail.com>,
	"Jacopo Mondi" <jacopo@jmondi.org>
Subject: [PATCH 00/57] media: i2c: Reduce cargo cult
Date: Thu, 14 Sep 2023 21:16:07 +0300	[thread overview]
Message-ID: <20230914181704.4811-1-laurent.pinchart@ideasonboard.com> (raw)

Hello,

While working on camera sensor drivers, I got bothered by the amount of
bad practices we have grown slowly as a result of cargo-cult
programming. This patch series is an attempt to improve the situation by
addressing two common problems.

The first problem is addressed in patches 01/57 to 30/57. The subdev
.s_stream() operation is not reentrant, it should never be called to
start an already started subdev, or stop an already stopped one. This
requirement has never been formally documented, which has led many
drivers to track the streaming status and return immediately from
.s_stream() if the requested streaming state matches the current state.

Patch 01/57 first updates the documentation, and the next 29 patches
drop the unneeded checks from camera sensor drivers.

The second problem is addressed in patches 31/57 to 57/57. Starting and
stopping streaming on a camera pipeline requires coordination of the
different blocks. This is handled by the bridge driver, which starts and
stops streaming on the sensor explicitly with the .s_stream() operation.
Despite thus, many sensor drivers track the streaming state internally,
to stop the sensor in the system suspend handler if it is streaming, and
restart it in the system resume handler. This is not needed, and
couldn't work anyway in the general case as starting the sensor before
the bridge can prevent the bridge from synchronizing, for instance for
CSI-2 buses with a continuous clock.

Patches 31/57 to 34/57 refactor and improve the camera sensor
documentation, and the next 23 patches drop system suspend and resume
handlers from camera sensor drivers. Patch 53/57 is a bit of an oddball
as it drops stream handling from the runtime PM handlers instead, which
is even more incorrect as the sensor just can't be streaming already
when the runtime PM resume handler is called.

There are still a few related issues in drivers/media/i2c/ that I have
decided *not* to address in this series:

- The series focusses on camera sensor drivers, the lens controllers,
  flash controllers, and the ADV748x (HDMI/CVBS to CSI-2 converter)
  still implement system PM handlers.

- The et8ek8 driver still implements system PM handlers. While fixable,
  the change will be bigger as the sensor should also move away from the
  .s_power() operation. This requires more testing, which I can't easily
  perform.

- More generally, the series doesn't address drivers that rely on the
  .s_power() operation instead of implementing runtime PM (disregarding
  the drivers other than camera sensors, there are still 17 of them).

The second part of the series unfortunately depends on the first part.
I've decided to split the patches in two parts to clearly show the two
separate issues, and then split them further by driver. If strongly
desired, I could squash patches from the first and second parts together
when they address the same driver, although that will cause quite a bit
of churn to update all commit messages. I prefer keeping the per-driver
split to facilitate backporting.

Laurent Pinchart (57):
  media: v4l2-subdev: Document .s_stream() operation requirements
  media: i2c: hi556: Drop check for reentrant .s_stream()
  media: i2c: hi846: Drop check for reentrant .s_stream()
  media: i2c: imx208: Drop check for reentrant .s_stream()
  media: i2c: imx214: Drop check for reentrant .s_stream()
  media: i2c: imx219: Drop check for reentrant .s_stream()
  media: i2c: imx258: Drop check for reentrant .s_stream()
  media: i2c: imx319: Drop check for reentrant .s_stream()
  media: i2c: imx334: Drop check for reentrant .s_stream()
  media: i2c: imx335: Drop check for reentrant .s_stream()
  media: i2c: imx355: Drop check for reentrant .s_stream()
  media: i2c: imx412: Drop check for reentrant .s_stream()
  media: i2c: mt9m001: Drop check for reentrant .s_stream()
  media: i2c: og01a1b: Drop check for reentrant .s_stream()
  media: i2c: ov01a10: Drop check for reentrant .s_stream()
  media: i2c: ov08d10: Drop check for reentrant .s_stream()
  media: i2c: ov08x40: Drop check for reentrant .s_stream()
  media: i2c: ov13858: Drop check for reentrant .s_stream()
  media: i2c: ov13b10: Drop check for reentrant .s_stream()
  media: i2c: ov2685: Drop check for reentrant .s_stream()
  media: i2c: ov2740: Drop check for reentrant .s_stream()
  media: i2c: ov4689: Drop check for reentrant .s_stream()
  media: i2c: ov5647: Drop check for reentrant .s_stream()
  media: i2c: ov5670: Drop check for reentrant .s_stream()
  media: i2c: ov5675: Drop check for reentrant .s_stream()
  media: i2c: ov5695: Drop check for reentrant .s_stream()
  media: i2c: ov7740: Drop check for reentrant .s_stream()
  media: i2c: ov8856: Drop check for reentrant .s_stream()
  media: i2c: ov9282: Drop check for reentrant .s_stream()
  media: i2c: ov9734: Drop check for reentrant .s_stream()
  Documentation: media: camera-sensor: Fix typo and vocabulary selection
  Documentation: media: camera-sensor: Use link to upstream DT bindings
  Documentation: media: camera-sensor: Move power management section
  Documentation: media: camera-sensor: Improve power management
    documentation
  media: i2c: ar0521: Drop system suspend and resume handlers
  media: i2c: ccs: Drop system suspend and resume handlers
  media: i2c: hi556: Drop system suspend and resume handlers
  media: i2c: hi846: Drop system suspend and resume handlers
  media: i2c: hi847: Drop system suspend and resume handlers
  media: i2c: imx208: Drop system suspend and resume handlers
  media: i2c: imx214: Drop system suspend and resume handlers
  media: i2c: imx219: Drop system suspend and resume handlers
  media: i2c: imx258: Drop system suspend and resume handlers
  media: i2c: imx319: Drop system suspend and resume handlers
  media: i2c: imx355: Drop system suspend and resume handlers
  media: i2c: og01a1b: Drop system suspend and resume handlers
  media: i2c: ov01a10: Drop system suspend and resume handlers
  media: i2c: ov02a10: Drop system suspend and resume handlers
  media: i2c: ov08d10: Drop system suspend and resume handlers
  media: i2c: ov08x40: Drop system suspend and resume handlers
  media: i2c: ov13858: Drop system suspend and resume handlers
  media: i2c: ov2740: Drop system suspend and resume handlers
  media: i2c: ov13b10: Drop stream handling in runtime PM handlers
  media: i2c: ov5670: Drop system suspend and resume handlers
  media: i2c: ov5675: Drop system suspend and resume handlers
  media: i2c: ov8856: Drop system suspend and resume handlers
  media: i2c: ov9734: Drop system suspend and resume handlers

 .../driver-api/media/camera-sensor.rst        | 107 +++++++++++-------
 drivers/media/i2c/ar0521.c                    |  30 +----
 drivers/media/i2c/ccs/ccs-core.c              |  37 ------
 drivers/media/i2c/hi556.c                     |  50 --------
 drivers/media/i2c/hi846.c                     |  28 +----
 drivers/media/i2c/hi847.c                     |  52 ---------
 drivers/media/i2c/imx208.c                    |  47 --------
 drivers/media/i2c/imx214.c                    |  40 -------
 drivers/media/i2c/imx219.c                    |  44 -------
 drivers/media/i2c/imx258.c                    |  40 -------
 drivers/media/i2c/imx319.c                    |  44 -------
 drivers/media/i2c/imx334.c                    |   9 --
 drivers/media/i2c/imx335.c                    |   9 --
 drivers/media/i2c/imx355.c                    |  45 --------
 drivers/media/i2c/imx412.c                    |   9 --
 drivers/media/i2c/mt9m001.c                   |   6 -
 drivers/media/i2c/og01a1b.c                   |  50 --------
 drivers/media/i2c/ov01a10.c                   |  59 +---------
 drivers/media/i2c/ov02a10.c                   |   2 -
 drivers/media/i2c/ov08d10.c                   |  52 ---------
 drivers/media/i2c/ov08x40.c                   |  44 -------
 drivers/media/i2c/ov13858.c                   |  44 -------
 drivers/media/i2c/ov13b10.c                   |  38 +------
 drivers/media/i2c/ov2685.c                    |   7 --
 drivers/media/i2c/ov2740.c                    |  45 --------
 drivers/media/i2c/ov4689.c                    |   7 --
 drivers/media/i2c/ov5647.c                    |   6 -
 drivers/media/i2c/ov5670.c                    |  36 ------
 drivers/media/i2c/ov5675.c                    |  44 -------
 drivers/media/i2c/ov5695.c                    |   6 -
 drivers/media/i2c/ov7740.c                    |   7 --
 drivers/media/i2c/ov8856.c                    |  47 --------
 drivers/media/i2c/ov9282.c                    |   9 --
 drivers/media/i2c/ov9734.c                    |  50 --------
 include/media/v4l2-subdev.h                   |   4 +-
 35 files changed, 76 insertions(+), 1078 deletions(-)


base-commit: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d
-- 
Regards,

Laurent Pinchart


             reply	other threads:[~2023-09-14 18:16 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-14 18:16 Laurent Pinchart [this message]
2023-09-14 18:16 ` [PATCH 01/57] media: v4l2-subdev: Document .s_stream() operation requirements Laurent Pinchart
2023-09-18  7:49   ` Ricardo Ribalda Delgado
2023-09-18  8:08     ` Laurent Pinchart
2023-09-14 18:16 ` [PATCH 02/57] media: i2c: hi556: Drop check for reentrant .s_stream() Laurent Pinchart
2023-09-14 18:16 ` [PATCH 03/57] media: i2c: hi846: " Laurent Pinchart
2023-09-26  7:18   ` Martin Kepplinger
2023-09-14 18:16 ` [PATCH 04/57] media: i2c: imx208: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 05/57] media: i2c: imx214: " Laurent Pinchart
2023-09-18  7:52   ` Ricardo Ribalda Delgado
2023-09-18  8:07     ` Laurent Pinchart
2023-09-14 18:16 ` [PATCH 06/57] media: i2c: imx219: " Laurent Pinchart
2023-09-15 10:49   ` Dave Stevenson
2023-09-14 18:16 ` [PATCH 07/57] media: i2c: imx258: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 08/57] media: i2c: imx319: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 09/57] media: i2c: imx334: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 10/57] media: i2c: imx335: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 11/57] media: i2c: imx355: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 12/57] media: i2c: imx412: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 13/57] media: i2c: mt9m001: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 14/57] media: i2c: og01a1b: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 15/57] media: i2c: ov01a10: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 16/57] media: i2c: ov08d10: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 17/57] media: i2c: ov08x40: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 18/57] media: i2c: ov13858: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 19/57] media: i2c: ov13b10: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 20/57] media: i2c: ov2685: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 21/57] media: i2c: ov2740: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 22/57] media: i2c: ov4689: " Laurent Pinchart
2023-09-15 19:26   ` Mikhail Rudenko
2023-09-18  6:55     ` Sakari Ailus
2023-09-14 18:16 ` [PATCH 23/57] media: i2c: ov5647: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 24/57] media: i2c: ov5670: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 25/57] media: i2c: ov5675: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 26/57] media: i2c: ov5695: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 27/57] media: i2c: ov7740: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 28/57] media: i2c: ov8856: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 29/57] media: i2c: ov9282: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 30/57] media: i2c: ov9734: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 31/57] Documentation: media: camera-sensor: Fix typo and vocabulary selection Laurent Pinchart
2023-09-14 18:16 ` [PATCH 32/57] Documentation: media: camera-sensor: Use link to upstream DT bindings Laurent Pinchart
2023-09-14 18:16 ` [PATCH 33/57] Documentation: media: camera-sensor: Move power management section Laurent Pinchart
2023-09-14 18:16 ` [PATCH 34/57] Documentation: media: camera-sensor: Improve power management documentation Laurent Pinchart
2023-09-14 18:16 ` [PATCH 35/57] media: i2c: ar0521: Drop system suspend and resume handlers Laurent Pinchart
2023-09-15  4:23   ` Krzysztof Hałasa
2023-09-14 18:16 ` [PATCH 36/57] media: i2c: ccs: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 37/57] media: i2c: hi556: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 38/57] media: i2c: hi846: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 39/57] media: i2c: hi847: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 40/57] media: i2c: imx208: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 41/57] media: i2c: imx214: " Laurent Pinchart
2023-09-18  7:53   ` Ricardo Ribalda Delgado
2023-09-14 18:16 ` [PATCH 42/57] media: i2c: imx219: " Laurent Pinchart
2023-09-15 10:53   ` Dave Stevenson
2023-09-15 11:35     ` Laurent Pinchart
2023-09-14 18:16 ` [PATCH 43/57] media: i2c: imx258: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 44/57] media: i2c: imx319: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 45/57] media: i2c: imx355: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 46/57] media: i2c: og01a1b: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 47/57] media: i2c: ov01a10: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 48/57] media: i2c: ov02a10: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 49/57] media: i2c: ov08d10: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 50/57] media: i2c: ov08x40: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 51/57] media: i2c: ov13858: " Laurent Pinchart
2023-09-14 18:16 ` [PATCH 52/57] media: i2c: ov2740: " Laurent Pinchart
2023-09-14 18:17 ` [PATCH 53/57] media: i2c: ov13b10: Drop stream handling in runtime PM handlers Laurent Pinchart
2023-09-14 18:17 ` [PATCH 54/57] media: i2c: ov5670: Drop system suspend and resume handlers Laurent Pinchart
2023-09-14 18:17 ` [PATCH 55/57] media: i2c: ov5675: " Laurent Pinchart
2023-09-14 18:17 ` [PATCH 56/57] media: i2c: ov8856: " Laurent Pinchart
2023-09-14 18:17 ` [PATCH 57/57] media: i2c: ov9734: " Laurent Pinchart

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=20230914181704.4811-1-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=arec.kao@intel.com \
    --cc=bingbu.cao@intel.com \
    --cc=daniele.alessandrelli@intel.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=jacopo@jmondi.org \
    --cc=jason.z.chen@intel.com \
    --cc=jimmy.su@intel.com \
    --cc=khalasa@piap.pl \
    --cc=linux-media@vger.kernel.org \
    --cc=martink@posteo.de \
    --cc=mike.rudenko@gmail.com \
    --cc=paul.j.murphy@intel.com \
    --cc=ribalda@kernel.org \
    --cc=sakari.ailus@iki.fi \
    --cc=tian.shu.qiu@intel.com \
    --cc=zhengsq@rock-chips.com \
    /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;
as well as URLs for NNTP newsgroup(s).