linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: Sakari Ailus <sakari.ailus@linux.intel.com>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	linux-media@vger.kernel.org
Cc: "Kieran Bingham" <kieran.bingham@ideasonboard.com>,
	linux-renesas-soc@vger.kernel.org,
	"Maxime Ripard" <maxime.ripard@free-electrons.com>,
	"Sylwester Nawrocki" <snawrocki@kernel.org>,
	"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Subject: [PATCH 4/4] v4l: async: add comment about re-probing to v4l2_async_notifier_unregister()
Date: Mon, 31 Jul 2017 00:31:58 +0200	[thread overview]
Message-ID: <20170730223158.14405-5-niklas.soderlund+renesas@ragnatech.se> (raw)
In-Reply-To: <20170730223158.14405-1-niklas.soderlund+renesas@ragnatech.se>

The re-probing of subdevices when unregistering a notifier is tricky to
understand, and implemented somewhat as a hack. Add a comment trying to
explain why the re-probing is needed in the first place and why existing
helper functions can't be used in this situation.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/media/v4l2-core/v4l2-async.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
index d91ff0a33fd3eaff..a3c5a1f6d4d2ab03 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -234,6 +234,23 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
 
 	mutex_unlock(&list_lock);
 
+	/*
+	 * Try to re-probe the subdevices which where part of the notifier.
+	 * This is done so subdevices which where part of the notifier will
+	 * be re-probed to a pristine state and put back on the global
+	 * list of subdevices so they can once more be found and associated
+	 * with a new notifier.
+	 *
+	 * One might be tempted to use device_reprobe() to handle the re-
+	 * probing. Unfortunately this is not possible since some video
+	 * device drivers call v4l2_async_notifier_unregister() from
+	 * there remove function leading to a dead lock situation on
+	 * device_lock(dev->parent). This lock is held when video device
+	 * drivers remove function is called and device_reprobe() also
+	 * tries to take the same lock, so using it here could lead to a
+	 * dead lock situation.
+	 */
+
 	for (i = 0; i < count; i++) {
 		/* If we handled USB devices, we'd have to lock the parent too */
 		device_release_driver(dev[i]);
-- 
2.13.3

  parent reply	other threads:[~2017-07-30 22:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-30 22:31 [PATCH 0/4] v4l: async: fixes for v4l2_async_notifier_unregister() Niklas Söderlund
2017-07-30 22:31 ` [PATCH 1/4] v4l: async: fix unbind error in v4l2_async_notifier_unregister() Niklas Söderlund
2017-08-15 16:16   ` Sakari Ailus
2017-08-18 11:15     ` Laurent Pinchart
2017-08-18 13:42       ` Niklas Söderlund
2017-08-18 13:49         ` Sakari Ailus
2017-08-18 11:13   ` Laurent Pinchart
2017-07-30 22:31 ` [PATCH 2/4] v4l: async: abort if memory allocation fails when unregistering notifiers Niklas Söderlund
2017-08-24 16:20   ` Sakari Ailus
2017-07-30 22:31 ` [PATCH 3/4] v4l: async: do not hold list_lock when re-probing devices Niklas Söderlund
2017-07-30 22:31 ` Niklas Söderlund [this message]
2017-08-15 16:09   ` [PATCH 4/4] v4l: async: add comment about re-probing to v4l2_async_notifier_unregister() Sakari Ailus
2017-08-18 11:20     ` Laurent Pinchart
2017-08-18 13:42       ` Niklas Söderlund
2017-08-23 19:03         ` Niklas Söderlund
2017-08-24  7:59           ` Hans Verkuil
2017-08-24 16:17             ` Sakari Ailus
2017-08-25  9:17               ` Hans Verkuil
2017-07-31  8:04 ` [PATCH 0/4] v4l: async: fixes for v4l2_async_notifier_unregister() Hans Verkuil

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=20170730223158.14405-5-niklas.soderlund+renesas@ragnatech.se \
    --to=niklas.soderlund+renesas@ragnatech.se \
    --cc=hverkuil@xs4all.nl \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=snawrocki@kernel.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;
as well as URLs for NNTP newsgroup(s).