From: wangyijing <wangyijing@huawei.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: bhelgaas@google.com, rjw@rjwysocki.net,
linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: release pci_host_bridge resource after remove root bus
Date: Thu, 25 Aug 2016 16:01:27 +0800 [thread overview]
Message-ID: <57BEA5D7.6090007@huawei.com> (raw)
In-Reply-To: <20160824213921.GH23914@localhost>
>>>> 1. For pci devices, we would release their resources in
>>>> pci_destroy_dev() regardless of pci device refcount.
>>>> 2. When we try to remove pci root bus, there is no devices
>>>> need to use the pci_host_bridge resources again, release
>>>> pci_host_bridge resources is safe.
>>>> 3. In some cases, users woule make mistake, for example,
>>>> user get a pci device(increase refcount), but forget to
>>>> put this device, then if we do hotplug pci root bus,
>>>> it would make all pci devices cannot work after hot add.
>>>
>>> Can you explain this a little more? Are you talking about a *driver*
>>> that forgets to put the device?
>>
>> Yes, may some pci drivers make a mistake, the refcount control the device object
>> release is fine, but I think move the mem resource release out is better.
>
> If this is caused by driver bugs, I think we need to fix the driver
> bugs.
Agree, but it's better if pci root bus hotplug could work well regardless of the drviers' bug.
After we stop all pci devices, I think no one could uses the resources again,
it's no need to free host bridge resource until its refcount reach 0.
But this is just my personal opinion :)
>
> So far all I see here is "it works when I do this." What we need is
> an argument for "it's correct to do this." It's certainly possible
> that you're already making that argument and I'm just not
> understanding it.
>
>>>> I found this issue in the following case:
>>>> 1. I have a raid pci device in my system;
>>>> 2. I mount a disk which connect to this raid.
>>>> 3. hot remove the pci root bus.
>>>> 4. hot add the pci root bus.
>>>> 5. found the resource conflicts for the children pci devices under this root bus.
>>>>
>>>> pci_root_bus increase a refcount at pci_host_bridge.
>>>> pci_root_bus decrease a refcount at pci_host_bridge in
>>>> release_pcibus_dev() when pci_root_bus device refcount reach 0.
>>>>
>>>> pci_dev increase a refcount at pci_bus in pci_alloc_dev().
>>>> pci_dev decrease a refcount at pci_bus in pci_release_dev()
>>>> when pci_dev refcount reach 0.
>>>>
>>>> If any pci device refcount cannot reach 0, then its pci_bus
>>>> refcount cannot reach 0 too, the result is pci_host_bridge
>>>> refcount cannot reach 0.
>>>
>>> .
>>>
>>
>
> .
>
WARNING: multiple messages have this Message-ID (diff)
From: wangyijing <wangyijing@huawei.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: <bhelgaas@google.com>, <rjw@rjwysocki.net>,
<linux-acpi@vger.kernel.org>, <linux-pci@vger.kernel.org>
Subject: Re: [PATCH] PCI: release pci_host_bridge resource after remove root bus
Date: Thu, 25 Aug 2016 16:01:27 +0800 [thread overview]
Message-ID: <57BEA5D7.6090007@huawei.com> (raw)
In-Reply-To: <20160824213921.GH23914@localhost>
>>>> 1. For pci devices, we would release their resources in
>>>> pci_destroy_dev() regardless of pci device refcount.
>>>> 2. When we try to remove pci root bus, there is no devices
>>>> need to use the pci_host_bridge resources again, release
>>>> pci_host_bridge resources is safe.
>>>> 3. In some cases, users woule make mistake, for example,
>>>> user get a pci device(increase refcount), but forget to
>>>> put this device, then if we do hotplug pci root bus,
>>>> it would make all pci devices cannot work after hot add.
>>>
>>> Can you explain this a little more? Are you talking about a *driver*
>>> that forgets to put the device?
>>
>> Yes, may some pci drivers make a mistake, the refcount control the device object
>> release is fine, but I think move the mem resource release out is better.
>
> If this is caused by driver bugs, I think we need to fix the driver
> bugs.
Agree, but it's better if pci root bus hotplug could work well regardless of the drviers' bug.
After we stop all pci devices, I think no one could uses the resources again,
it's no need to free host bridge resource until its refcount reach 0.
But this is just my personal opinion :)
>
> So far all I see here is "it works when I do this." What we need is
> an argument for "it's correct to do this." It's certainly possible
> that you're already making that argument and I'm just not
> understanding it.
>
>>>> I found this issue in the following case:
>>>> 1. I have a raid pci device in my system;
>>>> 2. I mount a disk which connect to this raid.
>>>> 3. hot remove the pci root bus.
>>>> 4. hot add the pci root bus.
>>>> 5. found the resource conflicts for the children pci devices under this root bus.
>>>>
>>>> pci_root_bus increase a refcount at pci_host_bridge.
>>>> pci_root_bus decrease a refcount at pci_host_bridge in
>>>> release_pcibus_dev() when pci_root_bus device refcount reach 0.
>>>>
>>>> pci_dev increase a refcount at pci_bus in pci_alloc_dev().
>>>> pci_dev decrease a refcount at pci_bus in pci_release_dev()
>>>> when pci_dev refcount reach 0.
>>>>
>>>> If any pci device refcount cannot reach 0, then its pci_bus
>>>> refcount cannot reach 0 too, the result is pci_host_bridge
>>>> refcount cannot reach 0.
>>>
>>> .
>>>
>>
>
> .
>
next prev parent reply other threads:[~2016-08-25 8:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-23 11:42 [PATCH] PCI: release pci_host_bridge resource after remove root bus Yijing Wang
2016-06-23 11:42 ` Yijing Wang
2016-07-25 1:18 ` wangyijing
2016-07-25 1:18 ` wangyijing
2016-08-22 17:28 ` Bjorn Helgaas
2016-08-23 2:22 ` wangyijing
2016-08-23 2:22 ` wangyijing
2016-08-24 21:39 ` Bjorn Helgaas
2016-08-24 21:48 ` Sinan Kaya
2016-08-25 8:16 ` wangyijing
2016-08-25 8:16 ` wangyijing
2016-08-25 8:01 ` wangyijing [this message]
2016-08-25 8:01 ` wangyijing
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=57BEA5D7.6090007@huawei.com \
--to=wangyijing@huawei.com \
--cc=bhelgaas@google.com \
--cc=helgaas@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=rjw@rjwysocki.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.