From patchwork Sun Jul 30 22:31:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 9870721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C498160353 for ; Sun, 30 Jul 2017 22:32:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B776C28575 for ; Sun, 30 Jul 2017 22:32:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC9A22857B; Sun, 30 Jul 2017 22:32:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DCEA28575 for ; Sun, 30 Jul 2017 22:32:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751716AbdG3Wc0 (ORCPT ); Sun, 30 Jul 2017 18:32:26 -0400 Received: from smtp-4.sys.kth.se ([130.237.48.193]:54296 "EHLO smtp-4.sys.kth.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751688AbdG3WcW (ORCPT ); Sun, 30 Jul 2017 18:32:22 -0400 Received: from smtp-4.sys.kth.se (localhost.localdomain [127.0.0.1]) by smtp-4.sys.kth.se (Postfix) with ESMTP id 09C712558; Mon, 31 Jul 2017 00:32:21 +0200 (CEST) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-4.sys.kth.se ([127.0.0.1]) by smtp-4.sys.kth.se (smtp-4.sys.kth.se [127.0.0.1]) (amavisd-new, port 10024) with LMTP id G4h0xA19E4n5; Mon, 31 Jul 2017 00:32:20 +0200 (CEST) X-KTH-Auth: niso [89.233.230.99] X-KTH-mail-from: niklas.soderlund+renesas@ragnatech.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by smtp-4.sys.kth.se (Postfix) with ESMTPSA id 26B022591; Mon, 31 Jul 2017 00:32:20 +0200 (CEST) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: Sakari Ailus , Hans Verkuil , Laurent Pinchart , linux-media@vger.kernel.org Cc: Kieran Bingham , linux-renesas-soc@vger.kernel.org, Maxime Ripard , Sylwester Nawrocki , =?UTF-8?q?Niklas=20S=C3=B6derlund?= 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 Message-Id: <20170730223158.14405-5-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170730223158.14405-1-niklas.soderlund+renesas@ragnatech.se> References: <20170730223158.14405-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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]);