Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1321044

Re: [PATCH 29/31] media: track media device unregister in progress

From Shuah Khan <shuahkh@osg.samsung.com>
Newsgroups linux.kernel
Subject Re: [PATCH 29/31] media: track media device unregister in progress
Date 2016-01-28 21:50 +0100
Message-ID <qW1FU-qH-33@gated-at.bofh.it> (permalink)
References <qO329-63K-3@gated-at.bofh.it> <qO3lw-6bl-27@gated-at.bofh.it> <qVYf0-6zx-17@gated-at.bofh.it> <qVYf1-6zx-49@gated-at.bofh.it> <qVYym-6Hg-23@gated-at.bofh.it>
Organization Samsung Open Source Group

Show all headers | View raw


On 01/28/2016 10:28 AM, Mauro Carvalho Chehab wrote:
> Em Thu, 28 Jan 2016 10:04:24 -0700
> Shuah Khan <shuahkh@osg.samsung.com> escreveu:
> 
>> On 01/28/2016 10:01 AM, Mauro Carvalho Chehab wrote:
>>> Em Wed,  6 Jan 2016 13:27:18 -0700
>>> Shuah Khan <shuahkh@osg.samsung.com> escreveu:
>>>   
>>>> Add support to track media device unregister in progress
>>>> state to prevent more than one driver entering unregister.
>>>> This enables fixing the general protection faults while
>>>> snd-usb-audio was cleaning up media resources for pcm
>>>> streams and mixers. In this patch a new interface is added
>>>> to return the unregister in progress state. Subsequent
>>>> patches to snd-usb-audio and au0828-core use this interface
>>>> to avoid entering unregister and attempting to unregister
>>>> entities and remove devnodes while unregister is in progress.
>>>> Media device unregister removes entities and interface nodes.  
>>>
>>> Hmm... isn't the spinlock enough to serialize it? It seems weird the
>>> need of an extra bool here to warrant that this is really serialized.
>>>   
>>
>> The spinlock and check for media_devnode_is_registered(&mdev->devnode)
>> aren't enough to ensure only one driver enters the unregister. 
>>
>> Please
>> note that the devnode isn't marked unregistered until the end in
>> media_device_unregister().
> 
> I guess the call to:
> 	device_remove_file(&mdev->devnode.dev, &dev_attr_model);
> 
> IMO, This should be, instead, at media_devnode_unregister().
> 
> Then, we can change the logic at media_devnode_unregister() to:
> 
> void media_devnode_unregister(struct media_devnode *mdev)
> {
> 	mutex_lock(&media_devnode_lock);
> 
> 	/* Check if mdev was ever registered at all */
> 	if (!media_devnode_is_registered(mdev)) {
> 		mutex_unlock(&media_devnode_lock);
> 		return;
> 	}
> 
> 	clear_bit(MEDIA_FLAG_REGISTERED, &mdev->flags);
> 	mutex_unlock(&media_devnode_lock);
> 	device_remove_file(&mdev->devnode.dev, &dev_attr_model);
> 	device_unregister(&mdev->dev);
> }
> 
> This sounds enough to avoid device_unregister() or device_remove_file()
> to be called twice.
> 

I can give it a try. There might other problems that could
result from media device being a devres in this case. The
last put_device on the usbdev parent device (media device
is created as devres for this), all device resources get
released. That might have to be solved in a different way.

For now I will see if your solution works.

thanks,
-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH 29/31] media: track media device unregister in progress Mauro Carvalho Chehab <mchehab@osg.samsung.com> - 2016-01-28 18:10 +0100
  Re: [PATCH 29/31] media: track media device unregister in progress Shuah Khan <shuahkh@osg.samsung.com> - 2016-01-28 18:10 +0100
    Re: [PATCH 29/31] media: track media device unregister in progress Mauro Carvalho Chehab <mchehab@osg.samsung.com> - 2016-01-28 18:30 +0100
      Re: [PATCH 29/31] media: track media device unregister in progress Shuah Khan <shuahkh@osg.samsung.com> - 2016-01-28 21:50 +0100
        Re: [PATCH 29/31] media: track media device unregister in progress Shuah Khan <shuahkh@osg.samsung.com> - 2016-02-03 20:40 +0100

csiph-web