All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Jarzmik <robert.jarzmik@free.fr>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	Jiri Kosina <trivial@kernel.org>,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Subject: Re: [PATCH v3 02/14] media: mt9m111: prevent module removal while in use
Date: Sun, 14 Aug 2016 21:31:13 +0200	[thread overview]
Message-ID: <87vaz3qha6.fsf@belgarion.home> (raw)
In-Reply-To: 4a60c89e-f183-5c92-8c5d-e5d75767c10b@xs4all.nl

Hans Verkuil <hverkuil@xs4all.nl> writes:

> On 08/08/2016 09:30 PM, Robert Jarzmik wrote:
>> The mt9m111 can be a removable module : the only case where the module
>> should be kept loaded is while it is used, ie. while an active
>> transation is ongoing on it.
>> 
>> The notion of active transaction is mapped on the power state of the
>> module : if powered on the removal is prohibited.
>
> I don't really see the purpose of this patch: if this driver is loaded
> by a platform driver (such as pxa_camera), then the module count should be
> 1 and it isn't possible to unload.
>
> So you shouldn't need this patch. Am I missing something?
Well, what you are missing is ugly and twisted.

With the current patchset, pxa_camera doesn't acquire the module (see
pxa_camera_sensor_bound()). That is the ugly part.

The reason behind is that if it acquires it, it's totally impossible to rmmod
either pxa_camera or mt9m111 because of the cross-dependency I wasn't able to
solve up to now.

The dependency chain goes as follows :
 - pxa_camera should +1 refcount mt9m111 in pxa_camera_sensor_bound()
 - mt9m111 should +1 refcount pxa_camera through the MCLK get_clock()
   Without MCLK, mt9m111 is not clocked, and no I2C is available, hence no
   control and a total loss of context

The purpose of this patch was the mt9m111 aquired a +1 refcount on pxa_camera so
that pxa_camera is prevented from removal while a transfer is underway, and
while the mt9m111 has the MCLK refcount acquired.

I perfectly know this is suboptimal, but I didn't find a way yet to solve
this. I was thinking to use pxac_fops_camera_open() to refcount +1 mt9m111
module and pxac_fops_camera_release() to refcound -1 mt9m111. But that didn't
work because in order for mt9m111 to probe, the I2C has to be functional, and
therefore the MCLK has to be provided.

> No other driver in drivers/media/i2c does something like this.
Yeah, I would bet either no other driver has the crossed dependency or they can
never be rmmoded.

Let me see how I can drop this patch and still prevent a kernel panic upon an
rmmod of either mt9m111 or pxa_camera.

Cheers.

--
Robert

  reply	other threads:[~2016-08-14 19:31 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-08 19:30 [PATCH v3 00/14] pxa_camera transition to v4l2 standalone device Robert Jarzmik
2016-08-08 19:30 ` [PATCH v3 01/14] media: mt9m111: make a standalone v4l2 subdevice Robert Jarzmik
2016-08-08 19:30 ` [PATCH v3 02/14] media: mt9m111: prevent module removal while in use Robert Jarzmik
2016-08-13 18:40   ` Hans Verkuil
2016-08-14 19:31     ` Robert Jarzmik [this message]
2016-08-08 19:30 ` [PATCH v3 03/14] media: mt9m111: use only the SRGB colorspace Robert Jarzmik
2016-08-08 19:30 ` [PATCH v3 04/14] media: mt9m111: move mt9m111 out of soc_camera Robert Jarzmik
2016-08-08 19:30 ` [PATCH v3 05/14] media: platform: pxa_camera: convert to vb2 Robert Jarzmik
2016-08-13  9:25   ` Robert Jarzmik
2016-08-13  9:29     ` Hans Verkuil
2016-08-13 11:15       ` Robert Jarzmik
2016-08-08 19:30 ` [PATCH v3 06/14] media: platform: pxa_camera: trivial move of functions Robert Jarzmik
2016-08-08 19:30 ` [PATCH v3 07/14] media: platform: pxa_camera: introduce sensor_call Robert Jarzmik
2016-08-08 19:30 ` [PATCH v3 08/14] media: platform: pxa_camera: make printk consistent Robert Jarzmik
2016-08-08 19:30 ` [PATCH v3 09/14] media: platform: pxa_camera: add buffer sequencing Robert Jarzmik
2016-08-15 13:26   ` Robert Jarzmik
2016-08-15 13:31     ` Hans Verkuil
2016-08-15 14:42       ` Robert Jarzmik
2016-08-08 19:30 ` [PATCH v3 10/14] media: platform: pxa_camera: remove set_crop Robert Jarzmik
2016-08-13 18:50   ` Hans Verkuil
2016-08-14 19:29     ` Robert Jarzmik
2016-08-08 19:30 ` [PATCH v3 11/14] media: platform: pxa_camera: make a standalone v4l2 device Robert Jarzmik
2016-08-13 18:58   ` Hans Verkuil
2016-08-14 19:30     ` Robert Jarzmik
2016-08-08 19:30 ` [PATCH v3 12/14] media: platform: pxa_camera: add debug register access Robert Jarzmik
2016-08-13 18:46   ` Hans Verkuil
2016-08-14 19:30     ` Robert Jarzmik
2016-08-08 19:30 ` [PATCH v3 13/14] media: platform: pxa_camera: change stop_streaming semantics Robert Jarzmik
2016-08-08 19:30 ` [PATCH v3 14/14] media: platform: pxa_camera: move pxa_camera out of soc_camera Robert Jarzmik
2016-08-15 10:04   ` Robert Jarzmik
2016-08-08 20:16 ` [PATCH v3 00/14] pxa_camera transition to v4l2 standalone device Hans Verkuil
2016-08-13 19:02 ` 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=87vaz3qha6.fsf@belgarion.home \
    --to=robert.jarzmik@free.fr \
    --cc=g.liakhovetski@gmx.de \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=trivial@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 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.