lkml.org 
[lkml]   [2015]   [Jul]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Is devm_* broken ?
Hello,

On Wed, Jul 15, 2015 at 10:00:54AM -0700, Dan Williams wrote:
> Sounds like a real problem. The drivers I've used devm with have an
> upper layer that prevents this crash, but that's not much consolation.
> I think adding lifetime to devm allocations would be useful that way
> ->probe() and open() can do a devres_get() while ->remove() and
> close() can do a devres_put(). Perhaps I'm also missing something
> obvious though...

Hmmm... so this really is a general lifetime management problem and
also why sysfs implements revoke semantics. As memory allocated by
devm_kmalloc() isn't tied to any specific hardware, it seems a bit
murky here but if you consider any other resources, this is clear - a
driver must not access any resources once detach is complete. These
aren't resources which can be detached and then held while draining
existing userland references. They immediately conflict with the next
driver which is gonna attach to the device.

A driver should isolate and drain on-going accesses from userland
before finishing detaching one way or another. No resources attached
to the hardware side can't be held once detaching is complete. If a
piece of memory isn't attached to the harware side but the userland
interface side which gets isolated and drained after detachment, that
shouldn't be allocated via devm - it has "dev" in its name for a
reason.

Thanks.

--
tejun


\
 
 \ /
  Last update: 2015-07-15 20:21    [W:0.088 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site