From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tomasz Nowicki Subject: Re: [PATCH V3 11/21] pci, acpi: Move ACPI host bridge device companion assignment to core code. Date: Wed, 20 Jan 2016 14:40:08 +0100 Message-ID: <569F8E38.5030101@semihalf.com> References: <1452691267-32240-1-git-send-email-tn@semihalf.com> <1452691267-32240-12-git-send-email-tn@semihalf.com> <20160119160224.GD5276@red-moon> <569F6D67.5000000@semihalf.com> <20160120123849.GA13437@red-moon> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20160120123849.GA13437@red-moon> Sender: linux-pci-owner@vger.kernel.org To: Lorenzo Pieralisi Cc: bhelgaas@google.com, arnd@arndb.de, will.deacon@arm.com, catalin.marinas@arm.com, rjw@rjwysocki.net, hanjun.guo@linaro.org, okaya@codeaurora.org, jiang.liu@linux.intel.com, Stefano.Stabellini@eu.citrix.com, robert.richter@caviumnetworks.com, mw@semihalf.com, Liviu.Dudau@arm.com, ddaney@caviumnetworks.com, tglx@linutronix.de, wangyijing@huawei.com, Suravee.Suthikulpanit@amd.com, msalter@redhat.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, jchandra@broadcom.com, jcm@redhat.com List-Id: linux-acpi@vger.kernel.org On 20.01.2016 13:38, Lorenzo Pieralisi wrote: > On Wed, Jan 20, 2016 at 12:20:07PM +0100, Tomasz Nowicki wrote: >> On 19.01.2016 17:02, Lorenzo Pieralisi wrote: >>> On Wed, Jan 13, 2016 at 02:20:57PM +0100, Tomasz Nowicki wrote: >> [...] >>>> device via pci_create_root_bus parameter (as the ACPI device type) >>> >>> I do not understand what you mean by "as the ACPI device type". >> >> See below. >> >>> >>>> and using ACPI_COMPANION_SET in core code for ACPI boot method. >>>> ACPI_COMPANION_SET is safe to run for all cases DT, ACPI and DT&ACPI. >>>> >>>> Suggested-by: Lorenzo Pieralisi >>>> Signed-off-by: Tomasz Nowicki >>>> --- >>>> drivers/acpi/pci_root.c | 5 ++++- >>>> drivers/pci/probe.c | 2 ++ >>>> 2 files changed, 6 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c >>>> index ae3fe4e..a65c8c2 100644 >>>> --- a/drivers/acpi/pci_root.c >>>> +++ b/drivers/acpi/pci_root.c >>>> @@ -846,7 +846,10 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, >>>> >>>> pci_acpi_root_add_resources(info); >>>> pci_add_resource(&info->resources, &root->secondary); >>>> - bus = pci_create_root_bus(NULL, busnum, ops->pci_ops, >>>> + >>>> + /* Root bridge device needs to be sure of parent ACPI type */ >>>> + ACPI_COMPANION_SET(&device->dev, device); >>> >>> I do not understand why the code above is needed, can you elaborate >>> please ? >>> >> >> This makes sure that device->dev can be identified as ACPI device, >> so we can use to_acpi_device_node() and assign companion safely >> below. > > I do not follow. If you refer to the fwnode handle type, that is > already set by ACPI core code (before acpi_pci_root_add() is called, > in acpi_init_device_object()). acpi_init_device_object() sets ACPI fwnode handle type only for "device", but not for "device->dev" which is what is passed as an argument to pci_create_root_bus(). Without ACPI_COMPANION_SET(&device->dev, device) here, no one can be sure if we have ACPI device in pci_create_root_bus(). > > Did you add the code above to solve a real issue you encountered ? Yes. You can try to run series with this patch: diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 88c9d20..1b74bf6 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -967,7 +967,11 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, pci_add_resource(&info->resources, &root->secondary); - /* Root bridge device needs to be sure of parent ACPI type */ - ACPI_COMPANION_SET(&device->dev, device); + if (to_acpi_device_node(device->dev.fwnode) == NULL) + pr_err("NON-ACPI TYPE\n"); + else + pr_err("ACPI TYPE\n"); + bus = pci_create_root_bus(&device->dev, busnum, ops->pci_ops, sysdata, &info->resources); Thanks, Tomasz