RE: [PATCH 2.6.33 1/3] net: Micrel KSZ8841/2 PCI Ethernet driver

From: Ha, Tristram
Date: Tue Jan 19 2010 - 19:13:41 EST


Alan Cox wrote:
>>> If you make a private copy of pdev in your struct you should
>>> refcount
>> it and use
>>> pci_dev_get/pci_dev_put when you take and release the reference.
>
>> I do not understand how pci_dev_get/pci_dev_put work. Does the pdev
>> pointer actually change during the lifetime of the PCI driver?
>
> No but it can go away if the device is removed. The pci_dev_get
ensures it won't go away while
> you have a pointer to it. and the pci_dev_put gives up your reference.

>

If the PCI device is removed, like physically removing the card,
shouldn't the kernel also close the network device assocated with the
PCI device? The driver does actually cleanup the network devices and
free all memory when the pci remove function is called.

>From the PCI network drivers included in the kernel I found most drivers
use pci_dev_put only on devices that are outside their own PCI devices,
retrieved from the pci_get_device call. (They never call pci_dev_get.)
That makes sense as those PCI devices are outside PCI driver control.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/