From: Will Deacon <will.deacon@arm.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
linux-pci@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] pci: Add support for unbinding the generic PCI host controller
Date: Fri, 24 Jun 2016 07:50:28 +0100 [thread overview]
Message-ID: <20160624065028.GG29165@arm.com> (raw)
In-Reply-To: <576CD58C.5020900@siemens.com>
On Fri, Jun 24, 2016 at 08:39:08AM +0200, Jan Kiszka wrote:
> On 2016-06-24 08:12, Will Deacon wrote:
> > On Thu, Jun 23, 2016 at 07:31:34PM +0200, Jan Kiszka wrote:
> >> On 2016-06-22 08:06, Will Deacon wrote:
> >>> - The probe path seems to have some stateful operations outside of PCI
> >>> resources. For example, kzalloc'ing the bus_range resource in
> >>> of_pci_get_host_bridge_resources. Do we need to clean these up
> >>> explicitly?
> >>>
> >>> - Similarly, we don't seem to tear-down the config space mappings and
> >>> data structures for that, so we leak VA space afaict.
> >>>
> >>
> >> Good points. But to my understanding, everything is released
> >> automatically on pci_remove_root_bus because all the resources are
> >> registered with the bus which takes care of them during destruction. And
> >> if I trace the release, I find this e.g.
> >>
> >> ...
> >> devres_release_all() {
> >> _raw_spin_lock_irqsave();
> >> release_nodes() {
> >> _raw_spin_unlock_irqrestore();
> >> devm_action_release() {
> >> gen_pci_unmap_cfg() {
> >
> > Ah, thanks for investigating that -- I completely missed the explicit
> > devm_ callback. That resolves my concern about the config space mappings,
> > but I still don't understand what happens to the resources allocated
> > in of_pci_get_host_bridge_resources. It looks like they should actually
> > be freed within that function, since pci_add_resource{_offset} copy the
> > resources into their own resource_entries anyway.
> >
> > Am I missing something?
>
> Tracing kmalloc and kfree in addition, it seems you are right. But then
> we already have leaks in the code in case the setup fails somewhere in
> the middle, no? gen_pci_init only releases the resource list on errors,
> but not bus_range. And pci_host_common_probe does non of both if
> pci_scan_root_bus fails. Anything else?
Yeah, it's a right old mess. of_pci_get_host_bridge_resources even cleans
up after itself, but gen_pci_init can fail in other ways and then doesn't
clean up properly.
I wonder why of_pci_get_host_bridge_resources can't just use devm_kzalloc.
Will
next prev parent reply other threads:[~2016-06-24 6:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-21 18:07 [PATCH] pci: Add support for unbinding the generic PCI host controller Jan Kiszka
2016-06-22 6:06 ` Will Deacon
2016-06-23 17:31 ` Jan Kiszka
2016-06-24 6:12 ` Will Deacon
2016-06-24 6:39 ` Jan Kiszka
2016-06-24 6:50 ` Will Deacon [this message]
2016-08-22 17:05 ` Bjorn Helgaas
2016-08-22 17:23 ` Jan Kiszka
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=20160624065028.GG29165@arm.com \
--to=will.deacon@arm.com \
--cc=bhelgaas@google.com \
--cc=jan.kiszka@siemens.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@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).