Re: [PATCH/RFC] core: add a function to safely try to get device driver owner

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Laurent Pinchart
Date: Tuesday, November 30, 2010 - 10:55 am

Hi Greg,

On Tuesday 30 November 2010 18:15:09 Greg KH wrote:
wrote:

[snip]


It depends on your definition of rude. I would consider the kernel even more 
rude if it accepted my unload request and then crashed.

I've recently run into a problem similar to Guennadi's with the OMAP3 ISP 
driver. The driver instantiates several V4L2 I2C sub-devices for the camera 
sensors and the lens and flash controllers. The sub-device drivers get 
platform data when they're probed, and receive callbacks to the board code to 
turn power on/off and configure clocks (it's a bit more complex than just 
that, but you get the idea). The board code callbacks then call to the OMAP3 
ISP driver to configure clocks, because the sensor clock is provided by the 
OMAP3 ISP.

Now, when the user opens the sensor's subdev device node (/dev/v4l-subdev*), 
the subdev open function will turn the sensor clock on. To do that it will 
call the OMAP3 ISP driver through board code. If the OMAP3 ISP driver is 
unloaded at that point things will go pretty bad.

The way we deal with this is to try_module_get() on the OMAP3 ISP driver in 
the subdev open() handlers. I'm of course opened to alternatives.


We need to lock the module in place if its code can be called from another 
driver. Coming up with a lock-free way to handle this would be similar to 
removing the try_module_get() call from cdev_get(). Maybe it could be done, 
but I'm not sure it should.

-- 
Regards,

Laurent Pinchart
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH/RFC] core: add a function to safely try to get devi ..., Guennadi Liakhovetski, (Mon Nov 29, 12:43 pm)
Re: [PATCH/RFC] core: add a function to safely try to get ..., Guennadi Liakhovetski, (Mon Nov 29, 1:11 pm)
Re: [PATCH/RFC] core: add a function to safely try to get ..., Guennadi Liakhovetski, (Mon Nov 29, 1:54 pm)
Re: [PATCH/RFC] core: add a function to safely try to get ..., Guennadi Liakhovetski, (Mon Nov 29, 3:10 pm)
Re: [PATCH/RFC] core: add a function to safely try to get ..., Guennadi Liakhovetski, (Mon Nov 29, 4:11 pm)
Re: [PATCH/RFC] core: add a function to safely try to get ..., Guennadi Liakhovetski, (Tue Nov 30, 12:18 am)
Re: [PATCH/RFC] core: add a function to safely try to get ..., Guennadi Liakhovetski, (Tue Nov 30, 10:09 am)
Re: [PATCH/RFC] core: add a function to safely try to get ..., Laurent Pinchart, (Tue Nov 30, 10:55 am)
Re: [PATCH/RFC] core: add a function to safely try to get ..., Laurent Pinchart, (Tue Nov 30, 1:43 pm)