From: paul.elder@ideasonboard.com
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org,
Dafna Hirschfeld <dafna@fastmail.com>,
Heiko Stuebner <heiko@sntech.de>,
Helen Koike <helen.koike@collabora.com>
Subject: Re: [PATCH v2 18/55] media: rkisp1: Fix sensor source pad retrieval at bound time
Date: Thu, 7 Jul 2022 23:01:23 +0900 [thread overview]
Message-ID: <20220707140123.GM3886060@pyrite.rasen.tech> (raw)
In-Reply-To: <20220630230713.10580-19-laurent.pinchart@ideasonboard.com>
Hi Laurent,
On Fri, Jul 01, 2022 at 02:06:36AM +0300, Laurent Pinchart wrote:
> When a sensor is bound, its source pad is retrieved in the .bound()
> operation with a call to media_entity_get_fwnode_pad(). The function
> should be called with the source endpoint fwnode of the sensor, but is
> instead called with the sensor's device fwnode.
>
> Fix this, which involves storing a reference to the source endpoint
> fwnode in the rkisp1_sensor_async structure, and thus implementing the
> subdev notifier .destroy() operation to release the reference.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> .../platform/rockchip/rkisp1/rkisp1-common.h | 2 ++
> .../platform/rockchip/rkisp1/rkisp1-dev.c | 28 ++++++++++++++++---
> 2 files changed, 26 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h
> index b0896b508db3..f08b3dec1465 100644
> --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h
> +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h
> @@ -117,6 +117,7 @@ struct rkisp1_info {
> *
> * @asd: async_subdev variable for the sensor
> * @index: index of the sensor (counting sensor found in DT)
> + * @source_ep: fwnode for the sensor source endpoint
> * @lanes: number of lanes
> * @mbus_type: type of bus (currently only CSI2 is supported)
> * @mbus_flags: media bus (V4L2_MBUS_*) flags
> @@ -127,6 +128,7 @@ struct rkisp1_info {
> struct rkisp1_sensor_async {
> struct v4l2_async_subdev asd;
> unsigned int index;
> + struct fwnode_handle *source_ep;
> unsigned int lanes;
> enum v4l2_mbus_type mbus_type;
> unsigned int mbus_flags;
> diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
> index 2e68f35e8ea5..813c013139ea 100644
> --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
> +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
> @@ -138,7 +138,7 @@ static int rkisp1_subdev_notifier_bound(struct v4l2_async_notifier *notifier,
> phy_init(s_asd->dphy);
>
> /* Create the link to the sensor. */
> - source_pad = media_entity_get_fwnode_pad(&sd->entity, sd->fwnode,
> + source_pad = media_entity_get_fwnode_pad(&sd->entity, s_asd->source_ep,
> MEDIA_PAD_FL_SOURCE);
> if (source_pad < 0) {
> dev_err(rkisp1->dev, "failed to find source pad for %s\n",
> @@ -170,10 +170,19 @@ static int rkisp1_subdev_notifier_complete(struct v4l2_async_notifier *notifier)
> return v4l2_device_register_subdev_nodes(&rkisp1->v4l2_dev);
> }
>
> +static void rkisp1_subdev_notifier_destroy(struct v4l2_async_subdev *asd)
> +{
> + struct rkisp1_sensor_async *rk_asd =
> + container_of(asd, struct rkisp1_sensor_async, asd);
> +
> + fwnode_handle_put(rk_asd->source_ep);
> +}
> +
> static const struct v4l2_async_notifier_operations rkisp1_subdev_notifier_ops = {
> .bound = rkisp1_subdev_notifier_bound,
> .unbind = rkisp1_subdev_notifier_unbind,
> .complete = rkisp1_subdev_notifier_complete,
> + .destroy = rkisp1_subdev_notifier_destroy,
> };
>
> static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1)
> @@ -190,6 +199,7 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1)
> .bus_type = V4L2_MBUS_CSI2_DPHY
> };
> struct rkisp1_sensor_async *rk_asd;
> + struct fwnode_handle *source = NULL;
> struct fwnode_handle *ep;
>
> ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(rkisp1->dev),
> @@ -202,15 +212,24 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1)
> if (ret)
> goto err_parse;
>
> - rk_asd = v4l2_async_nf_add_fwnode_remote(ntf, ep,
> - struct
> - rkisp1_sensor_async);
> + source = fwnode_graph_get_remote_endpoint(ep);
> + if (!source) {
> + dev_err(rkisp1->dev,
> + "endpoint %pfw has no remote endpoint\n",
> + ep);
> + ret = -ENODEV;
> + goto err_parse;
source is error here so you don't need to fwnode_handle_put() it later I
think.
Paul
> + }
> +
> + rk_asd = v4l2_async_nf_add_fwnode(ntf, source,
> + struct rkisp1_sensor_async);
> if (IS_ERR(rk_asd)) {
> ret = PTR_ERR(rk_asd);
> goto err_parse;
> }
>
> rk_asd->index = index++;
> + rk_asd->source_ep = source;
> rk_asd->mbus_type = vep.bus_type;
> rk_asd->mbus_flags = vep.bus.mipi_csi2.flags;
> rk_asd->lanes = vep.bus.mipi_csi2.num_data_lanes;
> @@ -225,6 +244,7 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1)
> continue;
> err_parse:
> fwnode_handle_put(ep);
> + fwnode_handle_put(source);
> v4l2_async_nf_cleanup(ntf);
> return ret;
> }
next prev parent reply other threads:[~2022-07-07 14:01 UTC|newest]
Thread overview: 102+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-30 23:06 [PATCH v2 00/55] media: rkisp1: Cleanups and add support for i.MX8MP Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 01/55] media: v4l2-async: Add notifier operation to destroy asd instances Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 02/55] media: mc-entity: Rename media_entity_remote_pad() to media_pad_remote_pad_first() Laurent Pinchart
2022-07-07 6:55 ` Hans Verkuil
2022-06-30 23:06 ` [PATCH v2 03/55] media: mc-entity: Add a new helper function to get a remote pad Laurent Pinchart
2022-07-07 6:57 ` Hans Verkuil
2022-07-07 9:59 ` [PATCH v2.1 " Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 04/55] media: mc-entity: Add a new helper function to get a remote pad for a pad Laurent Pinchart
2022-07-07 7:01 ` Hans Verkuil
2022-07-07 9:59 ` [PATCH v2.1 " Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 05/55] media: rkisp1: Enable compilation on ARCH_MXC Laurent Pinchart
2022-07-07 13:40 ` paul.elder
2022-06-30 23:06 ` [PATCH v2 06/55] media: rkisp1: Disable runtime PM in probe error path Laurent Pinchart
2022-07-07 13:39 ` paul.elder
2022-06-30 23:06 ` [PATCH v2 07/55] media: rkisp1: Read the ID register at probe time instead of streamon Laurent Pinchart
2022-07-07 13:39 ` paul.elder
2022-06-30 23:06 ` [PATCH v2 08/55] media: rkisp1: Rename rkisp1_match_data to rkisp1_info Laurent Pinchart
2022-07-07 13:38 ` paul.elder
2022-06-30 23:06 ` [PATCH v2 09/55] media: rkisp1: Save info pointer in rkisp1_device Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 10/55] media: rkisp1: Access ISP version from info pointer Laurent Pinchart
2022-07-07 13:38 ` paul.elder
2022-06-30 23:06 ` [PATCH v2 11/55] media: rkisp1: Make rkisp1_isp_mbus_info common Laurent Pinchart
2022-07-04 4:34 ` paul.elder
2022-06-30 23:06 ` [PATCH v2 12/55] media: rkisp1: cap: Print debug message on failed link validation Laurent Pinchart
2022-07-07 2:45 ` paul.elder
2022-07-10 19:40 ` Dafna Hirschfeld
2022-06-30 23:06 ` [PATCH v2 13/55] media: rkisp1: Move sensor .s_stream() call to ISP Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 14/55] media: rkisp1: Reject sensors without pixel rate control at bound time Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 15/55] media: rkisp1: Create link from sensor to ISP at notifier " Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 16/55] media: rkisp1: Create internal links at probe time Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 17/55] media: rkisp1: Rename rkisp1_subdev_notifier() to rkisp1_subdev_notifier_register() Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 18/55] media: rkisp1: Fix sensor source pad retrieval at bound time Laurent Pinchart
2022-07-07 14:01 ` paul.elder [this message]
2022-07-07 14:47 ` Laurent Pinchart
2022-07-07 14:50 ` paul.elder
2022-07-10 19:49 ` Dafna Hirschfeld
2022-06-30 23:06 ` [PATCH v2 19/55] media: rkisp1: Split CSI handling to separate file Laurent Pinchart
2022-07-11 0:40 ` Dafna Hirschfeld
2022-06-30 23:06 ` [PATCH v2 20/55] media: rkisp1: isp: Start CSI-2 receiver before ISP Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 21/55] media: rkisp1: csi: Handle CSI-2 RX configuration fully in rkisp1-csi.c Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 22/55] media: rkisp1: csi: Rename CSI functions with a common rkisp1_csi prefix Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 23/55] media: rkisp1: csi: Move start delay to rkisp1_csi_start() Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 24/55] media: rkisp1: csi: Pass sensor pointer to rkisp1_csi_config() Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 25/55] media: rkisp1: csi: Constify argument to rkisp1_csi_start() Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 26/55] media: rkisp1: isp: Don't initialize ret to 0 in rkisp1_isp_s_stream() Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 27/55] media: rkisp1: isp: Pass mbus type and flags to rkisp1_config_cif() Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 28/55] media: rkisp1: isp: Rename rkisp1_device.active_sensor to source Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 29/55] media: rkisp1: isp: Add container_of wrapper to cast subdev to rkisp1_isp Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 30/55] media: rkisp1: isp: Add rkisp1_device backpointer " Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 31/55] media: rkisp1: isp: Pass rkisp1_isp pointer to internal ISP functions Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 32/55] media: rkisp1: isp: Move input configuration to rkisp1_config_isp() Laurent Pinchart
2022-07-07 14:12 ` paul.elder
2022-07-11 0:48 ` Dafna Hirschfeld
2022-06-30 23:06 ` [PATCH v2 33/55] media: rkisp1: isp: Merge ISP_ACQ_PROP configuration in single variable Laurent Pinchart
2022-07-07 14:53 ` paul.elder
2022-06-30 23:06 ` [PATCH v2 34/55] media: rkisp1: isp: Initialize some variables at declaration time Laurent Pinchart
2022-07-07 14:54 ` paul.elder
2022-06-30 23:06 ` [PATCH v2 35/55] media: rkisp1: isp: Fix whitespace issues Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 36/55] media: rkisp1: isp: Constify various local variables Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 37/55] media: rkisp1: isp: Rename rkisp1_get_remote_source() Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 38/55] media: rkisp1: isp: Disallow multiple active sources Laurent Pinchart
2022-07-07 14:48 ` paul.elder
2022-07-11 0:56 ` Dafna Hirschfeld
2022-07-11 1:03 ` Laurent Pinchart
2022-07-11 1:06 ` [PATCH v2.1 " Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 39/55] media: rkisp1: csi: Implement a V4L2 subdev for the CSI receiver Laurent Pinchart
2022-07-11 1:22 ` Dafna Hirschfeld
2022-07-11 8:20 ` Laurent Pinchart
2022-06-30 23:06 ` [PATCH v2 40/55] media: rkisp1: csi: Plumb the CSI RX subdev Laurent Pinchart
2022-07-11 1:33 ` Dafna Hirschfeld
2022-06-30 23:06 ` [PATCH v2 41/55] media: rkisp1: Use fwnode_graph_for_each_endpoint Laurent Pinchart
2022-07-11 1:38 ` Dafna Hirschfeld
2022-06-30 23:07 ` [PATCH v2 42/55] dt-bindings: media: rkisp1: Add port for parallel interface Laurent Pinchart
2022-07-01 20:17 ` Rob Herring
2022-06-30 23:07 ` [PATCH v2 43/55] media: rkisp1: Support the ISP parallel input Laurent Pinchart
2022-07-11 2:12 ` Dafna Hirschfeld
2022-06-30 23:07 ` [PATCH v2 44/55] media: rkisp1: Add infrastructure to support ISP features Laurent Pinchart
2022-07-11 2:29 ` Dafna Hirschfeld
2022-06-30 23:07 ` [PATCH v2 45/55] media: rkisp1: Make the internal CSI-2 receiver optional Laurent Pinchart
2022-07-11 2:39 ` Dafna Hirschfeld
2022-06-30 23:07 ` [PATCH v2 46/55] media: rkisp1: debug: Add dump file in debugfs for MI buffer registers Laurent Pinchart
2022-07-11 2:51 ` Dafna Hirschfeld
2022-07-11 12:04 ` Laurent Pinchart
2022-06-30 23:07 ` [PATCH v2 47/55] dt-bindings: media: rkisp1: Add i.MX8MP ISP to compatible Laurent Pinchart
2022-07-01 20:18 ` Rob Herring
2022-06-30 23:07 ` [PATCH v2 48/55] media: rkisp1: Add match data for i.MX8MP ISP Laurent Pinchart
2022-07-15 11:56 ` Adam Ford
2022-07-17 14:56 ` Laurent Pinchart
2022-07-17 15:23 ` Laurent Pinchart
2022-07-17 18:04 ` Adam Ford
2022-06-30 23:07 ` [PATCH v2 49/55] media: rkisp1: Configure gasket on i.MX8MP Laurent Pinchart
2022-06-30 23:07 ` [PATCH v2 50/55] media: rkisp1: Add and set registers for crop for i.MX8MP Laurent Pinchart
2022-07-11 2:57 ` Dafna Hirschfeld
2022-06-30 23:07 ` [PATCH v2 51/55] media: rkisp1: Add and set registers for output size config on i.MX8MP Laurent Pinchart
2022-07-11 2:59 ` Dafna Hirschfeld
2022-06-30 23:07 ` [PATCH v2 52/55] media: rkisp1: Add i.MX8MP-specific registers for MI and resizer Laurent Pinchart
2022-07-11 3:02 ` Dafna Hirschfeld
2022-06-30 23:07 ` [PATCH v2 53/55] media: rkisp1: Shift DMA buffer addresses on i.MX8MP Laurent Pinchart
2022-06-30 23:07 ` [PATCH v2 54/55] media: rkisp1: Add register definitions for the test pattern generator Laurent Pinchart
2022-07-11 3:42 ` Dafna Hirschfeld
2022-06-30 23:07 ` [PATCH v2 55/55] media: rkisp1: Fix RSZ_CTRL bits for i.MX8MP Laurent Pinchart
2022-07-07 10:58 ` [PATCH v2 00/55] media: rkisp1: Cleanups and add support " Sakari Ailus
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=20220707140123.GM3886060@pyrite.rasen.tech \
--to=paul.elder@ideasonboard.com \
--cc=dafna@fastmail.com \
--cc=heiko@sntech.de \
--cc=helen.koike@collabora.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.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