From patchwork Wed Jan 20 13:40:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 8072161 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 64DC59F818 for ; Wed, 20 Jan 2016 13:44:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 725FC204A7 for ; Wed, 20 Jan 2016 13:44:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9CF9920443 for ; Wed, 20 Jan 2016 13:44:07 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aLt1v-0007uc-6l; Wed, 20 Jan 2016 13:42:35 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aLt1s-0007tB-Jh for linux-arm-kernel@lists.infradead.org; Wed, 20 Jan 2016 13:42:33 +0000 Received: by mail-wm0-x234.google.com with SMTP id u188so185188894wmu.1 for ; Wed, 20 Jan 2016 05:42:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=0C9w0Ad+jdB0xhVBQdwenp0LE9nkgaBaY5qysW2w9aQ=; b=ghdoYLdA4/6Q4+lVjDYJpiJp7rrKqOgCJqVeMsRaOTIVCsvxCxjS/zDaEtM/w3GnIS JGQQL3emOWYYDv0fHw2WcaKMQ/jur6lDuN0e3lEMjXd/GjN1UX8+s6sSmDxAu9h+LckA NCeByU6p43MxjwZwHviXIJMDyL3MwA9gh+dzhK8OYzHnEWnHzHSojYKNxfyyFbc66xEd YUDQPs48ffYzz4wcRVEa0nx9e9Gia7Ndv8pD6we9xZ4PWQ9V4wXhaNS16TPCBUkqqNqJ rZfrg6MNR7tRRMfoyhYFqjpG1JEWwIR3w7Vazl1svdrVf21tj4YLg/FE8oJAqjcejqkx gH+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=0C9w0Ad+jdB0xhVBQdwenp0LE9nkgaBaY5qysW2w9aQ=; b=TnNhA+So3FQXMQZiW2lvlJIzTHqCOuNsuXQM4/KkeS8Pu8gazJpjR+HGWH2YGFMQTi FzwNngwpvx5b1Nptgjt+TCuqxE0xfe19fA9YevVuvhZvly/FFv+CVZkRhXFIwaX5oFEh sc5jUv9OpIkj+jHZKI4UG/+NBudCsenx5yP8fCWxxLKfkrHrK3YtNaY+wcgZ29IDhS+c 6hUcJUEJcln+9E0FAdoPpRc7Fz2ApGoiJoBMtIInmHweBqRQmNwZICA2aokrn6jmO4iM xqy0pODsMTElNkGTbLLWe/OQ2h2e3iR/Nt8E8sAWGFIYjWVx73WmX3JSkm5brkBZkWv6 KVXw== X-Gm-Message-State: ALoCoQnNSMrdzu2DnH5zebpYlStTEGCIJu9S8Qr6JorU/KRrRZYAybJmdQXM4/ZppyfiLffVQF+KFjE5JPBU1KbWYbbOSCt60g== X-Received: by 10.194.60.231 with SMTP id k7mr35792037wjr.61.1453297330369; Wed, 20 Jan 2016 05:42:10 -0800 (PST) Received: from [10.0.0.11] ([80.82.22.190]) by smtp.googlemail.com with ESMTPSA id 198sm25262652wml.22.2016.01.20.05.42.08 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Jan 2016 05:42:09 -0800 (PST) Subject: Re: [PATCH V3 11/21] pci, acpi: Move ACPI host bridge device companion assignment to core code. To: Lorenzo Pieralisi 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> From: Tomasz Nowicki Message-ID: <569F8E38.5030101@semihalf.com> Date: Wed, 20 Jan 2016 14:40:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20160120123849.GA13437@red-moon> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160120_054232_858180_E3F2A5E3 X-CRM114-Status: GOOD ( 17.60 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linaro-acpi@lists.linaro.org, linux-pci@vger.kernel.org, will.deacon@arm.com, okaya@codeaurora.org, wangyijing@huawei.com, ddaney@caviumnetworks.com, linux-acpi@vger.kernel.org, robert.richter@caviumnetworks.com, catalin.marinas@arm.com, jcm@redhat.com, arnd@arndb.de, Stefano.Stabellini@eu.citrix.com, Liviu.Dudau@arm.com, msalter@redhat.com, bhelgaas@google.com, tglx@linutronix.de, mw@semihalf.com, linux-arm-kernel@lists.infradead.org, jchandra@broadcom.com, rjw@rjwysocki.net, linux-kernel@vger.kernel.org, hanjun.guo@linaro.org, Suravee.Suthikulpanit@amd.com, jiang.liu@linux.intel.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: Thanks, Tomasz 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);