From: Bjorn Helgaas <helgaas@kernel.org>
To: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
Marc Zyngier <marc.zyngier@arm.com>,
Hanjun Guo <hanjun.guo@linaro.org>,
Liviu Dudau <Liviu.Dudau@arm.com>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Len Brown <lenb@kernel.org>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
x86@kernel.org, linux-pci@vger.kernel.org
Subject: Re: [Patch v6 4/7] PCI/ACPI: Consolidate common PCI host bridge code into ACPI core
Date: Thu, 8 Oct 2015 08:20:10 -0500 [thread overview]
Message-ID: <20151008132010.GI27633@localhost> (raw)
In-Reply-To: <5615FFD4.3090202@linux.intel.com>
On Thu, Oct 08, 2015 at 01:32:04PM +0800, Jiang Liu wrote:
> On 2015/10/7 1:47, Bjorn Helgaas wrote:
> >> +struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
> >> + struct acpi_pci_root_ops *ops,
> >> + struct acpi_pci_root_info *info,
> >> + void *sysdata)
> >> +{
> >> + int ret, busnum = root->secondary.start;
> >> + struct acpi_device *device = root->device;
> >> + int node = acpi_get_node(device->handle);
> >> + struct pci_bus *bus;
> >> +
> >> + info->root = root;
> >> + info->bridge = device;
> >> + info->ops = ops;
> >> + INIT_LIST_HEAD(&info->resources);
> >> + snprintf(info->name, sizeof(info->name), "PCI Bus %04x:%02x",
> >> + root->segment, busnum);
> >> +
> >> + if (ops->init_info && ops->init_info(info))
> >> + goto out_release_info;
> >> + ret = acpi_pci_probe_root_resources(info);
> >> + if (ops->prepare_resources)
> >> + ret = ops->prepare_resources(info, ret);
> >> + if (ret < 0)
> >> + goto out_release_info;
> >> + else if (ret > 0)
> >> + pci_acpi_root_add_resources(info);
> >
> > This is unnecessarily complicated: you set "ret", then overwrite it if
> > ops->prepare_resources. By the time you test "ret", it's messy to
> > figure out what it means.
> >
> > Both ops->prepare_resources() and pci_acpi_root_add_resources()
> > should be able to deal with empty resource lists, so can you do the
> > following instead?
> >
> > ret = acpi_pci_probe_root_resources(info);
> > if (ret < 0)
> > goto out_release_info;
>
> The original code is used to handle a special case for x86,
> where acpi_pci_probe_root_resources() fails but ops->prepare_resources()
> succeeds. For x86, PCI host bridge resources may probed by means
> other than ACPI when pci_use_crs is true (AMD and Broadcom hostbridges).
> So we can't return failure when acpi_pci_probe_root_resources() fails.
That's even worse than I thought. I take back my ack; I think this
really needs to be restructured so it does the right thing *and* reads
clearly. Having convoluted generic code to deal with an arch-specific
special case is a recipe for breakage in the future.
Maybe you can move the non-ACPI resource probing from
prepare_resources() into acpi_pci_probe_root_resources() (you could
rename it to something more generic if that helps).
> + ret = acpi_pci_probe_root_resources(info);
> + if (ops->prepare_resources)
> + ret = ops->prepare_resources(info, ret);
> + if (ret < 0)
> + goto out_release_info;
>
> > if (ops->prepare_resources) {
> > ret = ops->prepare_resources(info, ret);
> > if (ret < 0)
> > goto out_release_info;
> > }
> > pci_acpi_root_add_resources(info);
> I will remove the redundant check of (ret > 0) in:
> + else if (ret > 0)
> + pci_acpi_root_add_resources(info);
next prev parent reply other threads:[~2015-10-08 13:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-14 8:07 [Patch v6 0/7] Consolidate ACPI PCI root common code into ACPI core Jiang Liu
2015-09-14 8:07 ` [Patch v6 1/7] ACPI/PCI: Enhance ACPI core to support sparse IO space Jiang Liu
2015-09-14 8:07 ` [Patch v6 2/7] ia64/PCI/ACPI: Use common ACPI resource parsing interface for host bridge Jiang Liu
2015-09-14 8:07 ` [Patch v6 3/7] ia64/PCI: Use common struct resource_entry to replace struct iospace_resource Jiang Liu
2015-09-14 8:07 ` [Patch v6 4/7] PCI/ACPI: Consolidate common PCI host bridge code into ACPI core Jiang Liu
2015-10-06 17:47 ` Bjorn Helgaas
2015-10-08 5:32 ` Jiang Liu
2015-10-08 13:20 ` Bjorn Helgaas [this message]
2015-10-09 8:19 ` Jiang Liu
2015-09-14 8:07 ` [Patch v6 5/7] ACPI, PCI: Reset acpi_root_dev->domain to 0 when pci_ignore_seg is set Jiang Liu
2015-10-06 17:54 ` Bjorn Helgaas
2015-09-14 8:07 ` [Patch v6 6/7] x86/PCI/ACPI: Use common interface to support PCI host bridge Jiang Liu
2015-10-06 18:01 ` Bjorn Helgaas
2015-10-07 8:52 ` Hanjun Guo
2015-10-07 12:45 ` Bjorn Helgaas
2015-09-14 8:07 ` [Patch v6 7/7] ia64/PCI/ACPI: " Jiang Liu
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=20151008132010.GI27633@localhost \
--to=helgaas@kernel.org \
--cc=Liviu.Dudau@arm.com \
--cc=bhelgaas@google.com \
--cc=hanjun.guo@linaro.org \
--cc=jiang.liu@linux.intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=marc.zyngier@arm.com \
--cc=rafael.j.wysocki@intel.com \
--cc=rjw@rjwysocki.net \
--cc=x86@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).