From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Wentong Wu <wentong.wu@intel.com>
Cc: linux-media@vger.kernel.org, hao.yao@intel.com,
Jason Chen <jason.z.chen@intel.com>
Subject: Re: [PATCH 2/3] media: ivsc: csi: add separate lock for v4l2 control handler
Date: Fri, 7 Jun 2024 12:41:05 +0000 [thread overview]
Message-ID: <ZmL_4f8UIab5qaZp@kekkonen.localdomain> (raw)
In-Reply-To: <20240603082614.1567712-3-wentong.wu@intel.com>
Hi Wentong,
Thanks for the patchset.
On Mon, Jun 03, 2024 at 04:26:13PM +0800, Wentong Wu wrote:
> There're possibilities that privacy status change notification happens
> in the middle of the ongoing mei command which already takes the command
> lock, but v4l2_ctrl_s_ctrl() would also need the same lock prior to this
> patch, so this may results in circular locking problem. This patch adds
> one dedicated lock for v4l2 control handler to avoid described issue.
Before this patch, wouldn't the ongoing MEI command simply complete before
v4l2_ctrl_s_ctrl() could proceed?
>
> Reported-by: Hao Yao <hao.yao@intel.com>
> Signed-off-by: Wentong Wu <wentong.wu@intel.com>
> Tested-by: Jason Chen <jason.z.chen@intel.com>
> ---
> drivers/media/pci/intel/ivsc/mei_csi.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/pci/intel/ivsc/mei_csi.c b/drivers/media/pci/intel/ivsc/mei_csi.c
> index 004ebab0b814..d6ba0d9efca1 100644
> --- a/drivers/media/pci/intel/ivsc/mei_csi.c
> +++ b/drivers/media/pci/intel/ivsc/mei_csi.c
> @@ -126,6 +126,8 @@ struct mei_csi {
> struct v4l2_ctrl_handler ctrl_handler;
> struct v4l2_ctrl *freq_ctrl;
> struct v4l2_ctrl *privacy_ctrl;
> + /* lock for v4l2 controls */
> + struct mutex ctrl_lock;
> unsigned int remote_pad;
> /* start streaming or not */
> int streaming;
> @@ -563,11 +565,13 @@ static int mei_csi_init_controls(struct mei_csi *csi)
> u32 max;
> int ret;
>
> + mutex_init(&csi->ctrl_lock);
> +
> ret = v4l2_ctrl_handler_init(&csi->ctrl_handler, 2);
> if (ret)
> return ret;
>
> - csi->ctrl_handler.lock = &csi->lock;
> + csi->ctrl_handler.lock = &csi->ctrl_lock;
>
> max = ARRAY_SIZE(link_freq_menu_items) - 1;
> csi->freq_ctrl = v4l2_ctrl_new_int_menu(&csi->ctrl_handler,
> @@ -756,6 +760,7 @@ static int mei_csi_probe(struct mei_cl_device *cldev,
>
> err_ctrl_handler:
> v4l2_ctrl_handler_free(&csi->ctrl_handler);
> + mutex_destroy(&csi->ctrl_lock);
> v4l2_async_nf_unregister(&csi->notifier);
> v4l2_async_nf_cleanup(&csi->notifier);
>
> @@ -775,6 +780,7 @@ static void mei_csi_remove(struct mei_cl_device *cldev)
> v4l2_async_nf_unregister(&csi->notifier);
> v4l2_async_nf_cleanup(&csi->notifier);
> v4l2_ctrl_handler_free(&csi->ctrl_handler);
> + mutex_destroy(&csi->ctrl_lock);
> v4l2_async_unregister_subdev(&csi->subdev);
> v4l2_subdev_cleanup(&csi->subdev);
> media_entity_cleanup(&csi->subdev.entity);
--
Kind regards,
Sakari Ailus
next prev parent reply other threads:[~2024-06-07 12:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-03 8:26 [PATCH 0/3] Fix privacy issue for MEI CSI Wentong Wu
2024-06-03 8:26 ` [PATCH 1/3] media: ivsc: csi: don't count privacy on as error Wentong Wu
2024-06-07 12:45 ` Sakari Ailus
2024-06-07 12:55 ` Wu, Wentong
2024-06-03 8:26 ` [PATCH 2/3] media: ivsc: csi: add separate lock for v4l2 control handler Wentong Wu
2024-06-07 12:41 ` Sakari Ailus [this message]
2024-06-07 12:53 ` Wu, Wentong
2024-06-03 8:26 ` [PATCH 3/3] media: ivsc: csi: remove privacy status in struct mei_csi Wentong Wu
2024-06-07 12:45 ` Sakari Ailus
2024-06-07 12:54 ` Wu, Wentong
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=ZmL_4f8UIab5qaZp@kekkonen.localdomain \
--to=sakari.ailus@linux.intel.com \
--cc=hao.yao@intel.com \
--cc=jason.z.chen@intel.com \
--cc=linux-media@vger.kernel.org \
--cc=wentong.wu@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 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.