From mboxrd@z Thu Jan 1 00:00:00 1970 From: Suravee Suthikulpanit Subject: Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus() Date: Sat, 21 Mar 2015 18:21:55 -0500 Message-ID: <550DFD13.9080505@amd.com> References: <1425868467-9667-1-git-send-email-wangyijing@huawei.com> <1425868467-9667-10-git-send-email-wangyijing@huawei.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1425868467-9667-10-git-send-email-wangyijing@huawei.com> Sender: linux-m68k-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: Yijing Wang , Bjorn Helgaas Cc: Jiang Liu , linux-pci@vger.kernel.org, Yinghai Lu , linux-kernel@vger.kernel.org, Marc Zyngier , linux-arm-kernel@lists.infradead.org, Russell King , x86@kernel.org, Thomas Gleixner , Benjamin Herrenschmidt , Rusty Russell , Tony Luck , linux-ia64@vger.kernel.org, "David S. Miller" , Guan Xuetao , linux-alpha@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Liviu Dudau , Arnd Bergmann , Geert Uytterhoeven On 3/8/15 21:34, Yijing Wang wrote: > This patch separate pci_host_bridge creation out > of pci_create_root_bus(), and try to make a generic > pci_host_bridge, then we could place generic PCI > infos like domain number in it. Also Ripping out > pci_host_bridge creation from pci_create_root_bus() > make code more better readability. Further more, > we could use the generic pci_host_bridge to hold > host bridge specific operations like > pcibios_root_bridge_prepare(). The changes are > transparent to platform host bridge drivers. > > Signed-off-by: Yijing Wang > Signed-off-by: Bjorn Helgaas > --- > drivers/pci/host-bridge.c | 55 ++++++++++++++++++++++ > drivers/pci/pci.h | 3 + > drivers/pci/probe.c | 114 ++++++++++++++++++++------------------------- > include/linux/pci.h | 1 + > 4 files changed, 109 insertions(+), 64 deletions(-) > > diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c > index 39b2dbe..3bd45e7 100644 > --- a/drivers/pci/host-bridge.c > +++ b/drivers/pci/host-bridge.c > @@ -8,6 +8,61 @@ > > #include "pci.h" > > +static void pci_release_host_bridge_dev(struct device *dev) > +{ > + struct pci_host_bridge *bridge = to_pci_host_bridge(dev); > + > + if (bridge->release_fn) > + bridge->release_fn(bridge); > + > + pci_free_resource_list(&bridge->windows); > + kfree(bridge); > +} > + > +struct pci_host_bridge *pci_create_host_bridge( > + struct device *parent, u32 db, struct list_head *resources) > +{ > + int error; > + int bus = PCI_BUSNUM(db); > + int domain = PCI_DOMAIN(db); > + struct pci_host_bridge *host; > + struct resource_entry *window, *n; > + > + host = kzalloc(sizeof(*host), GFP_KERNEL); > + if (!host) > + return NULL; > + > + host->busnum = bus; > + host->domain = domain; > + /* If support CONFIG_PCI_DOMAINS_GENERIC, use > + * pci_host_assign_domain_nr() to assign domain > + * number instead PCI_DOMAIN(db). > + */ > + pci_host_assign_domain_nr(host); At this point, host->dev.parent has not been assigned. However, when calling pci_host_assign_domain_nr(host), it calls pci_assign_domain_nr(host->dev.parent), which uses parent->of_node directly w/o checking if parent is NULL. This ended up causing NULL pointer exception when I do the test. I think we need to moveo host->dev.parent = parent before calling pci_host_assign_domain_nr(host). Thanks, Suravee From mboxrd@z Thu Jan 1 00:00:00 1970 From: Suravee Suthikulpanit Date: Sat, 21 Mar 2015 23:21:55 +0000 Subject: Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus() Message-Id: <550DFD13.9080505@amd.com> List-Id: References: <1425868467-9667-1-git-send-email-wangyijing@huawei.com> <1425868467-9667-10-git-send-email-wangyijing@huawei.com> In-Reply-To: <1425868467-9667-10-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Yijing Wang , Bjorn Helgaas Cc: Jiang Liu , linux-pci@vger.kernel.org, Yinghai Lu , linux-kernel@vger.kernel.org, Marc Zyngier , linux-arm-kernel@lists.infradead.org, Russell King , x86@kernel.org, Thomas Gleixner , Benjamin Herrenschmidt , Rusty Russell , Tony Luck , linux-ia64@vger.kernel.org, "David S. Miller" , Guan Xuetao , linux-alpha@vger.kernel.org, linux-m68k@vger.kernel.org, Liviu Dudau , Arnd Bergmann , Geert Uytterhoeven On 3/8/15 21:34, Yijing Wang wrote: > This patch separate pci_host_bridge creation out > of pci_create_root_bus(), and try to make a generic > pci_host_bridge, then we could place generic PCI > infos like domain number in it. Also Ripping out > pci_host_bridge creation from pci_create_root_bus() > make code more better readability. Further more, > we could use the generic pci_host_bridge to hold > host bridge specific operations like > pcibios_root_bridge_prepare(). The changes are > transparent to platform host bridge drivers. > > Signed-off-by: Yijing Wang > Signed-off-by: Bjorn Helgaas > --- > drivers/pci/host-bridge.c | 55 ++++++++++++++++++++++ > drivers/pci/pci.h | 3 + > drivers/pci/probe.c | 114 ++++++++++++++++++++------------------------- > include/linux/pci.h | 1 + > 4 files changed, 109 insertions(+), 64 deletions(-) > > diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c > index 39b2dbe..3bd45e7 100644 > --- a/drivers/pci/host-bridge.c > +++ b/drivers/pci/host-bridge.c > @@ -8,6 +8,61 @@ > > #include "pci.h" > > +static void pci_release_host_bridge_dev(struct device *dev) > +{ > + struct pci_host_bridge *bridge = to_pci_host_bridge(dev); > + > + if (bridge->release_fn) > + bridge->release_fn(bridge); > + > + pci_free_resource_list(&bridge->windows); > + kfree(bridge); > +} > + > +struct pci_host_bridge *pci_create_host_bridge( > + struct device *parent, u32 db, struct list_head *resources) > +{ > + int error; > + int bus = PCI_BUSNUM(db); > + int domain = PCI_DOMAIN(db); > + struct pci_host_bridge *host; > + struct resource_entry *window, *n; > + > + host = kzalloc(sizeof(*host), GFP_KERNEL); > + if (!host) > + return NULL; > + > + host->busnum = bus; > + host->domain = domain; > + /* If support CONFIG_PCI_DOMAINS_GENERIC, use > + * pci_host_assign_domain_nr() to assign domain > + * number instead PCI_DOMAIN(db). > + */ > + pci_host_assign_domain_nr(host); At this point, host->dev.parent has not been assigned. However, when calling pci_host_assign_domain_nr(host), it calls pci_assign_domain_nr(host->dev.parent), which uses parent->of_node directly w/o checking if parent is NULL. This ended up causing NULL pointer exception when I do the test. I think we need to moveo host->dev.parent = parent before calling pci_host_assign_domain_nr(host). Thanks, Suravee From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-bn1on0114.outbound.protection.outlook.com ([157.56.110.114]:33616 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751778AbbCUXWI (ORCPT ); Sat, 21 Mar 2015 19:22:08 -0400 Message-ID: <550DFD13.9080505@amd.com> Date: Sat, 21 Mar 2015 18:21:55 -0500 From: Suravee Suthikulpanit MIME-Version: 1.0 To: Yijing Wang , Bjorn Helgaas CC: Jiang Liu , , Yinghai Lu , , Marc Zyngier , , Russell King , , Thomas Gleixner , Benjamin Herrenschmidt , Rusty Russell , Tony Luck , , "David S. Miller" , "Guan Xuetao" , , , Liviu Dudau , "Arnd Bergmann" , Geert Uytterhoeven Subject: Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus() References: <1425868467-9667-1-git-send-email-wangyijing@huawei.com> <1425868467-9667-10-git-send-email-wangyijing@huawei.com> In-Reply-To: <1425868467-9667-10-git-send-email-wangyijing@huawei.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Sender: linux-pci-owner@vger.kernel.org List-ID: On 3/8/15 21:34, Yijing Wang wrote: > This patch separate pci_host_bridge creation out > of pci_create_root_bus(), and try to make a generic > pci_host_bridge, then we could place generic PCI > infos like domain number in it. Also Ripping out > pci_host_bridge creation from pci_create_root_bus() > make code more better readability. Further more, > we could use the generic pci_host_bridge to hold > host bridge specific operations like > pcibios_root_bridge_prepare(). The changes are > transparent to platform host bridge drivers. > > Signed-off-by: Yijing Wang > Signed-off-by: Bjorn Helgaas > --- > drivers/pci/host-bridge.c | 55 ++++++++++++++++++++++ > drivers/pci/pci.h | 3 + > drivers/pci/probe.c | 114 ++++++++++++++++++++------------------------- > include/linux/pci.h | 1 + > 4 files changed, 109 insertions(+), 64 deletions(-) > > diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c > index 39b2dbe..3bd45e7 100644 > --- a/drivers/pci/host-bridge.c > +++ b/drivers/pci/host-bridge.c > @@ -8,6 +8,61 @@ > > #include "pci.h" > > +static void pci_release_host_bridge_dev(struct device *dev) > +{ > + struct pci_host_bridge *bridge = to_pci_host_bridge(dev); > + > + if (bridge->release_fn) > + bridge->release_fn(bridge); > + > + pci_free_resource_list(&bridge->windows); > + kfree(bridge); > +} > + > +struct pci_host_bridge *pci_create_host_bridge( > + struct device *parent, u32 db, struct list_head *resources) > +{ > + int error; > + int bus = PCI_BUSNUM(db); > + int domain = PCI_DOMAIN(db); > + struct pci_host_bridge *host; > + struct resource_entry *window, *n; > + > + host = kzalloc(sizeof(*host), GFP_KERNEL); > + if (!host) > + return NULL; > + > + host->busnum = bus; > + host->domain = domain; > + /* If support CONFIG_PCI_DOMAINS_GENERIC, use > + * pci_host_assign_domain_nr() to assign domain > + * number instead PCI_DOMAIN(db). > + */ > + pci_host_assign_domain_nr(host); At this point, host->dev.parent has not been assigned. However, when calling pci_host_assign_domain_nr(host), it calls pci_assign_domain_nr(host->dev.parent), which uses parent->of_node directly w/o checking if parent is NULL. This ended up causing NULL pointer exception when I do the test. I think we need to moveo host->dev.parent = parent before calling pci_host_assign_domain_nr(host). Thanks, Suravee From mboxrd@z Thu Jan 1 00:00:00 1970 From: Suravee.Suthikulpanit@amd.com (Suravee Suthikulpanit) Date: Sat, 21 Mar 2015 18:21:55 -0500 Subject: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus() In-Reply-To: <1425868467-9667-10-git-send-email-wangyijing@huawei.com> References: <1425868467-9667-1-git-send-email-wangyijing@huawei.com> <1425868467-9667-10-git-send-email-wangyijing@huawei.com> Message-ID: <550DFD13.9080505@amd.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 3/8/15 21:34, Yijing Wang wrote: > This patch separate pci_host_bridge creation out > of pci_create_root_bus(), and try to make a generic > pci_host_bridge, then we could place generic PCI > infos like domain number in it. Also Ripping out > pci_host_bridge creation from pci_create_root_bus() > make code more better readability. Further more, > we could use the generic pci_host_bridge to hold > host bridge specific operations like > pcibios_root_bridge_prepare(). The changes are > transparent to platform host bridge drivers. > > Signed-off-by: Yijing Wang > Signed-off-by: Bjorn Helgaas > --- > drivers/pci/host-bridge.c | 55 ++++++++++++++++++++++ > drivers/pci/pci.h | 3 + > drivers/pci/probe.c | 114 ++++++++++++++++++++------------------------- > include/linux/pci.h | 1 + > 4 files changed, 109 insertions(+), 64 deletions(-) > > diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c > index 39b2dbe..3bd45e7 100644 > --- a/drivers/pci/host-bridge.c > +++ b/drivers/pci/host-bridge.c > @@ -8,6 +8,61 @@ > > #include "pci.h" > > +static void pci_release_host_bridge_dev(struct device *dev) > +{ > + struct pci_host_bridge *bridge = to_pci_host_bridge(dev); > + > + if (bridge->release_fn) > + bridge->release_fn(bridge); > + > + pci_free_resource_list(&bridge->windows); > + kfree(bridge); > +} > + > +struct pci_host_bridge *pci_create_host_bridge( > + struct device *parent, u32 db, struct list_head *resources) > +{ > + int error; > + int bus = PCI_BUSNUM(db); > + int domain = PCI_DOMAIN(db); > + struct pci_host_bridge *host; > + struct resource_entry *window, *n; > + > + host = kzalloc(sizeof(*host), GFP_KERNEL); > + if (!host) > + return NULL; > + > + host->busnum = bus; > + host->domain = domain; > + /* If support CONFIG_PCI_DOMAINS_GENERIC, use > + * pci_host_assign_domain_nr() to assign domain > + * number instead PCI_DOMAIN(db). > + */ > + pci_host_assign_domain_nr(host); At this point, host->dev.parent has not been assigned. However, when calling pci_host_assign_domain_nr(host), it calls pci_assign_domain_nr(host->dev.parent), which uses parent->of_node directly w/o checking if parent is NULL. This ended up causing NULL pointer exception when I do the test. I think we need to moveo host->dev.parent = parent before calling pci_host_assign_domain_nr(host). Thanks, Suravee From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751822AbbCUXWR (ORCPT ); Sat, 21 Mar 2015 19:22:17 -0400 Received: from mail-bn1on0114.outbound.protection.outlook.com ([157.56.110.114]:33616 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751778AbbCUXWI (ORCPT ); Sat, 21 Mar 2015 19:22:08 -0400 X-WSS-ID: 0NLL4WL-07-639-02 X-M-MSG: Message-ID: <550DFD13.9080505@amd.com> Date: Sat, 21 Mar 2015 18:21:55 -0500 From: Suravee Suthikulpanit User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Yijing Wang , Bjorn Helgaas CC: Jiang Liu , , Yinghai Lu , , Marc Zyngier , , Russell King , , Thomas Gleixner , Benjamin Herrenschmidt , Rusty Russell , Tony Luck , , "David S. Miller" , "Guan Xuetao" , , , Liviu Dudau , "Arnd Bergmann" , Geert Uytterhoeven Subject: Re: [PATCH v6 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus() References: <1425868467-9667-1-git-send-email-wangyijing@huawei.com> <1425868467-9667-10-git-send-email-wangyijing@huawei.com> In-Reply-To: <1425868467-9667-10-git-send-email-wangyijing@huawei.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.180.168.240] X-EOPAttributedMessage: 0 Authentication-Results: spf=none (sender IP is 165.204.84.221) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; arm.com; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:165.204.84.221;CTRY:US;IPV:NLI;EFV:NLI;BMV:1;SFV:NSPM;SFS:(10019020)(6009001)(428002)(479174004)(199003)(24454002)(164054003)(189002)(47776003)(65806001)(86362001)(106466001)(50466002)(92566002)(33656002)(64126003)(65956001)(80316001)(36756003)(101416001)(2950100001)(83506001)(19580405001)(87936001)(54356999)(65816999)(46102003)(77156002)(105586002)(23746002)(62966003)(77096005)(19580395003)(50986999)(76176999);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR02MB1299;H:atltwp01.amd.com;FPR:;SPF:None;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR02MB1299;UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR02MB1283; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(5002010);SRVR:BY2PR02MB1299;BCL:0;PCL:0;RULEID:;SRVR:BY2PR02MB1299; X-Forefront-PRVS: 05220145DE X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2015 23:21:59.0680 (UTC) X-MS-Exchange-CrossTenant-Id: fde4dada-be84-483f-92cc-e026cbee8e96 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fde4dada-be84-483f-92cc-e026cbee8e96;Ip=[165.204.84.221];Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR02MB1299 X-OriginatorOrg: amd4.onmicrosoft.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/8/15 21:34, Yijing Wang wrote: > This patch separate pci_host_bridge creation out > of pci_create_root_bus(), and try to make a generic > pci_host_bridge, then we could place generic PCI > infos like domain number in it. Also Ripping out > pci_host_bridge creation from pci_create_root_bus() > make code more better readability. Further more, > we could use the generic pci_host_bridge to hold > host bridge specific operations like > pcibios_root_bridge_prepare(). The changes are > transparent to platform host bridge drivers. > > Signed-off-by: Yijing Wang > Signed-off-by: Bjorn Helgaas > --- > drivers/pci/host-bridge.c | 55 ++++++++++++++++++++++ > drivers/pci/pci.h | 3 + > drivers/pci/probe.c | 114 ++++++++++++++++++++------------------------- > include/linux/pci.h | 1 + > 4 files changed, 109 insertions(+), 64 deletions(-) > > diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c > index 39b2dbe..3bd45e7 100644 > --- a/drivers/pci/host-bridge.c > +++ b/drivers/pci/host-bridge.c > @@ -8,6 +8,61 @@ > > #include "pci.h" > > +static void pci_release_host_bridge_dev(struct device *dev) > +{ > + struct pci_host_bridge *bridge = to_pci_host_bridge(dev); > + > + if (bridge->release_fn) > + bridge->release_fn(bridge); > + > + pci_free_resource_list(&bridge->windows); > + kfree(bridge); > +} > + > +struct pci_host_bridge *pci_create_host_bridge( > + struct device *parent, u32 db, struct list_head *resources) > +{ > + int error; > + int bus = PCI_BUSNUM(db); > + int domain = PCI_DOMAIN(db); > + struct pci_host_bridge *host; > + struct resource_entry *window, *n; > + > + host = kzalloc(sizeof(*host), GFP_KERNEL); > + if (!host) > + return NULL; > + > + host->busnum = bus; > + host->domain = domain; > + /* If support CONFIG_PCI_DOMAINS_GENERIC, use > + * pci_host_assign_domain_nr() to assign domain > + * number instead PCI_DOMAIN(db). > + */ > + pci_host_assign_domain_nr(host); At this point, host->dev.parent has not been assigned. However, when calling pci_host_assign_domain_nr(host), it calls pci_assign_domain_nr(host->dev.parent), which uses parent->of_node directly w/o checking if parent is NULL. This ended up causing NULL pointer exception when I do the test. I think we need to moveo host->dev.parent = parent before calling pci_host_assign_domain_nr(host). Thanks, Suravee