linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Sylwester Nawrocki <s.nawrocki@samsung.com>,
	linux-media@vger.kernel.org, Hans Verkuil <hverkuil@xs4all.nl>,
	linux-sh@vger.kernel.org, Magnus Damm <magnus.damm@gmail.com>,
	Sakari Ailus <sakari.ailus@iki.fi>,
	Prabhakar Lad <prabhakar.lad@ti.com>
Subject: Re: [PATCH v9 02/20] V4L2: support asynchronous subdevice registration
Date: Fri, 26 Apr 2013 22:46:45 +0200	[thread overview]
Message-ID: <517AE7B5.4010108@gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.64.1304231435540.1422@axis700.grange>

Hi Guennadi,

On 04/23/2013 03:01 PM, Guennadi Liakhovetski wrote:
> On Mon, 22 Apr 2013, Laurent Pinchart wrote:
>> On Monday 15 April 2013 13:57:17 Sylwester Nawrocki wrote:
>>> On 04/12/2013 05:40 PM, Guennadi Liakhovetski wrote:
>>>> +
>>>> +		if (notifier->unbind)
>>>> +			notifier->unbind(notifier, asdl);
>>>> +	}
>>>> +
>>>> +	mutex_unlock(&list_lock);
>>>> +
>>>> +	if (dev) {
>>>> +		while (i--) {
>>>> +			if (dev[i]&&  device_attach(dev[i])<  0)
>>
>> This is my last major pain point.
>>
>> To avoid race conditions we need circular references (see
>>http://www.mail-archive.com/linux-media@vger.kernel.org/msg61092.html).
>>We will thus need a
>> way to break the circle by explictly requesting the subdev to release its
>> resources. I'm afraid I have no well-designed solution for that at the moment.
>
> I think we really can design the framework to allow a _safe_ unloading of
> the bridge driver. An rmmod run is not an immediate death - we have time
> to clean up and release all resources properly. As an example, I just had
> a network interface running, but rmmod-ing of one of hardware drivers just
> safely destroyed the interface. In our case, rmmod<bridge>  should just
> signal the subdevice to release the clock reference. Whether we have the
> required - is a separate question.

It sounds like a reasonable requirements.

> Currently a call to v4l2_clk_get() increments the clock owner use-count.
> This isn't a problem for soc-camera, since there the soc-camera core owns
> the clock. For other bridge drivers they would probably own the clock
> themselves, so, incrementing their use-count would block their modules in
> memory. To avoid that we have to remove that use-count incrementing.
>
> The crash, described in the referenced mail can happen if the subdevice
> driver calls (typically) v4l2_clk_enable() on a clock, that's already been
> freed. Wouldn't a locked look-up in the global clock list in v4l2-clk.c
> prevent such a crash? E.g.
>
> int v4l2_clk_enable(struct v4l2_clk *clk)
> {
> 	struct v4l2_clk *tmp;
> 	int ret = -ENODEV;
>
> 	mutex_lock(&clk_lock);
> 	list_for_each_entry(tmp,&clk_list, list)
> 		if (tmp == clk) {
> 			ret = !try_module_get(clk->ops->owner);
> 			if (ret)
> 				ret = -EFAULT;
> 			break;
> 		}
> 	mutex_unlock(&clk_lock);
>
> 	if (ret<  0)
> 		return ret;
>
> 	...
> }
>
> We'd have to do a similar locked look-up in v4l2_clk_put().

Sounds good. This way it will not be possible to unload modules when 
clock is
enabled, which is expected. And it seems straightforward to ensure 
clk_prepare/
clk_unprepare, clk_enable/clk_disable are properly balanced. If module 
is gone
before subdev driver calls v4l2_clk_put() the clock provider module will 
have
to ensure any source clocks it uses are properly released 
(clk_unprepare/clk_put).

I'm looking forward to try your v10. :-)

Regards,
Sylwester

  reply	other threads:[~2013-04-26 20:46 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-12 15:40 [PATCH v9 00/20] V4L2 clock and async patches and soc-camera example Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 01/20] V4L2: add temporary clock helpers Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 02/20] V4L2: support asynchronous subdevice registration Guennadi Liakhovetski
2013-04-15 11:57   ` Sylwester Nawrocki
2013-04-22 11:39     ` Laurent Pinchart
2013-04-23 13:01       ` Guennadi Liakhovetski
2013-04-26 20:46         ` Sylwester Nawrocki [this message]
2013-04-15 14:22   ` Prabhakar Lad
2013-04-22  7:17   ` Prabhakar Lad
2013-04-26  8:44   ` Sascha Hauer
2013-04-26 21:07     ` Guennadi Liakhovetski
2013-04-29 10:01       ` Sascha Hauer
2013-04-30 13:53   ` Sascha Hauer
2013-04-30 14:06     ` Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 03/20] soc-camera: move common code to soc_camera.c Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 04/20] soc-camera: add host clock callbacks to start and stop the master clock Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 05/20] pxa-camera: move interface activation and deactivation to clock callbacks Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 06/20] omap1-camera: " Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 07/20] atmel-isi: " Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 08/20] mx3-camera: " Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 09/20] mx2-camera: " Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 10/20] mx1-camera: " Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 11/20] sh-mobile-ceu-camera: " Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 12/20] soc-camera: make .clock_{start,stop} compulsory, .add / .remove optional Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 13/20] soc-camera: don't attach the client to the host during probing Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 14/20] sh-mobile-ceu-camera: add primitive OF support Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 15/20] sh-mobile-ceu-driver: support max width and height in DT Guennadi Liakhovetski
2013-04-13 21:22   ` Sergei Shtylyov
2013-04-12 15:40 ` [PATCH v9 16/20] soc-camera: switch I2C subdevice drivers to use v4l2-clk Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 17/20] soc-camera: add V4L2-async support Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 18/20] sh_mobile_ceu_camera: add asynchronous subdevice probing support Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 19/20] imx074: support asynchronous probing Guennadi Liakhovetski
2013-04-12 15:40 ` [PATCH v9 20/20] ARM: shmobile: convert ap4evb to asynchronously register camera subdevices Guennadi Liakhovetski

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=517AE7B5.4010108@gmail.com \
    --to=sylvester.nawrocki@gmail.com \
    --cc=g.liakhovetski@gmx.de \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=prabhakar.lad@ti.com \
    --cc=s.nawrocki@samsung.com \
    --cc=sakari.ailus@iki.fi \
    /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).