linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	linux-media@vger.kernel.org,
	Kieran Bingham <kieran.bingham@ideasonboard.com>,
	linux-renesas-soc@vger.kernel.org,
	Maxime Ripard <maxime.ripard@free-electrons.com>,
	Sylwester Nawrocki <snawrocki@kernel.org>
Subject: Re: [PATCH 2/4] v4l: async: abort if memory allocation fails when unregistering notifiers
Date: Thu, 24 Aug 2017 19:20:36 +0300	[thread overview]
Message-ID: <20170824162036.k5szzrvdwnwt4pat@valkosipuli.retiisi.org.uk> (raw)
In-Reply-To: <20170730223158.14405-3-niklas.soderlund+renesas@ragnatech.se>

Hi Niklas,

On Mon, Jul 31, 2017 at 12:31:56AM +0200, Niklas Söderlund wrote:
> Instead of trying to cope with the failed memory allocation and still
> leaving the kernel in a semi-broken state (the subdevices will be
> released but never re-probed) simply abort. The kernel have already
> printed a warning about allocation failure but keep the error printout
> to ease pinpointing the problem if it happens.
> 
> By doing this we can increase the readability of this complex function
> which puts it in a better state to separate the v4l2 housekeeping tasks
> from the re-probing of devices. It also serves to prepare for adding
> subnotifers.

By the time the notifier has been removed from the notifier list, we're the
sole user of the notifier done list. There is thus no need to acquire the
list lock to serialise access to that list.

Is there something that prevents re-probing the devices directly off the
notifier's done list without gathering the device pointers first? As the
notifier has been removed from the notifier list already, there will be no
matches found.

> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
>  drivers/media/v4l2-core/v4l2-async.c | 13 ++-----------
>  1 file changed, 2 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> index 0acf288d7227ba97..67852f0f2d3000c9 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -215,6 +215,7 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
>  	if (!dev) {
>  		dev_err(notifier->v4l2_dev->dev,
>  			"Failed to allocate device cache!\n");
> +		return;
>  	}
>  
>  	mutex_lock(&list_lock);
> @@ -234,23 +235,13 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
>  		/* If we handled USB devices, we'd have to lock the parent too */
>  		device_release_driver(d);
>  
> -		/*
> -		 * Store device at the device cache, in order to call
> -		 * put_device() on the final step
> -		 */
> -		if (dev)
> -			dev[i++] = d;
> -		else
> -			put_device(d);
> +		dev[i++] = d;
>  	}
>  
>  	mutex_unlock(&list_lock);
>  
>  	/*
>  	 * Call device_attach() to reprobe devices
> -	 *
> -	 * NOTE: If dev allocation fails, i is 0, and the whole loop won't be
> -	 * executed.
>  	 */
>  	while (i--) {
>  		struct device *d = dev[i];
> -- 
> 2.13.3
> 

-- 
Regards,

Sakari Ailus
e-mail: sakari.ailus@iki.fi

  reply	other threads:[~2017-08-24 16:20 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 [this message]
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 ` [PATCH 4/4] v4l: async: add comment about re-probing to v4l2_async_notifier_unregister() Niklas Söderlund
2017-08-15 16:09   ` 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=20170824162036.k5szzrvdwnwt4pat@valkosipuli.retiisi.org.uk \
    --to=sakari.ailus@iki.fi \
    --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=niklas.soderlund+renesas@ragnatech.se \
    --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).