From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 246BBC2BA83 for ; Fri, 14 Feb 2020 09:46:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ECDBD20675 for ; Fri, 14 Feb 2020 09:46:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729211AbgBNJqN (ORCPT ); Fri, 14 Feb 2020 04:46:13 -0500 Received: from mga14.intel.com ([192.55.52.115]:29315 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729206AbgBNJqM (ORCPT ); Fri, 14 Feb 2020 04:46:12 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2020 01:46:11 -0800 X-IronPort-AV: E=Sophos;i="5.70,440,1574150400"; d="scan'208";a="347925547" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2020 01:46:09 -0800 Received: by paasikivi.fi.intel.com (Postfix, from userid 1000) id 3D0662088D; Fri, 14 Feb 2020 11:46:07 +0200 (EET) Date: Fri, 14 Feb 2020 11:46:07 +0200 From: Sakari Ailus To: Dafna Hirschfeld Cc: linux-media@vger.kernel.org, helen.koike@collabora.com, ezequiel@collabora.com, hverkuil@xs4all.nl, kernel@collabora.com, dafna3@gmail.com, linux-rockchip@lists.infradead.org, mchehab@kernel.org Subject: Re: [PATCH 3/4] media: staging: rkisp1: add serialization to the isp subdev ops Message-ID: <20200214094607.GG22481@paasikivi.fi.intel.com> References: <20200207085951.5226-1-dafna.hirschfeld@collabora.com> <20200207085951.5226-4-dafna.hirschfeld@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200207085951.5226-4-dafna.hirschfeld@collabora.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Hi Dafna, Thanks for the patchset. On Fri, Feb 07, 2020 at 09:59:50AM +0100, 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 > --- > 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; Could you add mutex_destroy() on the mutex in rkisp1_isp_unregister(), please? Similar comment on the 4th patch. This could be a follow-up patch, too. For the set, Acked-by: Sakari Ailus -- Kind regards, Sakari Ailus