From: Helen Koike <helen.koike@collabora.com>
To: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>,
linux-media@vger.kernel.org
Cc: ezequiel@collabora.com, hverkuil@xs4all.nl, kernel@collabora.com,
dafna3@gmail.com, sakari.ailus@linux.intel.com,
linux-rockchip@lists.infradead.org, mchehab@kernel.org
Subject: Re: [PATCH 3/4] media: staging: rkisp1: add serialization to the isp subdev ops
Date: Fri, 7 Feb 2020 10:54:51 -0300 [thread overview]
Message-ID: <88bba785-7dea-b8c9-b4a6-202e96e5a1a0@collabora.com> (raw)
In-Reply-To: <20200207085951.5226-4-dafna.hirschfeld@collabora.com>
On 2/7/20 6:59 AM, Dafna Hirschfeld wrote:
> For subdevices drivers, the drivers themself are responsible
> for serializing their operations.
> This patch adds serialization to the isp subdevice.
>
> Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Sakari, if you could take a look at this too it would be great.
Thanks,
Helen
> ---
> drivers/staging/media/rkisp1/rkisp1-common.h | 2 ++
> drivers/staging/media/rkisp1/rkisp1-isp.c | 29 ++++++++++++++------
> 2 files changed, 23 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/staging/media/rkisp1/rkisp1-common.h b/drivers/staging/media/rkisp1/rkisp1-common.h
> index 4e773d611d1b..7c668ac4bdd5 100644
> --- a/drivers/staging/media/rkisp1/rkisp1-common.h
> +++ b/drivers/staging/media/rkisp1/rkisp1-common.h
> @@ -96,6 +96,7 @@ struct rkisp1_sensor_async {
> * @sink_crop: crop for sink pad
> * @src_fmt: output format
> * @src_crop: output size
> + * @ops_lock: ops serialization
> *
> * @is_dphy_errctrl_disabled : if dphy errctrl is disabled (avoid endless interrupt)
> * @frame_sequence: used to synchronize frame_id between video devices.
> @@ -107,6 +108,7 @@ struct rkisp1_isp {
> struct v4l2_subdev_pad_config pad_cfg[RKISP1_ISP_PAD_MAX];
> const struct rkisp1_isp_mbus_info *sink_fmt;
> const struct rkisp1_isp_mbus_info *src_fmt;
> + struct mutex ops_lock;
> bool is_dphy_errctrl_disabled;
> atomic_t frame_sequence;
> };
> diff --git a/drivers/staging/media/rkisp1/rkisp1-isp.c b/drivers/staging/media/rkisp1/rkisp1-isp.c
> index c98e3c16f520..aa7a842f97f8 100644
> --- a/drivers/staging/media/rkisp1/rkisp1-isp.c
> +++ b/drivers/staging/media/rkisp1/rkisp1-isp.c
> @@ -791,7 +791,9 @@ static int rkisp1_isp_get_fmt(struct v4l2_subdev *sd,
> {
> struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd);
>
> + mutex_lock(&isp->ops_lock);
> fmt->format = *rkisp1_isp_get_pad_fmt(isp, cfg, fmt->pad, fmt->which);
> + mutex_unlock(&isp->ops_lock);
> return 0;
> }
>
> @@ -801,6 +803,7 @@ static int rkisp1_isp_set_fmt(struct v4l2_subdev *sd,
> {
> struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd);
>
> + mutex_lock(&isp->ops_lock);
> if (fmt->pad == RKISP1_ISP_PAD_SINK_VIDEO)
> rkisp1_isp_set_sink_fmt(isp, cfg, &fmt->format, fmt->which);
> else if (fmt->pad == RKISP1_ISP_PAD_SOURCE_VIDEO)
> @@ -809,6 +812,7 @@ static int rkisp1_isp_set_fmt(struct v4l2_subdev *sd,
> fmt->format = *rkisp1_isp_get_pad_fmt(isp, cfg, fmt->pad,
> fmt->which);
>
> + mutex_unlock(&isp->ops_lock);
> return 0;
> }
>
> @@ -817,11 +821,13 @@ static int rkisp1_isp_get_selection(struct v4l2_subdev *sd,
> struct v4l2_subdev_selection *sel)
> {
> struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd);
> + int ret = 0;
>
> if (sel->pad != RKISP1_ISP_PAD_SOURCE_VIDEO &&
> sel->pad != RKISP1_ISP_PAD_SINK_VIDEO)
> return -EINVAL;
>
> + mutex_lock(&isp->ops_lock);
> switch (sel->target) {
> case V4L2_SEL_TGT_CROP_BOUNDS:
> if (sel->pad == RKISP1_ISP_PAD_SINK_VIDEO) {
> @@ -844,10 +850,10 @@ static int rkisp1_isp_get_selection(struct v4l2_subdev *sd,
> sel->which);
> break;
> default:
> - return -EINVAL;
> + ret = -EINVAL;
> }
> -
> - return 0;
> + mutex_unlock(&isp->ops_lock);
> + return ret;
> }
>
> static int rkisp1_isp_set_selection(struct v4l2_subdev *sd,
> @@ -857,21 +863,23 @@ static int rkisp1_isp_set_selection(struct v4l2_subdev *sd,
> struct rkisp1_device *rkisp1 =
> container_of(sd->v4l2_dev, struct rkisp1_device, v4l2_dev);
> struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd);
> + int ret = 0;
>
> if (sel->target != V4L2_SEL_TGT_CROP)
> return -EINVAL;
>
> dev_dbg(rkisp1->dev, "%s: pad: %d sel(%d,%d)/%dx%d\n", __func__,
> sel->pad, sel->r.left, sel->r.top, sel->r.width, sel->r.height);
> -
> + mutex_lock(&isp->ops_lock);
> if (sel->pad == RKISP1_ISP_PAD_SINK_VIDEO)
> rkisp1_isp_set_sink_crop(isp, cfg, &sel->r, sel->which);
> else if (sel->pad == RKISP1_ISP_PAD_SOURCE_VIDEO)
> rkisp1_isp_set_src_crop(isp, cfg, &sel->r, sel->which);
> else
> - return -EINVAL;
> + ret = -EINVAL;
>
> - return 0;
> + mutex_unlock(&isp->ops_lock);
> + return ret;
> }
>
> static int rkisp1_subdev_link_validate(struct media_link *link)
> @@ -948,6 +956,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable)
> {
> struct rkisp1_device *rkisp1 =
> container_of(sd->v4l2_dev, struct rkisp1_device, v4l2_dev);
> + struct rkisp1_isp *isp = &rkisp1->isp;
> struct v4l2_subdev *sensor_sd;
> int ret = 0;
>
> @@ -967,16 +976,19 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable)
> return -EINVAL;
>
> atomic_set(&rkisp1->isp.frame_sequence, -1);
> + mutex_lock(&isp->ops_lock);
> ret = rkisp1_config_cif(rkisp1);
> if (ret)
> - return ret;
> + goto mutex_unlock;
>
> ret = rkisp1_mipi_csi2_start(&rkisp1->isp, rkisp1->active_sensor);
> if (ret)
> - return ret;
> + goto mutex_unlock;
>
> rkisp1_isp_start(rkisp1);
>
> +mutex_unlock:
> + mutex_unlock(&isp->ops_lock);
> return ret;
> }
>
> @@ -1036,6 +1048,7 @@ int rkisp1_isp_register(struct rkisp1_device *rkisp1,
> isp->sink_fmt = rkisp1_isp_mbus_info_get(RKISP1_DEF_SINK_PAD_FMT);
> isp->src_fmt = rkisp1_isp_mbus_info_get(RKISP1_DEF_SRC_PAD_FMT);
>
> + mutex_init(&isp->ops_lock);
> ret = media_entity_pads_init(&sd->entity, RKISP1_ISP_PAD_MAX, pads);
> if (ret)
> return ret;
>
next prev parent reply other threads:[~2020-02-07 13:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-07 8:59 [PATCH 0/4] media: staging: rkisp1: add serialization to the isp and resizer ops Dafna Hirschfeld
2020-02-07 8:59 ` [PATCH 1/4] media: staging: rkisp1: change function to return void instead of int Dafna Hirschfeld
2020-02-07 12:57 ` Helen Koike
2020-02-07 8:59 ` [PATCH 2/4] media: staging: rkisp1: isp: check for dphy bus before initializations in s_stream Dafna Hirschfeld
2020-02-07 12:57 ` Helen Koike
2020-02-07 8:59 ` [PATCH 3/4] media: staging: rkisp1: add serialization to the isp subdev ops Dafna Hirschfeld
2020-02-07 13:54 ` Helen Koike [this message]
2020-02-14 9:46 ` Sakari Ailus
2020-02-07 8:59 ` [PATCH 4/4] media: staging: rkisp1: add serialization to the resizer " Dafna Hirschfeld
2020-02-07 13:56 ` Helen Koike
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=88bba785-7dea-b8c9-b4a6-202e96e5a1a0@collabora.com \
--to=helen.koike@collabora.com \
--cc=dafna.hirschfeld@collabora.com \
--cc=dafna3@gmail.com \
--cc=ezequiel@collabora.com \
--cc=hverkuil@xs4all.nl \
--cc=kernel@collabora.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.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).