From: Wei Yang <weiyang@linux.vnet.ibm.com>
To: Benjamin Herrenschmidt <benh@au1.ibm.com>
Cc: aik@au1.ibm.com, linuxppc-dev@lists.ozlabs.org,
gwshan@linux.vnet.ibm.com, Gavin Shan <gwshan@au1.ibm.com>
Subject: Re: [PATCH 1/2] powerpc/powernv: clear the refcount for pci_dev on powernv platform
Date: Mon, 21 Apr 2014 14:03:53 +0800 [thread overview]
Message-ID: <20140421060353.GB24712@richard> (raw)
In-Reply-To: <1398051334.19682.14.camel@pasglop>
On Mon, Apr 21, 2014 at 01:35:34PM +1000, Benjamin Herrenschmidt wrote:
>On Mon, 2014-04-21 at 10:25 +0800, Wei Yang wrote:
>> When pcibios_remove_pci_devices() is removing pci devices, it will release
>> pci device respectively. When the refcount of the device is 0, the pci_dev
>> structure will be destroyed.
>>
>> On PowerNV platform, the pci_dev will not be destroyed since the refcount is
>> not 0.
>>
>> After applying the patch, this warning is cleared during the EEH hotplug
>> event.
>
>You have to be careful here. We take a reference to the device in the
>structure eeh_dev, that means we might access it after it's freed if
>we don't increase the refcount.
Ben,
Thanks for reminding.
Hmm, I checked the eeh_dev structure, there is a field pdev in eeh_dev, which
is not a ref to the device.
Then I did a check in eeh hotplug code patch. The pci_dev remove/install
happens in eeh_reset_device(), between pcibios_remove_pci_devices() and
pcibios_add_pci_devices(). During this period, we will try to clear/set the PE
state and restore the BAR of a pci device. But the BAR is restored through the
device node instead of pci_dev structure. As my understanding the eeh code
here has the assumption that these pci devices in the same PE are removed.
Maybe I missed something, needs confirmation from Gavin.
The code I removed in this patch is introduced in commit
184cd4a3(powerpc/powernv: PCI support for p7IOC under OPAL v2).
Sounds the original purpose is to make sure a pci device is covered by a Bus
PE, so don't remove it. After booting up, Bus PE will always be there, which
means we will always hold a refcount to a pci device.
I didn't come up with a better idea, or leaving the warning is fine.
Any comments are welcome :)
>
>Cheers,
>Ben.
>
next prev parent reply other threads:[~2014-04-21 6:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-21 2:25 [PATCH 1/2] powerpc/powernv: clear the refcount for pci_dev on powernv platform Wei Yang
2014-04-21 2:25 ` [PATCH 2/2] powerpc/powernc: revert part of commit d905c5df(PPC: POWERNV: move iommu_add_device earlier) Wei Yang
2014-04-21 3:37 ` Benjamin Herrenschmidt
2014-04-21 5:22 ` Wei Yang
2014-04-21 6:11 ` Wei Yang
2014-04-21 3:35 ` [PATCH 1/2] powerpc/powernv: clear the refcount for pci_dev on powernv platform Benjamin Herrenschmidt
2014-04-21 6:03 ` Wei Yang [this message]
2014-04-21 23:34 ` Gavin Shan
2014-04-22 7:44 ` Wei Yang
2014-04-22 8:25 ` Benjamin Herrenschmidt
2014-04-22 9:44 ` Wei Yang
2014-04-22 23:00 ` Gavin Shan
2014-04-23 0:26 ` Benjamin Herrenschmidt
2014-04-23 1:56 ` Wei Yang
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=20140421060353.GB24712@richard \
--to=weiyang@linux.vnet.ibm.com \
--cc=aik@au1.ibm.com \
--cc=benh@au1.ibm.com \
--cc=gwshan@au1.ibm.com \
--cc=gwshan@linux.vnet.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.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).