All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
To: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Cc: linux-media <linux-media@vger.kernel.org>,
	devicetree <devicetree@vger.kernel.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-doc@vger.kernel.org, devel@driverdev.osuosl.org,
	linux-sunxi@googlegroups.com, Yong Deng <yong.deng@magewell.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Maxime Ripard <mripard@kernel.org>, Chen-Yu Tsai <wens@csie.org>,
	Jernej Skrabec <jernej.skrabec@siol.net>,
	Jonathan Corbet <corbet@lwn.net>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Vinod Koul <vkoul@kernel.org>,
	Helen Koike <helen.koike@collabora.com>,
	Dafna Hirschfeld <dafna.hirschfeld@collabora.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Hans Verkuil <hans.verkuil@cisco.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	kevin.lhopital@hotmail.com
Subject: Re: [linux-sunxi] [PATCH v4 09/15] media: sunxi: Add support for the A31 MIPI CSI-2 controller
Date: Thu, 14 Jan 2021 10:30:01 +0100	[thread overview]
Message-ID: <YAAPGZCK/TffZChD@aptenodytes> (raw)
In-Reply-To: <CAAEAJfAJYCE2z662hPderJ-5Qv3WBA8K5ZQaZ1JuZbZN+KfFig@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4487 bytes --]

Hey Ezequiel,

