From: Tejun Heo <tj@kernel.org>
To: Dan Williams <dan.j.williams@gmail.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Is devm_* broken ?
Date: Wed, 15 Jul 2015 14:03:55 -0400 [thread overview]
Message-ID: <20150715180355.GH15934@mtj.duckdns.org> (raw)
In-Reply-To: <CAA9_cmfGQ0pXJ0vQt0uRUvz7EZYKv4goHcpf3Ewbn3rM0N204w@mail.gmail.com>
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
next prev parent reply other threads:[~2015-07-15 18:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-14 22:34 Laurent Pinchart
2015-07-15 15:51 ` Takashi Iwai
2015-07-15 16:08 ` Laurent Pinchart
2015-07-15 16:20 ` Takashi Iwai
2015-07-15 16:27 ` Laurent Pinchart
2015-07-15 16:34 ` Takashi Iwai
2015-07-28 14:10 ` Laurent Pinchart
2015-07-15 17:00 ` Dan Williams
2015-07-15 18:03 ` Tejun Heo [this message]
2015-07-28 14:16 ` Laurent Pinchart
2015-07-28 15:22 ` Tejun Heo
2015-07-28 17:05 ` Laurent Pinchart
2015-08-04 19:56 ` Pavel Machek
2015-08-04 21:26 ` Dmitry Torokhov
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=20150715180355.GH15934@mtj.duckdns.org \
--to=tj@kernel.org \
--cc=dan.j.williams@gmail.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®