From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751726AbbASFJO (ORCPT ); Mon, 19 Jan 2015 00:09:14 -0500 Received: from icp-osb-irony-out8.external.iinet.net.au ([203.59.1.225]:29305 "EHLO icp-osb-irony-out8.external.iinet.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750701AbbASFJM (ORCPT ); Mon, 19 Jan 2015 00:09:12 -0500 X-Greylist: delayed 560 seconds by postgrey-1.27 at vger.kernel.org; Mon, 19 Jan 2015 00:09:10 EST X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aq8CAByOvFSVhxBY/2dsb2JhbAANToc2yAGBJgKBWgEBAQEBhQoBAQQjVQEQCw0LAgIFFgsCAgkDAgECAUUGAQwBBQIBAYgTAboxcJNMAQEBAQEBAQEBAQEBAQEBAQEBGoEhjlgHgmiBQQEElCiKDYNViBCEIl2CQwEBAQ X-IronPort-AV: E=Sophos;i="5.09,424,1418054400"; d="scan'208";a="891150811" Message-ID: <54BC8F40.1080405@westnet.com.au> Date: Mon, 19 Jan 2015 14:59:44 +1000 From: Greg Ungerer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Yijing Wang , Yinghai Lu CC: Bjorn Helgaas , Jiang Liu , "linux-pci@vger.kernel.org" , Linux Kernel Mailing List , Marc Zyngier , "linux-arm-kernel@lists.infradead.org" , Russell King , the arch/x86 maintainers , Thomas Gleixner , 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 , "sparclinux@vger.kernel.org" Subject: Re: [PATCH 01/28] PCI: Rip out pci_bus_add_devices() from pci_scan_bus() References: <1421372666-12288-1-git-send-email-wangyijing@huawei.com> <1421372666-12288-2-git-send-email-wangyijing@huawei.com> <54BC6611.9020002@huawei.com> In-Reply-To: <54BC6611.9020002@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19/01/15 12:04, Yijing Wang wrote: > On 2015/1/17 7:16, Yinghai Lu wrote: >> On Fri, Jan 16, 2015 at 3:15 PM, Yinghai Lu wrote: >>> On Thu, Jan 15, 2015 at 5:43 PM, Yijing Wang wrote: >>>> Pci_bus_add_devices() should not be placed in pci_scan_bus(). >>>> Now pci device will be added to driver core once its >>>> creation. All things left in pci_bus_add_devices() are >>>> driver attachment and other trivial sysfs things. >>>> Pci_scan_bus() should be the function responsible for >>>> scanning PCI devices, not including driver attachment. >>>> Other, some callers(m68k,unicore32,alpha) of pci_scan_bus() >>>> will call pci_bus_size_bridges() and pci_bus_assign_resources() >>>> after pci_scan_bus(). >>>> >>>> E.g. >>>> In m68k >>>> mcf_pci_init() >>>> pci_scan_bus() >>>> ... >>>> pci_bus_add_devices() --- try to attach driver >>>> pci_fixup_irqs() >>>> pci_bus_size_bridges() >>>> pci_bus_assign_resources() >>>> >>>> It is not correct, resources should be assigned correctly >>>> before attaching driver. >>> >> No, for booting path, at that time pci drivers are *NOT* loaded yet. > > Hi Yinghai, I knew code flow here would not cause problems, sorry the log > confused you, I will refresh it. But I think pci_scan_bus()/pci_scan_root_bus() > which could only be used during system boot up(before module_init) make > the pci scan logic obscure. Because most callers additionally call > pci_bus_size_bridges() and pci_bus_assign_resources() later, > so rip out pci_bus_add_devices() from pci_scan_bus()/pci_scan_root_bus() > make code have better readability. I agree that ordering seems odd. I recall there was a reason I had to put it in that order (at that time - which is a few years back now). I can't remember exactly now, but it was something like bridges didn't get resourced properly without a pci scan first. Regards Greg