Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1243107

Re: [Patch v6 4/7] PCI/ACPI: Consolidate common PCI host bridge code into ACPI core

Path csiph.com!fu-berlin.de!bofh.it!news.nic.it!robomod
From Jiang Liu <jiang.liu@linux.intel.com>
Newsgroups linux.kernel
Subject Re: [Patch v6 4/7] PCI/ACPI: Consolidate common PCI host bridge code into ACPI core
Date Fri, 09 Oct 2015 10:20:02 +0200
Message-ID <qhB4e-4TO-13@gated-at.bofh.it> (permalink)
References <q8wZP-lk-3@gated-at.bofh.it> <q8wZR-lk-31@gated-at.bofh.it> <qgExc-4Ib-23@gated-at.bofh.it> <qhc5R-2yA-13@gated-at.bofh.it> <qhjqH-4LW-29@gated-at.bofh.it>
X-Original-To Bjorn Helgaas <helgaas@kernel.org>
X-Extloop1 1
X-Ironport-Av E=Sophos;i="5.17,657,1437462000"; d="scan'208";a="822812429"
Organization Intel
User-Agent Mozilla/5.0 (Windows NT 6.2; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0
MIME-Version 1.0
Content-Type text/plain; charset=windows-1252
Content-Transfer-Encoding 7bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 86
X-Original-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
X-Original-Date Fri, 9 Oct 2015 16:19:45 +0800
X-Original-Message-ID <561778A1.6000408@linux.intel.com>
X-Original-References <1442218057-4355-1-git-send-email-jiang.liu@linux.intel.com> <1442218057-4355-5-git-send-email-jiang.liu@linux.intel.com> <20151006174725.GA29420@localhost> <5615FFD4.3090202@linux.intel.com> <20151008132010.GI27633@localhost>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1243107

Show key headers only | View raw


On 2015/10/8 21:20, Bjorn Helgaas wrote:
> 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).
Hi Bjorn,
	How about this solution?
1) export acpi_pci_probe_root_resources() as a helper to arch code
2) change ACPI core code as below
        if (ops->init_info && ops->init_info(info))
                goto out_release_info;
        if (ops->prepare_resources)
                ret = ops->prepare_resources(info);
        else
                ret = acpi_pci_probe_root_resources(info);
        if (ret < 0)
                goto out_release_info;

        pci_acpi_root_add_resources(info);
        pci_add_resource(&info->resources, &root->secondary);
        bus = pci_create_root_bus(NULL, busnum, ops->pci_ops,
                                  sysdata, &info->resources);
        if (!bus)
                goto out_release_info;

By this way, if arch has special requirement, it could implement
prepare_resources callback and make use of
acpi_pci_probe_root_resources() if needed.
Thanks!
Gerry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: [Patch v6 4/7] PCI/ACPI: Consolidate common PCI host bridge code  into ACPI core Bjorn Helgaas <helgaas@kernel.org> - 2015-10-06 19:50 +0200
  Re: [Patch v6 4/7] PCI/ACPI: Consolidate common PCI host bridge code  into ACPI core Jiang Liu <jiang.liu@linux.intel.com> - 2015-10-08 07:40 +0200
    Re: [Patch v6 4/7] PCI/ACPI: Consolidate common PCI host bridge code  into ACPI core Bjorn Helgaas <helgaas@kernel.org> - 2015-10-08 15:30 +0200
      Re: [Patch v6 4/7] PCI/ACPI: Consolidate common PCI host bridge code  into ACPI core Jiang Liu <jiang.liu@linux.intel.com> - 2015-10-09 10:20 +0200

csiph-web