From: Yinghai Lu <yinghai@kernel.org>
To: Yijing Wang <wangyijing@huawei.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] PCI: Fix hotplug remove with sriov again
Date: Tue, 23 Jul 2013 19:15:48 -0700 [thread overview]
Message-ID: <CAE9FiQVBfx_nyyna-9Xn+769fqqmMMMiNUwcacf4dA1iaZj6jw@mail.gmail.com> (raw)
In-Reply-To: <CAE9FiQUX7Dx5Z8zgx94bQ5vWTRsExarzG6WB_iuGj1jWkurc4w@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1194 bytes --]
On Tue, Jul 23, 2013 at 7:04 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Tue, Jul 23, 2013 at 7:01 PM, Yijing Wang <wangyijing@huawei.com> wrote:
>> Hi Yinghai,
>> It seems to have the the same problem in acpiphp,
>>
>> diable_device(..):
>>
>> while ((pdev = dev_in_slot(slot))) {
>> pci_stop_and_remove_bus_device(pdev);
>> pci_dev_put(pdev);
>> }
>>
>>
>> static struct pci_dev *dev_in_slot(struct acpiphp_slot *slot)
>> {
>> struct pci_bus *bus = slot->bridge->pci_bus;
>> struct pci_dev *dev;
>> struct pci_dev *ret = NULL;
>>
>> down_read(&pci_bus_sem);
>> list_for_each_entry(dev, &bus->devices, bus_list)
>> if (PCI_SLOT(dev->devfn) == slot->device) {
>> ret = pci_dev_get(dev);
>> break;
>> }
>> up_read(&pci_bus_sem);
>>
>
> acpiphp is ok.
>
> dev_in_slot will restart from bus->devices again every time.
Actually I had another version to fix the problem, but I did not even
try to compile
and to test it after i figured out that mlx4_core like to VF get stopped before
PF's driver.
Thanks
Yinghai
[-- Attachment #2: fix_cx3_hotplug_1x.patch --]
[-- Type: application/octet-stream, Size: 1420 bytes --]
---
drivers/pci/hotplug/pciehp_pci.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
Index: linux-2.6/drivers/pci/hotplug/pciehp_pci.c
===================================================================
--- linux-2.6.orig/drivers/pci/hotplug/pciehp_pci.c
+++ linux-2.6/drivers/pci/hotplug/pciehp_pci.c
@@ -76,12 +76,28 @@ int pciehp_configure_device(struct slot
return 0;
}
+/* return one device on bus, acquiring a reference on it */
+static struct pci_dev *one_dev_on_bus(struct pci_bus *bus)
+{
+ struct pci_dev *dev;
+ struct pci_dev *ret = NULL;
+
+ down_read(&pci_bus_sem);
+ list_for_each_entry(dev, &bus->devices, bus_list) {
+ ret = pci_dev_get(dev);
+ break;
+ }
+ up_read(&pci_bus_sem);
+
+ return ret;
+}
+
int pciehp_unconfigure_device(struct slot *p_slot)
{
int ret, rc = 0;
u8 bctl = 0;
u8 presence = 0;
- struct pci_dev *dev, *temp;
+ struct pci_dev *dev;
struct pci_bus *parent = p_slot->ctrl->pcie->port->subordinate;
u16 command;
struct controller *ctrl = p_slot->ctrl;
@@ -92,8 +108,7 @@ int pciehp_unconfigure_device(struct slo
if (ret)
presence = 0;
- list_for_each_entry_safe(dev, temp, &parent->devices, bus_list) {
- pci_dev_get(dev);
+ while (dev = one_dev_on_bus(parent)) {
if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE && presence) {
pci_read_config_byte(dev, PCI_BRIDGE_CONTROL, &bctl);
if (bctl & PCI_BRIDGE_CTL_VGA) {
next prev parent reply other threads:[~2013-07-24 2:15 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-19 19:14 [PATCH] PCI: Fix hotplug remove with sriov again Yinghai Lu
2013-07-19 19:14 ` [PATCH] PCI: Separate stop and remove devices in pciehp Yinghai Lu
2013-07-22 21:23 ` Bjorn Helgaas
2013-07-23 2:32 ` Yinghai Lu
2013-07-23 15:56 ` Bjorn Helgaas
2013-07-23 22:44 ` Yinghai Lu
2013-07-23 23:15 ` Yinghai Lu
2013-07-24 4:00 ` Yijing Wang
2013-07-26 22:05 ` Bjorn Helgaas
2013-07-27 14:30 ` Yinghai Lu
2013-07-19 19:14 ` [PATCH] PCI: Stop sriov before remove PF Yinghai Lu
2013-07-19 21:46 ` Alexander Duyck
2013-07-19 22:44 ` Yinghai Lu
2013-07-19 23:22 ` Alexander Duyck
2013-07-23 15:34 ` Don Dutile
2013-07-23 16:10 ` Yinghai Lu
2013-07-22 23:15 ` Bjorn Helgaas
2013-07-23 1:59 ` Yinghai Lu
2013-07-22 7:07 ` [PATCH] PCI: Fix hotplug remove with sriov again Yijing Wang
2013-07-22 17:39 ` Bjorn Helgaas
2013-07-22 17:48 ` Yinghai Lu
2013-07-23 17:40 ` Bjorn Helgaas
2013-07-24 2:01 ` Yijing Wang
2013-07-24 2:04 ` Yinghai Lu
2013-07-24 2:15 ` Yinghai Lu [this message]
2013-07-24 2:25 ` Yijing Wang
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=CAE9FiQVBfx_nyyna-9Xn+769fqqmMMMiNUwcacf4dA1iaZj6jw@mail.gmail.com \
--to=yinghai@kernel.org \
--cc=bhelgaas@google.com \
--cc=linux-pci@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=wangyijing@huawei.com \
/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).