linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: linas@austin.ibm.com
To: linux-hotplug@vger.kernel.org
Subject: Re: hotplug remove vs. device driver close
Date: Thu, 03 Jun 2004 22:25:03 +0000	[thread overview]
Message-ID: <20040603172503.J17544@forte.austin.ibm.com> (raw)
In-Reply-To: <20040602181455.C17544@forte.austin.ibm.com>


Greg,

My apologies, I think I needed to read the source before posting to the 
mailing list.  (yes, my middle name really is 'Luke', no kidding). I might have 
been on a wild goose chase.  See below.

On Thu, Jun 03, 2004 at 01:02:27PM -0700, Don Fry wrote:
> > > 
> > > The pcnet32 driver tries to do the 'right thing' when it reads 0xffff,
> > > but that does not include doing a 'close' prior to being removed.  The
> > > driver could keep some state around so that if its remove routine was
> > > called without close first, it would cleanup, but I don't know of any
> > > network driver that does this.
> > 
> > What I get out of this thread is that pcnet32, and in fact, all drivers, 
> > should keep sufficient state around so that close() can be called either 
> > after or before remove().
> 
> Today in 2.6.6 if I try and do a rmmod pcnet32 and something is still using
> the device, the rmmod will wait until the device is closed, and then it
> goes away.  

Where?  pcnet32_cleanup_module() doesn't seem to wait for anything.

However, I'm reading the source, tracing through a power-off, and I don't
see any device driver memory leaks, at least not in the 'typical' pcnet32
driver.  What I do see is that the the device driver close() routine is
called before the device driver memory is released.

Anatomy of a device remove,
---------------------------
starting with an

echo 1 > /sysfs/bus/ .. power file ... 

I trace this through the ppc64 rpaphp hotplug code, and the pcnet32 code.
I did this manually, I hope there aren't any mistakes.

power_write_file () // in /drivers/pci/hotplug/pci_hotplug_core.c
{
  calls
  slot->ops->disable_slot() which is just
  struct hotplug_slot_ops ->disable_slot() which is just
  disable_slot (struct hotplug_slot *) // in /drivers/pci/hotplug/rpaphp_core.c
  {
    which calls
    rpa_php_unconfig_pci_adapter (struct slot *)  // in rpaphp_pci.c
    {
      calls
      pci_remove_bus_device (struct pci_dev *) // in /drivers/pci/remove.c
      { 
        calls
        pci_destroy_dev (struct pci_dev *) 
        {
          calls 
          device_unregister (&dev->dev) // in /drivers/base/core.c
          {
            calls
            device_del (struct device *)
            {
              calls 
              bus_remove_device() // in /drivers/base/bus.c
              {
                calls 
                device_release_driver()
                {
                  calls 
                  struct device_driver->remove() which is just
                  pci_device_remove()  // in /drivers/pci/pci_driver.c
                  {
                    calls
                    struct pci_driver->remove() which is just
                    pcnet32_remove_one() // in /drivers/net/pcnet32.c  
                    {
                      calls
                      unregister_netdev() // in /net/core/dev.c
                      {
                        calls 
                        dev_close()  // in /net/core/dev.c
                        { 
                           calls dev->stop();
                           which is just pcnet32_close() // in pcnet32.c
                           {
                             which does what you wanted
                             to stop the device
                           }
                        }
                     }
                   which
                   frees pcnet32 device driver memory
                }
     }}}}}}







-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
From Windows to Linux, servers to mobile, InstallShield X is the one
installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

  parent reply	other threads:[~2004-06-03 22:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-02 23:14 hotplug remove vs. device driver close linas
2004-06-02 23:28 ` Greg KH
2004-06-03  1:40 ` Anton Blanchard
2004-06-03 16:20 ` Greg KH
2004-06-03 18:50 ` linas
2004-06-03 19:02 ` Greg KH
2004-06-03 19:23 ` Don Fry
2004-06-03 19:28 ` Greg KH
2004-06-03 19:34 ` linas
2004-06-03 19:39 ` linas
2004-06-03 20:02 ` Don Fry
2004-06-03 20:39 ` Greg KH
2004-06-03 22:25 ` linas [this message]
2004-06-04  3:58 ` Benjamin Herrenschmidt
2004-06-04 16:24 ` Greg KH
2004-06-04 17:26 ` linas

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=20040603172503.J17544@forte.austin.ibm.com \
    --to=linas@austin.ibm.com \
    --cc=linux-hotplug@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;
as well as URLs for NNTP newsgroup(s).