From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: Enrik Berkhan <Enrik.Berkhan@ge.com>
Cc: David Vrabel <david.vrabel@csr.com>,
Pierre Ossman <drzeus-mmc@drzeus.cx>,
linux-kernel@vger.kernel.org
Subject: Re: Reference counting of MMC host driver modules
Date: Sat, 10 Jan 2009 10:49:00 +0100 [thread overview]
Message-ID: <49686F0C.7030807@s5r6.in-berlin.de> (raw)
In-Reply-To: <20090109200024.GA14754@ngeserver2.localdomain>
Enrik Berkhan wrote:
> On Fri, Jan 09, 2009 at 06:20:32PM +0000, David Vrabel wrote:
>> Enrik Berkhan wrote:
>>> I've noticed recently that the MMC/SD block driver does not reference
>>> count the MMC/SD host driver module that it uses via the MMC/SD core
>>> layer. Thus, I can rmmod my host driver module while, for example, a
>>> partition on a SD card is mounted.
>> This is same as removing the card while it's in use.
>
> I don't think so.
>
> Being able to remove the card while it is in use is a bug of the
> mechanical interface. Can't be fixed easily.
>
> Being able to remove the module while it is in use is a bug of the
> software. Can be fixed.
Here is my implementation experience with the issue, concerning the two
FireWire driver stacks which I maintain:
In case of firewire (new FireWire stack), module removal of the
controller driver will trigger removal of all child and grandchild
devices, e.g. sd_shutdown of FireWire HDDs.
This will have the same effect as if the cable of the HDD was pulled.
I don't see a need to prevent this because whoever runs
# modprobe -r firewire-ohci
is supposed to know what he is doing.
But in case of ieee1394 (old FireWire stack), the sbp2 storage driver
calls try_module_get() on the host driver whenever it starts using a
device, and of course module_put() when it is done. I.e. modprobe -r
ohci1394 is blocked as long as the sbp2 driver is in touch with a
FireWire drive.
I added this at some point because of unclean layering of the ieee1394
stack: The high-level drivers video1394 and dv1394 do not only depend
on the ieee1394 core driver, but also directly on the ohci1394 low-level
driver. Now, if somebody runs
# modprobe -r video1394
it would also remove ohci1394 if sbp2 hadn't artificially increased
ohci1394's reference count.
*However*, note that try_module_get() and module_put() don't actually do
what you asked for: They do _not_ guarantee that the host driver gets
unbound from the MMC (or FireWire...) controller:
You can still do
# echo -n ${ID} > /sys/module/${MODULE}/drivers/${DRIVER}/unbind
So, if somebody asked me to copy my ieee1394/sbp2 safeguard into
firewire/fw-sbp2, I would reject that on the grounds that killing the
connection to the FireWire disk is the *expected result* of
# modprobe -r firewire-ohci
--
Stefan Richter
-=====-==--= ---= -=-=-
http://arcgraph.de/sr/
next prev parent reply other threads:[~2009-01-10 9:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-09 17:07 Enrik Berkhan
2009-01-09 18:20 ` David Vrabel
2009-01-09 20:00 ` Enrik Berkhan
2009-01-10 9:49 ` Stefan Richter [this message]
2009-01-11 9:41 ` Pierre Ossman
2009-01-12 15:41 ` Enrik Berkhan
2009-01-12 17:10 ` Stefan Richter
2009-01-12 20:01 ` Enrik Berkhan
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=49686F0C.7030807@s5r6.in-berlin.de \
--to=stefanr@s5r6.in-berlin.de \
--cc=Enrik.Berkhan@ge.com \
--cc=david.vrabel@csr.com \
--cc=drzeus-mmc@drzeus.cx \
--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
Powered by JetHome