On Mon 11 Jan 21, 15:21, Ezequiel Garcia wrote:
> Salut Paul,
> 
> Just a minor comment about the v4l2 async API.
>
> On Thu, 31 Dec 2020 at 11:30, Paul Kocialkowski
> <paul.kocialkowski@bootlin.com> wrote:
> >
> > The A31 MIPI CSI-2 controller is a dedicated MIPI CSI-2 bridge
> > found on Allwinner SoCs such as the A31 and V3/V3s.
> >
> > It is a standalone block, connected to the CSI controller on one side
> > and to the MIPI D-PHY block on the other. It has a dedicated address
> > space, interrupt line and clock.
> >
> > It is represented as a V4L2 subdev to the CSI controller and takes a
> > MIPI CSI-2 sensor as its own subdev, all using the fwnode graph and
> > media controller API.
> >
> > Only 8-bit and 10-bit Bayer formats are currently supported.
> > While up to 4 internal channels to the CSI controller exist, only one
> > is currently supported by this implementation.
> >
> > Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > ---
> >  drivers/media/platform/sunxi/Kconfig          |   1 +
> >  drivers/media/platform/sunxi/Makefile         |   1 +
> >  .../platform/sunxi/sun6i-mipi-csi2/Kconfig    |  12 +
> >  .../platform/sunxi/sun6i-mipi-csi2/Makefile   |   4 +
> >  .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c   | 590 ++++++++++++++++++
> >  .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.h   | 117 ++++
> >  6 files changed, 725 insertions(+)
> >  create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/Kconfig
> >  create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/Makefile
> >  create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
> >  create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.h
> >
> [..]
> > +static int sun6i_mipi_csi2_v4l2_setup(struct sun6i_mipi_csi2_dev *cdev)
> > +{
> > +       struct sun6i_mipi_csi2_video *video = &cdev->video;
> > +       struct v4l2_subdev *subdev = &video->subdev;
> > +       struct v4l2_async_notifier *notifier = &video->notifier;
> > +       struct fwnode_handle *handle;
> > +       struct v4l2_fwnode_endpoint *endpoint;
> > +       struct v4l2_async_subdev *subdev_async;
> > +       int ret;
> > +
> > +       /* Subdev */
> > +
> > +       v4l2_subdev_init(subdev, &sun6i_mipi_csi2_subdev_ops);
> > +       subdev->dev = cdev->dev;
> > +       subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
> > +       strscpy(subdev->name, MODULE_NAME, sizeof(subdev->name));
> > +       v4l2_set_subdevdata(subdev, cdev);
> > +
> > +       /* Entity */
> > +
> > +       subdev->entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;
> > +       subdev->entity.ops = &sun6i_mipi_csi2_entity_ops;
> > +
> > +       /* Pads */
> > +
> > +       video->pads[0].flags = MEDIA_PAD_FL_SINK;
> > +       video->pads[1].flags = MEDIA_PAD_FL_SOURCE;
> > +
> > +       ret = media_entity_pads_init(&subdev->entity, 2, video->pads);
> > +       if (ret)
> > +               return ret;
> > +
> > +       /* Endpoint */
> > +
> > +       handle = fwnode_graph_get_endpoint_by_id(dev_fwnode(cdev->dev), 0, 0,
> > +                                                FWNODE_GRAPH_ENDPOINT_NEXT);
> > +       if (!handle) {
> > +               ret = -ENODEV;
> > +               goto error_media_entity;
> > +       }
> > +
> > +       endpoint = &video->endpoint;
> > +       endpoint->bus_type = V4L2_MBUS_CSI2_DPHY;
> > +
> > +       ret = v4l2_fwnode_endpoint_parse(handle, endpoint);
> > +       fwnode_handle_put(handle);
> 
> I think the _put should be...
> 
> > +       if (ret)
> > +               goto error_media_entity;
> > +
> > +       /* Notifier */
> > +
> > +       v4l2_async_notifier_init(notifier);
> > +
> > +       subdev_async = &video->subdev_async;
> > +       ret = v4l2_async_notifier_add_fwnode_remote_subdev(notifier, handle,
> > +                                                          subdev_async);
> 
> ... here. See for instance drivers/media/platform/rcar-vin/rcar-csi2.c.
> 
> (Unless I've missed something, of course).

I think you're right, the reference is obtained at
fwnode_graph_get_endpoint_by_id and should be held when passing handle to
v4l2_async_notifier_add_fwnode_remote_subdev since it will be used to get
a reference to the remote port.

Good catch and thanks for the review!

Paul

-- 
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
To: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Cc: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>,
	linux-doc@vger.kernel.org, linux-sunxi@googlegroups.com,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	kevin.lhopital@hotmail.com, devel@driverdev.osuosl.org,
	Jonathan Corbet <corbet@lwn.net>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Chen-Yu Tsai <wens@csie.org>,
	Hans Verkuil <hans.verkuil@cisco.com>,
	linux-media <linux-media@vger.kernel.org>,
	devicetree <devicetree@vger.kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Helen Koike <helen.koike@collabora.com>,
	Rob Herring <robh+dt@kernel.org>,
	Yong Deng <yong.deng@magewell.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	Jernej Skrabec <jernej.skrabec@siol.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Vinod Koul <vkoul@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>
Subject: Re: [linux-sunxi] [PATCH v4 09/15] media: sunxi: Add support for the A31 MIPI CSI-2 controller
Date: Thu, 14 Jan 2021 10:30:01 +0100	[thread overview]
Message-ID: <YAAPGZCK/TffZChD@aptenodytes> (raw)
In-Reply-To: <CAAEAJfAJYCE2z662hPderJ-5Qv3WBA8K5ZQaZ1JuZbZN+KfFig@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 4487 bytes --]

Hey Ezequiel,

On Mon 11 Jan 21, 15:21, Ezequiel Garcia wrote:
> Salut Paul,
> 
> Just a minor comment about the v4l2 async API.
>
> On Thu, 31 Dec 2020 at 11:30, Paul Kocialkowski
> <paul.kocialkowski@bootlin.com> wrote:
> >
> > The A31 MIPI CSI-2 controller is a dedicated MIPI CSI-2 bridge
> > found on Allwinner SoCs such as the A31 and V3/V3s.
> >
> > It is a standalone block, connected to the CSI controller on one side
> > and to the MIPI D-PHY block on the other. It has a dedicated address
> > space, interrupt line and clock.
> >
> > It is represented as a V4L2 subdev to the CSI controller and takes a
> > MIPI CSI-2 sensor as its own subdev, all using the fwnode graph and
> > media controller API.
> >
> > Only 8-bit and 10-bit Bayer formats are currently supported.
> > While up to 4 internal channels to the CSI controller exist, only one
> > is currently supported by this implementation.
> >
> > Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > ---
> >  drivers/media/platform/sunxi/Kconfig          |   1 +
> >  drivers/media/platform/sunxi/Makefile         |   1 +
> >  .../platform/sunxi/sun6i-mipi-csi2/Kconfig    |  12 +
> >  .../platform/sunxi/sun6i-mipi-csi2/Makefile   |   4 +
> >  .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c   | 590 ++++++++++++++++++
> >  .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.h   | 117 ++++
> >  6 files changed, 725 insertions(+)
> >  create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/Kconfig
> >  create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/Makefile
> >  create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
> >  create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.h
> >
> [..]
> > +static int sun6i_mipi_csi2_v4l2_setup(struct sun6i_mipi_csi2_dev *cdev)
> > +{
> > +       struct sun6i_mipi_csi2_video *video = &cdev->video;
> > +       struct v4l2_subdev *subdev = &video->subdev;
> > +       struct v4l2_async_notifier *notifier = &video->notifier;
> > +       struct fwnode_handle *handle;
> > +       struct v4l2_fwnode_endpoint *endpoint;
> > +       struct v4l2_async_subdev *subdev_async;
> > +       int ret;
> > +
> > +       /* Subdev */
> > +
> > +       v4l2_subdev_init(subdev, &sun6i_mipi_csi2_subdev_ops);
> > +       subdev->dev = cdev->dev;
> > +       subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
> > +       strscpy(subdev->name, MODULE_NAME, sizeof(subdev->name));
> > +       v4l2_set_subdevdata(subdev, cdev);
> > +
> > +       /* Entity */
> > +
> > +       subdev->entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;
> > +       subdev->entity.ops = &sun6i_mipi_csi2_entity_ops;
> > +
> > +       /* Pads */
> > +
> > +       video->pads[0].flags = MEDIA_PAD_FL_SINK;
> > +       video->pads[1].flags = MEDIA_PAD_FL_SOURCE;
> > +
> > +       ret = media_entity_pads_init(&subdev->entity, 2, video->pads);
> > +       if (ret)
> > +               return ret;
> > +
> > +       /* Endpoint */
> > +
> > +       handle = fwnode_graph_get_endpoint_by_id(dev_fwnode(cdev->dev), 0, 0,
> > +                                                FWNODE_GRAPH_ENDPOINT_NEXT);
> > +       if (!handle) {
> > +               ret = -ENODEV;
> > +               goto error_media_entity;
> > +       }
> > +
> > +       endpoint = &video->endpoint;
> > +       endpoint->bus_type = V4L2_MBUS_CSI2_DPHY;
> > +
> > +       ret = v4l2_fwnode_endpoint_parse(handle, endpoint);
> > +       fwnode_handle_put(handle);
> 
> I think the _put should be...
> 
> > +       if (ret)
> > +               goto error_media_entity;
> > +
> > +       /* Notifier */
> > +
> > +       v4l2_async_notifier_init(notifier);
> > +
> > +       subdev_async = &video->subdev_async;
> > +       ret = v4l2_async_notifier_add_fwnode_remote_subdev(notifier, handle,
> > +                                                          subdev_async);
> 
> ... here. See for instance drivers/media/platform/rcar-vin/rcar-csi2.c.
> 
> (Unless I've missed something, of course).

I think you're right, the reference is obtained at
fwnode_graph_get_endpoint_by_id and should be held when passing handle to
v4l2_async_notifier_add_fwnode_remote_subdev since it will be used to get
a reference to the remote port.

Good catch and thanks for the review!

Paul

-- 
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-01-14  9:31 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-31 14:29 [PATCH v4 00/15] Allwinner MIPI CSI-2 support for A31/V3s/A83T Paul Kocialkowski
2020-12-31 14:29 ` Paul Kocialkowski
2020-12-31 14:29 ` [PATCH v4 01/15] docs: phy: Add a part about PHY mode and submode Paul Kocialkowski
2020-12-31 14:29   ` Paul Kocialkowski
2020-12-31 14:29 ` [PATCH v4 02/15] phy: Distinguish between Rx and Tx for MIPI D-PHY with submodes Paul Kocialkowski
2020-12-31 14:29   ` Paul Kocialkowski
2020-12-31 14:29 ` [PATCH v4 03/15] phy: allwinner: phy-sun6i-mipi-dphy: Support D-PHY Rx mode for MIPI CSI-2 Paul Kocialkowski
2020-12-31 14:29   ` Paul Kocialkowski
2020-12-31 14:29 ` [PATCH v4 04/15] media: sun6i-csi: Use common V4L2 format info for storage bpp Paul Kocialkowski
2020-12-31 14:29   ` Paul Kocialkowski
2020-12-31 14:29 ` [PATCH v4 05/15] media: sun6i-csi: Only configure the interface data width for parallel Paul Kocialkowski
2020-12-31 14:29   ` Paul Kocialkowski
2021-01-08  9:56   ` Maxime Ripard
2021-01-08  9:56     ` Maxime Ripard
2020-12-31 14:29 ` [PATCH v4 06/15] dt-bindings: media: sun6i-a31-csi: Add MIPI CSI-2 input port Paul Kocialkowski
2020-12-31 14:29   ` Paul Kocialkowski
2021-01-08  9:48   ` Maxime Ripard
2021-01-08  9:48     ` Maxime Ripard
2020-12-31 14:29 ` [PATCH v4 07/15] media: sun6i-csi: Add support for MIPI CSI-2 bridge input Paul Kocialkowski
2020-12-31 14:29   ` Paul Kocialkowski
2021-01-08  9:52   ` Maxime Ripard
2021-01-08  9:52     ` Maxime Ripard
2020-12-31 14:29 ` [PATCH v4 08/15] dt-bindings: media: Add A31 MIPI CSI-2 bindings documentation Paul Kocialkowski
2020-12-31 14:29   ` Paul Kocialkowski
2021-01-08  9:52   ` Maxime Ripard
2021-01-08  9:52     ` Maxime Ripard
2021-01-11 22:20   ` Rob Herring
2021-01-11 22:20     ` Rob Herring
2020-12-31 14:29 ` [PATCH v4 09/15] media: sunxi: Add support for the A31 MIPI CSI-2 controller Paul Kocialkowski
2020-12-31 14:29   ` Paul Kocialkowski
2021-01-08  9:54   ` Maxime Ripard
2021-01-08  9:54     ` Maxime Ripard
2021-01-09 22:24   ` Samuel Holland
2021-01-09 22:24     ` Samuel Holland
2021-01-11 17:15     ` Paul Kocialkowski
2021-01-11 17:15       ` Paul Kocialkowski
2021-01-11 18:21   ` [linux-sunxi] " Ezequiel Garcia
2021-01-11 18:21     ` Ezequiel Garcia
2021-01-14  9:30     ` Paul Kocialkowski [this message]
2021-01-14  9:30       ` Paul Kocialkowski
2020-12-31 14:29 ` [PATCH v4 10/15] ARM: dts: sun8i: v3s: Add nodes for MIPI CSI-2 support Paul Kocialkowski
2020-12-31 14:29   ` Paul Kocialkowski
2020-12-31 14:29 ` [PATCH v4 11/15] MAINTAINERS: Add entry for the Allwinner A31 MIPI CSI-2 bridge Paul Kocialkowski
2020-12-31 14:29   ` Paul Kocialkowski
2020-12-31 14:29 ` [PATCH v4 12/15] dt-bindings: media: Add A83T MIPI CSI-2 bindings documentation Paul Kocialkowski
2020-12-31 14:29   ` Paul Kocialkowski
2020-12-31 14:29 ` [PATCH v4 13/15] media: sunxi: Add support for the A83T MIPI CSI-2 controller Paul Kocialkowski
2020-12-31 14:29   ` Paul Kocialkowski
2021-01-08  9:56   ` Maxime Ripard
2021-01-08  9:56     ` Maxime Ripard
2020-12-31 14:29 ` [PATCH v4 14/15] ARM: dts: sun8i: a83t: Add MIPI CSI-2 controller node Paul Kocialkowski
2020-12-31 14:29   ` Paul Kocialkowski
2020-12-31 14:29 ` [PATCH v4 15/15] MAINTAINERS: Add entry for the Allwinner A83T MIPI CSI-2 bridge Paul Kocialkowski
2020-12-31 14:29   ` Paul Kocialkowski

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=YAAPGZCK/TffZChD@aptenodytes \
    --to=paul.kocialkowski@bootlin.com \
    --cc=corbet@lwn.net \
    --cc=dafna.hirschfeld@collabora.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=devicetree@vger.kernel.org \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=gregkh@linuxfoundation.org \
    --cc=hans.verkuil@cisco.com \
    --cc=helen.koike@collabora.com \
    --cc=jernej.skrabec@siol.net \
    --cc=kevin.lhopital@hotmail.com \
    --cc=kishon@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=mchehab@kernel.org \
    --cc=mripard@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=vkoul@kernel.org \
    --cc=wens@csie.org \
    --cc=yong.deng@magewell.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.